@theokit/sdk 4.51.1 → 4.52.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 (53) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/dist/{agent-QWNWBCQZ.js → agent-RDHK6MVT.js} +6 -5
  3. package/dist/{agent-QWNWBCQZ.js.map → agent-RDHK6MVT.js.map} +1 -1
  4. package/dist/{agent-2KSLHB6B.cjs → agent-U2R2R5JP.cjs} +7 -6
  5. package/dist/{agent-2KSLHB6B.cjs.map → agent-U2R2R5JP.cjs.map} +1 -1
  6. package/dist/auth/index.cjs +5 -0
  7. package/dist/auth/index.cjs.map +1 -1
  8. package/dist/auth/index.d.cts +15 -0
  9. package/dist/auth/index.d.ts +15 -0
  10. package/dist/auth/index.js +1 -0
  11. package/dist/auth/index.js.map +1 -1
  12. package/dist/{chunk-DRRSUUI5.js → chunk-42PLABFU.js} +3 -3
  13. package/dist/{chunk-DRRSUUI5.js.map → chunk-42PLABFU.js.map} +1 -1
  14. package/dist/{chunk-XI4L45SS.cjs → chunk-6GS7JI64.cjs} +43 -43
  15. package/dist/{chunk-XI4L45SS.cjs.map → chunk-6GS7JI64.cjs.map} +1 -1
  16. package/dist/{chunk-3BKWFISQ.cjs → chunk-CY7MIMI4.cjs} +3 -3
  17. package/dist/{chunk-3BKWFISQ.cjs.map → chunk-CY7MIMI4.cjs.map} +1 -1
  18. package/dist/chunk-FRITRLZQ.cjs +24 -0
  19. package/dist/chunk-FRITRLZQ.cjs.map +1 -0
  20. package/dist/{chunk-BVT6LFQ3.js → chunk-GNPI5IWZ.js} +3 -3
  21. package/dist/{chunk-BVT6LFQ3.js.map → chunk-GNPI5IWZ.js.map} +1 -1
  22. package/dist/{chunk-6CSIUJ5W.js → chunk-KELIQH7K.js} +6 -6
  23. package/dist/{chunk-6CSIUJ5W.js.map → chunk-KELIQH7K.js.map} +1 -1
  24. package/dist/{chunk-QVIUICFM.js → chunk-M5EK7N6R.js} +6 -14
  25. package/dist/chunk-M5EK7N6R.js.map +1 -0
  26. package/dist/chunk-NAF4L3T6.js +22 -0
  27. package/dist/chunk-NAF4L3T6.js.map +1 -0
  28. package/dist/{chunk-N6NUMXAJ.cjs → chunk-WLESQ3ZQ.cjs} +8 -16
  29. package/dist/chunk-WLESQ3ZQ.cjs.map +1 -0
  30. package/dist/{chunk-2S7IB4O3.cjs → chunk-ZNEE4WWQ.cjs} +5 -5
  31. package/dist/{chunk-2S7IB4O3.cjs.map → chunk-ZNEE4WWQ.cjs.map} +1 -1
  32. package/dist/{compact-session-AAFICMPQ.cjs → compact-session-FBVWO6B3.cjs} +12 -11
  33. package/dist/{compact-session-AAFICMPQ.cjs.map → compact-session-FBVWO6B3.cjs.map} +1 -1
  34. package/dist/{compact-session-LR73ESZX.js → compact-session-XLXC2CZN.js} +4 -3
  35. package/dist/{compact-session-LR73ESZX.js.map → compact-session-XLXC2CZN.js.map} +1 -1
  36. package/dist/cron.cjs +6 -5
  37. package/dist/cron.js +5 -4
  38. package/dist/eval.cjs +5 -4
  39. package/dist/eval.cjs.map +1 -1
  40. package/dist/eval.js +4 -3
  41. package/dist/eval.js.map +1 -1
  42. package/dist/index.cjs +28 -27
  43. package/dist/index.cjs.map +1 -1
  44. package/dist/index.js +7 -6
  45. package/dist/index.js.map +1 -1
  46. package/dist/{inject-session-KOGUD6KM.cjs → inject-session-UBAQ7I3G.cjs} +4 -4
  47. package/dist/{inject-session-KOGUD6KM.cjs.map → inject-session-UBAQ7I3G.cjs.map} +1 -1
  48. package/dist/{inject-session-6ZAFN7F7.js → inject-session-UEH5MAKU.js} +3 -3
  49. package/dist/{inject-session-6ZAFN7F7.js.map → inject-session-UEH5MAKU.js.map} +1 -1
  50. package/dist/internal/auth/api-key-prefix.d.ts +23 -0
  51. package/package.json +1 -1
  52. package/dist/chunk-N6NUMXAJ.cjs.map +0 -1
  53. package/dist/chunk-QVIUICFM.js.map +0 -1
