Open History to see the last commit
1#!/usr/bin/env node
2// @effect-diagnostics nodeBuiltinImport:off
3import * as NodeFS from "node:fs";
4
5import * as Effect from "effect/Effect";
6import * as Deferred from "effect/Deferred";
7
8import * as NodeServices from "@effect/platform-node/NodeServices";
9import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
10
11import * as EffectAcpAgent from "effect-acp/agent";
12import * as AcpError from "effect-acp/errors";
13import type * as AcpSchema from "effect-acp/schema";
14
15const requestLogPath = process.env.T3_ACP_REQUEST_LOG_PATH;
16const exitLogPath = process.env.T3_ACP_EXIT_LOG_PATH;
17const antigravityProfile = process.env.T3_ACP_ANTIGRAVITY === "1";
18const emitToolCalls = process.env.T3_ACP_EMIT_TOOL_CALLS === "1";
19const emitInterleavedAssistantToolCalls =
20 process.env.T3_ACP_EMIT_INTERLEAVED_ASSISTANT_TOOL_CALLS === "1";
21const emitGenericToolPlaceholders = process.env.T3_ACP_EMIT_GENERIC_TOOL_PLACEHOLDERS === "1";
22const emitAskQuestion = process.env.T3_ACP_EMIT_ASK_QUESTION === "1";
23const emitXAiAskUserQuestion = process.env.T3_ACP_EMIT_XAI_ASK_USER_QUESTION === "1";
24const emitXAiExitPlanMode = process.env.T3_ACP_EMIT_XAI_EXIT_PLAN_MODE === "1";
25const emitXAiPlanMdWrite = process.env.T3_ACP_EMIT_XAI_PLAN_MD_WRITE === "1";
26const emitXAiPromptCompleteThenHang = process.env.T3_ACP_EMIT_XAI_PROMPT_COMPLETE_THEN_HANG === "1";
27const emitXAiRateLimitThenHang = process.env.T3_ACP_EMIT_XAI_RATE_LIMIT_THEN_HANG === "1";
28const emitXAiAskUserQuestionThenHang =
29 process.env.T3_ACP_EMIT_XAI_ASK_USER_QUESTION_THEN_HANG === "1";
30const emitContentThenHang = process.env.T3_ACP_EMIT_CONTENT_THEN_HANG === "1";
31const emitPlanThenHang = process.env.T3_ACP_EMIT_PLAN_THEN_HANG === "1";
32const emitActiveToolThenHang = process.env.T3_ACP_EMIT_ACTIVE_TOOL_THEN_HANG === "1";
33const emitGrokMonitorPostTurnPoll = process.env.T3_ACP_EMIT_GROK_MONITOR_POST_TURN_POLL === "1";
34const emitGrokBackgroundTaskStarted = process.env.T3_ACP_EMIT_GROK_BACKGROUND_TASK_STARTED === "1";
35const emitForeignSessionUpdates = process.env.T3_ACP_EMIT_FOREIGN_SESSION_UPDATES === "1";
36const waitForResumeRelease = process.env.T3_ACP_WAIT_FOR_RESUME_RELEASE === "1";
37const completeFirstPromptOnCancel = process.env.T3_ACP_COMPLETE_FIRST_PROMPT_ON_CANCEL === "1";
38const floodStderr = process.env.T3_ACP_FLOOD_STDERR === "1";
39const hangPromptForever = process.env.T3_ACP_HANG_PROMPT_FOREVER === "1";
40const hangFirstPromptForever = process.env.T3_ACP_HANG_FIRST_PROMPT_FOREVER === "1";
41const emitLateUpdateAfterCancel = process.env.T3_ACP_EMIT_LATE_UPDATE_AFTER_CANCEL === "1";
42const omitXAiPromptCompleteStopReason =
43 process.env.T3_ACP_OMIT_XAI_PROMPT_COMPLETE_STOP_REASON === "1";
44const failLoadSession = process.env.T3_ACP_FAIL_LOAD_SESSION === "1";
45const emitLoadReplay = process.env.T3_ACP_EMIT_LOAD_REPLAY === "1";
46const hangLoadSessionAfterReplay = process.env.T3_ACP_HANG_LOAD_SESSION_AFTER_REPLAY === "1";
47const delayLoadSessionAfterReplay = process.env.T3_ACP_DELAY_LOAD_SESSION_AFTER_REPLAY === "1";
48const loadSessionDelayMs = Number(process.env.T3_ACP_LOAD_SESSION_DELAY_MS ?? "5000");
49const emitStaleXAiPromptCompleteBeforeSecondHang =
50 process.env.T3_ACP_EMIT_STALE_XAI_PROMPT_COMPLETE_BEFORE_SECOND_HANG === "1";
51const emitOverlappingXAiPromptCompleteOutOfOrder =
52 process.env.T3_ACP_EMIT_OVERLAPPING_XAI_PROMPT_COMPLETE_OUT_OF_ORDER === "1";
53const failPrompt = process.env.T3_ACP_FAIL_PROMPT === "1";
54const failSetConfigOption = process.env.T3_ACP_FAIL_SET_CONFIG_OPTION === "1";
55const exitOnSetConfigOption = process.env.T3_ACP_EXIT_ON_SET_CONFIG_OPTION === "1";
56const promptResponseText = process.env.T3_ACP_PROMPT_RESPONSE_TEXT;
57const initialGrokReasoningEffort =
58 process.env.T3_ACP_INITIAL_GROK_REASONING_EFFORT?.trim() || undefined;
59const promptDelayMs = Number(process.env.T3_ACP_PROMPT_DELAY_MS ?? "0");
60const permissionOptionIds = {
61 allowOnce: process.env.T3_ACP_ALLOW_ONCE_OPTION_ID ?? "allow-once",
62 allowAlways: process.env.T3_ACP_ALLOW_ALWAYS_OPTION_ID ?? "allow-always",
63 rejectOnce: process.env.T3_ACP_REJECT_ONCE_OPTION_ID ?? "reject-once",
64};
65const omitAllowAlways = process.env.T3_ACP_OMIT_ALLOW_ALWAYS === "1";
66const permissionRequestCount = Math.max(
67 1,
68 Number(process.env.T3_ACP_PERMISSION_REQUEST_COUNT ?? "1") || 1,
69);
70const sessionId = "mock-session-1";
71
72let currentModeId = antigravityProfile ? "default" : "ask";
73let currentModelId = antigravityProfile ? "gemini-test-low" : "default";
74let parameterizedModelPicker = false;
75let currentReasoning = "medium";
76let currentContext = "272k";
77let currentFast = false;
78let promptCount = 0;
79let overlappingFirstPromptId: string | undefined;
80const cancelledSessions = new Set<string>();
81
82function promptIdFromRequestMeta(
83 request: Pick<AcpSchema.PromptRequest, "_meta">,
84): string | undefined {
85 const meta = request._meta;
86 if (meta === null || typeof meta !== "object") {
87 return undefined;
88 }
89 const promptId = meta.promptId ?? meta.requestId;
90 return typeof promptId === "string" && promptId.length > 0 ? promptId : undefined;
91}
92
93function logExit(reason: string): void {
94 if (!exitLogPath) {
95 return;
96 }
97 NodeFS.appendFileSync(exitLogPath, `${reason}\n`, "utf8");
98}
99
100function writeJsonRpcNotification(method: string, params: unknown): void {
101 process.stdout.write(`${JSON.stringify({ jsonrpc: "2.0", method, params })}\n`);
102}
103
104process.once("SIGTERM", () => {
105 logExit("SIGTERM");
106 process.exit(0);
107});
108
109process.once("SIGINT", () => {
110 logExit("SIGINT");
111 process.exit(0);
112});
113
114process.once("exit", (code) => {
115 logExit(`exit:${code}`);
116});
117
118function configOptions(): ReadonlyArray<AcpSchema.SessionConfigOption> {
119 if (antigravityProfile) {
120 return [
121 {
122 id: "model",
123 name: "Model",
124 category: "model",
125 type: "select",
126 currentValue: currentModelId,
127 options: antigravityModels.map((model) => ({ value: model.modelId, name: model.name })),
128 },
129 {
130 id: "mode",
131 name: "Mode",
132 category: "mode",
133 type: "select",
134 currentValue: currentModeId,
135 options: availableModes.map((mode) => ({ value: mode.id, name: mode.name })),
136 },
137 ];
138 }
139 if (parameterizedModelPicker) {
140 const baseOptions: Array<AcpSchema.SessionConfigOption> = [
141 {
142 id: "mode",
143 name: "Mode",
144 category: "mode",
145 type: "select",
146 currentValue: currentModeId,
147 options: availableModes.map((mode) => ({
148 value: mode.id,
149 name: mode.name,
150 ...(mode.description ? { description: mode.description } : {}),
151 })),
152 },
153 {
154 id: "model",
155 name: "Model",
156 category: "model",
157 type: "select",
158 currentValue: currentModelId,
159 options: [
160 { value: "default", name: "Auto" },
161 { value: "composer-2", name: "Composer 2" },
162 { value: "gpt-5.4", name: "GPT-5.4" },
163 { value: "claude-opus-4-6", name: "Opus 4.6" },
164 ],
165 },
166 ];
167
168 switch (currentModelId) {
169 case "gpt-5.4":
170 return [
171 ...baseOptions,
172 {
173 id: "reasoning",
174 name: "Reasoning",
175 category: "thought_level",
176 type: "select",
177 currentValue: currentReasoning,
178 options: [
179 { value: "none", name: "None" },
180 { value: "low", name: "Low" },
181 { value: "medium", name: "Medium" },
182 { value: "high", name: "High" },
183 { value: "extra-high", name: "Extra High" },
184 ],
185 },
186 {
187 id: "context",
188 name: "Context",
189 category: "model_config",
190 type: "select",
191 currentValue: currentContext,
192 options: [
193 { value: "272k", name: "272K" },
194 { value: "1m", name: "1M" },
195 ],
196 },
197 {
198 id: "fast",
199 name: "Fast",
200 category: "model_config",
201 type: "select",
202 currentValue: String(currentFast),
203 options: [
204 { value: "false", name: "Off" },
205 { value: "true", name: "Fast" },
206 ],
207 },
208 ];
209 case "composer-2":
210 return [
211 ...baseOptions,
212 {
213 id: "fast",
214 name: "Fast",
215 category: "model_config",
216 type: "select",
217 currentValue: String(currentFast),
218 options: [
219 { value: "false", name: "Off" },
220 { value: "true", name: "Fast" },
221 ],
222 },
223 ];
224 case "claude-opus-4-6":
225 return [
226 ...baseOptions,
227 {
228 id: "reasoning",
229 name: "Reasoning",
230 category: "thought_level",
231 type: "select",
232 currentValue: currentReasoning,
233 options: [
234 { value: "low", name: "Low" },
235 { value: "medium", name: "Medium" },
236 { value: "high", name: "High" },
237 ],
238 },
239 {
240 id: "thinking",
241 name: "Thinking",
242 category: "model_config",
243 type: "boolean",
244 currentValue: true,
245 },
246 ];
247 default:
248 return baseOptions;
249 }
250 }
251
252 return [
253 {
254 id: "model",
255 name: "Model",
256 category: "model",
257 type: "select" as const,
258 currentValue: currentModelId,
259 options: [
260 { value: "default", name: "Auto" },
261 { value: "composer-2", name: "Composer 2" },
262 { value: "composer-2[fast=true]", name: "Composer 2 Fast" },
263 { value: "gpt-5.3-codex[reasoning=medium,fast=false]", name: "Codex 5.3" },
264 ],
265 },
266 ];
267}
268
269function modelConfigOptionsFor(modelId: string): ReadonlyArray<AcpSchema.SessionConfigOption> {
270 const previousModelId = currentModelId;
271 try {
272 currentModelId = modelId;
273 return configOptions().filter(
274 (option) => option.category !== "mode" && option.category !== "model",
275 );
276 } finally {
277 currentModelId = previousModelId;
278 }
279}
280
281function availableModels(): ReadonlyArray<{
282 readonly value: string;
283 readonly name: string;
284 readonly configOptions: ReadonlyArray<AcpSchema.SessionConfigOption>;
285}> {
286 return [
287 { value: "default", name: "Auto" },
288 { value: "composer-2", name: "Composer 2" },
289 { value: "gpt-5.4", name: "GPT-5.4" },
290 { value: "claude-opus-4-6", name: "Opus 4.6" },
291 ].map((model) => ({
292 value: model.value,
293 name: model.name,
294 configOptions: modelConfigOptionsFor(model.value),
295 }));
296}
297
298const antigravityModels = [
299 { modelId: "gemini-test-low", name: "Gemini Test Low" },
300 { modelId: "gemini-test-high", name: "Gemini Test High" },
301] satisfies ReadonlyArray<AcpSchema.ModelInfo>;
302
303const availableModes: ReadonlyArray<AcpSchema.SessionMode> = antigravityProfile
304 ? [
305 { id: "default", name: "Default" },
306 { id: "auto_edit", name: "Auto edit" },
307 { id: "yolo", name: "YOLO" },
308 ]
309 : [
310 {
311 id: "ask",
312 name: "Ask",
313 description: "Request permission before making any changes",
314 },
315 {
316 id: "architect",
317 name: "Architect",
318 description: "Design and plan software systems without implementation",
319 },
320 {
321 id: "code",
322 name: "Code",
323 description: "Write and modify code with full tool access",
324 },
325 ];
326
327function modeState(): AcpSchema.SessionModeState {
328 return {
329 currentModeId,
330 availableModes,
331 };
332}
333
334// Mirrors the real Grok ACP: it advertises versioned model ids, never the CLI's own
335// "grok-build" product name, and it rejects unknown ids in session/set_model.
336const grokAcpModels: ReadonlyArray<AcpSchema.ModelInfo> = [
337 {
338 modelId: "grok-4.6",
339 name: "Grok 4.6",
340 _meta: {
341 totalContextTokens: 500_000,
342 supportsReasoningEffort: true,
343 reasoningEffort: initialGrokReasoningEffort ?? "high",
344 reasoningEfforts: [
345 { id: "xhigh", value: "xhigh", label: "Extra High Effort", default: false },
346 { id: "high", value: "high", label: "High Effort", default: true },
347 { id: "low", value: "low", label: "Low Effort", default: false },
348 ],
349 },
350 },
351 { modelId: "grok-mock-alt", name: "Grok Mock Alt" },
352];
353
354function modelState(): AcpSchema.SessionModelState {
355 if (antigravityProfile) {
356 return { currentModelId, availableModels: antigravityModels };
357 }
358 const modelId = grokAcpModels.some((model) => model.modelId === currentModelId)
359 ? currentModelId
360 : "grok-4.6";
361 return {
362 currentModelId: modelId,
363 availableModels: grokAcpModels,
364 };
365}
366
367const program = Effect.gen(function* () {
368 const agent = yield* EffectAcpAgent.AcpAgent;
369 const resumeRelease = yield* Deferred.make<void>();
370 const nativeCancelRequested = yield* Deferred.make<void>();
371 const nativeCancelRelease = yield* Deferred.make<void>();
372 const publishAntigravityCommands = (targetSessionId: string) =>
373 agent.client.sessionUpdate({
374 sessionId: targetSessionId,
375 update: {
376 sessionUpdate: "available_commands_update",
377 availableCommands: [
378 { name: "plan", description: "Plan a task", input: { hint: "task" } },
379 { name: "logout", description: "Sign out" },
380 ],
381 },
382 });
383
384 yield* agent.handleInitialize((request) =>
385 Effect.gen(function* () {
386 if (floodStderr) {
387 yield* Effect.promise(
388 () =>
389 new Promise<void>((resolve) => {
390 process.stderr.write("stderr".repeat(350_000), () => resolve());
391 }),
392 );
393 }
394 parameterizedModelPicker =
395 request.clientCapabilities?._meta?.parameterizedModelPicker === true;
396 if (antigravityProfile) {
397 return {
398 protocolVersion: 1,
399 agentInfo: { name: "antigravity-acp", version: "mock" },
400 agentCapabilities: {
401 loadSession: true,
402 sessionCapabilities: { resume: {} },
403 auth: { logout: {} },
404 promptCapabilities: { image: true, embeddedContext: true },
405 },
406 authMethods: [{ id: "oauth-personal", name: "Sign in with Google" }],
407 };
408 }
409 return {
410 protocolVersion: 1,
411 agentCapabilities: { loadSession: true, sessionCapabilities: { resume: {} } },
412 // Grok advertises model state before any session exists; the provider
413 // health check reads it from here without authenticating.
414 _meta: { modelState: modelState() },
415 };
416 }),
417 );
418
419 // Mirrors the real agent: the API key method reads GEMINI_API_KEY from the
420 // process environment and rejects when it is missing.
421 yield* agent.handleAuthenticate((request) =>
422 !antigravityProfile || request.methodId === "oauth-personal"
423 ? Effect.succeed({})
424 : request.methodId === "gemini-api-key" && process.env.GEMINI_API_KEY
425 ? Effect.succeed({})
426 : Effect.fail(
427 AcpError.AcpRequestError.invalidParams(
428 `Mock Antigravity rejected auth method ${request.methodId}.`,
429 ),
430 ),
431 );
432 if (antigravityProfile) {
433 yield* agent.handleLogout(() => Effect.succeed({}));
434 }
435
436 yield* agent.handleCreateSession(() =>
437 Effect.gen(function* () {
438 if (antigravityProfile) {
439 yield* publishAntigravityCommands(sessionId);
440 }
441 return {
442 sessionId,
443 modes: modeState(),
444 models: modelState(),
445 configOptions: configOptions(),
446 };
447 }),
448 );
449
450 yield* agent.handleResumeSession((request) =>
451 Effect.gen(function* () {
452 yield* agent.client.sessionUpdate({
453 sessionId: request.sessionId,
454 update: {
455 sessionUpdate: "user_message_chunk",
456 content: { type: "text", text: "native-resume-started" },
457 },
458 });
459 if (waitForResumeRelease) {
460 yield* Deferred.await(resumeRelease);
461 }
462 if (antigravityProfile) {
463 yield* publishAntigravityCommands(request.sessionId);
464 }
465 return {
466 modes: modeState(),
467 models: modelState(),
468 configOptions: configOptions(),
469 _meta: { nativeResume: true },
470 };
471 }),
472 );
473
474 const emitLoadReplayNotifications = (requestedSessionId: string) => {
475 writeJsonRpcNotification("session/update", {
476 _meta: { isReplay: true },
477 sessionId: requestedSessionId,
478 update: {
479 sessionUpdate: "tool_call",
480 toolCallId: "replay-tool-1",
481 title: "Replay tool",
482 kind: "search",
483 status: "completed",
484 },
485 });
486 writeJsonRpcNotification("session/update", {
487 _meta: { isReplay: true },
488 sessionId: requestedSessionId,
489 update: {
490 sessionUpdate: "agent_message_chunk",
491 content: { type: "text", text: "replayed assistant text" },
492 },
493 });
494 };
495
496 yield* agent.handleLoadSession((request) =>
497 Effect.gen(function* () {
498 const requestedSessionId = String(request.sessionId ?? sessionId);
499 if (failLoadSession) {
500 return yield* AcpError.AcpRequestError.internalError("Mock load session failure");
501 }
502 if (hangLoadSessionAfterReplay || delayLoadSessionAfterReplay) {
503 emitLoadReplayNotifications(requestedSessionId);
504 yield* agent.client.sessionUpdate({
505 sessionId: requestedSessionId,
506 update: {
507 sessionUpdate: "user_message_chunk",
508 content: { type: "text", text: "replay-tail" },
509 },
510 });
511 yield* Effect.sleep(loadSessionDelayMs);
512 return {
513 modes: modeState(),
514 models: modelState(),
515 configOptions: configOptions(),
516 };
517 }
518 if (emitLoadReplay) {
519 emitLoadReplayNotifications(requestedSessionId);
520 }
521 yield* agent.client.sessionUpdate({
522 sessionId: requestedSessionId,
523 update: {
524 sessionUpdate: "user_message_chunk",
525 content: { type: "text", text: "replay" },
526 },
527 });
528 return {
529 modes: modeState(),
530 models: modelState(),
531 configOptions: configOptions(),
532 };
533 }),
534 );
535
536 yield* agent.handleSetSessionModel((request) =>
537 Effect.gen(function* () {
538 if (!modelState().availableModels.some((model) => model.modelId === request.modelId)) {
539 return yield* AcpError.AcpRequestError.invalidParams(
540 `Unknown mock model id: ${request.modelId}`,
541 {
542 method: "session/set_model",
543 params: request,
544 },
545 );
546 }
547 currentModelId = request.modelId;
548 return {};
549 }),
550 );
551
552 yield* agent.handleSetSessionConfigOption((request) =>
553 Effect.gen(function* () {
554 if (exitOnSetConfigOption) {
555 return yield* Effect.sync(() => {
556 process.exit(7);
557 });
558 }
559 if (failSetConfigOption) {
560 return yield* AcpError.AcpRequestError.invalidParams(
561 "Mock invalid params for session/set_config_option",
562 {
563 method: "session/set_config_option",
564 params: request,
565 },
566 );
567 }
568 if (request.configId === "mode" && typeof request.value === "string") {
569 currentModeId = request.value;
570 }
571 if (request.configId === "model" && typeof request.value === "string") {
572 currentModelId = request.value;
573 }
574 if (request.configId === "reasoning" && typeof request.value === "string") {
575 currentReasoning = request.value;
576 }
577 if (request.configId === "context" && typeof request.value === "string") {
578 currentContext = request.value;
579 }
580 if (request.configId === "fast") {
581 currentFast = request.value === true || request.value === "true";
582 }
583 return {
584 configOptions: configOptions(),
585 };
586 }),
587 );
588
589 yield* agent.handleCancel(({ sessionId }) =>
590 Effect.gen(function* () {
591 const cancelledSessionId = String(sessionId ?? "mock-session-1");
592 cancelledSessions.add(cancelledSessionId);
593 if (completeFirstPromptOnCancel) {
594 yield* Deferred.succeed(nativeCancelRequested, undefined);
595 yield* agent.client.sessionUpdate({
596 sessionId: cancelledSessionId,
597 update: {
598 sessionUpdate: "agent_thought_chunk",
599 content: { type: "text", text: "native-cancel-received" },
600 },
601 });
602 }
603 if (emitLateUpdateAfterCancel) {
604 yield* Effect.sleep("50 millis");
605 yield* Effect.sync(() => {
606 writeJsonRpcNotification("session/update", {
607 sessionId: cancelledSessionId,
608 update: {
609 sessionUpdate: "agent_message_chunk",
610 content: { type: "text", text: "late after cancel" },
611 },
612 });
613 });
614 }
615 }),
616 );
617
618 yield* agent.handlePrompt((request) =>
619 Effect.gen(function* () {
620 const requestedSessionId = String(request.sessionId ?? sessionId);
621 promptCount += 1;
622
623 if (completeFirstPromptOnCancel && promptCount === 1) {
624 yield* agent.client.sessionUpdate({
625 sessionId: requestedSessionId,
626 update: {
627 sessionUpdate: "tool_call",
628 toolCallId: "native-cancel-tool",
629 title: "Long command",
630 kind: "execute",
631 status: "in_progress",
632 },
633 });
634 yield* Deferred.await(nativeCancelRequested);
635 yield* Deferred.await(nativeCancelRelease);
636 yield* agent.client.sessionUpdate({
637 sessionId: requestedSessionId,
638 update: {
639 sessionUpdate: "tool_call_update",
640 toolCallId: "native-cancel-tool",
641 status: "failed",
642 content: [{ type: "content", content: { type: "text", text: "Cancelled." } }],
643 },
644 });
645 yield* agent.client.sessionUpdate({
646 sessionId: requestedSessionId,
647 update: {
648 sessionUpdate: "agent_message_chunk",
649 content: { type: "text", text: "Request cancelled." },
650 },
651 });
652 return { stopReason: "cancelled", _meta: { nativeCancel: true } };
653 }
654
655 if (Number.isFinite(promptDelayMs) && promptDelayMs > 0) {
656 yield* Effect.sleep(`${promptDelayMs} millis`);
657 }
658
659 if (failPrompt) {
660 return yield* AcpError.AcpRequestError.internalError("Mock prompt failure");
661 }
662
663 if (emitStaleXAiPromptCompleteBeforeSecondHang && promptCount === 1) {
664 return {
665 stopReason: "end_turn",
666 _meta: {
667 promptId: "mock-stale-xai-prompt-1",
668 requestId: "mock-stale-xai-prompt-1",
669 },
670 };
671 }
672
673 if (emitStaleXAiPromptCompleteBeforeSecondHang && promptCount === 2) {
674 const currentPromptId = promptIdFromRequestMeta(request) ?? "mock-current-xai-prompt-2";
675 writeJsonRpcNotification("_x.ai/session/prompt_complete", {
676 sessionId: requestedSessionId,
677 promptId: "mock-stale-xai-prompt-1",
678 stopReason: "end_turn",
679 agentResult: null,
680 });
681
682 writeJsonRpcNotification("_x.ai/session/prompt_complete", {
683 sessionId: requestedSessionId,
684 promptId: currentPromptId,
685 stopReason: "end_turn",
686 agentResult: null,
687 });
688
689 return yield* Effect.never;
690 }
691
692 if (emitOverlappingXAiPromptCompleteOutOfOrder && promptCount === 1) {
693 overlappingFirstPromptId = promptIdFromRequestMeta(request);
694 return yield* Effect.never;
695 }
696
697 if (emitOverlappingXAiPromptCompleteOutOfOrder && promptCount === 2) {
698 const secondPromptId = promptIdFromRequestMeta(request);
699 if (overlappingFirstPromptId !== undefined && secondPromptId !== undefined) {
700 writeJsonRpcNotification("_x.ai/session/prompt_complete", {
701 sessionId: requestedSessionId,
702 promptId: secondPromptId,
703 stopReason: "end_turn",
704 agentResult: null,
705 });
706 writeJsonRpcNotification("_x.ai/session/prompt_complete", {
707 sessionId: requestedSessionId,
708 promptId: overlappingFirstPromptId,
709 stopReason: "end_turn",
710 agentResult: null,
711 });
712 }
713 return yield* Effect.never;
714 }
715
716 if (hangPromptForever || (hangFirstPromptForever && promptCount === 1)) {
717 return yield* Effect.never;
718 }
719
720 if (emitXAiRateLimitThenHang) {
721 writeJsonRpcNotification("_x.ai/session/prompt_complete", {
722 sessionId: requestedSessionId,
723 promptId: promptIdFromRequestMeta(request) ?? "mock-xai-rate-limit-prompt-1",
724 stopReason: "rate_limit",
725 agentResult: null,
726 });
727 return yield* Effect.never;
728 }
729
730 if (emitContentThenHang) {
731 yield* agent.client.sessionUpdate({
732 sessionId: requestedSessionId,
733 update: {
734 sessionUpdate: "agent_message_chunk",
735 content: { type: "text", text: "partial before stall" },
736 },
737 });
738 return yield* Effect.never;
739 }
740
741 if (emitPlanThenHang) {
742 yield* agent.client.sessionUpdate({
743 sessionId: requestedSessionId,
744 update: {
745 sessionUpdate: "plan",
746 entries: [
747 {
748 content: "Wait for more ACP progress",
749 priority: "high",
750 status: "in_progress",
751 },
752 ],
753 },
754 });
755 return yield* Effect.never;
756 }
757
758 if (emitActiveToolThenHang) {
759 const toolCallId = "tool-call-long-running-1";
760 yield* agent.client.sessionUpdate({
761 sessionId: requestedSessionId,
762 update: {
763 sessionUpdate: "tool_call",
764 toolCallId,
765 title: "Long-running tool",
766 kind: "execute",
767 status: "pending",
768 rawInput: { command: ["long-running-tool"] },
769 },
770 });
771 yield* agent.client.sessionUpdate({
772 sessionId: requestedSessionId,
773 update: {
774 sessionUpdate: "tool_call_update",
775 toolCallId,
776 status: "in_progress",
777 },
778 });
779 return yield* Effect.never;
780 }
781
782 if (emitXAiPromptCompleteThenHang) {
783 writeJsonRpcNotification("session/update", {
784 sessionId: requestedSessionId,
785 update: {
786 sessionUpdate: "agent_message_chunk",
787 content: { type: "text", text: "hello from" },
788 },
789 });
790
791 if (emitForeignSessionUpdates) {
792 writeJsonRpcNotification("session/update", {
793 sessionId: "mock-child-session-1",
794 update: {
795 sessionUpdate: "agent_message_chunk",
796 content: { type: "text", text: "child before completion" },
797 },
798 });
799 }
800
801 writeJsonRpcNotification("_x.ai/session/prompt_complete", {
802 sessionId: requestedSessionId,
803 promptId: promptIdFromRequestMeta(request) ?? "mock-xai-prompt-1",
804 ...(omitXAiPromptCompleteStopReason ? {} : { stopReason: "end_turn" }),
805 agentResult: null,
806 });
807
808 if (emitForeignSessionUpdates) {
809 writeJsonRpcNotification("session/update", {
810 sessionId: "mock-child-session-1",
811 update: {
812 sessionUpdate: "tool_call",
813 toolCallId: "child-tool-call-1",
814 title: "Child-only tool",
815 kind: "other",
816 status: "pending",
817 rawInput: {},
818 },
819 });
820 writeJsonRpcNotification("session/update", {
821 sessionId: "mock-child-session-1",
822 update: {
823 sessionUpdate: "agent_message_chunk",
824 content: { type: "text", text: "child after completion" },
825 },
826 });
827 }
828
829 for (const text of [" ", "mo", "ck"]) {
830 writeJsonRpcNotification("session/update", {
831 sessionId: requestedSessionId,
832 update: {
833 sessionUpdate: "agent_message_chunk",
834 content: { type: "text", text },
835 },
836 });
837 }
838
839 return yield* Effect.never;
840 }
841
842 if (emitGrokMonitorPostTurnPoll) {
843 const monitorCallId = "call-monitor-1";
844 const pollCallId = "call-monitor-poll-1";
845 const taskId = "01a05f41-5107-7550-821e-79e8d1cd7687";
846 const description = "Watch count-sheet Typst unit until done";
847 writeJsonRpcNotification("session/update", {
848 sessionId: requestedSessionId,
849 update: {
850 sessionUpdate: "tool_call",
851 toolCallId: monitorCallId,
852 title: "monitor",
853 kind: "other",
854 status: "pending",
855 rawInput: { description },
856 _meta: {
857 "x.ai/tool": { version: 1, name: "monitor", kind: "task", namespace: "grok_build" },
858 },
859 },
860 });
861 writeJsonRpcNotification("session/update", {
862 sessionId: requestedSessionId,
863 update: {
864 sessionUpdate: "tool_call_update",
865 toolCallId: monitorCallId,
866 status: "completed",
867 rawInput: { description },
868 rawOutput: {
869 type: "Monitor",
870 taskId,
871 timeoutMs: 36_000_000,
872 },
873 },
874 });
875 writeJsonRpcNotification("_x.ai/session/prompt_complete", {
876 sessionId: requestedSessionId,
877 promptId: promptIdFromRequestMeta(request) ?? "mock-xai-prompt-1",
878 stopReason: "end_turn",
879 agentResult: null,
880 });
881 yield* Effect.sleep("120 millis");
882 writeJsonRpcNotification("session/update", {
883 sessionId: requestedSessionId,
884 update: {
885 sessionUpdate: "tool_call",
886 toolCallId: pollCallId,
887 title: "get_command_or_subagent_output",
888 kind: "other",
889 status: "completed",
890 rawInput: { variant: "TaskOutput", task_ids: [taskId], timeout_ms: 0 },
891 rawOutput: {
892 type: "TaskOutput",
893 Result: {
894 task_id: taskId,
895 command: `[monitor] ${description}`,
896 status: "completed",
897 exit_code: 0,
898 output: "Monitor finished.",
899 },
900 },
901 },
902 });
903 return yield* Effect.never;
904 }
905
906 if (emitGrokBackgroundTaskStarted) {
907 const toolCallId = "call-fb9d0000-0000-0000-0000-000000000026";
908 const command = "sleep 40; echo done-a";
909 writeJsonRpcNotification("session/update", {
910 sessionId: requestedSessionId,
911 update: {
912 sessionUpdate: "tool_call",
913 toolCallId,
914 title: "run_terminal_command",
915 kind: "execute",
916 status: "in_progress",
917 rawInput: { command },
918 },
919 });
920 writeJsonRpcNotification("session/update", {
921 sessionId: requestedSessionId,
922 update: {
923 sessionUpdate: "tool_call_update",
924 toolCallId,
925 status: "completed",
926 rawOutput: {
927 type: "BackgroundTaskStarted",
928 task_id: toolCallId,
929 task_type: "bash",
930 status: "running",
931 command,
932 },
933 },
934 });
935 writeJsonRpcNotification("_x.ai/session/prompt_complete", {
936 sessionId: requestedSessionId,
937 promptId: promptIdFromRequestMeta(request) ?? "mock-xai-prompt-1",
938 stopReason: "end_turn",
939 agentResult: null,
940 });
941 return yield* Effect.never;
942 }
943
944 if (emitInterleavedAssistantToolCalls) {
945 const toolCallId = "tool-call-1";
946
947 yield* agent.client.sessionUpdate({
948 sessionId: requestedSessionId,
949 update: {
950 sessionUpdate: "agent_message_chunk",
951 content: { type: "text", text: "before tool" },
952 },
953 });
954
955 yield* agent.client.sessionUpdate({
956 sessionId: requestedSessionId,
957 update: {
958 sessionUpdate: "tool_call",
959 toolCallId,
960 title: "Terminal",
961 kind: "execute",
962 status: "pending",
963 rawInput: {
964 command: ["echo", "hello"],
965 },
966 },
967 });
968
969 yield* agent.client.sessionUpdate({
970 sessionId: requestedSessionId,
971 update: {
972 sessionUpdate: "tool_call_update",
973 toolCallId,
974 status: "completed",
975 rawOutput: {
976 exitCode: 0,
977 stdout: "hello",
978 stderr: "",
979 },
980 },
981 });
982
983 yield* agent.client.sessionUpdate({
984 sessionId: requestedSessionId,
985 update: {
986 sessionUpdate: "agent_message_chunk",
987 content: { type: "text", text: "after tool" },
988 },
989 });
990
991 return { stopReason: "end_turn" };
992 }
993
994 if (emitToolCalls) {
995 const toolCallId = "tool-call-1";
996
997 yield* agent.client.sessionUpdate({
998 sessionId: requestedSessionId,
999 update: {
1000 sessionUpdate: "tool_call",
1001 toolCallId,
1002 title: "Terminal",
1003 kind: "execute",
1004 status: "pending",
1005 rawInput: {
1006 command: ["cat", "server/package.json"],
1007 },
1008 },
1009 });
1010
1011 yield* agent.client.sessionUpdate({
1012 sessionId: requestedSessionId,
1013 update: {
1014 sessionUpdate: "tool_call_update",
1015 toolCallId,
1016 status: "in_progress",
1017 },
1018 });
1019
1020 const permissionOptions: Array<AcpSchema.PermissionOption> = [
1021 { optionId: permissionOptionIds.allowOnce, name: "Allow once", kind: "allow_once" },
1022 ...(omitAllowAlways
1023 ? []
1024 : [
1025 {
1026 optionId: permissionOptionIds.allowAlways,
1027 name: "Allow always",
1028 kind: "allow_always" as const,
1029 },
1030 ]),
1031 { optionId: permissionOptionIds.rejectOnce, name: "Reject", kind: "reject_once" },
1032 ];
1033
1034 let cancelled = cancelledSessions.delete(requestedSessionId);
1035 for (let index = 0; index < permissionRequestCount; index++) {
1036 const command =
1037 index > 0
1038 ? (process.env.T3_ACP_SECOND_PERMISSION_COMMAND ?? "cat server/package.json")
1039 : "cat server/package.json";
1040 const permission = yield* agent.client.requestPermission({
1041 sessionId: requestedSessionId,
1042 toolCall: {
1043 toolCallId: index === 0 ? toolCallId : `${toolCallId}-${index + 1}`,
1044 title: process.env.T3_ACP_PERMISSION_TITLE ?? `\`${command}\``,
1045 kind: "execute",
1046 status: "pending",
1047 rawInput: {
1048 variant: "Bash",
1049 command,
1050 description: index === 0 ? "Read package metadata" : "Read it again",
1051 },
1052 content: [
1053 {
1054 type: "content",
1055 content: {
1056 type: "text",
1057 text: `Not in allowlist: ${command}`,
1058 },
1059 },
1060 ],
1061 },
1062 options: permissionOptions,
1063 });
1064 cancelled =
1065 cancelled ||
1066 cancelledSessions.delete(requestedSessionId) ||
1067 permission.outcome.outcome === "cancelled";
1068 if (cancelled) {
1069 break;
1070 }
1071 }
1072
1073 yield* agent.client.sessionUpdate({
1074 sessionId: requestedSessionId,
1075 update: {
1076 sessionUpdate: "tool_call_update",
1077 toolCallId,
1078 title: "Terminal",
1079 kind: "execute",
1080 status: "completed",
1081 rawOutput: {
1082 exitCode: 0,
1083 stdout: '{ "name": "t3" }',
1084 stderr: "",
1085 },
1086 },
1087 });
1088
1089 yield* agent.client.sessionUpdate({
1090 sessionId: requestedSessionId,
1091 update: {
1092 sessionUpdate: "agent_message_chunk",
1093 content: { type: "text", text: "hello from mock" },
1094 },
1095 });
1096
1097 return { stopReason: cancelled ? "cancelled" : "end_turn" };
1098 }
1099
1100 if (emitGenericToolPlaceholders) {
1101 const toolCallId = "tool-call-generic-1";
1102
1103 yield* agent.client.sessionUpdate({
1104 sessionId: requestedSessionId,
1105 update: {
1106 sessionUpdate: "tool_call",
1107 toolCallId,
1108 title: "Read File",
1109 kind: "read",
1110 status: "pending",
1111 rawInput: {},
1112 },
1113 });
1114
1115 yield* agent.client.sessionUpdate({
1116 sessionId: requestedSessionId,
1117 update: {
1118 sessionUpdate: "tool_call_update",
1119 toolCallId,
1120 status: "in_progress",
1121 },
1122 });
1123
1124 yield* agent.client.sessionUpdate({
1125 sessionId: requestedSessionId,
1126 update: {
1127 sessionUpdate: "tool_call_update",
1128 toolCallId,
1129 status: "completed",
1130 rawOutput: {
1131 content: "package.json\n",
1132 },
1133 },
1134 });
1135
1136 return { stopReason: "end_turn" };
1137 }
1138
1139 if (emitAskQuestion) {
1140 yield* agent.client.extRequest("cursor/ask_question", {
1141 toolCallId: "ask-question-tool-call-1",
1142 title: "Question",
1143 questions: [
1144 {
1145 id: "scope",
1146 prompt: "Which scope?",
1147 options: [
1148 { id: "workspace", label: "Workspace" },
1149 { id: "session", label: "Session" },
1150 ],
1151 },
1152 ],
1153 });
1154
1155 return { stopReason: "end_turn" };
1156 }
1157
1158 if (emitXAiAskUserQuestion || emitXAiAskUserQuestionThenHang) {
1159 const result = yield* agent.client.extRequest("_x.ai/ask_user_question", {
1160 method: "x.ai/ask_user_question",
1161 params: {
1162 sessionId: requestedSessionId,
1163 toolCallId: "ask-user-question-tool-call-1",
1164 questions: [
1165 {
1166 question: "Which scope should Grok use?",
1167 multiSelect: null,
1168 options: [
1169 { label: "Workspace", description: "Use the current workspace" },
1170 { label: "Session", description: "Only use this session" },
1171 ],
1172 },
1173 ],
1174 mode: "default",
1175 },
1176 });
1177 if (typeof result !== "object" || result === null || !("outcome" in result)) {
1178 throw new Error("Expected _x.ai/ask_user_question response outcome.");
1179 }
1180 if (result.outcome === "cancelled") {
1181 return { stopReason: "end_turn" };
1182 }
1183 if (
1184 result.outcome !== "accepted" ||
1185 !("answers" in result) ||
1186 typeof result.answers !== "object" ||
1187 result.answers === null
1188 ) {
1189 throw new Error("Expected accepted _x.ai/ask_user_question response answers.");
1190 }
1191
1192 if (emitXAiAskUserQuestionThenHang) {
1193 return yield* Effect.never;
1194 }
1195
1196 return { stopReason: "end_turn" };
1197 }
1198
1199 if (emitXAiPlanMdWrite) {
1200 // Match Grok's real session layout so isGrokPlanMarkdownPath accepts it.
1201 const planRoot = process.env.T3_ACP_PLAN_ROOT ?? "/tmp/mock-home/.grok";
1202 const planPath = `${planRoot}/sessions/${requestedSessionId}/plan.md`;
1203 const planBody = "# Mock plan\n\n- Write the feature\n- Add a test\n- Ship it\n";
1204 // enter_plan_mode first so the adapter arms planModeActive.
1205 yield* agent.client.sessionUpdate({
1206 sessionId: requestedSessionId,
1207 update: {
1208 sessionUpdate: "tool_call",
1209 toolCallId: "enter-plan-mode-1",
1210 title: "enter_plan_mode",
1211 kind: "other",
1212 status: "completed",
1213 rawInput: { variant: "EnterPlanMode" },
1214 },
1215 });
1216 yield* agent.client.sessionUpdate({
1217 sessionId: requestedSessionId,
1218 update: {
1219 sessionUpdate: "tool_call",
1220 toolCallId: "plan-md-write-1",
1221 title: "write",
1222 kind: "edit",
1223 status: "pending",
1224 rawInput: { file_path: planPath, content: planBody },
1225 },
1226 });
1227 yield* agent.client.sessionUpdate({
1228 sessionId: requestedSessionId,
1229 update: {
1230 sessionUpdate: "tool_call_update",
1231 toolCallId: "plan-md-write-1",
1232 kind: "edit",
1233 status: "completed",
1234 title: `Write \`${planPath}\``,
1235 rawInput: { file_path: planPath, content: planBody },
1236 content: [
1237 {
1238 type: "diff",
1239 path: planPath,
1240 oldText: "",
1241 newText: planBody,
1242 },
1243 ],
1244 },
1245 });
1246 return { stopReason: "end_turn" };
1247 }
1248
1249 if (emitXAiExitPlanMode) {
1250 const result = yield* agent.client.extRequest("_x.ai/exit_plan_mode", {
1251 method: "x.ai/exit_plan_mode",
1252 params: {
1253 sessionId: requestedSessionId,
1254 toolCallId: "exit-plan-mode-tool-call-1",
1255 planContent: "# Exit plan\n\n- Step one\n- Step two\n",
1256 },
1257 });
1258 if (typeof result !== "object" || result === null || !("outcome" in result)) {
1259 throw new Error("Expected _x.ai/exit_plan_mode response outcome.");
1260 }
1261 if (
1262 result.outcome !== "abandoned" &&
1263 result.outcome !== "approved" &&
1264 result.outcome !== "request_changes"
1265 ) {
1266 throw new Error(
1267 `Expected exit_plan_mode outcome abandoned|approved|request_changes, got ${String(result.outcome)}`,
1268 );
1269 }
1270 return { stopReason: "end_turn" };
1271 }
1272
1273 if (emitForeignSessionUpdates) {
1274 yield* agent.client.sessionUpdate({
1275 sessionId: requestedSessionId,
1276 update: {
1277 sessionUpdate: "agent_message_chunk",
1278 content: { type: "text", text: "root before child" },
1279 },
1280 });
1281 yield* agent.client.sessionUpdate({
1282 sessionId: "mock-child-session-1",
1283 update: {
1284 sessionUpdate: "agent_message_chunk",
1285 content: { type: "text", text: "child content" },
1286 },
1287 });
1288 yield* agent.client.sessionUpdate({
1289 sessionId: "mock-child-session-1",
1290 update: {
1291 sessionUpdate: "tool_call",
1292 toolCallId: "child-tool-call-1",
1293 title: "Child-only tool",
1294 kind: "other",
1295 status: "pending",
1296 rawInput: {},
1297 },
1298 });
1299 yield* agent.client.sessionUpdate({
1300 sessionId: requestedSessionId,
1301 update: {
1302 sessionUpdate: "agent_message_chunk",
1303 content: { type: "text", text: " root after child" },
1304 },
1305 });
1306 return { stopReason: "end_turn" };
1307 }
1308
1309 yield* agent.client.sessionUpdate({
1310 sessionId: requestedSessionId,
1311 update: {
1312 sessionUpdate: "plan",
1313 entries: [
1314 {
1315 content: "Inspect mock ACP state",
1316 priority: "high",
1317 status: "completed",
1318 },
1319 {
1320 content: "Implement the requested change",
1321 priority: "high",
1322 status: "in_progress",
1323 },
1324 ],
1325 },
1326 });
1327
1328 yield* agent.client.sessionUpdate({
1329 sessionId: requestedSessionId,
1330 update: {
1331 sessionUpdate: "agent_message_chunk",
1332 content: { type: "text", text: promptResponseText ?? "hello from mock" },
1333 },
1334 });
1335
1336 return { stopReason: "end_turn" };
1337 }),
1338 );
1339
1340 yield* agent.handleUnknownExtRequest((method, params) => {
1341 if (method === "_test/environment") {
1342 return Effect.succeed({
1343 inherited: process.env.T3_ACP_RUNTIME_AMBIENT === "sentinel",
1344 explicit: process.env.T3_ACP_RUNTIME_EXPLICIT === "kept",
1345 });
1346 }
1347 if (method === "_test/release-resume") {
1348 return Deferred.succeed(resumeRelease, undefined).pipe(Effect.as({}));
1349 }
1350 if (method === "_test/finish-cancel") {
1351 return Deferred.succeed(nativeCancelRelease, undefined).pipe(Effect.as({}));
1352 }
1353 if (method === "_test/startup-metadata") {
1354 return Effect.gen(function* () {
1355 for (const [metadataSessionId, commandName, modeId] of [
1356 [sessionId, "plan", "code"],
1357 ["child-session", "foreign-command", "ask"],
1358 ] as const) {
1359 yield* agent.client.sessionUpdate({
1360 sessionId: metadataSessionId,
1361 update: {
1362 sessionUpdate: "available_commands_update",
1363 availableCommands: [{ name: commandName, description: "Native command" }],
1364 },
1365 });
1366 yield* agent.client.sessionUpdate({
1367 sessionId: metadataSessionId,
1368 update: { sessionUpdate: "current_mode_update", currentModeId: modeId },
1369 });
1370 yield* agent.client.sessionUpdate({
1371 sessionId: metadataSessionId,
1372 update: {
1373 sessionUpdate: "config_option_update",
1374 configOptions: configOptions().map((option) =>
1375 option.type === "select" && option.category === "model"
1376 ? {
1377 ...option,
1378 currentValue: metadataSessionId === sessionId ? "gpt-5.4" : "default",
1379 }
1380 : option,
1381 ),
1382 },
1383 });
1384 yield* agent.client.sessionUpdate({
1385 sessionId: metadataSessionId,
1386 update: {
1387 sessionUpdate: "agent_message_chunk",
1388 content: { type: "text", text: "Startup transcript must not replay." },
1389 },
1390 });
1391 }
1392 return {};
1393 });
1394 }
1395 if (method === "cursor/list_available_models") {
1396 return Effect.succeed({
1397 models: availableModels(),
1398 });
1399 }
1400
1401 if (method !== "session/mode/set") {
1402 return Effect.fail(AcpError.AcpRequestError.methodNotFound(method));
1403 }
1404
1405 const nextModeId =
1406 typeof params === "object" &&
1407 params !== null &&
1408 "modeId" in params &&
1409 typeof params.modeId === "string"
1410 ? params.modeId
1411 : typeof params === "object" &&
1412 params !== null &&
1413 "mode" in params &&
1414 typeof params.mode === "string"
1415 ? params.mode
1416 : undefined;
1417 const requestedSessionId =
1418 typeof params === "object" &&
1419 params !== null &&
1420 "sessionId" in params &&
1421 typeof params.sessionId === "string"
1422 ? params.sessionId
1423 : sessionId;
1424
1425 if (typeof nextModeId === "string" && nextModeId.trim()) {
1426 currentModeId = nextModeId.trim();
1427 return agent.client
1428 .sessionUpdate({
1429 sessionId: requestedSessionId,
1430 update: {
1431 sessionUpdate: "current_mode_update",
1432 currentModeId,
1433 },
1434 })
1435 .pipe(Effect.as({}));
1436 }
1437
1438 return Effect.succeed({});
1439 });
1440
1441 yield* agent.handleUnknownExtNotification((method) =>
1442 method === "_test/exit" ? Effect.sync(() => process.exit(19)) : Effect.void,
1443 );
1444
1445 return yield* Effect.never;
1446}).pipe(
1447 Effect.provide(
1448 EffectAcpAgent.layerStdio(
1449 requestLogPath
1450 ? {
1451 logIncoming: true,
1452 logger: (event) => {
1453 if (event.direction !== "incoming" || event.stage !== "raw") {
1454 return Effect.void;
1455 }
1456 if (typeof event.payload !== "string") {
1457 return Effect.void;
1458 }
1459 const payload = event.payload;
1460 return Effect.sync(() => {
1461 NodeFS.appendFileSync(
1462 requestLogPath,
1463 payload.endsWith("\n") ? payload : `${payload}\n`,
1464 "utf8",
1465 );
1466 });
1467 },
1468 }
1469 : {},
1470 ),
1471 ),
1472 Effect.scoped,
1473 Effect.provide(NodeServices.layer),
1474);
1475
1476NodeRuntime.runMain(program);