@xiaoso/dsh-tool-plus 0.1.6 → 0.1.7-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/THIRD_PARTY_NOTICES.md +9 -3
  2. package/lib/{abort-Cwwm4Err.mjs → abort-Caqff3M6.mjs} +2 -2
  3. package/lib/alibaba-coding-plan-DTupMiAi.mjs +73 -0
  4. package/lib/alibaba-token-plan-CHGyWOfX.mjs +46 -0
  5. package/lib/alibaba-token-plan-Dj3OZhEE.mjs +82 -0
  6. package/lib/{amazon-bedrock-TVMpUTRG.mjs → amazon-bedrock-DbFSYXfJ.mjs} +117 -38
  7. package/lib/{anthropic-BL6LFDQS.mjs → anthropic-CTJ3IQVa.mjs} +675 -166
  8. package/lib/anthropic-CXfWlp-x.mjs +105 -0
  9. package/lib/{aws-credentials-B20dliS7.mjs → anthropic-wire-CKuhDwZ1.mjs} +74 -14
  10. package/lib/{api-key-login-CIDnXeYd.mjs → api-key-validation-CGCJFbFr.mjs} +27 -68
  11. package/lib/{azure-openai-responses-BkhsLmN3.mjs → azure-openai-responses-ChFbWaGj.mjs} +27 -16
  12. package/lib/{browser-render-CmgvSNte.mjs → browser-render-9o0Rknop.mjs} +4 -4
  13. package/lib/bun-shim.mjs +71 -2
  14. package/lib/{bundled-references-ChZSPDFw.mjs → bundled-references-DY3EJxZV.mjs} +6 -5
  15. package/lib/cline-pass-Bwg3esu9.mjs +44 -0
  16. package/lib/cloudflare-ai-gateway-BupNXyKK.mjs +35 -0
  17. package/lib/cloudflare-ai-gateway-EWo0VkP5.mjs +44 -0
  18. package/lib/collapse-DOR8sOGf.mjs +2304 -0
  19. package/lib/coreweave-C82HrLpb.mjs +31 -0
  20. package/lib/coreweave-Ct8cF-da.mjs +14 -0
  21. package/lib/{cursor-B6HcmplF.mjs → cursor-B95LzVWV.mjs} +11 -3
  22. package/lib/{cursor-CRpLpaZ3.mjs → cursor-DJV_dcgB.mjs} +887 -1784
  23. package/lib/{cursor-B8m6SqAH.mjs → cursor-LKGjucn2.mjs} +48 -38
  24. package/lib/cursor-proto-B8Wj8bv9.mjs +10513 -0
  25. package/lib/{deterministic-id-D-yIV_eI.mjs → deterministic-id-CUEIMSqR.mjs} +1 -1
  26. package/lib/devin-BMTdx_hx.mjs +316 -0
  27. package/lib/{devin-DUAfvBsW.mjs → devin-DSp0Rw_E.mjs} +172 -86
  28. package/lib/devin-ExGIghmx.mjs +69 -0
  29. package/lib/devin-proto-Br8fdyNl.mjs +2888 -0
  30. package/lib/{dom-CawWi8fa.mjs → dom-DG3sPESc.mjs} +8 -8
  31. package/lib/effort-BdtQMN-_.mjs +23 -0
  32. package/lib/{error-C-f_Wnw4.mjs → error-CORgGg5a.mjs} +275 -154
  33. package/lib/{event-stream-Dh2guZxS.mjs → event-stream-ulcDenZD.mjs} +20 -4
  34. package/lib/{gemini-headers-DKUShltF.mjs → gemini-headers-Co9cVvex.mjs} +2 -2
  35. package/lib/{github-copilot-suDymKrx.mjs → github-copilot-Dstq1D3s.mjs} +69 -29
  36. package/lib/github-copilot-headers-DOh1gt_w.mjs +312 -0
  37. package/lib/gitlab-duo-DSCMrU0m.mjs +11 -0
  38. package/lib/google-CtsKkOQK.mjs +38 -0
  39. package/lib/google-antigravity-z-5KsEci.mjs +252 -0
  40. package/lib/{google-auth-DYJLM792.mjs → google-auth-ieLBaneO.mjs} +4 -4
  41. package/lib/{google-gemini-cli-8BT513Ul.mjs → google-gemini-cli-C6NE5mWz.mjs} +28 -54
  42. package/lib/{google-gemini-cli-D6cSmfvB.mjs → google-gemini-cli-CAIPSl7e.mjs} +23 -29
  43. package/lib/google-oauth-shared-DhMllAkt.mjs +53 -0
  44. package/lib/{google-shared-CVbHK5vZ.mjs → google-shared-B0aNCYEH.mjs} +140 -44
  45. package/lib/{google-validation-Cgbn3tWJ.mjs → google-validation-BEkNs-Bx.mjs} +1 -1
  46. package/lib/{google-vertex-Bui-ypAe.mjs → google-vertex-Bbd1tYNc.mjs} +8 -8
  47. package/lib/hosts-00rjRzUD.mjs +203 -0
  48. package/lib/id-AL5obQzR.mjs +71 -0
  49. package/lib/{idle-iterator-CYAxUkSD.mjs → idle-iterator-DlUkEfzW.mjs} +3 -3
  50. package/lib/index.mjs +587 -5266
  51. package/lib/kilo-ChJL54wq.mjs +81 -0
  52. package/lib/kimi-C2c_Zq8A.mjs +67 -0
  53. package/lib/{launch-BmgEUycu.mjs → launch-DKDH71En.mjs} +1 -1
  54. package/lib/markit-CmRfm4E2.mjs +9885 -0
  55. package/lib/models-DnXMYGcJ.mjs +381604 -0
  56. package/lib/muse-code-Di1VZmB1.mjs +143 -0
  57. package/lib/{ollama-Df9ce-Cp.mjs → ollama-B8ic3sEp.mjs} +15 -30
  58. package/lib/{openai-codex-CAVI3Me-.mjs → openai-codex-DuJNC99x.mjs} +29 -99
  59. package/lib/{openai-codex-responses-BcnOotRB.mjs → openai-codex-responses-BL29nh9K.mjs} +204 -116
  60. package/lib/{openai-completions-Bq4WT47M.mjs → openai-completions-BK2f2dBv.mjs} +152 -82
  61. package/lib/openai-configuration-update-xMYUjaK_.mjs +150 -0
  62. package/lib/{openai-reasoning-fallback-DXsfiSXO.mjs → openai-reasoning-fallback-BdB3RCbj.mjs} +106 -12
  63. package/lib/{openai-responses-Mq_-PjvE.mjs → openai-responses-CGQPlIIy.mjs} +76 -82
  64. package/lib/{perplexity-XgLF73E7.mjs → perplexity-TBjz3VMB.mjs} +52 -9
  65. package/lib/{pkce-BlQikGPu.mjs → pkce-BYjmugmw.mjs} +1 -1
  66. package/lib/protobuf-aab1UGVn.mjs +717 -0
  67. package/lib/{provider-response-C6vcbQyO.mjs → provider-response-SqKSkkUc.mjs} +1 -1
  68. package/lib/{proxy-D9lm7ONA.mjs → proxy-5nWqRL1f.mjs} +45 -5
  69. package/lib/{readability-Cpm-ocau.mjs → readability-uGhqb4GC.mjs} +2 -2
  70. package/lib/reference-CtvM4zLU.mjs +114 -0
  71. package/lib/{request-debug-HJMoJncL.mjs → request-debug-NQN0BjHH.mjs} +1 -1
  72. package/lib/{sanitize-text-CfcXzw5X.mjs → sanitize-text-BCf5KmCf.mjs} +1 -1
  73. package/lib/{scrapers-Cg5w77td.mjs → scrapers-D8oWspgW.mjs} +12 -12
  74. package/lib/{src-BcD0_rQR.mjs → src-BwW51vA5.mjs} +979 -388
  75. package/lib/{sse-debug-CYdjOC96.mjs → sse-debug-B-tkLCPW.mjs} +1 -1
  76. package/lib/{stream-Bjq8wjfr.mjs → stream-B_7qN-bA.mjs} +3802 -2623
  77. package/lib/stream-markup-healing-DKT1lnkW.mjs +267 -0
  78. package/lib/{strict-tool-validation-imVLUcbI.mjs → strict-tool-validation-CBTz1dAA.mjs} +2 -2
  79. package/lib/taxonomy-DSIM99rS.mjs +15392 -0
  80. package/lib/{stream-markup-healing-DZ6bVDxH.mjs → thinking-CiLa2LFB.mjs} +31 -186
  81. package/lib/{turndown-DN7ByzEI.mjs → turndown-DrX1M4WG.mjs} +4 -4
  82. package/lib/{type-guards-B9VVjRDK.mjs → type-guards-CttAANEx.mjs} +1 -1
  83. package/lib/{types-DX_bvuus.mjs → types-PVueGi9S.mjs} +2 -2
  84. package/lib/{utils-C-dSORPa.mjs → utils-CCfhUQen.mjs} +2364 -2676
  85. package/lib/{utils-Cp2Mxf_U.mjs → utils-CUPhpw9A.mjs} +413 -134
  86. package/lib/{utils-CQHPEQ3W.mjs → utils-DeWqNWV8.mjs} +2 -2
  87. package/lib/{vision-guard-mBmtAHx0.mjs → vision-guard-_XwsL1DF.mjs} +14 -29
  88. package/lib/xai-oauth-CXhnz0gO.mjs +210 -0
  89. package/lib/{xiaomi-7mE345KX.mjs → xiaomi-psoUItal.mjs} +8 -37
  90. package/lib/{zai-CeNpMV3W.mjs → zai-ApJ8HBgT.mjs} +8 -71
  91. package/lib/{zip-BK7UHCwX.mjs → zip-Kd602XNe.mjs} +1 -1
  92. package/package.json +11 -11
  93. package/presets/package.json +1 -1
  94. package/presets/tool-plus-ptc/agent.cordis.yml +1 -1
  95. package/presets/tool-plus-standard/agent.cordis.yml +1 -1
  96. package/lib/agent_pb-Rizyt9Zg.mjs +0 -805
  97. package/lib/anthropic-CDmj476p.mjs +0 -262
  98. package/lib/api_server_pb-CDZgLMta.mjs +0 -252
  99. package/lib/callback-server-CFJK-jvK.mjs +0 -398
  100. package/lib/codex-P1dGpX7G.mjs +0 -54
  101. package/lib/device-code-CuXTWYwY.mjs +0 -51
  102. package/lib/devin-BcQwht1W.mjs +0 -114
  103. package/lib/devin-BvMfGevz.mjs +0 -95
  104. package/lib/github-copilot-B3kQl0g0.mjs +0 -104
  105. package/lib/gitlab-duo-BriUTP8k.mjs +0 -155
  106. package/lib/gitlab-duo-workflow-wK5Ljzmc.mjs +0 -91
  107. package/lib/google-CE5tFDod.mjs +0 -30
  108. package/lib/google-antigravity-C1jgNljz.mjs +0 -198
  109. package/lib/google-oauth-shared-BLVTvokk.mjs +0 -147
  110. package/lib/grammar-D-NqNUxQ.mjs +0 -49
  111. package/lib/identity-HNO1Oe9B.mjs +0 -219
  112. package/lib/kimi-DgcUpPtK.mjs +0 -236
  113. package/lib/markit-DtGoRE6M.mjs +0 -1417
  114. package/lib/minimax-code-Y3h5li9N.mjs +0 -53
  115. package/lib/models-DRA2c_8U.mjs +0 -104660
  116. package/lib/opencode-BsVw9rCD.mjs +0 -38
  117. package/lib/to-binary-B1BEBIPC.mjs +0 -6002
  118. package/lib/wafer-BlhWLweO.mjs +0 -17
  119. package/lib/xai-oauth-5pORHUrg.mjs +0 -446
@@ -1,9 +1,11 @@
1
1
  import { installBunShim as __installBunShim } from "./bun-shim.mjs";
2
2
  __installBunShim();
