@theokit/sdk 4.13.1 → 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 +6 -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 +134 -8
- 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 +134 -8
- package/dist/cron.js.map +1 -1
- package/dist/eval.cjs +134 -8
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +134 -8
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +134 -8
- 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 +134 -8
- 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 +116 -2
- package/dist/models.cjs.map +1 -1
- package/dist/models.js +116 -2
- package/dist/models.js.map +1 -1
- package/dist/provider-catalog.json +467 -143
- package/dist/types/provider-profile.d.ts +7 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.14.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Data-provider fleet (agent-builder M45): 9 new first-party builtins on a data-only `openAiCompatibleProfile` base — `google` (DIRECT Gemini via the OpenAI-compat endpoint, `GOOGLE_API_KEY`/`GEMINI_API_KEY`; distinct from the `gemini` OpenRouter passthrough), `mistral`, `groq`, `cohere` (via `api.cohere.ai/compatibility/v1`), `deepinfra`, `together` (alias `togetherai`), `xai` (alias `grok`), `perplexity`, `cerebras` — each ~10 lines with source-cited values. Two defects fixed: the chat_completions URL-join no longer doubles version segments (`…/v1/v1/chat/completions` — every version-suffixed catalog baseUrl was broken for streaming) via version-segment detection + a data-only `ProviderProfile.chatCompletionsPath` escape (existing builtins byte-identical, contract-asserted), and Google is finally reachable (the `google-gemini` catalog entry was silently skipped by an alias collision). The `anthropic_messages` transport now consumes `extraHeaders` + the provider `transform` (mirror of the M41 chat_completions wiring) and the anthropic builtin ships `anthropic-beta: interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14` (the sanctioned behavior delta); openrouter gains theokit's own attribution headers (`HTTP-Referer: https://usetheo.dev`, `X-Title: theokit`); cerebras sends `X-Cerebras-3rd-Party-Integration: theokit`. A table-driven contract suite asserts identity + the EXACT wire URL and headers per provider. Values adapted from OpenCode (MIT); see NOTICE.
|
|
8
|
+
|
|
3
9
|
## 4.13.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -1230,6 +1230,13 @@ interface ProviderProfile {
|
|
|
1230
1230
|
hostname?: string;
|
|
1231
1231
|
fallbackModels: ReadonlyArray<string>;
|
|
1232
1232
|
extraHeaders?: Record<string, string>;
|
|
1233
|
+
/**
|
|
1234
|
+
* M45 — explicit chat-completions path override (data-only). Absent, the transport derives it: a baseUrl
|
|
1235
|
+
* whose path already carries a version segment (`/v1`, `/v2beta`, …) gets `/chat/completions` appended;
|
|
1236
|
+
* a host-only baseUrl keeps the legacy `/v1/chat/completions`. Set this for shapes neither rule expresses
|
|
1237
|
+
* (e.g. Perplexity's unversioned `/chat/completions`).
|
|
1238
|
+
*/
|
|
1239
|
+
chatCompletionsPath?: string;
|
|
1233
1240
|
bodyOverrides?: Record<string, unknown>;
|
|
1234
1241
|
/**
|
|
1235
1242
|
* M41 — the optional per-request behavior seam (dynamic headers + refresh-aware fetch). Absent ⇒ the profile
|
|
@@ -1230,6 +1230,13 @@ interface ProviderProfile {
|
|
|
1230
1230
|
hostname?: string;
|
|
1231
1231
|
fallbackModels: ReadonlyArray<string>;
|
|
1232
1232
|
extraHeaders?: Record<string, string>;
|
|
1233
|
+
/**
|
|
1234
|
+
* M45 — explicit chat-completions path override (data-only). Absent, the transport derives it: a baseUrl
|
|
1235
|
+
* whose path already carries a version segment (`/v1`, `/v2beta`, …) gets `/chat/completions` appended;
|
|
1236
|
+
* a host-only baseUrl keeps the legacy `/v1/chat/completions`. Set this for shapes neither rule expresses
|
|
1237
|
+
* (e.g. Perplexity's unversioned `/chat/completions`).
|
|
1238
|
+
*/
|
|
1239
|
+
chatCompletionsPath?: string;
|
|
1233
1240
|
bodyOverrides?: Record<string, unknown>;
|
|
1234
1241
|
/**
|
|
1235
1242
|
* M41 — the optional per-request behavior seam (dynamic headers + refresh-aware fetch). Absent ⇒ the profile
|
package/dist/cron.cjs
CHANGED
|
@@ -11407,7 +11407,13 @@ var ANTHROPIC = {
|
|
|
11407
11407
|
baseUrl: "https://api.anthropic.com",
|
|
11408
11408
|
modelsUrl: "https://api.anthropic.com/v1/models",
|
|
11409
11409
|
hostname: "api.anthropic.com",
|
|
11410
|
-
fallbackModels: ["claude-opus-4-7", "claude-sonnet-4-6", "claude-haiku-4-5-20251001"]
|
|
11410
|
+
fallbackModels: ["claude-opus-4-7", "claude-sonnet-4-6", "claude-haiku-4-5-20251001"],
|
|
11411
|
+
// M45 — the Anthropic beta-features header (interleaved thinking + fine-grained tool streaming). An
|
|
11412
|
+
// Anthropic API constant, adapted verbatim from OpenCode's anthropic plugin (MIT © 2025 opencode). The
|
|
11413
|
+
// SANCTIONED behavior delta of M45 (ADR D4) — consumed by the anthropic transport's extraHeaders wiring.
|
|
11414
|
+
extraHeaders: {
|
|
11415
|
+
"anthropic-beta": "interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14"
|
|
11416
|
+
}
|
|
11411
11417
|
};
|
|
11412
11418
|
|
|
11413
11419
|
// src/internal/providers/builtin/bedrock.ts
|
|
@@ -11442,6 +11448,101 @@ function resolveBedrockBaseUrl(modelId) {
|
|
|
11442
11448
|
return `https://bedrock-runtime.${region}.amazonaws.com`;
|
|
11443
11449
|
}
|
|
11444
11450
|
|
|
11451
|
+
// src/internal/providers/builtin/openai-compatible.ts
|
|
11452
|
+
function openAiCompatibleProfile(p) {
|
|
11453
|
+
return {
|
|
11454
|
+
apiMode: "chat_completions",
|
|
11455
|
+
authType: "api_key",
|
|
11456
|
+
fallbackModels: [],
|
|
11457
|
+
...p
|
|
11458
|
+
};
|
|
11459
|
+
}
|
|
11460
|
+
|
|
11461
|
+
// src/internal/providers/builtin/cerebras.ts
|
|
11462
|
+
var CEREBRAS = openAiCompatibleProfile({
|
|
11463
|
+
name: "cerebras",
|
|
11464
|
+
baseUrl: "https://api.cerebras.ai/v1",
|
|
11465
|
+
envVars: ["CEREBRAS_API_KEY"],
|
|
11466
|
+
fallbackModels: ["gpt-oss-120b", "zai-glm-4.7"],
|
|
11467
|
+
extraHeaders: { "X-Cerebras-3rd-Party-Integration": "theokit" },
|
|
11468
|
+
hostname: "api.cerebras.ai"
|
|
11469
|
+
});
|
|
11470
|
+
|
|
11471
|
+
// src/internal/providers/builtin/cohere.ts
|
|
11472
|
+
var COHERE = openAiCompatibleProfile({
|
|
11473
|
+
name: "cohere",
|
|
11474
|
+
baseUrl: "https://api.cohere.ai/compatibility/v1",
|
|
11475
|
+
envVars: ["COHERE_API_KEY", "CO_API_KEY"],
|
|
11476
|
+
fallbackModels: ["command-a-03-2025"],
|
|
11477
|
+
hostname: "api.cohere.ai"
|
|
11478
|
+
});
|
|
11479
|
+
|
|
11480
|
+
// src/internal/providers/builtin/deepinfra.ts
|
|
11481
|
+
var DEEPINFRA = openAiCompatibleProfile({
|
|
11482
|
+
name: "deepinfra",
|
|
11483
|
+
baseUrl: "https://api.deepinfra.com/v1/openai",
|
|
11484
|
+
envVars: ["DEEPINFRA_API_KEY"],
|
|
11485
|
+
fallbackModels: ["Qwen/Qwen3-32B"],
|
|
11486
|
+
hostname: "api.deepinfra.com"
|
|
11487
|
+
});
|
|
11488
|
+
|
|
11489
|
+
// src/internal/providers/builtin/google.ts
|
|
11490
|
+
var GOOGLE = openAiCompatibleProfile({
|
|
11491
|
+
name: "google",
|
|
11492
|
+
baseUrl: "https://generativelanguage.googleapis.com/v1beta/openai",
|
|
11493
|
+
envVars: ["GOOGLE_API_KEY", "GEMINI_API_KEY"],
|
|
11494
|
+
fallbackModels: ["gemini-2.5-pro", "gemini-2.5-flash"],
|
|
11495
|
+
hostname: "generativelanguage.googleapis.com"
|
|
11496
|
+
});
|
|
11497
|
+
|
|
11498
|
+
// src/internal/providers/builtin/groq.ts
|
|
11499
|
+
var GROQ = openAiCompatibleProfile({
|
|
11500
|
+
name: "groq",
|
|
11501
|
+
baseUrl: "https://api.groq.com/openai/v1",
|
|
11502
|
+
envVars: ["GROQ_API_KEY"],
|
|
11503
|
+
fallbackModels: ["llama-3.3-70b-versatile", "llama-3.1-8b-instant"],
|
|
11504
|
+
hostname: "api.groq.com"
|
|
11505
|
+
});
|
|
11506
|
+
|
|
11507
|
+
// src/internal/providers/builtin/mistral.ts
|
|
11508
|
+
var MISTRAL = openAiCompatibleProfile({
|
|
11509
|
+
name: "mistral",
|
|
11510
|
+
baseUrl: "https://api.mistral.ai/v1",
|
|
11511
|
+
envVars: ["MISTRAL_API_KEY"],
|
|
11512
|
+
fallbackModels: ["mistral-large-latest", "codestral-latest"],
|
|
11513
|
+
hostname: "api.mistral.ai"
|
|
11514
|
+
});
|
|
11515
|
+
|
|
11516
|
+
// src/internal/providers/builtin/perplexity.ts
|
|
11517
|
+
var PERPLEXITY = openAiCompatibleProfile({
|
|
11518
|
+
name: "perplexity",
|
|
11519
|
+
baseUrl: "https://api.perplexity.ai",
|
|
11520
|
+
chatCompletionsPath: "/chat/completions",
|
|
11521
|
+
envVars: ["PERPLEXITY_API_KEY"],
|
|
11522
|
+
fallbackModels: ["sonar-pro", "sonar"],
|
|
11523
|
+
hostname: "api.perplexity.ai"
|
|
11524
|
+
});
|
|
11525
|
+
|
|
11526
|
+
// src/internal/providers/builtin/together.ts
|
|
11527
|
+
var TOGETHER = openAiCompatibleProfile({
|
|
11528
|
+
name: "together",
|
|
11529
|
+
aliases: ["togetherai"],
|
|
11530
|
+
baseUrl: "https://api.together.xyz/v1",
|
|
11531
|
+
envVars: ["TOGETHER_API_KEY"],
|
|
11532
|
+
fallbackModels: ["Qwen/Qwen2.5-7B-Instruct-Turbo"],
|
|
11533
|
+
hostname: "api.together.xyz"
|
|
11534
|
+
});
|
|
11535
|
+
|
|
11536
|
+
// src/internal/providers/builtin/xai.ts
|
|
11537
|
+
var XAI = openAiCompatibleProfile({
|
|
11538
|
+
name: "xai",
|
|
11539
|
+
aliases: ["grok"],
|
|
11540
|
+
baseUrl: "https://api.x.ai/v1",
|
|
11541
|
+
envVars: ["XAI_API_KEY"],
|
|
11542
|
+
fallbackModels: ["grok-4.5", "grok-4.3"],
|
|
11543
|
+
hostname: "api.x.ai"
|
|
11544
|
+
});
|
|
11545
|
+
|
|
11445
11546
|
// src/internal/providers/builtin/gemini.ts
|
|
11446
11547
|
var GEMINI = {
|
|
11447
11548
|
name: "gemini",
|
|
@@ -11866,7 +11967,11 @@ var OPENROUTER = {
|
|
|
11866
11967
|
baseUrl: "https://openrouter.ai/api",
|
|
11867
11968
|
modelsUrl: "https://openrouter.ai/api/v1/models",
|
|
11868
11969
|
hostname: "openrouter.ai",
|
|
11869
|
-
|
|
11970
|
+
// M45 — models refreshed (claude-3-haiku retired upstream).
|
|
11971
|
+
fallbackModels: ["openai/gpt-4o-mini", "anthropic/claude-haiku-4-5"],
|
|
11972
|
+
// M45 — OpenRouter app-attribution headers (mechanism from OpenCode's openrouter plugin, MIT; VALUES are
|
|
11973
|
+
// theokit's own — copying another app's referer would misattribute traffic).
|
|
11974
|
+
extraHeaders: { "HTTP-Referer": "https://usetheo.dev", "X-Title": "theokit" }
|
|
11870
11975
|
};
|
|
11871
11976
|
|
|
11872
11977
|
// src/internal/providers/builtin/vertex.ts
|
|
@@ -11915,6 +12020,15 @@ function registerBuiltins() {
|
|
|
11915
12020
|
registerProvider(LLAMACPP);
|
|
11916
12021
|
registerProvider(BEDROCK);
|
|
11917
12022
|
registerProvider(VERTEX);
|
|
12023
|
+
registerProvider(GOOGLE);
|
|
12024
|
+
registerProvider(MISTRAL);
|
|
12025
|
+
registerProvider(GROQ);
|
|
12026
|
+
registerProvider(COHERE);
|
|
12027
|
+
registerProvider(DEEPINFRA);
|
|
12028
|
+
registerProvider(TOGETHER);
|
|
12029
|
+
registerProvider(XAI);
|
|
12030
|
+
registerProvider(PERPLEXITY);
|
|
12031
|
+
registerProvider(CEREBRAS);
|
|
11918
12032
|
registerCatalogProviders();
|
|
11919
12033
|
}
|
|
11920
12034
|
|
|
@@ -12182,14 +12296,16 @@ var AnthropicClient = class {
|
|
|
12182
12296
|
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: HTTP+SSE handshake + accumulator is intentionally one block
|
|
12183
12297
|
async *stream(request, signal) {
|
|
12184
12298
|
const body = buildAnthropicBody(request);
|
|
12299
|
+
const headers = {
|
|
12300
|
+
"content-type": "application/json",
|
|
12301
|
+
"x-api-key": this.options.apiKey,
|
|
12302
|
+
"anthropic-version": this.options.version ?? "2023-06-01"
|
|
12303
|
+
};
|
|
12304
|
+
if (this.options.extraHeaders !== void 0) Object.assign(headers, this.options.extraHeaders);
|
|
12185
12305
|
const response = await this.fetchImpl(`${this.baseUrl}/v1/messages`, {
|
|
12186
12306
|
method: "POST",
|
|
12187
12307
|
signal,
|
|
12188
|
-
headers
|
|
12189
|
-
"content-type": "application/json",
|
|
12190
|
-
"x-api-key": this.options.apiKey,
|
|
12191
|
-
"anthropic-version": this.options.version ?? "2023-06-01"
|
|
12192
|
-
},
|
|
12308
|
+
headers,
|
|
12193
12309
|
body: JSON.stringify(body)
|
|
12194
12310
|
});
|
|
12195
12311
|
if (!response.ok) {
|
|
@@ -13066,11 +13182,13 @@ var OpenAIClient = class {
|
|
|
13066
13182
|
constructor(options) {
|
|
13067
13183
|
this.options = options;
|
|
13068
13184
|
this.baseUrl = options.baseUrl ?? "https://api.openai.com";
|
|
13185
|
+
this.chatPath = options.chatCompletionsPath ?? (/\/v\d+[a-z]*(\/|$)/.test(new URL(this.baseUrl).pathname) ? "/chat/completions" : "/v1/chat/completions");
|
|
13069
13186
|
this.fetchImpl = options.fetch ?? fetch;
|
|
13070
13187
|
}
|
|
13071
13188
|
options;
|
|
13072
13189
|
name = "openai";
|
|
13073
13190
|
baseUrl;
|
|
13191
|
+
chatPath;
|
|
13074
13192
|
fetchImpl;
|
|
13075
13193
|
/**
|
|
13076
13194
|
* Whether this client recovers leaked Hermes tool-call dialect from assistant
|
|
@@ -13093,7 +13211,7 @@ var OpenAIClient = class {
|
|
|
13093
13211
|
const providerId = this.options.providerName ?? this.name;
|
|
13094
13212
|
let response;
|
|
13095
13213
|
try {
|
|
13096
|
-
response = await this.fetchImpl(`${this.baseUrl}
|
|
13214
|
+
response = await this.fetchImpl(`${this.baseUrl}${this.chatPath}`, {
|
|
13097
13215
|
method: "POST",
|
|
13098
13216
|
signal,
|
|
13099
13217
|
headers,
|
|
@@ -14190,6 +14308,9 @@ function selectTransport(profile, apiKey) {
|
|
|
14190
14308
|
if (profile.extractToolCallsFromContent === true) {
|
|
14191
14309
|
opts.extractToolCallsFromContent = true;
|
|
14192
14310
|
}
|
|
14311
|
+
if (profile.chatCompletionsPath !== void 0) {
|
|
14312
|
+
opts.chatCompletionsPath = profile.chatCompletionsPath;
|
|
14313
|
+
}
|
|
14193
14314
|
if (profile.name === "openai" && process.env.OPENAI_ORGANIZATION !== void 0) {
|
|
14194
14315
|
opts.organization = process.env.OPENAI_ORGANIZATION;
|
|
14195
14316
|
}
|
|
@@ -14209,6 +14330,11 @@ function selectTransport(profile, apiKey) {
|
|
|
14209
14330
|
}
|
|
14210
14331
|
const opts = { apiKey };
|
|
14211
14332
|
opts.baseUrl = process.env.ANTHROPIC_API_BASE_URL ?? profile.baseUrl;
|
|
14333
|
+
const t = applyTransform();
|
|
14334
|
+
assertOAuthResolved(t);
|
|
14335
|
+
if (t.fetch !== void 0) opts.fetch = t.fetch;
|
|
14336
|
+
const merged = profile.extraHeaders !== void 0 || t.headers !== void 0 ? { ...profile.extraHeaders, ...t.headers } : void 0;
|
|
14337
|
+
if (merged !== void 0) opts.extraHeaders = merged;
|
|
14212
14338
|
return new AnthropicClient(opts);
|
|
14213
14339
|
}
|
|
14214
14340
|
if (profile.apiMode === "bedrock_anthropic") {
|