@rowan-agent/models 0.4.4 → 0.4.7

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/README.md CHANGED
@@ -1,36 +1,183 @@
1
- # @rowan-agent/adapters
1
+ # @rowan-agent/models
2
2
 
3
- ## Main Features
3
+ Model registry, streaming provider implementations, cost calculation, and protocol types. Supports OpenAI Chat Completions, OpenAI Responses, and Anthropic Messages APIs with streaming, retry, tool calling, and thinking/reasoning.
4
4
 
5
- `@rowan-agent/adapters` connects external model services to the Rowan runtime protocol. The current primary implementation is an OpenAI-compatible Chat Completions adapter that resolves configuration, builds requests, handles retries and timeouts, and normalizes JSON model output into typed Rowan phase output events such as routing decisions, tasks, tool calls, and verification results.
5
+ ## Installation
6
6
 
7
- The package also provides JSON extraction helpers. They can parse complete JSON, `json` fenced code blocks, or balanced JSON fragments embedded in text. When model output does not match the expected contract, the adapter raises `OpenAICompatibleError` or `JsonExtractionError` with useful error codes for logging and recovery.
7
+ ```bash
8
+ bun add @rowan-agent/models
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```ts
14
+ import { resolveModel, calculateCost, stream } from "@rowan-agent/models";
15
+
16
+ const model = resolveModel("anthropic/claude-sonnet-4-20250514");
17
+
18
+ for await (const event of stream(model, request, { signal })) {
19
+ if (event.type === "text_delta") process.stdout.write(event.delta);
20
+ }
21
+
22
+ const cost = calculateCost(model, usage);
23
+ console.log(cost.total); // USD
24
+ ```
25
+
26
+ ## Model Registry
27
+
28
+ An in-memory registry of model definitions. Models are auto-registered on import from `models.generated.ts`. Use `resolveModel` for quick lookup by `"provider/model"` string, or `registerModel` to add custom models.
29
+
30
+ ```ts
31
+ import { registerModel, getModel, resolveModel, getProviders, getModels, getAllModels } from "@rowan-agent/models";
32
+
33
+ registerModel({
34
+ id: "gpt-4.1-mini", name: "gpt-4.1-mini",
35
+ api: "openai-completions", provider: "openai",
36
+ baseUrl: "https://api.openai.com/v1",
37
+ reasoning: false, input: ["text", "image"],
38
+ cost: { input: 0.40, output: 1.60, cacheRead: 0.10, cacheWrite: 0.40 },
39
+ contextWindow: 1047576, maxTokens: 32768,
40
+ });
41
+
42
+ const model = resolveModel("openai/gpt-4.1-mini");
43
+ const providers = getProviders(); // ["openai", "anthropic", ...]
44
+ const all = getAllModels(); // Model[]
45
+ ```
46
+
47
+ ### Pre-registered Models
8
48
 
9
- ## Architecture
49
+ | Provider | Models |
50
+ |----------|--------|
51
+ | `anthropic` | claude-sonnet-4-20250514, claude-opus-4-20250514, claude-haiku-4-20250514 |
52
+ | `openai` | gpt-4o, and others |
10
53
 
11
- `src/index.ts` exports the package surface.
54
+ ## Cost Calculation
12
55
 
13
- `src/openai-compatible.ts` is the main adapter layer and has three core responsibilities:
56
+ Computes per-token costs from usage data, broken down by input, output, cache read, and cache write.
14
57
 
15
- - `resolveOpenAICompatibleConfig` resolves `baseUrl`, `apiKey`, `model`, timeout, retry, and tool settings from input options and environment variables.
16
- - `callOpenAICompatibleChatCompletion` wraps HTTP requests, response parsing, error normalization, exponential backoff retries, and abort/timeout handling.
17
- - `createOpenAICompatibleStream` implements Rowan's `StreamFn`, uses `@rowan-agent/context` to build phase prompts, and converts model output into typed `phase_output` events from `@rowan-agent/protocol`.
58
+ ```ts
59
+ import { calculateCost, resolveModel } from "@rowan-agent/models";
60
+
61
+ const model = resolveModel("anthropic/claude-sonnet-4-20250514")!;
62
+ const cost = calculateCost(model, {
63
+ inputTokens: 1000, outputTokens: 500,
64
+ cacheReadTokens: 2000, cacheWriteTokens: 100,
65
+ });
66
+ // cost = { input, output, cacheRead, cacheWrite, total }
67
+ ```
68
+
69
+ ## Providers
70
+
71
+ Three built-in API providers, each with streaming support and exponential backoff retry.
72
+
73
+ ### Provider Registry
74
+
75
+ The dispatch layer routes requests to the right provider based on the model's `api` field.
76
+
77
+ ```ts
78
+ import { stream, streamByRef, createDispatchStream, registerApiProvider } from "@rowan-agent/models";
79
+
80
+ for await (const event of stream(model, request, { signal })) { ... }
81
+ for await (const event of streamByRef("openai/gpt-4.1-mini", request)) { ... }
18
82
 
