UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

89 lines (88 loc) • 3.53 kB
import { I as readNonBlankString, a as defineChannelAliasMigration } from "./runtime-doctor-migrations-JGL9tD-z.js"; import { t as createLegacyWebhookListenerDoctorContract } from "./legacy-webhook-listener-migration-s2MKGUiS.js"; import { n as normalizeResolvedSecretInputString, r as normalizeSecretInputString } from "./types.secrets-Dt3OCDui.js"; import "./secret-input-BZwvogpO.js"; import "./string-coerce-runtime-DkwxSzQP.js"; //#region extensions/msteams/src/token-config.ts function resolveAuthType(e, t) { const n = e?.authType; if (n === "secret" || n === "federated") return n; if ((t?.allowEnvFallback === false ? void 0 : process.env.MSTEAMS_AUTH_TYPE) === "federated") return "federated"; return "secret"; } function resolveFederatedPath(e, t) { return readNonBlankString(e) ?? readNonBlankString(t); } function resolveMSTeamsAppId(e, t) { return normalizeSecretInputString(e?.appId) || (t ? normalizeSecretInputString(process.env.MSTEAMS_APP_ID) : void 0); } function resolveMSTeamsTenantId(e, t) { return normalizeSecretInputString(e?.tenantId) || (t ? normalizeSecretInputString(process.env.MSTEAMS_TENANT_ID) : void 0); } function resolveMSTeamsCredentials(e, t) { const n = t?.allowEnvFallback ?? true; const r = t?.pathPrefix ?? "channels.msteams"; const i = resolveAuthType(e, { allowEnvFallback: n }); const a = resolveMSTeamsAppId(e, n); const o = resolveMSTeamsTenantId(e, n); if (!a || !o) return; if (i === "federated") { const t = resolveFederatedPath(e?.certificatePath, n ? process.env.MSTEAMS_CERTIFICATE_PATH : void 0); const r = e?.useManagedIdentity ?? (n ? process.env.MSTEAMS_USE_MANAGED_IDENTITY === "true" : false); const i = e?.managedIdentityClientId || (n ? process.env.MSTEAMS_MANAGED_IDENTITY_CLIENT_ID : void 0) || void 0; if (!t && !r) return; return { type: "federated", appId: a, tenantId: o, certificatePath: t, useManagedIdentity: r || void 0, managedIdentityClientId: i }; } const s = normalizeResolvedSecretInputString({ value: e?.appPassword, path: `${r}.appPassword` }) || (n ? normalizeSecretInputString(process.env.MSTEAMS_APP_PASSWORD) : void 0); if (!s) return; return { type: "secret", appId: a, appPassword: s, tenantId: o }; } //#endregion //#region extensions/msteams/config-doctor-api.ts const webhookMigration = createLegacyWebhookListenerDoctorContract({ channelKey: "msteams", defaultPort: 3978, webhookKey: "webhook", portKey: "port", hostKey: null, preserveAuthoredActivation: true }); const { historicalWebhookListener } = webhookMigration; const streamingAliasMigration = defineChannelAliasMigration({ channelId: "msteams", streaming: { defaultMode: "partial" } }); const legacyConfigRules = [...webhookMigration.legacyConfigRules, ...streamingAliasMigration.legacyConfigRules]; function normalizeHistoricalWebhookConfig({ cfg: e }) { return { ...webhookMigration.normalizeCompatibilityConfig({ cfg: e }), historicalWebhookAccountIds: e.channels?.msteams === void 0 && !resolveMSTeamsCredentials() ? null : e.channels?.msteams?.enabled === false ? [] : [void 0] }; } function normalizeCompatibilityConfig({ cfg: e }) { const t = normalizeHistoricalWebhookConfig({ cfg: e }); return { ...streamingAliasMigration.normalizeChannelConfig({ cfg: t.config, changes: t.changes }), historicalWebhookAccountIds: t.historicalWebhookAccountIds }; } //#endregion export { historicalWebhookListener, legacyConfigRules, normalizeCompatibilityConfig, normalizeHistoricalWebhookConfig };