@theokit/sdk 5.9.0 → 5.9.2

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 (168) hide show
  1. package/CHANGELOG.md +100 -0
  2. package/dist/{agent-6STOEBGQ.js → agent-GZVZXKME.js} +18 -17
  3. package/dist/{agent-6STOEBGQ.js.map → agent-GZVZXKME.js.map} +1 -1
  4. package/dist/{agent-ZM4FDDL7.cjs → agent-WQ4LLTSY.cjs} +19 -18
  5. package/dist/{agent-ZM4FDDL7.cjs.map → agent-WQ4LLTSY.cjs.map} +1 -1
  6. package/dist/agent-session-store-ODD3IZCW.js +6 -0
  7. package/dist/{agent-session-store-AFML3AXC.js.map → agent-session-store-ODD3IZCW.js.map} +1 -1
  8. package/dist/agent-session-store-SVEJHSUA.cjs +23 -0
  9. package/dist/{agent-session-store-MTSIY3MH.cjs.map → agent-session-store-SVEJHSUA.cjs.map} +1 -1
  10. package/dist/auth/index.cjs +8 -7
  11. package/dist/auth/index.cjs.map +1 -1
  12. package/dist/auth/index.js +3 -2
  13. package/dist/auth/index.js.map +1 -1
  14. package/dist/{chunk-TC4RWP3Y.js → chunk-47Z6LP3I.js} +3 -3
  15. package/dist/{chunk-TC4RWP3Y.js.map → chunk-47Z6LP3I.js.map} +1 -1
  16. package/dist/{chunk-DDRX4LYS.js → chunk-7QJYKVP6.js} +3 -3
  17. package/dist/{chunk-DDRX4LYS.js.map → chunk-7QJYKVP6.js.map} +1 -1
  18. package/dist/{chunk-TTBIQTO5.cjs → chunk-DLUCTZ56.cjs} +15 -15
  19. package/dist/{chunk-TTBIQTO5.cjs.map → chunk-DLUCTZ56.cjs.map} +1 -1
  20. package/dist/chunk-EHD25JBZ.cjs +10 -0
  21. package/dist/chunk-EHD25JBZ.cjs.map +1 -0
  22. package/dist/{chunk-NOO6GZTZ.js → chunk-EVH3OUMY.js} +13 -12
  23. package/dist/chunk-EVH3OUMY.js.map +1 -0
  24. package/dist/{chunk-5522X223.js → chunk-EXI7EHDN.js} +4 -4
  25. package/dist/{chunk-5522X223.js.map → chunk-EXI7EHDN.js.map} +1 -1
  26. package/dist/{chunk-PSLCVSCS.cjs → chunk-FR6COQXZ.cjs} +6 -6
  27. package/dist/{chunk-PSLCVSCS.cjs.map → chunk-FR6COQXZ.cjs.map} +1 -1
  28. package/dist/{chunk-JOFVLOFY.js → chunk-FTZTZBCU.js} +12 -4
  29. package/dist/chunk-FTZTZBCU.js.map +1 -0
  30. package/dist/{chunk-HOHR75KF.js → chunk-HI3W37FY.js} +4 -3
  31. package/dist/chunk-HI3W37FY.js.map +1 -0
  32. package/dist/chunk-HU666T3Q.cjs +1891 -0
  33. package/dist/chunk-HU666T3Q.cjs.map +1 -0
  34. package/dist/{chunk-53RDNK3H.js → chunk-I2ORT6QD.js} +3 -3
  35. package/dist/{chunk-53RDNK3H.js.map → chunk-I2ORT6QD.js.map} +1 -1
  36. package/dist/{chunk-BM6PDJW3.cjs → chunk-JU76WCW7.cjs} +113 -112
  37. package/dist/chunk-JU76WCW7.cjs.map +1 -0
  38. package/dist/{chunk-J4SA2ZEJ.cjs → chunk-KIKKTW5O.cjs} +4 -4
  39. package/dist/{chunk-J4SA2ZEJ.cjs.map → chunk-KIKKTW5O.cjs.map} +1 -1
  40. package/dist/{chunk-5WR33BHA.cjs → chunk-KXKT3HSD.cjs} +4 -4
  41. package/dist/{chunk-5WR33BHA.cjs.map → chunk-KXKT3HSD.cjs.map} +1 -1
  42. package/dist/{chunk-UKBBYVNS.js → chunk-M2CCHC66.js} +3 -3
  43. package/dist/{chunk-UKBBYVNS.js.map → chunk-M2CCHC66.js.map} +1 -1
  44. package/dist/{chunk-OCEQ6DW2.cjs → chunk-N6OEX5TN.cjs} +2 -2
  45. package/dist/chunk-N6OEX5TN.cjs.map +1 -0
  46. package/dist/{chunk-QDQQYRJI.js → chunk-N7KYUNFO.js} +3 -3
  47. package/dist/{chunk-QDQQYRJI.js.map → chunk-N7KYUNFO.js.map} +1 -1
  48. package/dist/{chunk-7GDHFV2M.js → chunk-OPAKPEPG.js} +2 -2
  49. package/dist/chunk-OPAKPEPG.js.map +1 -0
  50. package/dist/{chunk-UNZOJVVC.js → chunk-OZLQ6ZFM.js} +3 -3
  51. package/dist/{chunk-UNZOJVVC.js.map → chunk-OZLQ6ZFM.js.map} +1 -1
  52. package/dist/{chunk-PYFBS6OQ.js → chunk-PEIV7LOU.js} +22 -21
  53. package/dist/chunk-PEIV7LOU.js.map +1 -0
  54. package/dist/chunk-Q7GYMXVC.js +8 -0
  55. package/dist/chunk-Q7GYMXVC.js.map +1 -0
  56. package/dist/{chunk-ARMFXTY6.cjs → chunk-QY3CIMUV.cjs} +34 -33
  57. package/dist/chunk-QY3CIMUV.cjs.map +1 -0
  58. package/dist/{chunk-B3XXQX6L.cjs → chunk-RX3CFWQ2.cjs} +6 -6
  59. package/dist/{chunk-B3XXQX6L.cjs.map → chunk-RX3CFWQ2.cjs.map} +1 -1
  60. package/dist/chunk-SGC7LSHF.cjs +18 -0
  61. package/dist/{chunk-R3ZQBPA5.cjs.map → chunk-SGC7LSHF.cjs.map} +1 -1
  62. package/dist/{chunk-RA7IE4NK.cjs → chunk-SKDNCTXG.cjs} +4 -3
  63. package/dist/chunk-SKDNCTXG.cjs.map +1 -0
  64. package/dist/chunk-SVCPJRUB.js +1874 -0
  65. package/dist/chunk-SVCPJRUB.js.map +1 -0
  66. package/dist/{chunk-EJROML3Q.js → chunk-TX56N7FR.js} +4 -3
  67. package/dist/chunk-TX56N7FR.js.map +1 -0
  68. package/dist/{chunk-76PIKR4P.cjs → chunk-VZ2JZ2EH.cjs} +5 -5
  69. package/dist/{chunk-76PIKR4P.cjs.map → chunk-VZ2JZ2EH.cjs.map} +1 -1
  70. package/dist/{chunk-T5KOSR5Y.cjs → chunk-X7Z2FEI7.cjs} +8 -8
  71. package/dist/{chunk-T5KOSR5Y.cjs.map → chunk-X7Z2FEI7.cjs.map} +1 -1
  72. package/dist/{chunk-2WXHA33T.js → chunk-XERM7PDQ.js} +3 -3
  73. package/dist/{chunk-2WXHA33T.js.map → chunk-XERM7PDQ.js.map} +1 -1
  74. package/dist/{chunk-KTA7YTZQ.cjs → chunk-XKZFIP7Z.cjs} +4 -4
  75. package/dist/{chunk-KTA7YTZQ.cjs.map → chunk-XKZFIP7Z.cjs.map} +1 -1
  76. package/dist/{chunk-MEUBLCM4.cjs → chunk-YEHQ3SIC.cjs} +4 -3
  77. package/dist/chunk-YEHQ3SIC.cjs.map +1 -0
  78. package/dist/{chunk-YIFFF23U.cjs → chunk-ZAM7BJXJ.cjs} +5 -5
  79. package/dist/{chunk-YIFFF23U.cjs.map → chunk-ZAM7BJXJ.cjs.map} +1 -1
  80. package/dist/{chunk-R2C3HXR3.js → chunk-ZDF2IJKC.js} +3 -3
  81. package/dist/{chunk-R2C3HXR3.js.map → chunk-ZDF2IJKC.js.map} +1 -1
  82. package/dist/{chunk-PQCTDMUI.js → chunk-ZHWKT2NI.js} +3 -3
  83. package/dist/{chunk-PQCTDMUI.js.map → chunk-ZHWKT2NI.js.map} +1 -1
  84. package/dist/{chunk-GZV6AVRL.cjs → chunk-ZWACQM5U.cjs} +11 -3
  85. package/dist/chunk-ZWACQM5U.cjs.map +1 -0
  86. package/dist/{compact-session-RBPLUPCK.cjs → compact-session-4QHBBGEY.cjs} +16 -15
  87. package/dist/{compact-session-RBPLUPCK.cjs.map → compact-session-4QHBBGEY.cjs.map} +1 -1
  88. package/dist/{compact-session-2N3ZYJTW.js → compact-session-PVAWTKKL.js} +7 -6
  89. package/dist/{compact-session-2N3ZYJTW.js.map → compact-session-PVAWTKKL.js.map} +1 -1
  90. package/dist/context/index.cjs +6 -6
  91. package/dist/context/index.js +3 -3
  92. package/dist/context-3FZRAO5K.js +7 -0
  93. package/dist/{context-SXR2HLHT.js.map → context-3FZRAO5K.js.map} +1 -1
  94. package/dist/{context-ZOULM2RB.cjs → context-B5J4GX2F.cjs} +7 -7
  95. package/dist/{context-ZOULM2RB.cjs.map → context-B5J4GX2F.cjs.map} +1 -1
  96. package/dist/cron.cjs +18 -17
  97. package/dist/cron.js +17 -16
  98. package/dist/eval.cjs +17 -16
  99. package/dist/eval.cjs.map +1 -1
  100. package/dist/eval.js +16 -15
  101. package/dist/eval.js.map +1 -1
  102. package/dist/fs-session-store-LCZBM3LT.js +10 -0
  103. package/dist/{fs-session-store-STZZFXH2.js.map → fs-session-store-LCZBM3LT.js.map} +1 -1
  104. package/dist/{fs-session-store-JHBJFKVV.cjs → fs-session-store-SVEMRE4K.cjs} +5 -5
  105. package/dist/{fs-session-store-JHBJFKVV.cjs.map → fs-session-store-SVEMRE4K.cjs.map} +1 -1
  106. package/dist/{index-manager-ONQJSWX5.js → index-manager-6B2UF5S3.js} +5 -5
  107. package/dist/{index-manager-ONQJSWX5.js.map → index-manager-6B2UF5S3.js.map} +1 -1
  108. package/dist/{index-manager-ZGJN25FD.cjs → index-manager-M3FHJCHQ.cjs} +6 -6
  109. package/dist/{index-manager-ZGJN25FD.cjs.map → index-manager-M3FHJCHQ.cjs.map} +1 -1
  110. package/dist/index.cjs +58 -57
  111. package/dist/index.cjs.map +1 -1
  112. package/dist/index.d.cts +30 -3
  113. package/dist/index.d.ts +30 -3
  114. package/dist/index.js +21 -20
  115. package/dist/index.js.map +1 -1
  116. package/dist/{inject-session-YNNOE3O6.js → inject-session-O24XGRR6.js} +5 -5
  117. package/dist/{inject-session-YNNOE3O6.js.map → inject-session-O24XGRR6.js.map} +1 -1
  118. package/dist/{inject-session-3FPXJDJP.cjs → inject-session-OMLFL2V3.cjs} +7 -7
  119. package/dist/{inject-session-3FPXJDJP.cjs.map → inject-session-OMLFL2V3.cjs.map} +1 -1
  120. package/dist/internal/memory/adapters/index.cjs +3 -2
  121. package/dist/internal/memory/adapters/index.js +2 -1
  122. package/dist/internal/memory/storage/index.cjs +32 -32
  123. package/dist/internal/memory/storage/index.js +3 -3
  124. package/dist/internal/persistence/persistence-schema.d.cts +1 -1
  125. package/dist/internal/persistence/persistence-schema.d.ts +1 -1
  126. package/dist/internal/providers/catalog-loader.d.ts +30 -3
  127. package/dist/internal/runtime/hooks/hooks-source.d.ts +24 -0
  128. package/dist/internal/runtime-fetch.d.ts +1 -0
  129. package/dist/models.cjs +12 -11
  130. package/dist/models.cjs.map +1 -1
  131. package/dist/models.js +4 -3
  132. package/dist/models.js.map +1 -1
  133. package/dist/persistence.cjs +7 -7
  134. package/dist/persistence.js +2 -2
  135. package/dist/providers.cjs +6 -5
  136. package/dist/providers.js +4 -3
  137. package/dist/{session-transcript-VTBTCGQX.js → session-transcript-AR7IBICT.js} +3 -3
  138. package/dist/{session-transcript-VTBTCGQX.js.map → session-transcript-AR7IBICT.js.map} +1 -1
  139. package/dist/{session-transcript-LGHSNVY5.cjs → session-transcript-RACG7BK2.cjs} +16 -16
  140. package/dist/{session-transcript-LGHSNVY5.cjs.map → session-transcript-RACG7BK2.cjs.map} +1 -1
  141. package/dist/subscription/index.cjs +2 -1
  142. package/dist/subscription/index.cjs.map +1 -1
  143. package/dist/subscription/index.js +2 -1
  144. package/dist/subscription/index.js.map +1 -1
  145. package/docs/error-codes.md +16 -16
  146. package/package.json +2 -2
  147. package/dist/agent-session-store-AFML3AXC.js +0 -6
  148. package/dist/agent-session-store-MTSIY3MH.cjs +0 -23
  149. package/dist/chunk-7GDHFV2M.js.map +0 -1
  150. package/dist/chunk-ARMFXTY6.cjs.map +0 -1
  151. package/dist/chunk-BM6PDJW3.cjs.map +0 -1
  152. package/dist/chunk-EJROML3Q.js.map +0 -1
  153. package/dist/chunk-GZV6AVRL.cjs.map +0 -1
  154. package/dist/chunk-HOHR75KF.js.map +0 -1
  155. package/dist/chunk-JOFVLOFY.js.map +0 -1
  156. package/dist/chunk-MEUBLCM4.cjs.map +0 -1
  157. package/dist/chunk-MFZODA5Y.js +0 -583
  158. package/dist/chunk-MFZODA5Y.js.map +0 -1
  159. package/dist/chunk-NOO6GZTZ.js.map +0 -1
  160. package/dist/chunk-OCEQ6DW2.cjs.map +0 -1
  161. package/dist/chunk-PYFBS6OQ.js.map +0 -1
  162. package/dist/chunk-R3ZQBPA5.cjs +0 -18
  163. package/dist/chunk-RA7IE4NK.cjs.map +0 -1
  164. package/dist/chunk-YRJA2POB.cjs +0 -601
  165. package/dist/chunk-YRJA2POB.cjs.map +0 -1
  166. package/dist/context-SXR2HLHT.js +0 -7
  167. package/dist/fs-session-store-STZZFXH2.js +0 -10
  168. package/dist/provider-catalog.json +0 -1295