@@ -0,0 +1,22 @@
1
+ // src/internal/auth/api-key-prefix.ts
2
+ var PREFIXES = {
3
+ "sk-or-": "openrouter",
4
+ "sk-ant-": "anthropic",
5
+ "sk-": "openai"
6
+ };
7
+ var BY_LENGTH = Object.entries(PREFIXES).sort(
8
+ (a, b) => b[0].length - a[0].length
9
+ );
10
+ function providerFromApiKeyPrefix(apiKey) {
11
+ if (apiKey === void 0) return void 0;
12
+ const key = apiKey.trim();
13
+ if (key.length === 0) return void 0;
14
+ for (const [prefix, provider] of BY_LENGTH) {
15
+ if (key.startsWith(prefix)) return provider;
16
+ }
17
+ return void 0;
18
+ }
19
+
20
+ export { providerFromApiKeyPrefix };
21
+ //# sourceMappingURL=chunk-NAF4L3T6.js.map
22
+ //# sourceMappingURL=chunk-NAF4L3T6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/internal/auth/api-key-prefix.ts"],"names":[],"mappings":";AAiBA,IAAM,QAAA,GAA6C;AAAA,EACjD,QAAA,EAAU,YAAA;AAAA,EACV,SAAA,EAAW,WAAA;AAAA,EACX,KAAA,EAAO;AACT,CAAA;AAYA,IAAM,SAAA,GAAsD,MAAA,CAAO,OAAA,CAAQ,QAAQ,CAAA,CAAE,IAAA;AAAA,EACnF,CAAC,GAAG,CAAA,KAAM,CAAA,CAAE,CAAC,CAAA,CAAE,MAAA,GAAS,CAAA,CAAE,CAAC,CAAA,CAAE;AAC/B,CAAA;AASO,SAAS,yBAAyB,MAAA,EAAgD;AACvF,EAAA,IAAI,MAAA,KAAW,QAAW,OAAO,MAAA;AACjC,EAAA,MAAM,GAAA,GAAM,OAAO,IAAA,EAAK;AACxB,EAAA,IAAI,GAAA,CAAI,MAAA,KAAW,CAAA,EAAG,OAAO,MAAA;AAC7B,EAAA,KAAA,MAAW,CAAC,MAAA,EAAQ,QAAQ,CAAA,IAAK,SAAA,EAAW;AAC1C,IAAA,IAAI,GAAA,CAAI,UAAA,CAAW,MAAM,CAAA,EAAG,OAAO,QAAA;AAAA,EACrC;AACA,EAAA,OAAO,MAAA;AACT","file":"chunk-NAF4L3T6.js","sourcesContent":["/**\n * \"Which provider issued this key?\" — the pure prefix answer.\n *\n * Lives in `auth/` and not beside the local-run helper that used to own it, because the question is\n * an auth question. The local-run path additionally refuses a provider it has no profile for; that\n * is its policy, not part of this answer, so it stays there and composes with this.\n *\n * Lives under `internal/` by FOLDER, and is PUBLIC by contract — re-exported from\n * `@theokit/sdk/auth`.\n *\n * Deliberately NOT tagged `@internal`: `tsconfig.base.json` sets `stripInternal: true`, so that tag\n * deletes the declaration from every emitted `.d.ts`. The symbol then exists at runtime and cannot\n * be imported with types — which is the exact defect this module was published to fix, reintroduced\n * one layer down by a docblock. Measured: usetheodev/theokit-sdk#283.\n */\n\n/** Prefix → provider. Order here is irrelevant: the lookup sorts. */\nconst PREFIXES: Readonly<Record<string, string>> = {\n \"sk-or-\": \"openrouter\",\n \"sk-ant-\": \"anthropic\",\n \"sk-\": \"openai\",\n};\n\n/**\n * Longest first, computed once.\n *\n * The ordering IS the correctness property, so it is derived rather than written down: every\n * OpenRouter and Anthropic key also starts with `sk-`, and a shortest-match-first scan resolves\n * them to OpenAI. That failure is invisible locally — it surfaces as a remote 401 from the wrong\n * endpoint, with a message that says nothing about prefixes. The previous implementation was\n * correct only because the entries happened to be written in a workable order; appending a longer\n * prefix, or sorting the table for readability, would have broken it silently.\n */\nconst BY_LENGTH: ReadonlyArray<readonly [string, string]> = Object.entries(PREFIXES).sort(\n (a, b) => b[0].length - a[0].length,\n);\n\n/**\n * The provider whose key prefix matches, or `undefined` when none does.\n *\n * `undefined` means \"cannot tell\" and never a guess: a wrong guess here routes a real credential to\n * the wrong endpoint. Whitespace-only and empty inputs are \"cannot tell\" too — they are what an\n * empty prompt submits, not a key.\n */\nexport function providerFromApiKeyPrefix(apiKey: string | undefined): string | undefined {\n if (apiKey === undefined) return undefined;\n const key = apiKey.trim();\n if (key.length === 0) return undefined;\n for (const [prefix, provider] of BY_LENGTH) {\n if (key.startsWith(prefix)) return provider;\n }\n return undefined;\n}\n"]}
@@ -4,6 +4,7 @@ var chunk4JBHSLQO_cjs = require('./chunk-4JBHSLQO.cjs');
4
4
  var chunkRAACTJ7C_cjs = require('./chunk-RAACTJ7C.cjs');
