@theokit/sdk 4.13.0 → 4.14.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.
- package/CHANGELOG.md +12 -0
- package/dist/{cron-C7catiH8.d.ts → cron-DY0uC1ng.d.ts} +7 -0
- package/dist/{cron-DK1WVZnI.d.cts → cron-ElTj1cSH.d.cts} +7 -0
- package/dist/cron.cjs +183 -20
- package/dist/cron.cjs.map +1 -1
- package/dist/cron.d.cts +1 -1
- package/dist/cron.d.ts +1 -1
- package/dist/cron.js +183 -20
- package/dist/cron.js.map +1 -1
- package/dist/eval.cjs +183 -20
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +183 -20
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +183 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +183 -20
- package/dist/index.js.map +1 -1
- package/dist/internal/llm/openai.d.ts +1 -0
- package/dist/internal/providers/builtin/cerebras.d.ts +5 -0
- package/dist/internal/providers/builtin/cohere.d.ts +6 -0
- package/dist/internal/providers/builtin/deepinfra.d.ts +2 -0
- package/dist/internal/providers/builtin/google.d.ts +6 -0
- package/dist/internal/providers/builtin/groq.d.ts +2 -0
- package/dist/internal/providers/builtin/mistral.d.ts +2 -0
- package/dist/internal/providers/builtin/openai-compatible.d.ts +1 -0
- package/dist/internal/providers/builtin/perplexity.d.ts +5 -0
- package/dist/internal/providers/builtin/together.d.ts +2 -0
- package/dist/internal/providers/builtin/xai.d.ts +2 -0
- package/dist/models.cjs +753 -17
- package/dist/models.cjs.map +1 -1
- package/dist/models.js +754 -18
- package/dist/models.js.map +1 -1
- package/dist/provider-catalog.json +473 -146
- package/dist/types/provider-profile.d.ts +7 -0
- package/package.json +1 -1
package/dist/eval.cjs
CHANGED
|
@@ -10534,8 +10534,17 @@ var catalogModelSchema = zod.z.object({
|
|
|
10534
10534
|
}).loose();
|
|
10535
10535
|
|
|
10536
10536
|
// src/internal/providers/registry.ts
|
|
10537
|
-
|
|
10538
|
-
|
|
10537
|
+
function globalSingleton(key, create) {
|
|
10538
|
+
const g = globalThis;
|
|
10539
|
+
const sym = Symbol.for(key);
|
|
10540
|
+
if (g[sym] === void 0) g[sym] = create();
|
|
10541
|
+
return g[sym];
|
|
10542
|
+
}
|
|
10543
|
+
var REGISTRY = globalSingleton(
|
|
10544
|
+
"theokit-sdk.providers.registry",
|
|
10545
|
+
() => /* @__PURE__ */ new Map()
|
|
10546
|
+
);
|
|
10547
|
+
var ALIASES = globalSingleton("theokit-sdk.providers.aliases", () => /* @__PURE__ */ new Map());
|
|
10539
10548
|
function registerProvider(profile) {
|
|
10540
10549
|
if (REGISTRY.has(profile.name)) {
|
|
10541
10550
|
process.stderr.write(`[theokit-sdk] Provider "${profile.name}" overridden by user plugin.
|
|
@@ -10560,18 +10569,43 @@ function getProviderProfile(name) {
|
|
|
10560
10569
|
|
|
10561
10570
|
// src/internal/providers/catalog-loader.ts
|
|
10562
10571
|
var __dirname_resolved = path.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('eval.cjs', document.baseURI).href))));
|
|
10563
|
-
|
|
10572
|
+
function globalSingleton2(key, create) {
|
|
10573
|
+
const g = globalThis;
|
|
10574
|
+
const sym = Symbol.for(key);
|
|
10575
|
+
if (g[sym] === void 0) g[sym] = create();
|
|
10576
|
+
return g[sym];
|
|
10577
|
+
}
|
|
10578
|
+
var modelInfoIndex = globalSingleton2(
|
|
10579
|
+
"theokit-sdk.providers.model-info-index",
|
|
10580
|
+
() => /* @__PURE__ */ new Map()
|
|
10581
|
+
);
|
|
10582
|
+
var patchedModelKeys = globalSingleton2(
|
|
10583
|
+
"theokit-sdk.providers.model-info-patched",
|
|
10584
|
+
() => /* @__PURE__ */ new Set()
|
|
10585
|
+
);
|
|
10586
|
+
var indexState = globalSingleton2("theokit-sdk.providers.model-info-loaded", () => ({
|
|
10587
|
+
loaded: false
|
|
10588
|
+
}));
|
|
10564
10589
|
function getCatalogModelInfo(key) {
|
|
10565
10590
|
ensureModelIndexLoaded();
|
|
10566
10591
|
return modelInfoIndex.get(key);
|
|
10567
10592
|
}
|
|
10568
|
-
|
|
10593
|
+
function isPatchedModelKey(key) {
|
|
10594
|
+
return patchedModelKeys.has(key);
|
|
10595
|
+
}
|
|
10569
10596
|
function ensureModelIndexLoaded() {
|
|
10570
|
-
if (
|
|
10571
|
-
|
|
10572
|
-
|
|
10573
|
-
|
|
10574
|
-
|
|
10597
|
+
if (indexState.loaded) return;
|
|
10598
|
+
indexState.loaded = true;
|
|
10599
|
+
try {
|
|
10600
|
+
const catalog = loadProviderCatalog();
|
|
10601
|
+
for (const entry of Object.values(catalog)) {
|
|
10602
|
+
indexEntryModels(entry);
|
|
10603
|
+
}
|
|
10604
|
+
} catch (err) {
|
|
10605
|
+
process.stderr.write(
|
|
10606
|
+
`[theokit-sdk] WARN: provider catalog unavailable (${err.message}) \u2014 per-model data disabled
|
|
10607
|
+
`
|
|
10608
|
+
);
|
|
10575
10609
|
}
|
|
10576
10610
|
}
|
|
10577
10611
|
function indexEntryModels(entry) {
|
|
@@ -10824,8 +10858,10 @@ function getPricingEntry(opts) {
|
|
|
10824
10858
|
return void 0;
|
|
10825
10859
|
}
|
|
10826
10860
|
function catalogCostFallback(provider, cleanedModel) {
|
|
10827
|
-
const
|
|
10828
|
-
|
|
10861
|
+
const stripped = stripDateSuffix(cleanedModel);
|
|
10862
|
+
const candidates = [`${provider}/${cleanedModel}`, cleanedModel];
|
|
10863
|
+
if (stripped !== cleanedModel) candidates.push(`${provider}/${stripped}`, stripped);
|
|
10864
|
+
for (const key of candidates) {
|
|
10829
10865
|
const info = getCatalogModelInfo(key);
|
|
10830
10866
|
const cost = info?.cost;
|
|
10831
10867
|
if (cost === void 0) continue;
|
|
@@ -10837,7 +10873,8 @@ function catalogCostFallback(provider, cleanedModel) {
|
|
|
10837
10873
|
outputCostPerMillion: cost.output,
|
|
10838
10874
|
...cost.cache_read !== void 0 ? { cacheReadCostPerMillion: cost.cache_read } : {},
|
|
10839
10875
|
...cost.cache_write !== void 0 ? { cacheWriteCostPerMillion: cost.cache_write } : {},
|
|
10840
|
-
|
|
10876
|
+
// M44 M5 fix — honest provenance: a key patched by the LIVE models-dev source is not "vendored".
|
|
10877
|
+
pricingVersion: isPatchedModelKey(key) ? "catalog-models-dev" : "catalog-vendored"
|
|
10841
10878
|
};
|
|
10842
10879
|
}
|
|
10843
10880
|
return void 0;
|
|
@@ -11365,7 +11402,13 @@ var ANTHROPIC = {
|
|
|
11365
11402
|
baseUrl: "https://api.anthropic.com",
|
|
11366
11403
|
modelsUrl: "https://api.anthropic.com/v1/models",
|
|
11367
11404
|
hostname: "api.anthropic.com",
|
|
11368
|
-
fallbackModels: ["claude-opus-4-7", "claude-sonnet-4-6", "claude-haiku-4-5-20251001"]
|
|
11405
|
+
fallbackModels: ["claude-opus-4-7", "claude-sonnet-4-6", "claude-haiku-4-5-20251001"],
|
|
11406
|
+
// M45 — the Anthropic beta-features header (interleaved thinking + fine-grained tool streaming). An
|
|
11407
|
+
// Anthropic API constant, adapted verbatim from OpenCode's anthropic plugin (MIT © 2025 opencode). The
|
|
11408
|
+
// SANCTIONED behavior delta of M45 (ADR D4) — consumed by the anthropic transport's extraHeaders wiring.
|
|
11409
|
+
extraHeaders: {
|
|
11410
|
+
"anthropic-beta": "interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14"
|
|
11411
|
+
}
|
|
11369
11412
|
};
|
|
11370
11413
|
|
|
11371
11414
|
// src/internal/providers/builtin/bedrock.ts
|
|
@@ -11400,6 +11443,101 @@ function resolveBedrockBaseUrl(modelId) {
|
|
|
11400
11443
|
return `https://bedrock-runtime.${region}.amazonaws.com`;
|
|
11401
11444
|
}
|
|
11402
11445
|
|
|
11446
|
+
// src/internal/providers/builtin/openai-compatible.ts
|
|
11447
|
+
function openAiCompatibleProfile(p) {
|
|
11448
|
+
return {
|
|
11449
|
+
apiMode: "chat_completions",
|
|
11450
|
+
authType: "api_key",
|
|
11451
|
+
fallbackModels: [],
|
|
11452
|
+
...p
|
|
11453
|
+
};
|
|
11454
|
+
}
|
|
11455
|
+
|
|
11456
|
+
// src/internal/providers/builtin/cerebras.ts
|
|
11457
|
+
var CEREBRAS = openAiCompatibleProfile({
|
|
11458
|
+
name: "cerebras",
|
|
11459
|
+
baseUrl: "https://api.cerebras.ai/v1",
|
|
11460
|
+
envVars: ["CEREBRAS_API_KEY"],
|
|
11461
|
+
fallbackModels: ["gpt-oss-120b", "zai-glm-4.7"],
|
|
11462
|
+
extraHeaders: { "X-Cerebras-3rd-Party-Integration": "theokit" },
|
|
11463
|
+
hostname: "api.cerebras.ai"
|
|
11464
|
+
});
|
|
11465
|
+
|
|
11466
|
+
// src/internal/providers/builtin/cohere.ts
|
|
11467
|
+
var COHERE = openAiCompatibleProfile({
|
|
11468
|
+
name: "cohere",
|
|
11469
|
+
baseUrl: "https://api.cohere.ai/compatibility/v1",
|
|
11470
|
+
envVars: ["COHERE_API_KEY", "CO_API_KEY"],
|
|
11471
|
+
fallbackModels: ["command-a-03-2025"],
|
|
11472
|
+
hostname: "api.cohere.ai"
|
|
11473
|
+
});
|
|
11474
|
+
|
|
11475
|
+
// src/internal/providers/builtin/deepinfra.ts
|
|
11476
|
+
var DEEPINFRA = openAiCompatibleProfile({
|
|
11477
|
+
name: "deepinfra",
|
|
11478
|
+
baseUrl: "https://api.deepinfra.com/v1/openai",
|
|
11479
|
+
envVars: ["DEEPINFRA_API_KEY"],
|
|
11480
|
+
fallbackModels: ["Qwen/Qwen3-32B"],
|
|
11481
|
+
hostname: "api.deepinfra.com"
|
|
11482
|
+
});
|
|
11483
|
+
|
|
11484
|
+
// src/internal/providers/builtin/google.ts
|
|
11485
|
+
var GOOGLE = openAiCompatibleProfile({
|
|
11486
|
+
name: "google",
|
|
11487
|
+
baseUrl: "https://generativelanguage.googleapis.com/v1beta/openai",
|
|
11488
|
+
envVars: ["GOOGLE_API_KEY", "GEMINI_API_KEY"],
|
|
11489
|
+
fallbackModels: ["gemini-2.5-pro", "gemini-2.5-flash"],
|
|
11490
|
+
hostname: "generativelanguage.googleapis.com"
|
|
11491
|
+
});
|
|
11492
|
+
|
|
11493
|
+
// src/internal/providers/builtin/groq.ts
|
|
11494
|
+
var GROQ = openAiCompatibleProfile({
|
|
11495
|
+
name: "groq",
|
|
11496
|
+
baseUrl: "https://api.groq.com/openai/v1",
|
|
11497
|
+
envVars: ["GROQ_API_KEY"],
|
|
11498
|
+
fallbackModels: ["llama-3.3-70b-versatile", "llama-3.1-8b-instant"],
|
|
11499
|
+
hostname: "api.groq.com"
|
|
11500
|
+
});
|
|
11501
|
+
|
|
11502
|
+
// src/internal/providers/builtin/mistral.ts
|
|
11503
|
+
var MISTRAL = openAiCompatibleProfile({
|
|
11504
|
+
name: "mistral",
|
|
11505
|
+
baseUrl: "https://api.mistral.ai/v1",
|
|
11506
|
+
envVars: ["MISTRAL_API_KEY"],
|
|
11507
|
+
fallbackModels: ["mistral-large-latest", "codestral-latest"],
|
|
11508
|
+
hostname: "api.mistral.ai"
|
|
11509
|
+
});
|
|
11510
|
+
|
|
11511
|
+
// src/internal/providers/builtin/perplexity.ts
|
|
11512
|
+
var PERPLEXITY = openAiCompatibleProfile({
|
|
11513
|
+
name: "perplexity",
|
|
11514
|
+
baseUrl: "https://api.perplexity.ai",
|
|
11515
|
+
chatCompletionsPath: "/chat/completions",
|
|
11516
|
+
envVars: ["PERPLEXITY_API_KEY"],
|
|
11517
|
+
fallbackModels: ["sonar-pro", "sonar"],
|
|
11518
|
+
hostname: "api.perplexity.ai"
|
|
11519
|
+
});
|
|
11520
|
+
|
|
11521
|
+
// src/internal/providers/builtin/together.ts
|
|
11522
|
+
var TOGETHER = openAiCompatibleProfile({
|
|
11523
|
+
name: "together",
|
|
11524
|
+
aliases: ["togetherai"],
|
|
11525
|
+
baseUrl: "https://api.together.xyz/v1",
|
|
11526
|
+
envVars: ["TOGETHER_API_KEY"],
|
|
11527
|
+
fallbackModels: ["Qwen/Qwen2.5-7B-Instruct-Turbo"],
|
|
11528
|
+
hostname: "api.together.xyz"
|
|
11529
|
+
});
|
|
11530
|
+
|
|
11531
|
+
// src/internal/providers/builtin/xai.ts
|
|
11532
|
+
var XAI = openAiCompatibleProfile({
|
|
11533
|
+
name: "xai",
|
|
11534
|
+
aliases: ["grok"],
|
|
11535
|
+
baseUrl: "https://api.x.ai/v1",
|
|
11536
|
+
envVars: ["XAI_API_KEY"],
|
|
11537
|
+
fallbackModels: ["grok-4.5", "grok-4.3"],
|
|
11538
|
+
hostname: "api.x.ai"
|
|
11539
|
+
});
|
|
11540
|
+
|
|
11403
11541
|
// src/internal/providers/builtin/gemini.ts
|
|
11404
11542
|
var GEMINI = {
|
|
11405
11543
|
name: "gemini",
|
|
@@ -11824,7 +11962,11 @@ var OPENROUTER = {
|
|
|
11824
11962
|
baseUrl: "https://openrouter.ai/api",
|
|
11825
11963
|
modelsUrl: "https://openrouter.ai/api/v1/models",
|
|
11826
11964
|
hostname: "openrouter.ai",
|
|
11827
|
-
|
|
11965
|
+
// M45 — models refreshed (claude-3-haiku retired upstream).
|
|
11966
|
+
fallbackModels: ["openai/gpt-4o-mini", "anthropic/claude-haiku-4-5"],
|
|
11967
|
+
// M45 — OpenRouter app-attribution headers (mechanism from OpenCode's openrouter plugin, MIT; VALUES are
|
|
11968
|
+
// theokit's own — copying another app's referer would misattribute traffic).
|
|
11969
|
+
extraHeaders: { "HTTP-Referer": "https://usetheo.dev", "X-Title": "theokit" }
|
|
11828
11970
|
};
|
|
11829
11971
|
|
|
11830
11972
|
// src/internal/providers/builtin/vertex.ts
|
|
@@ -11873,6 +12015,15 @@ function registerBuiltins() {
|
|
|
11873
12015
|
registerProvider(LLAMACPP);
|
|
11874
12016
|
registerProvider(BEDROCK);
|
|
11875
12017
|
registerProvider(VERTEX);
|
|
12018
|
+
registerProvider(GOOGLE);
|
|
12019
|
+
registerProvider(MISTRAL);
|
|
12020
|
+
registerProvider(GROQ);
|
|
12021
|
+
registerProvider(COHERE);
|
|
12022
|
+
registerProvider(DEEPINFRA);
|
|
12023
|
+
registerProvider(TOGETHER);
|
|
12024
|
+
registerProvider(XAI);
|
|
12025
|
+
registerProvider(PERPLEXITY);
|
|
12026
|
+
registerProvider(CEREBRAS);
|
|
11876
12027
|
registerCatalogProviders();
|
|
11877
12028
|
}
|
|
11878
12029
|
|
|
@@ -12140,14 +12291,16 @@ var AnthropicClient = class {
|
|
|
12140
12291
|
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: HTTP+SSE handshake + accumulator is intentionally one block
|
|
12141
12292
|
async *stream(request, signal) {
|
|
12142
12293
|
const body = buildAnthropicBody(request);
|
|
12294
|
+
const headers = {
|
|
12295
|
+
"content-type": "application/json",
|
|
12296
|
+
"x-api-key": this.options.apiKey,
|
|
12297
|
+
"anthropic-version": this.options.version ?? "2023-06-01"
|
|
12298
|
+
};
|
|
12299
|
+
if (this.options.extraHeaders !== void 0) Object.assign(headers, this.options.extraHeaders);
|
|
12143
12300
|
const response = await this.fetchImpl(`${this.baseUrl}/v1/messages`, {
|
|
12144
12301
|
method: "POST",
|
|
12145
12302
|
signal,
|
|
12146
|
-
headers
|
|
12147
|
-
"content-type": "application/json",
|
|
12148
|
-
"x-api-key": this.options.apiKey,
|
|
12149
|
-
"anthropic-version": this.options.version ?? "2023-06-01"
|
|
12150
|
-
},
|
|
12303
|
+
headers,
|
|
12151
12304
|
body: JSON.stringify(body)
|
|
12152
12305
|
});
|
|
12153
12306
|
if (!response.ok) {
|
|
@@ -13024,11 +13177,13 @@ var OpenAIClient = class {
|
|
|
13024
13177
|
constructor(options) {
|
|
13025
13178
|
this.options = options;
|
|
13026
13179
|
this.baseUrl = options.baseUrl ?? "https://api.openai.com";
|
|
13180
|
+
this.chatPath = options.chatCompletionsPath ?? (/\/v\d+[a-z]*(\/|$)/.test(new URL(this.baseUrl).pathname) ? "/chat/completions" : "/v1/chat/completions");
|
|
13027
13181
|
this.fetchImpl = options.fetch ?? fetch;
|
|
13028
13182
|
}
|
|
13029
13183
|
options;
|
|
13030
13184
|
name = "openai";
|
|
13031
13185
|
baseUrl;
|
|
13186
|
+
chatPath;
|
|
13032
13187
|
fetchImpl;
|
|
13033
13188
|
/**
|
|
13034
13189
|
* Whether this client recovers leaked Hermes tool-call dialect from assistant
|
|
@@ -13051,7 +13206,7 @@ var OpenAIClient = class {
|
|
|
13051
13206
|
const providerId = this.options.providerName ?? this.name;
|
|
13052
13207
|
let response;
|
|
13053
13208
|
try {
|
|
13054
|
-
response = await this.fetchImpl(`${this.baseUrl}
|
|
13209
|
+
response = await this.fetchImpl(`${this.baseUrl}${this.chatPath}`, {
|
|
13055
13210
|
method: "POST",
|
|
13056
13211
|
signal,
|
|
13057
13212
|
headers,
|
|
@@ -14148,6 +14303,9 @@ function selectTransport(profile, apiKey) {
|
|
|
14148
14303
|
if (profile.extractToolCallsFromContent === true) {
|
|
14149
14304
|
opts.extractToolCallsFromContent = true;
|
|
14150
14305
|
}
|
|
14306
|
+
if (profile.chatCompletionsPath !== void 0) {
|
|
14307
|
+
opts.chatCompletionsPath = profile.chatCompletionsPath;
|
|
14308
|
+
}
|
|
14151
14309
|
if (profile.name === "openai" && process.env.OPENAI_ORGANIZATION !== void 0) {
|
|
14152
14310
|
opts.organization = process.env.OPENAI_ORGANIZATION;
|
|
14153
14311
|
}
|
|
@@ -14167,6 +14325,11 @@ function selectTransport(profile, apiKey) {
|
|
|
14167
14325
|
}
|
|
14168
14326
|
const opts = { apiKey };
|
|
14169
14327
|
opts.baseUrl = process.env.ANTHROPIC_API_BASE_URL ?? profile.baseUrl;
|
|
14328
|
+
const t = applyTransform();
|
|
14329
|
+
assertOAuthResolved(t);
|
|
14330
|
+
if (t.fetch !== void 0) opts.fetch = t.fetch;
|
|
14331
|
+
const merged = profile.extraHeaders !== void 0 || t.headers !== void 0 ? { ...profile.extraHeaders, ...t.headers } : void 0;
|
|
14332
|
+
if (merged !== void 0) opts.extraHeaders = merged;
|
|
14170
14333
|
return new AnthropicClient(opts);
|
|
14171
14334
|
}
|
|
14172
14335
|
if (profile.apiMode === "bedrock_anthropic") {
|