@@ -0,0 +1,8 @@
1
+ // src/internal/runtime-fetch.ts
2
+ function boundFetch(override) {
3
+ return override ?? globalThis.fetch.bind(globalThis);
4
+ }
5
+
6
+ export { boundFetch };
7
+ //# sourceMappingURL=chunk-Q7GYMXVC.js.map
8
+ //# sourceMappingURL=chunk-Q7GYMXVC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/internal/runtime-fetch.ts"],"names":[],"mappings":";AAiCO,SAAS,WAAW,QAAA,EAAuC;AAChE,EAAA,OAAO,QAAA,IAAY,UAAA,CAAW,KAAA,CAAM,IAAA,CAAK,UAAU,CAAA;AACrD","file":"chunk-Q7GYMXVC.js","sourcesContent":["/**\n * The global `fetch`, bound to its own receiver.\n *\n * ## Why this exists\n *\n * `this.fetchImpl = options.fetch ?? fetch` detaches the global. Node's undici tolerates that;\n * **workerd does not** — calling the reference as a property of another object, or as a bare function\n * in a module where `this` is `undefined`, throws:\n *\n * Illegal invocation: function called with incorrect `this` reference.\n *\n * Measured on 2026-09-28, on a real Cloudflare deploy, after two filesystem defects in this package\n * had been cleared and the turn finally reached the model:\n *\n * agent turn failed (AGENT_ERROR): openrouter transport failure on /v1/chat/completions:\n * Illegal invocation: function called with incorrect `this` reference.\n *\n * Thirteen call sites across eleven files wrote that expression, so fixing the one that happened to\n * run would have left twelve identical landmines — every other provider, the memory adapter, the\n * credential resolver, the cloud-run client — each a deploy that fails on the first request through\n * it.\n *\n * ## Why binding, and not a call-site trick\n *\n * `(0, this.fetchImpl)(url)` also works and has to be remembered at every invocation. Binding where\n * the reference is TAKEN fixes every call that reference will ever receive, and puts the rule in one\n * place a test can sweep for.\n *\n * An injected `fetch` is returned untouched: it is a caller's own function, already carrying whatever\n * receiver it needs, and binding it would break every suite that asserts on the double it passed in.\n *\n * @internal\n */\nexport function boundFetch(override?: typeof fetch): typeof fetch {\n return override ?? globalThis.fetch.bind(globalThis);\n}\n"]}
@@ -6,12 +6,13 @@ var chunkWPO3VCY4_cjs = require('./chunk-WPO3VCY4.cjs');
6
6
  var chunkQOGNZMHD_cjs = require('./chunk-QOGNZMHD.cjs');
