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 if (
623 process.env.T3_ACP_CRASH_PROMPT === "1" &&
624 request.prompt.some((part) => part.type === "text" && part.text === "crash now")
625 ) {
626 return yield* Effect.sync(() => process.exit(23));
627 }
628
629 if (completeFirstPromptOnCancel && promptCount === 1) {
630 yield* agent.client.sessionUpdate({
631 sessionId: requestedSessionId,
632 update: {
633 sessionUpdate: "tool_call",
634 toolCallId: "native-cancel-tool",
635 title: "Long command",
636 kind: "execute",
637 status: "in_progress",
638 },
639 });
640 yield* Deferred.await(nativeCancelRequested);
641 yield* Deferred.await(nativeCancelRelease);
642 yield* agent.client.sessionUpdate({
643 sessionId: requestedSessionId,
644 update: {
645 sessionUpdate: "tool_call_update",
646 toolCallId: "native-cancel-tool",
647 status: "failed",
648 content: [{ type: "content", content: { type: "text", text: "Cancelled." } }],
649 },
650 });
651 yield* agent.client.sessionUpdate({
652 sessionId: requestedSessionId,
653 update: {
654 sessionUpdate: "agent_message_chunk",
655 content: { type: "text", text: "Request cancelled." },
656 },
657 });
658 return { stopReason: "cancelled", _meta: { nativeCancel: true } };
659 }
660
661 if (Number.isFinite(promptDelayMs) && promptDelayMs > 0) {
662 yield* Effect.sleep(`${promptDelayMs} millis`);
663 }
664
665 if (failPrompt) {
666 return yield* AcpError.AcpRequestError.internalError("Mock prompt failure");
667 }
668
669 if (emitStaleXAiPromptCompleteBeforeSecondHang && promptCount === 1) {
670 return {
671 stopReason: "end_turn",
672 _meta: {
673 promptId: "mock-stale-xai-prompt-1",
674 requestId: "mock-stale-xai-prompt-1",
675 },
676 };
677 }
678
679 if (emitStaleXAiPromptCompleteBeforeSecondHang && promptCount === 2) {
680 const currentPromptId = promptIdFromRequestMeta(request) ?? "mock-current-xai-prompt-2";
681 writeJsonRpcNotification("_x.ai/session/prompt_complete", {
682 sessionId: requestedSessionId,
683 promptId: "mock-stale-xai-prompt-1",
684 stopReason: "end_turn",
685 agentResult: null,
686 });
687
688 writeJsonRpcNotification("_x.ai/session/prompt_complete", {
689 sessionId: requestedSessionId,
690 promptId: currentPromptId,
691 stopReason: "end_turn",
692 agentResult: null,
693 });
694
695 return yield* Effect.never;
696 }
697
698 if (emitOverlappingXAiPromptCompleteOutOfOrder && promptCount === 1) {
699 overlappingFirstPromptId = promptIdFromRequestMeta(request);
700 return yield* Effect.never;
701 }
702
703 if (emitOverlappingXAiPromptCompleteOutOfOrder && promptCount === 2) {
704 const secondPromptId = promptIdFromRequestMeta(request);
705 if (overlappingFirstPromptId !== undefined && secondPromptId !== undefined) {
706 writeJsonRpcNotification("_x.ai/session/prompt_complete", {
707 sessionId: requestedSessionId,
708 promptId: secondPromptId,
709 stopReason: "end_turn",
710 agentResult: null,
711 });
712 writeJsonRpcNotification("_x.ai/session/prompt_complete", {
713 sessionId: requestedSessionId,
714 promptId: overlappingFirstPromptId,
715 stopReason: "end_turn",
716 agentResult: null,
717 });
718 }
719 return yield* Effect.never;
720 }
721
722 if (hangPromptForever || (hangFirstPromptForever && promptCount === 1)) {
723 return yield* Effect.never;
724 }
725
726 if (emitXAiRateLimitThenHang) {
727 writeJsonRpcNotification("_x.ai/session/prompt_complete", {
728 sessionId: requestedSessionId,
729 promptId: promptIdFromRequestMeta(request) ?? "mock-xai-rate-limit-prompt-1",
730 stopReason: "rate_limit",
731 agentResult: null,
732 });
733 return yield* Effect.never;
734 }
735
736 if (emitContentThenHang) {
737 yield* agent.client.sessionUpdate({
738 sessionId: requestedSessionId,
739 update: {
740 sessionUpdate: "agent_message_chunk",
741 content: { type: "text", text: "partial before stall" },
742 },
743 });
744 return yield* Effect.never;
745 }
746
747 if (emitPlanThenHang) {
748 yield* agent.client.sessionUpdate({
749 sessionId: requestedSessionId,
750 update: {
751 sessionUpdate: "plan",
752 entries: [
753 {
754 content: "Wait for more ACP progress",
755 priority: "high",
756 status: "in_progress",
757 },
758 ],
759 },
760 });
761 return yield* Effect.never;
762 }
763
764 if (emitActiveToolThenHang) {
765 const toolCallId = "tool-call-long-running-1";
766 yield* agent.client.sessionUpdate({
767 sessionId: requestedSessionId,
768 update: {
769 sessionUpdate: "tool_call",
770 toolCallId,
771 title: "Long-running tool",
772 kind: "execute",
773 status: "pending",
774 rawInput: { command: ["long-running-tool"] },
775 },
776 });
777 yield* agent.client.sessionUpdate({
778 sessionId: requestedSessionId,
779 update: {
780 sessionUpdate: "tool_call_update",
781 toolCallId,
782 status: "in_progress",
783 },
784 });
785 return yield* Effect.never;
786 }
787
788 if (emitXAiPromptCompleteThenHang) {
789 writeJsonRpcNotification("session/update", {
790 sessionId: requestedSessionId,
791 update: {
792 sessionUpdate: "agent_message_chunk",
793 content: { type: "text", text: "hello from" },
794 },
795 });
796
797 if (emitForeignSessionUpdates) {
798 writeJsonRpcNotification("session/update", {
799 sessionId: "mock-child-session-1",
800 update: {
801 sessionUpdate: "agent_message_chunk",
802 content: { type: "text", text: "child before completion" },
803 },
804 });
805 }
806
807 writeJsonRpcNotification("_x.ai/session/prompt_complete", {
808 sessionId: requestedSessionId,
809 promptId: promptIdFromRequestMeta(request) ?? "mock-xai-prompt-1",
810 ...(omitXAiPromptCompleteStopReason ? {} : { stopReason: "end_turn" }),
811 agentResult: null,
812 });
813
814 if (emitForeignSessionUpdates) {
815 writeJsonRpcNotification("session/update", {
816 sessionId: "mock-child-session-1",
817 update: {
818 sessionUpdate: "tool_call",
819 toolCallId: "child-tool-call-1",
820 title: "Child-only tool",
821 kind: "other",
822 status: "pending",
823 rawInput: {},
824 },
825 });
826 writeJsonRpcNotification("session/update", {
827 sessionId: "mock-child-session-1",
828 update: {
829 sessionUpdate: "agent_message_chunk",
830 content: { type: "text", text: "child after completion" },
831 },
832 });
833 }
834
835 for (const text of [" ", "mo", "ck"]) {
836 writeJsonRpcNotification("session/update", {
837 sessionId: requestedSessionId,
838 update: {
839 sessionUpdate: "agent_message_chunk",
840 content: { type: "text", text },
841 },
842 });
843 }
844
845 return yield* Effect.never;
846 }
847
848 if (emitGrokMonitorPostTurnPoll) {
849 const monitorCallId = "call-monitor-1";
850 const pollCallId = "call-monitor-poll-1";
851 const taskId = "01a05f41-5107-7550-821e-79e8d1cd7687";
852 const description = "Watch count-sheet Typst unit until done";
853 writeJsonRpcNotification("session/update", {
854 sessionId: requestedSessionId,
855 update: {
856 sessionUpdate: "tool_call",
857 toolCallId: monitorCallId,
858 title: "monitor",
859 kind: "other",
860 status: "pending",
861 rawInput: { description },
862 _meta: {
863 "x.ai/tool": { version: 1, name: "monitor", kind: "task", namespace: "grok_build" },
864 },
865 },
866 });
867 writeJsonRpcNotification("session/update", {
868 sessionId: requestedSessionId,
869 update: {
870 sessionUpdate: "tool_call_update",
871 toolCallId: monitorCallId,
872 status: "completed",
873 rawInput: { description },
874 rawOutput: {
875 type: "Monitor",
876 taskId,
877 timeoutMs: 36_000_000,
878 },
879 },
880 });
881 writeJsonRpcNotification("_x.ai/session/prompt_complete", {
882 sessionId: requestedSessionId,
883 promptId: promptIdFromRequestMeta(request) ?? "mock-xai-prompt-1",
884 stopReason: "end_turn",
885 agentResult: null,
886 });
887 yield* Effect.sleep("120 millis");
888 writeJsonRpcNotification("session/update", {
889 sessionId: requestedSessionId,
890 update: {
891 sessionUpdate: "tool_call",
892 toolCallId: pollCallId,
893 title: "get_command_or_subagent_output",
894 kind: "other",
895 status: "completed",
896 rawInput: { variant: "TaskOutput", task_ids: [taskId], timeout_ms: 0 },
897 rawOutput: {
898 type: "TaskOutput",
899 Result: {
900 task_id: taskId,
901 command: `[monitor] ${description}`,
902 status: "completed",
903 exit_code: 0,
904 output: "Monitor finished.",
905 },
906 },
907 },
908 });
909 return yield* Effect.never;
910 }
911
912 if (emitGrokBackgroundTaskStarted) {
913 const toolCallId = "call-fb9d0000-0000-0000-0000-000000000026";
914 const command = "sleep 40; echo done-a";
915 writeJsonRpcNotification("session/update", {
916 sessionId: requestedSessionId,
917 update: {
918 sessionUpdate: "tool_call",
919 toolCallId,
920 title: "run_terminal_command",
921 kind: "execute",
922 status: "in_progress",
923 rawInput: { command },
924 },
925 });
926 writeJsonRpcNotification("session/update", {
927 sessionId: requestedSessionId,
928 update: {
929 sessionUpdate: "tool_call_update",
930 toolCallId,
931 status: "completed",
932 rawOutput: {
933 type: "BackgroundTaskStarted",
934 task_id: toolCallId,
935 task_type: "bash",
936 status: "running",
937 command,
938 },
939 },
940 });
941 writeJsonRpcNotification("_x.ai/session/prompt_complete", {
942 sessionId: requestedSessionId,
943 promptId: promptIdFromRequestMeta(request) ?? "mock-xai-prompt-1",
944 stopReason: "end_turn",
945 agentResult: null,
946 });
947 return yield* Effect.never;
948 }
949
950 if (emitInterleavedAssistantToolCalls) {
951 const toolCallId = "tool-call-1";
952
953 yield* agent.client.sessionUpdate({
954 sessionId: requestedSessionId,
955 update: {
956 sessionUpdate: "agent_message_chunk",
957 content: { type: "text", text: "before tool" },
958 },
959 });
960
961 yield* agent.client.sessionUpdate({
962 sessionId: requestedSessionId,
963 update: {
964 sessionUpdate: "tool_call",
965 toolCallId,
966 title: "Terminal",
967 kind: "execute",
968 status: "pending",
969 rawInput: {
970 command: ["echo", "hello"],
971 },
972 },
973 });
974
975 yield* agent.client.sessionUpdate({
976 sessionId: requestedSessionId,
977 update: {
978 sessionUpdate: "tool_call_update",
979 toolCallId,
980 status: "completed",
981 rawOutput: {
982 exitCode: 0,
983 stdout: "hello",
984 stderr: "",
985 },
986 },
987 });
988
989 yield* agent.client.sessionUpdate({
990 sessionId: requestedSessionId,
991 update: {
992 sessionUpdate: "agent_message_chunk",
993 content: { type: "text", text: "after tool" },
994 },
995 });
996
997 return { stopReason: "end_turn" };
998 }
999
1000 if (emitToolCalls) {
1001 const toolCallId = "tool-call-1";
1002
1003 yield* agent.client.sessionUpdate({
1004 sessionId: requestedSessionId,
1005 update: {
1006 sessionUpdate: "tool_call",
1007 toolCallId,
1008 title: "Terminal",
1009 kind: "execute",
1010 status: "pending",
1011 rawInput: {
1012 command: ["cat", "server/package.json"],
1013 },
1014 },
1015 });
1016
1017 yield* agent.client.sessionUpdate({
1018 sessionId: requestedSessionId,
1019 update: {
1020 sessionUpdate: "tool_call_update",
1021 toolCallId,
1022 status: "in_progress",
1023 },
1024 });
1025
1026 const permissionOptions: Array<AcpSchema.PermissionOption> = [
1027 { optionId: permissionOptionIds.allowOnce, name: "Allow once", kind: "allow_once" },
1028 ...(omitAllowAlways
1029 ? []
1030 : [
1031 {
1032 optionId: permissionOptionIds.allowAlways,
1033 name: "Allow always",
1034 kind: "allow_always" as const,
1035 },
1036 ]),
1037 { optionId: permissionOptionIds.rejectOnce, name: "Reject", kind: "reject_once" },
1038 ];
1039
1040 let cancelled = cancelledSessions.delete(requestedSessionId);
1041 for (let index = 0; index < permissionRequestCount; index++) {
1042 const command =
1043 index > 0
1044 ? (process.env.T3_ACP_SECOND_PERMISSION_COMMAND ?? "cat server/package.json")
1045 : "cat server/package.json";
1046 const permission = yield* agent.client.requestPermission({
1047 sessionId: requestedSessionId,
1048 toolCall: {
1049 toolCallId: index === 0 ? toolCallId : `${toolCallId}-${index + 1}`,
1050 title: process.env.T3_ACP_PERMISSION_TITLE ?? `\`${command}\``,
1051 kind: "execute",
1052 status: "pending",
1053 rawInput: {
1054 variant: "Bash",
1055 command,
1056 description: index === 0 ? "Read package metadata" : "Read it again",
1057 },
1058 content: [
1059 {
1060 type: "content",
1061 content: {
1062 type: "text",
1063 text: `Not in allowlist: ${command}`,
1064 },
1065 },
1066 ],
1067 },
1068 options: permissionOptions,
1069 });
1070 cancelled =
1071 cancelled ||
1072 cancelledSessions.delete(requestedSessionId) ||
1073 permission.outcome.outcome === "cancelled";
1074 if (cancelled) {
1075 break;
1076 }
1077 }
1078
1079 yield* agent.client.sessionUpdate({
1080 sessionId: requestedSessionId,
1081 update: {
1082 sessionUpdate: "tool_call_update",
1083 toolCallId,
1084 title: "Terminal",
1085 kind: "execute",
1086 status: "completed",
1087 rawOutput: {
1088 exitCode: 0,
1089 stdout: '{ "name": "t3" }',
1090 stderr: "",
1091 },
1092 },
1093 });
1094
1095 yield* agent.client.sessionUpdate({
1096 sessionId: requestedSessionId,
1097 update: {
1098 sessionUpdate: "agent_message_chunk",
1099 content: { type: "text", text: "hello from mock" },
1100 },
1101 });
1102
1103 return { stopReason: cancelled ? "cancelled" : "end_turn" };
1104 }
1105
1106 if (emitGenericToolPlaceholders) {
1107 const toolCallId = "tool-call-generic-1";
1108
1109 yield* agent.client.sessionUpdate({
1110 sessionId: requestedSessionId,
1111 update: {
1112 sessionUpdate: "tool_call",
1113 toolCallId,
1114 title: "Read File",
1115 kind: "read",
1116 status: "pending",
1117 rawInput: {},
1118 },
1119 });
1120
1121 yield* agent.client.sessionUpdate({
1122 sessionId: requestedSessionId,
1123 update: {
1124 sessionUpdate: "tool_call_update",
1125 toolCallId,
1126 status: "in_progress",
1127 },
1128 });
1129
1130 yield* agent.client.sessionUpdate({
1131 sessionId: requestedSessionId,
1132 update: {
1133 sessionUpdate: "tool_call_update",
1134 toolCallId,
1135 status: "completed",
1136 rawOutput: {
1137 content: "package.json\n",
1138 },
1139 },
1140 });
1141
1142 return { stopReason: "end_turn" };
1143 }
1144
1145 if (emitAskQuestion) {
1146 yield* agent.client.extRequest("cursor/ask_question", {
1147 toolCallId: "ask-question-tool-call-1",
1148 title: "Question",
1149 questions: [
1150 {
1151 id: "scope",
1152 prompt: "Which scope?",
1153 options: [
1154 { id: "workspace", label: "Workspace" },
1155 { id: "session", label: "Session" },
1156 ],
1157 },
1158 ],
1159 });
1160
1161 return { stopReason: "end_turn" };
1162 }
1163
1164 if (emitXAiAskUserQuestion || emitXAiAskUserQuestionThenHang) {
1165 const result = yield* agent.client.extRequest("_x.ai/ask_user_question", {
1166 method: "x.ai/ask_user_question",
1167 params: {
1168 sessionId: requestedSessionId,
1169 toolCallId: "ask-user-question-tool-call-1",
1170 questions: [
1171 {
1172 question: "Which scope should Grok use?",
1173 multiSelect: null,
1174 options: [
1175 { label: "Workspace", description: "Use the current workspace" },
1176 { label: "Session", description: "Only use this session" },
1177 ],
1178 },
1179 ],
1180 mode: "default",
1181 },
1182 });
1183 if (typeof result !== "object" || result === null || !("outcome" in result)) {
1184 throw new Error("Expected _x.ai/ask_user_question response outcome.");
1185 }
1186 if (result.outcome === "cancelled") {
1187 return { stopReason: "end_turn" };
1188 }
1189 if (
1190 result.outcome !== "accepted" ||
1191 !("answers" in result) ||
1192 typeof result.answers !== "object" ||
1193 result.answers === null
1194 ) {
1195 throw new Error("Expected accepted _x.ai/ask_user_question response answers.");
1196 }
1197
1198 if (emitXAiAskUserQuestionThenHang) {
1199 return yield* Effect.never;
1200 }
1201
1202 return { stopReason: "end_turn" };
1203 }
1204
1205 if (emitXAiPlanMdWrite) {
1206 // Match Grok's real session layout so isGrokPlanMarkdownPath accepts it.
1207 const planRoot = process.env.T3_ACP_PLAN_ROOT ?? "/tmp/mock-home/.grok";
1208 const planPath = `${planRoot}/sessions/${requestedSessionId}/plan.md`;
1209 const planBody = "# Mock plan\n\n- Write the feature\n- Add a test\n- Ship it\n";
1210 // enter_plan_mode first so the adapter arms planModeActive.
1211 yield* agent.client.sessionUpdate({
1212 sessionId: requestedSessionId,
1213 update: {
1214 sessionUpdate: "tool_call",
1215 toolCallId: "enter-plan-mode-1",
1216 title: "enter_plan_mode",
1217 kind: "other",
1218 status: "completed",
1219 rawInput: { variant: "EnterPlanMode" },
1220 },
1221 });
1222 yield* agent.client.sessionUpdate({
1223 sessionId: requestedSessionId,
1224 update: {
1225 sessionUpdate: "tool_call",
1226 toolCallId: "plan-md-write-1",
1227 title: "write",
1228 kind: "edit",
1229 status: "pending",
1230 rawInput: { file_path: planPath, content: planBody },
1231 },
1232 });
1233 yield* agent.client.sessionUpdate({
1234 sessionId: requestedSessionId,
1235 update: {
1236 sessionUpdate: "tool_call_update",
1237 toolCallId: "plan-md-write-1",
1238 kind: "edit",
1239 status: "completed",
1240 title: `Write \`${planPath}\``,
1241 rawInput: { file_path: planPath, content: planBody },
1242 content: [
1243 {
1244 type: "diff",
1245 path: planPath,
1246 oldText: "",
1247 newText: planBody,
1248 },
1249 ],
1250 },
1251 });
1252 return { stopReason: "end_turn" };
1253 }
1254
1255 if (emitXAiExitPlanMode) {
1256 const result = yield* agent.client.extRequest("_x.ai/exit_plan_mode", {
1257 method: "x.ai/exit_plan_mode",
1258 params: {
1259 sessionId: requestedSessionId,
1260 toolCallId: "exit-plan-mode-tool-call-1",
1261 planContent: "# Exit plan\n\n- Step one\n- Step two\n",
1262 },
1263 });
1264 if (typeof result !== "object" || result === null || !("outcome" in result)) {
1265 throw new Error("Expected _x.ai/exit_plan_mode response outcome.");
1266 }
1267 if (
1268 result.outcome !== "abandoned" &&
1269 result.outcome !== "approved" &&
1270 result.outcome !== "request_changes"
1271 ) {
1272 throw new Error(
1273 `Expected exit_plan_mode outcome abandoned|approved|request_changes, got ${String(result.outcome)}`,
1274 );
1275 }
1276 return { stopReason: "end_turn" };
1277 }
1278
1279 if (emitForeignSessionUpdates) {
1280 yield* agent.client.sessionUpdate({
1281 sessionId: requestedSessionId,
1282 update: {
1283 sessionUpdate: "agent_message_chunk",
1284 content: { type: "text", text: "root before child" },
1285 },
1286 });
1287 yield* agent.client.sessionUpdate({
1288 sessionId: "mock-child-session-1",
1289 update: {
1290 sessionUpdate: "agent_message_chunk",
1291 content: { type: "text", text: "child content" },
1292 },
1293 });
1294 yield* agent.client.sessionUpdate({
1295 sessionId: "mock-child-session-1",
1296 update: {
1297 sessionUpdate: "tool_call",
1298 toolCallId: "child-tool-call-1",
1299 title: "Child-only tool",
1300 kind: "other",
1301 status: "pending",
1302 rawInput: {},
1303 },
1304 });
1305 yield* agent.client.sessionUpdate({
1306 sessionId: requestedSessionId,
1307 update: {
1308 sessionUpdate: "agent_message_chunk",
1309 content: { type: "text", text: " root after child" },
1310 },
1311 });
1312 return { stopReason: "end_turn" };
1313 }
1314
1315 yield* agent.client.sessionUpdate({
1316 sessionId: requestedSessionId,
1317 update: {
1318 sessionUpdate: "plan",
1319 entries: [
1320 {
1321 content: "Inspect mock ACP state",
1322 priority: "high",
1323 status: "completed",
1324 },
1325 {
1326 content: "Implement the requested change",
1327 priority: "high",
1328 status: "in_progress",
1329 },
1330 ],
1331 },
1332 });
1333
1334 yield* agent.client.sessionUpdate({
1335 sessionId: requestedSessionId,
1336 update: {
1337 sessionUpdate: "agent_message_chunk",
1338 content: { type: "text", text: promptResponseText ?? "hello from mock" },
1339 },
1340 });
1341
1342 return { stopReason: "end_turn" };
1343 }),
1344 );
1345
1346 yield* agent.handleUnknownExtRequest((method, params) => {
1347 if (method === "_test/environment") {
1348 return Effect.succeed({
1349 inherited: process.env.T3_ACP_RUNTIME_AMBIENT === "sentinel",
1350 explicit: process.env.T3_ACP_RUNTIME_EXPLICIT === "kept",
1351 });
1352 }
1353 if (method === "_test/release-resume") {
1354 return Deferred.succeed(resumeRelease, undefined).pipe(Effect.as({}));
1355 }
1356 if (method === "_test/finish-cancel") {
1357 return Deferred.succeed(nativeCancelRelease, undefined).pipe(Effect.as({}));
1358 }
1359 if (method === "_test/startup-metadata") {
1360 return Effect.gen(function* () {
1361 for (const [metadataSessionId, commandName, modeId] of [
1362 [sessionId, "plan", "code"],
1363 ["child-session", "foreign-command", "ask"],
1364 ] as const) {
1365 yield* agent.client.sessionUpdate({
1366 sessionId: metadataSessionId,
1367 update: {
1368 sessionUpdate: "available_commands_update",
1369 availableCommands: [{ name: commandName, description: "Native command" }],
1370 },
1371 });
1372 yield* agent.client.sessionUpdate({
1373 sessionId: metadataSessionId,
1374 update: { sessionUpdate: "current_mode_update", currentModeId: modeId },
1375 });
1376 yield* agent.client.sessionUpdate({
1377 sessionId: metadataSessionId,
1378 update: {
1379 sessionUpdate: "config_option_update",
1380 configOptions: configOptions().map((option) =>
1381 option.type === "select" && option.category === "model"
1382 ? {
1383 ...option,
1384 currentValue: metadataSessionId === sessionId ? "gpt-5.4" : "default",
1385 }
1386 : option,
1387 ),
1388 },
1389 });
1390 yield* agent.client.sessionUpdate({
1391 sessionId: metadataSessionId,
1392 update: {
1393 sessionUpdate: "agent_message_chunk",
1394 content: { type: "text", text: "Startup transcript must not replay." },
1395 },
1396 });
1397 }
1398 return {};
1399 });
1400 }
1401 if (method === "cursor/list_available_models") {
1402 return Effect.succeed({
1403 models: availableModels(),
1404 });
1405 }
1406
1407 if (method !== "session/mode/set") {
1408 return Effect.fail(AcpError.AcpRequestError.methodNotFound(method));
1409 }
1410
1411 const nextModeId =
1412 typeof params === "object" &&
1413 params !== null &&
1414 "modeId" in params &&
1415 typeof params.modeId === "string"
1416 ? params.modeId
1417 : typeof params === "object" &&
1418 params !== null &&
1419 "mode" in params &&
1420 typeof params.mode === "string"
1421 ? params.mode
1422 : undefined;
1423 const requestedSessionId =
1424 typeof params === "object" &&
1425 params !== null &&
1426 "sessionId" in params &&
1427 typeof params.sessionId === "string"
1428 ? params.sessionId
1429 : sessionId;
1430
1431 if (typeof nextModeId === "string" && nextModeId.trim()) {
1432 currentModeId = nextModeId.trim();
1433 return agent.client
1434 .sessionUpdate({
1435 sessionId: requestedSessionId,
1436 update: {
1437 sessionUpdate: "current_mode_update",
1438 currentModeId,
1439 },
1440 })
1441 .pipe(Effect.as({}));
1442 }
1443
1444 return Effect.succeed({});
1445 });
1446
1447 yield* agent.handleUnknownExtNotification((method) =>
1448 method === "_test/exit" ? Effect.sync(() => process.exit(19)) : Effect.void,
1449 );
1450
1451 return yield* Effect.never;
1452}).pipe(
1453 Effect.provide(
1454 EffectAcpAgent.layerStdio(
1455 requestLogPath
1456 ? {
1457 logIncoming: true,
1458 logger: (event) => {
1459 if (event.direction !== "incoming" || event.stage !== "raw") {
1460 return Effect.void;
1461 }
1462 if (typeof event.payload !== "string") {
1463 return Effect.void;
1464 }
1465 const payload = event.payload;
1466 return Effect.sync(() => {
1467 NodeFS.appendFileSync(
1468 requestLogPath,
1469 payload.endsWith("\n") ? payload : `${payload}\n`,
1470 "utf8",
1471 );
1472 });
1473 },
1474 }
1475 : {},
1476 ),
1477 ),
1478 Effect.scoped,
1479 Effect.provide(NodeServices.layer),
1480);
1481
1482NodeRuntime.runMain(program);