5
5
  var chunkE3OCRJU6_cjs = require('./chunk-E3OCRJU6.cjs');
6
6
  var chunk6JSIEDKL_cjs = require('./chunk-6JSIEDKL.cjs');
7
+ var chunkFRITRLZQ_cjs = require('./chunk-FRITRLZQ.cjs');
7
8
  var chunkECPL5RV6_cjs = require('./chunk-ECPL5RV6.cjs');
8
9
  var chunkAMYY3JHQ_cjs = require('./chunk-AMYY3JHQ.cjs');
9
10
  var chunkT6ZCG5AP_cjs = require('./chunk-T6ZCG5AP.cjs');
@@ -739,7 +740,7 @@ async function resolveBedrockToken(region) {
739
740
  return cachedToken.value;
740
741
  }
741
742
  try {
742
- const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-N6NUMXAJ.cjs', document.baseURI).href)));
743
+ const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-WLESQ3ZQ.cjs', document.baseURI).href)));
743
744
  const gen = r("@aws/bedrock-token-generator");
744
745
  if (typeof gen.getToken !== "function") return void 0;
745
746
  const providers = r("@aws-sdk/credential-providers");
@@ -2403,7 +2404,7 @@ async function resolveVertexAccessToken() {
2403
2404
  async function getAuthClientOrThrow() {
2404
2405
  let mod;
2405
2406
  try {
2406
- const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-N6NUMXAJ.cjs', document.baseURI).href)));
2407
+ const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-WLESQ3ZQ.cjs', document.baseURI).href)));
2407
2408
  mod = r("google-auth-library");
2408
2409
  } catch (err) {
2409
2410
  const isModuleMissing = err instanceof Error && (err.message.includes("Cannot find module") || err.code === "MODULE_NOT_FOUND");
@@ -2768,18 +2769,9 @@ function selectTransport(profile, apiKey) {
2768
2769
 
2769
2770
  // src/internal/local-agent/real-local-run-provider.ts
2770
2771
  function inferProviderFromApiKey(apiKey) {
2771
- if (apiKey === void 0 || apiKey.length === 0) return void 0;
2772
- const byPrefix = [
2773
- { provider: "openrouter", prefix: "sk-or-" },
2774
- { provider: "anthropic", prefix: "sk-ant-" },
2775
- { provider: "openai", prefix: "sk-" }
2776
- ];
2777
- for (const { provider, prefix } of byPrefix) {
2778
- if (apiKey.startsWith(prefix) && chunkT6ZCG5AP_cjs.getProviderProfile(provider) !== void 0) {
2779
- return provider;
2780
- }
2781
- }
2782
- return void 0;
2772
+ const provider = chunkFRITRLZQ_cjs.providerFromApiKeyPrefix(apiKey);
2773
+ if (provider === void 0) return void 0;
2774
+ return chunkT6ZCG5AP_cjs.getProviderProfile(provider) === void 0 ? void 0 : provider;
2783
2775
  }
2784
2776
  function detectPrimaryProvider() {
2785
2777
  if (process.env.ANTHROPIC_API_KEY !== void 0 && process.env.ANTHROPIC_API_KEY.length > 0) {
@@ -3067,5 +3059,5 @@ exports.shouldAutoCompact = shouldAutoCompact;
3067
3059
  exports.shouldUseFixtureMode = shouldUseFixtureMode;
3068
3060
  exports.shouldUseRealLocalRuntime = shouldUseRealLocalRuntime;
3069
3061
  exports.tryFirstEvent = tryFirstEvent;
3070
- //# sourceMappingURL=chunk-N6NUMXAJ.cjs.map
3071
- //# sourceMappingURL=chunk-N6NUMXAJ.cjs.map
3062
+ //# sourceMappingURL=chunk-WLESQ3ZQ.cjs.map
3063
+ //# sourceMappingURL=chunk-WLESQ3ZQ.cjs.map