7
7
  var chunkYSTXFWQE_cjs = require('./chunk-YSTXFWQE.cjs');
8
8
  var chunkFRITRLZQ_cjs = require('./chunk-FRITRLZQ.cjs');
9
- var chunkGZV6AVRL_cjs = require('./chunk-GZV6AVRL.cjs');
9
+ var chunkZWACQM5U_cjs = require('./chunk-ZWACQM5U.cjs');
10
10
  var chunkJ5623RIV_cjs = require('./chunk-J5623RIV.cjs');
11
11
  var chunk3EE6LVWT_cjs = require('./chunk-3EE6LVWT.cjs');
12
- var chunkYRJA2POB_cjs = require('./chunk-YRJA2POB.cjs');
12
+ var chunkHU666T3Q_cjs = require('./chunk-HU666T3Q.cjs');
13
13
  var chunkNVXXWAU7_cjs = require('./chunk-NVXXWAU7.cjs');
14
14
  var chunkNAGPKWOD_cjs = require('./chunk-NAGPKWOD.cjs');
15
+ var chunkEHD25JBZ_cjs = require('./chunk-EHD25JBZ.cjs');
15
16
  var chunkUNFBHV46_cjs = require('./chunk-UNFBHV46.cjs');
16
17
  var chunk6LHQPOMI_cjs = require('./chunk-6LHQPOMI.cjs');
