@theokit/sdk 4.9.0 → 4.10.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.
@@ -13,6 +13,32 @@
13
13
  */
14
14
  export type ApiMode = "chat_completions" | "anthropic_messages" | "responses_api" | "bedrock" | "bedrock_anthropic";
15
15
  export type AuthType = "api_key" | "oauth_device_code" | "oauth_external" | "aws_sdk" | "aws_bearer" | "gcp_oauth" | "none";
16
+ /**
17
+ * M41 (agent-builder provider framework) — the context a provider's `transform` receives per request. An
18
+ * object from day one so it can grow without breaking (M42 adds the resolved `credential`).
19
+ *
20
+ * @public
21
+ */
22
+ export interface ProviderTransformContext {
23
+ /** The bearer the router resolved for this request (env var, injected key, or an oauth access token). */
24
+ apiKey: string;
25
+ }
26
+ /**
27
+ * M41 — the one OPTIONAL behavior seam on a provider profile. It lets a provider own its per-request auth:
28
+ * `fetch` is the universal seam (a provider that returns its own fetch fully controls headers + refresh, for
29
+ * every transport that accepts a fetch); `headers` is a convenience merged over `extraHeaders` on transports
30
+ * that carry them (responses_api). This is the CONTRACT-shape adaptation of OpenCode's provider `auth.loader`
31
+ * (MIT © 2025 opencode — `packages/core/src/plugin/provider/*.ts`), retargeted to theokit's transport model.
32
+ * Closes the gap where a `ProviderProfile` could only declare STATIC headers.
33
+ *
34
+ * @public
35
+ */
36
+ export interface ProviderTransform {
37
+ /** Dynamic per-request headers, merged OVER the profile's static `extraHeaders`. */
38
+ headers?(ctx: ProviderTransformContext): Record<string, string>;
39
+ /** A fetch to use for this provider's requests (refresh-aware / fully provider-controlled). */
40
+ fetch?(ctx: ProviderTransformContext): typeof fetch;
41
+ }
16
42
  export interface ProviderProfile {
17
43
  name: string;
18
44
  apiMode: ApiMode;
@@ -28,6 +54,11 @@ export interface ProviderProfile {
28
54
  fallbackModels: ReadonlyArray<string>;
29
55
  extraHeaders?: Record<string, string>;
30
56
  bodyOverrides?: Record<string, unknown>;
57
+ /**
58
+ * M41 — the optional per-request behavior seam (dynamic headers + refresh-aware fetch). Absent ⇒ the profile
59
+ * is pure data and takes the static path byte-for-byte. See {@link ProviderTransform}.
60
+ */
61
+ transform?: ProviderTransform;
31
62
  /**
32
63
  * Opt-in leaked-dialect safe-parse (theokit#58 follow-up). When `true`, a chat_completions finish
33
64
  * with ZERO native `tool_calls` has its assistant content scanned for the Hermes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theokit/sdk",
3
- "version": "4.9.0",
3
+ "version": "4.10.0",
4
4
  "description": "TypeScript SDK for the Theo agent harness — same surface, local or cloud.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/usetheodev/theokit-sdk#readme",