19
- `src/json-extract.ts` only handles JSON extraction and parse errors from model text. It is independent from model providers and runtime phases.
83
+ const streamFn = createDispatchStream(); // reusable StreamFn
84
+ registerApiProvider({ api: "my-api", stream: myApiStreamFn }); // custom provider
85
+ ```
20
86
 
21
- ## Usage Flow
87
+ ### OpenAI Chat Completions
22
88
 
23
- 1. Prepare OpenAI-compatible environment variables: `ROWAN_OPENAI_BASE_URL` is optional, while `ROWAN_OPENAI_API_KEY` and `ROWAN_MODEL` are required.
24
- 2. Call `resolveOpenAICompatibleConfig` and pass the runtime tools through `tools`.
25
- 3. Call `createOpenAICompatibleStream` to create a `StreamFn` that the Rowan runtime can consume.
26
- 4. Pass the `stream` to `Agent` from `@rowan-agent/agent`.
89
+ Endpoint: `{baseUrl}/chat/completions`. Auth: `Authorization: Bearer`.
27
90
 
28
91
  ```ts
29
- import {
30
- createOpenAICompatibleStream,
31
- resolveOpenAICompatibleConfig,
32
- } from "@rowan-agent/adapters";
92
+ import { resolveOpenAICompletionsConfig, createOpenAICompletionsStream, callOpenAICompletions } from "@rowan-agent/models/providers";
33
93
 
