acpx 0.4.0 → 0.4.1
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.
- package/dist/{acp-jsonrpc-C7pPk9Tw.js → acp-jsonrpc-BbBgC5gO.js} +15 -2
- package/dist/acp-jsonrpc-BbBgC5gO.js.map +1 -0
- package/dist/{cli-5s-E-Y99.js → cli-idpWyCOs.js} +4 -4
- package/dist/{cli-5s-E-Y99.js.map → cli-idpWyCOs.js.map} +1 -1
- package/dist/cli.js +8 -8
- package/dist/{flags-BkWInxAq.js → flags-CCcX9fZj.js} +5 -5
- package/dist/{flags-BkWInxAq.js.map → flags-CCcX9fZj.js.map} +1 -1
- package/dist/{flows-DnIYoHI1.js → flows-BL1tSvZT.js} +4 -4
- package/dist/{flows-DnIYoHI1.js.map → flows-BL1tSvZT.js.map} +1 -1
- package/dist/flows.js +1 -1
- package/dist/{output-C58ukIo3.js → output-Du3m6oPQ.js} +4 -18
- package/dist/output-Du3m6oPQ.js.map +1 -0
- package/dist/{output-render-C7w9NZ2H.js → output-render-Bz58qaQn.js} +2 -2
- package/dist/{output-render-C7w9NZ2H.js.map → output-render-Bz58qaQn.js.map} +1 -1
- package/dist/{queue-ipc-CgWf63GN.js → queue-ipc-CE8_QGX3.js} +2 -2
- package/dist/{queue-ipc-CgWf63GN.js.map → queue-ipc-CE8_QGX3.js.map} +1 -1
- package/dist/{session-BtpTC2pM.js → session-RO_LZUnv.js} +3 -3
- package/dist/{session-BtpTC2pM.js.map → session-RO_LZUnv.js.map} +1 -1
- package/package.json +16 -7
- package/dist/acp-jsonrpc-C7pPk9Tw.js.map +0 -1
- package/dist/output-C58ukIo3.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-Du3m6oPQ.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 {\n extractSessionUpdateNotification,\n parseJsonRpcErrorMessage,\n parsePromptStopReason,\n} 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 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 = extractSessionUpdateNotification(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 = extractSessionUpdateNotification(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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Ac;CAId,sBAAoC;AAClC,MAAI,KAAK,QACP;AAGF,OAAK,UAAU;EACf,MAAM,OAAO,KAAK,OAAO,KAAK,GAAG;AACjC,OAAK,OAAO,MAAM,KAAK,SAAS,KAAK,GAAG,OAAO,GAAG,KAAK,IAAI;;;AAI/D,SAAgB,sBACd,QACA,UAAkC,EAAE,EACnB;CACjB,MAAM,SAAS,QAAQ,UAAU,QAAQ;CACzC,MAAM,gBAAgB,QAAQ,kBAAkB;AAEhD,SAAQ,QAAR;EACE,KAAK,OACH,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,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-CiIaOW0V.js";
|
|
2
|
-
import { N as normalizeRuntimeSessionId, s as probeQueueOwnerHealth } from "./queue-ipc-
|
|
2
|
+
import { N as normalizeRuntimeSessionId, s as probeQueueOwnerHealth } from "./queue-ipc-CE8_QGX3.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
//#region src/cli/json-output.ts
|
|
5
5
|
function emitJsonResult(format, payload) {
|
|
@@ -136,4 +136,4 @@ function agentSessionIdPayload(agentSessionId) {
|
|
|
136
136
|
//#endregion
|
|
137
137
|
export { emitJsonResult as i, formatPromptSessionBannerLine as n, output_render_exports as r, agentSessionIdPayload as t };
|
|
138
138
|
|
|
139
|
-
//# sourceMappingURL=output-render-
|
|
139
|
+
//# sourceMappingURL=output-render-Bz58qaQn.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output-render-
|
|
1
|
+
{"version":3,"file":"output-render-Bz58qaQn.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":";;;;AAEA,SAAgB,eAAe,QAAsB,SAA2B;AAC9E,KAAI,WAAW,OACb,QAAO;AAET,SAAQ,OAAO,MAAM,GAAG,KAAK,UAAU,QAAQ,CAAC,IAAI;AACpD,QAAO;;;;;;;;;;;;;;;ACDT,SAAS,mBAAmB,QAA+B;AACzD,QAAO,OAAO,QAAQ;;AAGxB,SAAS,iBAAiB,YAAoB,YAAwC;CACpF,MAAM,WAAW,KAAK,SAAS,YAAY,WAAW;AACtD,KAAI,CAAC,YAAY,aAAa,IAC5B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CAAC,IAAI;;AAGxF,SAAgB,0BACd,QACA,WACA,QACA,aAAa,OACP;AACN,KAAI,WAAW,WAAY,cAAc,WAAW,OAClD;CAGF,MAAM,QAAQ,mBAAmB,OAAO;AACxC,SAAQ,OAAO,MAAM,0BAA0B,MAAM,IAAI,OAAO,aAAa,KAAK;AAClF,SAAQ,OAAO,MAAM,iBAAiB,UAAU,IAAI;AACpD,SAAQ,OAAO,MAAM,eAAe,OAAO,IAAI,IAAI;;AAGrD,SAAgB,sBAAsB,gBAEpC;CACA,MAAM,aAAa,0BAA0B,eAAe;AAC5D,KAAI,CAAC,WACH,QAAO,EAAE;AAGX,QAAO,EAAE,gBAAgB,YAAY"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as isAcpJsonRpcMessage } from "./acp-jsonrpc-BbBgC5gO.js";
|
|
2
2
|
import fs from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import os from "node:os";
|
|
@@ -1766,4 +1766,4 @@ async function trySetConfigOptionOnRunningOwner(sessionId, configId, value, time
|
|
|
1766
1766
|
//#endregion
|
|
1767
1767
|
export { extractAcpError as $, OUTPUT_FORMATS as A, AgentSpawnError as B, formatErrorMessage as C, AUTH_POLICIES as D, normalizeOutputError as E, mergePromptSourceWithText as F, PermissionDeniedError as G, ClaudeAcpSessionCreateTimeoutError as H, parsePromptSource as I, SessionModeReplayError as J, PermissionPromptUnavailableError as K, promptToDisplayText as L, extractRuntimeSessionId as M, normalizeRuntimeSessionId as N, EXIT_CODES as O, PromptInputValidationError as P, SessionResumeRequiredError as Q, textPrompt as R, exitCodeForOutputErrorCode as S, isRetryablePromptError as T, CopilotAcpUnsupportedError as U, AuthPolicyError as V, GeminiAcpStartupTimeoutError as W, SessionNotFoundError as X, SessionModelReplayError as Y, SessionResolutionError as Z, incrementPerfCounter as _, trySubmitToRunningOwner as a, setPerfGauge as b, isProcessAlive as c, terminateProcess as d, isAcpResourceNotFoundError as et, terminateQueueOwnerForSession as f, getPerfMetricsSnapshot as g, formatPerfMetric as h, trySetModelOnRunningOwner as i, SESSION_RECORD_SCHEMA as j, NON_INTERACTIVE_PERMISSION_POLICIES as k, refreshQueueOwnerLease as l, waitMs as m, trySetConfigOptionOnRunningOwner as n, SessionQueueOwner as o, tryAcquireQueueOwnerLease as p, QueueConnectionError as q, trySetModeOnRunningOwner as r, probeQueueOwnerHealth as s, tryCancelOnRunningOwner as t, releaseQueueOwnerLease as u, measurePerf as v, isAcpQueryClosedBeforeResponseError as w, startPerfTimer as x, resetPerfMetrics as y, AgentDisconnectedError as z };
|
|
1768
1768
|
|
|
1769
|
-
//# sourceMappingURL=queue-ipc-
|
|
1769
|
+
//# sourceMappingURL=queue-ipc-CE8_QGX3.js.map
|