



















@@ -7,10 +7,52 @@ import {
77connectMcpClient,
88extractTextFromGatewayPayload,
99type ClaudeChannelNotification,
10+type GatewayRpcClient,
1011maybeApprovePendingBridgePairing,
1112waitFor,
1213} from "./mcp-channels-harness.ts";
131415+function summarizeSessionRows(rows: Array<Record<string, unknown>> | undefined) {
16+return (rows ?? []).map((entry) => ({
17+key: entry.key,
18+channel: entry.channel,
19+deliveryContext: entry.deliveryContext,
20+lastChannel: entry.lastChannel,
21+lastTo: entry.lastTo,
22+lastAccountId: entry.lastAccountId,
23+lastThreadId: entry.lastThreadId,
24+}));
25+}
26+27+async function waitForGatewaySeededConversation(gateway: GatewayRpcClient) {
28+let lastList: { sessions?: Array<Record<string, unknown>> } | undefined;
29+try {
30+return await waitFor(
31+"seeded conversation in gateway sessions.list",
32+async () => {
33+lastList = await gateway.request<{ sessions?: Array<Record<string, unknown>> }>(
34+"sessions.list",
35+{ limit: 50, includeDerivedTitles: true, includeLastMessage: true },
36+);
37+return lastList.sessions?.find((entry) => entry.key === "agent:main:main");
38+},
39+60_000,
40+);
41+} catch (error) {
42+throw new Error(
43+`gateway sessions.list did not include seeded conversation: ${JSON.stringify(
44+ {
45+ count: lastList?.sessions?.length ?? 0,
46+ sessions: summarizeSessionRows(lastList?.sessions),
47+ },
48+ null,
49+ 2,
50+ )}`,
51+{ cause: error },
52+);
53+}
54+}
55+1456async function main() {
1557const gatewayUrl = process.env.GW_URL?.trim();
1658const gatewayToken = process.env.GW_TOKEN?.trim();
@@ -36,6 +78,18 @@ async function main() {
3678const callTool = <T>(params: Parameters<typeof mcp.callTool>[0]) =>
3779mcp.callTool(params, undefined, { timeout: 240_000 }) as Promise<T>;
388081+const gatewayConversation = await waitForGatewaySeededConversation(gateway);
82+assert(
83+(gatewayConversation.deliveryContext as { channel?: unknown } | undefined)?.channel ===
84+"imessage",
85+"expected seeded gateway deliveryContext channel",
86+);
87+assert(
88+(gatewayConversation.deliveryContext as { to?: unknown } | undefined)?.to === "+15551234567",
89+"expected seeded gateway deliveryContext target",
90+);
91+92+let lastMcpConversationList: unknown;
3993const conversation = await waitFor(
4094"seeded conversation in conversations_list",
4195async () => {
@@ -45,12 +99,22 @@ async function main() {
4599name: "conversations_list",
46100arguments: {},
47101});
102+lastMcpConversationList = listed;
48103return listed.structuredContent?.conversations?.find(
49104(entry) => entry.sessionKey === "agent:main:main",
50105);
51106},
52107240_000,
53-);
108+).catch((error) => {
109+throw new Error(
110+`timeout waiting for seeded MCP conversation: ${JSON.stringify(
111+ lastMcpConversationList,
112+ null,
113+ 2,
114+ )}`,
115+{ cause: error },
116+);
117+});
54118assert(conversation.channel === "imessage", "expected seeded channel");
55119assert(conversation.to === "+15551234567", "expected seeded target");
56120此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。