@theokit/sdk 4.10.0 → 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 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
@@ -1206,7 +1206,12 @@ interface ProviderTransformContext {
1206
1206
  * @public
1207
1207
  */
1208
1208
  interface ProviderTransform {
1209
- /** Dynamic per-request headers, merged OVER the profile's static `extraHeaders`. */
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
+ */
1210
1215
  headers?(ctx: ProviderTransformContext): Record<string, string>;
1211
1216
  /** A fetch to use for this provider's requests (refresh-aware / fully provider-controlled). */
1212
1217
  fetch?(ctx: ProviderTransformContext): typeof fetch;
@@ -2559,4 +2564,4 @@ declare class Cron {
2559
2564
  static status(_options?: CronStartOptions): Promise<CronSchedulerStatus>;
2560
2565
  }
2561
2566
 
2562
- 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 SystemPromptContext as aA, type SystemPromptMemoryFact as aB, type SystemPromptSkillRef as aC, type TelemetrySettings as aD, 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 RecordSessionSummaryArgs as ak, type ResolvedProviderRoute as al, type RunUntilIterator as am, type SDKAgentPlugins as an, type SDKAgentSkillDetail as ao, type SDKAgentSkills as ap, type SDKArtifact as aq, type SDKContextManager as ar, type SDKPluginMetadata as as, type SDKProvidersManager as at, type SessionRecord as au, type SessionStore as av, type SettingSource as aw, Skill as ax, type SkillsResolver as ay, type SkillsResolverContext 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 };
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 };
@@ -1206,7 +1206,12 @@ interface ProviderTransformContext {
1206
1206
  * @public
1207
1207
  */
1208
1208
  interface ProviderTransform {
1209
- /** Dynamic per-request headers, merged OVER the profile's static `extraHeaders`. */
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
+ */
1210
1215
  headers?(ctx: ProviderTransformContext): Record<string, string>;
1211
1216
  /** A fetch to use for this provider's requests (refresh-aware / fully provider-controlled). */
1212
1217
  fetch?(ctx: ProviderTransformContext): typeof fetch;
@@ -2559,4 +2564,4 @@ declare class Cron {
2559
2564
  static status(_options?: CronStartOptions): Promise<CronSchedulerStatus>;
2560
2565
  }
2561
2566
 
2562
- 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 SystemPromptContext as aA, type SystemPromptMemoryFact as aB, type SystemPromptSkillRef as aC, type TelemetrySettings as aD, 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 RecordSessionSummaryArgs as ak, type ResolvedProviderRoute as al, type RunUntilIterator as am, type SDKAgentPlugins as an, type SDKAgentSkillDetail as ao, type SDKAgentSkills as ap, type SDKArtifact as aq, type SDKContextManager as ar, type SDKPluginMetadata as as, type SDKProvidersManager as at, type SessionRecord as au, type SessionStore as av, type SettingSource as aw, Skill as ax, type SkillsResolver as ay, type SkillsResolverContext 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 };
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,9 +13686,11 @@ function resolveApiKey2(envVars) {
13685
13686
  return void 0;
13686
13687
  }
13687
13688
  function selectTransport(profile, apiKey) {
13688
- const transformCtx = { apiKey };
13689
- const transformFetch = profile.transform?.fetch?.(transformCtx);
13690
- const transformHeaders = profile.transform?.headers?.(transformCtx);
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
+ };
13691
13694
  if (profile.apiMode === "chat_completions") {
13692
13695
  if (profile.name === "ollama") {
13693
13696
  const ollamaBase = process.env.OLLAMA_HOST ?? profile.baseUrl;
@@ -13704,7 +13707,10 @@ function selectTransport(profile, apiKey) {
13704
13707
  }
13705
13708
  const envOverride = resolveBaseUrlEnvOverride(profile.name);
13706
13709
  if (envOverride !== void 0) opts.baseUrl = envOverride;
13707
- if (transformFetch !== void 0) opts.fetch = transformFetch;
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;
13708
13714
  return new OpenAIClient(opts);
13709
13715
  }
13710
13716
  if (profile.apiMode === "anthropic_messages") {
@@ -13721,12 +13727,13 @@ function selectTransport(profile, apiKey) {
13721
13727
  return new BedrockAnthropicClient(realKey !== void 0 ? { apiKey: realKey } : {});
13722
13728
  }
13723
13729
  if (profile.apiMode === "responses_api") {
13724
- const mergedHeaders = profile.extraHeaders !== void 0 || transformHeaders !== void 0 ? { ...profile.extraHeaders, ...transformHeaders } : void 0;
13730
+ const t = applyTransform();
13731
+ const mergedHeaders = profile.extraHeaders !== void 0 || t.headers !== void 0 ? { ...profile.extraHeaders, ...t.headers } : void 0;
13725
13732
  return new ResponsesApiClient({
13726
13733
  apiKey,
13727
13734
  ...profile.baseUrl !== void 0 ? { baseUrl: profile.baseUrl } : {},
13728
13735
  ...mergedHeaders !== void 0 ? { extraHeaders: mergedHeaders } : {},
13729
- ...transformFetch !== void 0 ? { fetch: transformFetch } : {},
13736
+ ...t.fetch !== void 0 ? { fetch: t.fetch } : {},
13730
13737
  providerName: profile.name
13731
13738
  });
13732
13739
  }