UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

43 lines (42 loc) • 1.58 kB
import { a as getActiveSecretsRuntimeConfigSnapshot } from "./runtime-state-Dq_fFDZp.mjs"; import { a as resolveConfiguredGitHubHost } from "./github-host-CjR25cOO.mjs"; import { n as GitHubIdentityError } from "./github-read-identity-DyhbpOtm.mjs"; import { f as resolveConfiguredGitHubToolIdentity, s as prepareGitHubReadIdentity } from "./github-tool-identity-41SK6r8O.mjs"; import { r as requestCurrentGitHubOAuthRefresh } from "./github-oauth-lifecycle-6AnTmFkw.mjs"; //#region src/gateway/github-reader-identity.ts /** UI and agent readers share selection; each caller supplies its own live authority. */ async function prepareGitHubReaderIdentity(e, t, n) { const r = e.getRuntimeConfig(); const configuredIdentity = () => { const n = e.getRuntimeConfig(); if (resolveConfiguredGitHubHost(n) !== "github.com") return; return resolveConfiguredGitHubToolIdentity({ config: n, agentId: t, scope: "agent" }) ?? resolveConfiguredGitHubToolIdentity({ config: n, agentId: t, scope: "system" }); }; n(); const i = configuredIdentity() ? await prepareGitHubReadIdentity({ config: r, sourceConfig: getActiveSecretsRuntimeConfigSnapshot()?.sourceConfig ?? r, agentId: t, allowStale: true, getCurrentConfig: () => e.getRuntimeConfig(), assertActive: n, refresh: () => requestCurrentGitHubOAuthRefresh(t) }) : void 0; return { identity: i, assertSelected: i?.assertSelected ?? (() => { n(); if (configuredIdentity()) throw new GitHubIdentityError("changed"); }) }; } //#endregion export { prepareGitHubReaderIdentity as t };