3
- import { I as $flag, P as $env, S as debug, g as parseStreamingJson, h as parseJsonWithRepair } from "./src-BcD0_rQR.mjs";
4
- import { r as ValidationError } from "./error-C-f_Wnw4.mjs";
5
- import { t as preferredDialect } from "./identity-HNO1Oe9B.mjs";
6
- //#region node_modules/.pnpm/@oh-my-pi+pi-utils@17.3.5/node_modules/@oh-my-pi/pi-utils/src/json.ts
3
+ import { F as $flag, N as $env, _ as parseStreamingJson, b as debug, g as parseJsonWithRepair } from "./src-BwW51vA5.mjs";
4
+ import { r as ValidationError } from "./error-CORgGg5a.mjs";
5
+ import { n as classifyModel } from "./taxonomy-DSIM99rS.mjs";
6
+ import { i as getBundledProviders, r as getBundledModels } from "./models-DnXMYGcJ.mjs";
7
+ import { t as buildModelReferenceIndex } from "./reference-CtvM4zLU.mjs";
8
+ //#region node_modules/.pnpm/@oh-my-pi+pi-utils@18.1.17/node_modules/@oh-my-pi/pi-utils/src/json.ts
7
9
  /**
8
10
  * Try to parse JSON, returning null on failure.
9
11
  */
@@ -27,10 +29,46 @@ function stringifyJson$1(value, space) {
27
29
  return JSON.stringify(value, (_key, item) => typeof item === "bigint" ? item.toString() : item, space);
28
30
  }
29
31
  //#endregion
30
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/dialect/anthropic.md
32
+ //#region node_modules/.pnpm/@oh-my-pi+pi-catalog@18.1.17/node_modules/@oh-my-pi/pi-catalog/src/identity/bundled.ts
33
+ /**
34
+ * Memoized proxy-reference index over the bundled model catalog.
35
+ *
36
+ * Lazy: walking every bundled model (~12K) triggers thinking enrichment, so the
37
+ * walk is deferred off module load and performed once. Consumers that need
38
+ * non-bundled reference data use the pure builder directly
39
+ * ({@link buildModelReferenceIndex}).
40
+ */
41
+ let bundledModels;
42
+ function getBundledModelList() {
43
+ bundledModels ??= getBundledProviders().flatMap((provider) => getBundledModels(provider));
44
+ return bundledModels;
45
+ }
46
+ let referenceIndex;
47
+ /** Proxy-reference index over the bundled catalog. */
48
+ function getBundledModelReferenceIndex() {
49
+ referenceIndex ??= buildModelReferenceIndex(getBundledModelList());
50
+ return referenceIndex;
51
+ }
52
+ function preferredDialect(modelId) {
53
+ switch (classifyModel("", modelId, { lenient: true }).class) {
54
+ case "anthropic": return "anthropic";
55
+ case "glm": return "glm";
56
+ case "gemini": return "gemini";
57
+ case "gemma": return "gemma";
58
+ case "kimi": return "kimi";
59
+ case "qwen": return "qwen3";
60
+ case "deepseek": return "deepseek";
61
+ case "minimax": return "minimax";
62
+ case "openai":
63
+ case "gpt-oss": return "harmony";
64
+ default: return "xml";
65
+ }
66
+ }
67
+ //#endregion
68
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/dialect/anthropic.md
31
69
  var anthropic_default = "## Format guide\n\nA call is a `<function_calls>` block wrapping one or more `<invoke>` blocks, each holding `<parameter>` children:\n\n```text\n<function_calls>\n<invoke name=\"tool_name\"><parameter name=\"arg_name\">arg value</parameter></invoke>\n</function_calls>\n```\n\nResults arrive later in a `<function_results>` block, one `<result>` per call (failures use `<error>` with `<stderr>` in place of `<result>` with `<stdout>`):\n\n```text\n<function_results>\n<result>\n<tool_name>tool_name</tool_name>\n<stdout>verbatim tool result</stdout>\n</result>\n</function_results>\n```\n\n## Rules\n\n- `name` MUST match a listed function.\n- String/scalar parameters: exact text, spaces preserved — bodies are read by regex (delimiter matching), NOT a real XML parser, so never HTML-escape them (emit `a & b`, not `a &amp; b`; `<`/`>` stay literal); only the body's own `</parameter>` closing tag is reserved. Lists/objects: JSON.\n- Multiple calls: multiple `<invoke>` blocks in one `<function_calls>`.\n- You MAY write visible text before the calls.\n- NEVER emit `tool_calls` JSON.\n- NEVER use the legacy `<tool_name>`/`<parameters>` call syntax.\n- Read each `<result>`/`<error>` in call order. NEVER emit `<function_results>` yourself.\n- Emit the stop sequence ONLY after the call is fully written — NEVER announce a tool then stop (e.g. halting at \"Let's run `cargo clippy`\" with no `<invoke>` emitted). Write the complete call, THEN the stop sequence, THEN halt.\n";
32
70
  //#endregion
33
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/utils/schema/types.ts
71
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/utils/schema/types.ts
34
72
  function isJsonObject(value) {
35
73
  return !!value && typeof value === "object" && !Array.isArray(value);
36
74
  }
@@ -39,7 +77,7 @@ function isJsonObjectEmpty(value) {
39
77
  return Object.keys(value).length === 0;
40
78
  }
41
79
  //#endregion
42
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/utils/schema/equality.ts
80
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/utils/schema/equality.ts
43
81
  function areJsonValuesEqual(left, right) {
44
82
  if (Object.is(left, right)) return true;
45
83
  if (Array.isArray(left) || Array.isArray(right)) {
@@ -92,7 +130,7 @@ function mergePropertySchemas(existing, incoming) {
92
130
  return mergedAnyOf.length === 1 ? mergedAnyOf[0] : { anyOf: mergedAnyOf };
93
131
  }
94
132
  //#endregion
95
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/utils/schema/stamps.ts
133
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/utils/schema/stamps.ts
96
134
  /**
97
135
  * Symbol-keyed lazy memoization stamped directly onto the host object.
98
136
  *
@@ -198,7 +236,7 @@ function exit(target) {
198
236
  slot[kDepth] = cur - 1;
199
237
  }
200
238
  //#endregion
201
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/utils/schema/draft.ts
239
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/utils/schema/draft.ts
202
240
  const JSON_SCHEMA_DRAFT_2020_12_URI = "https://json-schema.org/draft/2020-12/schema";
203
241
  /** Draft-07 schema URIs we recognise as needing an upgrade. The trailing `#` is the canonical form in the JSON Schema spec, but providers (and Zod) emit both. */
204
242
  const DRAFT_07_SCHEMA_URIS = {
@@ -467,7 +505,7 @@ function upgradeJsonSchemaTo202012(schema) {
467
505
  return upgradeJsonSchemaTo202012Impl(schema, /* @__PURE__ */ new WeakMap());
468
506
  }
469
507
  //#endregion
470
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/utils/schema/dereference.ts
508
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/utils/schema/dereference.ts
471
509
  /**
472
510
  * Inline `$ref` / `$defs` in a JSON Schema so every consumer sees
473
511
  * the full definition without needing a resolver.
@@ -545,7 +583,7 @@ function dereferenceJsonSchema(schema) {
545
583
  return dereferenceNode(schema, schema, /* @__PURE__ */ new Set());
546
584
  }
547
585
  //#endregion
548
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/utils/schema/fields.ts
586
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/utils/schema/fields.ts
549
587
  /**
550
588
  * Field classification sets for JSON Schema sanitization across providers.
551
589
  *
@@ -586,7 +624,12 @@ const UNSUPPORTED_SCHEMA_FIELDS = {
586
624
  format: true,
587
625
  dependencies: true,
588
626
  dependentSchemas: true,
589
- dependentRequired: true
627
+ dependentRequired: true,
628
+ "x-mcp-header": true,
629
+ deprecated: true,
630
+ readOnly: true,
631
+ writeOnly: true,
632
+ $comment: true
590
633
  };
591
634
  /**
592
635
  * Human-meaningful validation/decorative keywords that can be preserved in a
@@ -729,11 +772,7 @@ const CLOUD_CODE_ASSIST_SHARED_SCHEMA_KEYS = {
729
772
  title: true,
730
773
  description: true,
731
774
  default: true,
732
- examples: true,
733
- deprecated: true,
734
- readOnly: true,
735
- writeOnly: true,
736
- $comment: true
775
+ examples: true
737
776
  };
738
777
  /**
739
778
  * Combinator keys used across schema sanitization modules.
@@ -756,10 +795,14 @@ const CCA_UNSUPPORTED_SCHEMA_FIELDS = {
756
795
  $defs: true,
757
796
  $dynamicRef: true,
758
797
  $dynamicAnchor: true,
759
- propertyNames: true
798
+ propertyNames: true,
799
+ deprecated: true,
800
+ readOnly: true,
801
+ writeOnly: true,
802
+ $comment: true
760
803
  };
761
804
  //#endregion
762
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/utils/schema/meta-validator.ts
805
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/utils/schema/meta-validator.ts
763
806
  function isPlainObject(value) {
764
807
  return typeof value === "object" && value !== null && !Array.isArray(value);
765
808
  }
@@ -900,7 +943,7 @@ function isValidJsonSchema(schema) {
900
943
  }
901
944
  }
902
945
  //#endregion
903
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/utils/schema/spill.ts
946
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/utils/schema/spill.ts
904
947
  function formatSpillValue(value) {
905
948
  return JSON.stringify(value);
906
949
  }
@@ -931,7 +974,7 @@ function spillToDescription(node, entries, format = "spill") {
931
974
  node.description = existing ? `${existing}\n\n${formatted}` : formatted;
932
975
  }
933
976
  //#endregion
934
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/utils/schema/normalize.ts
977
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/utils/schema/normalize.ts
935
978
  /**
936
979
  * Provider-specific JSON Schema normalization used in the request path.
937
980
  *
@@ -947,11 +990,12 @@ const SNAKE_TO_CAMEL_RENAMES = /* @__PURE__ */ new Map([
947
990
  ["property_ordering", "propertyOrdering"]
948
991
  ]);
949
992
  const JSON_SCHEMA_COMBINERS = ["anyOf", "oneOf"];
950
- const CCA_FORBIDDEN_COMBINERS = /* @__PURE__ */ new Set([
993
+ /** The three JSON Schema composition keywords: `anyOf`, `oneOf`, `allOf`. */
994
+ const SCHEMA_COMPOSITION_COMBINERS = [
995
+ "allOf",
951
996
  "anyOf",
952
- "oneOf",
953
- "allOf"
954
- ]);
997
+ "oneOf"
998
+ ];
955
999
  /**
956
1000
  * Keywords whose value is a single subschema (draft 2020-12). A bare `true` /
957
1001
  * `false` in one of these slots is a boolean subschema to coerce (issue #5604).
@@ -1312,18 +1356,24 @@ function mergeObjectCombinerVariants(schema, combiner) {
1312
1356
  const nextSchema = copySchemaWithout(schema, combiner);
1313
1357
  nextSchema.type = "object";
1314
1358
  nextSchema.properties = mergedProperties;
1315
- let requiredIntersection;
1316
- for (const variant of variants) {
1317
- const variantRequired = Array.isArray(variant.required) ? variant.required.filter((r) => typeof r === "string") : [];
1318
- if (requiredIntersection === void 0) requiredIntersection = [...variantRequired];
1359
+ const branchRequired = variants.map((variant) => Array.isArray(variant.required) ? variant.required.filter((r) => typeof r === "string") : []);
1360
+ let combinedRequired;
1361
+ if (combiner === "allOf") {
1362
+ const union = /* @__PURE__ */ new Set();
1363
+ for (const required of branchRequired) for (const name of required) union.add(name);
1364
+ combinedRequired = [...union];
1365
+ } else {
1366
+ let intersection;
1367
+ for (const required of branchRequired) if (intersection === void 0) intersection = [...required];
1319
1368
  else {
1320
- const reqSet = new Set(variantRequired);
1321
- requiredIntersection = requiredIntersection.filter((r) => reqSet.has(r));
1369
+ const reqSet = new Set(required);
1370
+ intersection = intersection.filter((r) => reqSet.has(r));
1322
1371
  }
1372
+ combinedRequired = intersection ?? [];
1323
1373
  }
1324
1374
  const parentRequired = Array.isArray(schema.required) ? schema.required.filter((r) => typeof r === "string") : [];
1325
1375
  const safeRequired = /* @__PURE__ */ new Set();
1326
- for (const name of requiredIntersection ?? []) if (Object.hasOwn(mergedProperties, name)) safeRequired.add(name);
1376
+ for (const name of combinedRequired) if (Object.hasOwn(mergedProperties, name)) safeRequired.add(name);
1327
1377
  for (const name of parentRequired) if (Object.hasOwn(ownProperties, name) && Object.hasOwn(mergedProperties, name)) safeRequired.add(name);
