acpx 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +65 -16
  2. package/dist/{acp-jsonrpc-BNHXq7qK.js → acp-jsonrpc-C7pPk9Tw.js} +1 -1
  3. package/dist/{acp-jsonrpc-BNHXq7qK.js.map → acp-jsonrpc-C7pPk9Tw.js.map} +1 -1
  4. package/dist/cli-5s-E-Y99.js +176 -0
  5. package/dist/cli-5s-E-Y99.js.map +1 -0
  6. package/dist/cli.d.ts +1 -118
  7. package/dist/cli.d.ts.map +1 -1
  8. package/dist/cli.js +235 -336
  9. package/dist/cli.js.map +1 -1
  10. package/dist/flags-BkWInxAq.js +194 -0
  11. package/dist/flags-BkWInxAq.js.map +1 -0
  12. package/dist/flows-DnIYoHI1.js +1551 -0
  13. package/dist/flows-DnIYoHI1.js.map +1 -0
  14. package/dist/flows.d.ts +292 -0
  15. package/dist/flows.d.ts.map +1 -0
  16. package/dist/flows.js +2 -0
  17. package/dist/{output-BmkPP7qE.js → output-C58ukIo3.js} +137 -14
  18. package/dist/output-C58ukIo3.js.map +1 -0
  19. package/dist/{output-render-DEAaMxg8.js → output-render-C7w9NZ2H.js} +10 -10
  20. package/dist/output-render-C7w9NZ2H.js.map +1 -0
  21. package/dist/{queue-ipc-EQLpBMKv.js → queue-ipc-CgWf63GN.js} +258 -95
  22. package/dist/queue-ipc-CgWf63GN.js.map +1 -0
  23. package/dist/{session-C2Q8ktsN.js → session-BtpTC2pM.js} +687 -138
  24. package/dist/session-BtpTC2pM.js.map +1 -0
  25. package/dist/types-CeRKmEQ1.d.ts +137 -0
  26. package/dist/types-CeRKmEQ1.d.ts.map +1 -0
  27. package/package.json +35 -16
  28. package/skills/acpx/SKILL.md +22 -5
  29. package/dist/output-BmkPP7qE.js.map +0 -1
  30. package/dist/output-render-DEAaMxg8.js.map +0 -1
  31. package/dist/queue-ipc-EQLpBMKv.js.map +0 -1
  32. package/dist/runtime-session-id-C544sPPL.js +0 -31
  33. package/dist/runtime-session-id-C544sPPL.js.map +0 -1
  34. package/dist/session-C2Q8ktsN.js.map +0 -1
@@ -1,4 +1,5 @@
1
- import { i as parsePromptStopReason, r as parseJsonRpcErrorMessage } from "./acp-jsonrpc-BNHXq7qK.js";
1
+ import { t as __exportAll } from "./rolldown-runtime-CiIaOW0V.js";
2
+ import { i as parsePromptStopReason, r as parseJsonRpcErrorMessage } from "./acp-jsonrpc-C7pPk9Tw.js";
2
3
  //#region src/jsonrpc-error.ts
3
4
  const OUTPUT_ERROR_JSONRPC_CODES = {
4
5
  NO_SESSION: -32002,
@@ -44,20 +45,129 @@ function buildJsonRpcErrorResponse(params) {
44
45
  };
45
46
  }
46
47
  //#endregion
48
+ //#region src/read-output-suppression.ts
49
+ const SUPPRESSED_READ_OUTPUT = "[read output suppressed]";
50
+ function inferToolKindFromTitle(title) {
51
+ const normalized = title?.trim().toLowerCase();
52
+ if (!normalized) return;
53
+ const head = normalized.split(":", 1)[0]?.trim();
54
+ if (!head) return;
55
+ if (head.includes("read") || head.includes("cat") || head.includes("open") || head.includes("view")) return "read";
56
+ }
57
+ function isReadLikeTool(tool) {
58
+ return tool.kind?.trim().toLowerCase() === "read" || inferToolKindFromTitle(tool.title) === "read";
59
+ }
60
+ //#endregion
47
61
  //#region src/output-json-formatter.ts
48
62
  const DEFAULT_JSON_SESSION_ID = "unknown";
63
+ function asRecord$1(value) {
64
+ if (!value || typeof value !== "object" || Array.isArray(value)) return;
65
+ return value;
66
+ }
67
+ function jsonRpcIdKey(value) {
68
+ if (typeof value === "string") return `s:${value}`;
69
+ if (typeof value === "number" && Number.isFinite(value)) return `n:${value}`;
70
+ }
71
+ function sanitizeReadResult(result) {
72
+ const record = asRecord$1(result);
73
+ if (!record || typeof record.content !== "string") return result;
74
+ return {
75
+ ...record,
76
+ content: SUPPRESSED_READ_OUTPUT
77
+ };
78
+ }
79
+ function sanitizeToolContent(content) {
80
+ if (!Array.isArray(content)) return content;
81
+ return [{
82
+ type: "content",
83
+ content: {
84
+ type: "text",
85
+ text: SUPPRESSED_READ_OUTPUT
86
+ }
87
+ }];
88
+ }
89
+ function sanitizeToolMessage(message) {
90
+ const root = asRecord$1(message);
91
+ const params = asRecord$1(root?.params);
92
+ const update = asRecord$1(params?.update);
93
+ if (!root || !params || !update) return message;
94
+ return {
95
+ ...root,
96
+ params: {
97
+ ...params,
98
+ update: {
99
+ ...update,
100
+ rawOutput: Object.prototype.hasOwnProperty.call(update, "rawOutput") && update.rawOutput !== void 0 ? { content: SUPPRESSED_READ_OUTPUT } : update.rawOutput,
101
+ content: Object.prototype.hasOwnProperty.call(update, "content") && update.content !== void 0 ? sanitizeToolContent(update.content) : update.content
102
+ }
103
+ }
104
+ };
105
+ }
49
106
  var JsonOutputFormatter = class {
50
107
  stdout;
108
+ suppressReads;
51
109
  sessionId;
52
- constructor(stdout, context) {
110
+ requestMethodById = /* @__PURE__ */ new Map();
111
+ toolStateById = /* @__PURE__ */ new Map();
112
+ constructor(stdout, suppressReads, context) {
53
113
  this.stdout = stdout;
114
+ this.suppressReads = suppressReads;
54
115
  this.sessionId = context?.sessionId?.trim() || DEFAULT_JSON_SESSION_ID;
55
116
  }
56
117
  setContext(context) {
57
118
  this.sessionId = context.sessionId?.trim() || this.sessionId || DEFAULT_JSON_SESSION_ID;
58
119
  }
59
120
  onAcpMessage(message) {
60
- this.stdout.write(`${JSON.stringify(message)}\n`);
121
+ this.stdout.write(`${JSON.stringify(this.sanitizeMessage(message))}\n`);
122
+ }
123
+ sanitizeMessage(message) {
124
+ if (!this.suppressReads) return message;
125
+ const sanitizedResponse = this.sanitizeReadResponse(message);
126
+ if (sanitizedResponse !== message) return sanitizedResponse;
127
+ const sanitizedToolMessage = this.sanitizeReadToolMessage(message);
128
+ if (sanitizedToolMessage !== message) return sanitizedToolMessage;
129
+ this.trackRequestMethod(message);
130
+ return message;
131
+ }
132
+ trackRequestMethod(message) {
133
+ const candidate = message;
134
+ if (typeof candidate.method !== "string") return;
135
+ const idKey = jsonRpcIdKey(candidate.id);
136
+ if (!idKey) return;
137
+ this.requestMethodById.set(idKey, candidate.method);
138
+ }
139
+ sanitizeReadResponse(message) {
140
+ const candidate = message;
141
+ const idKey = jsonRpcIdKey(candidate.id);
142
+ if (!idKey || !Object.hasOwn(candidate, "result")) return message;
143
+ const method = this.requestMethodById.get(idKey);
144
+ this.requestMethodById.delete(idKey);
145
+ if (method !== "fs/read_text_file") return message;
146
+ const root = asRecord$1(message);
147
+ if (!root) return message;
148
+ return {
149
+ ...root,
150
+ result: sanitizeReadResult(candidate.result)
151
+ };
152
+ }
153
+ sanitizeReadToolMessage(message) {
154
+ const root = asRecord$1(message);
155
+ if (root?.method !== "session/update") return message;
156
+ const params = asRecord$1(root.params);
157
+ const update = asRecord$1(params?.update);
158
+ if (!params || !update) return message;
159
+ const sessionUpdate = update.sessionUpdate;
160
+ if (sessionUpdate !== "tool_call" && sessionUpdate !== "tool_call_update") return message;
161
+ const toolCallId = typeof update.toolCallId === "string" ? update.toolCallId : void 0;
162
+ if (!toolCallId) return message;
163
+ const previous = this.toolStateById.get(toolCallId) ?? {};
164
+ const current = {
165
+ title: typeof update.title === "string" ? update.title : previous.title,
166
+ kind: typeof update.kind === "string" || update.kind === null ? update.kind : previous.kind
167
+ };
168
+ this.toolStateById.set(toolCallId, current);
169
+ if (!isReadLikeTool(current)) return message;
170
+ return sanitizeToolMessage(message);
61
171
  }
62
172
  onError(params) {
63
173
  this.stdout.write(`${JSON.stringify(buildJsonRpcErrorResponse({
@@ -73,11 +183,12 @@ var JsonOutputFormatter = class {
73
183
  }
74
184
  flush() {}
75
185
  };
76
- function createJsonOutputFormatter(stdout, context) {
77
- return new JsonOutputFormatter(stdout, context);
186
+ function createJsonOutputFormatter(stdout, suppressReads = false, context) {
187
+ return new JsonOutputFormatter(stdout, suppressReads, context);
78
188
  }
79
189
  //#endregion
80
190
  //#region src/output.ts
191
+ var output_exports = /* @__PURE__ */ __exportAll({ createOutputFormatter: () => createOutputFormatter });
81
192
  const MAX_THOUGHT_CHARS = 900;
82
193
  const MAX_INLINE_CHARS = 220;
83
194
  const MAX_OUTPUT_CHARS = 2e3;
@@ -133,6 +244,9 @@ function extractJsonRpcMethod(message) {
133
244
  function collapseWhitespace(value) {
134
245
  return value.replace(/\s+/g, " ").trim();
135
246
  }
247
+ function normalizeLineEndings(value) {
248
+ return value.replace(/\r\n?/g, "\n");
249
+ }
136
250
  function truncate(value, maxChars) {
137
251
  if (value.length <= maxChars) return value;
138
252
  if (maxChars <= 3) return value.slice(0, maxChars);
@@ -308,6 +422,10 @@ function summarizeToolOutput(rawOutput, content) {
308
422
  if (fragments.length === 0) return;
309
423
  return fragments.join("\n\n");
310
424
  }
425
+ function renderToolOutput(state, suppressReads) {
426
+ if (suppressReads && isReadLikeTool(state)) return SUPPRESSED_READ_OUTPUT;
427
+ return summarizeToolOutput(state.rawOutput, state.content);
428
+ }
311
429
  function limitOutputBlock(value) {
312
430
  const normalized = value.replace(/\r\n/g, "\n").trim();
313
431
  if (!normalized) return "";
@@ -324,14 +442,16 @@ function limitOutputBlock(value) {
324
442
  var TextOutputFormatter = class {
325
443
  stdout;
326
444
  useColor;
445
+ suppressReads;
327
446
  toolStates = /* @__PURE__ */ new Map();
328
447
  thoughtBuffer = "";
329
448
  wroteAny = false;
330
449
  atLineStart = true;
331
450
  section = null;
332
- constructor(stdout) {
451
+ constructor(stdout, suppressReads) {
333
452
  this.stdout = stdout;
334
453
  this.useColor = Boolean(stdout.isTTY);
454
+ this.suppressReads = suppressReads;
335
455
  }
336
456
  setContext(_context) {}
337
457
  onAcpMessage(message) {
@@ -431,11 +551,13 @@ var TextOutputFormatter = class {
431
551
  this.write(text);
432
552
  }
433
553
  flushThoughtBuffer() {
434
- const thought = truncate(collapseWhitespace(this.thoughtBuffer), MAX_THOUGHT_CHARS);
554
+ const thought = truncate(normalizeLineEndings(this.thoughtBuffer).trim(), MAX_THOUGHT_CHARS);
435
555
  this.thoughtBuffer = "";
436
556
  if (!thought) return;
437
557
  this.beginSection("thought");
438
- this.writeLine(this.dim(`[thinking] ${thought}`));
558
+ const [firstLine, ...restLines] = thought.split("\n");
559
+ this.writeLine(this.dim(`[thinking] ${firstLine}`));
560
+ for (const line of restLines) this.writeLine(this.dim(` ${line}`));
439
561
  }
440
562
  renderToolUpdate(update) {
441
563
  const state = this.getOrCreateToolState(update.toolCallId);
@@ -479,7 +601,7 @@ var TextOutputFormatter = class {
479
601
  kind: state.kind,
480
602
  input: summarizeToolInput(state.rawInput),
481
603
  files: formatLocations(state.locations),
482
- output: summarizeToolOutput(state.rawOutput, state.content)
604
+ output: renderToolOutput(state, this.suppressReads)
483
605
  };
484
606
  return safeJson(signaturePayload, 0) ?? JSON.stringify(signaturePayload);
485
607
  }
@@ -504,7 +626,7 @@ var TextOutputFormatter = class {
504
626
  if (input) this.writeLine(` input: ${input}`);
505
627
  const files = formatLocations(state.locations);
506
628
  if (files) this.writeLine(` files: ${files}`);
507
- const output = summarizeToolOutput(state.rawOutput, state.content);
629
+ const output = renderToolOutput(state, this.suppressReads);
508
630
  if (output) {
509
631
  this.writeLine(" output:");
510
632
  this.writeLine(indentBlock(limitOutputBlock(output), " "));
@@ -556,14 +678,15 @@ var QuietOutputFormatter = class {
556
678
  };
557
679
  function createOutputFormatter(format, options = {}) {
558
680
  const stdout = options.stdout ?? process.stdout;
681
+ const suppressReads = options.suppressReads === true;
559
682
  switch (format) {
560
- case "text": return new TextOutputFormatter(stdout);
561
- case "json": return createJsonOutputFormatter(stdout, options.jsonContext);
683
+ case "text": return new TextOutputFormatter(stdout, suppressReads);
684
+ case "json": return createJsonOutputFormatter(stdout, suppressReads, options.jsonContext);
562
685
  case "quiet": return new QuietOutputFormatter(stdout);
563
686
  default: throw new Error("Unsupported output format");
564
687
  }
565
688
  }
566
689
  //#endregion
567
- export { createOutputFormatter };
690
+ export { output_exports as n, createOutputFormatter as t };
568
691
 
569
- //# sourceMappingURL=output-BmkPP7qE.js.map
692
+ //# sourceMappingURL=output-C58ukIo3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output-C58ukIo3.js","names":["asRecord"],"sources":["../src/jsonrpc-error.ts","../src/read-output-suppression.ts","../src/output-json-formatter.ts","../src/output.ts"],"sourcesContent":["import type { OutputErrorAcpPayload, OutputErrorCode, OutputErrorOrigin } from \"./types.js\";\n\nexport const OUTPUT_ERROR_JSONRPC_CODES: Record<OutputErrorCode, number> = {\n NO_SESSION: -32002,\n TIMEOUT: -32070,\n PERMISSION_DENIED: -32071,\n PERMISSION_PROMPT_UNAVAILABLE: -32072,\n RUNTIME: -32603,\n USAGE: -32602,\n};\n\ntype JsonRpcErrorObject = {\n code: number;\n message: string;\n data?: unknown;\n};\n\nexport type BuildJsonRpcErrorParams = {\n id?: string | number | null;\n outputCode: OutputErrorCode;\n detailCode?: string;\n origin?: OutputErrorOrigin;\n message: string;\n retryable?: boolean;\n timestamp?: string;\n sessionId?: string;\n acp?: OutputErrorAcpPayload;\n};\n\nfunction hasValidAcpError(\n acp: OutputErrorAcpPayload | undefined,\n): acp is { code: number; message: string; data?: unknown } {\n return Boolean(\n acp &&\n Number.isFinite(acp.code) &&\n typeof acp.message === \"string\" &&\n acp.message.trim().length > 0,\n );\n}\n\nfunction buildFallbackData(params: BuildJsonRpcErrorParams): Record<string, unknown> {\n const data: Record<string, unknown> = {\n acpxCode: params.outputCode,\n detailCode: params.detailCode,\n origin: params.origin,\n retryable: params.retryable,\n timestamp: params.timestamp,\n sessionId: params.sessionId,\n };\n\n for (const [key, value] of Object.entries(data)) {\n if (value === undefined) {\n delete data[key];\n }\n }\n\n return data;\n}\n\nfunction buildErrorObject(params: BuildJsonRpcErrorParams): JsonRpcErrorObject {\n if (hasValidAcpError(params.acp)) {\n return {\n code: params.acp.code,\n message: params.acp.message,\n ...(params.acp.data !== undefined ? { data: params.acp.data } : {}),\n };\n }\n\n const data = buildFallbackData(params);\n return {\n code: OUTPUT_ERROR_JSONRPC_CODES[params.outputCode] ?? -32603,\n message: params.message,\n ...(Object.keys(data).length > 0 ? { data } : {}),\n };\n}\n\nexport function buildJsonRpcErrorResponse(params: BuildJsonRpcErrorParams): {\n jsonrpc: \"2.0\";\n id: string | number | null;\n error: JsonRpcErrorObject;\n} {\n return {\n jsonrpc: \"2.0\",\n id: params.id ?? null,\n error: buildErrorObject(params),\n };\n}\n","export const SUPPRESSED_READ_OUTPUT = \"[read output suppressed]\";\n\nexport type ReadLikeToolDescriptor = {\n title?: string;\n kind?: string | null;\n};\n\nfunction inferToolKindFromTitle(title: string | undefined): string | undefined {\n const normalized = title?.trim().toLowerCase();\n if (!normalized) {\n return undefined;\n }\n\n const head = normalized.split(\":\", 1)[0]?.trim();\n if (!head) {\n return undefined;\n }\n\n if (\n head.includes(\"read\") ||\n head.includes(\"cat\") ||\n head.includes(\"open\") ||\n head.includes(\"view\")\n ) {\n return \"read\";\n }\n\n return undefined;\n}\n\nexport function isReadLikeTool(tool: ReadLikeToolDescriptor): boolean {\n return (\n tool.kind?.trim().toLowerCase() === \"read\" || inferToolKindFromTitle(tool.title) === \"read\"\n );\n}\n","import { buildJsonRpcErrorResponse } from \"./jsonrpc-error.js\";\nimport { isReadLikeTool, SUPPRESSED_READ_OUTPUT } from \"./read-output-suppression.js\";\nimport type {\n OutputErrorAcpPayload,\n OutputErrorCode,\n OutputErrorOrigin,\n OutputFormatter,\n OutputFormatterContext,\n} from \"./types.js\";\n\ntype WritableLike = {\n write(chunk: string): void;\n};\n\ntype JsonRpcRequestMessage = {\n jsonrpc?: unknown;\n id?: unknown;\n method?: unknown;\n};\n\ntype JsonRpcResponseMessage = {\n jsonrpc?: unknown;\n id?: unknown;\n result?: unknown;\n};\n\nconst DEFAULT_JSON_SESSION_ID = \"unknown\";\n\nfunction asRecord(value: unknown): Record<string, unknown> | undefined {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n return undefined;\n }\n return value as Record<string, unknown>;\n}\n\nfunction jsonRpcIdKey(value: unknown): string | undefined {\n if (typeof value === \"string\") {\n return `s:${value}`;\n }\n if (typeof value === \"number\" && Number.isFinite(value)) {\n return `n:${value}`;\n }\n return undefined;\n}\n\nfunction sanitizeReadResult(result: unknown): unknown {\n const record = asRecord(result);\n if (!record || typeof record.content !== \"string\") {\n return result;\n }\n return {\n ...record,\n content: SUPPRESSED_READ_OUTPUT,\n };\n}\n\nfunction sanitizeToolContent(content: unknown): unknown {\n if (!Array.isArray(content)) {\n return content;\n }\n\n return [\n {\n type: \"content\",\n content: {\n type: \"text\",\n text: SUPPRESSED_READ_OUTPUT,\n },\n },\n ];\n}\n\nfunction sanitizeToolMessage(message: unknown): unknown {\n const root = asRecord(message);\n const params = asRecord(root?.params);\n const update = asRecord(params?.update);\n if (!root || !params || !update) {\n return message;\n }\n\n return {\n ...root,\n params: {\n ...params,\n update: {\n ...update,\n rawOutput:\n Object.prototype.hasOwnProperty.call(update, \"rawOutput\") &&\n update.rawOutput !== undefined\n ? { content: SUPPRESSED_READ_OUTPUT }\n : update.rawOutput,\n content:\n Object.prototype.hasOwnProperty.call(update, \"content\") && update.content !== undefined\n ? sanitizeToolContent(update.content)\n : update.content,\n },\n },\n };\n}\n\nclass JsonOutputFormatter implements OutputFormatter {\n private readonly stdout: WritableLike;\n private readonly suppressReads: boolean;\n private sessionId: string;\n private readonly requestMethodById = new Map<string, string>();\n private readonly toolStateById = new Map<string, { title?: string; kind?: string | null }>();\n\n constructor(stdout: WritableLike, suppressReads: boolean, context?: OutputFormatterContext) {\n this.stdout = stdout;\n this.suppressReads = suppressReads;\n this.sessionId = context?.sessionId?.trim() || DEFAULT_JSON_SESSION_ID;\n }\n\n setContext(context: OutputFormatterContext): void {\n this.sessionId = context.sessionId?.trim() || this.sessionId || DEFAULT_JSON_SESSION_ID;\n }\n\n onAcpMessage(message: unknown): void {\n this.stdout.write(`${JSON.stringify(this.sanitizeMessage(message))}\\n`);\n }\n\n private sanitizeMessage(message: unknown): unknown {\n if (!this.suppressReads) {\n return message;\n }\n\n const sanitizedResponse = this.sanitizeReadResponse(message);\n if (sanitizedResponse !== message) {\n return sanitizedResponse;\n }\n\n const sanitizedToolMessage = this.sanitizeReadToolMessage(message);\n if (sanitizedToolMessage !== message) {\n return sanitizedToolMessage;\n }\n\n this.trackRequestMethod(message);\n return message;\n }\n\n private trackRequestMethod(message: unknown): void {\n const candidate = message as JsonRpcRequestMessage;\n if (typeof candidate.method !== \"string\") {\n return;\n }\n const idKey = jsonRpcIdKey(candidate.id);\n if (!idKey) {\n return;\n }\n this.requestMethodById.set(idKey, candidate.method);\n }\n\n private sanitizeReadResponse(message: unknown): unknown {\n const candidate = message as JsonRpcResponseMessage;\n const idKey = jsonRpcIdKey(candidate.id);\n if (!idKey || !Object.hasOwn(candidate, \"result\")) {\n return message;\n }\n\n const method = this.requestMethodById.get(idKey);\n this.requestMethodById.delete(idKey);\n if (method !== \"fs/read_text_file\") {\n return message;\n }\n\n const root = asRecord(message);\n if (!root) {\n return message;\n }\n\n return {\n ...root,\n result: sanitizeReadResult(candidate.result),\n };\n }\n\n private sanitizeReadToolMessage(message: unknown): unknown {\n const root = asRecord(message);\n if (root?.method !== \"session/update\") {\n return message;\n }\n\n const params = asRecord(root.params);\n const update = asRecord(params?.update);\n if (!params || !update) {\n return message;\n }\n\n const sessionUpdate = update.sessionUpdate;\n if (sessionUpdate !== \"tool_call\" && sessionUpdate !== \"tool_call_update\") {\n return message;\n }\n\n const toolCallId = typeof update.toolCallId === \"string\" ? update.toolCallId : undefined;\n if (!toolCallId) {\n return message;\n }\n\n const previous = this.toolStateById.get(toolCallId) ?? {};\n const current = {\n title: typeof update.title === \"string\" ? update.title : previous.title,\n kind: typeof update.kind === \"string\" || update.kind === null ? update.kind : previous.kind,\n };\n this.toolStateById.set(toolCallId, current);\n\n if (!isReadLikeTool(current)) {\n return message;\n }\n\n return sanitizeToolMessage(message);\n }\n\n onError(params: {\n code: OutputErrorCode;\n detailCode?: string;\n origin?: OutputErrorOrigin;\n message: string;\n retryable?: boolean;\n acp?: OutputErrorAcpPayload;\n timestamp?: string;\n }): void {\n this.stdout.write(\n `${JSON.stringify(\n buildJsonRpcErrorResponse({\n outputCode: params.code,\n detailCode: params.detailCode,\n origin: params.origin,\n message: params.message,\n retryable: params.retryable,\n timestamp: params.timestamp,\n sessionId: this.sessionId,\n acp: params.acp,\n }),\n )}\\n`,\n );\n }\n\n flush(): void {\n // no-op for streaming output\n }\n}\n\nexport function createJsonOutputFormatter(\n stdout: WritableLike,\n suppressReads = false,\n context?: OutputFormatterContext,\n): OutputFormatter {\n return new JsonOutputFormatter(stdout, suppressReads, context);\n}\n","import type {\n AnyMessage,\n ContentBlock,\n SessionNotification,\n ToolCall,\n ToolCallContent,\n ToolCallLocation,\n ToolCallStatus,\n ToolCallUpdate,\n} from \"@agentclientprotocol/sdk\";\nimport { parseJsonRpcErrorMessage, parsePromptStopReason } from \"./acp-jsonrpc.js\";\nimport { createJsonOutputFormatter } from \"./output-json-formatter.js\";\nimport { isReadLikeTool, SUPPRESSED_READ_OUTPUT } from \"./read-output-suppression.js\";\nimport type {\n AcpJsonRpcMessage,\n ClientOperation,\n OutputErrorAcpPayload,\n OutputErrorCode,\n OutputFormatterContext,\n OutputFormat,\n OutputFormatter,\n OutputErrorOrigin,\n} from \"./types.js\";\n\ntype WritableLike = {\n write(chunk: string): void;\n isTTY?: boolean;\n};\n\ntype OutputFormatterOptions = {\n stdout?: WritableLike;\n jsonContext?: OutputFormatterContext;\n suppressReads?: boolean;\n};\n\ntype NormalizedToolStatus = ToolCallStatus | \"unknown\";\n\ntype FormatterSection = \"assistant\" | \"thought\" | \"tool\" | \"plan\" | \"client\" | \"done\";\n\ntype ToolRenderState = {\n id: string;\n title?: string;\n status?: ToolCallStatus | null;\n kind?: string | null;\n locations?: Array<ToolCallLocation> | null;\n rawInput?: unknown;\n rawOutput?: unknown;\n content?: Array<ToolCallContent> | null;\n startedPrinted: boolean;\n finalSignature?: string;\n};\n\nconst MAX_THOUGHT_CHARS = 900;\nconst MAX_INLINE_CHARS = 220;\nconst MAX_OUTPUT_CHARS = 2_000;\nconst MAX_OUTPUT_LINES = 28;\nconst MAX_LOCATION_ITEMS = 5;\nconst OUTPUT_PRIORITY_KEYS = [\n \"stdout\",\n \"stderr\",\n \"output\",\n \"content\",\n \"text\",\n \"message\",\n \"result\",\n \"response\",\n \"value\",\n] as const;\n\nfunction asStatus(status: ToolCallStatus | null | undefined): NormalizedToolStatus {\n return status ?? \"unknown\";\n}\n\nfunction isFinalStatus(status: NormalizedToolStatus): status is \"completed\" | \"failed\" {\n return status === \"completed\" || status === \"failed\";\n}\n\nfunction toStatusLabel(status: NormalizedToolStatus): string {\n switch (status) {\n case \"in_progress\":\n return \"running\";\n case \"pending\":\n return \"pending\";\n case \"completed\":\n return \"completed\";\n case \"failed\":\n return \"failed\";\n default:\n return \"running\";\n }\n}\n\nfunction asRecord(value: unknown): Record<string, unknown> | undefined {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n return undefined;\n }\n return value as Record<string, unknown>;\n}\n\nfunction extractSessionUpdate(message: AnyMessage): SessionNotification | undefined {\n if (!Object.hasOwn(message, \"method\")) {\n return undefined;\n }\n const method = (message as { method?: unknown }).method;\n if (method !== \"session/update\") {\n return undefined;\n }\n const params = asRecord((message as { params?: unknown }).params);\n if (!params) {\n return undefined;\n }\n const sessionId = typeof params.sessionId === \"string\" ? params.sessionId : null;\n if (!sessionId) {\n return undefined;\n }\n const update = asRecord(params.update);\n if (!update || typeof update.sessionUpdate !== \"string\") {\n return undefined;\n }\n return {\n sessionId,\n update: update as SessionNotification[\"update\"],\n };\n}\n\nfunction extractJsonRpcMethod(message: AnyMessage): string | undefined {\n return Object.hasOwn(message, \"method\")\n ? (message as { method?: unknown }).method?.toString()\n : undefined;\n}\n\nfunction collapseWhitespace(value: string): string {\n return value.replace(/\\s+/g, \" \").trim();\n}\n\nfunction normalizeLineEndings(value: string): string {\n return value.replace(/\\r\\n?/g, \"\\n\");\n}\n\nfunction truncate(value: string, maxChars: number): string {\n if (value.length <= maxChars) {\n return value;\n }\n if (maxChars <= 3) {\n return value.slice(0, maxChars);\n }\n return `${value.slice(0, maxChars - 3)}...`;\n}\n\nfunction toInline(value: string, maxChars = MAX_INLINE_CHARS): string {\n return truncate(collapseWhitespace(value), maxChars);\n}\n\nfunction indentBlock(value: string, prefix: string): string {\n return value\n .split(\"\\n\")\n .map((line) => `${prefix}${line}`)\n .join(\"\\n\");\n}\n\nfunction dedupeStrings(values: string[]): string[] {\n const seen = new Set<string>();\n const result: string[] = [];\n\n for (const value of values) {\n if (seen.has(value)) {\n continue;\n }\n seen.add(value);\n result.push(value);\n }\n\n return result;\n}\n\nfunction safeJson(value: unknown, spacing: number): string | undefined {\n const seen = new WeakSet();\n\n try {\n return JSON.stringify(\n value,\n (_key, entry: unknown) => {\n if (typeof entry === \"bigint\") {\n return `${entry}n`;\n }\n if (typeof entry === \"function\") {\n return `[Function ${entry.name || \"anonymous\"}]`;\n }\n if (typeof entry === \"symbol\") {\n return entry.toString();\n }\n if (entry && typeof entry === \"object\") {\n if (seen.has(entry)) {\n return \"[Circular]\";\n }\n seen.add(entry);\n }\n return entry;\n },\n spacing,\n );\n } catch {\n return undefined;\n }\n}\n\nfunction readFirstString(source: Record<string, unknown>, keys: string[]): string | undefined {\n for (const key of keys) {\n const value = source[key];\n if (typeof value === \"string\" && value.trim()) {\n return value.trim();\n }\n }\n return undefined;\n}\n\nfunction readFirstStringArray(\n source: Record<string, unknown>,\n keys: string[],\n): string[] | undefined {\n for (const key of keys) {\n const value = source[key];\n if (!Array.isArray(value)) {\n continue;\n }\n const entries = value\n .map((entry) => (typeof entry === \"string\" ? entry.trim() : \"\"))\n .filter((entry) => entry.length > 0);\n if (entries.length > 0) {\n return entries;\n }\n }\n return undefined;\n}\n\nfunction summarizeToolInput(rawInput: unknown): string | undefined {\n if (rawInput == null) {\n return undefined;\n }\n\n if (\n typeof rawInput === \"string\" ||\n typeof rawInput === \"number\" ||\n typeof rawInput === \"boolean\"\n ) {\n return toInline(String(rawInput));\n }\n\n const record = asRecord(rawInput);\n if (record) {\n const command = readFirstString(record, [\"command\", \"cmd\", \"program\"]);\n const args = readFirstStringArray(record, [\"args\", \"arguments\"]);\n if (command) {\n const invocation = [command, ...(args ?? [])].join(\" \");\n return toInline(invocation);\n }\n\n const location = readFirstString(record, [\n \"path\",\n \"file\",\n \"filePath\",\n \"filepath\",\n \"target\",\n \"uri\",\n \"url\",\n ]);\n if (location) {\n return toInline(location);\n }\n\n const query = readFirstString(record, [\"query\", \"pattern\", \"text\", \"search\"]);\n if (query) {\n return toInline(query);\n }\n }\n\n const json = safeJson(rawInput, 0);\n return json ? toInline(json) : undefined;\n}\n\nfunction formatLocations(\n locations: Array<ToolCallLocation> | null | undefined,\n): string | undefined {\n if (!locations || locations.length === 0) {\n return undefined;\n }\n\n const unique = new Set<string>();\n for (const location of locations) {\n const path = location.path?.trim();\n if (!path) {\n continue;\n }\n\n const line =\n typeof location.line === \"number\" && Number.isFinite(location.line)\n ? `:${Math.max(1, Math.trunc(location.line))}`\n : \"\";\n unique.add(`${path}${line}`);\n }\n\n const items = [...unique];\n if (items.length === 0) {\n return undefined;\n }\n\n const visible = items.slice(0, MAX_LOCATION_ITEMS);\n const hidden = items.length - visible.length;\n if (hidden <= 0) {\n return visible.join(\", \");\n }\n\n return `${visible.join(\", \")}, +${hidden} more`;\n}\n\nfunction summarizeDiff(path: string, oldText: string | null | undefined, newText: string): string {\n const oldLines = oldText ? oldText.split(\"\\n\").length : 0;\n const newLines = newText.split(\"\\n\").length;\n const delta = newLines - oldLines;\n\n if (delta === 0) {\n return `diff ${path} (line count unchanged)`;\n }\n\n const signedDelta = `${delta > 0 ? \"+\" : \"\"}${delta}`;\n return `diff ${path} (${signedDelta} lines)`;\n}\n\nfunction textFromContentBlock(content: ContentBlock): string | undefined {\n switch (content.type) {\n case \"text\":\n return content.text;\n case \"resource_link\":\n return content.title ?? content.name ?? content.uri;\n case \"resource\": {\n if (\"text\" in content.resource && typeof content.resource.text === \"string\") {\n return content.resource.text;\n }\n const uri = content.resource.uri;\n const mimeType = content.resource.mimeType;\n return `[resource] ${uri}${mimeType ? ` (${mimeType})` : \"\"}`;\n }\n case \"image\":\n return `[image] ${content.mimeType}`;\n case \"audio\":\n return `[audio] ${content.mimeType}`;\n default:\n return undefined;\n }\n}\n\nfunction summarizeToolContent(\n content: Array<ToolCallContent> | null | undefined,\n): string | undefined {\n if (!content || content.length === 0) {\n return undefined;\n }\n\n const fragments: string[] = [];\n\n for (const entry of content) {\n if (entry.type === \"content\") {\n const text = textFromContentBlock(entry.content);\n if (text && text.trim()) {\n fragments.push(text.trimEnd());\n }\n continue;\n }\n\n if (entry.type === \"diff\") {\n fragments.push(summarizeDiff(entry.path, entry.oldText, entry.newText));\n continue;\n }\n\n if (entry.type === \"terminal\") {\n fragments.push(`[terminal] ${entry.terminalId}`);\n }\n }\n\n const unique = dedupeStrings(\n fragments.map((fragment) => fragment.trim()).filter((fragment) => fragment.length > 0),\n );\n if (unique.length === 0) {\n return undefined;\n }\n\n return unique.join(\"\\n\\n\");\n}\n\nfunction extractOutputText(\n value: unknown,\n depth = 0,\n seen = new Set<unknown>(),\n): string | undefined {\n if (value == null) {\n return undefined;\n }\n\n if (typeof value === \"string\") {\n const trimmed = value.trimEnd();\n return trimmed.length > 0 ? trimmed : undefined;\n }\n\n if (typeof value === \"number\" || typeof value === \"boolean\") {\n return String(value);\n }\n\n if (depth >= 4) {\n return undefined;\n }\n\n if (Array.isArray(value)) {\n const parts = value\n .map((entry) => extractOutputText(entry, depth + 1, seen))\n .filter((entry): entry is string => Boolean(entry));\n if (parts.length === 0) {\n return undefined;\n }\n return dedupeStrings(parts).join(\"\\n\");\n }\n\n const record = asRecord(value);\n if (!record) {\n return undefined;\n }\n if (seen.has(record)) {\n return undefined;\n }\n seen.add(record);\n\n const preferred: string[] = [];\n for (const key of OUTPUT_PRIORITY_KEYS) {\n if (!(key in record)) {\n continue;\n }\n const extracted = extractOutputText(record[key], depth + 1, seen);\n if (extracted) {\n preferred.push(extracted);\n }\n }\n\n const uniquePreferred = dedupeStrings(preferred);\n if (uniquePreferred.length > 0) {\n return uniquePreferred.join(\"\\n\");\n }\n\n const json = safeJson(record, 2);\n if (!json || json === \"{}\") {\n return undefined;\n }\n return json;\n}\n\nfunction summarizeToolOutput(\n rawOutput: unknown,\n content: Array<ToolCallContent> | null | undefined,\n): string | undefined {\n const outputFromRaw = extractOutputText(rawOutput);\n const outputFromContent = summarizeToolContent(content);\n\n const fragments = dedupeStrings(\n [outputFromRaw, outputFromContent]\n .map((fragment) => fragment?.trim())\n .filter((fragment): fragment is string => Boolean(fragment)),\n );\n\n if (fragments.length === 0) {\n return undefined;\n }\n\n return fragments.join(\"\\n\\n\");\n}\n\nfunction renderToolOutput(state: ToolRenderState, suppressReads: boolean): string | undefined {\n if (suppressReads && isReadLikeTool(state)) {\n return SUPPRESSED_READ_OUTPUT;\n }\n\n return summarizeToolOutput(state.rawOutput, state.content);\n}\n\nfunction limitOutputBlock(value: string): string {\n const normalized = value.replace(/\\r\\n/g, \"\\n\").trim();\n if (!normalized) {\n return \"\";\n }\n\n const lines = normalized.split(\"\\n\");\n const visible = lines.slice(0, MAX_OUTPUT_LINES);\n let result = visible.join(\"\\n\");\n\n if (lines.length > visible.length) {\n const hidden = lines.length - visible.length;\n result += `\\n... (${hidden} more lines)`;\n }\n\n if (result.length > MAX_OUTPUT_CHARS) {\n result = `${result.slice(0, MAX_OUTPUT_CHARS - 3)}...`;\n }\n\n return result;\n}\n\nclass TextOutputFormatter implements OutputFormatter {\n private readonly stdout: WritableLike;\n private readonly useColor: boolean;\n private readonly suppressReads: boolean;\n private readonly toolStates = new Map<string, ToolRenderState>();\n private thoughtBuffer = \"\";\n private wroteAny = false;\n private atLineStart = true;\n private section: FormatterSection | null = null;\n\n constructor(stdout: WritableLike, suppressReads: boolean) {\n this.stdout = stdout;\n this.useColor = Boolean(stdout.isTTY);\n this.suppressReads = suppressReads;\n }\n\n setContext(_context: OutputFormatterContext): void {\n // no-op for text mode\n }\n\n onAcpMessage(message: AcpJsonRpcMessage): void {\n const notification = extractSessionUpdate(message);\n if (notification) {\n this.renderSessionUpdate(notification);\n return;\n }\n\n const method = extractJsonRpcMethod(message);\n if (method && method !== \"session/prompt\" && method !== \"session/cancel\") {\n this.onClientOperation({\n method: method as ClientOperation[\"method\"],\n status: \"running\",\n summary: method,\n timestamp: new Date().toISOString(),\n });\n return;\n }\n\n const stopReason = parsePromptStopReason(message);\n if (stopReason) {\n this.renderDone(stopReason);\n return;\n }\n\n const errorMessage = parseJsonRpcErrorMessage(message);\n if (errorMessage) {\n this.onError({\n code: \"RUNTIME\",\n origin: \"acp\",\n message: errorMessage,\n });\n }\n }\n\n private renderSessionUpdate(notification: SessionNotification): void {\n const update = notification.update;\n if (update.sessionUpdate !== \"agent_thought_chunk\") {\n this.flushThoughtBuffer();\n }\n\n switch (update.sessionUpdate) {\n case \"agent_message_chunk\": {\n if (update.content.type === \"text\") {\n this.writeAssistantChunk(update.content.text);\n }\n return;\n }\n case \"agent_thought_chunk\": {\n if (update.content.type === \"text\") {\n this.thoughtBuffer += update.content.text;\n }\n return;\n }\n case \"tool_call\": {\n this.renderToolUpdate(update);\n return;\n }\n case \"tool_call_update\": {\n this.renderToolUpdate(update);\n return;\n }\n case \"plan\": {\n this.beginSection(\"plan\");\n this.writeLine(this.bold(\"[plan]\"));\n for (const entry of update.entries) {\n this.writeLine(` - [${entry.status}] ${entry.content}`);\n }\n return;\n }\n default:\n return;\n }\n }\n\n private renderDone(stopReason: string): void {\n this.flushThoughtBuffer();\n this.beginSection(\"done\");\n this.writeLine(this.dim(`[done] ${stopReason}`));\n }\n\n onError(params: {\n code: OutputErrorCode;\n detailCode?: string;\n origin?: OutputErrorOrigin;\n message: string;\n retryable?: boolean;\n acp?: OutputErrorAcpPayload;\n timestamp?: string;\n }): void {\n this.flushThoughtBuffer();\n this.beginSection(\"done\");\n this.writeLine(this.formatAnsi(`[error] ${params.code}: ${params.message}`, \"31\"));\n }\n\n onClientOperation(operation: ClientOperation): void {\n this.flushThoughtBuffer();\n this.beginSection(\"client\");\n\n const normalizedStatus: NormalizedToolStatus =\n operation.status === \"completed\"\n ? \"completed\"\n : operation.status === \"failed\"\n ? \"failed\"\n : \"in_progress\";\n const statusText = this.colorStatus(operation.status, normalizedStatus);\n this.writeLine(`${this.bold(\"[client]\")} ${operation.summary} (${statusText})`);\n if (operation.details && operation.details.trim().length > 0) {\n this.writeLine(\" details:\");\n this.writeLine(indentBlock(operation.details, \" \"));\n }\n }\n\n flush(): void {\n this.flushThoughtBuffer();\n if (!this.atLineStart) {\n this.write(\"\\n\");\n }\n }\n\n private write(chunk: string): void {\n if (!chunk) {\n return;\n }\n this.stdout.write(chunk);\n this.wroteAny = true;\n this.atLineStart = chunk.endsWith(\"\\n\");\n }\n\n private writeLine(line: string): void {\n this.write(`${line}\\n`);\n }\n\n private beginSection(next: Exclude<FormatterSection, \"assistant\">): void {\n if (!this.atLineStart) {\n this.write(\"\\n\");\n }\n if (this.wroteAny) {\n this.write(\"\\n\");\n }\n this.section = next;\n }\n\n private writeAssistantChunk(text: string): void {\n if (!text) {\n return;\n }\n this.section = \"assistant\";\n this.write(text);\n }\n\n private flushThoughtBuffer(): void {\n const thought = truncate(normalizeLineEndings(this.thoughtBuffer).trim(), MAX_THOUGHT_CHARS);\n this.thoughtBuffer = \"\";\n if (!thought) {\n return;\n }\n\n this.beginSection(\"thought\");\n const [firstLine, ...restLines] = thought.split(\"\\n\");\n this.writeLine(this.dim(`[thinking] ${firstLine}`));\n for (const line of restLines) {\n this.writeLine(this.dim(` ${line}`));\n }\n }\n\n private renderToolUpdate(update: ToolCall | ToolCallUpdate): void {\n const state = this.getOrCreateToolState(update.toolCallId);\n this.mergeToolState(state, update);\n\n const status = asStatus(state.status);\n if (isFinalStatus(status)) {\n const signature = this.toolSignature(state);\n if (signature !== state.finalSignature) {\n state.finalSignature = signature;\n this.renderFinalToolState(state, status);\n }\n return;\n }\n\n if (state.startedPrinted) {\n return;\n }\n\n state.startedPrinted = true;\n this.renderStartingToolState(state, status);\n }\n\n private getOrCreateToolState(toolCallId: string): ToolRenderState {\n const existing = this.toolStates.get(toolCallId);\n if (existing) {\n return existing;\n }\n\n const created: ToolRenderState = {\n id: toolCallId,\n startedPrinted: false,\n };\n this.toolStates.set(toolCallId, created);\n return created;\n }\n\n private mergeToolState(state: ToolRenderState, update: ToolCall | ToolCallUpdate): void {\n if (typeof update.title === \"string\" && update.title.trim().length > 0) {\n state.title = update.title;\n }\n\n if (update.status !== undefined) {\n state.status = update.status;\n }\n if (update.kind !== undefined) {\n state.kind = update.kind;\n }\n if (update.locations !== undefined) {\n state.locations = update.locations;\n }\n if (update.rawInput !== undefined) {\n state.rawInput = update.rawInput;\n }\n if (update.rawOutput !== undefined) {\n state.rawOutput = update.rawOutput;\n }\n if (update.content !== undefined) {\n state.content = update.content;\n }\n }\n\n private toolSignature(state: ToolRenderState): string {\n const signaturePayload = {\n title: state.title,\n status: state.status,\n kind: state.kind,\n input: summarizeToolInput(state.rawInput),\n files: formatLocations(state.locations),\n output: renderToolOutput(state, this.suppressReads),\n };\n\n return safeJson(signaturePayload, 0) ?? JSON.stringify(signaturePayload);\n }\n\n private renderStartingToolState(\n state: ToolRenderState,\n status: Exclude<NormalizedToolStatus, \"completed\" | \"failed\">,\n ): void {\n this.beginSection(\"tool\");\n\n const title = state.title ?? state.id;\n const label = status === \"pending\" ? \"pending\" : \"running\";\n const statusText = this.colorStatus(label, status);\n this.writeLine(`${this.bold(\"[tool]\")} ${title} (${statusText})`);\n\n const input = summarizeToolInput(state.rawInput);\n if (input) {\n this.writeLine(` input: ${input}`);\n }\n\n const files = formatLocations(state.locations);\n if (files) {\n this.writeLine(` files: ${files}`);\n }\n }\n\n private renderFinalToolState(state: ToolRenderState, status: \"completed\" | \"failed\"): void {\n this.beginSection(\"tool\");\n\n const title = state.title ?? state.id;\n const statusText = this.colorStatus(toStatusLabel(status), status);\n this.writeLine(`${this.bold(\"[tool]\")} ${title} (${statusText})`);\n\n if (state.kind) {\n this.writeLine(` kind: ${state.kind}`);\n }\n\n const input = summarizeToolInput(state.rawInput);\n if (input) {\n this.writeLine(` input: ${input}`);\n }\n\n const files = formatLocations(state.locations);\n if (files) {\n this.writeLine(` files: ${files}`);\n }\n\n const output = renderToolOutput(state, this.suppressReads);\n if (output) {\n this.writeLine(\" output:\");\n this.writeLine(indentBlock(limitOutputBlock(output), \" \"));\n }\n }\n\n private formatAnsi(text: string, code: string): string {\n if (!this.useColor) {\n return text;\n }\n return `\\u001b[${code}m${text}\\u001b[0m`;\n }\n\n private bold(text: string): string {\n return this.formatAnsi(text, \"1\");\n }\n\n private dim(text: string): string {\n return this.formatAnsi(text, \"2\");\n }\n\n private colorStatus(text: string, status: NormalizedToolStatus): string {\n if (!this.useColor) {\n return text;\n }\n\n switch (status) {\n case \"completed\":\n return this.formatAnsi(text, \"32\");\n case \"failed\":\n return this.formatAnsi(text, \"31\");\n case \"pending\":\n case \"in_progress\":\n case \"unknown\":\n default:\n return this.formatAnsi(text, \"33\");\n }\n }\n}\n\nclass QuietOutputFormatter implements OutputFormatter {\n private readonly stdout: WritableLike;\n private chunks: string[] = [];\n private flushed = false;\n\n constructor(stdout: WritableLike) {\n this.stdout = stdout;\n }\n\n setContext(_context: OutputFormatterContext): void {\n // no-op for quiet mode\n }\n\n onAcpMessage(message: AcpJsonRpcMessage): void {\n const update = extractSessionUpdate(message);\n if (\n update?.update.sessionUpdate === \"agent_message_chunk\" &&\n update.update.content.type === \"text\"\n ) {\n this.chunks.push(update.update.content.text);\n return;\n }\n\n if (parsePromptStopReason(message)) {\n this.flushBufferedOutput();\n }\n }\n\n onError(_params: {\n code: OutputErrorCode;\n detailCode?: string;\n origin?: OutputErrorOrigin;\n message: string;\n retryable?: boolean;\n acp?: OutputErrorAcpPayload;\n timestamp?: string;\n }): void {\n // no-op in quiet mode\n }\n\n flush(): void {\n // no-op for streaming output\n }\n\n private flushBufferedOutput(): void {\n if (this.flushed) {\n return;\n }\n\n this.flushed = true;\n const text = this.chunks.join(\"\");\n this.stdout.write(text.endsWith(\"\\n\") ? text : `${text}\\n`);\n }\n}\n\nexport function createOutputFormatter(\n format: OutputFormat,\n options: OutputFormatterOptions = {},\n): OutputFormatter {\n const stdout = options.stdout ?? process.stdout;\n const suppressReads = options.suppressReads === true;\n\n switch (format) {\n case \"text\":\n return new TextOutputFormatter(stdout, suppressReads);\n case \"json\":\n return createJsonOutputFormatter(stdout, suppressReads, options.jsonContext);\n case \"quiet\":\n return new QuietOutputFormatter(stdout);\n default: {\n const exhaustive: never = format;\n void exhaustive;\n throw new Error(\"Unsupported output format\");\n }\n }\n}\n"],"mappings":";;;AAEA,MAAa,6BAA8D;CACzE,YAAY;CACZ,SAAS;CACT,mBAAmB;CACnB,+BAA+B;CAC/B,SAAS;CACT,OAAO;CACR;AAoBD,SAAS,iBACP,KAC0D;AAC1D,QAAO,QACL,OACA,OAAO,SAAS,IAAI,KAAK,IACzB,OAAO,IAAI,YAAY,YACvB,IAAI,QAAQ,MAAM,CAAC,SAAS,EAC7B;;AAGH,SAAS,kBAAkB,QAA0D;CACnF,MAAM,OAAgC;EACpC,UAAU,OAAO;EACjB,YAAY,OAAO;EACnB,QAAQ,OAAO;EACf,WAAW,OAAO;EAClB,WAAW,OAAO;EAClB,WAAW,OAAO;EACnB;AAED,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,CAC7C,KAAI,UAAU,KAAA,EACZ,QAAO,KAAK;AAIhB,QAAO;;AAGT,SAAS,iBAAiB,QAAqD;AAC7E,KAAI,iBAAiB,OAAO,IAAI,CAC9B,QAAO;EACL,MAAM,OAAO,IAAI;EACjB,SAAS,OAAO,IAAI;EACpB,GAAI,OAAO,IAAI,SAAS,KAAA,IAAY,EAAE,MAAM,OAAO,IAAI,MAAM,GAAG,EAAE;EACnE;CAGH,MAAM,OAAO,kBAAkB,OAAO;AACt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,QAAO,IAAI,oBAAoB,QAAQ,cAAc;EACvD,KAAK,OACH,QAAO,0BAA0B,QAAQ,eAAe,QAAQ,YAAY;EAC9E,KAAK,QACH,QAAO,IAAI,qBAAqB,OAAO;EACzC,QAGE,OAAM,IAAI,MAAM,4BAA4B"}
@@ -1,11 +1,16 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-CiIaOW0V.js";
2
- import { n as probeQueueOwnerHealth } from "./queue-ipc-EQLpBMKv.js";
3
- import { n as normalizeRuntimeSessionId } from "./runtime-session-id-C544sPPL.js";
2
+ import { N as normalizeRuntimeSessionId, s as probeQueueOwnerHealth } from "./queue-ipc-CgWf63GN.js";
4
3
  import path from "node:path";
4
+ //#region src/cli/json-output.ts
5
+ function emitJsonResult(format, payload) {
6
+ if (format !== "json") return false;
7
+ process.stdout.write(`${JSON.stringify(payload)}\n`);
8
+ return true;
9
+ }
10
+ //#endregion
5
11
  //#region src/cli/output-render.ts
6
12
  var output_render_exports = /* @__PURE__ */ __exportAll({
7
13
  agentSessionIdPayload: () => agentSessionIdPayload,
8
- emitJsonResult: () => emitJsonResult,
9
14
  formatPromptSessionBannerLine: () => formatPromptSessionBannerLine,
10
15
  printClosedSessionByFormat: () => printClosedSessionByFormat,
11
16
  printCreatedSessionBanner: () => printCreatedSessionBanner,
@@ -26,11 +31,6 @@ function formatRoutedFrom(sessionCwd, currentCwd) {
26
31
  async function resolveSessionConnectionStatus(record) {
27
32
  return (await probeQueueOwnerHealth(record.acpxRecordId)).healthy ? "connected" : "needs reconnect";
28
33
  }
29
- function emitJsonResult(format, payload) {
30
- if (format !== "json") return false;
31
- process.stdout.write(`${JSON.stringify(payload)}\n`);
32
- return true;
33
- }
34
34
  function printSessionsByFormat(sessions, format) {
35
35
  if (format === "json") {
36
36
  process.stdout.write(`${JSON.stringify(sessions)}\n`);
@@ -134,6 +134,6 @@ function agentSessionIdPayload(agentSessionId) {
134
134
  return { agentSessionId: normalized };
135
135
  }
136
136
  //#endregion
137
- export { output_render_exports as n, formatPromptSessionBannerLine as t };
137
+ export { emitJsonResult as i, formatPromptSessionBannerLine as n, output_render_exports as r, agentSessionIdPayload as t };
138
138
 
139
- //# sourceMappingURL=output-render-DEAaMxg8.js.map
139
+ //# sourceMappingURL=output-render-C7w9NZ2H.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output-render-C7w9NZ2H.js","names":[],"sources":["../src/cli/json-output.ts","../src/cli/output-render.ts"],"sourcesContent":["import type { OutputFormat } from \"../types.js\";\n\nexport function emitJsonResult(format: OutputFormat, payload: unknown): boolean {\n if (format !== \"json\") {\n return false;\n }\n process.stdout.write(`${JSON.stringify(payload)}\\n`);\n return true;\n}\n","import path from \"node:path\";\nimport { probeQueueOwnerHealth } from \"../queue-ipc.js\";\nimport { normalizeRuntimeSessionId } from \"../runtime-session-id.js\";\nimport type { OutputFormat, SessionRecord } from \"../types.js\";\nimport { emitJsonResult } from \"./json-output.js\";\n\nfunction formatSessionLabel(record: SessionRecord): string {\n return record.name ?? \"cwd\";\n}\n\nfunction formatRoutedFrom(sessionCwd: string, currentCwd: string): string | undefined {\n const relative = path.relative(sessionCwd, currentCwd);\n if (!relative || relative === \".\") {\n return undefined;\n }\n return relative.startsWith(\".\") ? relative : `.${path.sep}${relative}`;\n}\n\ntype SessionConnectionStatus = \"connected\" | \"needs reconnect\";\n\nasync function resolveSessionConnectionStatus(\n record: SessionRecord,\n): Promise<SessionConnectionStatus> {\n const health = await probeQueueOwnerHealth(record.acpxRecordId);\n return health.healthy ? \"connected\" : \"needs reconnect\";\n}\n\nexport function printSessionsByFormat(sessions: SessionRecord[], format: OutputFormat): void {\n if (format === \"json\") {\n process.stdout.write(`${JSON.stringify(sessions)}\\n`);\n return;\n }\n\n if (format === \"quiet\") {\n for (const session of sessions) {\n const closedMarker = session.closed ? \" [closed]\" : \"\";\n process.stdout.write(`${session.acpxRecordId}${closedMarker}\\n`);\n }\n return;\n }\n\n if (sessions.length === 0) {\n process.stdout.write(\"No sessions\\n\");\n return;\n }\n\n for (const session of sessions) {\n const closedMarker = session.closed ? \" [closed]\" : \"\";\n process.stdout.write(\n `${session.acpxRecordId}${closedMarker}\\t${session.name ?? \"-\"}\\t${session.cwd}\\t${session.lastUsedAt}\\n`,\n );\n }\n}\n\nexport function printClosedSessionByFormat(record: SessionRecord, format: OutputFormat): void {\n if (\n emitJsonResult(format, {\n action: \"session_closed\",\n acpxRecordId: record.acpxRecordId,\n acpxSessionId: record.acpSessionId,\n agentSessionId: record.agentSessionId,\n })\n ) {\n return;\n }\n\n if (format === \"quiet\") {\n return;\n }\n\n process.stdout.write(`${record.acpxRecordId}\\n`);\n}\n\nexport function printNewSessionByFormat(\n record: SessionRecord,\n replaced: SessionRecord | undefined,\n format: OutputFormat,\n): void {\n if (\n emitJsonResult(format, {\n action: \"session_ensured\",\n created: true,\n acpxRecordId: record.acpxRecordId,\n acpxSessionId: record.acpSessionId,\n agentSessionId: record.agentSessionId,\n name: record.name,\n replacedSessionId: replaced?.acpxRecordId,\n })\n ) {\n return;\n }\n\n if (format === \"quiet\") {\n process.stdout.write(`${record.acpxRecordId}\\n`);\n return;\n }\n\n if (replaced) {\n process.stdout.write(`${record.acpxRecordId}\\t(replaced ${replaced.acpxRecordId})\\n`);\n return;\n }\n\n process.stdout.write(`${record.acpxRecordId}\\n`);\n}\n\nexport function printEnsuredSessionByFormat(\n record: SessionRecord,\n created: boolean,\n format: OutputFormat,\n): void {\n if (\n emitJsonResult(format, {\n action: \"session_ensured\",\n created,\n acpxRecordId: record.acpxRecordId,\n acpxSessionId: record.acpSessionId,\n agentSessionId: record.agentSessionId,\n name: record.name,\n })\n ) {\n return;\n }\n\n if (format === \"quiet\") {\n process.stdout.write(`${record.acpxRecordId}\\n`);\n return;\n }\n\n const action = created ? \"created\" : \"existing\";\n process.stdout.write(`${record.acpxRecordId}\\t(${action})\\n`);\n}\n\nexport function printQueuedPromptByFormat(\n result: {\n sessionId: string;\n requestId: string;\n },\n format: OutputFormat,\n): void {\n if (\n emitJsonResult(format, {\n action: \"prompt_queued\",\n acpxRecordId: result.sessionId,\n requestId: result.requestId,\n })\n ) {\n return;\n }\n\n if (format === \"quiet\") {\n return;\n }\n\n process.stdout.write(`[queued] ${result.requestId}\\n`);\n}\n\nexport function formatPromptSessionBannerLine(\n record: SessionRecord,\n currentCwd: string,\n connectionStatus: SessionConnectionStatus = \"needs reconnect\",\n): string {\n const label = formatSessionLabel(record);\n const normalizedSessionCwd = path.resolve(record.cwd);\n const normalizedCurrentCwd = path.resolve(currentCwd);\n const routedFrom =\n normalizedSessionCwd === normalizedCurrentCwd\n ? undefined\n : formatRoutedFrom(normalizedSessionCwd, normalizedCurrentCwd);\n const status = connectionStatus;\n\n if (routedFrom) {\n return `[acpx] session ${label} (${record.acpxRecordId}) · ${normalizedSessionCwd} (routed from ${routedFrom}) · agent ${status}`;\n }\n\n return `[acpx] session ${label} (${record.acpxRecordId}) · ${normalizedSessionCwd} · agent ${status}`;\n}\n\nexport async function printPromptSessionBanner(\n record: SessionRecord,\n currentCwd: string,\n format: OutputFormat,\n jsonStrict = false,\n): Promise<void> {\n if (format === \"quiet\" || (jsonStrict && format === \"json\")) {\n return;\n }\n\n const status = await resolveSessionConnectionStatus(record);\n process.stderr.write(`${formatPromptSessionBannerLine(record, currentCwd, status)}\\n`);\n}\n\nexport function printCreatedSessionBanner(\n record: SessionRecord,\n agentName: string,\n format: OutputFormat,\n jsonStrict = false,\n): void {\n if (format === \"quiet\" || (jsonStrict && format === \"json\")) {\n return;\n }\n\n const label = formatSessionLabel(record);\n process.stderr.write(`[acpx] created session ${label} (${record.acpxRecordId})\\n`);\n process.stderr.write(`[acpx] agent: ${agentName}\\n`);\n process.stderr.write(`[acpx] cwd: ${record.cwd}\\n`);\n}\n\nexport function agentSessionIdPayload(agentSessionId: string | undefined): {\n agentSessionId?: string;\n} {\n const normalized = normalizeRuntimeSessionId(agentSessionId);\n if (!normalized) {\n return {};\n }\n\n return { agentSessionId: normalized };\n}\n"],"mappings":";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