34
- const config = resolveOpenAICompatibleConfig({ tools });
35
- const stream = createOpenAICompatibleStream(config);
94
+ const config = resolveOpenAICompletionsConfig(); // from env vars
95
+ const streamFn = createOpenAICompletionsStream(config); // StreamFn
96
+ const response = await callOpenAICompletions(config, req); // non-streaming
36
97
  ```
98
+
99
+ Supports: text, image (base64), tool calling, streaming (SSE with non-streaming fallback), JSON response format.
100
+
101
+ ### OpenAI Responses
102
+
103
+ Endpoint: `{baseUrl}/responses`. Auth: `Authorization: Bearer`.
104
+
105
+ ```ts
106
+ import { resolveOpenAIResponsesConfig, createOpenAIResponsesStream } from "@rowan-agent/models/providers";
107
+
108
+ const config = resolveOpenAIResponsesConfig({ reasoningEffort: "high" });
109
+ const streamFn = createOpenAIResponsesStream(config);
110
+ ```
111
+
112
+ Supports: text, tool calling, streaming (always), thinking/reasoning via `reasoningEffort`.
113
+
114
+ ### Anthropic Messages
115
+
116
+ Endpoint: `{baseUrl}/v1/messages`. Auth: `x-api-key` + `anthropic-version: 2023-06-01`.
117
+
118
+ ```ts
119
+ import { resolveAnthropicConfig, createAnthropicStream } from "@rowan-agent/models/providers";
120
+
121
+ const config = resolveAnthropicConfig({ thinking: { budgetTokens: 10000 } });
122
+ const streamFn = createAnthropicStream(config);
123
+ ```
124
+
125
+ Supports: text, image (base64), tool calling, streaming (always), thinking/reasoning via `thinking.budgetTokens`.
126
+
127
+ ## SSE Streaming
128
+
129
+ Low-level SSE parser for `ReadableStream` bodies.
130
+
131
+ ```ts
132
+ import { iterateSseMessages } from "@rowan-agent/models";
133
+
134
+ for await (const sse of iterateSseMessages(response.body!, signal)) {
135
+ if (sse.data === "[DONE]") break;
136
+ const chunk = JSON.parse(sse.data);
137
+ }
138
+ ```
139
+
140
+ ## Protocol Types
141
+
142
+ Shared types for LLM requests, responses, stream events, and agent-level constructs.
143
+
144
+ ```ts
145
+ type LlmRequest = { model: LlmModelRef; system?: string; messages: LlmMessage[]; tools?: LlmToolDefinition[]; toolChoice?: LlmToolChoice; maxTokens?: number; temperature?: number };
146
+ type LlmResponse = { content: string; thinking?: string; toolCalls?: LlmToolCall[]; stopReason?: LlmStopReason; usage?: LlmTokenUsage };
147
+ type LlmStreamEvent = { type: "start" } | { type: "text_delta"; delta: string } | { type: "thinking_delta"; delta: string } | { type: "tool_call_start"; ... } | { type: "done"; stopReason: LlmStopReason } | ...;
148
+ type StreamFn = (request: LlmRequest, options: LlmStreamOptions) => AsyncIterable<LlmStreamEvent>;
149
+ type LlmModelRef = { provider: string; name: string };
150
+ type Model = { id: string; name: string; api: Api; provider: Provider; baseUrl: string; reasoning: boolean; input: ("text" | "image")[]; cost: ModelCost; contextWindow: number; maxTokens: number };
151
+ type KnownApi = "openai-completions" | "openai-responses" | "anthropic-messages";
152
+ type KnownProvider = "openai" | "anthropic" | "deepseek" | "openrouter" | "groq" | "together" | "fireworks" | "xai" | "cerebras";
153
+ ```
154
+
155
+ Agent-level types shared with the agent package:
156
+
157
+ ```ts
158
+ type AgentMessage = { id: string; role: "system" | "user" | "assistant" | "tool"; content: string | LlmContentPart[]; createdAt: string };
159
+ type AgentEvent = { type: "agent_start" | "agent_end" | "turn_start" | ... ; ts: string; ... };
160
+ type ToolCall = { id: string; name: string; args: unknown };
161
+ type ToolResult = { toolCallId: string; toolName: string; ok: boolean; content: unknown; error?: string };
162
+ type Outcome = { id: string; message: string; toolResults?: Array<...> };
163
+ ```
164
+
165
+ ## Source Structure
166
+
167
+ ```
168
+ src/
169
+ ├── protocol.ts # All protocol types
170
+ ├── models.ts # Model registry
171
+ ├── models.generated.ts # Pre-registered model catalog
172
+ ├── registry.ts # API provider dispatch (stream, streamByRef)
173
+ ├── sse.ts # SSE parser
174
+ └── providers/
175
+ ├── openai-completions.ts
176
+ ├── openai-responses.ts
177
+ ├── anthropic.ts
178
+ └── shared.ts # ProviderError, retry utilities
179
+ ```
180
+
181
+ ## Version
182
+
183
+ Current version: **0.4.6**
@@ -13,9 +13,6 @@ var ProviderError = class extends Error {
13
13
  this.details = input.details;
14
14
  }
15
15
  };
16
- function defaultEnv() {
17
- return process.env;
18
- }
19
16
  function normalizeBaseUrl(baseUrl) {
20
17
  return baseUrl.replace(/\/+$/, "");
21
18
  }
@@ -152,6 +149,14 @@ function normalizeUsage(usage) {
152
149
  function summarizeRequestUsage(request) {
153
150
  return { inputMessages: request.messages.length + (request.system ? 1 : 0) };
154
151
  }
152
+ function sanitizeToolInput(input) {
153
+ if (typeof input !== "string") return input;
154
+ try {
155
+ return JSON.parse(input);
156
+ } catch {
157
+ return input;
158
+ }
159
+ }
155
160
 
156
161
  // src/sse.ts
157
162
  function flushSseEvent(state) {
@@ -247,14 +252,13 @@ async function* iterateSseMessages(body, signal) {
247
252
 
248
253
  // src/providers/openai-completions.ts
249
254
  function resolveOpenAICompletionsConfig(input = {}) {
250
- const env = input.env ?? defaultEnv();
251
- const baseUrl = nonEmpty(input.baseUrl) ?? nonEmpty(env.ROWAN_OPENAI_BASE_URL) ?? "https://api.openai.com/v1";
252
- const apiKey = nonEmpty(input.apiKey) ?? nonEmpty(env.ROWAN_OPENAI_API_KEY);
253
- const model = nonEmpty(input.model) ?? nonEmpty(env.ROWAN_MODEL);
255
+ const baseUrl = nonEmpty(input.baseUrl) ?? "https://api.openai.com/v1";
256
+ const apiKey = nonEmpty(input.apiKey);
257
+ const model = nonEmpty(input.model);
254
258
  return {
255
259
  baseUrl: normalizeBaseUrl(baseUrl),
256
- apiKey: requireValue("API key", apiKey, "set ROWAN_OPENAI_API_KEY or pass --api-key"),
257
- model: requireValue("model", model, "set ROWAN_MODEL or pass --model"),
260
+ apiKey: requireValue("API key", apiKey, "model.apiKey is required (set apiKey in config.yaml or pass --api-key)"),
261
+ model: requireValue("model", model, "model.id is required"),
258
262
  ...input.temperature !== void 0 ? { temperature: input.temperature } : {},
259
263
  ...input.maxTokens !== void 0 ? { maxTokens: input.maxTokens } : {},
260
264
  ...input.timeoutMs !== void 0 ? { timeoutMs: input.timeoutMs } : {},
@@ -330,7 +334,7 @@ function convertMessages(messages) {
330
334
  type: "function",
331
335
  function: {
332
336
  name: p.name,
333
- arguments: typeof p.input === "string" ? p.input : JSON.stringify(p.input)
337
+ arguments: JSON.stringify(sanitizeToolInput(p.input))
334
338
  }
335
339
  }));
336
340
  result.push({ role: "assistant", content: text, tool_calls: toolCalls });
@@ -582,7 +586,11 @@ function createOpenAICompletionsStream(config) {
582
586
  var streamOpenAICompletions = (model, request, options) => {
583
587
  const config = resolveOpenAICompletionsConfig({
584
588
  baseUrl: model.baseUrl,
585
- model: model.id
589
+ model: model.id,
590
+ apiKey: model.apiKey,
591
+ timeoutMs: model.timeoutMs,
592
+ maxRetries: model.maxRetries,
593
+ retryDelayMs: model.retryDelayMs
586
594
  });
587
595
  return streamChatCompletions(config, request, options);
588
596
  };
@@ -620,14 +628,13 @@ async function callOpenAICompletions(config, request, options = {}) {
620
628
 
621
629
  // src/providers/openai-responses.ts
622
630
  function resolveOpenAIResponsesConfig(input = {}) {
623
- const env = input.env ?? defaultEnv();
624
- const baseUrl = nonEmpty(input.baseUrl) ?? nonEmpty(env.ROWAN_OPENAI_BASE_URL) ?? "https://api.openai.com/v1";
625
- const apiKey = nonEmpty(input.apiKey) ?? nonEmpty(env.ROWAN_OPENAI_API_KEY);
626
- const model = nonEmpty(input.model) ?? nonEmpty(env.ROWAN_MODEL);
631
+ const baseUrl = nonEmpty(input.baseUrl) ?? "https://api.openai.com/v1";
632
+ const apiKey = nonEmpty(input.apiKey);
633
+ const model = nonEmpty(input.model);
627
634
  return {
628
635
  baseUrl: normalizeBaseUrl(baseUrl),
629
- apiKey: requireValue("API key", apiKey, "set ROWAN_OPENAI_API_KEY or pass --api-key"),
630
- model: requireValue("model", model, "set ROWAN_MODEL or pass --model"),
636
+ apiKey: requireValue("API key", apiKey, "model.apiKey is required (set apiKey in config.yaml or pass --api-key)"),
637
+ model: requireValue("model", model, "model.id is required"),
631
638
  ...input.temperature !== void 0 ? { temperature: input.temperature } : {},
632
639
  ...input.maxTokens !== void 0 ? { maxTokens: input.maxTokens } : {},
633
640
  ...input.timeoutMs !== void 0 ? { timeoutMs: input.timeoutMs } : {},
@@ -674,7 +681,7 @@ function convertMessages2(messages) {
674
681
  type: "function_call",
675
682
  id: part.id,
676
683
  name: part.name,
677
- arguments: typeof part.input === "string" ? part.input : JSON.stringify(part.input)
684
+ arguments: JSON.stringify(sanitizeToolInput(part.input))
678
685
  });
679
686
  }
680
687
  }
@@ -905,7 +912,11 @@ function createOpenAIResponsesStream(config) {
905
912
  var streamOpenAIResponses = (model, request, options) => {
906
913
  const config = resolveOpenAIResponsesConfig({
907
914
  baseUrl: model.baseUrl,
908
- model: model.id
915
+ model: model.id,
916
+ apiKey: model.apiKey,
917
+ timeoutMs: model.timeoutMs,
918
+ maxRetries: model.maxRetries,
919
+ retryDelayMs: model.retryDelayMs
909
920
  });
910
921
  return streamResponses(config, request, options);
911
922
  };
@@ -913,14 +924,13 @@ var streamOpenAIResponses = (model, request, options) => {
913
924
  // src/providers/anthropic.ts
914
925
  var DEFAULT_MAX_TOKENS = 8192;
915
926
  function resolveAnthropicConfig(input = {}) {
916
- const env = input.env ?? defaultEnv();
917
- const baseUrl = nonEmpty(input.baseUrl) ?? nonEmpty(env.ROWAN_ANTHROPIC_BASE_URL) ?? "https://api.anthropic.com";
918
- const apiKey = nonEmpty(input.apiKey) ?? nonEmpty(env.ROWAN_ANTHROPIC_API_KEY) ?? nonEmpty(env.ANTHROPIC_API_KEY);
919
- const model = nonEmpty(input.model) ?? nonEmpty(env.ROWAN_MODEL);
927
+ const baseUrl = nonEmpty(input.baseUrl) ?? "https://api.anthropic.com";
928
+ const apiKey = nonEmpty(input.apiKey);
929
+ const model = nonEmpty(input.model);
920
930
  return {
921
931
  baseUrl: normalizeBaseUrl(baseUrl),
922
- apiKey: requireValue("API key", apiKey, "set ROWAN_ANTHROPIC_API_KEY or pass --api-key"),
923
- model: requireValue("model", model, "set ROWAN_MODEL or pass --model"),
932
+ apiKey: requireValue("API key", apiKey, "model.apiKey is required (set apiKey in config.yaml or pass --api-key)"),
933
+ model: requireValue("model", model, "model.id is required"),
924
934
  ...input.maxTokens !== void 0 ? { maxTokens: input.maxTokens } : {},
925
935
  ...input.timeoutMs !== void 0 ? { timeoutMs: input.timeoutMs } : {},
926
936
  ...input.maxRetries !== void 0 ? { maxRetries: input.maxRetries } : {},
@@ -1206,7 +1216,11 @@ function createAnthropicStream(config) {
1206
1216
  var streamAnthropic = (model, request, options) => {
1207
1217
  const config = resolveAnthropicConfig({
1208
1218
  baseUrl: model.baseUrl,
1209
- model: model.id
1219
+ model: model.id,
1220
+ apiKey: model.apiKey,
1221
+ timeoutMs: model.timeoutMs,
1222
+ maxRetries: model.maxRetries,
1223
+ retryDelayMs: model.retryDelayMs
1210
1224
  });
1211
1225
  return streamAnthropicMessages(config, request, options);
1212
1226
  };
@@ -1,5 +1,5 @@
1
- type KnownApi = "openai-completions" | "openai-responses" | "anthropic-messages";
2
- type Api = KnownApi | (string & {});
1
+ type KnownProtocol = "openai-completions" | "openai-responses" | "anthropic-messages";
2
+ type Protocol = KnownProtocol | (string & {});
3
3
  type KnownProvider = "openai" | "anthropic" | "deepseek" | "openrouter" | "groq" | "together" | "fireworks" | "xai" | "cerebras";
4
4
  type Provider = KnownProvider | string;
5
5
  interface ModelCost {
@@ -10,8 +10,8 @@ interface ModelCost {
10
10
  }
11
11
  interface Model {
12
12
  id: string;
13
- name: string;
14
- api: Api;
13
+ name?: string;
14
+ protocol: Protocol;
15
15
  provider: Provider;
16
16
  baseUrl: string;
17
17
  reasoning: boolean;
@@ -20,11 +20,15 @@ interface Model {
20
20
  contextWindow: number;
21
21
  maxTokens: number;
22
22
  headers?: Record<string, string>;
23
+ apiKey?: string;
24
+ timeoutMs?: number;
25
+ maxRetries?: number;
26
+ retryDelayMs?: number;
23
27
  }
24
28
  type ProviderModelConfig = {
25
29
  id: string;
26
- name: string;
27
- api: Api;
30
+ name?: string;
31
+ protocol: Protocol;
28
32
  reasoning: boolean;
29
33
  input: ("text" | "image")[];
30
34
  cost: ModelCost;
@@ -32,10 +36,10 @@ type ProviderModelConfig = {
32
36
  maxTokens: number;
33
37
  };
34
38
  type ProviderConfig = {
35
- name: string;
39
+ id: string;
36
40
  baseUrl: string;
37
- apiKey?: string;
38
- api: Api;
41
+ apiKey: string;
42
+ protocol: Protocol;
39
43
  streamSimple?: ApiStreamFn;
40
44
  headers?: Record<string, string>;
41
45
  authHeader?: string;
@@ -48,7 +52,7 @@ type ProviderConfig = {
48
52
  };
49
53
  type LlmModelRef = {
50
54
  provider: string;
51
- name: string;
55
+ id: string;
52
56
  };
53
57
  type LlmTokenUsage = {
54
58
  inputTokens?: number;
@@ -196,37 +200,39 @@ type LlmStreamOptions = {
196
200
  type StreamFn = (request: LlmRequest, options: LlmStreamOptions) => AsyncIterable<LlmStreamEvent>;
197
201
  /**
198
202
  * API-level stream function: receives a resolved Model and yields events.
199
- * Providers implement this signature. The registry dispatches by model.api.
203
+ * Providers implement this signature. The registry dispatches by model.protocol.
200
204
  */
201
205
  type ApiStreamFn = (model: Model, request: LlmRequest, options: LlmStreamOptions) => AsyncIterable<LlmStreamEvent>;
202
- type AgentContextMessage = {
206
+ type AgentMessage = {
203
207
  id: string;
204
208
  role: "system" | "user" | "assistant" | "tool";
205
- content: string;
209
+ content: string | LlmContentPart[];
206
210
  createdAt: string;
207
211
  metadata?: Record<string, unknown> & {
208
212
  phase?: string;
209
- toolCalls?: Array<{
210
- id: string;
211
- name: string;
212
- args: unknown;
213
- }>;
214
- toolCallId?: string;
215
- toolName?: string;
216
- isError?: boolean;
217
213
  };
218
214
  };
219
- type AgentContextSkill = {
215
+ type Skill = {
220
216
  name: string;
221
217
  description: string;
218
+ /** Absolute path to the SKILL.md file */
222
219
  filePath: string;
220
+ /** Directory containing the SKILL.md file */
223
221
  baseDir: string;
222
+ /** Full body content of the SKILL.md (after frontmatter) */
223
+ content: string;
224
224
  disableModelInvocation: boolean;
225
225
  };
226
226
  type Outcome = {
227
227
  id: string;
228
- taskId?: string;
229
228
  message: string;
229
+ toolResults?: Array<{
230
+ toolCallId: string;
231
+ toolName: string;
232
+ ok: boolean;
233
+ content: unknown;
234
+ error?: string;
235
+ }>;
230
236
  };
231
237
  type ToolCall = {
232
238
  id: string;
@@ -247,15 +253,15 @@ type AgentEvent = {
247
253
  } | {
248
254
  type: "agent_end";
249
255
  sessionId: string;
250
- messages: AgentContextMessage[];
256
+ messages: AgentMessage[];
251
257
  ts: string;
252
258
  } | {
253
259
  type: "turn_start";
254
- content: AgentContextMessage[];
260
+ content: AgentMessage[];
255
261
  ts: string;
256
262
  } | {
257
263
  type: "turn_end";
258
- content: AgentContextMessage[];
264
+ content: AgentMessage[];
259
265
  outcome?: Outcome;
260
266
  ts: string;
261
267
  } | {
@@ -273,16 +279,16 @@ type AgentEvent = {
273
279
  ts: string;
274
280
  } | {
275
281
  type: "message_start";
276
- message: AgentContextMessage;
282
+ message: AgentMessage;
277
283
  ts: string;
278
284
  } | {
279
285
  type: "message_update";
280
- message: AgentContextMessage;
286
+ message: AgentMessage;
281
287
  delta: string;
282
288
  ts: string;
283
289
  } | {
284
290
  type: "message_end";
285
- message: AgentContextMessage;
291
+ message: AgentMessage;
286
292
  ts: string;
287
293
  } | {
288
294
  type: "tool_execution_start";
@@ -350,7 +356,6 @@ type ResolveOpenAICompletionsConfigInput = {
350
356
  retryDelayMs?: number;
351
357
  fetch?: ProviderFetch;
352
358
  responseFormat?: boolean;
353
- env?: Record<string, string | undefined>;
354
359
  };
355
360
  declare function resolveOpenAICompletionsConfig(input?: ResolveOpenAICompletionsConfigInput): OpenAICompletionsConfig;
356
361
  declare function createOpenAICompletionsStream(config: OpenAICompletionsConfig): StreamFn;
@@ -378,7 +383,6 @@ type ResolveOpenAIResponsesConfigInput = {
378
383
  retryDelayMs?: number;
379
384
  fetch?: ProviderFetch;
380
385
  reasoningEffort?: "low" | "medium" | "high";
381
- env?: Record<string, string | undefined>;
382
386
  };
383
387
  declare function resolveOpenAIResponsesConfig(input?: ResolveOpenAIResponsesConfigInput): OpenAIResponsesConfig;
384
388
  declare function createOpenAIResponsesStream(config: OpenAIResponsesConfig): StreamFn;
@@ -413,7 +417,6 @@ type ResolveAnthropicConfigInput = {
413
417
  thinking?: {
414
418
  budgetTokens: number;
415
419
  };
416
- env?: Record<string, string | undefined>;
417
420
  };
418
421
  declare function resolveAnthropicConfig(input?: ResolveAnthropicConfigInput): AnthropicConfig;
419
422
  declare function createAnthropicStream(config: AnthropicConfig): StreamFn;
@@ -423,4 +426,4 @@ declare function createAnthropicStream(config: AnthropicConfig): StreamFn;
423
426
  */
424
427
  declare const streamAnthropic: ApiStreamFn;
425
428
 
426
- export { resolveAnthropicConfig as $, type Api as A, type BaseProviderConfig as B, type ContentBlock as C, type OpenAIResponsesConfig as D, type Outcome as E, type ProviderConfig as F, ProviderError as G, type ProviderFetch as H, type ProviderModelConfig as I, type ResolveOpenAICompletionsConfigInput as J, type KnownApi as K, type LlmTokenUsage as L, type Model as M, type ResolveOpenAIResponsesConfigInput as N, type OpenAICompletionsConfig as O, type Provider as P, type ThinkingBlock as Q, type ResolveAnthropicConfigInput as R, type StreamFn as S, type TextBlock as T, type ToolCall as U, type ToolCallBlock as V, type ToolResult as W, callOpenAICompletions as X, createAnthropicStream as Y, createOpenAICompletionsStream as Z, createOpenAIResponsesStream as _, type ApiStreamFn as a, resolveOpenAICompletionsConfig as a0, resolveOpenAIResponsesConfig as a1, streamAnthropic as a2, streamOpenAICompletions as a3, streamOpenAIResponses as a4, textFromPartial as a5, toolCallsFromPartial as a6, type LlmRequest as b, type LlmStreamOptions as c, type LlmStreamEvent as d, type AgentContextMessage as e, type AgentContextSkill as f, type AgentEvent as g, type AgentEventListener as h, type AnthropicConfig as i, type AssistantMessagePartial as j, type KnownProvider as k, type LlmContentPart as l, type LlmImageContent as m, type LlmMessage as n, type LlmModelRef as o, type LlmModelUsage as p, type LlmResponse as q, type LlmStopReason as r, type LlmTextContent as s, type LlmThinkingContent as t, type LlmToolCall as u, type LlmToolChoice as v, type LlmToolDefinition as w, type LlmToolResultContent as x, type LlmToolUseContent as y, type ModelCost as z };
429
+ export { resolveAnthropicConfig as $, type ApiStreamFn as A, type BaseProviderConfig as B, type ContentBlock as C, type Outcome as D, type ProviderConfig as E, ProviderError as F, type ProviderFetch as G, type ProviderModelConfig as H, type ResolveOpenAICompletionsConfigInput as I, type ResolveOpenAIResponsesConfigInput as J, type KnownProtocol as K, type LlmTokenUsage as L, type Model as M, type Skill as N, type OpenAICompletionsConfig as O, type Provider as P, type ThinkingBlock as Q, type ResolveAnthropicConfigInput as R, type StreamFn as S, type TextBlock as T, type ToolCall as U, type ToolCallBlock as V, type ToolResult as W, callOpenAICompletions as X, createAnthropicStream as Y, createOpenAICompletionsStream as Z, createOpenAIResponsesStream as _, type Protocol as a, resolveOpenAICompletionsConfig as a0, resolveOpenAIResponsesConfig as a1, streamAnthropic as a2, streamOpenAICompletions as a3, streamOpenAIResponses as a4, textFromPartial as a5, toolCallsFromPartial as a6, type LlmRequest as b, type LlmStreamOptions as c, type LlmStreamEvent as d, type AgentEvent as e, type AgentEventListener as f, type AgentMessage as g, type AnthropicConfig as h, type AssistantMessagePartial as i, type KnownProvider as j, type LlmContentPart as k, type LlmImageContent as l, type LlmMessage as m, type LlmModelRef as n, type LlmModelUsage as o, type LlmResponse as p, type LlmStopReason as q, type LlmTextContent as r, type LlmThinkingContent as s, type LlmToolCall as t, type LlmToolChoice as u, type LlmToolDefinition as v, type LlmToolResultContent as w, type LlmToolUseContent as x, type ModelCost as y, type OpenAIResponsesConfig as z };