acp-kernel 0.0.32 → 0.0.33

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.
@@ -398,6 +398,22 @@ function partText(part) {
398
398
  function messageContent(content) {
399
399
  return typeof content === "string" ? content : content.map(partText).join("\n");
400
400
  }
401
+ function reasoningText(item) {
402
+ const fromParts = (parts, type) => {
403
+ if (!Array.isArray(parts)) return "";
404
+ const texts = [];
405
+ for (const part of parts) {
406
+ if (part && typeof part === "object" && "type" in part && "text" in part) {
407
+ const rec = part;
408
+ if (rec.type === type && typeof rec.text === "string") texts.push(rec.text);
409
+ }
410
+ }
411
+ return texts.join("\n");
412
+ };
413
+ const content = "content" in item ? item.content : void 0;
414
+ const summary = "summary" in item ? item.summary : void 0;
415
+ return fromParts(content, "reasoning_text") || fromParts(summary, "summary_text");
416
+ }
401
417
  function responsesToCore(body) {
402
418
  const msgs = [];
403
419
  const systemParts = [];
@@ -422,7 +438,8 @@ function responsesToCore(body) {
422
438
  droppedReasoning++;
423
439
  continue;
424
440
  }
425
- const rid = typeof item.id === "string" ? String(item.id) : hashId(JSON.stringify(item));
441
+ const text = reasoningText(item);
442
+ const rid = text.length > 0 ? text : "id" in item && typeof item.id === "string" ? item.id : hashId(JSON.stringify(item));
426
443
  coreId = clusters.next(deriveMessageId("assistant", "reasoning", rid));
427
444
  msgs.push({
428
445
  id: coreId,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/wire/util.ts","../../src/wire/message-id.ts","../../src/wire/anthropic.ts","../../src/wire/bili-message.ts","../../src/wire/openai.ts","../../src/wire/responses.ts","../../src/wire/formats.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\n\n/** SHA-256-derived short id — kept verbatim from the proxy so message ids\n * stay byte-identical across the extraction (re-keying would orphan every\n * downstream map keyed on these ids). */\nexport function hashId(s: string): string {\n return createHash(\"sha256\").update(s, \"utf8\").digest(\"hex\").slice(0, 16);\n}\n\n/** How a conversation's identity was derived (kept verbatim from the proxy's\n * session-id.ts — only the TYPE moves; session-key derivation stays in the\n * proxy, which owns multi-tenant state). */\nexport type ConversationIdentity = {\n value: string;\n source: \"header\" | \"body-session\" | \"metadata-session\" | \"previous-response\" | \"content-fingerprint\" | \"generated\";\n clientProvided: boolean;\n};\n","import { hashId } from \"./util.js\";\n\n/**\n * Derive a stable, content-based message id.\n *\n * PROBLEM: none of the three wire protocols (Anthropic Messages, OpenAI Chat\n * Completions, OpenAI Responses) attach a stable id to request-side message\n * items. Historically each converter used `raw-${idx}` — a *position* index,\n * not an identity. As soon as a client deletes/reorders messages (other plugins\n * summarizing away old turns, multi-agent setups, etc.) the index drifts:\n * downstream ids shift, so\n * - assignRefs reuses stale `byRaw` entries, hiding new messages, and\n * - compression `effectiveMessageIds` start pointing at the *wrong* messages,\n * silently swallowing live content under an unrelated summary.\n *\n * FIX: derive the id from a SHA-256 of the message identity:\n * role + contentType + toolCallId + toolName + text\n * Two messages with identical identity collide. To keep duplicates distinct\n * (and avoid `covered` sets collapsing unrelated turns onto one id) we append a\n * within-conversation *cluster index* `_N`: the Nth occurrence of the same\n * identity, counting from 0 in arrival order.\n *\n * Trade-off vs a real client id:\n * - deleting a duplicated message only disturbs the cluster of that identity\n * (local damage), never the whole downstream (global damage like position).\n * - fully distinct messages are completely immune to reordering/deletion.\n *\n * `idx` is passed purely to break ties *within a single conversion pass*; it is\n * not part of the identity, so two passes over the same content produce the\n * same cluster numbering (deterministic).\n */\nexport function deriveMessageId(\n role: string,\n contentType: string,\n text: string,\n options: {\n toolCallId?: string;\n toolName?: string;\n } = {},\n): string {\n const seed = `${role}|${contentType}|${options.toolCallId ?? \"\"}|${options.toolName ?? \"\"}|${text}`;\n return \"h_\" + hashId(seed);\n}\n\n/**\n * Stateful cluster counter. Each converter instantiates one per conversion\n * pass; it tracks how many times each base identity has been seen so that the\n * Nth duplicate gets a `_${N}` suffix.\n */\nexport class ClusterCounter {\n private counts = new Map<string, number>();\n\n next(baseId: string): string {\n const n = this.counts.get(baseId) ?? 0;\n this.counts.set(baseId, n + 1);\n return n === 0 ? baseId : `${baseId}_${n}`;\n }\n}\n","import type { BiliMessage } from \"./bili-message.js\";\nimport { hashId } from \"./util.js\";\nimport { ClusterCounter, deriveMessageId } from \"./message-id.js\";\n\nexport type AnthropicTextBlock = { type: \"text\"; text: string; cache_control?: unknown };\nexport type AnthropicToolUse = {\n type: \"tool_use\";\n id: string;\n name: string;\n input: unknown;\n cache_control?: unknown;\n};\nexport type AnthropicToolResult = {\n type: \"tool_result\";\n tool_use_id: string;\n content: string | AnthropicTextBlock[];\n is_error?: boolean;\n cache_control?: unknown;\n};\nexport type AnthropicImage = { type: \"image\"; source: unknown };\nexport type AnthropicThinking = { type: \"thinking\"; thinking: string; signature?: string };\nexport type AnthropicBlock =\n | AnthropicTextBlock\n | AnthropicToolUse\n | AnthropicToolResult\n | AnthropicImage\n | AnthropicThinking;\n\nexport type AnthropicMessage = {\n role: \"user\" | \"assistant\";\n content: string | AnthropicBlock[];\n};\n\nexport type AnthropicRequestBody = {\n model?: string;\n max_tokens?: number;\n system?: string | AnthropicTextBlock[];\n messages: AnthropicMessage[];\n tools?: unknown[];\n stream?: boolean;\n temperature?: number;\n [key: string]: unknown;\n};\n\n\nexport function extractSystem(system: AnthropicRequestBody[\"system\"]): string {\n if (!system) return \"\";\n if (typeof system === \"string\") return system;\n return system.map((b) => b.text).join(\"\\n\\n\");\n}\n\nexport function buildSystem(text: string, original: AnthropicRequestBody[\"system\"]): string | AnthropicTextBlock[] {\n if (Array.isArray(original) && original.length > 0) {\n const ccBlock = original.find((b) => b.cache_control);\n return [{ type: \"text\", text, ...(ccBlock ? { cache_control: ccBlock.cache_control } : {}) }];\n }\n return text;\n}\n\ntype Flat = { msgs: BiliMessage[]; cacheControls: Map<string, unknown> };\n\nexport function anthropicToCore(body: AnthropicRequestBody): Flat {\n const msgs: BiliMessage[] = [];\n const cacheControls = new Map<string, unknown>();\n const clusters = new ClusterCounter();\n for (const m of body.messages) {\n const blocks = typeof m.content === \"string\" ? [{ type: \"text\" as const, text: m.content }] : m.content;\n for (const b of blocks) {\n switch (b.type) {\n case \"text\": {\n const base = deriveMessageId(m.role, \"text\", b.text);\n const id = clusters.next(base);\n msgs.push({ id, role: m.role, contentType: \"text\", text: b.text });\n if (b.cache_control) cacheControls.set(id, b.cache_control);\n break;\n }\n case \"tool_use\": {\n const base = deriveMessageId(\"assistant\", \"tool-call\", safeStringify(b.input), {\n toolCallId: b.id,\n toolName: b.name,\n });\n const id = clusters.next(base);\n msgs.push({\n id,\n role: \"assistant\",\n contentType: \"tool-call\",\n toolName: b.name,\n toolCallId: b.id,\n text: safeStringify(b.input),\n });\n if (b.cache_control) cacheControls.set(id, b.cache_control);\n break;\n }\n case \"tool_result\": {\n const text = typeof b.content === \"string\" ? b.content : b.content.map((c) => c.text).join(\"\\n\");\n const base = deriveMessageId(\"tool\", \"tool-result\", text, { toolCallId: b.tool_use_id });\n const id = clusters.next(base);\n msgs.push({\n id,\n role: \"tool\",\n contentType: \"tool-result\",\n toolCallId: b.tool_use_id,\n text,\n ...(b.is_error === true ? { toolIsError: true } : {}),\n });\n if (b.cache_control) cacheControls.set(id, b.cache_control);\n break;\n }\n case \"thinking\": {\n const base = deriveMessageId(\"assistant\", \"reasoning\", b.thinking);\n msgs.push({\n id: clusters.next(base),\n role: \"assistant\",\n contentType: \"reasoning\",\n text: b.thinking,\n ...(b.signature ? { thinkingSignature: b.signature } : {}),\n });\n break;\n }\n case \"image\": {\n const base = deriveMessageId(m.role, \"text\", \"[image]\");\n msgs.push({\n id: clusters.next(base),\n role: m.role,\n contentType: \"text\",\n text: \"[image]\",\n rawAnthropicBlock: b,\n });\n break;\n }\n }\n }\n }\n return { msgs, cacheControls };\n}\n\nexport function coreToAnthropic(messages: BiliMessage[], cacheControls?: Map<string, unknown>): AnthropicMessage[] {\n const out: AnthropicMessage[] = [];\n let current: { role: \"user\" | \"assistant\"; blocks: AnthropicBlock[] } | null = null;\n const flush = () => {\n if (current && current.blocks.length > 0) {\n out.push({ role: current.role, content: current.blocks });\n }\n current = null;\n };\n const cc = (id: string): { cache_control?: unknown } => {\n const v = cacheControls?.get(id);\n return v ? { cache_control: v } : {};\n };\n for (const m of messages) {\n const target: \"user\" | \"assistant\" =\n m.role === \"assistant\" ? \"assistant\" : \"user\";\n if (!current || current.role !== target) {\n flush();\n current = { role: target, blocks: [] };\n }\n switch (m.contentType) {\n case \"text\": {\n if (m.rawAnthropicBlock) {\n current.blocks.push(m.rawAnthropicBlock as AnthropicBlock);\n break;\n }\n current.blocks.push({ type: \"text\", text: m.text ?? \"\", ...cc(m.id) });\n break;\n }\n case \"tool-call\":\n current.blocks.push({\n type: \"tool_use\",\n id: m.toolCallId ?? `call_${m.id}`,\n name: m.toolName ?? \"unknown\",\n input: safeParse(m.text),\n ...cc(m.id),\n });\n break;\n case \"tool-result\":\n current.blocks.push({\n type: \"tool_result\",\n tool_use_id: m.toolCallId ?? \"\",\n content: m.text ?? \"\",\n ...(m.toolIsError ? { is_error: true } : {}),\n ...cc(m.id),\n });\n break;\n case \"reasoning\":\n current.blocks.push({\n type: \"thinking\",\n thinking: m.text ?? \"\",\n ...(m.thinkingSignature ? { signature: m.thinkingSignature } : {}),\n });\n break;\n }\n }\n flush();\n return out;\n}\n\n/** Extract the conversation dimension for Anthropic: a client-provided\n * session header if present, else a content fingerprint of the first user\n * message. The protocol+upstream+key dimensions are mixed in by the caller\n * (server.ts) via deriveSessionId() — this function contributes only the\n * conversation axis. */\nexport function conversationSignalAnthropic(body: AnthropicRequestBody, headerValue?: string): string {\n if (headerValue && headerValue.trim()) return headerValue.trim();\n const firstUser = body.messages.find((m) => m.role === \"user\");\n const seed = firstUser ? JSON.stringify(firstUser.content) : \"default\";\n return hashId(seed);\n}\n\nfunction safeStringify(v: unknown): string {\n try {\n return JSON.stringify(v ?? {});\n } catch {\n return \"{}\";\n }\n}\n\nfunction safeParse(s: string | undefined): unknown {\n if (!s) return {};\n try {\n return JSON.parse(s);\n } catch {\n return {};\n }\n}\n","/**\n * Lossless message bridge between protocol-specific message formats and the\n * kernel's CoreMessage.\n *\n * Problem: `anthropicToCore` / `openaiToCore` / `responsesToCore` flatten\n * rich protocol blocks (images, thinking signatures, tool_result.is_error,\n * developer-role messages, image_url) into plain `{ text }` placeholders.\n * The reverse `coreToX` then can't reconstruct them — `is_error` is lost\n * (upstream can't tell a tool error from a result), `thinking.signature` is\n * lost (Anthropic rejects thinking blocks without a matching signature),\n * images become \"[image]\" (the model never sees the picture).\n *\n * Solution: `BiliMessage` extends CoreMessage with optional sidecar fields.\n * The kernel only reads `{ ...message }` (spread copy) and known fields, so\n * the extra fields survive the compression pipeline unchanged and arrive back\n * at `coreToX`, which prefers them over the flattened `text`. No `as any`\n * needed — TypeScript array covariance lets `BiliMessage[]` satisfy a\n * `CoreMessage[]` parameter.\n */\n\nimport type { CoreMessage } from \"acp-kernel\";\n\n/** A message that carries its original protocol block(s) verbatim, so the\n * reverse conversion can reconstruct losslessly. Every field is optional —\n * plain text messages (the common case) have none set. */\nexport interface BiliMessage extends CoreMessage {\n /** Anthropic: the original content block for an image or a structured\n * tool_result. Restored verbatim by coreToAnthropic. */\n rawAnthropicBlock?: unknown;\n /** OpenAI chat: the original content part for an image_url, or the\n * original message object for a developer-role message. */\n rawOpenaiContent?: unknown;\n /** Responses API: the original input item (for input_image, or a raw\n * function_call / function_call_output we pass through). */\n rawResponsesItem?: unknown;\n /** Anthropic thinking signature. Anthropic verifies thinking+signature\n * pairs; without it the request is rejected. Stored alongside the\n * reasoning text so coreToAnthropic can reattach it. */\n thinkingSignature?: string;\n /** OpenAI reasoning_content (chain-of-thought from DeepSeek-R1, GLM-4.6\n * thinking, Qwen-QwQ). These models require reasoning_content be echoed\n * back on subsequent requests or the API returns HTTP 400; stored so\n * coreToOpenai can reattach it. */\n reasoningContent?: string;\n /** Anthropic tool_result.is_error. Marks the tool result as an error so\n * the model knows the tool failed (not just returned an error string). */\n toolIsError?: boolean;\n /** OpenAI: original role was \"developer\" (reconstructed as \"system\" by\n * openaiToCore for the kernel; coreToOpenai restores \"developer\"). */\n originalRole?: \"system\" | \"developer\";\n /** The original media type for an image (image/png, image/jpeg, image/gif,\n * image/webp). Lets coreToOpenai/coreToResponses rebuild image_url /\n * input_image with the right data URL. */\n imageMediaType?: string;\n /** The base64 data of an image (without the data: prefix). Lets the\n * reverse conversion rebuild the full image payload. */\n imageBase64?: string;\n /** OpenAI chat: ALL original image_url content parts (each a data: URL\n * part) for a user message carrying more than one image, in wire order.\n * coreToOpenai re-emits these verbatim (after the text part). The\n * singular `rawOpenaiContent` still covers the single-image case and\n * legacy persisted state. Typed as unknown[] (not OpenAIContentPart) to\n * avoid a circular import with the openai codec. */\n rawOpenaiContentParts?: unknown[];\n}\n\n/** Narrow a BiliMessage[] to CoreMessage[] for the kernel. The sidecar fields\n * are transparently carried along — the kernel's `{ ...msg }` copies them. */\nexport function toCoreMessages(msgs: BiliMessage[]): CoreMessage[] {\n return msgs as CoreMessage[];\n}\n\n/** Re-decode a base64 data URL into media type + data. Returns undefined if\n * the input is not a recognized data URL. Used by openaiToCore/responsesToCore\n * to split image_url/input_image into the sidecar fields. */\nexport function parseDataUrl(url: string): { mediaType: string; base64: string } | undefined {\n const m = /^data:([^;,]+)(?:;base64)?,(.+)$/i.exec(url);\n if (!m) return undefined;\n return { mediaType: m[1]!, base64: m[2]! };\n}\n","import { hashId } from \"./util.js\";\nimport { ClusterCounter, deriveMessageId } from \"./message-id.js\";\nimport { parseDataUrl, type BiliMessage } from \"./bili-message.js\";\n\nexport type OpenAIContentPart =\n | { type: \"text\"; text: string }\n | { type: \"image_url\"; image_url: { url: string } }\n | { type: string; [k: string]: unknown };\n\nexport type OpenAIToolCall = {\n id: string;\n type: \"function\";\n function: { name: string; arguments: string };\n};\n\nexport type OpenAIMessage = {\n role: \"system\" | \"developer\" | \"user\" | \"assistant\" | \"tool\";\n content?: string | null | OpenAIContentPart[];\n reasoning_content?: string | null;\n tool_calls?: OpenAIToolCall[];\n tool_call_id?: string;\n name?: string;\n};\n\nexport type OpenAITool = {\n type: \"function\";\n function: { name: string; description?: string; parameters?: unknown };\n};\n\nexport type OpenAIRequestBody = {\n model?: string;\n messages: OpenAIMessage[];\n tools?: OpenAITool[];\n stream?: boolean;\n [key: string]: unknown;\n};\n\ntype Flat = { msgs: BiliMessage[] };\n\nexport function openaiToCore(body: OpenAIRequestBody): Flat {\n const msgs: BiliMessage[] = [];\n const clusters = new ClusterCounter();\n for (const m of body.messages) {\n switch (m.role) {\n case \"system\":\n case \"developer\": {\n const base = deriveMessageId(m.role, \"text\", stringContent(m.content));\n msgs.push({ id: clusters.next(base), role: \"system\", contentType: \"text\", text: stringContent(m.content), originalRole: m.role });\n break;\n }\n case \"user\": {\n const text = stringContent(m.content);\n const imgs = allImageParts(m.content);\n const firstImg = imgs[0];\n const firstUrl = firstImg ? firstImg.image_url.url : undefined;\n const firstParsed = firstUrl ? parseDataUrl(firstUrl) : undefined;\n const base = deriveMessageId(\"user\", \"text\", text);\n msgs.push({\n id: clusters.next(base),\n role: \"user\",\n contentType: \"text\",\n text,\n ...(imgs.length === 1 && firstParsed\n ? { rawOpenaiContent: imgs[0], imageMediaType: firstParsed.mediaType, imageBase64: firstParsed.base64 }\n : imgs.length > 1\n ? { rawOpenaiContentParts: imgs }\n : {}),\n });\n break;\n }\n case \"assistant\": {\n const reasoning = typeof m.reasoning_content === \"string\" ? m.reasoning_content : \"\";\n if (reasoning) {\n const base = deriveMessageId(\"assistant\", \"reasoning\", reasoning);\n msgs.push({\n id: clusters.next(base),\n role: \"assistant\",\n contentType: \"reasoning\",\n text: reasoning,\n reasoningContent: reasoning,\n });\n }\n const text = stringContent(m.content);\n if (text) {\n const base = deriveMessageId(\"assistant\", \"text\", text);\n msgs.push({ id: clusters.next(base), role: \"assistant\", contentType: \"text\", text });\n }\n if (Array.isArray(m.tool_calls)) {\n for (const tc of m.tool_calls) {\n const base = deriveMessageId(\"assistant\", \"tool-call\", tc.function.arguments ?? \"\", {\n toolCallId: tc.id,\n toolName: tc.function.name,\n });\n msgs.push({\n id: clusters.next(base),\n role: \"assistant\",\n contentType: \"tool-call\",\n toolName: tc.function.name,\n toolCallId: tc.id,\n text: tc.function.arguments ?? \"\",\n });\n }\n }\n break;\n }\n case \"tool\": {\n const base = deriveMessageId(\"tool\", \"tool-result\", stringContent(m.content), {\n toolCallId: m.tool_call_id ?? \"\",\n });\n msgs.push({\n id: clusters.next(base),\n role: \"tool\",\n contentType: \"tool-result\",\n toolCallId: m.tool_call_id ?? \"\",\n text: stringContent(m.content),\n });\n break;\n }\n }\n }\n return { msgs };\n}\n\nexport function coreToOpenai(messages: BiliMessage[]): OpenAIMessage[] {\n const out: OpenAIMessage[] = [];\n let pending: { text: string | null; toolCalls: OpenAIToolCall[]; reasoning: string | null } | null = null;\n const flush = () => {\n if (!pending) return;\n const reasoning = pending.reasoning !== null && pending.reasoning.length > 0 ? pending.reasoning : undefined;\n if (pending.toolCalls.length > 0) {\n out.push({\n role: \"assistant\",\n content: pending.text ?? null,\n tool_calls: pending.toolCalls,\n ...(reasoning ? { reasoning_content: reasoning } : {}),\n });\n } else if (pending.text !== null) {\n out.push({ role: \"assistant\", content: pending.text, ...(reasoning ? { reasoning_content: reasoning } : {}) });\n } else if (reasoning) {\n out.push({ role: \"assistant\", content: null, reasoning_content: reasoning });\n }\n pending = null;\n };\n for (const m of messages) {\n if (m.role === \"assistant\") {\n if (!pending) pending = { text: null, toolCalls: [], reasoning: null };\n if (m.contentType === \"reasoning\") {\n pending.reasoning = (pending.reasoning ?? \"\") + (m.reasoningContent ?? m.text ?? \"\");\n } else if (m.contentType === \"text\") {\n pending.text = (pending.text ?? \"\") + (m.text ?? \"\");\n } else if (m.contentType === \"tool-call\") {\n pending.toolCalls.push({\n id: m.toolCallId ?? `call_${m.id}`,\n type: \"function\",\n function: { name: m.toolName ?? \"unknown\", arguments: m.text ?? \"\" },\n });\n }\n } else {\n flush();\n if (m.role === \"system\") {\n out.push({ role: m.originalRole === \"developer\" ? \"developer\" : \"system\", content: m.text ?? \"\" });\n } else if (m.role === \"user\") {\n if (m.rawOpenaiContent || m.imageBase64 || m.rawOpenaiContentParts) {\n const parts: OpenAIContentPart[] = [];\n if (m.text) parts.push({ type: \"text\", text: m.text });\n if (m.rawOpenaiContentParts && m.rawOpenaiContentParts.length > 0) {\n for (const part of m.rawOpenaiContentParts) parts.push(part as OpenAIContentPart);\n } else if (m.rawOpenaiContent) {\n parts.push(m.rawOpenaiContent as OpenAIContentPart);\n } else if (m.imageBase64 && m.imageMediaType) {\n parts.push({ type: \"image_url\", image_url: { url: `data:${m.imageMediaType};base64,${m.imageBase64}` } });\n }\n out.push({ role: \"user\", content: parts });\n } else {\n out.push({ role: \"user\", content: m.text ?? \"\" });\n }\n } else if (m.role === \"tool\") {\n out.push({ role: \"tool\", tool_call_id: m.toolCallId ?? \"\", content: m.text ?? \"\" });\n }\n }\n }\n flush();\n return out;\n}\n\nexport function injectOpenaiSystem(messages: OpenAIMessage[], parts: string[]): OpenAIMessage[] {\n if (parts.length === 0) return messages;\n const extra = parts.join(\"\\n\\n\");\n if (messages.length > 0 && (messages[0]?.role === \"system\" || messages[0]?.role === \"developer\")) {\n const head = messages[0] as OpenAIMessage;\n const base = stringContent(head.content);\n const merged = base ? `${base}\\n\\n---\\n\\n${extra}` : extra;\n return [{ ...head, content: merged }, ...messages.slice(1)];\n }\n return [{ role: \"system\", content: extra }, ...messages];\n}\n\n/** Extract the conversation dimension for OpenAI Chat: a client-provided\n * session header if present, else a content fingerprint of the first user\n * message. See conversationSignalAnthropic for the full rationale. */\nexport function conversationSignalOpenai(body: OpenAIRequestBody, headerValue?: string): string {\n if (headerValue && headerValue.trim()) return headerValue.trim();\n const firstUser = body.messages.find((m) => m.role === \"user\");\n const seed = firstUser ? stringContent(firstUser.content) : \"default\";\n return hashId(seed);\n}\n\nfunction stringContent(content: OpenAIMessage[\"content\"]): string {\n if (content == null) return \"\";\n if (typeof content === \"string\") return content;\n if (Array.isArray(content)) {\n return content\n .map((p) => (typeof p === \"string\" ? p : p.type === \"text\" ? (p as { text?: string }).text ?? \"\" : \"\"))\n .join(\"\\n\");\n }\n return \"\";\n}\n\ntype OpenAIImagePart = { type: \"image_url\"; image_url: { url: string } };\n\n/** Collect ALL data-URL image parts in a user content array, in wire order.\n * (firstImagePart only kept the first, which silently dropped images 2..N\n * on the coreToOpenai rebuild.) */\nfunction allImageParts(content: OpenAIMessage[\"content\"]): OpenAIImagePart[] {\n if (!Array.isArray(content)) return [];\n const out: OpenAIImagePart[] = [];\n for (const p of content) {\n if (typeof p !== \"object\" || p === null) continue;\n if (!(\"type\" in p) || p.type !== \"image_url\" || !(\"image_url\" in p)) continue;\n // The union's index-signature member leaves image_url as `unknown`, so\n // narrow via a named const before reading the url.\n const imagePart = p as { image_url: { url?: unknown } };\n const url = imagePart.image_url.url;\n if (typeof url === \"string\" && parseDataUrl(url)) out.push(p as OpenAIImagePart);\n }\n return out;\n}\n","import type { CoreMessage } from \"../types.js\";\nimport { ClusterCounter, deriveMessageId } from \"./message-id.js\";\nimport type { ConversationIdentity } from \"./util.js\";\nimport { hashId } from \"./util.js\";\nimport { parseDataUrl, type BiliMessage } from \"./bili-message.js\";\n\nexport type ResponseContentPart =\n | { type: \"input_text\"; text: string; [key: string]: unknown }\n | { type: \"output_text\"; text: string; [key: string]: unknown }\n | { type: \"input_image\"; image_url: string; [key: string]: unknown }\n | { type: string; [key: string]: unknown };\n\nexport type ResponseInputMessage = {\n type: \"message\";\n role: \"system\" | \"developer\" | \"user\" | \"assistant\";\n content: string | ResponseContentPart[];\n [key: string]: unknown;\n};\n\nexport type ResponseFunctionCall = {\n type: \"function_call\";\n id?: string;\n call_id: string;\n name: string;\n arguments: string;\n [key: string]: unknown;\n};\n\nexport type ResponseFunctionCallOutput = {\n type: \"function_call_output\";\n call_id: string;\n output: string;\n [key: string]: unknown;\n};\n\nexport type ResponseInputItem =\n | ResponseInputMessage\n | ResponseFunctionCall\n | ResponseFunctionCallOutput\n | { type: string; [key: string]: unknown };\n\nexport type ResponsesRequestBody = {\n model?: string;\n input: string | ResponseInputItem[];\n instructions?: string;\n tools?: unknown[];\n stream?: boolean;\n session_id?: string;\n previous_response_id?: string;\n prompt_cache_key?: string;\n metadata?: Record<string, unknown>;\n [key: string]: unknown;\n};\n\ntype ResponseLayoutSlot = {\n original: ResponseInputItem;\n coreId?: string;\n};\n\nexport type ResponsesProjection = {\n msgs: BiliMessage[];\n systemParts: string[];\n preamble: ResponseInputItem[];\n customToolCallIds: Set<string>;\n layout: ResponseLayoutSlot[];\n stringInput?: { original: string; coreId: string };\n /** Reasoning items dropped because ACP_REASONING_KEEP=none. 0 by default —\n * reasoning is normally routed through the compression pipeline so it is\n * hidden automatically once its turn is summarized. */\n droppedReasoning: number;\n};\n\n/** Item types that are host DIRECTIVES (tool/definition listings), not\n * conversation history: preserved verbatim and re-prepended at input[0..].\n * `additional_tools` carries the Codex code_mode exec/wait tool definitions\n * and MUST stay at input[0]. `mcp_list_tools` is a stable per-session listing.\n *\n * Only definitions belong here. Output/action items from a prior response\n * (reasoning, computer_call, function_call, mcp_call, ...) ARE conversation\n * history and are routed as tracked BiliMessages, so the compression pipeline\n * hides them once their turn is summarized — preserving them verbatim in the\n * preamble instead made them accumulate unbounded every turn and broke Codex's\n * prompt-cache prefix. */\nconst OPAQUE_ITEM_TYPES = new Set([\n \"additional_tools\",\n \"mcp_list_tools\",\n]);\n\nfunction isOpaqueItem(item: ResponseInputItem): boolean {\n return OPAQUE_ITEM_TYPES.has(item.type);\n}\n\nfunction shouldDropAllReasoning(): boolean {\n return (process.env.ACP_REASONING_KEEP ?? \"\").trim().toLowerCase() === \"none\";\n}\n\nfunction partText(part: ResponseContentPart): string {\n if (part.type === \"input_text\" || part.type === \"output_text\") {\n return typeof part.text === \"string\" ? part.text : \"\";\n }\n return \"\";\n}\n\nfunction messageContent(content: string | ResponseContentPart[]): string {\n return typeof content === \"string\" ? content : content.map(partText).join(\"\\n\");\n}\n\nexport function responsesToCore(body: ResponsesRequestBody): ResponsesProjection {\n const msgs: BiliMessage[] = [];\n const systemParts: string[] = [];\n const preamble: ResponseInputItem[] = [];\n const customToolCallIds = new Set<string>();\n const layout: ResponseLayoutSlot[] = [];\n let droppedReasoning = 0;\n const clusters = new ClusterCounter();\n let idx = 0;\n if (typeof body.instructions === \"string\" && body.instructions.trim()) systemParts.push(body.instructions);\n if (typeof body.input === \"string\") {\n const id = clusters.next(deriveMessageId(\"user\", \"text\", body.input));\n msgs.push({ id, role: \"user\", contentType: \"text\", text: body.input });\n return { msgs, systemParts, preamble, customToolCallIds, layout, droppedReasoning, stringInput: { original: body.input, coreId: id } };\n }\n for (const item of body.input) {\n let coreId: string | undefined;\n if (isOpaqueItem(item)) preamble.push(item);\n switch (item.type) {\n case \"reasoning\": {\n if (shouldDropAllReasoning()) {\n droppedReasoning++;\n continue;\n }\n const rid =\n typeof (item as { id?: unknown }).id === \"string\"\n ? String((item as { id?: string }).id)\n : hashId(JSON.stringify(item));\n coreId = clusters.next(deriveMessageId(\"assistant\", \"reasoning\", rid));\n msgs.push({\n id: coreId,\n role: \"assistant\",\n contentType: \"reasoning\",\n text: rid,\n rawResponsesItem: item,\n });\n break;\n }\n case \"message\": {\n const message = item as ResponseInputMessage;\n const text = messageContent(message.content);\n if (message.role === \"system\" || message.role === \"developer\") {\n systemParts.push(text);\n idx++;\n continue;\n } else if (message.role === \"user\" || (message.role === \"assistant\" && text)) {\n const role = message.role;\n coreId = clusters.next(deriveMessageId(role, \"text\", text));\n const imageUrl = Array.isArray(message.content)\n ? message.content.find((part) => part.type === \"input_image\" && typeof part.image_url === \"string\")?.image_url\n : undefined;\n const image = typeof imageUrl === \"string\" ? parseDataUrl(imageUrl) : undefined;\n msgs.push({\n id: coreId,\n role,\n contentType: \"text\",\n text,\n rawResponsesItem: item,\n ...(image ? { imageMediaType: image.mediaType, imageBase64: image.base64 } : {}),\n });\n }\n break;\n }\n case \"function_call\": {\n const call = item as ResponseFunctionCall;\n coreId = clusters.next(deriveMessageId(\"assistant\", \"tool-call\", call.arguments ?? \"\", {\n toolCallId: call.call_id,\n toolName: call.name,\n }));\n msgs.push({\n id: coreId,\n role: \"assistant\",\n contentType: \"tool-call\",\n toolName: call.name,\n toolCallId: call.call_id,\n text: call.arguments ?? \"\",\n rawResponsesItem: item,\n });\n break;\n }\n case \"function_call_output\": {\n const output = item as ResponseFunctionCallOutput;\n const text = typeof output.output === \"string\" ? output.output : JSON.stringify(output.output);\n coreId = clusters.next(deriveMessageId(\"tool\", \"tool-result\", text, { toolCallId: output.call_id }));\n msgs.push({ id: coreId, role: \"tool\", contentType: \"tool-result\", toolCallId: output.call_id, text, rawResponsesItem: item });\n break;\n }\n case \"computer_call\":\n case \"computer_call_output\":\n case \"file_search_call\":\n case \"web_search_call\":\n case \"image_generation_call\":\n case \"code_interpreter_call\":\n case \"mcp_call\": {\n const rid =\n typeof (item as { id?: unknown }).id === \"string\"\n ? String((item as { id?: string }).id)\n : hashId(JSON.stringify(item));\n coreId = clusters.next(deriveMessageId(\"assistant\", \"responses-call\", rid));\n msgs.push({ id: coreId, role: \"assistant\", contentType: \"reasoning\", text: rid, rawResponsesItem: item });\n break;\n }\n case \"custom_tool_call\": {\n const ctc = item as { call_id?: string; name?: string; input?: string; arguments?: string };\n const callId = ctc.call_id ?? `call_${idx}`;\n customToolCallIds.add(callId);\n const argText = ctc.input ?? ctc.arguments ?? \"\";\n coreId = clusters.next(deriveMessageId(\"assistant\", \"tool-call\", argText, { toolCallId: callId, toolName: ctc.name ?? \"custom\" }));\n msgs.push({ id: coreId, role: \"assistant\", contentType: \"tool-call\", toolName: ctc.name ?? \"custom\", toolCallId: callId, text: argText, rawResponsesItem: item });\n break;\n }\n case \"custom_tool_call_output\": {\n const ctco = item as { call_id?: string; output?: string };\n const callId = ctco.call_id ?? `call_${idx}`;\n customToolCallIds.add(callId);\n const outText = typeof ctco.output === \"string\" ? ctco.output : JSON.stringify(ctco.output ?? \"\");\n coreId = clusters.next(deriveMessageId(\"tool\", \"tool-result\", outText, { toolCallId: callId }));\n msgs.push({ id: coreId, role: \"tool\", contentType: \"tool-result\", toolCallId: callId, text: outText, rawResponsesItem: item });\n break;\n }\n default:\n if (!isOpaqueItem(item)) preamble.push(item);\n break;\n }\n layout.push({ original: item, coreId });\n idx++;\n }\n return { msgs, systemParts, preamble, customToolCallIds, layout, droppedReasoning };\n}\n\nfunction patchTextParts(parts: ResponseContentPart[], text: string): ResponseContentPart[] {\n const textIndexes = parts.flatMap((part, index) =>\n part.type === \"input_text\" || part.type === \"output_text\" ? [index] : [],\n );\n if (textIndexes.length === 0) return [{ type: \"input_text\", text }, ...parts];\n const first = textIndexes[0];\n const remaining = new Set(textIndexes.slice(1));\n return parts.map((part, index) => {\n if (index === first) return { ...part, text };\n if (remaining.has(index)) return { ...part, text: \"\" };\n return part;\n });\n}\n\nfunction patchOriginalItem(original: ResponseInputItem, source: CoreMessage, next: CoreMessage): ResponseInputItem {\n if (\n source.text === next.text &&\n source.toolName === next.toolName &&\n source.toolCallId === next.toolCallId &&\n source.role === next.role &&\n source.contentType === next.contentType\n ) return original;\n if (original.type === \"message\") {\n const message = original as ResponseInputMessage;\n const content = typeof message.content === \"string\" ? next.text ?? \"\" : patchTextParts(message.content, next.text ?? \"\");\n return { ...message, content };\n }\n if (original.type === \"function_call\") {\n return {\n ...original,\n name: next.toolName ?? String(original.name ?? \"unknown\"),\n call_id: next.toolCallId ?? String(original.call_id ?? \"\"),\n arguments: next.text ?? \"\",\n };\n }\n if (original.type === \"function_call_output\") {\n return { ...original, call_id: next.toolCallId ?? String(original.call_id ?? \"\"), output: next.text ?? \"\" };\n }\n return original;\n}\n\nexport function patchResponsesInput(projection: ResponsesProjection, messages: CoreMessage[]): string | ResponseInputItem[] {\n if (projection.stringInput) {\n const original = projection.msgs.find((message) => message.id === projection.stringInput?.coreId);\n const next = messages.find((message) => message.id === projection.stringInput?.coreId);\n if (original && next && messages.length === 1 && next.role === \"user\" && next.contentType === \"text\") {\n return next.text === original.text ? projection.stringInput.original : next.text ?? \"\";\n }\n return coreToResponses(messages, projection.customToolCallIds);\n }\n const sourceById = new Map(projection.msgs.map((message) => [message.id, message]));\n const nextById = new Map(messages.map((message) => [message.id, message]));\n const slotById = new Map<string, number>();\n projection.layout.forEach((slot, index) => {\n if (slot.coreId) slotById.set(slot.coreId, index);\n });\n const insertions = new Map<number, ResponseInputItem[]>();\n for (let index = 0; index < messages.length; index++) {\n const message = messages[index]!;\n if (sourceById.has(message.id)) continue;\n let target = projection.layout.length;\n for (let nextIndex = index + 1; nextIndex < messages.length; nextIndex++) {\n const slot = slotById.get(messages[nextIndex]!.id);\n if (slot !== undefined) {\n target = slot;\n break;\n }\n }\n const generated = coreToResponses([message], projection.customToolCallIds);\n if (generated.length > 0) insertions.set(target, [...(insertions.get(target) ?? []), ...generated]);\n }\n const out: ResponseInputItem[] = [];\n projection.layout.forEach((slot, index) => {\n out.push(...(insertions.get(index) ?? []));\n if (!slot.coreId) {\n out.push(slot.original);\n return;\n }\n const source = sourceById.get(slot.coreId);\n const next = nextById.get(slot.coreId);\n if (source && next) out.push(patchOriginalItem(slot.original, source, next));\n });\n out.push(...(insertions.get(projection.layout.length) ?? []));\n return out;\n}\n\nexport function coreToResponses(\n messages: CoreMessage[],\n customToolCallIds: Set<string> = new Set(),\n): ResponseInputItem[] {\n const out: ResponseInputItem[] = [];\n for (const message of messages) {\n const biliMessage = message as BiliMessage;\n const raw = biliMessage.rawResponsesItem as ResponseInputItem | undefined;\n if (message.role === \"system\") {\n out.push({ type: \"message\", role: \"developer\", content: message.text ?? \"\" });\n } else if (message.role === \"user\") {\n if (raw?.type === \"message\" && messageContent((raw as ResponseInputMessage).content) === (message.text ?? \"\")) out.push(raw);\n else out.push({ type: \"message\", role: \"user\", content: message.text ?? \"\" });\n } else if (message.role === \"assistant\") {\n if (message.contentType === \"text\") {\n out.push({ type: \"message\", role: \"assistant\", content: message.text ?? \"\" });\n } else if (message.contentType === \"tool-call\") {\n const callId = message.toolCallId ?? `call_${message.id}`;\n if (customToolCallIds.has(callId)) {\n out.push({ type: \"custom_tool_call\", call_id: callId, name: message.toolName ?? \"unknown\", input: message.text ?? \"\", status: \"completed\" } as ResponseInputItem);\n } else {\n out.push({ type: \"function_call\", call_id: callId, name: message.toolName ?? \"unknown\", arguments: message.text ?? \"\" });\n }\n } else if (message.contentType === \"reasoning\") {\n if (raw) out.push(raw);\n }\n } else if (message.role === \"tool\") {\n const callId = message.toolCallId ?? \"\";\n if (customToolCallIds.has(callId)) {\n out.push({ type: \"custom_tool_call_output\", call_id: callId, output: message.text ?? \"\" } as ResponseInputItem);\n } else {\n out.push({ type: \"function_call_output\", call_id: callId, output: message.text ?? \"\" });\n }\n }\n }\n return out;\n}\n\nexport function injectResponsesDeveloperMessage(\n input: string | ResponseInputItem[],\n content: string,\n): ResponseInputItem[] {\n const items: ResponseInputItem[] = typeof input === \"string\"\n ? [{ type: \"message\", role: \"user\", content: input }]\n : [...input];\n let index = 0;\n while (items[index]?.type === \"additional_tools\") index++;\n items.splice(index, 0, { type: \"message\", role: \"developer\", content });\n return items;\n}\n\nexport function conversationIdentityResponses(\n body: ResponsesRequestBody,\n headerValue?: string,\n): ConversationIdentity {\n if (headerValue?.trim()) return { value: headerValue.trim(), source: \"header\", clientProvided: true };\n if (typeof body.session_id === \"string\" && body.session_id.trim()) {\n return { value: body.session_id.trim(), source: \"body-session\", clientProvided: true };\n }\n const metadataSession = body.metadata?.session_id;\n if (typeof metadataSession === \"string\" && metadataSession.trim()) {\n return { value: metadataSession.trim(), source: \"metadata-session\", clientProvided: true };\n }\n if (typeof body.previous_response_id === \"string\" && body.previous_response_id.trim()) {\n return { value: body.previous_response_id.trim(), source: \"previous-response\", clientProvided: false };\n }\n return { value: hashId(JSON.stringify(body.input ?? [])), source: \"content-fingerprint\", clientProvided: false };\n}\n\nexport function conversationSignalResponses(body: ResponsesRequestBody, headerValue?: string): string {\n return conversationIdentityResponses(body, headerValue).value;\n}\n\n// Codex subagents (guardian approval reviewer, etc.) reuse the main\n// conversation's body.session_id, so identity alone collapses their requests\n// onto the main session's compression state — a compressed subagent request\n// loses the verbatim user authorization it must read back (#150). Subagent\n// requests carry their own `instructions` (the agent's role prompt), so the\n// FIRST instructions seen for an identity anchor the main namespace (it never\n// changes for the conversation, even if the main prompt drifts), and any other\n// instructions value maps to a separate `|sub:` namespace with its own empty\n// compression state. Subagent requests are self-contained replays, so the\n// fresh namespace is lossless.\nexport interface SubagentNamespaces {\n /** Resolve the compression-state namespace for a request: the identity\n * itself for the anchored (main) instructions, `identity|sub:<fp>` for\n * any other instructions value. First-seen instructions anchor. */\n namespaceFor(identityValue: string, instructions: unknown): string;\n}\n\n/** Host-owned subagent-namespace store.\n *\n * The anchor map is per-conversation mutable state, so it belongs to the\n * host — NOT to a library module global. Create one instance and keep it for\n * the process lifetime (or persist it alongside your session store if you\n * need namespaces to survive restarts: a fresh instance re-anchors on the\n * first request it sees, which after a restart may be a subagent request,\n * orphaning the main conversation's stored compression state). */\nexport function createSubagentNamespaces(): SubagentNamespaces {\n const anchors = new Map<string, string>();\n return {\n namespaceFor(identityValue: string, instructions: unknown): string {\n if (typeof instructions !== \"string\" || instructions.trim().length === 0) return identityValue;\n const fp = hashId(instructions);\n const anchor = anchors.get(identityValue);\n if (anchor === undefined) {\n anchors.set(identityValue, fp);\n return identityValue;\n }\n return anchor === fp ? identityValue : `${identityValue}|sub:${fp}`;\n },\n };\n}\n\n// Convenience singleton for single-process proxies that don't manage\n// per-session state themselves. Hosts needing isolation between\n// conversations, deterministic namespaces across restarts, or a bound on\n// anchor memory should create their own instance via\n// createSubagentNamespaces() and own its lifecycle.\nconst defaultNamespaces = createSubagentNamespaces();\n\nexport function subagentNamespace(identityValue: string, instructions: unknown): string {\n return defaultNamespaces.namespaceFor(identityValue, instructions);\n}\n","export const WIRE_FORMATS = [\"anthropic\", \"openai\", \"responses\"] as const;\nexport type WireFormat = (typeof WIRE_FORMATS)[number];\n\nexport function isWireFormat(value: unknown): value is WireFormat {\n return (\n typeof value === \"string\" &&\n (WIRE_FORMATS as readonly string[]).includes(value)\n );\n}\n\n/**\n * Classify a provider request body by the codec that can parse it.\n * Returns undefined when no codec handles the body — the caller must\n * pass such payloads through untransformed.\n */\nexport function detectWireFormat(payload: unknown): WireFormat | undefined {\n if (payload === null || typeof payload !== \"object\") return undefined;\n const p = payload as Record<string, unknown>;\n if (Array.isArray(p.input)) return \"responses\";\n const messages = p.messages;\n if (!Array.isArray(messages)) return undefined;\n if (\"system\" in p || \"anthropic_version\" in p) return \"anthropic\";\n for (const m of messages as Array<Record<string, unknown>>) {\n if (m === null || typeof m !== \"object\") continue;\n const c = m.content;\n if (Array.isArray(c)) {\n for (const b of c as Array<Record<string, unknown>>) {\n if (b && typeof b === \"object\" && typeof b.type === \"string\") {\n if (\n b.type === \"tool_use\" ||\n b.type === \"tool_result\" ||\n b.type === \"thinking\"\n )\n return \"anthropic\";\n if (b.type === \"text\" && \"cache_control\" in b) return \"anthropic\";\n }\n }\n }\n if (Array.isArray(m.tool_calls)) return \"openai\";\n if (m.role === \"tool\" && typeof m.tool_call_id === \"string\")\n return \"openai\";\n if (m.role === \"system\" || m.role === \"developer\") return \"openai\";\n }\n // Both chat formats share role+messages; default to openai — the safer\n // guess for OpenAI-compatible endpoints (GLM, DeepSeek, vLLM).\n return \"openai\";\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAKpB,SAAS,OAAO,GAAmB;AACtC,SAAO,WAAW,QAAQ,EAAE,OAAO,GAAG,MAAM,EAAE,OAAO,KAAK,EAAE,MAAM,GAAG,EAAE;AAC3E;;;ACwBO,SAAS,gBACZ,MACA,aACA,MACA,UAGI,CAAC,GACC;AACN,QAAM,OAAO,GAAG,IAAI,IAAI,WAAW,IAAI,QAAQ,cAAc,EAAE,IAAI,QAAQ,YAAY,EAAE,IAAI,IAAI;AACjG,SAAO,OAAO,OAAO,IAAI;AAC7B;AAOO,IAAM,iBAAN,MA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,QAAQ,OAAO,MAAM,SAAU;AACzC,UAAM,IAAI,EAAE;AACZ,QAAI,MAAM,QAAQ,CAAC,GAAG;AACpB,iBAAW,KAAK,GAAqC;AACnD,YAAI,KAAK,OAAO,MAAM,YAAY,OAAO,EAAE,SAAS,UAAU;AAC5D,cACE,EAAE,SAAS,cACX,EAAE,SAAS,iBACX,EAAE,SAAS;AAEX,mBAAO;AACT,cAAI,EAAE,SAAS,UAAU,mBAAmB,EAAG,QAAO;AAAA,QACxD;AAAA,MACF;AAAA,IACF;AACA,QAAI,MAAM,QAAQ,EAAE,UAAU,EAAG,QAAO;AACxC,QAAI,EAAE,SAAS,UAAU,OAAO,EAAE,iBAAiB;AACjD,aAAO;AACT,QAAI,EAAE,SAAS,YAAY,EAAE,SAAS,YAAa,QAAO;AAAA,EAC5D;AAGA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/wire/util.ts","../../src/wire/message-id.ts","../../src/wire/anthropic.ts","../../src/wire/bili-message.ts","../../src/wire/openai.ts","../../src/wire/responses.ts","../../src/wire/formats.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\n\n/** SHA-256-derived short id — kept verbatim from the proxy so message ids\n * stay byte-identical across the extraction (re-keying would orphan every\n * downstream map keyed on these ids). */\nexport function hashId(s: string): string {\n return createHash(\"sha256\").update(s, \"utf8\").digest(\"hex\").slice(0, 16);\n}\n\n/** How a conversation's identity was derived (kept verbatim from the proxy's\n * session-id.ts — only the TYPE moves; session-key derivation stays in the\n * proxy, which owns multi-tenant state). */\nexport type ConversationIdentity = {\n value: string;\n source: \"header\" | \"body-session\" | \"metadata-session\" | \"previous-response\" | \"content-fingerprint\" | \"generated\";\n clientProvided: boolean;\n};\n","import { hashId } from \"./util.js\";\n\n/**\n * Derive a stable, content-based message id.\n *\n * PROBLEM: none of the three wire protocols (Anthropic Messages, OpenAI Chat\n * Completions, OpenAI Responses) attach a stable id to request-side message\n * items. Historically each converter used `raw-${idx}` — a *position* index,\n * not an identity. As soon as a client deletes/reorders messages (other plugins\n * summarizing away old turns, multi-agent setups, etc.) the index drifts:\n * downstream ids shift, so\n * - assignRefs reuses stale `byRaw` entries, hiding new messages, and\n * - compression `effectiveMessageIds` start pointing at the *wrong* messages,\n * silently swallowing live content under an unrelated summary.\n *\n * FIX: derive the id from a SHA-256 of the message identity:\n * role + contentType + toolCallId + toolName + text\n * Two messages with identical identity collide. To keep duplicates distinct\n * (and avoid `covered` sets collapsing unrelated turns onto one id) we append a\n * within-conversation *cluster index* `_N`: the Nth occurrence of the same\n * identity, counting from 0 in arrival order.\n *\n * Trade-off vs a real client id:\n * - deleting a duplicated message only disturbs the cluster of that identity\n * (local damage), never the whole downstream (global damage like position).\n * - fully distinct messages are completely immune to reordering/deletion.\n *\n * `idx` is passed purely to break ties *within a single conversion pass*; it is\n * not part of the identity, so two passes over the same content produce the\n * same cluster numbering (deterministic).\n */\nexport function deriveMessageId(\n role: string,\n contentType: string,\n text: string,\n options: {\n toolCallId?: string;\n toolName?: string;\n } = {},\n): string {\n const seed = `${role}|${contentType}|${options.toolCallId ?? \"\"}|${options.toolName ?? \"\"}|${text}`;\n return \"h_\" + hashId(seed);\n}\n\n/**\n * Stateful cluster counter. Each converter instantiates one per conversion\n * pass; it tracks how many times each base identity has been seen so that the\n * Nth duplicate gets a `_${N}` suffix.\n */\nexport class ClusterCounter {\n private counts = new Map<string, number>();\n\n next(baseId: string): string {\n const n = this.counts.get(baseId) ?? 0;\n this.counts.set(baseId, n + 1);\n return n === 0 ? baseId : `${baseId}_${n}`;\n }\n}\n","import type { BiliMessage } from \"./bili-message.js\";\nimport { hashId } from \"./util.js\";\nimport { ClusterCounter, deriveMessageId } from \"./message-id.js\";\n\nexport type AnthropicTextBlock = { type: \"text\"; text: string; cache_control?: unknown };\nexport type AnthropicToolUse = {\n type: \"tool_use\";\n id: string;\n name: string;\n input: unknown;\n cache_control?: unknown;\n};\nexport type AnthropicToolResult = {\n type: \"tool_result\";\n tool_use_id: string;\n content: string | AnthropicTextBlock[];\n is_error?: boolean;\n cache_control?: unknown;\n};\nexport type AnthropicImage = { type: \"image\"; source: unknown };\nexport type AnthropicThinking = { type: \"thinking\"; thinking: string; signature?: string };\nexport type AnthropicBlock =\n | AnthropicTextBlock\n | AnthropicToolUse\n | AnthropicToolResult\n | AnthropicImage\n | AnthropicThinking;\n\nexport type AnthropicMessage = {\n role: \"user\" | \"assistant\";\n content: string | AnthropicBlock[];\n};\n\nexport type AnthropicRequestBody = {\n model?: string;\n max_tokens?: number;\n system?: string | AnthropicTextBlock[];\n messages: AnthropicMessage[];\n tools?: unknown[];\n stream?: boolean;\n temperature?: number;\n [key: string]: unknown;\n};\n\n\nexport function extractSystem(system: AnthropicRequestBody[\"system\"]): string {\n if (!system) return \"\";\n if (typeof system === \"string\") return system;\n return system.map((b) => b.text).join(\"\\n\\n\");\n}\n\nexport function buildSystem(text: string, original: AnthropicRequestBody[\"system\"]): string | AnthropicTextBlock[] {\n if (Array.isArray(original) && original.length > 0) {\n const ccBlock = original.find((b) => b.cache_control);\n return [{ type: \"text\", text, ...(ccBlock ? { cache_control: ccBlock.cache_control } : {}) }];\n }\n return text;\n}\n\ntype Flat = { msgs: BiliMessage[]; cacheControls: Map<string, unknown> };\n\nexport function anthropicToCore(body: AnthropicRequestBody): Flat {\n const msgs: BiliMessage[] = [];\n const cacheControls = new Map<string, unknown>();\n const clusters = new ClusterCounter();\n for (const m of body.messages) {\n const blocks = typeof m.content === \"string\" ? [{ type: \"text\" as const, text: m.content }] : m.content;\n for (const b of blocks) {\n switch (b.type) {\n case \"text\": {\n const base = deriveMessageId(m.role, \"text\", b.text);\n const id = clusters.next(base);\n msgs.push({ id, role: m.role, contentType: \"text\", text: b.text });\n if (b.cache_control) cacheControls.set(id, b.cache_control);\n break;\n }\n case \"tool_use\": {\n const base = deriveMessageId(\"assistant\", \"tool-call\", safeStringify(b.input), {\n toolCallId: b.id,\n toolName: b.name,\n });\n const id = clusters.next(base);\n msgs.push({\n id,\n role: \"assistant\",\n contentType: \"tool-call\",\n toolName: b.name,\n toolCallId: b.id,\n text: safeStringify(b.input),\n });\n if (b.cache_control) cacheControls.set(id, b.cache_control);\n break;\n }\n case \"tool_result\": {\n const text = typeof b.content === \"string\" ? b.content : b.content.map((c) => c.text).join(\"\\n\");\n const base = deriveMessageId(\"tool\", \"tool-result\", text, { toolCallId: b.tool_use_id });\n const id = clusters.next(base);\n msgs.push({\n id,\n role: \"tool\",\n contentType: \"tool-result\",\n toolCallId: b.tool_use_id,\n text,\n ...(b.is_error === true ? { toolIsError: true } : {}),\n });\n if (b.cache_control) cacheControls.set(id, b.cache_control);\n break;\n }\n case \"thinking\": {\n const base = deriveMessageId(\"assistant\", \"reasoning\", b.thinking);\n msgs.push({\n id: clusters.next(base),\n role: \"assistant\",\n contentType: \"reasoning\",\n text: b.thinking,\n ...(b.signature ? { thinkingSignature: b.signature } : {}),\n });\n break;\n }\n case \"image\": {\n const base = deriveMessageId(m.role, \"text\", \"[image]\");\n msgs.push({\n id: clusters.next(base),\n role: m.role,\n contentType: \"text\",\n text: \"[image]\",\n rawAnthropicBlock: b,\n });\n break;\n }\n }\n }\n }\n return { msgs, cacheControls };\n}\n\nexport function coreToAnthropic(messages: BiliMessage[], cacheControls?: Map<string, unknown>): AnthropicMessage[] {\n const out: AnthropicMessage[] = [];\n let current: { role: \"user\" | \"assistant\"; blocks: AnthropicBlock[] } | null = null;\n const flush = () => {\n if (current && current.blocks.length > 0) {\n out.push({ role: current.role, content: current.blocks });\n }\n current = null;\n };\n const cc = (id: string): { cache_control?: unknown } => {\n const v = cacheControls?.get(id);\n return v ? { cache_control: v } : {};\n };\n for (const m of messages) {\n const target: \"user\" | \"assistant\" =\n m.role === \"assistant\" ? \"assistant\" : \"user\";\n if (!current || current.role !== target) {\n flush();\n current = { role: target, blocks: [] };\n }\n switch (m.contentType) {\n case \"text\": {\n if (m.rawAnthropicBlock) {\n current.blocks.push(m.rawAnthropicBlock as AnthropicBlock);\n break;\n }\n current.blocks.push({ type: \"text\", text: m.text ?? \"\", ...cc(m.id) });\n break;\n }\n case \"tool-call\":\n current.blocks.push({\n type: \"tool_use\",\n id: m.toolCallId ?? `call_${m.id}`,\n name: m.toolName ?? \"unknown\",\n input: safeParse(m.text),\n ...cc(m.id),\n });\n break;\n case \"tool-result\":\n current.blocks.push({\n type: \"tool_result\",\n tool_use_id: m.toolCallId ?? \"\",\n content: m.text ?? \"\",\n ...(m.toolIsError ? { is_error: true } : {}),\n ...cc(m.id),\n });\n break;\n case \"reasoning\":\n current.blocks.push({\n type: \"thinking\",\n thinking: m.text ?? \"\",\n ...(m.thinkingSignature ? { signature: m.thinkingSignature } : {}),\n });\n break;\n }\n }\n flush();\n return out;\n}\n\n/** Extract the conversation dimension for Anthropic: a client-provided\n * session header if present, else a content fingerprint of the first user\n * message. The protocol+upstream+key dimensions are mixed in by the caller\n * (server.ts) via deriveSessionId() — this function contributes only the\n * conversation axis. */\nexport function conversationSignalAnthropic(body: AnthropicRequestBody, headerValue?: string): string {\n if (headerValue && headerValue.trim()) return headerValue.trim();\n const firstUser = body.messages.find((m) => m.role === \"user\");\n const seed = firstUser ? JSON.stringify(firstUser.content) : \"default\";\n return hashId(seed);\n}\n\nfunction safeStringify(v: unknown): string {\n try {\n return JSON.stringify(v ?? {});\n } catch {\n return \"{}\";\n }\n}\n\nfunction safeParse(s: string | undefined): unknown {\n if (!s) return {};\n try {\n return JSON.parse(s);\n } catch {\n return {};\n }\n}\n","/**\n * Lossless message bridge between protocol-specific message formats and the\n * kernel's CoreMessage.\n *\n * Problem: `anthropicToCore` / `openaiToCore` / `responsesToCore` flatten\n * rich protocol blocks (images, thinking signatures, tool_result.is_error,\n * developer-role messages, image_url) into plain `{ text }` placeholders.\n * The reverse `coreToX` then can't reconstruct them — `is_error` is lost\n * (upstream can't tell a tool error from a result), `thinking.signature` is\n * lost (Anthropic rejects thinking blocks without a matching signature),\n * images become \"[image]\" (the model never sees the picture).\n *\n * Solution: `BiliMessage` extends CoreMessage with optional sidecar fields.\n * The kernel only reads `{ ...message }` (spread copy) and known fields, so\n * the extra fields survive the compression pipeline unchanged and arrive back\n * at `coreToX`, which prefers them over the flattened `text`. No `as any`\n * needed — TypeScript array covariance lets `BiliMessage[]` satisfy a\n * `CoreMessage[]` parameter.\n */\n\nimport type { CoreMessage } from \"acp-kernel\";\n\n/** A message that carries its original protocol block(s) verbatim, so the\n * reverse conversion can reconstruct losslessly. Every field is optional —\n * plain text messages (the common case) have none set. */\nexport interface BiliMessage extends CoreMessage {\n /** Anthropic: the original content block for an image or a structured\n * tool_result. Restored verbatim by coreToAnthropic. */\n rawAnthropicBlock?: unknown;\n /** OpenAI chat: the original content part for an image_url, or the\n * original message object for a developer-role message. */\n rawOpenaiContent?: unknown;\n /** Responses API: the original input item (for input_image, or a raw\n * function_call / function_call_output we pass through). */\n rawResponsesItem?: unknown;\n /** Anthropic thinking signature. Anthropic verifies thinking+signature\n * pairs; without it the request is rejected. Stored alongside the\n * reasoning text so coreToAnthropic can reattach it. */\n thinkingSignature?: string;\n /** OpenAI reasoning_content (chain-of-thought from DeepSeek-R1, GLM-4.6\n * thinking, Qwen-QwQ). These models require reasoning_content be echoed\n * back on subsequent requests or the API returns HTTP 400; stored so\n * coreToOpenai can reattach it. */\n reasoningContent?: string;\n /** Anthropic tool_result.is_error. Marks the tool result as an error so\n * the model knows the tool failed (not just returned an error string). */\n toolIsError?: boolean;\n /** OpenAI: original role was \"developer\" (reconstructed as \"system\" by\n * openaiToCore for the kernel; coreToOpenai restores \"developer\"). */\n originalRole?: \"system\" | \"developer\";\n /** The original media type for an image (image/png, image/jpeg, image/gif,\n * image/webp). Lets coreToOpenai/coreToResponses rebuild image_url /\n * input_image with the right data URL. */\n imageMediaType?: string;\n /** The base64 data of an image (without the data: prefix). Lets the\n * reverse conversion rebuild the full image payload. */\n imageBase64?: string;\n /** OpenAI chat: ALL original image_url content parts (each a data: URL\n * part) for a user message carrying more than one image, in wire order.\n * coreToOpenai re-emits these verbatim (after the text part). The\n * singular `rawOpenaiContent` still covers the single-image case and\n * legacy persisted state. Typed as unknown[] (not OpenAIContentPart) to\n * avoid a circular import with the openai codec. */\n rawOpenaiContentParts?: unknown[];\n}\n\n/** Narrow a BiliMessage[] to CoreMessage[] for the kernel. The sidecar fields\n * are transparently carried along — the kernel's `{ ...msg }` copies them. */\nexport function toCoreMessages(msgs: BiliMessage[]): CoreMessage[] {\n return msgs as CoreMessage[];\n}\n\n/** Re-decode a base64 data URL into media type + data. Returns undefined if\n * the input is not a recognized data URL. Used by openaiToCore/responsesToCore\n * to split image_url/input_image into the sidecar fields. */\nexport function parseDataUrl(url: string): { mediaType: string; base64: string } | undefined {\n const m = /^data:([^;,]+)(?:;base64)?,(.+)$/i.exec(url);\n if (!m) return undefined;\n return { mediaType: m[1]!, base64: m[2]! };\n}\n","import { hashId } from \"./util.js\";\nimport { ClusterCounter, deriveMessageId } from \"./message-id.js\";\nimport { parseDataUrl, type BiliMessage } from \"./bili-message.js\";\n\nexport type OpenAIContentPart =\n | { type: \"text\"; text: string }\n | { type: \"image_url\"; image_url: { url: string } }\n | { type: string; [k: string]: unknown };\n\nexport type OpenAIToolCall = {\n id: string;\n type: \"function\";\n function: { name: string; arguments: string };\n};\n\nexport type OpenAIMessage = {\n role: \"system\" | \"developer\" | \"user\" | \"assistant\" | \"tool\";\n content?: string | null | OpenAIContentPart[];\n reasoning_content?: string | null;\n tool_calls?: OpenAIToolCall[];\n tool_call_id?: string;\n name?: string;\n};\n\nexport type OpenAITool = {\n type: \"function\";\n function: { name: string; description?: string; parameters?: unknown };\n};\n\nexport type OpenAIRequestBody = {\n model?: string;\n messages: OpenAIMessage[];\n tools?: OpenAITool[];\n stream?: boolean;\n [key: string]: unknown;\n};\n\ntype Flat = { msgs: BiliMessage[] };\n\nexport function openaiToCore(body: OpenAIRequestBody): Flat {\n const msgs: BiliMessage[] = [];\n const clusters = new ClusterCounter();\n for (const m of body.messages) {\n switch (m.role) {\n case \"system\":\n case \"developer\": {\n const base = deriveMessageId(m.role, \"text\", stringContent(m.content));\n msgs.push({ id: clusters.next(base), role: \"system\", contentType: \"text\", text: stringContent(m.content), originalRole: m.role });\n break;\n }\n case \"user\": {\n const text = stringContent(m.content);\n const imgs = allImageParts(m.content);\n const firstImg = imgs[0];\n const firstUrl = firstImg ? firstImg.image_url.url : undefined;\n const firstParsed = firstUrl ? parseDataUrl(firstUrl) : undefined;\n const base = deriveMessageId(\"user\", \"text\", text);\n msgs.push({\n id: clusters.next(base),\n role: \"user\",\n contentType: \"text\",\n text,\n ...(imgs.length === 1 && firstParsed\n ? { rawOpenaiContent: imgs[0], imageMediaType: firstParsed.mediaType, imageBase64: firstParsed.base64 }\n : imgs.length > 1\n ? { rawOpenaiContentParts: imgs }\n : {}),\n });\n break;\n }\n case \"assistant\": {\n const reasoning = typeof m.reasoning_content === \"string\" ? m.reasoning_content : \"\";\n if (reasoning) {\n const base = deriveMessageId(\"assistant\", \"reasoning\", reasoning);\n msgs.push({\n id: clusters.next(base),\n role: \"assistant\",\n contentType: \"reasoning\",\n text: reasoning,\n reasoningContent: reasoning,\n });\n }\n const text = stringContent(m.content);\n if (text) {\n const base = deriveMessageId(\"assistant\", \"text\", text);\n msgs.push({ id: clusters.next(base), role: \"assistant\", contentType: \"text\", text });\n }\n if (Array.isArray(m.tool_calls)) {\n for (const tc of m.tool_calls) {\n const base = deriveMessageId(\"assistant\", \"tool-call\", tc.function.arguments ?? \"\", {\n toolCallId: tc.id,\n toolName: tc.function.name,\n });\n msgs.push({\n id: clusters.next(base),\n role: \"assistant\",\n contentType: \"tool-call\",\n toolName: tc.function.name,\n toolCallId: tc.id,\n text: tc.function.arguments ?? \"\",\n });\n }\n }\n break;\n }\n case \"tool\": {\n const base = deriveMessageId(\"tool\", \"tool-result\", stringContent(m.content), {\n toolCallId: m.tool_call_id ?? \"\",\n });\n msgs.push({\n id: clusters.next(base),\n role: \"tool\",\n contentType: \"tool-result\",\n toolCallId: m.tool_call_id ?? \"\",\n text: stringContent(m.content),\n });\n break;\n }\n }\n }\n return { msgs };\n}\n\nexport function coreToOpenai(messages: BiliMessage[]): OpenAIMessage[] {\n const out: OpenAIMessage[] = [];\n let pending: { text: string | null; toolCalls: OpenAIToolCall[]; reasoning: string | null } | null = null;\n const flush = () => {\n if (!pending) return;\n const reasoning = pending.reasoning !== null && pending.reasoning.length > 0 ? pending.reasoning : undefined;\n if (pending.toolCalls.length > 0) {\n out.push({\n role: \"assistant\",\n content: pending.text ?? null,\n tool_calls: pending.toolCalls,\n ...(reasoning ? { reasoning_content: reasoning } : {}),\n });\n } else if (pending.text !== null) {\n out.push({ role: \"assistant\", content: pending.text, ...(reasoning ? { reasoning_content: reasoning } : {}) });\n } else if (reasoning) {\n out.push({ role: \"assistant\", content: null, reasoning_content: reasoning });\n }\n pending = null;\n };\n for (const m of messages) {\n if (m.role === \"assistant\") {\n if (!pending) pending = { text: null, toolCalls: [], reasoning: null };\n if (m.contentType === \"reasoning\") {\n pending.reasoning = (pending.reasoning ?? \"\") + (m.reasoningContent ?? m.text ?? \"\");\n } else if (m.contentType === \"text\") {\n pending.text = (pending.text ?? \"\") + (m.text ?? \"\");\n } else if (m.contentType === \"tool-call\") {\n pending.toolCalls.push({\n id: m.toolCallId ?? `call_${m.id}`,\n type: \"function\",\n function: { name: m.toolName ?? \"unknown\", arguments: m.text ?? \"\" },\n });\n }\n } else {\n flush();\n if (m.role === \"system\") {\n out.push({ role: m.originalRole === \"developer\" ? \"developer\" : \"system\", content: m.text ?? \"\" });\n } else if (m.role === \"user\") {\n if (m.rawOpenaiContent || m.imageBase64 || m.rawOpenaiContentParts) {\n const parts: OpenAIContentPart[] = [];\n if (m.text) parts.push({ type: \"text\", text: m.text });\n if (m.rawOpenaiContentParts && m.rawOpenaiContentParts.length > 0) {\n for (const part of m.rawOpenaiContentParts) parts.push(part as OpenAIContentPart);\n } else if (m.rawOpenaiContent) {\n parts.push(m.rawOpenaiContent as OpenAIContentPart);\n } else if (m.imageBase64 && m.imageMediaType) {\n parts.push({ type: \"image_url\", image_url: { url: `data:${m.imageMediaType};base64,${m.imageBase64}` } });\n }\n out.push({ role: \"user\", content: parts });\n } else {\n out.push({ role: \"user\", content: m.text ?? \"\" });\n }\n } else if (m.role === \"tool\") {\n out.push({ role: \"tool\", tool_call_id: m.toolCallId ?? \"\", content: m.text ?? \"\" });\n }\n }\n }\n flush();\n return out;\n}\n\nexport function injectOpenaiSystem(messages: OpenAIMessage[], parts: string[]): OpenAIMessage[] {\n if (parts.length === 0) return messages;\n const extra = parts.join(\"\\n\\n\");\n if (messages.length > 0 && (messages[0]?.role === \"system\" || messages[0]?.role === \"developer\")) {\n const head = messages[0] as OpenAIMessage;\n const base = stringContent(head.content);\n const merged = base ? `${base}\\n\\n---\\n\\n${extra}` : extra;\n return [{ ...head, content: merged }, ...messages.slice(1)];\n }\n return [{ role: \"system\", content: extra }, ...messages];\n}\n\n/** Extract the conversation dimension for OpenAI Chat: a client-provided\n * session header if present, else a content fingerprint of the first user\n * message. See conversationSignalAnthropic for the full rationale. */\nexport function conversationSignalOpenai(body: OpenAIRequestBody, headerValue?: string): string {\n if (headerValue && headerValue.trim()) return headerValue.trim();\n const firstUser = body.messages.find((m) => m.role === \"user\");\n const seed = firstUser ? stringContent(firstUser.content) : \"default\";\n return hashId(seed);\n}\n\nfunction stringContent(content: OpenAIMessage[\"content\"]): string {\n if (content == null) return \"\";\n if (typeof content === \"string\") return content;\n if (Array.isArray(content)) {\n return content\n .map((p) => (typeof p === \"string\" ? p : p.type === \"text\" ? (p as { text?: string }).text ?? \"\" : \"\"))\n .join(\"\\n\");\n }\n return \"\";\n}\n\ntype OpenAIImagePart = { type: \"image_url\"; image_url: { url: string } };\n\n/** Collect ALL data-URL image parts in a user content array, in wire order.\n * (firstImagePart only kept the first, which silently dropped images 2..N\n * on the coreToOpenai rebuild.) */\nfunction allImageParts(content: OpenAIMessage[\"content\"]): OpenAIImagePart[] {\n if (!Array.isArray(content)) return [];\n const out: OpenAIImagePart[] = [];\n for (const p of content) {\n if (typeof p !== \"object\" || p === null) continue;\n if (!(\"type\" in p) || p.type !== \"image_url\" || !(\"image_url\" in p)) continue;\n // The union's index-signature member leaves image_url as `unknown`, so\n // narrow via a named const before reading the url.\n const imagePart = p as { image_url: { url?: unknown } };\n const url = imagePart.image_url.url;\n if (typeof url === \"string\" && parseDataUrl(url)) out.push(p as OpenAIImagePart);\n }\n return out;\n}\n","import type { CoreMessage } from \"../types.js\";\nimport { ClusterCounter, deriveMessageId } from \"./message-id.js\";\nimport type { ConversationIdentity } from \"./util.js\";\nimport { hashId } from \"./util.js\";\nimport { parseDataUrl, type BiliMessage } from \"./bili-message.js\";\n\nexport type ResponseContentPart =\n | { type: \"input_text\"; text: string; [key: string]: unknown }\n | { type: \"output_text\"; text: string; [key: string]: unknown }\n | { type: \"input_image\"; image_url: string; [key: string]: unknown }\n | { type: string; [key: string]: unknown };\n\nexport type ResponseInputMessage = {\n type: \"message\";\n role: \"system\" | \"developer\" | \"user\" | \"assistant\";\n content: string | ResponseContentPart[];\n [key: string]: unknown;\n};\n\nexport type ResponseFunctionCall = {\n type: \"function_call\";\n id?: string;\n call_id: string;\n name: string;\n arguments: string;\n [key: string]: unknown;\n};\n\nexport type ResponseFunctionCallOutput = {\n type: \"function_call_output\";\n call_id: string;\n output: string;\n [key: string]: unknown;\n};\n\nexport type ResponseInputItem =\n | ResponseInputMessage\n | ResponseFunctionCall\n | ResponseFunctionCallOutput\n | { type: string; [key: string]: unknown };\n\nexport type ResponsesRequestBody = {\n model?: string;\n input: string | ResponseInputItem[];\n instructions?: string;\n tools?: unknown[];\n stream?: boolean;\n session_id?: string;\n previous_response_id?: string;\n prompt_cache_key?: string;\n metadata?: Record<string, unknown>;\n [key: string]: unknown;\n};\n\ntype ResponseLayoutSlot = {\n original: ResponseInputItem;\n coreId?: string;\n};\n\nexport type ResponsesProjection = {\n msgs: BiliMessage[];\n systemParts: string[];\n preamble: ResponseInputItem[];\n customToolCallIds: Set<string>;\n layout: ResponseLayoutSlot[];\n stringInput?: { original: string; coreId: string };\n /** Reasoning items dropped because ACP_REASONING_KEEP=none. 0 by default —\n * reasoning is normally routed through the compression pipeline so it is\n * hidden automatically once its turn is summarized. */\n droppedReasoning: number;\n};\n\n/** Item types that are host DIRECTIVES (tool/definition listings), not\n * conversation history: preserved verbatim and re-prepended at input[0..].\n * `additional_tools` carries the Codex code_mode exec/wait tool definitions\n * and MUST stay at input[0]. `mcp_list_tools` is a stable per-session listing.\n *\n * Only definitions belong here. Output/action items from a prior response\n * (reasoning, computer_call, function_call, mcp_call, ...) ARE conversation\n * history and are routed as tracked BiliMessages, so the compression pipeline\n * hides them once their turn is summarized — preserving them verbatim in the\n * preamble instead made them accumulate unbounded every turn and broke Codex's\n * prompt-cache prefix. */\nconst OPAQUE_ITEM_TYPES = new Set([\n \"additional_tools\",\n \"mcp_list_tools\",\n]);\n\nfunction isOpaqueItem(item: ResponseInputItem): boolean {\n return OPAQUE_ITEM_TYPES.has(item.type);\n}\n\nfunction shouldDropAllReasoning(): boolean {\n return (process.env.ACP_REASONING_KEEP ?? \"\").trim().toLowerCase() === \"none\";\n}\n\nfunction partText(part: ResponseContentPart): string {\n if (part.type === \"input_text\" || part.type === \"output_text\") {\n return typeof part.text === \"string\" ? part.text : \"\";\n }\n return \"\";\n}\n\nfunction messageContent(content: string | ResponseContentPart[]): string {\n return typeof content === \"string\" ? content : content.map(partText).join(\"\\n\");\n}\n\n/** Extract the reasoning text from a responses reasoning item. The host\n * carries it in `content` (reasoning_text parts); the primeFold mirror\n * carries it in `summary` (summary_text parts). Both must yield the same\n * text so the kernel derives the same core id (issue #64, responses). */\nfunction reasoningText(item: ResponseInputItem): string {\n const fromParts = (parts: unknown, type: string): string => {\n if (!Array.isArray(parts)) return \"\";\n const texts: string[] = [];\n for (const part of parts) {\n if (part && typeof part === \"object\" && \"type\" in part && \"text\" in part) {\n const rec = part as { type: unknown; text: unknown };\n if (rec.type === type && typeof rec.text === \"string\") texts.push(rec.text);\n }\n }\n return texts.join(\"\\n\");\n };\n const content = \"content\" in item ? item.content : undefined;\n const summary = \"summary\" in item ? item.summary : undefined;\n return fromParts(content, \"reasoning_text\") || fromParts(summary, \"summary_text\");\n}\n\nexport function responsesToCore(body: ResponsesRequestBody): ResponsesProjection {\n const msgs: BiliMessage[] = [];\n const systemParts: string[] = [];\n const preamble: ResponseInputItem[] = [];\n const customToolCallIds = new Set<string>();\n const layout: ResponseLayoutSlot[] = [];\n let droppedReasoning = 0;\n const clusters = new ClusterCounter();\n let idx = 0;\n if (typeof body.instructions === \"string\" && body.instructions.trim()) systemParts.push(body.instructions);\n if (typeof body.input === \"string\") {\n const id = clusters.next(deriveMessageId(\"user\", \"text\", body.input));\n msgs.push({ id, role: \"user\", contentType: \"text\", text: body.input });\n return { msgs, systemParts, preamble, customToolCallIds, layout, droppedReasoning, stringInput: { original: body.input, coreId: id } };\n }\n for (const item of body.input) {\n let coreId: string | undefined;\n if (isOpaqueItem(item)) preamble.push(item);\n switch (item.type) {\n case \"reasoning\": {\n if (shouldDropAllReasoning()) {\n droppedReasoning++;\n continue;\n }\n // Key the reasoning piece on its TEXT (deterministic), consistent\n // with the anthropic/openai codecs. The host mints a per-request\n // item id that the primeFold mirror cannot reproduce; keying on it\n // put the mirror in a different ref/fingerprint space, so restart\n // replay rejected every in-stream compress call (issue #64,\n // responses variant).\n const text = reasoningText(item);\n const rid =\n text.length > 0\n ? text\n : \"id\" in item && typeof item.id === \"string\"\n ? item.id\n : hashId(JSON.stringify(item));\n coreId = clusters.next(deriveMessageId(\"assistant\", \"reasoning\", rid));\n msgs.push({\n id: coreId,\n role: \"assistant\",\n contentType: \"reasoning\",\n text: rid,\n rawResponsesItem: item,\n });\n break;\n }\n case \"message\": {\n const message = item as ResponseInputMessage;\n const text = messageContent(message.content);\n if (message.role === \"system\" || message.role === \"developer\") {\n systemParts.push(text);\n idx++;\n continue;\n } else if (message.role === \"user\" || (message.role === \"assistant\" && text)) {\n const role = message.role;\n coreId = clusters.next(deriveMessageId(role, \"text\", text));\n const imageUrl = Array.isArray(message.content)\n ? message.content.find((part) => part.type === \"input_image\" && typeof part.image_url === \"string\")?.image_url\n : undefined;\n const image = typeof imageUrl === \"string\" ? parseDataUrl(imageUrl) : undefined;\n msgs.push({\n id: coreId,\n role,\n contentType: \"text\",\n text,\n rawResponsesItem: item,\n ...(image ? { imageMediaType: image.mediaType, imageBase64: image.base64 } : {}),\n });\n }\n break;\n }\n case \"function_call\": {\n const call = item as ResponseFunctionCall;\n coreId = clusters.next(deriveMessageId(\"assistant\", \"tool-call\", call.arguments ?? \"\", {\n toolCallId: call.call_id,\n toolName: call.name,\n }));\n msgs.push({\n id: coreId,\n role: \"assistant\",\n contentType: \"tool-call\",\n toolName: call.name,\n toolCallId: call.call_id,\n text: call.arguments ?? \"\",\n rawResponsesItem: item,\n });\n break;\n }\n case \"function_call_output\": {\n const output = item as ResponseFunctionCallOutput;\n const text = typeof output.output === \"string\" ? output.output : JSON.stringify(output.output);\n coreId = clusters.next(deriveMessageId(\"tool\", \"tool-result\", text, { toolCallId: output.call_id }));\n msgs.push({ id: coreId, role: \"tool\", contentType: \"tool-result\", toolCallId: output.call_id, text, rawResponsesItem: item });\n break;\n }\n case \"computer_call\":\n case \"computer_call_output\":\n case \"file_search_call\":\n case \"web_search_call\":\n case \"image_generation_call\":\n case \"code_interpreter_call\":\n case \"mcp_call\": {\n const rid =\n typeof (item as { id?: unknown }).id === \"string\"\n ? String((item as { id?: string }).id)\n : hashId(JSON.stringify(item));\n coreId = clusters.next(deriveMessageId(\"assistant\", \"responses-call\", rid));\n msgs.push({ id: coreId, role: \"assistant\", contentType: \"reasoning\", text: rid, rawResponsesItem: item });\n break;\n }\n case \"custom_tool_call\": {\n const ctc = item as { call_id?: string; name?: string; input?: string; arguments?: string };\n const callId = ctc.call_id ?? `call_${idx}`;\n customToolCallIds.add(callId);\n const argText = ctc.input ?? ctc.arguments ?? \"\";\n coreId = clusters.next(deriveMessageId(\"assistant\", \"tool-call\", argText, { toolCallId: callId, toolName: ctc.name ?? \"custom\" }));\n msgs.push({ id: coreId, role: \"assistant\", contentType: \"tool-call\", toolName: ctc.name ?? \"custom\", toolCallId: callId, text: argText, rawResponsesItem: item });\n break;\n }\n case \"custom_tool_call_output\": {\n const ctco = item as { call_id?: string; output?: string };\n const callId = ctco.call_id ?? `call_${idx}`;\n customToolCallIds.add(callId);\n const outText = typeof ctco.output === \"string\" ? ctco.output : JSON.stringify(ctco.output ?? \"\");\n coreId = clusters.next(deriveMessageId(\"tool\", \"tool-result\", outText, { toolCallId: callId }));\n msgs.push({ id: coreId, role: \"tool\", contentType: \"tool-result\", toolCallId: callId, text: outText, rawResponsesItem: item });\n break;\n }\n default:\n if (!isOpaqueItem(item)) preamble.push(item);\n break;\n }\n layout.push({ original: item, coreId });\n idx++;\n }\n return { msgs, systemParts, preamble, customToolCallIds, layout, droppedReasoning };\n}\n\nfunction patchTextParts(parts: ResponseContentPart[], text: string): ResponseContentPart[] {\n const textIndexes = parts.flatMap((part, index) =>\n part.type === \"input_text\" || part.type === \"output_text\" ? [index] : [],\n );\n if (textIndexes.length === 0) return [{ type: \"input_text\", text }, ...parts];\n const first = textIndexes[0];\n const remaining = new Set(textIndexes.slice(1));\n return parts.map((part, index) => {\n if (index === first) return { ...part, text };\n if (remaining.has(index)) return { ...part, text: \"\" };\n return part;\n });\n}\n\nfunction patchOriginalItem(original: ResponseInputItem, source: CoreMessage, next: CoreMessage): ResponseInputItem {\n if (\n source.text === next.text &&\n source.toolName === next.toolName &&\n source.toolCallId === next.toolCallId &&\n source.role === next.role &&\n source.contentType === next.contentType\n ) return original;\n if (original.type === \"message\") {\n const message = original as ResponseInputMessage;\n const content = typeof message.content === \"string\" ? next.text ?? \"\" : patchTextParts(message.content, next.text ?? \"\");\n return { ...message, content };\n }\n if (original.type === \"function_call\") {\n return {\n ...original,\n name: next.toolName ?? String(original.name ?? \"unknown\"),\n call_id: next.toolCallId ?? String(original.call_id ?? \"\"),\n arguments: next.text ?? \"\",\n };\n }\n if (original.type === \"function_call_output\") {\n return { ...original, call_id: next.toolCallId ?? String(original.call_id ?? \"\"), output: next.text ?? \"\" };\n }\n return original;\n}\n\nexport function patchResponsesInput(projection: ResponsesProjection, messages: CoreMessage[]): string | ResponseInputItem[] {\n if (projection.stringInput) {\n const original = projection.msgs.find((message) => message.id === projection.stringInput?.coreId);\n const next = messages.find((message) => message.id === projection.stringInput?.coreId);\n if (original && next && messages.length === 1 && next.role === \"user\" && next.contentType === \"text\") {\n return next.text === original.text ? projection.stringInput.original : next.text ?? \"\";\n }\n return coreToResponses(messages, projection.customToolCallIds);\n }\n const sourceById = new Map(projection.msgs.map((message) => [message.id, message]));\n const nextById = new Map(messages.map((message) => [message.id, message]));\n const slotById = new Map<string, number>();\n projection.layout.forEach((slot, index) => {\n if (slot.coreId) slotById.set(slot.coreId, index);\n });\n const insertions = new Map<number, ResponseInputItem[]>();\n for (let index = 0; index < messages.length; index++) {\n const message = messages[index]!;\n if (sourceById.has(message.id)) continue;\n let target = projection.layout.length;\n for (let nextIndex = index + 1; nextIndex < messages.length; nextIndex++) {\n const slot = slotById.get(messages[nextIndex]!.id);\n if (slot !== undefined) {\n target = slot;\n break;\n }\n }\n const generated = coreToResponses([message], projection.customToolCallIds);\n if (generated.length > 0) insertions.set(target, [...(insertions.get(target) ?? []), ...generated]);\n }\n const out: ResponseInputItem[] = [];\n projection.layout.forEach((slot, index) => {\n out.push(...(insertions.get(index) ?? []));\n if (!slot.coreId) {\n out.push(slot.original);\n return;\n }\n const source = sourceById.get(slot.coreId);\n const next = nextById.get(slot.coreId);\n if (source && next) out.push(patchOriginalItem(slot.original, source, next));\n });\n out.push(...(insertions.get(projection.layout.length) ?? []));\n return out;\n}\n\nexport function coreToResponses(\n messages: CoreMessage[],\n customToolCallIds: Set<string> = new Set(),\n): ResponseInputItem[] {\n const out: ResponseInputItem[] = [];\n for (const message of messages) {\n const biliMessage = message as BiliMessage;\n const raw = biliMessage.rawResponsesItem as ResponseInputItem | undefined;\n if (message.role === \"system\") {\n out.push({ type: \"message\", role: \"developer\", content: message.text ?? \"\" });\n } else if (message.role === \"user\") {\n if (raw?.type === \"message\" && messageContent((raw as ResponseInputMessage).content) === (message.text ?? \"\")) out.push(raw);\n else out.push({ type: \"message\", role: \"user\", content: message.text ?? \"\" });\n } else if (message.role === \"assistant\") {\n if (message.contentType === \"text\") {\n out.push({ type: \"message\", role: \"assistant\", content: message.text ?? \"\" });\n } else if (message.contentType === \"tool-call\") {\n const callId = message.toolCallId ?? `call_${message.id}`;\n if (customToolCallIds.has(callId)) {\n out.push({ type: \"custom_tool_call\", call_id: callId, name: message.toolName ?? \"unknown\", input: message.text ?? \"\", status: \"completed\" } as ResponseInputItem);\n } else {\n out.push({ type: \"function_call\", call_id: callId, name: message.toolName ?? \"unknown\", arguments: message.text ?? \"\" });\n }\n } else if (message.contentType === \"reasoning\") {\n if (raw) out.push(raw);\n }\n } else if (message.role === \"tool\") {\n const callId = message.toolCallId ?? \"\";\n if (customToolCallIds.has(callId)) {\n out.push({ type: \"custom_tool_call_output\", call_id: callId, output: message.text ?? \"\" } as ResponseInputItem);\n } else {\n out.push({ type: \"function_call_output\", call_id: callId, output: message.text ?? \"\" });\n }\n }\n }\n return out;\n}\n\nexport function injectResponsesDeveloperMessage(\n input: string | ResponseInputItem[],\n content: string,\n): ResponseInputItem[] {\n const items: ResponseInputItem[] = typeof input === \"string\"\n ? [{ type: \"message\", role: \"user\", content: input }]\n : [...input];\n let index = 0;\n while (items[index]?.type === \"additional_tools\") index++;\n items.splice(index, 0, { type: \"message\", role: \"developer\", content });\n return items;\n}\n\nexport function conversationIdentityResponses(\n body: ResponsesRequestBody,\n headerValue?: string,\n): ConversationIdentity {\n if (headerValue?.trim()) return { value: headerValue.trim(), source: \"header\", clientProvided: true };\n if (typeof body.session_id === \"string\" && body.session_id.trim()) {\n return { value: body.session_id.trim(), source: \"body-session\", clientProvided: true };\n }\n const metadataSession = body.metadata?.session_id;\n if (typeof metadataSession === \"string\" && metadataSession.trim()) {\n return { value: metadataSession.trim(), source: \"metadata-session\", clientProvided: true };\n }\n if (typeof body.previous_response_id === \"string\" && body.previous_response_id.trim()) {\n return { value: body.previous_response_id.trim(), source: \"previous-response\", clientProvided: false };\n }\n return { value: hashId(JSON.stringify(body.input ?? [])), source: \"content-fingerprint\", clientProvided: false };\n}\n\nexport function conversationSignalResponses(body: ResponsesRequestBody, headerValue?: string): string {\n return conversationIdentityResponses(body, headerValue).value;\n}\n\n// Codex subagents (guardian approval reviewer, etc.) reuse the main\n// conversation's body.session_id, so identity alone collapses their requests\n// onto the main session's compression state — a compressed subagent request\n// loses the verbatim user authorization it must read back (#150). Subagent\n// requests carry their own `instructions` (the agent's role prompt), so the\n// FIRST instructions seen for an identity anchor the main namespace (it never\n// changes for the conversation, even if the main prompt drifts), and any other\n// instructions value maps to a separate `|sub:` namespace with its own empty\n// compression state. Subagent requests are self-contained replays, so the\n// fresh namespace is lossless.\nexport interface SubagentNamespaces {\n /** Resolve the compression-state namespace for a request: the identity\n * itself for the anchored (main) instructions, `identity|sub:<fp>` for\n * any other instructions value. First-seen instructions anchor. */\n namespaceFor(identityValue: string, instructions: unknown): string;\n}\n\n/** Host-owned subagent-namespace store.\n *\n * The anchor map is per-conversation mutable state, so it belongs to the\n * host — NOT to a library module global. Create one instance and keep it for\n * the process lifetime (or persist it alongside your session store if you\n * need namespaces to survive restarts: a fresh instance re-anchors on the\n * first request it sees, which after a restart may be a subagent request,\n * orphaning the main conversation's stored compression state). */\nexport function createSubagentNamespaces(): SubagentNamespaces {\n const anchors = new Map<string, string>();\n return {\n namespaceFor(identityValue: string, instructions: unknown): string {\n if (typeof instructions !== \"string\" || instructions.trim().length === 0) return identityValue;\n const fp = hashId(instructions);\n const anchor = anchors.get(identityValue);\n if (anchor === undefined) {\n anchors.set(identityValue, fp);\n return identityValue;\n }\n return anchor === fp ? identityValue : `${identityValue}|sub:${fp}`;\n },\n };\n}\n\n// Convenience singleton for single-process proxies that don't manage\n// per-session state themselves. Hosts needing isolation between\n// conversations, deterministic namespaces across restarts, or a bound on\n// anchor memory should create their own instance via\n// createSubagentNamespaces() and own its lifecycle.\nconst defaultNamespaces = createSubagentNamespaces();\n\nexport function subagentNamespace(identityValue: string, instructions: unknown): string {\n return defaultNamespaces.namespaceFor(identityValue, instructions);\n}\n","export const WIRE_FORMATS = [\"anthropic\", \"openai\", \"responses\"] as const;\nexport type WireFormat = (typeof WIRE_FORMATS)[number];\n\nexport function isWireFormat(value: unknown): value is WireFormat {\n return (\n typeof value === \"string\" &&\n (WIRE_FORMATS as readonly string[]).includes(value)\n );\n}\n\n/**\n * Classify a provider request body by the codec that can parse it.\n * Returns undefined when no codec handles the body — the caller must\n * pass such payloads through untransformed.\n */\nexport function detectWireFormat(payload: unknown): WireFormat | undefined {\n if (payload === null || typeof payload !== \"object\") return undefined;\n const p = payload as Record<string, unknown>;\n if (Array.isArray(p.input)) return \"responses\";\n const messages = p.messages;\n if (!Array.isArray(messages)) return undefined;\n if (\"system\" in p || \"anthropic_version\" in p) return \"anthropic\";\n for (const m of messages as Array<Record<string, unknown>>) {\n if (m === null || typeof m !== \"object\") continue;\n const c = m.content;\n if (Array.isArray(c)) {\n for (const b of c as Array<Record<string, unknown>>) {\n if (b && typeof b === \"object\" && typeof b.type === \"string\") {\n if (\n b.type === \"tool_use\" ||\n b.type === \"tool_result\" ||\n b.type === \"thinking\"\n )\n return \"anthropic\";\n if (b.type === \"text\" && \"cache_control\" in b) return \"anthropic\";\n }\n }\n }\n if (Array.isArray(m.tool_calls)) return \"openai\";\n if (m.role === \"tool\" && typeof m.tool_call_id === \"string\")\n return \"openai\";\n if (m.role === \"system\" || m.role === \"developer\") return \"openai\";\n }\n // Both chat formats share role+messages; default to openai — the safer\n // guess for OpenAI-compatible endpoints (GLM, DeepSeek, vLLM).\n return \"openai\";\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAKpB,SAAS,OAAO,GAAmB;AACtC,SAAO,WAA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AE,MAAM,CAAA;KAAE,CAAC;IACnD;;4DAEwD;IACxD,gBAAgB,EAAE,MAAM,CAAC;CAC5B,CAAC;AA0DF,wBAAgB,eAAe,CAAC,IAAI,EAAE,oBAAoB,GAAG,mBAAmB,CAyI/E;AA2CD,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,mBAAmB,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,MAAM,GAAG,iBAAiB,EAAE,CA2C1H;AAED,wBAAgB,eAAe,CAC3B,QAAQ,EAAE,WAAW,EAAE,EACvB,iBAAiB,GAAE,GAAG,CAAC,MAAM,CAAa,GAC3C,iBAAiB,EAAE,CAiCrB;AAED,wBAAgB,+BAA+B,CAC3C,KAAK,EAAE,MAAM,GAAG,iBAAiB,EAAE,EACnC,OAAO,EAAE,MAAM,GAChB,iBAAiB,EAAE,CAQrB;AAED,wBAAgB,6BAA6B,CACzC,IAAI,EAAE,oBAAoB,EAC1B,WAAW,CAAC,EAAE,MAAM,GACrB,oBAAoB,CAatB;AAED,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,oBAAoB,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAEpG;AAYD,MAAM,WAAW,kBAAkB;IAC/B;;wEAEoE;IACpE,YAAY,CAAC,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,GAAG,MAAM,CAAC;CACtE;AAED;;;;;;;kEAOkE;AAClE,wBAAgB,wBAAwB,IAAI,kBAAkB,CAc7D;AASD,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,GAAG,MAAM,CAEtF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "acp-kernel",
3
- "version": "0.0.32",
3
+ "version": "0.0.33",
4
4
  "description": "Framework-agnostic context-compression engine (model-driven, 3-tier LSM). Pure core: no host dependency.",
5
5
  "license": "MIT",
6
6
  "author": "ranxianglei",