17
18
  var fs = require('fs');
@@ -101,7 +102,7 @@ async function loadOne(dir, entryName) {
101
102
  if (plugin !== null && typeof plugin === "object" && plugin.kind === "model-provider") {
102
103
  const profile = plugin.profile;
103
104
  if (profile !== void 0 && typeof profile === "object") {
104
- chunkYRJA2POB_cjs.registerProvider(profile);
105
+ chunkHU666T3Q_cjs.registerProvider(profile);
105
106
  }
106
107
  }
107
108
  return;
@@ -498,7 +499,7 @@ var AnthropicClient = class {
498
499
  constructor(options) {
499
500
  this.options = options;
500
501
  this.baseUrl = options.baseUrl ?? "https://api.anthropic.com";
501
- this.fetchImpl = options.fetch ?? fetch;
502
+ this.fetchImpl = chunkEHD25JBZ_cjs.boundFetch(options.fetch);
502
503
  }
503
504
  options;
504
505
  name = "anthropic";
@@ -747,7 +748,7 @@ async function resolveBedrockToken(region) {
747
748
  return cachedToken.value;
748
749
  }
749
750
  try {
750
- const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-ARMFXTY6.cjs', document.baseURI).href)));
751
+ const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-QY3CIMUV.cjs', document.baseURI).href)));
751
752
  const gen = r("@aws/bedrock-token-generator");
752
753
  if (typeof gen.getToken !== "function") return void 0;
753
754
  const providers = r("@aws-sdk/credential-providers");
@@ -765,7 +766,7 @@ async function resolveBedrockToken(region) {
765
766
  var BedrockAnthropicClient = class {
766
767
  constructor(options) {
767
768
  this.options = options;
768
- this.fetchImpl = options.fetch ?? fetch;
769
+ this.fetchImpl = chunkEHD25JBZ_cjs.boundFetch(options.fetch);
769
770
  }
770
771
  options;
771
772
  name = "bedrock";
@@ -781,10 +782,10 @@ var BedrockAnthropicClient = class {
781
782
  );
782
783
  }
783
784
  async *stream(request, signal) {
784
- const region = chunkYRJA2POB_cjs.inferRegionFromModelId(request.model) ?? process.env.AWS_REGION ?? "us-east-1";
785
+ const region = chunkHU666T3Q_cjs.inferRegionFromModelId(request.model) ?? process.env.AWS_REGION ?? "us-east-1";
785
786
  const token = await this.resolveTokenOrThrow(region);
786
- const bareModel = chunkYRJA2POB_cjs.stripBedrockPrefix(request.model);
787
- const baseUrl = this.options.baseUrl ?? chunkYRJA2POB_cjs.resolveBedrockBaseUrl(request.model);
787
+ const bareModel = chunkHU666T3Q_cjs.stripBedrockPrefix(request.model);
788
+ const baseUrl = this.options.baseUrl ?? chunkHU666T3Q_cjs.resolveBedrockBaseUrl(request.model);
788
789
  const endpoint = `/model/${encodeURIComponent(bareModel)}/invoke`;
789
790
  const url = `${baseUrl}${endpoint}`;
790
791
  const response = await postAnthropicRequest({
@@ -988,7 +989,7 @@ var OllamaNativeClient = class {
988
989
  this.options = options;
989
990
  const raw = (options.baseUrl ?? "http://localhost:11434").replace(/\/+$/, "");
990
991
  this.baseUrl = raw.replace(/\/v1$/i, "");
991
- this.fetchImpl = options.fetch ?? fetch;
992
+ this.fetchImpl = chunkEHD25JBZ_cjs.boundFetch(options.fetch);
992
993
  }
993
994
  options;
994
995
  name = "ollama";
@@ -1244,7 +1245,7 @@ function resolveBaseUrl() {
1244
1245
  }
1245
1246
  async function httpRequest(path, options) {
1246
1247
  const url = `${resolveBaseUrl()}${path}`;
1247
- const fetchFn = options.fetchFn ?? globalThis.fetch;
1248
+ const fetchFn = chunkEHD25JBZ_cjs.boundFetch(options.fetchFn);
1248
1249
  const headers = {
1249
1250
  "content-type": "application/json",
1250
1251
  authorization: `Bearer ${options.apiKey}`,
@@ -1519,7 +1520,7 @@ var OpenAIClient = class {
1519
1520
  this.options = options;
1520
1521
  this.baseUrl = (options.baseUrl ?? "https://api.openai.com").replace(/\/+$/, "");
1521
1522
  this.chatPath = options.chatCompletionsPath ?? deriveChatPath(this.baseUrl);
1522
- this.fetchImpl = options.fetch ?? fetch;
1523
+ this.fetchImpl = chunkEHD25JBZ_cjs.boundFetch(options.fetch);
1523
1524
  }
1524
1525
  options;
1525
1526
  name = "openai";
@@ -2250,7 +2251,7 @@ var ResponsesApiClient = class {
2250
2251
  this.options = options;
2251
2252
  this.name = options.providerName ?? "openai-responses";
2252
2253
  this.baseUrl = (options.baseUrl ?? "https://api.openai.com/v1").replace(/\/+$/, "");
2253
- this.fetchImpl = options.fetch ?? fetch;
2254
+ this.fetchImpl = chunkEHD25JBZ_cjs.boundFetch(options.fetch);
2254
2255
  }
2255
2256
  options;
2256
2257
  name;
@@ -2515,7 +2516,7 @@ async function resolveVertexAccessToken() {
2515
2516
  async function getAuthClientOrThrow() {
2516
2517
  let mod;
2517
2518
  try {
2518
- const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-ARMFXTY6.cjs', document.baseURI).href)));
2519
+ const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-QY3CIMUV.cjs', document.baseURI).href)));
2519
2520
  mod = r("google-auth-library");
2520
2521
  } catch (err) {
2521
2522
  const isModuleMissing = err instanceof Error && (err.message.includes("Cannot find module") || err.code === "MODULE_NOT_FOUND");
@@ -2549,7 +2550,7 @@ function resolveVertexLocation() {
2549
2550
  var VertexAnthropicClient = class {
2550
2551
  constructor(options) {
2551
2552
  this.options = options;
2552
- this.fetchImpl = options.fetch ?? fetch;
2553
+ this.fetchImpl = chunkEHD25JBZ_cjs.boundFetch(options.fetch);
2553
2554
  }
2554
2555
  options;
2555
2556
  name = "vertex_anthropic";
@@ -2576,8 +2577,8 @@ var VertexAnthropicClient = class {
2576
2577
  const projectId = this.resolveProjectOrThrow();
2577
2578
  const location = this.options.location ?? resolveVertexLocation();
2578
2579
  const accessToken = await this.resolveTokenOrThrow();
2579
- const baseUrl = chunkYRJA2POB_cjs.resolveVertexBaseUrl({ projectId, location, modelDialect: "anthropic" });
2580
- const bareModel = chunkYRJA2POB_cjs.stripVertexPrefix(request.model);
2580
+ const baseUrl = chunkHU666T3Q_cjs.resolveVertexBaseUrl({ projectId, location, modelDialect: "anthropic" });
2581
+ const bareModel = chunkHU666T3Q_cjs.stripVertexPrefix(request.model);
2581
2582
  const endpoint = `/models/${encodeURIComponent(bareModel)}:rawPredict`;
2582
2583
  const url = `${baseUrl}${endpoint}`;
2583
2584
  const response = await postAnthropicRequest({
@@ -2626,9 +2627,9 @@ var VertexGeminiClient = class {
2626
2627
  { code: "auth_failed" }
2627
2628
  );
2628
2629
  }
2629
- const baseUrl = chunkYRJA2POB_cjs.resolveVertexBaseUrl({ projectId, location, modelDialect: "gemini" });
2630
+ const baseUrl = chunkHU666T3Q_cjs.resolveVertexBaseUrl({ projectId, location, modelDialect: "gemini" });
2630
2631
  const url = `${baseUrl}/chat/completions`;
2631
- const innerFetch = this.options.fetch ?? fetch;
2632
+ const innerFetch = chunkEHD25JBZ_cjs.boundFetch(this.options.fetch);
2632
2633
  const rewriteFetch = (_input, init) => innerFetch(url, init);
2633
2634
  const inner = new OpenAIClient({
2634
2635
  apiKey: accessToken,
@@ -2648,7 +2649,7 @@ var VertexRouterClient = class {
2648
2649
  options;
2649
2650
  name = "vertex";
2650
2651
  async *stream(request, signal) {
2651
- const dialect = chunkYRJA2POB_cjs.inferModelDialect(request.model);
2652
+ const dialect = chunkHU666T3Q_cjs.inferModelDialect(request.model);
2652
2653
  if (dialect === "anthropic") {
2653
2654
  const inner2 = new VertexAnthropicClient(this.options);
2654
2655
  return yield* inner2.stream(request, signal);
@@ -2660,7 +2661,7 @@ var VertexRouterClient = class {
2660
2661
 
2661
2662
  // src/internal/llm/router.ts
2662
2663
  function resolveProviderChain(options) {
2663
- chunkYRJA2POB_cjs.registerBuiltins();
2664
+ chunkHU666T3Q_cjs.registerBuiltins();
2664
2665
  return buildChain(options);
2665
2666
  }
2666
2667
  function buildChain(options) {
@@ -2685,7 +2686,7 @@ function buildChain(options) {
2685
2686
  return clients;
2686
2687
  }
2687
2688
  function buildTransport(name, routerOptions, perCallBaseUrl) {
2688
- const baseProfile = chunkYRJA2POB_cjs.getProviderProfile(name);
2689
+ const baseProfile = chunkHU666T3Q_cjs.getProviderProfile(name);
2689
2690
  if (baseProfile === void 0) return void 0;
2690
2691
  const profile = routerOptions.extractToolCallsFromContent === true && baseProfile.extractToolCallsFromContent !== true ? { ...baseProfile, extractToolCallsFromContent: true } : baseProfile;
2691
2692
  const resilience = routerOptions.onRateLimit !== void 0 ? { onRateLimit: routerOptions.onRateLimit } : {};
@@ -2780,7 +2781,7 @@ function warnUnknownProvidersInApiKeys(apiKeys) {
2780
2781
  if (apiKeys === void 0) return;
2781
2782
  for (const name of Object.keys(apiKeys)) {
2782
2783
  if (warnedProviders.has(name)) continue;
2783
- const profile = chunkYRJA2POB_cjs.getProviderProfile(name);
2784
+ const profile = chunkHU666T3Q_cjs.getProviderProfile(name);
2784
2785
  if (profile === void 0) {
2785
2786
  warnedProviders.add(name);
2786
2787
  chunk6LHQPOMI_cjs.diag(
@@ -2955,7 +2956,7 @@ function checkProviderPrefix(key, provider) {
2955
2956
  function registerPluginProviderProfiles(entries) {
2956
2957
  let registered = 0;
2957
2958
  for (const entry of entries) {
2958
- chunkYRJA2POB_cjs.registerProvider(entry.profile);
2959
+ chunkHU666T3Q_cjs.registerProvider(entry.profile);
2959
2960
  registered += 1;
2960
2961
  }
2961
2962
  return registered;
@@ -3039,7 +3040,7 @@ function shouldUseRealLocalRuntime(apiKey) {
3039
3040
  function inferProviderFromApiKey(apiKey) {
3040
3041
  const provider = chunkFRITRLZQ_cjs.providerFromApiKeyPrefix(apiKey);
3041
3042
  if (provider === void 0) return void 0;
3042
- return chunkYRJA2POB_cjs.getProviderProfile(provider) === void 0 ? void 0 : provider;
3043
+ return chunkHU666T3Q_cjs.getProviderProfile(provider) === void 0 ? void 0 : provider;
3043
3044
  }
3044
3045
  function detectPrimaryProvider() {
3045
3046
  if (process.env.ANTHROPIC_API_KEY !== void 0 && process.env.ANTHROPIC_API_KEY.length > 0) {
@@ -3066,7 +3067,7 @@ function warnProviderPrecedenceOnce(asked, used) {
3066
3067
  }
3067
3068
  var pluginProvidersAnnounced = false;
3068
3069
  function resolveRunProvider(options) {
3069
- chunkYRJA2POB_cjs.registerBuiltins();
3070
+ chunkHU666T3Q_cjs.registerBuiltins();
3070
3071
  const profiles = options.pluginManager?.aggregated.providerProfiles ?? [];
3071
3072
  const registered = registerPluginProviderProfiles(profiles);
3072
3073
  if (registered > 0 && !pluginProvidersAnnounced) {
@@ -3076,7 +3077,7 @@ function resolveRunProvider(options) {
3076
3077
  `);
3077
3078
  }
3078
3079
  const parsedModel = chunk3EE6LVWT_cjs.parseModelId(options.model?.id);
3079
- const modelInferredProvider = parsedModel.provider !== void 0 && chunkYRJA2POB_cjs.getProviderProfile(parsedModel.provider) !== void 0 ? parsedModel.provider : void 0;
3080
+ const modelInferredProvider = parsedModel.provider !== void 0 && chunkHU666T3Q_cjs.getProviderProfile(parsedModel.provider) !== void 0 ? parsedModel.provider : void 0;
3080
3081
  const keyInferredProvider = inferProviderFromApiKey(options.agentOptions.apiKey);
3081
3082
  const primary = options.agentOptions.providers?.routes?.[0]?.provider ?? keyInferredProvider ?? modelInferredProvider ?? detectPrimaryProvider();
3082
3083
  warnProviderPrecedenceOnce(modelInferredProvider, primary);
@@ -3159,7 +3160,7 @@ async function runPreCompactBounded(handler, ctx, timeoutMs, onError) {
3159
3160
  }
3160
3161
  async function compactSessionTranscript(opts) {
3161
3162
  const prior = await opts.store.readRecords(opts.loc.agentId);
3162
- const history = chunkGZV6AVRL_cjs.reconstructMessages(prior);
3163
+ const history = chunkZWACQM5U_cjs.reconstructMessages(prior);
3163
3164
  const compressible = [];
3164
3165
  for (const m of history) {
3165
3166
  const text = plainText(m.content);
@@ -3196,7 +3197,7 @@ async function compactSessionTranscript(opts) {
3196
3197
  }
3197
3198
  const summary = `${COMPACT_SUMMARY_MARKER}
3198
3199
  ${summaryBody}`;
3199
- const transcript = chunkGZV6AVRL_cjs.SessionTranscript.fromRecords(prior, {
3200
+ const transcript = chunkZWACQM5U_cjs.SessionTranscript.fromRecords(prior, {
3200
3201
  cwd: opts.loc.cwd,
3201
3202
  sessionId: opts.sessionId,
3202
3203
  model: opts.loc.model ?? "unknown"
@@ -3216,9 +3217,9 @@ function resolveSummarizerRoute(opts) {
3216
3217
  }
3217
3218
  function buildDefaultSummarizer(opts) {
3218
3219
  return async (messages) => {
3219
- chunkYRJA2POB_cjs.registerBuiltins();
3220
+ chunkHU666T3Q_cjs.registerBuiltins();
3220
3221
  const modelPrefix = opts.agentModel.includes("/") ? opts.agentModel.slice(0, opts.agentModel.indexOf("/")) : void 0;
3221
- const prefixProfile = modelPrefix !== void 0 ? chunkYRJA2POB_cjs.getProviderProfile(modelPrefix) : void 0;
3222
+ const prefixProfile = modelPrefix !== void 0 ? chunkHU666T3Q_cjs.getProviderProfile(modelPrefix) : void 0;
3222
3223
  const prefixUsable = prefixProfile !== void 0 && (prefixProfile.authType !== "api_key" || prefixProfile.envVars.some((v) => (process.env[v] ?? "").length > 0));
3223
3224
  const route = resolveSummarizerRoute({
3224
3225
  keyProvider: inferProviderFromApiKey(opts.apiKey),
@@ -3322,5 +3323,5 @@ exports.shouldUseFixtureMode = shouldUseFixtureMode;
3322
3323
  exports.shouldUseRealLocalRuntime = shouldUseRealLocalRuntime;
3323
3324
  exports.tryFirstEvent = tryFirstEvent;
3324
3325
  exports.validateApiKeyShape = validateApiKeyShape;
3325
- //# sourceMappingURL=chunk-ARMFXTY6.cjs.map
3326
- //# sourceMappingURL=chunk-ARMFXTY6.cjs.map
3326
+ //# sourceMappingURL=chunk-QY3CIMUV.cjs.map
3327
+ //# sourceMappingURL=chunk-QY3CIMUV.cjs.map