@theokit/sdk 5.14.0 → 5.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/{agent-T34LCGQM.js → agent-66U5QCPF.js} +18 -17
  3. package/dist/{agent-T34LCGQM.js.map → agent-66U5QCPF.js.map} +1 -1
  4. package/dist/{agent-DExqjqYy.d.cts → agent-BL4kxgwq.d.cts} +30 -214
  5. package/dist/{agent-Dfw3VsIX.d.ts → agent-ByDx7K30.d.ts} +30 -214
  6. package/dist/{agent-TL4K7BTG.cjs → agent-CB27KF6O.cjs} +19 -18
  7. package/dist/{agent-TL4K7BTG.cjs.map → agent-CB27KF6O.cjs.map} +1 -1
  8. package/dist/agent.d.ts +2 -3
  9. package/dist/{batch-EP3FCL6D.js → batch-N2XDYZED.js} +4 -4
  10. package/dist/{batch-EP3FCL6D.js.map → batch-N2XDYZED.js.map} +1 -1
  11. package/dist/{batch-IZ5EDKJ5.cjs → batch-VFR2MAUE.cjs} +7 -7
  12. package/dist/{batch-IZ5EDKJ5.cjs.map → batch-VFR2MAUE.cjs.map} +1 -1
  13. package/dist/{chunk-ZOL3L4EH.js → chunk-26GI3OYA.js} +118 -21
  14. package/dist/chunk-26GI3OYA.js.map +1 -0
  15. package/dist/{chunk-2WY2OFSC.cjs → chunk-26UQG242.cjs} +616 -318
  16. package/dist/chunk-26UQG242.cjs.map +1 -0
  17. package/dist/{chunk-2C24NSNV.js → chunk-3BBTHFGJ.js} +3 -3
  18. package/dist/{chunk-2C24NSNV.js.map → chunk-3BBTHFGJ.js.map} +1 -1
  19. package/dist/{chunk-SNVYOX46.cjs → chunk-3E3VSMB6.cjs} +160 -63
  20. package/dist/chunk-3E3VSMB6.cjs.map +1 -0
  21. package/dist/{chunk-NP362THY.cjs → chunk-3F53FLQ7.cjs} +5 -7
  22. package/dist/chunk-3F53FLQ7.cjs.map +1 -0
  23. package/dist/{chunk-SXH37C7X.cjs → chunk-55LLQFHW.cjs} +6 -6
  24. package/dist/{chunk-SXH37C7X.cjs.map → chunk-55LLQFHW.cjs.map} +1 -1
  25. package/dist/{chunk-ZJAYFSVI.js → chunk-7ACS6P5Z.js} +5 -7
  26. package/dist/chunk-7ACS6P5Z.js.map +1 -0
  27. package/dist/{chunk-WDVG5R2Q.cjs → chunk-AUH2EVWY.cjs} +4 -3
  28. package/dist/chunk-AUH2EVWY.cjs.map +1 -0
  29. package/dist/chunk-BNEUB52I.cjs +55 -0
  30. package/dist/chunk-BNEUB52I.cjs.map +1 -0
  31. package/dist/chunk-BPL5CVZ5.js +53 -0
  32. package/dist/chunk-BPL5CVZ5.js.map +1 -0
  33. package/dist/{chunk-NVQSBRG6.js → chunk-CBBT42VX.js} +3 -3
  34. package/dist/{chunk-NVQSBRG6.js.map → chunk-CBBT42VX.js.map} +1 -1
  35. package/dist/chunk-CHKV2L2Y.cjs +416 -0
  36. package/dist/chunk-CHKV2L2Y.cjs.map +1 -0
  37. package/dist/{chunk-LXG6VL6R.cjs → chunk-FBIDOOJM.cjs} +3 -3
  38. package/dist/{chunk-LXG6VL6R.cjs.map → chunk-FBIDOOJM.cjs.map} +1 -1
  39. package/dist/{chunk-354F3OF5.js → chunk-FGGVSHDW.js} +3 -3
  40. package/dist/{chunk-354F3OF5.js.map → chunk-FGGVSHDW.js.map} +1 -1
  41. package/dist/{chunk-6OCJWGVD.cjs → chunk-FTXY4D44.cjs} +4 -4
  42. package/dist/{chunk-6OCJWGVD.cjs.map → chunk-FTXY4D44.cjs.map} +1 -1
  43. package/dist/chunk-INVEGVGO.js +405 -0
  44. package/dist/chunk-INVEGVGO.js.map +1 -0
  45. package/dist/{chunk-DF77RBF4.js → chunk-LCCT5ZXJ.js} +6 -6
  46. package/dist/{chunk-DF77RBF4.js.map → chunk-LCCT5ZXJ.js.map} +1 -1
  47. package/dist/{chunk-G7XBVM3T.cjs → chunk-MHUOVS5I.cjs} +5 -5
  48. package/dist/{chunk-G7XBVM3T.cjs.map → chunk-MHUOVS5I.cjs.map} +1 -1
  49. package/dist/{chunk-CWQPQTUZ.cjs → chunk-NEH3BPFD.cjs} +15 -15
  50. package/dist/{chunk-CWQPQTUZ.cjs.map → chunk-NEH3BPFD.cjs.map} +1 -1
  51. package/dist/{chunk-5AR6O7GW.js → chunk-NK5EOTDY.js} +3 -3
  52. package/dist/{chunk-5AR6O7GW.js.map → chunk-NK5EOTDY.js.map} +1 -1
  53. package/dist/{chunk-NAVUTK6X.js → chunk-O2RCS3SJ.js} +3 -3
  54. package/dist/{chunk-NAVUTK6X.js.map → chunk-O2RCS3SJ.js.map} +1 -1
  55. package/dist/{chunk-4TEGFMSP.cjs → chunk-P7QYG4RZ.cjs} +23 -15
  56. package/dist/chunk-P7QYG4RZ.cjs.map +1 -0
  57. package/dist/chunk-PPU2D4FZ.js +19 -0
  58. package/dist/chunk-PPU2D4FZ.js.map +1 -0
  59. package/dist/{chunk-AB4OPJLD.js → chunk-RGVMJU57.js} +3 -3
  60. package/dist/{chunk-AB4OPJLD.js.map → chunk-RGVMJU57.js.map} +1 -1
  61. package/dist/{chunk-4KBI37F3.cjs → chunk-RTDVSHJR.cjs} +5 -5
  62. package/dist/{chunk-4KBI37F3.cjs.map → chunk-RTDVSHJR.cjs.map} +1 -1
  63. package/dist/{chunk-CJN5CEI3.js → chunk-RZL2W4C3.js} +23 -15
  64. package/dist/chunk-RZL2W4C3.js.map +1 -0
  65. package/dist/chunk-SPEN7RJU.cjs +18 -0
  66. package/dist/{chunk-R5UQL2R5.cjs.map → chunk-SPEN7RJU.cjs.map} +1 -1
  67. package/dist/{chunk-BZK5QL3N.cjs → chunk-TRPRTZEH.cjs} +4 -4
  68. package/dist/{chunk-BZK5QL3N.cjs.map → chunk-TRPRTZEH.cjs.map} +1 -1
  69. package/dist/{chunk-ZF2LDKQQ.cjs → chunk-U3DW3WDE.cjs} +9 -8
  70. package/dist/chunk-U3DW3WDE.cjs.map +1 -0
  71. package/dist/{chunk-H7G65PNI.js → chunk-VCQ37TC5.js} +3 -3
  72. package/dist/{chunk-H7G65PNI.js.map → chunk-VCQ37TC5.js.map} +1 -1
  73. package/dist/{chunk-3ONIVO2I.js → chunk-VNRNZ3WI.js} +3 -3
  74. package/dist/{chunk-3ONIVO2I.js.map → chunk-VNRNZ3WI.js.map} +1 -1
  75. package/dist/{chunk-SDZ4XDWS.cjs → chunk-VWYFGE27.cjs} +9 -9
  76. package/dist/{chunk-SDZ4XDWS.cjs.map → chunk-VWYFGE27.cjs.map} +1 -1
  77. package/dist/{chunk-RN3XDZGS.js → chunk-WM646HEN.js} +4 -3
  78. package/dist/chunk-WM646HEN.js.map +1 -0
  79. package/dist/chunk-X7CE7Y5W.js +305 -0
  80. package/dist/chunk-X7CE7Y5W.js.map +1 -0
  81. package/dist/{chunk-CGH4BCIY.cjs → chunk-XE3CAY6Z.cjs} +5 -5
  82. package/dist/{chunk-CGH4BCIY.cjs.map → chunk-XE3CAY6Z.cjs.map} +1 -1
  83. package/dist/chunk-XOU3CL7S.cjs +312 -0
  84. package/dist/chunk-XOU3CL7S.cjs.map +1 -0
  85. package/dist/{chunk-ULEK4OM4.js → chunk-YKNBTHMD.js} +3 -3
  86. package/dist/{chunk-ULEK4OM4.js.map → chunk-YKNBTHMD.js.map} +1 -1
  87. package/dist/{chunk-GARVAUCU.js → chunk-ZQWRUJHE.js} +534 -236
  88. package/dist/chunk-ZQWRUJHE.js.map +1 -0
  89. package/dist/{compact-session-D2MQDB6G.cjs → compact-session-CHBJOYWP.cjs} +16 -16
  90. package/dist/{compact-session-D2MQDB6G.cjs.map → compact-session-CHBJOYWP.cjs.map} +1 -1
  91. package/dist/{compact-session-N2PPHQO6.js → compact-session-F3J3FMEU.js} +7 -7
  92. package/dist/{compact-session-N2PPHQO6.js.map → compact-session-F3J3FMEU.js.map} +1 -1
  93. package/dist/{cron-CK2v0VWA.d.cts → cron-B7KH9sHW.d.cts} +2 -2
  94. package/dist/{cron-BubDpFJG.d.ts → cron-FEO7UAQF.d.ts} +2 -2
  95. package/dist/cron.cjs +18 -17
  96. package/dist/cron.d.cts +4 -3
  97. package/dist/cron.d.ts +4 -3
  98. package/dist/cron.js +17 -16
  99. package/dist/eval.cjs +17 -16
  100. package/dist/eval.cjs.map +1 -1
  101. package/dist/eval.js +16 -15
  102. package/dist/eval.js.map +1 -1
  103. package/dist/fs-session-store-CYNTEPJZ.cjs +20 -0
  104. package/dist/{fs-session-store-S2AXVJIX.cjs.map → fs-session-store-CYNTEPJZ.cjs.map} +1 -1
  105. package/dist/fs-session-store-MYQEVUFL.js +11 -0
  106. package/dist/{fs-session-store-6ZCCJX3K.js.map → fs-session-store-MYQEVUFL.js.map} +1 -1
  107. package/dist/{index-manager-HO456AVW.cjs → index-manager-2KH75BRW.cjs} +7 -7
  108. package/dist/{index-manager-HO456AVW.cjs.map → index-manager-2KH75BRW.cjs.map} +1 -1
  109. package/dist/{index-manager-QDH56FER.js → index-manager-NF2WRLOU.js} +6 -6
  110. package/dist/{index-manager-QDH56FER.js.map → index-manager-NF2WRLOU.js.map} +1 -1
  111. package/dist/index.cjs +66 -262
  112. package/dist/index.cjs.map +1 -1
  113. package/dist/index.d.cts +10 -46
  114. package/dist/index.d.ts +10 -46
  115. package/dist/index.js +27 -227
  116. package/dist/index.js.map +1 -1
  117. package/dist/{inject-session-J26SHHIO.js → inject-session-LC2TROHM.js} +3 -3
  118. package/dist/{inject-session-J26SHHIO.js.map → inject-session-LC2TROHM.js.map} +1 -1
  119. package/dist/{inject-session-3ICZIJ2N.cjs → inject-session-T4RXANG3.cjs} +4 -4
  120. package/dist/{inject-session-3ICZIJ2N.cjs.map → inject-session-T4RXANG3.cjs.map} +1 -1
  121. package/dist/internal/agent-loop/doom-loop-tracker.d.ts +3 -0
  122. package/dist/internal/agent-loop/types.d.ts +6 -0
  123. package/dist/internal/error-mappers/anthropic.d.ts +3 -0
  124. package/dist/internal/error-mappers/openai-compatible.d.ts +2 -3
  125. package/dist/internal/llm/hermes-tool-extract.d.ts +2 -0
  126. package/dist/internal/local-agent/local-agent-dispatch.d.ts +3 -1
  127. package/dist/internal/local-agent/send-queue.d.ts +31 -0
  128. package/dist/internal/mcp/client.d.ts +2 -0
  129. package/dist/internal/mcp/oauth-bearer.d.ts +2 -0
  130. package/dist/internal/memory/adapters/index.cjs +3 -3
  131. package/dist/internal/memory/adapters/index.js +2 -2
  132. package/dist/internal/memory/dreaming/phases.d.ts +15 -0
  133. package/dist/internal/memory/dreaming/run.d.ts +29 -0
  134. package/dist/internal/memory/sdk-memory-peer-loader.d.ts +2 -0
  135. package/dist/internal/memory/storage/index.cjs +51 -35
  136. package/dist/internal/memory/storage/index.d.cts +2 -0
  137. package/dist/internal/memory/storage/index.d.ts +2 -0
  138. package/dist/internal/memory/storage/index.js +4 -4
  139. package/dist/internal/persistence/cwd-mutex.d.cts +4 -2
  140. package/dist/internal/persistence/cwd-mutex.d.ts +4 -2
  141. package/dist/internal/persistence/index.cjs +4 -4
  142. package/dist/internal/persistence/index.js +2 -2
  143. package/dist/internal/persistence/sqlite-session-store.d.cts +25 -0
  144. package/dist/internal/persistence/sqlite-session-store.d.ts +25 -0
  145. package/dist/internal/providers/registry.d.ts +5 -1
  146. package/dist/mcp-auth.cjs +25 -307
  147. package/dist/mcp-auth.cjs.map +1 -1
  148. package/dist/mcp-auth.js +5 -305
  149. package/dist/mcp-auth.js.map +1 -1
  150. package/dist/models.cjs +9 -9
  151. package/dist/models.js +2 -2
  152. package/dist/persistence.cjs +9 -4
  153. package/dist/persistence.cjs.map +1 -1
  154. package/dist/persistence.d.cts +744 -40
  155. package/dist/persistence.d.ts +744 -40
  156. package/dist/persistence.js +3 -2
  157. package/dist/persistence.js.map +1 -1
  158. package/dist/providers.cjs +4 -4
  159. package/dist/providers.js +2 -2
  160. package/dist/sandbox/docker-sandbox.d.cts +58 -0
  161. package/dist/sandbox/docker-sandbox.d.ts +58 -0
  162. package/dist/sandbox/index.cjs +129 -1
  163. package/dist/sandbox/index.cjs.map +1 -1
  164. package/dist/sandbox/index.d.cts +1 -0
  165. package/dist/sandbox/index.d.ts +1 -0
  166. package/dist/sandbox/index.js +132 -5
  167. package/dist/sandbox/index.js.map +1 -1
  168. package/dist/{sdk-agent-DwzHcuxy.d.cts → sdk-agent-BA_6_wtc.d.cts} +30 -2
  169. package/dist/{sdk-agent-a3fW1xUK.d.ts → sdk-agent-CnwPODYH.d.ts} +30 -2
  170. package/dist/session-store-Dh07jr9N.d.cts +209 -0
  171. package/dist/session-store-Dh07jr9N.d.ts +209 -0
  172. package/dist/sqlite-session-store-BbcpKY1L.d.ts +64 -0
  173. package/dist/sqlite-session-store-TKXtT4ON.d.cts +64 -0
  174. package/dist/subagents-loader-KLWF4QPD.cjs +16 -0
  175. package/dist/{subagents-loader-TXOA5EJJ.cjs.map → subagents-loader-KLWF4QPD.cjs.map} +1 -1
  176. package/dist/subagents-loader-SXETS2F2.js +7 -0
  177. package/dist/{subagents-loader-Z744TAKD.js.map → subagents-loader-SXETS2F2.js.map} +1 -1
  178. package/dist/subagents-loader.cjs +2 -2
  179. package/dist/subagents-loader.d.cts +3 -2
  180. package/dist/subagents-loader.d.ts +3 -2
  181. package/dist/subagents-loader.js +1 -1
  182. package/dist/types/agent.d.ts +14 -1
  183. package/dist/types/budget-tracker.d.ts +6 -2
  184. package/dist/types/hooks.d.ts +7 -1
  185. package/dist/types/mcp.d.ts +14 -0
  186. package/dist/types/run.d.ts +15 -1
  187. package/dist/workflow.d.cts +1 -1
  188. package/dist/workflow.d.ts +1 -1
  189. package/docs/adr/mutation-testing-scope.md +12 -2
  190. package/docs/error-codes.md +41 -40
  191. package/docs/harness-capability-map.md +32 -6
  192. package/package.json +1 -1
  193. package/dist/chunk-2WY2OFSC.cjs.map +0 -1
  194. package/dist/chunk-4TEGFMSP.cjs.map +0 -1
  195. package/dist/chunk-6CXRYPG7.cjs +0 -211
  196. package/dist/chunk-6CXRYPG7.cjs.map +0 -1
  197. package/dist/chunk-CJN5CEI3.js.map +0 -1
  198. package/dist/chunk-GARVAUCU.js.map +0 -1
  199. package/dist/chunk-MSEL5E5P.js +0 -204
  200. package/dist/chunk-MSEL5E5P.js.map +0 -1
  201. package/dist/chunk-NP362THY.cjs.map +0 -1
  202. package/dist/chunk-Q5EWJPRY.js +0 -18
  203. package/dist/chunk-Q5EWJPRY.js.map +0 -1
  204. package/dist/chunk-R5UQL2R5.cjs +0 -18
  205. package/dist/chunk-RN3XDZGS.js.map +0 -1
  206. package/dist/chunk-SNVYOX46.cjs.map +0 -1
  207. package/dist/chunk-WDVG5R2Q.cjs.map +0 -1
  208. package/dist/chunk-ZF2LDKQQ.cjs.map +0 -1
  209. package/dist/chunk-ZJAYFSVI.js.map +0 -1
  210. package/dist/chunk-ZOL3L4EH.js.map +0 -1
  211. package/dist/fs-session-store-6ZCCJX3K.js +0 -11
  212. package/dist/fs-session-store-S2AXVJIX.cjs +0 -20
  213. package/dist/subagents-loader-TXOA5EJJ.cjs +0 -16
  214. package/dist/subagents-loader-Z744TAKD.js +0 -7