1328
1378
  const requiredInPropertyOrder = [];
1329
1379
  for (const name in mergedProperties) if (Object.hasOwn(mergedProperties, name) && safeRequired.has(name)) requiredInPropertyOrder.push(name);
@@ -1611,7 +1661,7 @@ function hasResidualSchemaIncompatibilities(value, checks, epoch = epochNext(),
1611
1661
  if (checks.nullable && Object.hasOwn(value, "nullable")) return true;
1612
1662
  if (checks.not && Object.hasOwn(value, "not")) return true;
1613
1663
  if (checks.combiners) {
1614
- for (const combiner of CCA_FORBIDDEN_COMBINERS) if (Array.isArray(value[combiner])) return true;
1664
+ for (const combiner of SCHEMA_COMPOSITION_COMBINERS) if (Array.isArray(value[combiner])) return true;
1615
1665
  }
1616
1666
  }
1617
1667
  for (const key in value) {
@@ -1622,6 +1672,120 @@ function hasResidualSchemaIncompatibilities(value, checks, epoch = epochNext(),
1622
1672
  }
1623
1673
  return false;
1624
1674
  }
1675
+ /**
1676
+ * True when a JSON Schema subtree carries any composition keyword (`anyOf`,
1677
+ * `oneOf`, `allOf`) in a schema position. Property *names* that happen to equal
1678
+ * a combiner keyword (living under `properties`/`patternProperties`) are not
1679
+ * combiners and do not count.
1680
+ */
1681
+ function containsSchemaCombiner(value, insideSchemaMap, epoch) {
1682
+ if (Array.isArray(value)) {
1683
+ if (!once(value, epoch)) return false;
1684
+ return value.some((entry) => containsSchemaCombiner(entry, false, epoch));
1685
+ }
1686
+ if (!isJsonObject(value)) return false;
1687
+ if (!once(value, epoch)) return false;
1688
+ if (!insideSchemaMap) {
1689
+ for (const combiner of SCHEMA_COMPOSITION_COMBINERS) if (Array.isArray(value[combiner])) return true;
1690
+ }
1691
+ for (const key in value) {
1692
+ if (!Object.hasOwn(value, key)) continue;
1693
+ const childKind = classifySchemaChild(key, value[key], insideSchemaMap);
1694
+ if (childKind && containsSchemaCombiner(value[key], childKind === "map", epoch)) return true;
1695
+ }
1696
+ return false;
1697
+ }
1698
+ /**
1699
+ * Fold every composition keyword out of one already child-projected node while
1700
+ * only ever widening acceptance. Object-shaped `anyOf`/`oneOf`/`allOf` branches
1701
+ * merge into the node's own `properties` via {@link mergeObjectCombinerVariants}
1702
+ * (union properties, combiner-appropriate `required`); any combiner whose
1703
+ * branches are not all object-shaped — scalar unions especially — is dropped so
1704
+ * the node widens to accept-all rather than narrowing to one branch. Merging can
1705
+ * itself synthesize a fresh `anyOf` inside a shared property (see
1706
+ * {@link mergePropertySchemas}), so property values are re-projected until the
1707
+ * node is combiner-free.
1708
+ */
1709
+ function projectNodeCombinersForCursor(node) {
1710
+ let current = node;
1711
+ let changed = true;
1712
+ while (changed) {
1713
+ changed = false;
1714
+ for (const combiner of SCHEMA_COMPOSITION_COMBINERS) {
1715
+ if (!Array.isArray(current[combiner])) continue;
1716
+ const source = current;
1717
+ const merged = mergeObjectCombinerVariants(current, combiner);
1718
+ if (merged !== current) {
1719
+ current = merged;
1720
+ const properties = current.properties;
1721
+ if (isJsonObject(properties)) {
1722
+ if (combiner !== "allOf") {
1723
+ const sourceProperties = isJsonObject(source.properties) ? source.properties : {};
1724
+ const sourceVariants = source[combiner];
1725
+ for (const name in properties) {
1726
+ if (!Object.hasOwn(properties, name)) continue;
1727
+ if (Object.hasOwn(sourceProperties, name)) {
1728
+ properties[name] = sourceProperties[name];
1729
+ continue;
1730
+ }
1731
+ let widenedProperty;
1732
+ for (const variant of sourceVariants) {
1733
+ const variantProperties = isJsonObject(variant.properties) ? variant.properties : {};
1734
+ let constraint;
1735
+ if (Object.hasOwn(variantProperties, name)) constraint = variantProperties[name];
1736
+ else if (variant.additionalProperties === false) continue;
1737
+ else if (isJsonObject(variant.additionalProperties)) constraint = variant.additionalProperties;
1738
+ else constraint = {};
1739
+ widenedProperty = widenedProperty === void 0 ? constraint : mergePropertySchemas(widenedProperty, constraint);
1740
+ }
1741
+ properties[name] = widenedProperty ?? {};
1742
+ }
1743
+ }
1744
+ for (const name in properties) if (Object.hasOwn(properties, name)) properties[name] = projectSchemaForCursor(properties[name], false);
1745
+ }
1746
+ } else current = copySchemaWithout(current, combiner);
1747
+ changed = true;
1748
+ }
1749
+ }
1750
+ return current;
1751
+ }
1752
+ function projectSchemaForCursor(value, insideSchemaMap) {
1753
+ if (Array.isArray(value)) {
1754
+ if (!enter(value)) return [];
1755
+ try {
1756
+ return value.map((entry) => projectSchemaForCursor(entry, false));
1757
+ } finally {
1758
+ exit(value);
1759
+ }
1760
+ }
1761
+ if (!isJsonObject(value)) return value;
1762
+ if (!enter(value)) return {};
1763
+ try {
1764
+ const result = {};
1765
+ for (const key in value) {
1766
+ if (!Object.hasOwn(value, key)) continue;
1767
+ const entry = value[key];
1768
+ if (!insideSchemaMap && key === "not" && containsSchemaCombiner(entry, false, epochNext())) continue;
1769
+ const childKind = classifySchemaChild(key, entry, insideSchemaMap);
1770
+ result[key] = childKind ? projectSchemaForCursor(entry, childKind === "map") : entry;
1771
+ }
1772
+ return insideSchemaMap ? result : projectNodeCombinersForCursor(result);
1773
+ } finally {
1774
+ exit(value);
1775
+ }
1776
+ }
1777
+ /**
1778
+ * Project a tool's wire schema onto the subset Cursor's MCP tool catalog
1779
+ * accepts. Cursor rejects the entire request with a provider 400 when any
1780
+ * advertised schema carries a composition keyword (issue #10432); this removes
1781
+ * `anyOf`/`oneOf`/`allOf` everywhere while preserving representable guidance and
1782
+ * only ever widening acceptance, so every input the canonical schema accepts is
1783
+ * still accepted by the advertised projection. The canonical schema (used for
1784
+ * execution-time argument validation) is never mutated.
1785
+ */
1786
+ function sanitizeSchemaForCursor(schema) {
1787
+ return projectSchemaForCursor(dereferenceJsonSchema(schema), false);
1788
+ }
1625
1789
  function normalizeSchema(value, options) {
1626
1790
  let normalized = normalizeSchemaNode(dereferenceJsonSchema(upgradeJsonSchemaTo202012(value)), {
1627
1791
  ...options,
@@ -2524,7 +2688,7 @@ function resolveStrictRef(root, ref) {
2524
2688
  return isJsonObject(cursor) ? cursor : void 0;
2525
2689
  }
2526
2690
  //#endregion
2527
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/utils/schema/adapt.ts
2691
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/utils/schema/adapt.ts
2528
2692
  /**
2529
2693
  * Set when callers want to globally bypass OpenAI strict-mode enforcement
2530
2694
  * (e.g. for debugging a provider that misreports strict support, or when
@@ -2557,7 +2721,7 @@ function adaptSchemaForStrict(schema, strict) {
2557
2721
  ({ ...UNSUPPORTED_SCHEMA_FIELDS });
2558
2722
  ({ ...CCA_UNSUPPORTED_SCHEMA_FIELDS });
2559
2723
  //#endregion
2560
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/utils/schema/wire.ts
2724
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/utils/schema/wire.ts
2561
2725
  /**
2562
2726
  * True when `value` is a live ArkType schema instance.
2563
2727
  *
@@ -3053,7 +3217,7 @@ function toolWireSchema(tool) {
3053
3217
  });
3054
3218
  }
3055
3219
  //#endregion
3056
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/dialect/coercion.ts
3220
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/dialect/coercion.ts
3057
3221
  function buildArgShapes(tools = []) {
3058
3222
  const shapes = /* @__PURE__ */ new Map();
3059
3223
  for (const tool of tools) {
@@ -3152,7 +3316,7 @@ function asRecord(value) {
3152
3316
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
3153
3317
  }
3154
3318
  //#endregion
3155
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/dialect/rendering.ts
3319
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/dialect/rendering.ts
3156
3320
  function renderToolResponseResults(results) {
3157
3321
  return results.map((result) => `<tool_response>\n${result.text}\n</tool_response>`).join("\n");
3158
3322
  }
@@ -3340,7 +3504,7 @@ function appendLegacySegment(out, segment) {
3340
3504
  return `${out}\n\n${segment}`;
3341
3505
  }
3342
3506
  //#endregion
3343
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/dialect/anthropic.ts
3507
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/dialect/anthropic.ts
3344
3508
  const MAX_PARTIAL_TAG_LENGTH = 256;
3345
3509
  const MAX_PARAMETER_VALUE_LENGTH = 1e6;
3346
3510
  const WRAPPER_TAGS = {
@@ -3859,10 +4023,10 @@ const definition$10 = {
3859
4023
  renderTranscript: renderTranscript$10
3860
4024
  };
3861
4025
  //#endregion
3862
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/dialect/deepseek.md
4026
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/dialect/deepseek.md
3863
4027
  var deepseek_default = "## Format guide\n\nA tool call wraps the function name, a separator, and one JSON object of arguments in fixed tokens. Emit them exactly:\n\n```text\n<|tool▁calls▁begin|><|tool▁call▁begin|>tool_name<|tool▁sep|>{\"arg\":\"value\"}<|tool▁call▁end|><|tool▁calls▁end|>\n```\n\nResults arrive as output tokens:\n\n```text\n<|tool▁output▁begin|>verbatim tool result<|tool▁output▁end|>\n```\n\n## Rules\n\n- Use `|` (U+FF5C) and `▁` (U+2581) exactly.\n- Tool name MUST match an available function; arguments are one valid JSON object.\n- Argument string values use only normal JSON string escaping (`\\\"`, `\\\\`, `\\n`); never HTML-escape their contents — write `a & b`, not `a &amp; b`.\n- NEVER wrap arguments in Markdown fences; NEVER emit a `type` field or `function` prefix.\n- Multiple calls chain `<|tool▁call▁begin|>...<|tool▁call▁end|>` directly — no separators, spaces, or newlines between them.\n- Private reasoning, when needed, goes in `<think>...</think>` before the tokens.\n- Read each output token in call order. NEVER emit output tokens yourself.\n- Emit the stop sequence ONLY after the call is fully written — NEVER announce a tool then stop (e.g. halting at \"Let's run `cargo clippy`\" with no `<|tool▁call▁begin|>` emitted). Write the complete call, THEN the stop sequence, THEN halt.\n";
3864
4028
  //#endregion
3865
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/dialect/deepseek.ts
4029
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/dialect/deepseek.ts
3866
4030
  const DEEPSEEK_TOOL_CALLS_BEGIN = "<|tool▁calls▁begin|>";
3867
4031
  const DEEPSEEK_TOOL_CALLS_END = "<|tool▁calls▁end|>";
3868
4032
  const DEEPSEEK_TOOL_CALL_BEGIN = "<|tool▁call▁begin|>";
@@ -3883,6 +4047,10 @@ const DSML_TOOL_CALLS_OPEN_FULLWIDTH = "<|DSML|tool_calls>";
3883
4047
  const DSML_TOOL_CALLS_CLOSE_FULLWIDTH = "</|DSML|tool_calls>";
3884
4048
  const DSML_TOOL_CALLS_OPEN_ASCII = "<|DSML|tool_calls>";
3885
4049
  const DSML_TOOL_CALLS_CLOSE_ASCII = "</|DSML|tool_calls>";
4050
+ const DSML_INVOKE_CLOSE_FULLWIDTH = "</|DSML|invoke>";
4051
+ const DSML_INVOKE_CLOSE_ASCII = "</|DSML|invoke>";
4052
+ const DSML_PARAMETER_CLOSE_FULLWIDTH = "</|DSML|parameter>";
4053
+ const DSML_PARAMETER_CLOSE_ASCII = "</|DSML|parameter>";
3886
4054
  const CONTROL_TOKENS = [
3887
4055
  DEEPSEEK_BOS,
3888
4056
  DEEPSEEK_EOS,
@@ -3900,6 +4068,12 @@ const CONTROL_TOKENS = [
3900
4068
  DEEPSEEK_TOOL_OUTPUT_BEGIN,
3901
4069
  DEEPSEEK_TOOL_OUTPUT_END
3902
4070
  ];
4071
+ const DSML_ORPHAN_CLOSE_TOKENS = [
4072
+ DSML_INVOKE_CLOSE_FULLWIDTH,
4073
+ DSML_INVOKE_CLOSE_ASCII,
4074
+ DSML_PARAMETER_CLOSE_FULLWIDTH,
4075
+ DSML_PARAMETER_CLOSE_ASCII
4076
+ ];
3903
4077
  const OUTSIDE_TOKENS = [
3904
4078
  DEEPSEEK_TOOL_CALLS_BEGIN,
3905
4079
  DEEPSEEK_TOOL_CALLS_END,
@@ -3910,6 +4084,7 @@ const OUTSIDE_TOKENS = [
3910
4084
  DSML_TOOL_CALLS_OPEN_ASCII,
3911
4085
  DSML_TOOL_CALLS_CLOSE_FULLWIDTH,
3912
4086
  DSML_TOOL_CALLS_CLOSE_ASCII,
4087
+ ...DSML_ORPHAN_CLOSE_TOKENS,
3913
4088
  ...CONTROL_TOKENS
3914
4089
  ];
3915
4090
  const SECTION_TOKENS = [DEEPSEEK_TOOL_CALL_BEGIN, DEEPSEEK_TOOL_CALLS_END];
@@ -3920,12 +4095,12 @@ const DSML_SECTION_TOKENS = [
3920
4095
  "<|DSML|invoke"
3921
4096
  ];
3922
4097
  const DSML_INVOKE_TOKENS = [
3923
- "</|DSML|invoke>",
3924
- "</|DSML|invoke>",
4098
+ DSML_INVOKE_CLOSE_FULLWIDTH,
4099
+ DSML_INVOKE_CLOSE_ASCII,
3925
4100
  "<|DSML|parameter",
3926
4101
  "<|DSML|parameter"
3927
4102
  ];
3928
- const DSML_PARAMETER_CLOSE_TOKENS = ["</|DSML|parameter>", "</|DSML|parameter>"];
4103
+ const DSML_PARAMETER_CLOSE_TOKENS = [DSML_PARAMETER_CLOSE_FULLWIDTH, DSML_PARAMETER_CLOSE_ASCII];
3929
4104
  var DeepSeekInbandScanner = class {
3930
4105
  #buffer = "";
3931
4106
  #state = "outside";
@@ -4047,6 +4222,11 @@ var DeepSeekInbandScanner = class {
4047
4222
  this.#state = "dsmlSection";
4048
4223
  return;
4049
4224
  }
4225
+ const orphanClose = this.#matchingOrphanDsmlClose();
4226
+ if (orphanClose) {
4227
+ this.#buffer = this.#buffer.slice(orphanClose.length);
4228
+ continue;
4229
+ }
4050
4230
  const control = this.#matchingControlToken();
4051
4231
  if (control) {
4052
4232
  this.#buffer = this.#buffer.slice(control.length);
@@ -4306,6 +4486,9 @@ var DeepSeekInbandScanner = class {
4306
4486
  }
4307
4487
  return "";
4308
4488
  }
4489
+ #matchingOrphanDsmlClose() {
4490
+ for (const token of DSML_ORPHAN_CLOSE_TOKENS) if (this.#buffer.startsWith(token)) return token;
4491
+ }
4309
4492
  #matchingControlToken() {
4310
4493
  if (this.#buffer.startsWith("<|tool▁calls▁end|>")) return DEEPSEEK_TOOL_CALLS_END;
4311
4494
  if (this.#buffer.startsWith(THINK_CLOSE$4)) return THINK_CLOSE$4;
@@ -4423,7 +4606,7 @@ const definition$9 = {
4423
4606
  renderTranscript: renderTranscript$9
4424
4607
  };
4425
4608
  //#endregion
4426
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/dialect/fenced-thinking.ts
4609
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/dialect/fenced-thinking.ts
4427
4610
  /**
4428
4611
  * Close-matcher for a ` ```thinking ` block that respects nested Markdown code
4429
4612
  * fences. A naive `indexOf("```")` closes the thinking section at the FIRST
@@ -4598,10 +4781,10 @@ var FencedThinkingScanner = class {
4598
4781
  }
4599
4782
  };
4600
4783
  //#endregion
4601
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/dialect/gemini.md
4784
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/dialect/gemini.md
4602
4785
  var gemini_default = "## Format guide\n\nEmit tool calls as Python inside a fenced ` ```tool_code ` block. Call each function as a method on `default_api`:\n\n````text\n```tool_code\ndefault_api.function_name(arg=\"value\", count=2)\n```\n````\n\nArgument values are Python literals: `\"strings\"`, numbers, `True`/`False`, `None`, `[lists]`, `{\"dicts\": 1}`.\n\nCall several functions in parallel as a Python list:\n\n````text\n```tool_code\n[default_api.first(x=\"a\"), default_api.second(y=\"b\")]\n```\n````\n\nTool results arrive later in a ` ```tool_outputs ` block:\n\n````text\n```tool_outputs\nverbatim tool result\n```\n````\n\nPut any private reasoning in a fenced ` ```thinking ` block before the ` ```tool_code ` block:\n\n````text\n```thinking\nbrief reasoning\n```\n````\n\n## Rules\n\n- The function name MUST match a listed function; arguments are keyword form (`name=value`).\n- Argument string values use only normal Python string escaping; never HTML-escape their contents — write `\"a & b\"`, not `\"a &amp; b\"`.\n- Multiple calls = a single `[...]` list (or one `default_api...` call per line) inside one ` ```tool_code ` block.\n- Put private reasoning in a ` ```thinking ` block before the ` ```tool_code ` block, never inside ` ```tool_code `.\n- Read each ` ```tool_outputs ` block in call order. NEVER write a ` ```tool_outputs ` block yourself.\n- Emit the ` ```tool_code ` block in full, THEN stop and halt — NEVER announce a tool then stop (e.g. halting at \"Let's run `cargo clippy`\" with no ` ```tool_code ` block emitted).\n";
4603
4786
  //#endregion
4604
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/dialect/gemini.ts
4787
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/dialect/gemini.ts
4605
4788
  const CODE_OPEN = "```tool_code";
4606
4789
  const OUTPUT_OPEN = "```tool_outputs";
4607
4790
  const FENCE = "```";
@@ -5129,10 +5312,10 @@ const definition$8 = {
5129
5312
  renderTranscript: renderTranscript$8
5130
5313
  };
5131
5314
  //#endregion
5132
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/dialect/gemma.md
5315
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/dialect/gemma.md
5133
5316
  var gemma_default = "## Format guide\n\nEmit each tool call as one `<|tool_call>` block. The body is `call:NAME{key:value,...}`; wrap every string value in the `<|\"|>` token:\n\n```text\n<|tool_call>call:function_name{path:<|\"|>src/a.ts<|\"|>,count:2}<tool_call|>\n```\n\nNon-string values are bare: numbers (`2`), `true`/`false`, `null`, lists `[<|\"|>a<|\"|>,<|\"|>b<|\"|>]`, and nested objects `{k:<|\"|>v<|\"|>}`.\n\nTool results arrive later in matching `<|tool_response>` blocks:\n\n```text\n<|tool_response>response:function_name{output:<|\"|>verbatim result<|\"|>}<tool_response|>\n```\n\nOptionally precede tool calls with private reasoning in a `<|channel>thought` block, closed by `<channel|>`:\n\n```text\n<|channel>thought\nbrief reasoning\n<channel|>\n```\n\n## Rules\n\n- `NAME` MUST match a listed function; arguments are `key:value` pairs separated by commas.\n- String values between `<|\"|>` tokens are raw literal text (no escaping); never HTML-escape them — write `a & b`, not `a &amp; b`.\n- Multiple calls = consecutive `<|tool_call>...<tool_call|>` blocks; keep prose outside them.\n- The closer is `<tool_call|>` (pipe on the right), not `</tool_call>` or `<|tool_call>`.\n- Private reasoning goes in a `<|channel>thought…<channel|>` block before any call; NEVER put tool calls inside it.\n- Read each `<|tool_response>` block in call order. NEVER write a `<|tool_response>` block yourself.\n- Write each call in full, THEN stop and halt — NEVER announce a tool then stop (e.g. halting at \"Let's run `cargo clippy`\" with no `<|tool_call>` block emitted).\n";
5134
5317
  //#endregion
5135
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/dialect/gemma.ts
5318
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/dialect/gemma.ts
5136
5319
  const CALL_OPEN = "<|tool_call>";
5137
5320
  const CALL_CLOSE = "<tool_call|>";
5138
5321
  const STRING = "<|\"|>";
@@ -5477,10 +5660,10 @@ const definition$7 = {
5477
5660
  renderTranscript: renderTranscript$7
5478
5661
  };
5479
5662
  //#endregion
5480
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/dialect/glm.md
5663
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/dialect/glm.md
5481
5664
  var glm_default = "## Format guide\n\nEmit each call as a `<tool_call>` block. The function name goes on the same line as the opening tag, followed by one `<arg_key>`/`<arg_value>` pair per argument, closed by `</tool_call>`:\n\n```text\n<tool_call>get_weather\n<arg_key>location</arg_key>\n<arg_value>Beijing</arg_value>\n<arg_key>days</arg_key>\n<arg_value>3</arg_value>\n</tool_call>\n```\n\nTool results return in an observation block:\n\n```text\n<observation>\n<tool_response>\nverbatim tool result\n</tool_response>\n</observation>\n```\n\n## Rules\n\n- The name after `<tool_call>` must match a listed function and sit on the same line.\n- Emit one `<arg_key>name</arg_key>` + `<arg_value>value</arg_value>` pair per argument; omit unset optional args.\n- `<arg_value>` bodies are read by regex (delimiter matching), NOT a real XML parser: write string values as raw literal text and never HTML-escape them (emit `a & b`, not `a &amp; b`; `<`/`>` stay literal); only the body's own `</arg_value>` closing tag is reserved. Non-string values are valid JSON.\n- Multiple calls are consecutive `<tool_call>…</tool_call>` blocks.\n- Private reasoning goes in `<think>…</think>`; NEVER put tool calls inside `<think>`.\n- Read each `<tool_response>` in call order. NEVER emit `<tool_response>` yourself.\n- Emit the stop sequence ONLY after the call is fully written — NEVER announce a tool then stop (e.g. halting at \"Let's run `cargo clippy`\" with no `<tool_call>` emitted). Write the complete call, THEN the stop sequence, THEN halt.\n";
5482
5665
  //#endregion
5483
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/dialect/glm.ts
5666
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/dialect/glm.ts
5484
5667
  const TOOL_OPEN$2 = "<tool_call>";
5485
5668
  const TOOL_CLOSE$2 = "</tool_call>";
5486
5669
  const ARG_KEY_OPEN = "<arg_key>";
@@ -6005,10 +6188,10 @@ const definition$6 = {
6005
6188
  renderTranscript: renderTranscript$6
6006
6189
  };
6007
6190
  //#endregion
6008
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/dialect/harmony.md
6191
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/dialect/harmony.md
6009
6192
  var harmony_default = "## Format guide\n\nEach function call is one assistant message on the `commentary` channel addressed to the function, emitted as text:\n\n```text\n<|start|>assistant<|channel|>commentary to=functions.function_name<|message|>{\"arg\":\"value\"}<|call|>\n```\n\nPut private reasoning in an `analysis` message:\n\n```text\n<|start|>assistant<|channel|>analysis<|message|>private reasoning<|end|>\n```\n\nTool results arrive as messages authored by the function, addressed back to the assistant:\n\n```text\n<|start|>functions.function_name to=assistant<|channel|>commentary<|message|>verbatim tool result<|end|>\n```\n\n## Rules\n\n- Recipient is `functions.` + a listed function name.\n- Body is one JSON object matching the schema; omit optional arguments you are not setting.\n- Argument string values use only normal JSON string escaping (`\\\"`, `\\\\`, `\\n`); never HTML-escape their contents — write `a & b`, not `a &amp; b`.\n- Multiple calls = consecutive call messages.\n- An optional visible preamble is a `commentary` message ending `<|end|>`.\n- NEVER put tool calls in `analysis`.\n- NEVER wrap calls in Markdown/code fences.\n- Read each tool-result message in call order. NEVER emit tool-result messages yourself.\n- Emit the stop sequence ONLY after the call is fully written — NEVER announce a tool then stop (e.g. halting at \"Let's run `cargo clippy`\" with no `<|call|>` message emitted). Write the complete call, THEN the stop sequence, THEN halt.\n";
6010
6193
  //#endregion
6011
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/dialect/harmony.ts
6194
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/dialect/harmony.ts
6012
6195
  const START = "<|start|>";
6013
6196
  const END = "<|end|>";
6014
6197
  const MESSAGE = "<|message|>";
@@ -6316,10 +6499,10 @@ const definition$5 = {
6316
6499
  renderTranscript: renderTranscript$5
6317
6500
  };
6318
6501
  //#endregion
6319
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/dialect/hermes.md
6502
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/dialect/hermes.md
6320
6503
  var hermes_default = "## Format guide\n\nEmit each call as a `<tool_call>` block wrapping a single-line JSON object with `name` and `arguments`:\n\n```text\n<tool_call>\n{\"name\":\"function_name\",\"arguments\":{\"arg\":\"value\"}}\n</tool_call>\n```\n\nResults arrive later as `<tool_response>` blocks:\n\n```text\n<tool_response>\nverbatim tool result\n</tool_response>\n```\n\n## Rules\n\n- `name` MUST match a listed function; `arguments` is a JSON object, never a stringified JSON.\n- Argument string values use only normal JSON string escaping (`\\\"`, `\\\\`, `\\n`); never HTML-escape their contents — write `a & b`, not `a &amp; b`.\n- Emit multiple calls as consecutive `<tool_call>` blocks; keep any prose outside them.\n- Read each `<tool_response>` in call order. NEVER emit `<tool_response>` yourself.\n- Emit the stop sequence ONLY after the call is fully written — NEVER announce a tool then stop (e.g. halting at \"Let's run `cargo clippy`\" with no `<tool_call>` emitted). Write the complete call, THEN the stop sequence, THEN halt.\n";
6321
6504
  //#endregion
6322
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/dialect/hermes.ts
6505
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/dialect/hermes.ts
6323
6506
  const TOOL_OPEN$1 = "<tool_call>";
6324
6507
  const TOOL_CLOSE$1 = "</tool_call>";
6325
6508
  const THINK_OPEN$2 = "<think>";
@@ -6527,10 +6710,10 @@ const definition$4 = {
6527
6710
  renderTranscript: renderTranscript$4
6528
6711
  };
6529
6712
  //#endregion
6530
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/dialect/kimi.md
6713
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/dialect/kimi.md
6531
6714
  var kimi_default = "## Format guide\n\nEmit every call of a turn inside one section. Each call is an id of the fixed form `functions.NAME:INDEX` followed by one JSON arguments object:\n\n```text\n<|tool_calls_section_begin|><|tool_call_begin|>functions.NAME:INDEX<|tool_call_argument_begin|>{\"arg\":\"value\"}<|tool_call_end|><|tool_calls_section_end|>\n```\n\nTool results arrive later as turns whose body is a `## Return of functions.NAME:INDEX` header then the verbatim result:\n\n```text\n<|im_system|>NAME<|im_middle|>## Return of functions.NAME:INDEX\nverbatim tool result<|im_end|>\n```\n\n## Rules\n\n- `NAME` MUST match a listed function exactly.\n- Arguments MUST be one JSON object with double-quoted keys.\n- Argument string values use only normal JSON string escaping (`\\\"`, `\\\\`, `\\n`); never HTML-escape their contents — write `a & b`, not `a &amp; b`.\n- Multiple calls = consecutive `<|tool_call_begin|>…<|tool_call_end|>` blocks in the same section; `INDEX` increments from `0`.\n- Private reasoning, when supported, goes in `<think>…</think>` before the tool-call section; NEVER put tool calls inside `<think>`.\n- Read each result turn in call order. NEVER emit result turns yourself.\n- Emit the stop sequence ONLY after the call is fully written — NEVER announce a tool then stop (e.g. halting at \"Let's run `cargo clippy`\" with no `<|tool_call_begin|>` emitted). Write the complete call, THEN the stop sequence, THEN halt.\n";
6532
6715
  //#endregion
6533
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/dialect/kimi.ts
6716
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/dialect/kimi.ts
6534
6717
  const KIMI_SECTION_BEGIN = "<|tool_calls_section_begin|>";
6535
6718
  const KIMI_SECTION_END = "<|tool_calls_section_end|>";
6536
6719
  const KIMI_CALL_BEGIN = "<|tool_call_begin|>";
@@ -6826,10 +7009,10 @@ const definition$3 = {
6826
7009
  renderTranscript: renderTranscript$3
6827
7010
  };
6828
7011
  //#endregion
6829
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/dialect/minimax.md
7012
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/dialect/minimax.md
6830
7013
  var minimax_default = "## Format guide\n\nA call is a `<minimax:tool_call>` block wrapping one or more `<invoke>` blocks, each holding `<parameter>` children:\n\n```text\n<minimax:tool_call>\n<invoke name=\"tool_name\"><parameter name=\"arg_name\">arg value</parameter></invoke>\n</minimax:tool_call>\n```\n\nResults arrive later in a `<function_results>` block, one `<result>` per call (failures use `<error>` with `<stderr>` in place of `<result>` with `<stdout>`):\n\n```text\n<function_results>\n<result>\n<tool_name>tool_name</tool_name>\n<stdout>verbatim tool result</stdout>\n</result>\n</function_results>\n```\n\n## Rules\n\n- `name` MUST match a listed function.\n- String/scalar parameters: exact text, spaces preserved — bodies are read by regex (delimiter matching), NOT a real XML parser, so never HTML-escape them (emit `a & b`, not `a &amp; b`; `<`/`>` stay literal); only the body's own `</parameter>` closing tag is reserved. Lists/objects: JSON.\n- Multiple calls: multiple `<invoke>` blocks in one `<minimax:tool_call>`.\n- You MAY write visible text before the calls.\n- NEVER emit `tool_calls` JSON.\n- NEVER use `<function_calls>` or the legacy `<tool_name>`/`<parameters>` call syntax.\n- Read each `<result>`/`<error>` in call order. NEVER emit `<function_results>` yourself.\n- Emit the stop sequence ONLY after the call is fully written — NEVER announce a tool then stop (e.g. halting at \"Let's run `cargo clippy`\" with no `<invoke>` emitted). Write the complete call, THEN the stop sequence, THEN halt.\n";
6831
7014
  //#endregion
6832
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/dialect/minimax.ts
7015
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/dialect/minimax.ts
6833
7016
  const MINIMAX_WRAPPER_TAGS = { tool_call: true };
6834
7017
  const MINIMAX_BASE_TAG_PREFIXES = [
6835
7018
  "<minimax:tool_call",
@@ -6894,10 +7077,10 @@ const definition$2 = {
6894
7077
  renderTranscript: renderTranscript$2
6895
7078
  };
6896
7079
  //#endregion
6897
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/dialect/qwen3.md
7080
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/dialect/qwen3.md
6898
7081
  var qwen3_default = "## Format guide\n\nEmit each tool call as one `<tool_call>` block wrapping a single-line JSON object with `name` and a nested `arguments` object:\n\n```text\n<tool_call>\n{\"name\":\"function_name\",\"arguments\":{\"arg\":\"value\"}}\n</tool_call>\n```\n\nDo any private reasoning in `<think>...</think>` before your tool calls.\n\nTool results arrive later in a user turn:\n\n```text\n<tool_response>\nverbatim tool result\n</tool_response>\n```\n\n## Rules\n\n- `name` MUST match a listed function; `arguments` is a JSON object, never a JSON string.\n- Argument string values use only normal JSON string escaping (`\\\"`, `\\\\`, `\\n`); never HTML-escape their contents — write `a & b`, not `a &amp; b`.\n- Multiple calls = consecutive `<tool_call>...</tool_call>` blocks; keep prose outside them.\n- NEVER put tool calls inside `<think>`.\n- Read each `<tool_response>` in call order. NEVER emit `<tool_response>` yourself.\n- Emit the stop sequence ONLY after the call is fully written — NEVER announce a tool then stop (e.g. halting at \"Let's run `cargo clippy`\" with no `<tool_call>` emitted). Write the complete call, THEN the stop sequence, THEN halt.\n";
6899
7082
  //#endregion
6900
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/dialect/qwen3.ts
7083
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/dialect/qwen3.ts
6901
7084
  const TOOL_OPEN = "<tool_call>";
6902
7085
  const TOOL_CLOSE = "</tool_call>";
6903
7086
  const THINK_OPEN = "<think>";
@@ -7118,10 +7301,10 @@ const definition$1 = {
7118
7301
  renderTranscript: renderTranscript$1
7119
7302
  };
7120
7303
  //#endregion
7121
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/dialect/xml.md
7304
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/dialect/xml.md
7122
7305
  var xml_default = "## Format guide\n\nA call is one `<invoke>` element whose `<parameter>` children carry its arguments:\n\n```text\n<invoke name=\"fn\"><parameter name=\"arg\">value</parameter></invoke>\n```\n\nEmit consecutive `<invoke>…</invoke>` blocks for multiple calls; you MAY wrap them in `<tool_calls>…</tool_calls>`. Each call's result arrives as a response block:\n\n```text\n<tool_response>\nverbatim tool result\n</tool_response>\n```\n\n## Rules\n\n- `name` MUST match a listed function.\n- Parameter values are read literally by regex (delimiter matching), NOT a real XML parser: write them verbatim and never HTML-escape (emit `a & b`, never `a &amp; b`; `<`/`>` stay literal too). Only the body's own `</parameter>` closing tag is reserved. Non-string values are JSON; add `string=\"false\"` to a parameter only to force JSON parsing of a value the schema treats as a string.\n- Read each `<tool_response>` in call order. NEVER emit `<tool_response>` yourself.\n- Emit the stop sequence ONLY after the call is fully written — NEVER announce a tool then stop (e.g. halting at \"Let's run `cargo clippy`\" with no `<invoke>` emitted). Write the complete call, THEN the stop sequence, THEN halt.\n";
7123
7306
  //#endregion
7124
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/dialect/xml.ts
7307
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/dialect/xml.ts
7125
7308
  var XmlInbandScanner = class {
7126
7309
  #inner;
7127
7310
  constructor(options = {}) {
@@ -7167,7 +7350,7 @@ function renderInvokes(calls, tools) {
7167
7350
  return calls.map((call) => renderInvoke(call, shapes.get(call.name))).join("\n");
7168
7351
  }
7169
7352
  //#endregion
7170
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/dialect/factory.ts
7353
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/dialect/factory.ts
7171
7354
  const DIALECT_DEFINITIONS = {
7172
7355
  glm: definition$6,
7173
7356
  hermes: definition$4,
@@ -7197,7 +7380,7 @@ function createInbandScanner(dialect, options = {}) {
7197
7380
  return getDialectDefinition(dialect).createScanner(options);
7198
7381
  }
7199
7382
  //#endregion
7200
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/dialect/demotion.ts
7383
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/dialect/demotion.ts
7201
7384
  /**
7202
7385
  * Wrap a prior-turn reasoning string for demotion into native conversation
7203
7386
  * history — the cross-provider / cross-model case where the target cannot
@@ -7236,7 +7419,7 @@ function renderDemotedThinking(modelId, text) {
7236
7419
  return getDialectDefinition(dialect).renderThinking(text);
7237
7420
  }
7238
7421
  //#endregion
7239
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/utils/block-symbols.ts
7422
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/utils/block-symbols.ts
7240
7423
  /** Stores streamed tool-call argument JSON for live renderers and parser recovery. */
7241
7424
  const kStreamingPartialJson = Symbol("provider.block.partialJson");
7242
7425
  /** Clears streamed tool-call argument JSON without deleting or changing object shape. */
@@ -7288,7 +7471,7 @@ function isDemotedThinking(block) {
7288
7471
  return block?.[kDemotedThinking] === true;
7289
7472
  }
7290
7473
  //#endregion
7291
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/providers/transform-messages.ts
7474
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/providers/transform-messages.ts
7292
7475
  var ToolCallStatus = /* @__PURE__ */ function(ToolCallStatus) {
7293
7476
  /** A tool result has already been emitted for this tool call; later duplicates must be skipped. */
7294
7477
  ToolCallStatus[ToolCallStatus["Resolved"] = 1] = "Resolved";
@@ -7306,6 +7489,79 @@ var ToolCallStatus = /* @__PURE__ */ function(ToolCallStatus) {
7306
7489
  * MUST not push a normalized id past this bound.
7307
7490
  */
7308
7491
  const MAX_TOOL_CALL_ID_LENGTH = 64;
7492
+ /**
7493
+ * OpenAI Responses-family APIs mint composite tool ids (`call_id|item_id`);
7494
+ * opaque Chat Completions ids do not (openai-completions preserves same-model
7495
+ * ids verbatim as provider correlation tokens), so ONLY these origins may be
7496
+ * canonicalized to their `call_` component for pairing.
7497
+ */
7498
+ function isResponsesFamilyApi(api) {
7499
+ return api === "openai-responses" || api === "openai-codex-responses" || api === "azure-openai-responses";
7500
+ }
7501
+ /**
7502
+ * The wire `call_id` component of a (possibly composite) Responses id: the
7503
+ * FIRST segment before `|`. A degenerate `|itemId` (empty call half, pipe at
7504
+ * index 0) keeps its full id so unrelated empty-half ids never collapse onto
7505
+ * one empty-string bucket.
7506
+ */
7507
+ function responsesCallComponent(id) {
7508
+ const pipe = id.indexOf("|");
7509
+ return pipe <= 0 ? id : id.slice(0, pipe);
7510
+ }
7511
+ function collectToolCallOriginScope(messages) {
7512
+ const responsesComponents = /* @__PURE__ */ new Set();
7513
+ const opaqueCompositeCallIds = /* @__PURE__ */ new Set();
7514
+ for (const msg of messages) {
7515
+ if (msg.role !== "assistant") continue;
7516
+ const responsesOrigin = isResponsesFamilyApi(msg.api);
7517
+ for (const block of msg.content) {
7518
+ if (block.type !== "toolCall") continue;
7519
+ if (responsesOrigin) responsesComponents.add(responsesCallComponent(block.id));
7520
+ else if (block.id.includes("|")) opaqueCompositeCallIds.add(block.id);
7521
+ }
7522
+ }
7523
+ return {
7524
+ responsesComponents,
7525
+ opaqueCompositeCallIds
7526
+ };
7527
+ }
7528
+ /**
7529
+ * Canonical key for pairing a tool result with its assistant tool call.
7530
+ *
7531
+ * The OpenAI Codex/Responses APIs store a tool result's id as a composite
7532
+ * `<call_id>|<response_item_id>` (e.g. `call_ABC|fc_XYZ`), while the assistant
7533
+ * `toolCall` that produced it carries the plain `call_ABC` (or a composite with
7534
+ * a DIFFERENT item half). Keying both sides on the FIRST segment pairs them,
7535
+ * while NOT collapsing two distinct parallel calls whose results happen to
7536
+ * share a `response_item` (`fc_`) half.
7537
+ *
7538
+ * SCOPING (load-bearing, #10284): a pipe-bearing id is canonicalized to its
7539
+ * `call_` component ONLY when it is not itself a concrete opaque-origin call id
7540
+ * ({@link ToolCallOriginScope.opaqueCompositeCallIds}) and its component was
7541
+ * minted by a Responses-family turn ({@link ToolCallOriginScope.responsesComponents}).
7542
+ * A same-model Chat Completions id is an OPAQUE provider correlation token that
7543
+ * may itself contain `|` (openai-completions.ts preserves it verbatim);
7544
+ * splitting it would collapse two distinct opaque calls onto one bucket, so the
7545
+ * real result never pairs and the call is back-filled with a synthetic stub.
7546
+ * Opaque ids fall through to full-id keying, where the provider's own echoed
7547
+ * `tool_call_id` already pairs result to call by raw equality.
7548
+ *
7549
+ * Pairing keys are used only for lookup; the messages' own ids are left intact
7550
+ * so the provider encoder still receives the exact wire ids it expects.
7551
+ *
7552
+ * LOAD-BEARING INVARIANT: pairing correctness depends on the wire `call_id`
7553
+ * being unique per distinct tool call. The Codex Responses wire guarantees this
7554
+ * (distinct parallel calls carry distinct call_ids; only the `fc_` half varies),
7555
+ * and genuine cross-turn id reuse is `_dup`-suffixed on the call_ segment by
7556
+ * `deduplicateToolCallIds` (which this key preserves).
7557
+ */
7558
+ function toolCallPairingKey(id, originScope) {
7559
+ const pipe = id.indexOf("|");
7560
+ if (pipe <= 0) return id;
7561
+ if (originScope.opaqueCompositeCallIds.has(id)) return id;
7562
+ const prefix = id.slice(0, pipe);
7563
+ return originScope.responsesComponents.has(prefix) ? prefix : id;
7564
+ }
7309
7565
  function appendDuplicateSuffix(originalId, suffix, maxLength) {
7310
7566
  if (originalId.includes("|")) return originalId.split("|").map((segment) => appendSegmentDuplicateSuffix(segment, suffix, maxLength)).join("|");
7311
7567
  return appendSegmentDuplicateSuffix(originalId, suffix, maxLength);
@@ -7315,15 +7571,16 @@ function appendSegmentDuplicateSuffix(segment, suffix, maxLength) {
7315
7571
  const prefixBudget = Math.max(0, maxLength - suffix.length);
7316
7572
  return `${segment.slice(0, prefixBudget)}${suffix}`;
7317
7573
  }
7318
- function deduplicateToolCallIds(messages, maxToolCallIdLength = MAX_TOOL_CALL_ID_LENGTH, duplicateSuffixPrefix = "_dup") {
7574
+ function deduplicateToolCallIds(messages, originScope, maxToolCallIdLength = MAX_TOOL_CALL_ID_LENGTH, duplicateSuffixPrefix = "_dup") {
7319
7575
  const seenToolCallIds = /* @__PURE__ */ new Map();
7320
7576
  const pendingToolResultRewrites = /* @__PURE__ */ new Map();
7321
7577
  return messages.map((msg) => {
7322
7578
  if (msg.role === "toolResult") {
7323
- const rewrites = pendingToolResultRewrites.get(msg.toolCallId);
7579
+ const key = toolCallPairingKey(msg.toolCallId, originScope);
7580
+ const rewrites = pendingToolResultRewrites.get(key);
7324
7581
  if (!rewrites || rewrites.length === 0) return msg;
7325
7582
  const rewrite = rewrites.shift();
7326
- if (rewrites.length === 0) pendingToolResultRewrites.delete(msg.toolCallId);
7583
+ if (rewrites.length === 0) pendingToolResultRewrites.delete(key);
7327
7584
  if (rewrite) return {
7328
7585
  ...msg,
7329
7586
  toolCallId: rewrite.replacementId
@@ -7343,25 +7600,26 @@ function deduplicateToolCallIds(messages, maxToolCallIdLength = MAX_TOOL_CALL_ID
7343
7600
  let contentChanged = false;
7344
7601
  const content = msg.content.map((block) => {
7345
7602
  if (block.type !== "toolCall") return block;
7346
- if (!idsTouchedInTurn.has(block.id)) {
7347
- pendingToolResultRewrites.delete(block.id);
7348
- idsTouchedInTurn.add(block.id);
7603
+ const blockKey = toolCallPairingKey(block.id, originScope);
7604
+ if (!idsTouchedInTurn.has(blockKey)) {
7605
+ pendingToolResultRewrites.delete(blockKey);
7606
+ idsTouchedInTurn.add(blockKey);
7349
7607
  }
7350
- const previousCount = seenToolCallIds.get(block.id) ?? 0;
7608
+ const previousCount = seenToolCallIds.get(blockKey) ?? 0;
7351
7609
  if (previousCount === 0) {
7352
- seenToolCallIds.set(block.id, 1);
7353
- enqueueToolResultRewrite(block.id, void 0);
7610
+ seenToolCallIds.set(blockKey, 1);
7611
+ enqueueToolResultRewrite(blockKey, void 0);
7354
7612
  return block;
7355
7613
  }
7356
7614
  let duplicateIndex = previousCount;
7357
7615
  let replacementId = appendDuplicateSuffix(block.id, `${duplicateSuffixPrefix}${duplicateIndex}`, maxToolCallIdLength);
7358
- while (seenToolCallIds.has(replacementId)) {
7616
+ while (seenToolCallIds.has(toolCallPairingKey(replacementId, originScope))) {
7359
7617
  duplicateIndex += 1;
7360
7618
  replacementId = appendDuplicateSuffix(block.id, `${duplicateSuffixPrefix}${duplicateIndex}`, maxToolCallIdLength);
7361
7619
  }
7362
- seenToolCallIds.set(block.id, duplicateIndex + 1);
7363
- seenToolCallIds.set(replacementId, 1);
7364
- enqueueToolResultRewrite(block.id, { replacementId });
7620
+ seenToolCallIds.set(blockKey, duplicateIndex + 1);
7621
+ seenToolCallIds.set(toolCallPairingKey(replacementId, originScope), 1);
7622
+ enqueueToolResultRewrite(blockKey, { replacementId });
7365
7623
  contentChanged = true;
7366
7624
  return {
7367
7625
  ...block,
@@ -7508,11 +7766,22 @@ function transformMessages(messages, model, normalizeToolCallId, maxNormalizedTo
7508
7766
  messages = redactSensitiveCredentialsInMessages(messages);
7509
7767
  messages = sanitizeMalformedToolCalls(messages);
7510
7768
  const toolCallIdMap = /* @__PURE__ */ new Map();
7769
+ const responsesCompositeIdMap = /* @__PURE__ */ new Map();
7511
7770
  const latestSurvivingAssistantIndex = getLatestSurvivingAssistantIndex(messages);
7512
- const transformed = deduplicateToolCallIds(messages.map((msg, index) => {
7771
+ const invalidBoundThinkingAssistantIndexes = /* @__PURE__ */ new Set();
7772
+ if (model.thinking?.prefixBinding) {
7773
+ let latestRewriteAt;
7774
+ for (let index = 0; index < messages.length; index++) {
7775
+ const message = messages[index];
7776
+ if (message.role === "user" && message.historyRewriteAt !== void 0) latestRewriteAt = latestRewriteAt === void 0 ? message.historyRewriteAt : Math.max(latestRewriteAt, message.historyRewriteAt);
7777
+ else if (message.role === "toolResult" && message.prunedAt !== void 0) latestRewriteAt = latestRewriteAt === void 0 ? message.prunedAt : Math.max(latestRewriteAt, message.prunedAt);
7778
+ else if (message.role === "assistant" && latestRewriteAt !== void 0 && message.timestamp <= latestRewriteAt) invalidBoundThinkingAssistantIndexes.add(index);
7779
+ }
7780
+ }
7781
+ const normalizedMessages = messages.map((msg, index) => {
7513
7782
  if (msg.role === "user" || msg.role === "developer") return msg;
7514
7783
  if (msg.role === "toolResult") {
7515
- const normalizedId = toolCallIdMap.get(msg.toolCallId);
7784
+ const normalizedId = toolCallIdMap.get(msg.toolCallId) ?? (msg.toolCallId.includes("|") ? responsesCompositeIdMap.get(responsesCallComponent(msg.toolCallId)) : void 0);
7516
7785
  if (normalizedId && normalizedId !== msg.toolCallId) return {
7517
7786
  ...msg,
7518
7787
  toolCallId: normalizedId
@@ -7524,6 +7793,7 @@ function transformMessages(messages, model, normalizeToolCallId, maxNormalizedTo
7524
7793
  const isSameModel = assistantMsg.provider === model.provider && assistantMsg.api === model.api && assistantMsg.model === model.id;
7525
7794
  const isAnthropicTarget = isAnthropicMessagesModel(model);
7526
7795
  const isAnthropicReplay = isAnthropicTarget && assistantMsg.api === "anthropic-messages";
7796
+ const sameAnthropicDeployment = isAnthropicReplay && assistantMsg.provider === model.provider && (model.compat.officialEndpoint || model.thinking?.prefixBinding === true);
7527
7797
  const isLatestSurvivingAssistant = index === latestSurvivingAssistantIndex;
7528
7798
  const isOfficialAnthropicSource = isAnthropicReplay && assistantMsg.provider === "anthropic";
7529
7799
  const isSigningAnthropicTarget = isAnthropicTarget && model.compat.signingEndpoint;
@@ -7544,6 +7814,7 @@ function transformMessages(messages, model, normalizeToolCallId, maxNormalizedTo
7544
7814
  const hasVisibleAnthropicThinking = assistantMsg.content.some((candidate) => candidate.type === "thinking");
7545
7815
  const dropsAllSameModelVisibleThinking = isAnthropicReplay && isSameModel && isSigningAnthropicTarget && hasVisibleAnthropicThinking && !assistantMsg.content.some(anthropicVisibleThinkingSurvivesReplay);
7546
7816
  const transformedContent = assistantMsg.content.flatMap((block, blockIndex) => {
7817
+ if (invalidBoundThinkingAssistantIndexes.has(index) && (block.type === "thinking" || block.type === "redactedThinking")) return [];
7547
7818
  if (block.type === "thinking") {
7548
7819
  let sanitized = (abandonedToolUse || invalidStopReason && blockIndex === lastBlockIndex) && block.thinkingSignature ? {
7549
7820
  ...block,
@@ -7552,7 +7823,7 @@ function transformMessages(messages, model, normalizeToolCallId, maxNormalizedTo
7552
7823
  if (isAnthropicReplay) {
7553
7824
  const crossProviderSource = assistantMsg.provider !== model.provider;
7554
7825
  if (isLatestSurvivingAssistant && abandonedToolUse && !crossProviderSource) return block;
7555
- if ((isLatestSurvivingAssistant ? crossProviderSource : !isSameModel) && signingAnthropicInvolved && sanitized.thinkingSignature) sanitized = {
7826
+ if (!sameAnthropicDeployment && (isLatestSurvivingAssistant ? crossProviderSource : !isSameModel) && signingAnthropicInvolved && sanitized.thinkingSignature) sanitized = {
7556
7827
  ...sanitized,
7557
7828
  thinkingSignature: void 0
7558
7829
  };
@@ -7576,7 +7847,7 @@ function transformMessages(messages, model, normalizeToolCallId, maxNormalizedTo
7576
7847
  if (block.type === "redactedThinking") {
7577
7848
  if (isAnthropicReplay) {
7578
7849
  if (dropsAllSameModelVisibleThinking) return [];
7579
- if (isSameModel || isLatestSurvivingAssistant && assistantMsg.provider === model.provider || replaysUnsignedAnthropicThinking) return block;
7850
+ if (isSameModel || sameAnthropicDeployment || isLatestSurvivingAssistant && assistantMsg.provider === model.provider || replaysUnsignedAnthropicThinking) return block;
7580
7851
  return [];
7581
7852
  }
7582
7853
  if (isSameModel) return block;
@@ -7605,17 +7876,11 @@ function transformMessages(messages, model, normalizeToolCallId, maxNormalizedTo
7605
7876
  ...toolCall,
7606
7877
  thoughtSignature: void 0
7607
7878
  };
7879
+ let normalizedId;
7608
7880
  if (isAnthropicTarget) {
7609
- const normalizedId = normalizeAnthropicTargetToolCallId(toolCall.id, model, assistantMsg, normalizeToolCallId);
7610
- if (normalizedId !== toolCall.id) {
7611
- toolCallIdMap.set(toolCall.id, normalizedId);
7612
- normalizedToolCall = {
7613
- ...normalizedToolCall,
7614
- id: normalizedId
7615
- };
7616
- }
7617
- } else if (!isSameModel && normalizeToolCallId) {
7618
- const normalizedId = normalizeToolCallId(toolCall.id, model, assistantMsg);
7881
+ if (!isSameModel || model.compat.officialEndpoint) normalizedId = normalizeAnthropicTargetToolCallId(toolCall.id, model, assistantMsg, normalizeToolCallId);
7882
+ } else if (!isSameModel && normalizeToolCallId) normalizedId = normalizeToolCallId(toolCall.id, model, assistantMsg);
7883
+ if (normalizedId !== void 0) {
7619
7884
  if (normalizedId !== toolCall.id) {
7620
7885
  toolCallIdMap.set(toolCall.id, normalizedId);
7621
7886
  normalizedToolCall = {
@@ -7623,6 +7888,7 @@ function transformMessages(messages, model, normalizeToolCallId, maxNormalizedTo
7623
7888
  id: normalizedId
7624
7889
  };
7625
7890
  }
7891
+ if (isResponsesFamilyApi(assistantMsg.api)) responsesCompositeIdMap.set(responsesCallComponent(toolCall.id), normalizedId);
7626
7892
  }
7627
7893
  return normalizedToolCall;
7628
7894
  }
@@ -7639,7 +7905,9 @@ function transformMessages(messages, model, normalizeToolCallId, maxNormalizedTo
7639
7905
  };
7640
7906
  }
7641
7907
  return msg;
7642
- }), maxNormalizedToolCallIdLength, duplicateToolCallIdSuffixPrefix);
7908
+ });
7909
+ const originScope = collectToolCallOriginScope(normalizedMessages);
7910
+ const transformed = deduplicateToolCallIds(normalizedMessages, originScope, maxNormalizedToolCallIdLength, duplicateToolCallIdSuffixPrefix);
7643
7911
  const realToolResultsById = /* @__PURE__ */ new Map();
7644
7912
  for (let index = 0; index < transformed.length; index++) {
7645
7913
  const msg = transformed[index];
@@ -7649,13 +7917,14 @@ function transformMessages(messages, model, normalizeToolCallId, maxNormalizedTo
7649
7917
  msg,
7650
7918
  consumed: false
7651
7919
  };
7652
- const entries = realToolResultsById.get(msg.toolCallId);
7920
+ const key = toolCallPairingKey(msg.toolCallId, originScope);
7921
+ const entries = realToolResultsById.get(key);
7653
7922
  if (entries) entries.push(entry);
7654
- else realToolResultsById.set(msg.toolCallId, [entry]);
7923
+ else realToolResultsById.set(key, [entry]);
7655
7924
  }
7656
7925
  }
7657
7926
  const takeRealToolResult = (id, afterIndex) => {
7658
- const entries = realToolResultsById.get(id);
7927
+ const entries = realToolResultsById.get(toolCallPairingKey(id, originScope));
7659
7928
  if (!entries) return void 0;
7660
7929
  for (const entry of entries) {
7661
7930
  if (entry.consumed || entry.index <= afterIndex) continue;
@@ -7666,7 +7935,7 @@ function transformMessages(messages, model, normalizeToolCallId, maxNormalizedTo
7666
7935
  const validToolUseIds = /* @__PURE__ */ new Set();
7667
7936
  for (const msg of transformed) {
7668
7937
  if (msg.role !== "assistant") continue;
7669
- for (const block of msg.content) if (block.type === "toolCall") validToolUseIds.add(block.id);
7938
+ for (const block of msg.content) if (block.type === "toolCall") validToolUseIds.add(toolCallPairingKey(block.id, originScope));
7670
7939
  }
7671
7940
  const result = [];
7672
7941
  let pendingToolCalls = [];
@@ -7678,11 +7947,12 @@ function transformMessages(messages, model, normalizeToolCallId, maxNormalizedTo
7678
7947
  const flushPendingToolCalls = (timestamp) => {
7679
7948
  if (pendingToolCalls.length === 0) return;
7680
7949
  for (const tc of pendingToolCalls) {
7681
- if (toolCallStatus.has(tc.id)) continue;
7950
+ const statusKey = toolCallPairingKey(tc.id, originScope);
7951
+ if (toolCallStatus.has(statusKey)) continue;
7682
7952
  const realToolResult = takeRealToolResult(tc.id, pendingToolCallsStartIndex);
7683
7953
  if (realToolResult) {
7684
7954
  result.push(realToolResult);
7685
- toolCallStatus.set(tc.id, 1);
7955
+ toolCallStatus.set(statusKey, 1);
7686
7956
  continue;
7687
7957
  }
7688
7958
  result.push({
@@ -7696,18 +7966,19 @@ function transformMessages(messages, model, normalizeToolCallId, maxNormalizedTo
7696
7966
  isError: true,
7697
7967
  timestamp
7698
7968
  });
7699
- toolCallStatus.set(tc.id, 1);
7969
+ toolCallStatus.set(statusKey, 1);
7700
7970
  }
7701
7971
  pendingToolCalls = [];
7702
7972
  };
7703
7973
  const flushPendingAbortedToolCalls = () => {
7704
7974
  if (pendingAbortedTimestamp === void 0) return;
7705
7975
  for (const tc of pendingAbortedToolCalls.values()) {
7706
- if (toolCallStatus.has(tc.id)) continue;
7976
+ const statusKey = toolCallPairingKey(tc.id, originScope);
7977
+ if (toolCallStatus.has(statusKey)) continue;
7707
7978
  const realToolResult = takeRealToolResult(tc.id, pendingAbortedStartIndex);
7708
7979
  if (realToolResult) {
7709
7980
  result.push(realToolResult);
7710
- toolCallStatus.set(tc.id, 1);
7981
+ toolCallStatus.set(statusKey, 1);
7711
7982
  continue;
7712
7983
  }
7713
7984
  result.push({
@@ -7721,7 +7992,7 @@ function transformMessages(messages, model, normalizeToolCallId, maxNormalizedTo
7721
7992
  isError: true,
7722
7993
  timestamp: pendingAbortedTimestamp
7723
7994
  });
7724
- toolCallStatus.set(tc.id, 2);
7995
+ toolCallStatus.set(statusKey, 2);
7725
7996
  }
7726
7997
  pendingAbortedToolCalls = /* @__PURE__ */ new Map();
7727
7998
  pendingAbortedTimestamp = void 0;
@@ -7738,7 +8009,7 @@ function transformMessages(messages, model, normalizeToolCallId, maxNormalizedTo
7738
8009
  const toolCalls = assistantMsg.content.filter((b) => b.type === "toolCall");
7739
8010
  if (assistantMsg.stopReason === "error" || assistantMsg.stopReason === "aborted") {
7740
8011
  result.push(msg);
7741
- pendingAbortedToolCalls = new Map(toolCalls.map((toolCall) => [toolCall.id, toolCall]));
8012
+ pendingAbortedToolCalls = new Map(toolCalls.map((toolCall) => [toolCallPairingKey(toolCall.id, originScope), toolCall]));
7742
8013
  pendingAbortedTimestamp = assistantMsg.timestamp;
7743
8014
  pendingAbortedStartIndex = i;
7744
8015
  continue;
@@ -7749,20 +8020,21 @@ function transformMessages(messages, model, normalizeToolCallId, maxNormalizedTo
7749
8020
  }
7750
8021
  result.push(msg);
7751
8022
  } else if (msg.role === "toolResult") {
7752
- if (toolCallStatus.has(msg.toolCallId)) continue;
7753
- if (pendingAbortedToolCalls.has(msg.toolCallId)) {
7754
- pendingAbortedToolCalls.delete(msg.toolCallId);
7755
- toolCallStatus.set(msg.toolCallId, 1);
8023
+ const resultKey = toolCallPairingKey(msg.toolCallId, originScope);
8024
+ if (toolCallStatus.has(resultKey)) continue;
8025
+ if (pendingAbortedToolCalls.has(resultKey)) {
8026
+ pendingAbortedToolCalls.delete(resultKey);
8027
+ toolCallStatus.set(resultKey, 1);
7756
8028
  result.push(msg);
7757
8029
  continue;
7758
8030
  }
7759
- if (pendingToolCalls.some((tc) => tc.id === msg.toolCallId)) {
7760
- toolCallStatus.set(msg.toolCallId, 1);
8031
+ if (pendingToolCalls.some((tc) => toolCallPairingKey(tc.id, originScope) === resultKey)) {
8032
+ toolCallStatus.set(resultKey, 1);
7761
8033
  result.push(msg);
7762
8034
  continue;
7763
8035
  }
7764
- if (!validToolUseIds.has(msg.toolCallId)) {
7765
- if (pendingToolCalls.some((tc) => !toolCallStatus.has(tc.id)) || pendingAbortedToolCalls.size > 0) continue;
8036
+ if (!validToolUseIds.has(resultKey)) {
8037
+ if (pendingToolCalls.some((tc) => !toolCallStatus.has(toolCallPairingKey(tc.id, originScope))) || pendingAbortedToolCalls.size > 0) continue;
7766
8038
  const textParts = [];
7767
8039
  for (const part of msg.content) if (part.type === "text" && part.text.trim() !== "") textParts.push(part.text);
7768
8040
  if (textParts.length > 0) {
@@ -7789,8 +8061,19 @@ function transformMessages(messages, model, normalizeToolCallId, maxNormalizedTo
7789
8061
  return result;
7790
8062
  }
7791
8063
  //#endregion
7792
- //#region node_modules/.pnpm/@oh-my-pi+pi-ai@17.3.5/node_modules/@oh-my-pi/pi-ai/src/utils.ts
8064
+ //#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/utils.ts
7793
8065
  const NON_WHITESPACE_RE = /\S/;
8066
+ /**
8067
+ * Read a header value ignoring key casing. HTTP header names are
8068
+ * case-insensitive, but `Record<string, string>` header bags are not, so a
8069
+ * config-authored `User-Agent` and a caller-authored `user-agent` are the same
8070
+ * header to every provider that lowercases before merging.
8071
+ */
8072
+ function getHeaderCaseInsensitive(headers, headerName) {
8073
+ if (!headers) return void 0;
8074
+ const normalizedName = headerName.toLowerCase();
8075
+ for (const [key, value] of Object.entries(headers)) if (key.toLowerCase() === normalizedName) return value;
8076
+ }
7794
8077
  function normalizeSystemPrompts(systemPrompt) {
7795
8078
  if (systemPrompt === void 0 || systemPrompt === null) return [];
7796
8079
  return (Array.isArray(systemPrompt) ? systemPrompt : typeof systemPrompt === "string" ? [systemPrompt] : []).map((prompt) => redactSensitiveCredentials(prompt.toWellFormed())).filter((prompt) => prompt.trim().length > 0);
@@ -7799,21 +8082,18 @@ function normalizeToolCallId(id) {
7799
8082
  const sanitized = id.replace(/[^a-zA-Z0-9_-]/g, "_");
7800
8083
  return sanitized.length > 64 ? sanitized.slice(0, 64) : sanitized;
7801
8084
  }
8085
+ /** Preserve opaque call IDs for Responses replay while normalizing or generating the separate item ID. */
7802
8086
  function normalizeResponsesToolCallId(id, itemPrefix = "fc") {
7803
8087
  const [callId, itemId] = id.split("|");
7804
8088
  if (callId && itemId) return {
7805
- callId: truncateResponseItemId(callId, getIdPrefix(callId, "call")),
8089
+ callId,
7806
8090
  itemId: normalizeResponsesItemId(itemId, itemPrefix)
7807
8091
  };
7808
- const hash = Bun.hash(id).toString(36);
7809
8092
  return {
7810
- callId: id.startsWith("call_") ? truncateResponseItemId(id, "call") : `call_${hash}`,
7811
- itemId: `${itemPrefix}_${hash}`
8093
+ callId: id,
8094
+ itemId: `${itemPrefix}_${Bun.hash(id).toString(36)}`
7812
8095
  };
7813
8096
  }
7814
- function getIdPrefix(id, fallback) {
7815
- return id.match(/^([a-zA-Z][a-zA-Z0-9]*)_/)?.[1] || fallback;
7816
- }
7817
8097
  function getExplicitIdPrefix(id) {
7818
8098
  return id.match(/^([a-zA-Z][a-zA-Z0-9]*)_/)?.[1];
7819
8099
  }
@@ -7839,7 +8119,7 @@ function stripOpenAIResponsesOutputOnlyStatusesForReplay(items) {
7839
8119
  let sanitized;
7840
8120
  for (let index = 0; index < items.length; index++) {
7841
8121
  const item = items[index];
7842
- if (!(item.type === "message" || item.type === "function_call" || item.type === "custom_tool_call") || !Object.hasOwn(item, "status")) {
8122
+ if (!(item.type === "message" || item.type === "function_call" || item.type === "custom_tool_call" || item.type === "compaction" || item.type === "compaction_summary") || !Object.hasOwn(item, "status")) {
7843
8123
  sanitized?.push(item);
7844
8124
  continue;
7845
8125
  }
@@ -7922,12 +8202,11 @@ function collectOpenAIResponsesComputerLinkedReasoningItems(items, requireLaterO
7922
8202
  }
7923
8203
  const provisionalOpenAIResponsesComputerReasoningItems = /* @__PURE__ */ new WeakSet();
7924
8204
  function sanitizeOpenAIResponsesHistoryItemsForReplay(items, options = {}) {
7925
- const normalizedCallIds = /* @__PURE__ */ new Map();
7926
8205
  const supportsImageDetailOriginal = options.supportsImageDetailOriginal !== false;
7927
8206
  const computerLinkedReasoningItems = options.supportsComputerUse === false ? void 0 : collectOpenAIResponsesComputerLinkedReasoningItems(items, false);
7928
8207
  return stripOpenAIResponsesOutputOnlyStatusesForReplay(items.flatMap((item) => {
7929
8208
  const preserveForComputer = computerLinkedReasoningItems?.has(item) === true;
7930
- const sanitizedItem = sanitizeOpenAIResponsesHistoryItemForReplay(item, normalizedCallIds, supportsImageDetailOriginal, preserveForComputer);
8209
+ const sanitizedItem = sanitizeOpenAIResponsesHistoryItemForReplay(item, supportsImageDetailOriginal, preserveForComputer);
7931
8210
  if (preserveForComputer && sanitizedItem?.type === "reasoning") provisionalOpenAIResponsesComputerReasoningItems.add(sanitizedItem);
7932
8211
  return sanitizedItem ? [sanitizedItem] : [];
7933
8212
  }));
@@ -8051,13 +8330,20 @@ function sanitizeOpenAIResponsesAssistantFallbackItemsForReplay(items) {
8051
8330
  }
8052
8331
  return sanitized;
8053
8332
  }
8054
- function sanitizeOpenAIResponsesHistoryItemForReplay(item, normalizedCallIds, supportsImageDetailOriginal, preserveReasoningItemIds) {
8333
+ function sanitizeOpenAIResponsesHistoryItemForReplay(item, supportsImageDetailOriginal, preserveReasoningItemIds) {
8334
+ if (item.type === "function_call") {
8335
+ if (typeof item.arguments !== "string" || item.arguments.trim().length === 0) return void 0;
8336
+ try {
8337
+ JSON.parse(item.arguments);
8338
+ } catch {
8339
+ return;
8340
+ }
8341
+ }
8055
8342
  if (item.type === "item_reference") return void 0;
8056
8343
  if (item.type === "image_generation_call") return sanitizeOpenAIResponsesImageGenerationCallForReplay(item);
8057
8344
  if (item.type === "reasoning") return sanitizeOpenAIResponsesReasoningItemForReplay(item, preserveReasoningItemIds);
8058
8345
  const { id: _id, ...sanitizedItem } = item;
8059
8346
  if (item.type === "computer_call" && typeof item.id === "string") sanitizedItem.id = item.id;
8060
- if (typeof item.call_id === "string") sanitizedItem.call_id = normalizeReplayedResponsesHistoryCallId(item.call_id, normalizedCallIds);
8061
8347
  return clampReplayItemImageDetail(sanitizedItem, supportsImageDetailOriginal);
8062
8348
  }
8063
8349
  function sanitizeOpenAIResponsesReasoningItemForReplay(item, preserveItemId) {
@@ -8077,13 +8363,6 @@ function sanitizeOpenAIResponsesImageGenerationCallForReplay(item) {
8077
8363
  result: item.result
8078
8364
  };
8079
8365
  }
8080
- function normalizeReplayedResponsesHistoryCallId(value, normalizedValues) {
8081
- const normalized = normalizedValues.get(value);
8082
- if (normalized) return normalized;
8083
- const next = truncateResponseItemId(value, getIdPrefix(value, "call"));
8084
- normalizedValues.set(value, next);
8085
- return next;
8086
- }
8087
8366
  function createOpenAIResponsesHistoryPayload(provider, items, incremental = true) {
8088
8367
  return {
8089
8368
  type: "openaiResponsesHistory",
@@ -8116,4 +8395,4 @@ function resolveCacheRetention(cacheRetention, fallback = "short") {
8116
8395
  return fallback;
8117
8396
  }
8118
8397
  //#endregion
8119
- export { NO_STRICT as A, stringifyJson$1 as B, kStreamingPartialJson as C, partialSuffixOverlapAny as D, FencedThinkingScanner as E, sanitizeSchemaForGrammar as F, sanitizeSchemaForOllama as I, sanitizeSchemaForOpenAIResponses as L, normalizeSchemaForCCA as M, normalizeSchemaForGoogle as N, flattenExclusiveRequiredRootUnion as O, normalizeSchemaForMoonshot as P, spillToDescription as R, kStreamingLastParseLen as S, createInbandScanner as T, tryParseJson as V, kCursorExecResolved as _, normalizeSystemPrompts as a, kStreamingBlockKind as b, sanitizeOpenAIResponsesAssistantFallbackItemsForReplay as c, stripOpenAIResponsesComputerLinkedReasoningIdsForReplay as d, stripUnpairedOpenAIResponsesComputerReasoningIdsForReplay as f, isDemotedThinking as g, clearStreamingPartialJson as h, normalizeResponsesToolCallId as i, adaptSchemaForStrict as j, toolWireSchema as k, sanitizeOpenAIResponsesAssistantHistoryItemsForReplay as l, transformMessages as m, getOpenAIResponsesHistoryItems as n, normalizeToolCallId as o, redactSensitiveInObject as p, getOpenAIResponsesHistoryPayload as r, resolveCacheRetention as s, createOpenAIResponsesHistoryPayload as t, sanitizeOpenAIResponsesHistoryItemsForReplay as u, kStreamingArgumentsDone as v, renderDemotedThinking as w, kStreamingEnvelopeId as x, kStreamingBlockIndex as y, COMBINATOR_KEYS as z };
8398
+ export { toolWireSchema as A, spillToDescription as B, kStreamingLastParseLen as C, FencedThinkingScanner as D, createInbandScanner as E, normalizeSchemaForMoonshot as F, getBundledModelReferenceIndex as H, sanitizeSchemaForCursor as I, sanitizeSchemaForGrammar as L, adaptSchemaForStrict as M, normalizeSchemaForCCA as N, partialSuffixOverlapAny as O, normalizeSchemaForGoogle as P, sanitizeSchemaForOllama as R, kStreamingEnvelopeId as S, renderDemotedThinking as T, stringifyJson$1 as U, COMBINATOR_KEYS as V, tryParseJson as W, isDemotedThinking as _, normalizeResponsesToolCallId as a, kStreamingBlockIndex as b, resolveCacheRetention as c, sanitizeOpenAIResponsesHistoryItemsForReplay as d, stripOpenAIResponsesComputerLinkedReasoningIdsForReplay as f, clearStreamingPartialJson as g, transformMessages as h, getOpenAIResponsesHistoryPayload as i, NO_STRICT as j, flattenExclusiveRequiredRootUnion as k, sanitizeOpenAIResponsesAssistantFallbackItemsForReplay as l, redactSensitiveInObject as m, getHeaderCaseInsensitive as n, normalizeSystemPrompts as o, stripUnpairedOpenAIResponsesComputerReasoningIdsForReplay as p, getOpenAIResponsesHistoryItems as r, normalizeToolCallId as s, createOpenAIResponsesHistoryPayload as t, sanitizeOpenAIResponsesAssistantHistoryItemsForReplay as u, kCursorExecResolved as v, kStreamingPartialJson as w, kStreamingBlockKind as x, kStreamingArgumentsDone as y, sanitizeSchemaForOpenAIResponses as z };