@theokit/sdk 4.9.1 → 4.10.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.
- package/CHANGELOG.md +30 -0
- package/dist/{cron-D_0p_gXd.d.ts → cron-C7catiH8.d.ts} +37 -1
- package/dist/{cron-26WH1n7o.d.cts → cron-DK1WVZnI.d.cts} +37 -1
- package/dist/cron.cjs +14 -1
- 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 +14 -1
- package/dist/cron.js.map +1 -1
- package/dist/eval.cjs +14 -1
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +14 -1
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +14 -1
- 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 +14 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/providers/types.d.ts +1 -1
- package/dist/types/provider-profile.d.ts +36 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.10.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Provider transform seam hardening (agent-builder M41 review): `OpenAIClient` now honors `extraHeaders` so `chat_completions` providers get `transform.headers` (previously silently dropped); the `transform` seam is invoked per-branch (no side effects for transports that ignore it); `ProviderTransform` + `ProviderTransformContext` are re-exported from the package entry; added back-compat golden tests (plain `responses_api` passthrough) + a `chat_completions` transform.fetch test.
|
|
8
|
+
|
|
9
|
+
## 4.10.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- Provider `transform` seam (agent-builder M41): `ProviderProfile` gains an optional `transform` (dynamic `headers(ctx)` + refresh-aware `fetch(ctx)`), fed through `selectTransport` into the `chat_completions` + `responses_api` transports — a provider can now own its per-request auth/headers. A profile without `transform` takes the static path byte-for-byte. Contract-shape adaptation of OpenCode's provider `auth.loader` (MIT).
|
|
14
|
+
|
|
15
|
+
## 4.9.1
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Responses transport strips a `provider/` prefix from the model id (defense-in-depth: the ChatGPT Codex backend wants a bare `gpt-5.4`, decoupled from the router's provider-inference heuristic).
|
|
20
|
+
|
|
21
|
+
## 4.9.0
|
|
22
|
+
|
|
23
|
+
### Minor Changes
|
|
24
|
+
|
|
25
|
+
- `responses_api` transport (agent-builder M40): a `ResponsesApiClient` for the OpenAI Responses API (ChatGPT Codex backend + any responses provider). The `responses_api` apiMode was declared but had no transport (`selectTransport` threw); this ships it — body build + SSE state machine, consuming `baseUrl` + `extraHeaders`. Protocol shape adapted from OpenCode's `openai-responses.ts` (MIT), recorded fixtures as golden tests.
|
|
26
|
+
|
|
27
|
+
## 4.8.0
|
|
28
|
+
|
|
29
|
+
### Minor Changes
|
|
30
|
+
|
|
31
|
+
- `Agent.rename(agentId, name)` (agent-builder M39): the public mutator for the registry `name` field (mirrors `Agent.archive`/`setArchivedFlag`). The registry already carried `name` (`SDKAgentInfo.name`) but had no public setter.
|
|
32
|
+
|
|
3
33
|
## 4.7.1
|
|
4
34
|
|
|
5
35
|
### Patch Changes
|
|
@@ -1185,6 +1185,37 @@ interface MemoryProvider {
|
|
|
1185
1185
|
*/
|
|
1186
1186
|
type ApiMode = "chat_completions" | "anthropic_messages" | "responses_api" | "bedrock" | "bedrock_anthropic";
|
|
1187
1187
|
type AuthType = "api_key" | "oauth_device_code" | "oauth_external" | "aws_sdk" | "aws_bearer" | "gcp_oauth" | "none";
|
|
1188
|
+
/**
|
|
1189
|
+
* M41 (agent-builder provider framework) — the context a provider's `transform` receives per request. An
|
|
1190
|
+
* object from day one so it can grow without breaking (M42 adds the resolved `credential`).
|
|
1191
|
+
*
|
|
1192
|
+
* @public
|
|
1193
|
+
*/
|
|
1194
|
+
interface ProviderTransformContext {
|
|
1195
|
+
/** The bearer the router resolved for this request (env var, injected key, or an oauth access token). */
|
|
1196
|
+
apiKey: string;
|
|
1197
|
+
}
|
|
1198
|
+
/**
|
|
1199
|
+
* M41 — the one OPTIONAL behavior seam on a provider profile. It lets a provider own its per-request auth:
|
|
1200
|
+
* `fetch` is the universal seam (a provider that returns its own fetch fully controls headers + refresh, for
|
|
1201
|
+
* every transport that accepts a fetch); `headers` is a convenience merged over `extraHeaders` on transports
|
|
1202
|
+
* that carry them (responses_api). This is the CONTRACT-shape adaptation of OpenCode's provider `auth.loader`
|
|
1203
|
+
* (MIT © 2025 opencode — `packages/core/src/plugin/provider/*.ts`), retargeted to theokit's transport model.
|
|
1204
|
+
* Closes the gap where a `ProviderProfile` could only declare STATIC headers.
|
|
1205
|
+
*
|
|
1206
|
+
* @public
|
|
1207
|
+
*/
|
|
1208
|
+
interface ProviderTransform {
|
|
1209
|
+
/**
|
|
1210
|
+
* Dynamic per-request headers, merged OVER the profile's static `extraHeaders`, and spread AFTER the
|
|
1211
|
+
* transport's base `authorization`/`content-type`. A provider that owns its auth MAY intentionally set
|
|
1212
|
+
* `authorization` here to override the resolved bearer — but a stray `authorization`/`content-type` key
|
|
1213
|
+
* will silently replace the base header, so return only the headers you mean to add.
|
|
1214
|
+
*/
|
|
1215
|
+
headers?(ctx: ProviderTransformContext): Record<string, string>;
|
|
1216
|
+
/** A fetch to use for this provider's requests (refresh-aware / fully provider-controlled). */
|
|
1217
|
+
fetch?(ctx: ProviderTransformContext): typeof fetch;
|
|
1218
|
+
}
|
|
1188
1219
|
interface ProviderProfile {
|
|
1189
1220
|
name: string;
|
|
1190
1221
|
apiMode: ApiMode;
|
|
@@ -1200,6 +1231,11 @@ interface ProviderProfile {
|
|
|
1200
1231
|
fallbackModels: ReadonlyArray<string>;
|
|
1201
1232
|
extraHeaders?: Record<string, string>;
|
|
1202
1233
|
bodyOverrides?: Record<string, unknown>;
|
|
1234
|
+
/**
|
|
1235
|
+
* M41 — the optional per-request behavior seam (dynamic headers + refresh-aware fetch). Absent ⇒ the profile
|
|
1236
|
+
* is pure data and takes the static path byte-for-byte. See {@link ProviderTransform}.
|
|
1237
|
+
*/
|
|
1238
|
+
transform?: ProviderTransform;
|
|
1203
1239
|
/**
|
|
1204
1240
|
* Opt-in leaked-dialect safe-parse (theokit#58 follow-up). When `true`, a chat_completions finish
|
|
1205
1241
|
* with ZERO native `tool_calls` has its assistant content scanned for the Hermes
|
|
@@ -2528,4 +2564,4 @@ declare class Cron {
|
|
|
2528
2564
|
static status(_options?: CronStartOptions): Promise<CronSchedulerStatus>;
|
|
2529
2565
|
}
|
|
2530
2566
|
|
|
2531
|
-
export { type GoalOptions as $, type AgentOptions as A, type BudgetTracker as B, type CloudOptions as C, type ContextBudget as D, type ContextManagerKind as E, type ContextSnapshot as F, type GetAgentOptions as G, type ContextSource as H, type InlineSkill as I, type ContextSourceStatus as J, type CreateSkillSpec as K, type LocalOptions as L, type MemorySettings as M, Cron as N, type CronCreateOptions as O, type ProviderRoutingSettings as P, type CronGetOptions as Q, type CronJob as R, type SystemPromptResolver as S, type CronJobStatus as T, type CronListOptions as U, type CronOperationOptions as V, type CronRunOptions as W, type CronRuntime as X, type CronSchedulerStatus as Y, type CronStartOptions as Z, type GoalEvent as _, type AgentDefinition as a, type GoalResult as a0, type HookName as a1, type InvalidateCacheOptions as a2, type MemoryAdapter as a3, type MemoryAdapterCapabilities as a4, type MemoryContext as a5, type MemoryFact as a6, type MemoryProviderHandle as a7, type MemoryProviderInitOptions as a8, type MemoryRevision as a9, type
|
|
2567
|
+
export { type GoalOptions as $, type AgentOptions as A, type BudgetTracker as B, type CloudOptions as C, type ContextBudget as D, type ContextManagerKind as E, type ContextSnapshot as F, type GetAgentOptions as G, type ContextSource as H, type InlineSkill as I, type ContextSourceStatus as J, type CreateSkillSpec as K, type LocalOptions as L, type MemorySettings as M, Cron as N, type CronCreateOptions as O, type ProviderRoutingSettings as P, type CronGetOptions as Q, type CronJob as R, type SystemPromptResolver as S, type CronJobStatus as T, type CronListOptions as U, type CronOperationOptions as V, type CronRunOptions as W, type CronRuntime as X, type CronSchedulerStatus as Y, type CronStartOptions as Z, type GoalEvent as _, type AgentDefinition as a, type GoalResult as a0, type HookName as a1, type InvalidateCacheOptions as a2, type MemoryAdapter as a3, type MemoryAdapterCapabilities as a4, type MemoryContext as a5, type MemoryFact as a6, type MemoryProviderHandle as a7, type MemoryProviderInitOptions as a8, type MemoryRevision as a9, type SkillsResolver as aA, type SkillsResolverContext as aB, type SystemPromptContext as aC, type SystemPromptMemoryFact as aD, type SystemPromptSkillRef as aE, type TelemetrySettings as aF, type MemoryToolSchema as aa, type MemoryTurnMessage as ab, type PersonalityPreset as ac, type PluginContext as ad, type PostAssistantReplyContext as ae, type PreToolCallContext as af, type PreUserSendContext as ag, type PreUserSendResult as ah, type ProviderCapability as ai, type ProviderRoute as aj, type ProviderTransform as ak, type ProviderTransformContext as al, type RecordSessionSummaryArgs as am, type ResolvedProviderRoute as an, type RunUntilIterator as ao, type SDKAgentPlugins as ap, type SDKAgentSkillDetail as aq, type SDKAgentSkills as ar, type SDKArtifact as as, type SDKContextManager as at, type SDKPluginMetadata as au, type SDKProvidersManager as av, type SessionRecord as aw, type SessionStore as ax, type SettingSource as ay, Skill as az, type ContextSettings as b, type PluginsSettings as c, type SkillsSettings as d, type SDKAgent as e, type ListAgentsOptions as f, type ListResult as g, type SDKAgentInfo as h, type ListRunsOptions as i, type GetRunOptions as j, type AgentOperationOptions as k, type Plugin as l, type ProviderProfile as m, type MemoryProvider as n, type MemoryId as o, type PreToolCallDecision as p, type StepResult as q, type SDKProvider as r, type ActiveMemoryPassArgs as s, type ActiveMemoryPassResult as t, type AgentMemory as u, type BudgetCheck as v, type BudgetTotal as w, type BudgetUsageEvent as x, type CloudEnv as y, type CloudRepo as z };
|
|
@@ -1185,6 +1185,37 @@ interface MemoryProvider {
|
|
|
1185
1185
|
*/
|
|
1186
1186
|
type ApiMode = "chat_completions" | "anthropic_messages" | "responses_api" | "bedrock" | "bedrock_anthropic";
|
|
1187
1187
|
type AuthType = "api_key" | "oauth_device_code" | "oauth_external" | "aws_sdk" | "aws_bearer" | "gcp_oauth" | "none";
|
|
1188
|
+
/**
|
|
1189
|
+
* M41 (agent-builder provider framework) — the context a provider's `transform` receives per request. An
|
|
1190
|
+
* object from day one so it can grow without breaking (M42 adds the resolved `credential`).
|
|
1191
|
+
*
|
|
1192
|
+
* @public
|
|
1193
|
+
*/
|
|
1194
|
+
interface ProviderTransformContext {
|
|
1195
|
+
/** The bearer the router resolved for this request (env var, injected key, or an oauth access token). */
|
|
1196
|
+
apiKey: string;
|
|
1197
|
+
}
|
|
1198
|
+
/**
|
|
1199
|
+
* M41 — the one OPTIONAL behavior seam on a provider profile. It lets a provider own its per-request auth:
|
|
1200
|
+
* `fetch` is the universal seam (a provider that returns its own fetch fully controls headers + refresh, for
|
|
1201
|
+
* every transport that accepts a fetch); `headers` is a convenience merged over `extraHeaders` on transports
|
|
1202
|
+
* that carry them (responses_api). This is the CONTRACT-shape adaptation of OpenCode's provider `auth.loader`
|
|
1203
|
+
* (MIT © 2025 opencode — `packages/core/src/plugin/provider/*.ts`), retargeted to theokit's transport model.
|
|
1204
|
+
* Closes the gap where a `ProviderProfile` could only declare STATIC headers.
|
|
1205
|
+
*
|
|
1206
|
+
* @public
|
|
1207
|
+
*/
|
|
1208
|
+
interface ProviderTransform {
|
|
1209
|
+
/**
|
|
1210
|
+
* Dynamic per-request headers, merged OVER the profile's static `extraHeaders`, and spread AFTER the
|
|
1211
|
+
* transport's base `authorization`/`content-type`. A provider that owns its auth MAY intentionally set
|
|
1212
|
+
* `authorization` here to override the resolved bearer — but a stray `authorization`/`content-type` key
|
|
1213
|
+
* will silently replace the base header, so return only the headers you mean to add.
|
|
1214
|
+
*/
|
|
1215
|
+
headers?(ctx: ProviderTransformContext): Record<string, string>;
|
|
1216
|
+
/** A fetch to use for this provider's requests (refresh-aware / fully provider-controlled). */
|
|
1217
|
+
fetch?(ctx: ProviderTransformContext): typeof fetch;
|
|
1218
|
+
}
|
|
1188
1219
|
interface ProviderProfile {
|
|
1189
1220
|
name: string;
|
|
1190
1221
|
apiMode: ApiMode;
|
|
@@ -1200,6 +1231,11 @@ interface ProviderProfile {
|
|
|
1200
1231
|
fallbackModels: ReadonlyArray<string>;
|
|
1201
1232
|
extraHeaders?: Record<string, string>;
|
|
1202
1233
|
bodyOverrides?: Record<string, unknown>;
|
|
1234
|
+
/**
|
|
1235
|
+
* M41 — the optional per-request behavior seam (dynamic headers + refresh-aware fetch). Absent ⇒ the profile
|
|
1236
|
+
* is pure data and takes the static path byte-for-byte. See {@link ProviderTransform}.
|
|
1237
|
+
*/
|
|
1238
|
+
transform?: ProviderTransform;
|
|
1203
1239
|
/**
|
|
1204
1240
|
* Opt-in leaked-dialect safe-parse (theokit#58 follow-up). When `true`, a chat_completions finish
|
|
1205
1241
|
* with ZERO native `tool_calls` has its assistant content scanned for the Hermes
|
|
@@ -2528,4 +2564,4 @@ declare class Cron {
|
|
|
2528
2564
|
static status(_options?: CronStartOptions): Promise<CronSchedulerStatus>;
|
|
2529
2565
|
}
|
|
2530
2566
|
|
|
2531
|
-
export { type GoalOptions as $, type AgentOptions as A, type BudgetTracker as B, type CloudOptions as C, type ContextBudget as D, type ContextManagerKind as E, type ContextSnapshot as F, type GetAgentOptions as G, type ContextSource as H, type InlineSkill as I, type ContextSourceStatus as J, type CreateSkillSpec as K, type LocalOptions as L, type MemorySettings as M, Cron as N, type CronCreateOptions as O, type ProviderRoutingSettings as P, type CronGetOptions as Q, type CronJob as R, type SystemPromptResolver as S, type CronJobStatus as T, type CronListOptions as U, type CronOperationOptions as V, type CronRunOptions as W, type CronRuntime as X, type CronSchedulerStatus as Y, type CronStartOptions as Z, type GoalEvent as _, type AgentDefinition as a, type GoalResult as a0, type HookName as a1, type InvalidateCacheOptions as a2, type MemoryAdapter as a3, type MemoryAdapterCapabilities as a4, type MemoryContext as a5, type MemoryFact as a6, type MemoryProviderHandle as a7, type MemoryProviderInitOptions as a8, type MemoryRevision as a9, type
|
|
2567
|
+
export { type GoalOptions as $, type AgentOptions as A, type BudgetTracker as B, type CloudOptions as C, type ContextBudget as D, type ContextManagerKind as E, type ContextSnapshot as F, type GetAgentOptions as G, type ContextSource as H, type InlineSkill as I, type ContextSourceStatus as J, type CreateSkillSpec as K, type LocalOptions as L, type MemorySettings as M, Cron as N, type CronCreateOptions as O, type ProviderRoutingSettings as P, type CronGetOptions as Q, type CronJob as R, type SystemPromptResolver as S, type CronJobStatus as T, type CronListOptions as U, type CronOperationOptions as V, type CronRunOptions as W, type CronRuntime as X, type CronSchedulerStatus as Y, type CronStartOptions as Z, type GoalEvent as _, type AgentDefinition as a, type GoalResult as a0, type HookName as a1, type InvalidateCacheOptions as a2, type MemoryAdapter as a3, type MemoryAdapterCapabilities as a4, type MemoryContext as a5, type MemoryFact as a6, type MemoryProviderHandle as a7, type MemoryProviderInitOptions as a8, type MemoryRevision as a9, type SkillsResolver as aA, type SkillsResolverContext as aB, type SystemPromptContext as aC, type SystemPromptMemoryFact as aD, type SystemPromptSkillRef as aE, type TelemetrySettings as aF, type MemoryToolSchema as aa, type MemoryTurnMessage as ab, type PersonalityPreset as ac, type PluginContext as ad, type PostAssistantReplyContext as ae, type PreToolCallContext as af, type PreUserSendContext as ag, type PreUserSendResult as ah, type ProviderCapability as ai, type ProviderRoute as aj, type ProviderTransform as ak, type ProviderTransformContext as al, type RecordSessionSummaryArgs as am, type ResolvedProviderRoute as an, type RunUntilIterator as ao, type SDKAgentPlugins as ap, type SDKAgentSkillDetail as aq, type SDKAgentSkills as ar, type SDKArtifact as as, type SDKContextManager as at, type SDKPluginMetadata as au, type SDKProvidersManager as av, type SessionRecord as aw, type SessionStore as ax, type SettingSource as ay, Skill as az, type ContextSettings as b, type PluginsSettings as c, type SkillsSettings as d, type SDKAgent as e, type ListAgentsOptions as f, type ListResult as g, type SDKAgentInfo as h, type ListRunsOptions as i, type GetRunOptions as j, type AgentOperationOptions as k, type Plugin as l, type ProviderProfile as m, type MemoryProvider as n, type MemoryId as o, type PreToolCallDecision as p, type StepResult as q, type SDKProvider as r, type ActiveMemoryPassArgs as s, type ActiveMemoryPassResult as t, type AgentMemory as u, type BudgetCheck as v, type BudgetTotal as w, type BudgetUsageEvent as x, type CloudEnv as y, type CloudRepo as z };
|
package/dist/cron.cjs
CHANGED
|
@@ -12613,6 +12613,7 @@ var OpenAIClient = class {
|
|
|
12613
12613
|
if (this.options.organization !== void 0) {
|
|
12614
12614
|
headers["openai-organization"] = this.options.organization;
|
|
12615
12615
|
}
|
|
12616
|
+
if (this.options.extraHeaders !== void 0) Object.assign(headers, this.options.extraHeaders);
|
|
12616
12617
|
const providerId = this.options.providerName ?? this.name;
|
|
12617
12618
|
let response;
|
|
12618
12619
|
try {
|
|
@@ -13685,6 +13686,11 @@ function resolveApiKey2(envVars) {
|
|
|
13685
13686
|
return void 0;
|
|
13686
13687
|
}
|
|
13687
13688
|
function selectTransport(profile, apiKey) {
|
|
13689
|
+
const applyTransform = () => {
|
|
13690
|
+
if (profile.transform === void 0) return {};
|
|
13691
|
+
const ctx = { apiKey };
|
|
13692
|
+
return { fetch: profile.transform.fetch?.(ctx), headers: profile.transform.headers?.(ctx) };
|
|
13693
|
+
};
|
|
13688
13694
|
if (profile.apiMode === "chat_completions") {
|
|
13689
13695
|
if (profile.name === "ollama") {
|
|
13690
13696
|
const ollamaBase = process.env.OLLAMA_HOST ?? profile.baseUrl;
|
|
@@ -13701,6 +13707,10 @@ function selectTransport(profile, apiKey) {
|
|
|
13701
13707
|
}
|
|
13702
13708
|
const envOverride = resolveBaseUrlEnvOverride(profile.name);
|
|
13703
13709
|
if (envOverride !== void 0) opts.baseUrl = envOverride;
|
|
13710
|
+
const t = applyTransform();
|
|
13711
|
+
if (t.fetch !== void 0) opts.fetch = t.fetch;
|
|
13712
|
+
const merged = profile.extraHeaders !== void 0 || t.headers !== void 0 ? { ...profile.extraHeaders, ...t.headers } : void 0;
|
|
13713
|
+
if (merged !== void 0) opts.extraHeaders = merged;
|
|
13704
13714
|
return new OpenAIClient(opts);
|
|
13705
13715
|
}
|
|
13706
13716
|
if (profile.apiMode === "anthropic_messages") {
|
|
@@ -13717,10 +13727,13 @@ function selectTransport(profile, apiKey) {
|
|
|
13717
13727
|
return new BedrockAnthropicClient(realKey !== void 0 ? { apiKey: realKey } : {});
|
|
13718
13728
|
}
|
|
13719
13729
|
if (profile.apiMode === "responses_api") {
|
|
13730
|
+
const t = applyTransform();
|
|
13731
|
+
const mergedHeaders = profile.extraHeaders !== void 0 || t.headers !== void 0 ? { ...profile.extraHeaders, ...t.headers } : void 0;
|
|
13720
13732
|
return new ResponsesApiClient({
|
|
13721
13733
|
apiKey,
|
|
13722
13734
|
...profile.baseUrl !== void 0 ? { baseUrl: profile.baseUrl } : {},
|
|
13723
|
-
...
|
|
13735
|
+
...mergedHeaders !== void 0 ? { extraHeaders: mergedHeaders } : {},
|
|
13736
|
+
...t.fetch !== void 0 ? { fetch: t.fetch } : {},
|
|
13724
13737
|
providerName: profile.name
|
|
13725
13738
|
});
|
|
13726
13739
|
}
|