

























@@ -1491,6 +1491,74 @@ describe("exec approval handlers", () => {
14911491}
14921492});
149314931494+it("resolves Control UI-style approvals by id while preserving stored turn-source metadata", async () => {
1495+const { handlers, forwarder, respond, context } = createForwardingExecApprovalFixture();
1496+const broadcasts: Array<{ event: string; payload: unknown }> = [];
1497+const requestContext = {
1498+ ...context,
1499+hasExecApprovalClients: () => true,
1500+broadcast: (event: string, payload: unknown) => {
1501+broadcasts.push({ event, payload });
1502+},
1503+};
1504+1505+const requestPromise = requestExecApproval({
1506+ handlers,
1507+ respond,
1508+context: requestContext,
1509+params: {
1510+id: "approval-control-ui-multichannel",
1511+twoPhase: true,
1512+timeoutMs: 60_000,
1513+host: "gateway",
1514+nodeId: undefined,
1515+systemRunPlan: undefined,
1516+sessionKey: "agent:main:feishu:chat-123",
1517+turnSourceChannel: "feishu",
1518+turnSourceTo: "chat-123",
1519+turnSourceAccountId: "work",
1520+turnSourceThreadId: "thread-456",
1521+},
1522+});
1523+await drainApprovalRequestTicks();
1524+1525+const resolveRespond = vi.fn();
1526+await resolveExecApproval({
1527+ handlers,
1528+id: "approval-control-ui-multichannel",
1529+respond: resolveRespond,
1530+context: requestContext,
1531+});
1532+await requestPromise;
1533+1534+expect(resolveRespond).toHaveBeenCalledWith(true, { ok: true }, undefined);
1535+expect(forwarder.handleResolved).toHaveBeenCalledWith(
1536+expect.objectContaining({
1537+id: "approval-control-ui-multichannel",
1538+decision: "allow-once",
1539+request: expect.objectContaining({
1540+sessionKey: "agent:main:feishu:chat-123",
1541+turnSourceChannel: "feishu",
1542+turnSourceTo: "chat-123",
1543+turnSourceAccountId: "work",
1544+turnSourceThreadId: "thread-456",
1545+}),
1546+}),
1547+);
1548+expect(broadcasts).toContainEqual(
1549+expect.objectContaining({
1550+event: "exec.approval.resolved",
1551+payload: expect.objectContaining({
1552+id: "approval-control-ui-multichannel",
1553+request: expect.objectContaining({
1554+turnSourceChannel: "feishu",
1555+turnSourceTo: "chat-123",
1556+}),
1557+}),
1558+}),
1559+);
1560+});
1561+14941562it("fast-fails approvals when no approver clients and no forwarding targets", async () => {
14951563const { manager, handlers, forwarder, respond, context } =
14961564createForwardingExecApprovalFixture();
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。