Open History to see the last commit
1import {
2 EventId,
3 ProviderDriverKind,
4 RuntimeRequestId,
5 ThreadId,
6 type ProviderRuntimeEvent,
7} from "@t3tools/contracts";
8import { describe, expect, it } from "vite-plus/test";
9
10import { runtimeEventToActivities } from "./ProviderRuntimeIngestion.ts";
11
12describe("runtimeEventToActivities approval details", () => {
13 it("preserves complete multiline command details", () => {
14 const detail = `bun run release -- ${"long-argument ".repeat(20)}\nsecond line`;
15 const event = {
16 type: "request.opened",
17 eventId: EventId.make("evt-request-opened"),
18 provider: ProviderDriverKind.make("codex"),
19 createdAt: "2026-07-18T00:00:00.000Z",
20 threadId: ThreadId.make("thread-1"),
21 requestId: RuntimeRequestId.make("approval-1"),
22 payload: {
23 requestType: "command_execution_approval",
24 detail,
25 },
26 } satisfies ProviderRuntimeEvent;
27
28 const [activity] = runtimeEventToActivities(event);
29
30 expect(activity?.kind).toBe("approval.requested");
31 expect((activity?.payload as Record<string, unknown> | undefined)?.detail).toBe(detail);
32 });
33
34 it("keeps app details and approval options available to remote clients", () => {
35 const options = [
36 { decision: "decline", label: "Decline" },
37 { decision: "acceptAlways", label: "Always allow Safari" },
38 { decision: "accept", label: "Approve" },
39 ] as const;
40 const event = {
41 type: "request.opened",
42 eventId: EventId.make("evt-mcp-elicitation"),
43 provider: ProviderDriverKind.make("codex"),
44 createdAt: "2026-08-24T00:00:00.000Z",
45 threadId: ThreadId.make("thread-1"),
46 requestId: RuntimeRequestId.make("approval-safari"),
47 payload: {
48 requestType: "mcp_elicitation_approval",
49 detail: "Allow ChatGPT to use Safari?",
50 appName: "Safari",
51 options,
52 },
53 } satisfies ProviderRuntimeEvent;
54
55 const [activity] = runtimeEventToActivities(event);
56
57 expect(activity).toMatchObject({
58 kind: "approval.requested",
59 summary: "App access approval requested",
60 payload: {
61 requestId: "approval-safari",
62 requestKind: "mcp-elicitation",
63 requestType: "mcp_elicitation_approval",
64 detail: "Allow ChatGPT to use Safari?",
65 appName: "Safari",
66 options,
67 },
68 });
69 });
70});