@@ -1,15 +1,15 @@
1
1
  'use strict';
2
2
 
3
- var chunkSXH37C7X_cjs = require('./chunk-SXH37C7X.cjs');
3
+ var chunk55LLQFHW_cjs = require('./chunk-55LLQFHW.cjs');
4
4
  var chunkYJNYDJ2T_cjs = require('./chunk-YJNYDJ2T.cjs');
5
- var chunkNP362THY_cjs = require('./chunk-NP362THY.cjs');
5
+ var chunk3F53FLQ7_cjs = require('./chunk-3F53FLQ7.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
9
  var chunk3WKWBYPO_cjs = require('./chunk-3WKWBYPO.cjs');
10
10
  var chunkKX5QXLBS_cjs = require('./chunk-KX5QXLBS.cjs');
11
11
  var chunk3EE6LVWT_cjs = require('./chunk-3EE6LVWT.cjs');
12
- var chunk4TEGFMSP_cjs = require('./chunk-4TEGFMSP.cjs');
12
+ var chunkP7QYG4RZ_cjs = require('./chunk-P7QYG4RZ.cjs');
13
13
  var chunkNVXXWAU7_cjs = require('./chunk-NVXXWAU7.cjs');
14
14
  var chunk5645PMVU_cjs = require('./chunk-5645PMVU.cjs');
15
15
  var chunkEHD25JBZ_cjs = require('./chunk-EHD25JBZ.cjs');
@@ -116,7 +116,7 @@ async function loadOne(dir, entryName) {
116
116
  if (plugin !== null && typeof plugin === "object" && plugin.kind === "model-provider") {
117
117
  const profile = plugin.profile;
118
118
  if (profile !== void 0 && typeof profile === "object") {
119
- chunk4TEGFMSP_cjs.registerProvider(profile);
119
+ chunkP7QYG4RZ_cjs.registerProvider(profile);
120
120
  }
121
121
  }
122
122
  return;
@@ -134,7 +134,7 @@ function mapAnthropicError(args) {
134
134
  const { status, body, headers, endpoint } = args;
135
135
  const code = mapAnthropicStatusToCode(status, body);
136
136
  const message = formatMessage(status, code);
137
- const metadata = chunkNP362THY_cjs.buildErrorMetadata({
137
+ const metadata = chunk3F53FLQ7_cjs.buildErrorMetadata({
138
138
  provider: "anthropic",
139
139
  endpoint,
140
140
  code,
@@ -148,7 +148,7 @@ function mapAnthropicError(args) {
148
148
  if (status === 429) {
149
149
  return new chunkCEGU5AVD_cjs.RateLimitError(message, { code: "anthropic_rate_limit", metadata });
150
150
  }
151
- if (status === 400) {
151
+ if (status === 400 || code === "model_unavailable") {
152
152
  return new chunkCEGU5AVD_cjs.ConfigurationError(message, {
153
153
  code: `anthropic_${code}`,
154
154
  metadata
@@ -163,17 +163,23 @@ function mapAnthropicError(args) {
163
163
  return new chunkCEGU5AVD_cjs.UnknownAgentError(message, { code: "anthropic_unknown", metadata });
164
164
  }
165
165
  function mapAnthropicStatusToCode(status, body) {
166
- if (status === 400) {
167
- const text = JSON.stringify(body ?? "").toLowerCase();
168
- if (text.includes("context") && (text.includes("too long") || text.includes("too_long") || text.includes("length"))) {
169
- return "context_too_long";
170
- }
171
- if (text.includes("filtered") || text.includes("content policy") || text.includes("content_policy")) {
172
- return "content_filtered";
173
- }
174
- return "invalid_request";
166
+ if (status === 400) return classify400(body);
167
+ if (status === 404 && isModelNotFound(body)) return "model_unavailable";
168
+ return chunk3F53FLQ7_cjs.httpStatusToErrorCode(status);
169
+ }
170
+ function classify400(body) {
171
+ const text = JSON.stringify(body ?? "").toLowerCase();
172
+ if (text.includes("context") && (text.includes("too long") || text.includes("too_long") || text.includes("length"))) {
173
+ return "context_too_long";
175
174
  }
176
- return chunkNP362THY_cjs.httpStatusToErrorCode(status);
175
+ if (text.includes("filtered") || text.includes("content policy") || text.includes("content_policy")) {
176
+ return "content_filtered";
177
+ }
178
+ return "invalid_request";
179
+ }
180
+ function isModelNotFound(body) {
181
+ const error = body?.error;
182
+ return error?.type === "not_found_error" && typeof error.message === "string" && /^model\b/i.test(error.message);
177
183
  }
178
184
  function formatMessage(status, code) {
179
185
  return `Anthropic API error: ${code} (HTTP ${status})`;
@@ -577,6 +583,12 @@ var CONTENT_FRAMES = /* @__PURE__ */ new Set([
577
583
  "content_block_delta",
578
584
  "message_delta"
579
585
  ]);
586
+ function redactedParseCause(err) {
587
+ const name = err instanceof Error ? err.name : "Error";
588
+ const cause = new Error(`${name}: frame body is not valid JSON (body withheld)`);
589
+ cause.name = name;
590
+ return cause;
591
+ }
580
592
  function parseAnthropicFrame(record) {
581
593
  try {
582
594
  return JSON.parse(record.data);
@@ -586,7 +598,7 @@ function parseAnthropicFrame(record) {
586
598
  if (CONTENT_FRAMES.has(event)) {
587
599
  throw new chunkCEGU5AVD_cjs.NetworkError(
588
600
  `Anthropic SSE ${event} frame (${size}) is not valid JSON; the turn would lose content`,
589
- { code: "stream_malformed_frame", cause: parseErr }
601
+ { code: "stream_malformed_frame", cause: redactedParseCause(parseErr) }
590
602
  );
591
603
  }
592
604
  chunkRNXXYF22_cjs.diag(
@@ -755,10 +767,10 @@ function classifyBedrockError(args, awsType, message) {
755
767
  return "invalid_request";
756
768
  }
757
769
  if (awsType.includes("Timeout")) return "timeout";
758
- return chunkNP362THY_cjs.httpStatusToErrorCode(args.status);
770
+ return chunk3F53FLQ7_cjs.httpStatusToErrorCode(args.status);
759
771
  }
760
772
  function buildBedrockMetadata(args, code) {
761
- return chunkNP362THY_cjs.buildErrorMetadata({
773
+ return chunk3F53FLQ7_cjs.buildErrorMetadata({
762
774
  provider: "bedrock",
763
775
  endpoint: args.endpoint,
764
776
  code,
@@ -768,7 +780,7 @@ function buildBedrockMetadata(args, code) {
768
780
  });
769
781
  }
770
782
  function mapBedrockError(args) {
771
- const parsed = chunkNP362THY_cjs.parseErrorBody(args.body);
783
+ const parsed = chunk3F53FLQ7_cjs.parseErrorBody(args.body);
772
784
  const awsType = parsed.__type ?? "";
773
785
  const message = parsed.message ?? parsed.Message ?? "Bedrock request failed";
774
786
  const code = classifyBedrockError(args, awsType, message);
@@ -802,7 +814,7 @@ async function resolveBedrockToken(region) {
802
814
  return cachedToken.value;
803
815
  }
804
816
  try {
805
- const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-SNVYOX46.cjs', document.baseURI).href)));
817
+ const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-3E3VSMB6.cjs', document.baseURI).href)));
806
818
  const gen = r("@aws/bedrock-token-generator");
807
819
  if (typeof gen.getToken !== "function") return void 0;
808
820
  const providers = r("@aws-sdk/credential-providers");
@@ -836,10 +848,10 @@ var BedrockAnthropicClient = class {
836
848
  );
837
849
  }
838
850
  async *stream(request, signal) {
839
- const region = chunk4TEGFMSP_cjs.inferRegionFromModelId(request.model) ?? process.env.AWS_REGION ?? "us-east-1";
851
+ const region = chunkP7QYG4RZ_cjs.inferRegionFromModelId(request.model) ?? process.env.AWS_REGION ?? "us-east-1";
840
852
  const token = await this.resolveTokenOrThrow(region);
841
- const bareModel = chunk4TEGFMSP_cjs.stripBedrockPrefix(request.model);
842
- const baseUrl = this.options.baseUrl ?? chunk4TEGFMSP_cjs.resolveBedrockBaseUrl(request.model);
853
+ const bareModel = chunkP7QYG4RZ_cjs.stripBedrockPrefix(request.model);
854
+ const baseUrl = this.options.baseUrl ?? chunkP7QYG4RZ_cjs.resolveBedrockBaseUrl(request.model);
843
855
  const endpoint = `/model/${encodeURIComponent(bareModel)}/invoke`;
844
856
  const url = `${baseUrl}${endpoint}`;
845
857
  const response = await postAnthropicRequest({
@@ -894,7 +906,7 @@ var FaultInjectingLlmClient = class {
894
906
  return yield* this.inner.stream(request, signal);
895
907
  }
896
908
  if (parsed.status >= 400) {
897
- throw chunkNP362THY_cjs.mapOpenAICompatibleError({
909
+ throw chunk3F53FLQ7_cjs.mapOpenAICompatibleError({
898
910
  providerId: this.name,
899
911
  status: parsed.status,
900
912
  body: parsed.body,
@@ -969,7 +981,7 @@ function mapOllamaTransportError(args) {
969
981
  if (args.providerId !== "ollama") return void 0;
970
982
  const causeCode = extractCauseCode(args.cause);
971
983
  if (causeCode !== "ECONNREFUSED" && causeCode !== "ENOTFOUND") return void 0;
972
- const metadata = chunkNP362THY_cjs.buildErrorMetadata({
984
+ const metadata = chunk3F53FLQ7_cjs.buildErrorMetadata({
973
985
  provider: "ollama",
974
986
  endpoint: args.endpoint,
975
987
  code: "network",
@@ -987,7 +999,7 @@ function mapOllamaHttpError(args) {
987
999
  const errString = extractErrorString(args.body).toLowerCase();
988
1000
  if (args.status === 404 && errString.includes("not found") && errString.includes("pull")) {
989
1001
  const modelHint = extractModelName(errString);
990
- const metadata = chunkNP362THY_cjs.buildErrorMetadata({
1002
+ const metadata = chunk3F53FLQ7_cjs.buildErrorMetadata({
991
1003
  provider: "ollama",
992
1004
  endpoint: args.endpoint,
993
1005
  code: "model_unavailable",
@@ -1002,7 +1014,7 @@ function mapOllamaHttpError(args) {
1002
1014
  );
1003
1015
  }
1004
1016
  if (args.status === 503 && errString.includes("model is loading")) {
1005
- const metadata = chunkNP362THY_cjs.buildErrorMetadata({
1017
+ const metadata = chunk3F53FLQ7_cjs.buildErrorMetadata({
1006
1018
  provider: "ollama",
1007
1019
  endpoint: args.endpoint,
1008
1020
  code: "server_error",
@@ -1089,7 +1101,7 @@ var OllamaNativeClient = class {
1089
1101
  endpoint: "/api/chat"
1090
1102
  });
1091
1103
  if (mapped !== void 0) throw mapped;
1092
- throw chunkNP362THY_cjs.mapOpenAICompatibleError({
1104
+ throw chunk3F53FLQ7_cjs.mapOpenAICompatibleError({
1093
1105
  providerId: "ollama",
1094
1106
  status: response.status,
1095
1107
  body: bodyJson,
@@ -1395,7 +1407,12 @@ function netOfCache(total, cacheReadTokens, cacheWriteTokens) {
1395
1407
  function normalizeOpenAIChat(raw) {
1396
1408
  const outputTokens = int(raw.completion_tokens);
1397
1409
  const completionDetails = raw.completion_tokens_details ?? {};
1398
- const split = splitChatCompletionsPrompt(raw);
1410
+ const rawDetails = raw.prompt_tokens_details ?? {};
1411
+ const details = { ...rawDetails };
1412
+ for (const key of ["cached_tokens", "cache_write_tokens"]) {
1413
+ if (sent(details[key]) && Number.isNaN(strictCount(details[key]))) details[key] = 0;
1414
+ }
1415
+ const split = splitChatCompletionsPrompt({ ...raw, prompt_tokens_details: details });
1399
1416
  const inputTokens = int(split.inputTokens);
1400
1417
  const cacheReadTokens = int(split.cacheReadTokens);
1401
1418
  const cacheWriteTokens = int(split.cacheWriteTokens);
@@ -1525,16 +1542,38 @@ function pickString(record, key) {
1525
1542
  // src/internal/llm/hermes-tool-extract.ts
1526
1543
  var HERMES_BLOCK = /<function=\s*([^>\s]+)\s*>([\s\S]*?)<\/tool_call>/g;
1527
1544
  var HERMES_PARAM = /<parameter=\s*([^>\s]+)\s*>([\s\S]*?)<\/parameter>/g;
1545
+ var CTRL_CALL_SRC = String.raw`print\(\s*default_api\.([A-Za-z_]\w*)\(([\s\S]*?)\)\s*\)(?=\s*(?:print\(\s*default_api\.|<ctrl\d+>|$))`;
1546
+ var CTRL_BLOCK = new RegExp(`<ctrl42>call\\s*((?:${CTRL_CALL_SRC}\\s*)+)(?=<ctrl\\d+>|$)`, "g");
1547
+ var CTRL_MARKER = "<ctrl42>call";
1548
+ var CTRL_PREFIX = "print(default_api.";
1528
1549
  function extractHermesToolCalls(content, makeId, allowedToolNames) {
1529
1550
  const isPromoted = (name) => name.length > 0 && (allowedToolNames === void 0 || allowedToolNames.has(name));
1530
1551
  const toolCalls = [];
1531
1552
  const droppedNames = [];
1553
+ const formats = /* @__PURE__ */ new Set();
1554
+ for (const block of content.matchAll(CTRL_BLOCK)) {
1555
+ for (const call of (block[1] ?? "").matchAll(new RegExp(CTRL_CALL_SRC, "g"))) {
1556
+ const name = call[1] ?? "";
1557
+ if (!isPromoted(name)) {
1558
+ if (allowedToolNames !== void 0) droppedNames.push(name);
1559
+ continue;
1560
+ }
1561
+ toolCalls.push({
1562
+ type: "tool_use",
1563
+ id: makeId(),
1564
+ name,
1565
+ input: parseCtrlArgs(call[2] ?? "")
1566
+ });
1567
+ formats.add("gemini-ctrl42");
1568
+ }
1569
+ }
1532
1570
  for (const block of content.matchAll(HERMES_BLOCK)) {
1533
1571
  const name = (block[1] ?? "").trim();
1534
1572
  if (!isPromoted(name)) {
1535
1573
  if (name.length > 0 && allowedToolNames !== void 0) droppedNames.push(name);
1536
1574
  continue;
1537
1575
  }
1576
+ formats.add("hermes");
1538
1577
  toolCalls.push({
1539
1578
  type: "tool_use",
1540
1579
  id: makeId(),
@@ -1543,10 +1582,37 @@ function extractHermesToolCalls(content, makeId, allowedToolNames) {
1543
1582
  });
1544
1583
  }
1545
1584
  const residualText = toolCalls.length === 0 ? content : content.replace(
1585
+ CTRL_BLOCK,
1586
+ (_full, calls) => keepUnpromotedCtrl(calls, isPromoted)
1587
+ ).replace(
1546
1588
  HERMES_BLOCK,
1547
1589
  (full, rawName) => isPromoted((rawName ?? "").trim()) ? "" : full
1548
1590
  ).trim();
1549
- return { toolCalls, residualText, droppedNames };
1591
+ return { toolCalls, residualText, droppedNames, formats: [...formats] };
1592
+ }
1593
+ function keepUnpromotedCtrl(calls, isPromoted) {
1594
+ const kept = [...calls.matchAll(new RegExp(CTRL_CALL_SRC, "g"))].filter((c) => !isPromoted(c[1] ?? "")).map((c) => c[0]);
1595
+ return kept.length === 0 ? "" : `<ctrl42>call
1596
+ ${kept.join("\n")}`;
1597
+ }
1598
+ var CTRL_ARG = /\s*([A-Za-z_]\w*)\s*=\s*("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|[^,]+)\s*(?:,|$)/y;
1599
+ function parseCtrlArgs(raw) {
1600
+ const input = {};
1601
+ CTRL_ARG.lastIndex = 0;
1602
+ for (let m = CTRL_ARG.exec(raw); m !== null; m = CTRL_ARG.exec(raw)) {
1603
+ input[m[1]] = parseCtrlValue(m[2].trim());
1604
+ }
1605
+ return chunkYSTXFWQE_cjs.sanitizeToolInput(input, { trim: true }).value;
1606
+ }
1607
+ function parseCtrlValue(v) {
1608
+ const q = v[0];
1609
+ if ((q === '"' || q === "'") && v.length >= 2 && v.endsWith(q)) {
1610
+ return v.slice(1, -1).replace(/\\(.)/g, (_, c) => c === "n" ? "\n" : c === "t" ? " " : c);
1611
+ }
1612
+ if (v === "True") return true;
1613
+ if (v === "False") return false;
1614
+ if (v === "None") return null;
1615
+ return /^-?\d+(\.\d+)?$/.test(v) ? Number(v) : v;
1550
1616
  }
1551
1617
  function parseHermesParams(inner) {
1552
1618
  const input = {};
@@ -1564,6 +1630,10 @@ var isStreamWs = (c) => c === " " || c === " " || c === "\n" || c === "\r";
1564
1630
  function streamToolCallBufferState(held, allowedToolNames, cap = DEFAULT_STREAM_BUFFER_CAP) {
1565
1631
  if (allowedToolNames.size === 0) return "impossible";
1566
1632
  const t = held.trimStart();
1633
+ if (t.startsWith("<c")) return ctrlState(t, held.length, allowedToolNames, cap);
1634
+ return functionMarkerState(held, t, allowedToolNames, cap);
1635
+ }
1636
+ function functionMarkerState(held, t, allowedToolNames, cap) {
1567
1637
  if (t.length < STREAM_MARKER.length) {
1568
1638
  return STREAM_MARKER.startsWith(t) ? "possible" : "impossible";
1569
1639
  }
@@ -1575,6 +1645,20 @@ function streamToolCallBufferState(held, allowedToolNames, cap = DEFAULT_STREAM_
1575
1645
  if (!nameOk) return "impossible";
1576
1646
  return held.length > cap ? "impossible" : "possible";
1577
1647
  }
1648
+ function ctrlState(t, heldLength, allowedToolNames, cap) {
1649
+ if (t.length < CTRL_MARKER.length) return CTRL_MARKER.startsWith(t) ? "possible" : "impossible";
1650
+ if (!t.startsWith(CTRL_MARKER)) return "impossible";
1651
+ const rest = t.slice(CTRL_MARKER.length).trimStart();
1652
+ if (rest.length <= CTRL_PREFIX.length)
1653
+ return CTRL_PREFIX.startsWith(rest) ? "possible" : "impossible";
1654
+ if (!rest.startsWith(CTRL_PREFIX)) return "impossible";
1655
+ const afterPrefix = rest.slice(CTRL_PREFIX.length);
1656
+ const paren = afterPrefix.indexOf("(");
1657
+ const name = paren === -1 ? afterPrefix : afterPrefix.slice(0, paren);
1658
+ if (!/^\w*$/.test(name)) return "impossible";
1659
+ const nameOk = paren === -1 ? someToolNameStartsWith(allowedToolNames, name) : allowedToolNames.has(name);
1660
+ return nameOk && heldLength <= cap ? "possible" : "impossible";
1661
+ }
1578
1662
  function parseStreamMarkerName(t) {
1579
1663
  let cursor = STREAM_MARKER.length;
1580
1664
  while (cursor < t.length && isStreamWs(t[cursor])) cursor += 1;
@@ -1763,7 +1847,7 @@ var OpenAIClient = class {
1763
1847
  endpoint: "/v1/chat/completions"
1764
1848
  });
1765
1849
  if (ollamaMapped !== void 0) throw ollamaMapped;
1766
- throw chunkNP362THY_cjs.mapOpenAICompatibleError({
1850
+ throw chunk3F53FLQ7_cjs.mapOpenAICompatibleError({
1767
1851
  providerId,
1768
1852
  status: response.status,
1769
1853
  body,
@@ -1799,7 +1883,7 @@ var OpenAIClient = class {
1799
1883
  }
1800
1884
  if (chunk.error !== void 0 && chunk.error !== null) {
1801
1885
  const status = typeof chunk.error.code === "number" ? chunk.error.code : 502;
1802
- throw chunkNP362THY_cjs.mapOpenAICompatibleError({
1886
+ throw chunk3F53FLQ7_cjs.mapOpenAICompatibleError({
1803
1887
  providerId,
1804
1888
  status,
1805
1889
  body: chunk,
@@ -1930,7 +2014,7 @@ var OpenAIStreamAccumulator = class {
1930
2014
  text = recovered.residualText;
1931
2015
  stopReason = "tool_use";
1932
2016
  chunkRNXXYF22_cjs.diag(
1933
- `[theokit-sdk] recovered ${recovered.toolCalls.length} leaked tool call(s) from assistant content (provider="${this.providerName}", names=${recovered.toolCalls.map((c) => c.name).join(",")})
2017
+ `[theokit-sdk] recovered ${recovered.toolCalls.length} leaked tool call(s) from assistant content (provider="${this.providerName}", format=${recovered.formats.join(",") || "hermes"}, names=${recovered.toolCalls.map((c) => c.name).join(",")})
1934
2018
  `
1935
2019
  );
1936
2020
  }
@@ -2483,7 +2567,7 @@ var ResponsesApiClient = class {
2483
2567
  body = JSON.parse(text);
2484
2568
  } catch {
2485
2569
  }
2486
- return chunkNP362THY_cjs.mapOpenAICompatibleError({
2570
+ return chunk3F53FLQ7_cjs.mapOpenAICompatibleError({
2487
2571
  providerId,
2488
2572
  status: response.status,
2489
2573
  body,
@@ -2519,7 +2603,7 @@ var ResponsesApiClient = class {
2519
2603
  const failure = ResponsesStreamAccumulator.failureMessage(event);
2520
2604
  if (failure !== void 0) {
2521
2605
  yield { type: "error", message: failure };
2522
- throw chunkNP362THY_cjs.mapOpenAICompatibleError({
2606
+ throw chunk3F53FLQ7_cjs.mapOpenAICompatibleError({
2523
2607
  providerId,
2524
2608
  status: 502,
2525
2609
  body: { error: { message: failure } },
@@ -2633,11 +2717,11 @@ function classifyVertexError(args, errStatus) {
2633
2717
  for (const rule of VERTEX_RULES) {
2634
2718
  if (rule.test(args.status, errStatus)) return rule.code;
2635
2719
  }
2636
- const shared = chunkNP362THY_cjs.httpStatusToErrorCode(args.status);
2720
+ const shared = chunk3F53FLQ7_cjs.httpStatusToErrorCode(args.status);
2637
2721
  return shared === "auth_failed" ? "auth_permission" : shared;
2638
2722
  }
2639
2723
  function vertexMetadata(args, code) {
2640
- return chunkNP362THY_cjs.buildErrorMetadata({
2724
+ return chunk3F53FLQ7_cjs.buildErrorMetadata({
2641
2725
  provider: "vertex",
2642
2726
  endpoint: args.endpoint,
2643
2727
  code,
@@ -2669,7 +2753,7 @@ var VERTEX_ERROR_BUILDERS = {
2669
2753
  unknown: (args, msg) => new chunkCEGU5AVD_cjs.UnknownAgentError(`Vertex unknown: ${msg}`, { metadata: vertexMetadata(args, "unknown") })
2670
2754
  };
2671
2755
  function mapVertexError(args) {
2672
- const parsed = chunkNP362THY_cjs.parseErrorBody(args.body);
2756
+ const parsed = chunk3F53FLQ7_cjs.parseErrorBody(args.body);
2673
2757
  const errStatus = parsed.error?.status ?? "";
2674
2758
  const message = parsed.error?.message ?? "Vertex request failed";
2675
2759
  const code = classifyVertexError(args, errStatus);
@@ -2691,7 +2775,7 @@ async function resolveVertexAccessToken() {
2691
2775
  async function getAuthClientOrThrow() {
2692
2776
  let mod;
2693
2777
  try {
2694
- const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-SNVYOX46.cjs', document.baseURI).href)));
2778
+ const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-3E3VSMB6.cjs', document.baseURI).href)));
2695
2779
  mod = r("google-auth-library");
2696
2780
  } catch (err) {
2697
2781
  const isModuleMissing = err instanceof Error && (err.message.includes("Cannot find module") || err.code === "MODULE_NOT_FOUND");
@@ -2752,8 +2836,8 @@ var VertexAnthropicClient = class {
2752
2836
  const projectId = this.resolveProjectOrThrow();
2753
2837
  const location = this.options.location ?? resolveVertexLocation();
2754
2838
  const accessToken = await this.resolveTokenOrThrow();
2755
- const baseUrl = chunk4TEGFMSP_cjs.resolveVertexBaseUrl({ projectId, location, modelDialect: "anthropic" });
2756
- const bareModel = chunk4TEGFMSP_cjs.stripVertexPrefix(request.model);
2839
+ const baseUrl = chunkP7QYG4RZ_cjs.resolveVertexBaseUrl({ projectId, location, modelDialect: "anthropic" });
2840
+ const bareModel = chunkP7QYG4RZ_cjs.stripVertexPrefix(request.model);
2757
2841
  const endpoint = `/models/${encodeURIComponent(bareModel)}:rawPredict`;
2758
2842
  const url = `${baseUrl}${endpoint}`;
2759
2843
  const response = await postAnthropicRequest({
@@ -2802,7 +2886,7 @@ var VertexGeminiClient = class {
2802
2886
  { code: "auth_failed" }
2803
2887
  );
2804
2888
  }
2805
- const baseUrl = chunk4TEGFMSP_cjs.resolveVertexBaseUrl({ projectId, location, modelDialect: "gemini" });
2889
+ const baseUrl = chunkP7QYG4RZ_cjs.resolveVertexBaseUrl({ projectId, location, modelDialect: "gemini" });
2806
2890
  const url = `${baseUrl}/chat/completions`;
2807
2891
  const innerFetch = chunkEHD25JBZ_cjs.boundFetch(this.options.fetch);
2808
2892
  const rewriteFetch = (_input, init) => innerFetch(url, init);
@@ -2824,7 +2908,7 @@ var VertexRouterClient = class {
2824
2908
  options;
2825
2909
  name = "vertex";
2826
2910
  async *stream(request, signal) {
2827
- const dialect = chunk4TEGFMSP_cjs.inferModelDialect(request.model);
2911
+ const dialect = chunkP7QYG4RZ_cjs.inferModelDialect(request.model);
2828
2912
  if (dialect === "anthropic") {
2829
2913
  const inner2 = new VertexAnthropicClient(this.options);
2830
2914
  return yield* inner2.stream(request, signal);
@@ -2836,7 +2920,7 @@ var VertexRouterClient = class {
2836
2920
 
2837
2921
  // src/internal/llm/router.ts
2838
2922
  function resolveProviderChain(options) {
2839
- chunk4TEGFMSP_cjs.registerBuiltins();
2923
+ chunkP7QYG4RZ_cjs.registerBuiltins();
2840
2924
  return buildChain(options);
2841
2925
  }
2842
2926
  function buildChain(options) {
@@ -2851,9 +2935,12 @@ function buildChain(options) {
2851
2935
  if (client !== void 0) clients.push(maybeWrapWithFaultInjection(client));
2852
2936
  };
2853
2937
  addClient(options.primary, options.baseUrl);
2854
- for (const fallback of options.fallback ?? []) addClient(fallback);
2938
+ for (const fallback of options.fallback ?? []) {
2939
+ warnUnknownFallback(fallback);
2940
+ addClient(fallback);
2941
+ }
2855
2942
  if (clients.length === 0) {
2856
- if (chunk4TEGFMSP_cjs.getProviderProfile(normalizeProviderName(options.primary)) === void 0) {
2943
+ if (chunkP7QYG4RZ_cjs.getProviderProfile(normalizeProviderName(options.primary)) === void 0) {
2857
2944
  throw new chunkCEGU5AVD_cjs.ConfigurationError(unregisteredProviderMessage(options.primary), {
2858
2945
  code: "provider_unresolved"
2859
2946
  });
@@ -2870,7 +2957,7 @@ function normalizeProviderName(name) {
2870
2957
  }
2871
2958
  function unregisteredProviderMessage(name) {
2872
2959
  const normalized = normalizeProviderName(name);
2873
- const caseOnlyMatch = chunk4TEGFMSP_cjs.listProviders().find(
2960
+ const caseOnlyMatch = chunkP7QYG4RZ_cjs.listProviders().find(
2874
2961
  (profile) => normalizeProviderName(profile.name) === normalized
2875
2962
  );
2876
2963
  if (caseOnlyMatch !== void 0) {
@@ -2878,11 +2965,11 @@ function unregisteredProviderMessage(name) {
2878
2965
  }
2879
2966
  const aliasMessage = caseOnlyAliasMessage(name, normalized);
2880
2967
  if (aliasMessage !== void 0) return aliasMessage;
2881
- const registered = chunk4TEGFMSP_cjs.listProviders().map((profile) => profile.name).sort((a, b) => a.localeCompare(b)).join(", ");
2968
+ const registered = chunkP7QYG4RZ_cjs.listProviders().map((profile) => profile.name).sort((a, b) => a.localeCompare(b)).join(", ");
2882
2969
  return `No provider client could be resolved: "${name}" is not a known provider. Registered providers: ${registered}.`;
2883
2970
  }
2884
2971
  function caseOnlyAliasMessage(name, normalized) {
2885
- for (const profile of chunk4TEGFMSP_cjs.listProviders()) {
2972
+ for (const profile of chunkP7QYG4RZ_cjs.listProviders()) {
2886
2973
  const alias = profile.aliases?.find((entry) => normalizeProviderName(entry) === normalized);
2887
2974
  if (alias === void 0) continue;
2888
2975
  return `No provider client could be resolved: "${name}" matches the alias "${alias}" of the registered provider "${profile.name}" only when case is ignored, and routes look provider names up in lowercase. Register the alias as "${normalized}", or route to "${profile.name}".`;
@@ -2890,11 +2977,11 @@ function caseOnlyAliasMessage(name, normalized) {
2890
2977
  return void 0;
2891
2978
  }
2892
2979
  function buildTransport(name, routerOptions, perCallBaseUrl) {
2893
- const baseProfile = chunk4TEGFMSP_cjs.getProviderProfile(name);
2980
+ const baseProfile = chunkP7QYG4RZ_cjs.getProviderProfile(name);
2894
2981
  if (baseProfile === void 0) return void 0;
2895
2982
  const profile = routerOptions.extractToolCallsFromContent === true && baseProfile.extractToolCallsFromContent !== true ? { ...baseProfile, extractToolCallsFromContent: true } : baseProfile;
2896
2983
  const resilience = routerOptions.onRateLimit !== void 0 ? { onRateLimit: routerOptions.onRateLimit } : {};
2897
- const ambient = chunkSXH37C7X_cjs.currentCredentialPool(name);
2984
+ const ambient = chunk55LLQFHW_cjs.currentCredentialPool(name);
2898
2985
  if (ambient !== void 0) {
2899
2986
  return new PoolAwareLlmClient(
2900
2987
  ambient,
@@ -2926,9 +3013,9 @@ function buildPoolOrSingle(args) {
2926
3013
  if (poolKeys !== void 0 && poolKeys.length >= 2) {
2927
3014
  const strategy = routerOptions.credentialPoolStrategy?.[name] ?? "fill_first";
2928
3015
  const entries = poolKeys.map(
2929
- (accessToken, priority) => chunkSXH37C7X_cjs.newPooledCredential({ provider: name, accessToken, priority, source: "manual" })
3016
+ (accessToken, priority) => chunk55LLQFHW_cjs.newPooledCredential({ provider: name, accessToken, priority, source: "manual" })
2930
3017
  );
2931
- const pool = new chunkSXH37C7X_cjs.CredentialPool(name, entries, strategy);
3018
+ const pool = new chunk55LLQFHW_cjs.CredentialPool(name, entries, strategy);
2932
3019
  const resilience = routerOptions.onRateLimit !== void 0 ? { onRateLimit: routerOptions.onRateLimit } : {};
2933
3020
  return new PoolAwareLlmClient(
2934
3021
  pool,
@@ -2985,7 +3072,7 @@ function warnUnknownProvidersInApiKeys(apiKeys) {
2985
3072
  if (apiKeys === void 0) return;
2986
3073
  for (const name of Object.keys(apiKeys)) {
2987
3074
  if (warnedProviders.has(name)) continue;
2988
- const profile = chunk4TEGFMSP_cjs.getProviderProfile(name);
3075
+ const profile = chunkP7QYG4RZ_cjs.getProviderProfile(name);
2989
3076
  if (profile === void 0) {
2990
3077
  warnedProviders.add(name);
2991
3078
  chunkRNXXYF22_cjs.diag(
@@ -2995,6 +3082,16 @@ function warnUnknownProvidersInApiKeys(apiKeys) {
2995
3082
  }
2996
3083
  }
2997
3084
  }
3085
+ function warnUnknownFallback(name) {
3086
+ const key = `fallback:${normalizeProviderName(name)}`;
3087
+ if (warnedProviders.has(key)) return;
3088
+ if (chunkP7QYG4RZ_cjs.getProviderProfile(normalizeProviderName(name)) !== void 0) return;
3089
+ warnedProviders.add(key);
3090
+ chunkRNXXYF22_cjs.diag(
3091
+ `[theokit-sdk] providers.fallback: unknown provider "${name}" (no profile registered) \u2014 dropped from the fallback chain
3092
+ `
3093
+ );
3094
+ }
2998
3095
  function resolveApiKey(envVars) {
2999
3096
  for (const v of envVars) {
3000
3097
  const value = process.env[v];
@@ -3160,7 +3257,7 @@ function checkProviderPrefix(key, provider) {
3160
3257
  function registerPluginProviderProfiles(entries) {
3161
3258
  let registered = 0;
3162
3259
  for (const entry of entries) {
3163
- chunk4TEGFMSP_cjs.registerProvider(entry.profile);
3260
+ chunkP7QYG4RZ_cjs.registerProvider(entry.profile);
3164
3261
  registered += 1;
3165
3262
  }
3166
3263
  return registered;
@@ -3244,7 +3341,7 @@ function shouldUseRealLocalRuntime(apiKey) {
3244
3341
  function inferProviderFromApiKey(apiKey) {
3245
3342
  const provider = chunkFRITRLZQ_cjs.providerFromApiKeyPrefix(apiKey);
3246
3343
  if (provider === void 0) return void 0;
3247
- return chunk4TEGFMSP_cjs.getProviderProfile(provider) === void 0 ? void 0 : provider;
3344
+ return chunkP7QYG4RZ_cjs.getProviderProfile(provider) === void 0 ? void 0 : provider;
3248
3345
  }
3249
3346
  function detectPrimaryProvider() {
3250
3347
  if (process.env.ANTHROPIC_API_KEY !== void 0 && process.env.ANTHROPIC_API_KEY.length > 0) {
@@ -3271,7 +3368,7 @@ function warnProviderPrecedenceOnce(asked, used) {
3271
3368
  }
3272
3369
  var pluginProvidersAnnounced = false;
3273
3370
  function resolveRunProvider(options) {
3274
- chunk4TEGFMSP_cjs.registerBuiltins();
3371
+ chunkP7QYG4RZ_cjs.registerBuiltins();
3275
3372
  const profiles = options.pluginManager?.aggregated.providerProfiles ?? [];
3276
3373
  const registered = registerPluginProviderProfiles(profiles);
3277
3374
  if (registered > 0 && !pluginProvidersAnnounced) {
@@ -3281,7 +3378,7 @@ function resolveRunProvider(options) {
3281
3378
  `);
3282
3379
  }
3283
3380
  const parsedModel = chunk3EE6LVWT_cjs.parseModelId(options.model?.id);
3284
- const modelInferredProvider = parsedModel.provider !== void 0 && chunk4TEGFMSP_cjs.getProviderProfile(parsedModel.provider) !== void 0 ? parsedModel.provider : void 0;
3381
+ const modelInferredProvider = parsedModel.provider !== void 0 && chunkP7QYG4RZ_cjs.getProviderProfile(parsedModel.provider) !== void 0 ? parsedModel.provider : void 0;
3285
3382
  const keyInferredProvider = inferProviderFromApiKey(options.agentOptions.apiKey);
3286
3383
  const primary = options.agentOptions.providers?.routes?.[0]?.provider ?? keyInferredProvider ?? modelInferredProvider ?? detectPrimaryProvider();
3287
3384
  warnProviderPrecedenceOnce(modelInferredProvider, primary);
@@ -3421,9 +3518,9 @@ function resolveSummarizerRoute(opts) {
3421
3518
  }
3422
3519
  function buildDefaultSummarizer(opts) {
3423
3520
  return async (messages) => {
3424
- chunk4TEGFMSP_cjs.registerBuiltins();
3521
+ chunkP7QYG4RZ_cjs.registerBuiltins();
3425
3522
  const modelPrefix = opts.agentModel.includes("/") ? opts.agentModel.slice(0, opts.agentModel.indexOf("/")) : void 0;
3426
- const prefixProfile = modelPrefix !== void 0 ? chunk4TEGFMSP_cjs.getProviderProfile(modelPrefix) : void 0;
3523
+ const prefixProfile = modelPrefix !== void 0 ? chunkP7QYG4RZ_cjs.getProviderProfile(modelPrefix) : void 0;
3427
3524
  const prefixUsable = prefixProfile !== void 0 && (prefixProfile.authType !== "api_key" || prefixProfile.envVars.some((v) => (process.env[v] ?? "").length > 0));
3428
3525
  const route = resolveSummarizerRoute({
3429
3526
  keyProvider: inferProviderFromApiKey(opts.apiKey),
@@ -3531,5 +3628,5 @@ exports.shouldUseRealLocalRuntime = shouldUseRealLocalRuntime;
3531
3628
  exports.trustFilePath = trustFilePath;
3532
3629
  exports.tryFirstEvent = tryFirstEvent;
3533
3630
  exports.validateApiKeyShape = validateApiKeyShape;
3534
- //# sourceMappingURL=chunk-SNVYOX46.cjs.map
3535
- //# sourceMappingURL=chunk-SNVYOX46.cjs.map
3631
+ //# sourceMappingURL=chunk-3E3VSMB6.cjs.map
3632
+ //# sourceMappingURL=chunk-3E3VSMB6.cjs.map