fix(gateway): harden agent provider routing
This commit is contained in:
@@ -24,6 +24,7 @@ import {
|
||||
resolveDefaultIMessageAccountId,
|
||||
resolveIMessageAccount,
|
||||
} from "../imessage/accounts.js";
|
||||
import { resolveMSTeamsCredentials } from "../msteams/token.js";
|
||||
import {
|
||||
type ChatProviderId,
|
||||
getChatProviderMeta,
|
||||
@@ -564,6 +565,20 @@ async function buildProviderStatusIndex(
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
const accountId = DEFAULT_ACCOUNT_ID;
|
||||
const hasCreds = Boolean(resolveMSTeamsCredentials(cfg.msteams));
|
||||
const hasConfig = Boolean(cfg.msteams);
|
||||
const enabled = cfg.msteams?.enabled !== false;
|
||||
map.set(providerAccountKey("msteams", accountId), {
|
||||
provider: "msteams",
|
||||
accountId,
|
||||
state: hasCreds ? "configured" : "not configured",
|
||||
enabled,
|
||||
configured: hasCreds || hasConfig,
|
||||
});
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -584,6 +599,8 @@ function resolveDefaultAccountId(
|
||||
return resolveDefaultSignalAccountId(cfg) || DEFAULT_ACCOUNT_ID;
|
||||
case "imessage":
|
||||
return resolveDefaultIMessageAccountId(cfg) || DEFAULT_ACCOUNT_ID;
|
||||
case "msteams":
|
||||
return DEFAULT_ACCOUNT_ID;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,10 +16,12 @@ import {
|
||||
formatUsageReportLines,
|
||||
loadProviderUsageSummary,
|
||||
} from "../../infra/provider-usage.js";
|
||||
import { resolveMSTeamsCredentials } from "../../msteams/token.js";
|
||||
import {
|
||||
type ChatProviderId,
|
||||
listChatProviders,
|
||||
} from "../../providers/registry.js";
|
||||
import { DEFAULT_ACCOUNT_ID } from "../../routing/session-key.js";
|
||||
import { defaultRuntime, type RuntimeEnv } from "../../runtime.js";
|
||||
import {
|
||||
listSignalAccountIds,
|
||||
@@ -104,6 +106,7 @@ export async function providersListCommand(
|
||||
slack: listSlackAccountIds(cfg),
|
||||
signal: listSignalAccountIds(cfg),
|
||||
imessage: listIMessageAccountIds(cfg),
|
||||
msteams: [DEFAULT_ACCOUNT_ID],
|
||||
};
|
||||
|
||||
const lineBuilders: Record<
|
||||
@@ -194,6 +197,19 @@ export async function providersListCommand(
|
||||
});
|
||||
return `- ${label}: ${formatEnabled(account.enabled)}`;
|
||||
},
|
||||
msteams: async (accountId) => {
|
||||
const label = formatProviderAccountLabel({
|
||||
provider: "msteams",
|
||||
accountId,
|
||||
providerStyle: theme.accent,
|
||||
accountStyle: theme.heading,
|
||||
});
|
||||
const configured = Boolean(resolveMSTeamsCredentials(cfg.msteams));
|
||||
const enabled = cfg.msteams?.enabled !== false;
|
||||
return `- ${label}: ${formatConfigured(configured)}, ${formatEnabled(
|
||||
enabled,
|
||||
)}`;
|
||||
},
|
||||
};
|
||||
|
||||
const authStore = loadAuthProfileStore();
|
||||
@@ -217,6 +233,7 @@ export async function providersListCommand(
|
||||
slack: accountIdsByProvider.slack,
|
||||
signal: accountIdsByProvider.signal,
|
||||
imessage: accountIdsByProvider.imessage,
|
||||
msteams: accountIdsByProvider.msteams,
|
||||
},
|
||||
auth: authProfiles,
|
||||
...(usage ? { usage } : {}),
|
||||
|
||||
@@ -42,6 +42,8 @@ function listAccountIds(cfg: ClawdbotConfig, provider: ChatProvider): string[] {
|
||||
return listSignalAccountIds(cfg);
|
||||
case "imessage":
|
||||
return listIMessageAccountIds(cfg);
|
||||
case "msteams":
|
||||
return [DEFAULT_ACCOUNT_ID];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,9 @@ import {
|
||||
} from "../../imessage/accounts.js";
|
||||
import { formatAge } from "../../infra/provider-summary.js";
|
||||
import { collectProvidersStatusIssues } from "../../infra/providers-status-issues.js";
|
||||
import { resolveMSTeamsCredentials } from "../../msteams/token.js";
|
||||
import { listChatProviders } from "../../providers/registry.js";
|
||||
import { DEFAULT_ACCOUNT_ID } from "../../routing/session-key.js";
|
||||
import { defaultRuntime, type RuntimeEnv } from "../../runtime.js";
|
||||
import {
|
||||
listSignalAccountIds,
|
||||
@@ -340,6 +342,18 @@ async function formatConfigProvidersStatusLines(
|
||||
configured: imsgConfigured,
|
||||
};
|
||||
}),
|
||||
msteams: [
|
||||
{
|
||||
accountId: DEFAULT_ACCOUNT_ID,
|
||||
enabled: cfg.msteams?.enabled !== false,
|
||||
configured: Boolean(resolveMSTeamsCredentials(cfg.msteams)),
|
||||
dmPolicy: cfg.msteams?.dmPolicy ?? "pairing",
|
||||
allowFrom: (cfg.msteams?.allowFrom ?? [])
|
||||
.map((value) => String(value ?? "").trim())
|
||||
.filter(Boolean)
|
||||
.slice(0, 2),
|
||||
},
|
||||
],
|
||||
} satisfies Partial<Record<ChatProvider, Array<Record<string, unknown>>>>;
|
||||
|
||||
// WhatsApp linked info (config-only best-effort).
|
||||
|
||||
Reference in New Issue
Block a user