acp-kernel 0.0.58 → 0.0.59-pr.222.74

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.
@@ -5,6 +5,8 @@ export interface CompressParseDiagnostics {
5
5
  ok: boolean;
6
6
  /** Why the input parsed the way it did. */
7
7
  kind: CompressParseKind;
8
+ /** True when the winning parse came from single→double quote repair. */
9
+ quoteSalvage?: boolean;
8
10
  /** First 800 chars of the raw string input (string inputs only). */
9
11
  rawPrefix?: string;
10
12
  /** Raw string input length (string inputs only). */
@@ -1 +1 @@
1
- {"version":3,"file":"parse-compress-input.d.ts","sourceRoot":"","sources":["../src/parse-compress-input.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,MAAM,MAAM,iBAAiB,GACvB,IAAI,GACJ,aAAa,GACb,YAAY,GACZ,iBAAiB,GACjB,mBAAmB,GACnB,gBAAgB,GAChB,WAAW,GACX,iBAAiB,CAAC;AAExB,MAAM,WAAW,wBAAwB;IACrC,uDAAuD;IACvD,EAAE,EAAE,OAAO,CAAC;IACZ,2CAA2C;IAC3C,IAAI,EAAE,iBAAiB,CAAC;IACxB,oEAAoE;IACpE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oDAAoD;IACpD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iFAAiF;IACjF,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,0DAA0D;IAC1D,YAAY,EAAE,MAAM,CAAC;IACrB,oEAAoE;IACpE,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,mBAAmB;IAChC,MAAM,EAAE,iBAAiB,EAAE,CAAC;IAC5B,WAAW,EAAE,wBAAwB,CAAC;CACzC;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,mBAAmB,CAmBjG"}
1
+ {"version":3,"file":"parse-compress-input.d.ts","sourceRoot":"","sources":["../src/parse-compress-input.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,MAAM,MAAM,iBAAiB,GACvB,IAAI,GACJ,aAAa,GACb,YAAY,GACZ,iBAAiB,GACjB,mBAAmB,GACnB,gBAAgB,GAChB,WAAW,GACX,iBAAiB,CAAC;AAExB,MAAM,WAAW,wBAAwB;IACrC,uDAAuD;IACvD,EAAE,EAAE,OAAO,CAAC;IACZ,2CAA2C;IAC3C,IAAI,EAAE,iBAAiB,CAAC;IACxB,wEAAwE;IACxE,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,oEAAoE;IACpE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oDAAoD;IACpD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iFAAiF;IACjF,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,0DAA0D;IAC1D,YAAY,EAAE,MAAM,CAAC;IACrB,oEAAoE;IACpE,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,mBAAmB;IAChC,MAAM,EAAE,iBAAiB,EAAE,CAAC;IAC5B,WAAW,EAAE,wBAAwB,CAAC;CACzC;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,mBAAmB,CAmBjG"}
@@ -1 +1 @@
1
- {"version":3,"file":"recommend.d.ts","sourceRoot":"","sources":["../src/recommend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,MAAM,EACN,aAAa,EACb,WAAW,EAEZ,MAAM,YAAY,CAAC;AACpB,OAAO,KAA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;AAID;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,WAAW,EAAE,EACvB,KAAK,EAAE,gBAAgB,EACvB,MAAM,EAAE,MAAM,EACd,iBAAiB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,EAC/B,WAAW,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAA2B,GACzD,aAAa,CA2If;AAiCD;;;;;;;8DAO8D;AAC9D,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,iBAAiB,EAAE,EAC3B,QAAQ,EAAE,MAAM,GACf,iBAAiB,EAAE,CAkBrB"}
@@ -1 +1 @@
1
- {"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAoB,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAsGlF,MAAM,WAAW,mBAAmB;IAChC,KAAK,CAAC,EAAE,YAAY,GAAG,cAAc,CAAC;IACtC,IAAI,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,iBAAiB,CAC7B,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,WAAW,EAAE,EACvB,WAAW,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,EAClC,OAAO,GAAE,mBAAwB,GAClC,MAAM,CAyBR;AA0MD,wBAAgB,UAAU,CACtB,KAAK,EAAE,gBAAgB,EACvB,OAAO,CAAC,EAAE,MAAM,GACjB,MAAM,CA6BR"}
1
+ {"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAoB,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AA2G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BAIyB;AACzB,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,oBAAoB,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAKpG"}
@@ -35,6 +35,7 @@ function anthropicToCore(body) {
35
35
  const msgs = [];
36
36
  const cacheControls = /* @__PURE__ */ new Map();
37
37
  const clusters = new ClusterCounter();
38
+ const toolNames = /* @__PURE__ */ new Map();
38
39
  for (const m of body.messages) {
39
40
  const blocks = typeof m.content === "string" ? [{ type: "text", text: m.content }] : m.content;
40
41
  for (const b of blocks) {
@@ -60,6 +61,7 @@ function anthropicToCore(body) {
60
61
  toolCallId: b.id,
61
62
  text: safeStringify(b.input)
62
63
  });
64
+ toolNames.set(b.id, b.name);
63
65
  if (b.cache_control) cacheControls.set(id, b.cache_control);
64
66
  break;
65
67
  }
@@ -67,12 +69,14 @@ function anthropicToCore(body) {
67
69
  const text = typeof b.content === "string" ? b.content : b.content.map((c) => c.text).join("\n");
68
70
  const base = deriveMessageId("tool", "tool-result", text, { toolCallId: b.tool_use_id });
69
71
  const id = clusters.next(base);
72
+ const name = toolNames.get(b.tool_use_id);
70
73
  msgs.push({
71
74
  id,
72
75
  role: "tool",
73
76
  contentType: "tool-result",
74
77
  toolCallId: b.tool_use_id,
75
78
  text,
79
+ ...name ? { toolName: name } : {},
76
80
  ...b.is_error === true ? { toolIsError: true } : {}
77
81
  });
78
82
  if (b.cache_control) cacheControls.set(id, b.cache_control);
@@ -229,6 +233,7 @@ function openaiToCore(body) {
229
233
  const msgs = [];
230
234
  const systemParts = [];
231
235
  const clusters = new ClusterCounter();
236
+ const toolNames = /* @__PURE__ */ new Map();
232
237
  for (const m of body.messages) {
233
238
  switch (m.role) {
234
239
  case "system":
@@ -296,6 +301,7 @@ function openaiToCore(body) {
296
301
  toolCallId: tc.id,
297
302
  text: tc.function.arguments ?? ""
298
303
  });
304
+ toolNames.set(tc.id, tc.function.name);
299
305
  }
300
306
  }
301
307
  break;
@@ -304,12 +310,14 @@ function openaiToCore(body) {
304
310
  const base = deriveMessageId("tool", "tool-result", stringContent(m.content), {
305
311
  toolCallId: m.tool_call_id ?? ""
306
312
  });
313
+ const name = m.name || toolNames.get(m.tool_call_id ?? "");
307
314
  msgs.push({
308
315
  id: clusters.next(base),
309
316
  role: "tool",
310
317
  contentType: "tool-result",
311
318
  toolCallId: m.tool_call_id ?? "",
312
- text: stringContent(m.content)
319
+ text: stringContent(m.content),
320
+ ...name ? { toolName: name } : {}
313
321
  });
314
322
  break;
315
323
  }
@@ -414,7 +422,7 @@ function allImageParts(content) {
414
422
  if (typeof p !== "object" || p === null) continue;
415
423
  if (!("type" in p) || p.type !== "image_url" || !("image_url" in p)) continue;
416
424
  const imagePart = p;
417
- const url = imagePart.image_url.url;
425
+ const url = imagePart.image_url?.url;
418
426
  if (typeof url === "string" && parseDataUrl(url)) out.push(p);
419
427
  }
420
428
  return out;
@@ -428,6 +436,14 @@ var OPAQUE_ITEM_TYPES = /* @__PURE__ */ new Set([
428
436
  function isOpaqueItem(item) {
429
437
  return OPAQUE_ITEM_TYPES.has(item.type);
430
438
  }
439
+ var EASY_INPUT_ROLES = /* @__PURE__ */ new Set(["user", "assistant", "system", "developer"]);
440
+ function normalizeEasyInputItem(item) {
441
+ if (typeof item.type === "string") return item;
442
+ if (EASY_INPUT_ROLES.has(String(item.role))) {
443
+ return { ...item, type: "message" };
444
+ }
445
+ return item;
446
+ }
431
447
  function shouldDropAllReasoning() {
432
448
  return (process.env.ACP_REASONING_KEEP ?? "").trim().toLowerCase() === "none";
433
449
  }
@@ -464,6 +480,7 @@ function responsesToCore(body) {
464
480
  const layout = [];
465
481
  let droppedReasoning = 0;
466
482
  const clusters = new ClusterCounter();
483
+ const toolNames = /* @__PURE__ */ new Map();
467
484
  let idx = 0;
468
485
  if (typeof body.instructions === "string" && body.instructions.trim()) systemParts.push(body.instructions);
469
486
  if (typeof body.input === "string") {
@@ -471,7 +488,8 @@ function responsesToCore(body) {
471
488
  msgs.push({ id, role: "user", contentType: "text", text: body.input });
472
489
  return { msgs, systemParts, preamble, customToolCallIds, layout, droppedReasoning, stringInput: { original: body.input, coreId: id } };
473
490
  }
474
- for (const item of body.input) {
491
+ for (const raw of body.input) {
492
+ const item = normalizeEasyInputItem(raw);
475
493
  let coreId;
476
494
  if (isOpaqueItem(item)) preamble.push(item);
477
495
  switch (item.type) {
@@ -546,13 +564,15 @@ function responsesToCore(body) {
546
564
  text: call.arguments ?? "",
547
565
  rawResponsesItem: item
548
566
  });
567
+ toolNames.set(call.call_id, call.name);
549
568
  break;
550
569
  }
551
570
  case "function_call_output": {
552
571
  const output = item;
553
572
  const text = typeof output.output === "string" ? output.output : JSON.stringify(output.output);
554
573
  coreId = clusters.next(deriveMessageId("tool", "tool-result", text, { toolCallId: output.call_id }));
555
- msgs.push({ id: coreId, role: "tool", contentType: "tool-result", toolCallId: output.call_id, text, rawResponsesItem: item });
574
+ const name = toolNames.get(output.call_id);
575
+ msgs.push({ id: coreId, role: "tool", contentType: "tool-result", toolCallId: output.call_id, text, ...name ? { toolName: name } : {}, rawResponsesItem: item });
556
576
  break;
557
577
  }
558
578
  case "computer_call":
@@ -574,6 +594,7 @@ function responsesToCore(body) {
574
594
  const argText = ctc.input ?? ctc.arguments ?? "";
575
595
  coreId = clusters.next(deriveMessageId("assistant", "tool-call", argText, { toolCallId: callId, toolName: ctc.name ?? "custom" }));
576
596
  msgs.push({ id: coreId, role: "assistant", contentType: "tool-call", toolName: ctc.name ?? "custom", toolCallId: callId, text: argText, rawResponsesItem: item });
597
+ toolNames.set(callId, ctc.name ?? "custom");
577
598
  break;
578
599
  }
579
600
  case "custom_tool_call_output": {
@@ -582,7 +603,8 @@ function responsesToCore(body) {
582
603
  customToolCallIds.add(callId);
583
604
  const outText = typeof ctco.output === "string" ? ctco.output : JSON.stringify(ctco.output ?? "");
584
605
  coreId = clusters.next(deriveMessageId("tool", "tool-result", outText, { toolCallId: callId }));
585
- msgs.push({ id: coreId, role: "tool", contentType: "tool-result", toolCallId: callId, text: outText, rawResponsesItem: item });
606
+ const name = toolNames.get(callId);
607
+ msgs.push({ id: coreId, role: "tool", contentType: "tool-result", toolCallId: callId, text: outText, ...name ? { toolName: name } : {}, rawResponsesItem: item });
586
608
  break;
587
609
  }
588
610
  default: