@theokit/sdk 5.9.1 → 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.
- package/CHANGELOG.md +74 -0
- package/dist/{agent-R5RERYFU.js → agent-GZVZXKME.js} +15 -14
- package/dist/{agent-R5RERYFU.js.map → agent-GZVZXKME.js.map} +1 -1
- package/dist/{agent-5M7WLUWH.cjs → agent-WQ4LLTSY.cjs} +16 -15
- package/dist/{agent-5M7WLUWH.cjs.map → agent-WQ4LLTSY.cjs.map} +1 -1
- package/dist/agent-session-store-ODD3IZCW.js +6 -0
- package/dist/{agent-session-store-AFML3AXC.js.map → agent-session-store-ODD3IZCW.js.map} +1 -1
- package/dist/agent-session-store-SVEJHSUA.cjs +23 -0
- package/dist/{agent-session-store-MTSIY3MH.cjs.map → agent-session-store-SVEJHSUA.cjs.map} +1 -1
- package/dist/auth/index.cjs +8 -7
- package/dist/auth/index.cjs.map +1 -1
- package/dist/auth/index.js +3 -2
- package/dist/auth/index.js.map +1 -1
- package/dist/{chunk-TC4RWP3Y.js → chunk-47Z6LP3I.js} +3 -3
- package/dist/{chunk-TC4RWP3Y.js.map → chunk-47Z6LP3I.js.map} +1 -1
- package/dist/{chunk-TTBIQTO5.cjs → chunk-DLUCTZ56.cjs} +15 -15
- package/dist/{chunk-TTBIQTO5.cjs.map → chunk-DLUCTZ56.cjs.map} +1 -1
- package/dist/chunk-EHD25JBZ.cjs +10 -0
- package/dist/chunk-EHD25JBZ.cjs.map +1 -0
- package/dist/{chunk-NOO6GZTZ.js → chunk-EVH3OUMY.js} +13 -12
- package/dist/chunk-EVH3OUMY.js.map +1 -0
- package/dist/{chunk-5522X223.js → chunk-EXI7EHDN.js} +4 -4
- package/dist/{chunk-5522X223.js.map → chunk-EXI7EHDN.js.map} +1 -1
- package/dist/{chunk-PSLCVSCS.cjs → chunk-FR6COQXZ.cjs} +6 -6
- package/dist/{chunk-PSLCVSCS.cjs.map → chunk-FR6COQXZ.cjs.map} +1 -1
- package/dist/{chunk-JOFVLOFY.js → chunk-FTZTZBCU.js} +12 -4
- package/dist/chunk-FTZTZBCU.js.map +1 -0
- package/dist/{chunk-HOHR75KF.js → chunk-HI3W37FY.js} +4 -3
- package/dist/chunk-HI3W37FY.js.map +1 -0
- package/dist/chunk-HU666T3Q.cjs +1891 -0
- package/dist/chunk-HU666T3Q.cjs.map +1 -0
- package/dist/{chunk-53RDNK3H.js → chunk-I2ORT6QD.js} +3 -3
- package/dist/{chunk-53RDNK3H.js.map → chunk-I2ORT6QD.js.map} +1 -1
- package/dist/{chunk-56BCEM26.cjs → chunk-JU76WCW7.cjs} +90 -89
- package/dist/chunk-JU76WCW7.cjs.map +1 -0
- package/dist/{chunk-LL4QA3DI.cjs → chunk-KXKT3HSD.cjs} +4 -4
- package/dist/{chunk-LL4QA3DI.cjs.map → chunk-KXKT3HSD.cjs.map} +1 -1
- package/dist/{chunk-QCIARBLS.js → chunk-M2CCHC66.js} +3 -3
- package/dist/{chunk-QCIARBLS.js.map → chunk-M2CCHC66.js.map} +1 -1
- package/dist/{chunk-QDQQYRJI.js → chunk-N7KYUNFO.js} +3 -3
- package/dist/{chunk-QDQQYRJI.js.map → chunk-N7KYUNFO.js.map} +1 -1
- package/dist/{chunk-UNZOJVVC.js → chunk-OZLQ6ZFM.js} +3 -3
- package/dist/{chunk-UNZOJVVC.js.map → chunk-OZLQ6ZFM.js.map} +1 -1
- package/dist/{chunk-OOM236Z4.js → chunk-PEIV7LOU.js} +18 -17
- package/dist/chunk-PEIV7LOU.js.map +1 -0
- package/dist/chunk-Q7GYMXVC.js +8 -0
- package/dist/chunk-Q7GYMXVC.js.map +1 -0
- package/dist/{chunk-ARMFXTY6.cjs → chunk-QY3CIMUV.cjs} +34 -33
- package/dist/chunk-QY3CIMUV.cjs.map +1 -0
- package/dist/{chunk-B3XXQX6L.cjs → chunk-RX3CFWQ2.cjs} +6 -6
- package/dist/{chunk-B3XXQX6L.cjs.map → chunk-RX3CFWQ2.cjs.map} +1 -1
- package/dist/chunk-SGC7LSHF.cjs +18 -0
- package/dist/{chunk-R3ZQBPA5.cjs.map → chunk-SGC7LSHF.cjs.map} +1 -1
- package/dist/{chunk-RA7IE4NK.cjs → chunk-SKDNCTXG.cjs} +4 -3
- package/dist/chunk-SKDNCTXG.cjs.map +1 -0
- package/dist/chunk-SVCPJRUB.js +1874 -0
- package/dist/chunk-SVCPJRUB.js.map +1 -0
- package/dist/{chunk-EJROML3Q.js → chunk-TX56N7FR.js} +4 -3
- package/dist/chunk-TX56N7FR.js.map +1 -0
- package/dist/{chunk-76PIKR4P.cjs → chunk-VZ2JZ2EH.cjs} +5 -5
- package/dist/{chunk-76PIKR4P.cjs.map → chunk-VZ2JZ2EH.cjs.map} +1 -1
- package/dist/{chunk-T5KOSR5Y.cjs → chunk-X7Z2FEI7.cjs} +8 -8
- package/dist/{chunk-T5KOSR5Y.cjs.map → chunk-X7Z2FEI7.cjs.map} +1 -1
- package/dist/{chunk-2WXHA33T.js → chunk-XERM7PDQ.js} +3 -3
- package/dist/{chunk-2WXHA33T.js.map → chunk-XERM7PDQ.js.map} +1 -1
- package/dist/{chunk-MEUBLCM4.cjs → chunk-YEHQ3SIC.cjs} +4 -3
- package/dist/chunk-YEHQ3SIC.cjs.map +1 -0
- package/dist/{chunk-YIFFF23U.cjs → chunk-ZAM7BJXJ.cjs} +5 -5
- package/dist/{chunk-YIFFF23U.cjs.map → chunk-ZAM7BJXJ.cjs.map} +1 -1
- package/dist/{chunk-R2C3HXR3.js → chunk-ZDF2IJKC.js} +3 -3
- package/dist/{chunk-R2C3HXR3.js.map → chunk-ZDF2IJKC.js.map} +1 -1
- package/dist/{chunk-GZV6AVRL.cjs → chunk-ZWACQM5U.cjs} +11 -3
- package/dist/chunk-ZWACQM5U.cjs.map +1 -0
- package/dist/{compact-session-RBPLUPCK.cjs → compact-session-4QHBBGEY.cjs} +16 -15
- package/dist/{compact-session-RBPLUPCK.cjs.map → compact-session-4QHBBGEY.cjs.map} +1 -1
- package/dist/{compact-session-2N3ZYJTW.js → compact-session-PVAWTKKL.js} +7 -6
- package/dist/{compact-session-2N3ZYJTW.js.map → compact-session-PVAWTKKL.js.map} +1 -1
- package/dist/cron.cjs +15 -14
- package/dist/cron.js +14 -13
- package/dist/eval.cjs +14 -13
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +13 -12
- package/dist/eval.js.map +1 -1
- package/dist/fs-session-store-LCZBM3LT.js +10 -0
- package/dist/{fs-session-store-STZZFXH2.js.map → fs-session-store-LCZBM3LT.js.map} +1 -1
- package/dist/{fs-session-store-JHBJFKVV.cjs → fs-session-store-SVEMRE4K.cjs} +5 -5
- package/dist/{fs-session-store-JHBJFKVV.cjs.map → fs-session-store-SVEMRE4K.cjs.map} +1 -1
- package/dist/{index-manager-ONQJSWX5.js → index-manager-6B2UF5S3.js} +5 -5
- package/dist/{index-manager-ONQJSWX5.js.map → index-manager-6B2UF5S3.js.map} +1 -1
- package/dist/{index-manager-ZGJN25FD.cjs → index-manager-M3FHJCHQ.cjs} +6 -6
- package/dist/{index-manager-ZGJN25FD.cjs.map → index-manager-M3FHJCHQ.cjs.map} +1 -1
- package/dist/index.cjs +55 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +30 -3
- package/dist/index.d.ts +30 -3
- package/dist/index.js +18 -17
- package/dist/index.js.map +1 -1
- package/dist/{inject-session-YNNOE3O6.js → inject-session-O24XGRR6.js} +5 -5
- package/dist/{inject-session-YNNOE3O6.js.map → inject-session-O24XGRR6.js.map} +1 -1
- package/dist/{inject-session-3FPXJDJP.cjs → inject-session-OMLFL2V3.cjs} +7 -7
- package/dist/{inject-session-3FPXJDJP.cjs.map → inject-session-OMLFL2V3.cjs.map} +1 -1
- package/dist/internal/memory/adapters/index.cjs +3 -2
- package/dist/internal/memory/adapters/index.js +2 -1
- package/dist/internal/memory/storage/index.cjs +32 -32
- package/dist/internal/memory/storage/index.js +3 -3
- package/dist/internal/persistence/persistence-schema.d.cts +1 -1
- package/dist/internal/persistence/persistence-schema.d.ts +1 -1
- package/dist/internal/providers/catalog-loader.d.ts +30 -3
- package/dist/internal/runtime-fetch.d.ts +1 -0
- package/dist/models.cjs +12 -11
- package/dist/models.cjs.map +1 -1
- package/dist/models.js +4 -3
- package/dist/models.js.map +1 -1
- package/dist/persistence.cjs +7 -7
- package/dist/persistence.js +2 -2
- package/dist/providers.cjs +6 -5
- package/dist/providers.js +4 -3
- package/dist/{session-transcript-VTBTCGQX.js → session-transcript-AR7IBICT.js} +3 -3
- package/dist/{session-transcript-VTBTCGQX.js.map → session-transcript-AR7IBICT.js.map} +1 -1
- package/dist/{session-transcript-LGHSNVY5.cjs → session-transcript-RACG7BK2.cjs} +16 -16
- package/dist/{session-transcript-LGHSNVY5.cjs.map → session-transcript-RACG7BK2.cjs.map} +1 -1
- package/dist/subscription/index.cjs +2 -1
- package/dist/subscription/index.cjs.map +1 -1
- package/dist/subscription/index.js +2 -1
- package/dist/subscription/index.js.map +1 -1
- package/docs/error-codes.md +13 -13
- package/package.json +2 -2
- package/dist/agent-session-store-AFML3AXC.js +0 -6
- package/dist/agent-session-store-MTSIY3MH.cjs +0 -23
- package/dist/chunk-56BCEM26.cjs.map +0 -1
- package/dist/chunk-ARMFXTY6.cjs.map +0 -1
- package/dist/chunk-EJROML3Q.js.map +0 -1
- package/dist/chunk-GZV6AVRL.cjs.map +0 -1
- package/dist/chunk-HOHR75KF.js.map +0 -1
- package/dist/chunk-JOFVLOFY.js.map +0 -1
- package/dist/chunk-MEUBLCM4.cjs.map +0 -1
- package/dist/chunk-MFZODA5Y.js +0 -583
- package/dist/chunk-MFZODA5Y.js.map +0 -1
- package/dist/chunk-NOO6GZTZ.js.map +0 -1
- package/dist/chunk-OOM236Z4.js.map +0 -1
- package/dist/chunk-R3ZQBPA5.cjs +0 -18
- package/dist/chunk-RA7IE4NK.cjs.map +0 -1
- package/dist/chunk-YRJA2POB.cjs +0 -601
- package/dist/chunk-YRJA2POB.cjs.map +0 -1
- package/dist/fs-session-store-STZZFXH2.js +0 -10
- package/dist/provider-catalog.json +0 -1295
package/dist/chunk-MFZODA5Y.js
DELETED
|
@@ -1,583 +0,0 @@
|
|
|
1
|
-
import { globalSingleton } from './chunk-AGACYRJ2.js';
|
|
2
|
-
import { resolveCredential } from './chunk-EJROML3Q.js';
|
|
3
|
-
import { readStoredOAuth } from './chunk-5Q4RTLMP.js';
|
|
4
|
-
import { AuthenticationError } from './chunk-B5MHRQJZ.js';
|
|
5
|
-
import { diag } from './chunk-CZJ6Q7CW.js';
|
|
6
|
-
import { readFileSync } from 'fs';
|
|
7
|
-
import { dirname, join } from 'path';
|
|
8
|
-
import { fileURLToPath } from 'url';
|
|
9
|
-
import { z } from 'zod';
|
|
10
|
-
import { homedir } from 'os';
|
|
11
|
-
|
|
12
|
-
// src/internal/providers/registry.ts
|
|
13
|
-
var REGISTRY = globalSingleton(
|
|
14
|
-
"theokit-sdk.providers.registry",
|
|
15
|
-
() => /* @__PURE__ */ new Map()
|
|
16
|
-
);
|
|
17
|
-
var ALIASES = globalSingleton("theokit-sdk.providers.aliases", () => /* @__PURE__ */ new Map());
|
|
18
|
-
function registerProvider(profile) {
|
|
19
|
-
if (REGISTRY.has(profile.name)) {
|
|
20
|
-
diag(`[theokit-sdk] Provider "${profile.name}" overridden by user plugin.
|
|
21
|
-
`);
|
|
22
|
-
}
|
|
23
|
-
REGISTRY.set(profile.name, profile);
|
|
24
|
-
for (const alias of profile.aliases ?? []) {
|
|
25
|
-
const previous = ALIASES.get(alias);
|
|
26
|
-
if (previous !== void 0 && previous !== profile.name) {
|
|
27
|
-
diag(`[theokit-sdk] Alias "${alias}" collision: was "${previous}", now "${profile.name}".
|
|
28
|
-
`);
|
|
29
|
-
}
|
|
30
|
-
ALIASES.set(alias, profile.name);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
function getProviderProfile(name) {
|
|
34
|
-
const canonical = ALIASES.get(name) ?? name;
|
|
35
|
-
return REGISTRY.get(canonical);
|
|
36
|
-
}
|
|
37
|
-
function listProviders() {
|
|
38
|
-
return Array.from(REGISTRY.values());
|
|
39
|
-
}
|
|
40
|
-
var MODALITIES = ["text", "audio", "image", "video", "pdf"];
|
|
41
|
-
var costSchema = z.object({
|
|
42
|
-
/** USD per 1M tokens (models.dev convention). */
|
|
43
|
-
input: z.number().nonnegative(),
|
|
44
|
-
output: z.number().nonnegative(),
|
|
45
|
-
cache_read: z.number().nonnegative().optional(),
|
|
46
|
-
cache_write: z.number().nonnegative().optional()
|
|
47
|
-
}).loose();
|
|
48
|
-
var limitSchema = z.object({
|
|
49
|
-
context: z.number().positive(),
|
|
50
|
-
input: z.number().positive().optional(),
|
|
51
|
-
output: z.number().positive().optional()
|
|
52
|
-
}).loose();
|
|
53
|
-
var modalitiesSchema = z.object({
|
|
54
|
-
input: z.array(z.enum(MODALITIES)).optional(),
|
|
55
|
-
output: z.array(z.enum(MODALITIES)).optional()
|
|
56
|
-
}).loose();
|
|
57
|
-
var catalogModelSchema = z.object({
|
|
58
|
-
name: z.string().optional(),
|
|
59
|
-
release_date: z.string().optional(),
|
|
60
|
-
attachment: z.boolean().optional(),
|
|
61
|
-
reasoning: z.boolean().optional(),
|
|
62
|
-
temperature: z.boolean().optional(),
|
|
63
|
-
tool_call: z.boolean().optional(),
|
|
64
|
-
/** theokit extension — maps to ModelCapabilities.supportsStructuredOutput. */
|
|
65
|
-
structured_output: z.boolean().optional(),
|
|
66
|
-
/** theokit extension — maps to ModelCapabilities.supportsCacheControl. */
|
|
67
|
-
cache_control: z.boolean().optional(),
|
|
68
|
-
cost: costSchema.optional(),
|
|
69
|
-
limit: limitSchema.optional(),
|
|
70
|
-
modalities: modalitiesSchema.optional(),
|
|
71
|
-
status: z.enum(["alpha", "beta", "deprecated"]).optional()
|
|
72
|
-
}).loose();
|
|
73
|
-
var catalogEntrySchema = z.object({
|
|
74
|
-
id: z.string().min(1),
|
|
75
|
-
displayName: z.string().min(1),
|
|
76
|
-
apiMode: z.enum([
|
|
77
|
-
"chat_completions",
|
|
78
|
-
"anthropic_messages",
|
|
79
|
-
"responses_api",
|
|
80
|
-
"bedrock",
|
|
81
|
-
"bedrock_anthropic"
|
|
82
|
-
]),
|
|
83
|
-
authType: z.enum([
|
|
84
|
-
"api_key",
|
|
85
|
-
"oauth_device_code",
|
|
86
|
-
"oauth_external",
|
|
87
|
-
"aws_sdk",
|
|
88
|
-
"aws_bearer",
|
|
89
|
-
"gcp_oauth",
|
|
90
|
-
"none"
|
|
91
|
-
]),
|
|
92
|
-
baseUrl: z.string(),
|
|
93
|
-
envVars: z.array(z.string()),
|
|
94
|
-
fallbackModels: z.array(z.string()),
|
|
95
|
-
capabilities: z.object({
|
|
96
|
-
supportsToolUse: z.boolean(),
|
|
97
|
-
supportsVision: z.boolean(),
|
|
98
|
-
supportsStructuredOutput: z.boolean(),
|
|
99
|
-
supportsStreaming: z.boolean(),
|
|
100
|
-
supportsCacheControl: z.boolean(),
|
|
101
|
-
maxContextTokens: z.number().int().positive().optional(),
|
|
102
|
-
maxOutputTokens: z.number().int().positive().optional()
|
|
103
|
-
}),
|
|
104
|
-
aliases: z.array(z.string()).optional(),
|
|
105
|
-
modelsUrl: z.string().optional(),
|
|
106
|
-
hostname: z.string().optional(),
|
|
107
|
-
extraHeaders: z.record(z.string(), z.string()).optional(),
|
|
108
|
-
models: z.record(z.string(), catalogModelSchema).optional()
|
|
109
|
-
}).loose();
|
|
110
|
-
|
|
111
|
-
// src/internal/providers/catalog-loader.ts
|
|
112
|
-
var __dirname_resolved = dirname(fileURLToPath(import.meta.url));
|
|
113
|
-
var modelInfoIndex = globalSingleton(
|
|
114
|
-
"theokit-sdk.providers.model-info-index",
|
|
115
|
-
() => /* @__PURE__ */ new Map()
|
|
116
|
-
);
|
|
117
|
-
var patchedModelKeys = globalSingleton(
|
|
118
|
-
"theokit-sdk.providers.model-info-patched",
|
|
119
|
-
() => /* @__PURE__ */ new Set()
|
|
120
|
-
);
|
|
121
|
-
var indexState = globalSingleton("theokit-sdk.providers.model-info-loaded", () => ({
|
|
122
|
-
loaded: false
|
|
123
|
-
}));
|
|
124
|
-
function getCatalogModelInfo(key) {
|
|
125
|
-
ensureModelIndexLoaded();
|
|
126
|
-
return modelInfoIndex.get(key);
|
|
127
|
-
}
|
|
128
|
-
function isPatchedModelKey(key) {
|
|
129
|
-
return patchedModelKeys.has(key);
|
|
130
|
-
}
|
|
131
|
-
function patchModelInfo(key, model) {
|
|
132
|
-
ensureModelIndexLoaded();
|
|
133
|
-
const existing = modelInfoIndex.get(key);
|
|
134
|
-
modelInfoIndex.set(key, existing === void 0 ? model : { ...existing, ...model });
|
|
135
|
-
patchedModelKeys.add(key);
|
|
136
|
-
}
|
|
137
|
-
function ensureModelIndexLoaded() {
|
|
138
|
-
if (indexState.loaded) return;
|
|
139
|
-
indexState.loaded = true;
|
|
140
|
-
try {
|
|
141
|
-
const catalog = loadProviderCatalog();
|
|
142
|
-
for (const entry of Object.values(catalog)) {
|
|
143
|
-
indexEntryModels(entry);
|
|
144
|
-
}
|
|
145
|
-
} catch (err) {
|
|
146
|
-
diag(
|
|
147
|
-
`[theokit-sdk] WARN: provider catalog unavailable (${err.message}) \u2014 per-model data disabled
|
|
148
|
-
`
|
|
149
|
-
);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
function indexEntryModels(entry) {
|
|
153
|
-
if (entry.models === void 0 || typeof entry.models !== "object") return;
|
|
154
|
-
for (const [modelId, raw] of Object.entries(entry.models)) {
|
|
155
|
-
const parsed = catalogModelSchema.safeParse(raw);
|
|
156
|
-
if (!parsed.success) {
|
|
157
|
-
diag(
|
|
158
|
-
`[theokit-sdk] WARN: Skipping malformed catalog model "${entry.id}/${modelId}": ${parsed.error.issues[0]?.message ?? "invalid"}
|
|
159
|
-
`
|
|
160
|
-
);
|
|
161
|
-
continue;
|
|
162
|
-
}
|
|
163
|
-
modelInfoIndex.set(`${entry.id}/${modelId}`, parsed.data);
|
|
164
|
-
for (const alias of entry.aliases ?? []) {
|
|
165
|
-
const key = `${alias}/${modelId}`;
|
|
166
|
-
if (!modelInfoIndex.has(key)) modelInfoIndex.set(key, parsed.data);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
function validateEntry(raw) {
|
|
171
|
-
const parsed = catalogEntrySchema.safeParse(raw);
|
|
172
|
-
return parsed.success ? parsed.data : null;
|
|
173
|
-
}
|
|
174
|
-
function loadProviderCatalog(opts) {
|
|
175
|
-
const catalogPath = join(__dirname_resolved, "provider-catalog.json");
|
|
176
|
-
const rawText = readFileSync(catalogPath, "utf-8");
|
|
177
|
-
let entries = JSON.parse(rawText);
|
|
178
|
-
if (opts?._testInjectMalformed) {
|
|
179
|
-
entries = [
|
|
180
|
-
...entries,
|
|
181
|
-
{ id: "malformed-provider", displayName: "Bad" }
|
|
182
|
-
];
|
|
183
|
-
}
|
|
184
|
-
const result = {};
|
|
185
|
-
for (const raw of entries) {
|
|
186
|
-
const validated = validateEntry(raw);
|
|
187
|
-
if (validated === null) {
|
|
188
|
-
diag(
|
|
189
|
-
`[theokit-sdk] WARN: Skipping malformed catalog entry: ${JSON.stringify(raw).slice(0, 100)}
|
|
190
|
-
`
|
|
191
|
-
);
|
|
192
|
-
continue;
|
|
193
|
-
}
|
|
194
|
-
result[validated.id] = validated;
|
|
195
|
-
}
|
|
196
|
-
return result;
|
|
197
|
-
}
|
|
198
|
-
var _capabilitiesCache = null;
|
|
199
|
-
function getCatalogCapabilities(providerId) {
|
|
200
|
-
if (_capabilitiesCache === null) {
|
|
201
|
-
const catalog = loadProviderCatalog();
|
|
202
|
-
_capabilitiesCache = {};
|
|
203
|
-
for (const entry of Object.values(catalog)) {
|
|
204
|
-
_capabilitiesCache[entry.id] = entry.capabilities;
|
|
205
|
-
for (const alias of entry.aliases ?? []) {
|
|
206
|
-
if (_capabilitiesCache[alias] === void 0) _capabilitiesCache[alias] = entry.capabilities;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
return _capabilitiesCache[providerId];
|
|
211
|
-
}
|
|
212
|
-
function registerCatalogProviders(opts) {
|
|
213
|
-
const catalog = loadProviderCatalog(opts);
|
|
214
|
-
for (const entry of Object.values(catalog)) {
|
|
215
|
-
if (getProviderProfile(entry.id) !== void 0) continue;
|
|
216
|
-
if (entry.aliases?.some((a) => getProviderProfile(a) !== void 0)) continue;
|
|
217
|
-
const profile = {
|
|
218
|
-
name: entry.id,
|
|
219
|
-
apiMode: entry.apiMode,
|
|
220
|
-
authType: entry.authType,
|
|
221
|
-
baseUrl: entry.baseUrl,
|
|
222
|
-
envVars: entry.envVars,
|
|
223
|
-
fallbackModels: entry.fallbackModels,
|
|
224
|
-
displayName: entry.displayName,
|
|
225
|
-
aliases: entry.aliases,
|
|
226
|
-
modelsUrl: entry.modelsUrl,
|
|
227
|
-
hostname: entry.hostname,
|
|
228
|
-
extraHeaders: entry.extraHeaders
|
|
229
|
-
};
|
|
230
|
-
registerProvider(profile);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
// src/internal/providers/builtin/anthropic.ts
|
|
235
|
-
var ANTHROPIC = {
|
|
236
|
-
name: "anthropic",
|
|
237
|
-
apiMode: "anthropic_messages",
|
|
238
|
-
envVars: ["ANTHROPIC_API_KEY"],
|
|
239
|
-
authType: "api_key",
|
|
240
|
-
baseUrl: "https://api.anthropic.com",
|
|
241
|
-
modelsUrl: "https://api.anthropic.com/v1/models",
|
|
242
|
-
hostname: "api.anthropic.com",
|
|
243
|
-
fallbackModels: ["claude-opus-4-7", "claude-sonnet-4-6", "claude-haiku-4-5-20251001"],
|
|
244
|
-
// M45 — the Anthropic beta-features header (interleaved thinking + fine-grained tool streaming). An
|
|
245
|
-
// Anthropic API constant. The
|
|
246
|
-
// SANCTIONED behavior delta of M45 (ADR D4) — consumed by the anthropic transport's extraHeaders wiring.
|
|
247
|
-
extraHeaders: {
|
|
248
|
-
"anthropic-beta": "interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14"
|
|
249
|
-
}
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
// src/internal/providers/builtin/bedrock.ts
|
|
253
|
-
var BEDROCK = {
|
|
254
|
-
name: "bedrock",
|
|
255
|
-
apiMode: "bedrock_anthropic",
|
|
256
|
-
envVars: ["AWS_BEARER_TOKEN_BEDROCK"],
|
|
257
|
-
authType: "aws_bearer",
|
|
258
|
-
baseUrl: "https://bedrock-runtime.us-east-1.amazonaws.com",
|
|
259
|
-
modelsUrl: void 0,
|
|
260
|
-
hostname: "bedrock-runtime.amazonaws.com",
|
|
261
|
-
fallbackModels: [
|
|
262
|
-
"bedrock/us.anthropic.claude-sonnet-4-5-v1:0",
|
|
263
|
-
"bedrock/us.anthropic.claude-opus-4-7-v1:0",
|
|
264
|
-
"bedrock/global.anthropic.claude-haiku-4-5-v1:0"
|
|
265
|
-
]
|
|
266
|
-
};
|
|
267
|
-
function stripBedrockPrefix(modelId) {
|
|
268
|
-
return modelId.replace(/^bedrock\//, "");
|
|
269
|
-
}
|
|
270
|
-
function inferRegionFromModelId(modelId) {
|
|
271
|
-
const id = stripBedrockPrefix(modelId);
|
|
272
|
-
if (id.startsWith("global.")) return "us-east-1";
|
|
273
|
-
if (id.startsWith("us.")) return process.env.AWS_REGION ?? "us-east-1";
|
|
274
|
-
if (id.startsWith("eu.")) return process.env.AWS_REGION ?? "eu-west-1";
|
|
275
|
-
if (id.startsWith("apac.")) return process.env.AWS_REGION ?? "ap-southeast-1";
|
|
276
|
-
if (id.startsWith("jp.")) return "ap-northeast-1";
|
|
277
|
-
return void 0;
|
|
278
|
-
}
|
|
279
|
-
function resolveBedrockBaseUrl(modelId) {
|
|
280
|
-
const region = inferRegionFromModelId(modelId) ?? process.env.AWS_REGION ?? "us-east-1";
|
|
281
|
-
return `https://bedrock-runtime.${region}.amazonaws.com`;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
// src/internal/providers/builtin/openai-compatible.ts
|
|
285
|
-
function openAiCompatibleProfile(p) {
|
|
286
|
-
return {
|
|
287
|
-
apiMode: "chat_completions",
|
|
288
|
-
authType: "api_key",
|
|
289
|
-
fallbackModels: [],
|
|
290
|
-
...p
|
|
291
|
-
};
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
// src/internal/providers/builtin/cerebras.ts
|
|
295
|
-
var CEREBRAS = openAiCompatibleProfile({
|
|
296
|
-
name: "cerebras",
|
|
297
|
-
baseUrl: "https://api.cerebras.ai/v1",
|
|
298
|
-
envVars: ["CEREBRAS_API_KEY"],
|
|
299
|
-
fallbackModels: ["gpt-oss-120b", "zai-glm-4.7"],
|
|
300
|
-
extraHeaders: { "X-Cerebras-3rd-Party-Integration": "theokit" },
|
|
301
|
-
hostname: "api.cerebras.ai"
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
// src/internal/providers/builtin/cohere.ts
|
|
305
|
-
var COHERE = openAiCompatibleProfile({
|
|
306
|
-
name: "cohere",
|
|
307
|
-
baseUrl: "https://api.cohere.ai/compatibility/v1",
|
|
308
|
-
envVars: ["COHERE_API_KEY", "CO_API_KEY"],
|
|
309
|
-
fallbackModels: ["command-a-03-2025"],
|
|
310
|
-
hostname: "api.cohere.ai"
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
// src/internal/providers/builtin/deepinfra.ts
|
|
314
|
-
var DEEPINFRA = openAiCompatibleProfile({
|
|
315
|
-
name: "deepinfra",
|
|
316
|
-
baseUrl: "https://api.deepinfra.com/v1/openai",
|
|
317
|
-
envVars: ["DEEPINFRA_API_KEY"],
|
|
318
|
-
fallbackModels: ["Qwen/Qwen3-32B"],
|
|
319
|
-
hostname: "api.deepinfra.com"
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
// src/internal/providers/builtin/gemini.ts
|
|
323
|
-
var GEMINI = {
|
|
324
|
-
name: "gemini",
|
|
325
|
-
apiMode: "chat_completions",
|
|
326
|
-
envVars: ["OPENROUTER_API_KEY"],
|
|
327
|
-
authType: "api_key",
|
|
328
|
-
baseUrl: "https://openrouter.ai/api",
|
|
329
|
-
hostname: "openrouter.ai",
|
|
330
|
-
fallbackModels: ["google/gemini-2.0-flash-001"]
|
|
331
|
-
};
|
|
332
|
-
|
|
333
|
-
// src/internal/providers/builtin/google.ts
|
|
334
|
-
var GOOGLE = openAiCompatibleProfile({
|
|
335
|
-
name: "google",
|
|
336
|
-
baseUrl: "https://generativelanguage.googleapis.com/v1beta/openai",
|
|
337
|
-
envVars: ["GOOGLE_API_KEY", "GEMINI_API_KEY", "GOOGLE_GENERATIVE_AI_API_KEY"],
|
|
338
|
-
fallbackModels: ["gemini-2.5-pro", "gemini-2.5-flash"],
|
|
339
|
-
hostname: "generativelanguage.googleapis.com"
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
// src/internal/providers/builtin/groq.ts
|
|
343
|
-
var GROQ = openAiCompatibleProfile({
|
|
344
|
-
name: "groq",
|
|
345
|
-
baseUrl: "https://api.groq.com/openai/v1",
|
|
346
|
-
envVars: ["GROQ_API_KEY"],
|
|
347
|
-
fallbackModels: ["llama-3.3-70b-versatile", "llama-3.1-8b-instant"],
|
|
348
|
-
hostname: "api.groq.com"
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
// src/internal/providers/builtin/llamacpp.ts
|
|
352
|
-
var LLAMACPP = {
|
|
353
|
-
name: "llamacpp",
|
|
354
|
-
aliases: ["llama-cpp", "llama.cpp"],
|
|
355
|
-
apiMode: "chat_completions",
|
|
356
|
-
envVars: ["LLAMACPP_API_KEY"],
|
|
357
|
-
authType: "none",
|
|
358
|
-
baseUrl: "http://localhost:8080",
|
|
359
|
-
modelsUrl: "http://localhost:8080/v1/models",
|
|
360
|
-
hostname: "localhost",
|
|
361
|
-
fallbackModels: ["loaded-model"]
|
|
362
|
-
};
|
|
363
|
-
|
|
364
|
-
// src/internal/providers/builtin/lmstudio.ts
|
|
365
|
-
var LMSTUDIO = {
|
|
366
|
-
name: "lmstudio",
|
|
367
|
-
aliases: ["lm-studio", "lm_studio"],
|
|
368
|
-
apiMode: "chat_completions",
|
|
369
|
-
envVars: ["LMSTUDIO_API_KEY"],
|
|
370
|
-
authType: "none",
|
|
371
|
-
baseUrl: "http://localhost:1234",
|
|
372
|
-
modelsUrl: "http://localhost:1234/v1/models",
|
|
373
|
-
hostname: "localhost",
|
|
374
|
-
fallbackModels: ["loaded-model"]
|
|
375
|
-
};
|
|
376
|
-
|
|
377
|
-
// src/internal/providers/builtin/mistral.ts
|
|
378
|
-
var MISTRAL = openAiCompatibleProfile({
|
|
379
|
-
name: "mistral",
|
|
380
|
-
baseUrl: "https://api.mistral.ai/v1",
|
|
381
|
-
envVars: ["MISTRAL_API_KEY"],
|
|
382
|
-
fallbackModels: ["mistral-large-latest", "codestral-latest"],
|
|
383
|
-
hostname: "api.mistral.ai"
|
|
384
|
-
});
|
|
385
|
-
|
|
386
|
-
// src/internal/providers/builtin/ollama.ts
|
|
387
|
-
var OLLAMA = {
|
|
388
|
-
name: "ollama",
|
|
389
|
-
apiMode: "chat_completions",
|
|
390
|
-
envVars: ["OLLAMA_API_KEY"],
|
|
391
|
-
authType: "none",
|
|
392
|
-
baseUrl: "http://localhost:11434",
|
|
393
|
-
modelsUrl: "http://localhost:11434/v1/models",
|
|
394
|
-
hostname: "localhost",
|
|
395
|
-
fallbackModels: ["llama3.2", "qwen2.5", "mistral"]
|
|
396
|
-
};
|
|
397
|
-
|
|
398
|
-
// src/internal/providers/builtin/openai.ts
|
|
399
|
-
var OPENAI = {
|
|
400
|
-
name: "openai",
|
|
401
|
-
apiMode: "chat_completions",
|
|
402
|
-
envVars: ["OPENAI_API_KEY"],
|
|
403
|
-
authType: "api_key",
|
|
404
|
-
baseUrl: "https://api.openai.com",
|
|
405
|
-
modelsUrl: "https://api.openai.com/v1/models",
|
|
406
|
-
hostname: "api.openai.com",
|
|
407
|
-
fallbackModels: ["gpt-4o", "gpt-4o-mini"]
|
|
408
|
-
};
|
|
409
|
-
var DEFAULT_STORE = {
|
|
410
|
-
home: homedir(),
|
|
411
|
-
dirName: ".theokit",
|
|
412
|
-
fileName: "auth.json",
|
|
413
|
-
homeEnvVar: "THEOKIT_AUTH_HOME"
|
|
414
|
-
};
|
|
415
|
-
var OPENAI_OAUTH_CONFIG = {
|
|
416
|
-
provider: "openai",
|
|
417
|
-
authorizeEndpoint: "https://auth.openai.com/oauth/authorize",
|
|
418
|
-
tokenEndpoint: "https://auth.openai.com/oauth/token",
|
|
419
|
-
clientId: "app_EMoamEEZ73f0CkXaXp7hrann",
|
|
420
|
-
scopes: ["openid", "profile", "email", "offline_access"],
|
|
421
|
-
redirectUri: "https://auth.openai.com/deviceauth/callback"
|
|
422
|
-
};
|
|
423
|
-
function codexFetch() {
|
|
424
|
-
return (async (input, init) => {
|
|
425
|
-
const env = process.env;
|
|
426
|
-
const resolved = await resolveCredential({
|
|
427
|
-
provider: "openai",
|
|
428
|
-
store: DEFAULT_STORE,
|
|
429
|
-
oauth: OPENAI_OAUTH_CONFIG,
|
|
430
|
-
env
|
|
431
|
-
});
|
|
432
|
-
if (resolved === void 0) {
|
|
433
|
-
throw new AuthenticationError(
|
|
434
|
-
'openai-chatgpt: no ChatGPT credential found \u2014 run the OpenAI device login (e.g. "/login openai") first.',
|
|
435
|
-
{ code: "missing_credential" }
|
|
436
|
-
);
|
|
437
|
-
}
|
|
438
|
-
const accountId = readStoredOAuth(DEFAULT_STORE, env)?.account_id;
|
|
439
|
-
const headers = new Headers(init?.headers);
|
|
440
|
-
headers.set("authorization", `Bearer ${resolved.apiKey}`);
|
|
441
|
-
if (accountId !== void 0) headers.set("ChatGPT-Account-Id", accountId);
|
|
442
|
-
return fetch(input, { ...init, headers });
|
|
443
|
-
});
|
|
444
|
-
}
|
|
445
|
-
var OPENAI_CHATGPT = {
|
|
446
|
-
name: "openai-chatgpt",
|
|
447
|
-
apiMode: "responses_api",
|
|
448
|
-
authType: "oauth_device_code",
|
|
449
|
-
baseUrl: "https://chatgpt.com/backend-api/codex",
|
|
450
|
-
envVars: [],
|
|
451
|
-
fallbackModels: [
|
|
452
|
-
"openai-chatgpt/gpt-5.4",
|
|
453
|
-
"openai-chatgpt/gpt-5.4-mini",
|
|
454
|
-
"openai-chatgpt/gpt-5.5"
|
|
455
|
-
],
|
|
456
|
-
// #165 — this shipped as `codex_cli_rs`, another vendor's client identifier. Claiming to be a different
|
|
457
|
-
// vendor's client is a false statement of identity. Third-party clients send their OWN name against
|
|
458
|
-
// this same endpoint, which also shows the route is not restricted to the official client.
|
|
459
|
-
extraHeaders: { originator: "theokit" },
|
|
460
|
-
// usetheokit/theokit-sdk#383 — carry the model's encrypted reasoning between the rounds of a turn.
|
|
461
|
-
// On for THIS profile and no other because this is the endpoint the issue measured: OpenAI Codex
|
|
462
|
-
// sends `include: ["reasoning.encrypted_content"]` with `reasoning.context: "all_turns"` to the
|
|
463
|
-
// same backend, same model, on the same account, so acceptance is observed rather than assumed.
|
|
464
|
-
// The issue's measurement — a third of our bytes, 2.8x our tokens — is what this closes together
|
|
465
|
-
// with `prompt_cache_key`.
|
|
466
|
-
encryptedReasoning: true,
|
|
467
|
-
transform: {
|
|
468
|
-
// Only `fetch` (async) can await the credential refresh; `headers` is sync and cannot.
|
|
469
|
-
fetch: () => codexFetch()
|
|
470
|
-
}
|
|
471
|
-
};
|
|
472
|
-
|
|
473
|
-
// src/internal/providers/builtin/openrouter.ts
|
|
474
|
-
var OPENROUTER = {
|
|
475
|
-
name: "openrouter",
|
|
476
|
-
apiMode: "chat_completions",
|
|
477
|
-
aliases: ["or"],
|
|
478
|
-
// Ordered fallback (EC-10): OPENROUTER_API_KEY preferred, OPENAI_API_KEY as compat.
|
|
479
|
-
envVars: ["OPENROUTER_API_KEY", "OPENAI_API_KEY"],
|
|
480
|
-
authType: "api_key",
|
|
481
|
-
baseUrl: "https://openrouter.ai/api",
|
|
482
|
-
modelsUrl: "https://openrouter.ai/api/v1/models",
|
|
483
|
-
hostname: "openrouter.ai",
|
|
484
|
-
// M45 — models refreshed (claude-3-haiku retired upstream).
|
|
485
|
-
fallbackModels: ["openai/gpt-4o-mini", "anthropic/claude-haiku-4-5"],
|
|
486
|
-
// M45 — OpenRouter app-attribution headers. VALUES are
|
|
487
|
-
// theokit's own — copying another app's referer would misattribute traffic).
|
|
488
|
-
extraHeaders: { "HTTP-Referer": "https://usetheo.dev", "X-Title": "theokit" }
|
|
489
|
-
};
|
|
490
|
-
|
|
491
|
-
// src/internal/providers/builtin/perplexity.ts
|
|
492
|
-
var PERPLEXITY = openAiCompatibleProfile({
|
|
493
|
-
name: "perplexity",
|
|
494
|
-
baseUrl: "https://api.perplexity.ai",
|
|
495
|
-
chatCompletionsPath: "/chat/completions",
|
|
496
|
-
envVars: ["PERPLEXITY_API_KEY"],
|
|
497
|
-
fallbackModels: ["sonar-pro", "sonar"],
|
|
498
|
-
hostname: "api.perplexity.ai"
|
|
499
|
-
});
|
|
500
|
-
|
|
501
|
-
// src/internal/providers/builtin/together.ts
|
|
502
|
-
var TOGETHER = openAiCompatibleProfile({
|
|
503
|
-
name: "together",
|
|
504
|
-
aliases: ["togetherai"],
|
|
505
|
-
baseUrl: "https://api.together.xyz/v1",
|
|
506
|
-
envVars: ["TOGETHER_API_KEY"],
|
|
507
|
-
fallbackModels: ["Qwen/Qwen2.5-7B-Instruct-Turbo"],
|
|
508
|
-
hostname: "api.together.xyz"
|
|
509
|
-
});
|
|
510
|
-
|
|
511
|
-
// src/internal/providers/builtin/vertex.ts
|
|
512
|
-
var VERTEX = {
|
|
513
|
-
name: "vertex",
|
|
514
|
-
apiMode: "anthropic_messages",
|
|
515
|
-
// sub-dispatched in selectTransport by profile.name
|
|
516
|
-
envVars: ["GOOGLE_APPLICATION_CREDENTIALS"],
|
|
517
|
-
authType: "gcp_oauth",
|
|
518
|
-
baseUrl: "https://us-central1-aiplatform.googleapis.com",
|
|
519
|
-
modelsUrl: void 0,
|
|
520
|
-
hostname: "aiplatform.googleapis.com",
|
|
521
|
-
fallbackModels: [
|
|
522
|
-
"vertex/anthropic/claude-sonnet-4-5@20250929",
|
|
523
|
-
"vertex/google/gemini-2.0-flash-001"
|
|
524
|
-
]
|
|
525
|
-
};
|
|
526
|
-
function resolveVertexBaseUrl(opts) {
|
|
527
|
-
const host = opts.location === "global" ? "aiplatform.googleapis.com" : `${opts.location}-aiplatform.googleapis.com`;
|
|
528
|
-
if (opts.modelDialect === "gemini") {
|
|
529
|
-
return `https://${host}/v1/projects/${opts.projectId}/locations/${opts.location}/endpoints/openapi`;
|
|
530
|
-
}
|
|
531
|
-
return `https://${host}/v1/projects/${opts.projectId}/locations/${opts.location}/publishers/anthropic`;
|
|
532
|
-
}
|
|
533
|
-
function inferModelDialect(modelId) {
|
|
534
|
-
if (modelId.includes("/anthropic/")) return "anthropic";
|
|
535
|
-
if (modelId.includes("/google/")) return "gemini";
|
|
536
|
-
return "gemini";
|
|
537
|
-
}
|
|
538
|
-
function stripVertexPrefix(modelId) {
|
|
539
|
-
return modelId.replace(/^vertex\/(anthropic|google)\//, "");
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
// src/internal/providers/builtin/xai.ts
|
|
543
|
-
var XAI = openAiCompatibleProfile({
|
|
544
|
-
name: "xai",
|
|
545
|
-
aliases: ["grok"],
|
|
546
|
-
baseUrl: "https://api.x.ai/v1",
|
|
547
|
-
envVars: ["XAI_API_KEY"],
|
|
548
|
-
fallbackModels: ["grok-4.5", "grok-4.3"],
|
|
549
|
-
hostname: "api.x.ai"
|
|
550
|
-
});
|
|
551
|
-
|
|
552
|
-
// src/internal/providers/builtin/index.ts
|
|
553
|
-
var _registeredState = globalSingleton("theokit-sdk.providers.builtins-registered", () => ({
|
|
554
|
-
done: false
|
|
555
|
-
}));
|
|
556
|
-
function registerBuiltins() {
|
|
557
|
-
if (_registeredState.done) return;
|
|
558
|
-
_registeredState.done = true;
|
|
559
|
-
registerProvider(ANTHROPIC);
|
|
560
|
-
registerProvider(OPENAI);
|
|
561
|
-
registerProvider(OPENAI_CHATGPT);
|
|
562
|
-
registerProvider(OPENROUTER);
|
|
563
|
-
registerProvider(GEMINI);
|
|
564
|
-
registerProvider(OLLAMA);
|
|
565
|
-
registerProvider(LMSTUDIO);
|
|
566
|
-
registerProvider(LLAMACPP);
|
|
567
|
-
registerProvider(BEDROCK);
|
|
568
|
-
registerProvider(VERTEX);
|
|
569
|
-
registerProvider(GOOGLE);
|
|
570
|
-
registerProvider(MISTRAL);
|
|
571
|
-
registerProvider(GROQ);
|
|
572
|
-
registerProvider(COHERE);
|
|
573
|
-
registerProvider(DEEPINFRA);
|
|
574
|
-
registerProvider(TOGETHER);
|
|
575
|
-
registerProvider(XAI);
|
|
576
|
-
registerProvider(PERPLEXITY);
|
|
577
|
-
registerProvider(CEREBRAS);
|
|
578
|
-
registerCatalogProviders();
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
export { catalogModelSchema, getCatalogCapabilities, getCatalogModelInfo, getProviderProfile, inferModelDialect, inferRegionFromModelId, isPatchedModelKey, listProviders, loadProviderCatalog, patchModelInfo, registerBuiltins, registerProvider, resolveBedrockBaseUrl, resolveVertexBaseUrl, stripBedrockPrefix, stripVertexPrefix };
|
|
582
|
-
//# sourceMappingURL=chunk-MFZODA5Y.js.map
|
|
583
|
-
//# sourceMappingURL=chunk-MFZODA5Y.js.map
|