@nemesis-oss/ollama-sdk 1.3.0 → 1.4.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.
Files changed (58) hide show
  1. package/CHANGELOG.md +43 -212
  2. package/README.md +391 -18
  3. package/dist/compose-BR70yb4W.d.cts +164 -0
  4. package/dist/compose-DfAqKAFj.d.ts +164 -0
  5. package/dist/generated-api.cjs +454 -0
  6. package/dist/generated-api.cjs.map +1 -0
  7. package/dist/generated-api.d.cts +1651 -0
  8. package/dist/generated-api.d.ts +1651 -0
  9. package/dist/generated-api.js +428 -0
  10. package/dist/generated-api.js.map +1 -0
  11. package/dist/generated-models-schemas.cjs +328 -0
  12. package/dist/generated-models-schemas.cjs.map +1 -0
  13. package/dist/generated-models-schemas.d.cts +463 -0
  14. package/dist/generated-models-schemas.d.ts +463 -0
  15. package/dist/generated-models-schemas.js +291 -0
  16. package/dist/generated-models-schemas.js.map +1 -0
  17. package/dist/generated-runtime.cjs +145 -0
  18. package/dist/generated-runtime.cjs.map +1 -0
  19. package/dist/generated-runtime.d.cts +2 -0
  20. package/dist/generated-runtime.d.ts +2 -0
  21. package/dist/generated-runtime.js +143 -0
  22. package/dist/generated-runtime.js.map +1 -0
  23. package/dist/index-2RIErNT5.d.cts +583 -0
  24. package/dist/index-DIQ8NUbU.d.ts +583 -0
  25. package/dist/index.cjs +1886 -154
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.cts +817 -453
  28. package/dist/index.d.ts +817 -453
  29. package/dist/index.js +1877 -155
  30. package/dist/index.js.map +1 -1
  31. package/dist/mcp/tools.json +1058 -0
  32. package/dist/mcp-generated.cjs +386 -0
  33. package/dist/mcp-generated.cjs.map +1 -0
  34. package/dist/mcp-generated.d.cts +35 -0
  35. package/dist/mcp-generated.d.ts +35 -0
  36. package/dist/mcp-generated.js +381 -0
  37. package/dist/mcp-generated.js.map +1 -0
  38. package/dist/mcp-http.cjs +100 -0
  39. package/dist/mcp-http.cjs.map +1 -0
  40. package/dist/mcp-http.d.cts +48 -0
  41. package/dist/mcp-http.d.ts +48 -0
  42. package/dist/mcp-http.js +96 -0
  43. package/dist/mcp-http.js.map +1 -0
  44. package/dist/mcp-stdio.cjs +49 -0
  45. package/dist/mcp-stdio.cjs.map +1 -0
  46. package/dist/mcp-stdio.d.cts +34 -0
  47. package/dist/mcp-stdio.d.ts +34 -0
  48. package/dist/mcp-stdio.js +47 -0
  49. package/dist/mcp-stdio.js.map +1 -0
  50. package/dist/skills.cjs.map +1 -1
  51. package/dist/skills.d.cts +3 -2
  52. package/dist/skills.d.ts +3 -2
  53. package/dist/skills.js.map +1 -1
  54. package/dist/types-B9_axjum.d.cts +66 -0
  55. package/dist/types-B9_axjum.d.ts +66 -0
  56. package/dist/{compose-CDWq8oxJ.d.cts → types-BQhgW-du.d.cts} +68 -171
  57. package/dist/{compose-CDWq8oxJ.d.ts → types-BQhgW-du.d.ts} +68 -171
  58. package/package.json +96 -5
package/dist/index.d.ts CHANGED
@@ -1,339 +1,14 @@
1
- import { M as Message, C as ChatResponse, G as GenerateResponse, T as ToolCall, P as ProgressResponse, a as ModelResponse, S as ShowRequestOptions, b as ShowResponse, c as PullRequestOptions, d as PushRequestOptions, e as CreateRequestOptions, D as DeleteRequestOptions, f as StatusResponse, g as CopyRequestOptions, h as PsResponse, V as VersionResponse, i as ChatRequestOptions, j as GenerateRequestOptions, E as EmbedRequestOptions, k as EmbedResponse, l as EmbeddingsRequestOptions, m as EmbeddingsResponse, W as WebSearchRequestOptions, n as WebSearchResponse, o as WebFetchRequestOptions, p as WebFetchResponse, q as ToolHandler, r as Tool, A as AnyTool, s as ToolRegistry, t as ToolExecutionResult, u as ModelOptions, v as ToolDefinition } from './compose-CDWq8oxJ.js';
2
- export { w as AppliedSkillResult, x as ApplySkillOptions, F as FormatOption, L as ListResponse, y as Logprob, z as LogprobToken, B as ModelDetails, H as ParsedFrontmatter, R as RequestCancellationOptions, I as Role, J as Skill, K as SkillFrontmatter, N as SkillSummary, O as ToolCallFunction, Q as ToolExecutionContext, U as ToolExecutionFailure, X as ToolExecutionSuccess, Y as ToolFunctionDefinition, Z as ToolProperty, _ as ToolRegistryOptions, $ as WebSearchResult, a0 as applySkill, a1 as parseFrontmatter } from './compose-CDWq8oxJ.js';
1
+ import { F as FetchLike, M as Middleware, L as Logger, R as RequestLifecycleHook, H as HttpClient, a as OllamaStreamEvent, A as AbortableAsyncIterable, b as OllamaStreamEventType, P as ProgressStreamResult, B as BinaryBody, S as SseEvent, c as OllamaClientError, O as OllamaRuntime, C as ChatStreamResult, G as GenerateStreamResult, d as RawUsageSource, T as TokenUsage } from './index-DIQ8NUbU.js';
2
+ export { D as DoneEvent, E as ErrorEvent, e as HttpBody, f as HttpClientOptions, g as HttpRequestOptions, h as LifecycleErrorEvent, i as LifecycleRetryEvent, j as LifecycleStartEvent, k as LifecycleSuccessEvent, l as LogFn, m as MessageEvent, n as MiddlewareContext, N as NANOS_PER_MS, o as NANOS_PER_SECOND, p as NOOP_LOGGER, q as NextFunction, r as OllamaAbortError, s as OllamaAgentMaxIterationsError, t as OllamaAgentMaxToolCallsError, u as OllamaAuthError, v as OllamaClientErrorOptions, w as OllamaErrorRequestContext, x as OllamaErrorResponseContext, y as OllamaGenericClientError, z as OllamaIncompatibleModelError, I as OllamaMcpError, J as OllamaModelRoutingError, K as OllamaNetworkError, Q as OllamaNotFoundError, U as OllamaQuotaExceededError, V as OllamaRateLimitError, W as OllamaServerError, X as OllamaSkillInvalidError, Y as OllamaSkillNotFoundError, Z as OllamaTimeoutError, _ as OllamaToolTimeoutError, $ as OllamaToolValidationError, a0 as OllamaUnsupportedCapabilityError, a1 as RequestContext, a2 as RequestLifecycleEvent, a3 as ResponseContext, a4 as ThinkingEvent, a5 as TokenEvent, a6 as ToolCallEvent, a7 as composeMiddleware, a8 as createConsoleLogger, a9 as extractUsage, aa as mapError, ab as parseSseStream } from './index-DIQ8NUbU.js';
3
+ import { b as ThinkingMetadata, c as ModelResponse, S as ShowRequestOptions, d as ShowResponse, P as PullRequestOptions, e as ProgressResponse, f as PushRequestOptions, C as CreateRequestOptions, D as DeleteRequestOptions, g as StatusResponse, h as CopyRequestOptions, i as PsResponse, V as VersionResponse, j as ChatRequestOptions, k as ChatResponse, G as GenerateRequestOptions, l as GenerateResponse, E as EmbedRequestOptions, m as EmbedResponse, n as EmbeddingsRequestOptions, o as EmbeddingsResponse, W as WebSearchRequestOptions, p as WebSearchResponse, q as WebFetchRequestOptions, r as WebFetchResponse, T as ToolDefinition, a as ToolCall, M as Message, s as ModelOptions, t as ThinkValue } from './types-BQhgW-du.js';
4
+ export { F as FormatOption, L as ListResponse, u as Logprob, v as LogprobToken, w as ModelDetails, R as RequestCancellationOptions, x as Role, y as ToolCallFunction, z as ToolFunctionDefinition, A as ToolParameters, B as ToolProperty, H as WebSearchResult } from './types-BQhgW-du.js';
3
5
  import { z } from 'zod';
6
+ import { T as ToolHandler, e as Tool, f as AnyTool, g as ToolRegistry, h as ToolExecutionResult } from './compose-DfAqKAFj.js';
7
+ export { A as AppliedSkillResult, b as ApplySkillOptions, P as ParsedFrontmatter, a as Skill, c as SkillFrontmatter, S as SkillSummary, i as ToolExecutionContext, j as ToolExecutionFailure, k as ToolExecutionSuccess, l as ToolRegistryOptions, d as applySkill, p as parseFrontmatter } from './compose-DfAqKAFj.js';
8
+ import { a as McpClientLike, M as McpToolDescriptor } from './types-B9_axjum.js';
9
+ export { b as McpCallToolResult, c as McpContentBlock, d as McpIcon, e as McpListToolsParams, f as McpListToolsResult, g as McpRequestOptions, h as McpToolAnnotations, i as McpToolExecution } from './types-B9_axjum.js';
4
10
  import * as Otel from '@opentelemetry/api';
5
11
 
6
- /**
7
- * Structured, typed error hierarchy for OllamaClient.
8
- */
9
- interface OllamaErrorRequestContext {
10
- readonly method?: string | undefined;
11
- readonly url?: string | undefined;
12
- readonly model?: string | undefined;
13
- }
14
- interface OllamaErrorResponseContext {
15
- readonly status?: number | undefined;
16
- readonly headers?: Record<string, string> | undefined;
17
- readonly body?: unknown;
18
- }
19
- interface OllamaClientErrorOptions extends ErrorOptions {
20
- readonly code: string;
21
- readonly status?: number | undefined;
22
- readonly retryable?: boolean | undefined;
23
- readonly request?: OllamaErrorRequestContext | undefined;
24
- readonly response?: OllamaErrorResponseContext | undefined;
25
- }
26
- declare class OllamaClientError extends Error {
27
- readonly code: string;
28
- readonly status?: number | undefined;
29
- readonly retryable: boolean;
30
- readonly request?: OllamaErrorRequestContext | undefined;
31
- readonly response?: OllamaErrorResponseContext | undefined;
32
- constructor(message: string, options: OllamaClientErrorOptions);
33
- }
34
- declare class OllamaNetworkError extends OllamaClientError {
35
- constructor(message: string, options?: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> | undefined);
36
- }
37
- declare class OllamaTimeoutError extends OllamaClientError {
38
- readonly timeoutMs?: number | undefined;
39
- constructor(message: string, options?: (Omit<OllamaClientErrorOptions, 'code' | 'retryable'> & {
40
- timeoutMs?: number | undefined;
41
- }) | undefined);
42
- }
43
- declare class OllamaAuthError extends OllamaClientError {
44
- constructor(message: string, options?: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> | undefined);
45
- }
46
- declare class OllamaNotFoundError extends OllamaClientError {
47
- constructor(message: string, options?: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> | undefined);
48
- }
49
- declare class OllamaRateLimitError extends OllamaClientError {
50
- readonly retryAfterMs?: number | undefined;
51
- constructor(message: string, options?: (Omit<OllamaClientErrorOptions, 'code' | 'retryable'> & {
52
- retryAfterMs?: number | undefined;
53
- }) | undefined);
54
- }
55
- /**
56
- * Thrown client-side, before a network request is made, by `QuotaManager.assertCanProceed`
57
- * (see `src/quota.ts`) when issuing the request would exceed a configured usage budget for
58
- * one of its rolling windows. This is distinct from `OllamaRateLimitError`, which reflects
59
- * the server's own 429 response — Ollama Cloud does not expose account-level quota via the
60
- * API, so `QuotaManager` tracks usage against budgets the caller configures locally and
61
- * fails fast rather than waiting for the server to reject the request.
62
- */
63
- declare class OllamaQuotaExceededError extends OllamaClientError {
64
- readonly windowId: string;
65
- readonly resetAt: number;
66
- constructor(message: string, options: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> & {
67
- windowId: string;
68
- resetAt: number;
69
- });
70
- }
71
- declare class OllamaServerError extends OllamaClientError {
72
- constructor(message: string, options?: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> | undefined);
73
- }
74
- declare class OllamaAbortError extends OllamaClientError {
75
- constructor(message: string, options?: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> | undefined);
76
- }
77
- declare class OllamaToolValidationError extends OllamaClientError {
78
- readonly toolName: string;
79
- readonly issues?: unknown;
80
- constructor(message: string, options: Omit<OllamaClientErrorOptions, 'code'> & {
81
- toolName: string;
82
- issues?: unknown;
83
- });
84
- }
85
- declare class OllamaToolTimeoutError extends OllamaClientError {
86
- readonly toolName: string;
87
- readonly timeoutMs: number;
88
- constructor(message: string, options: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> & {
89
- toolName: string;
90
- timeoutMs: number;
91
- });
92
- }
93
- /**
94
- * Thrown client-side, before a network request is made, when a request asks for a
95
- * capability an endpoint is known not to support (e.g. structured output `format` against
96
- * an Ollama Cloud endpoint — see `ModelCapabilities.supportsStructuredOutputRequest` in
97
- * `src/capabilities/capabilities.ts`). Its `code` is included in `DEFAULT_FAILOVER_CODES`
98
- * by default, so in a multi-endpoint setup it causes failover to the next candidate rather
99
- * than failing outright — it only surfaces to the caller if every candidate is rejected.
100
- */
101
- declare class OllamaUnsupportedCapabilityError extends OllamaClientError {
102
- readonly capability: string;
103
- constructor(message: string, options: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> & {
104
- capability: string;
105
- });
106
- }
107
- /**
108
- * Thrown client-side, before any network call, when `config.endpoints` uses
109
- * `OllamaEndpoint.models` to scope endpoints/credentials to specific models and the
110
- * requested `model` isn't in any configured endpoint's allow-list. This is a routing
111
- * misconfiguration, not a connectivity problem — the SDK deliberately does not "probe"
112
- * unauthorized endpoints to find one that happens to work (that would burn quota on keys
113
- * that were never entitled to the model and produce non-deterministic startup behavior).
114
- */
115
- declare class OllamaModelRoutingError extends OllamaClientError {
116
- readonly model: string;
117
- readonly availableModels: readonly string[];
118
- constructor(message: string, options: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> & {
119
- model: string;
120
- availableModels: readonly string[];
121
- });
122
- }
123
- declare class OllamaAgentMaxIterationsError extends OllamaClientError {
124
- readonly maxIterations: number;
125
- constructor(message: string, options: Omit<OllamaClientErrorOptions, 'code'> & {
126
- maxIterations: number;
127
- });
128
- }
129
- declare class OllamaMcpError extends OllamaClientError {
130
- readonly mcpMethod: 'listTools' | 'callTool';
131
- readonly toolName?: string | undefined;
132
- constructor(message: string, options: Omit<OllamaClientErrorOptions, 'code'> & {
133
- mcpMethod: 'listTools' | 'callTool';
134
- toolName?: string | undefined;
135
- });
136
- }
137
- declare class OllamaSkillNotFoundError extends OllamaClientError {
138
- readonly skillName: string;
139
- constructor(message: string, options: Omit<OllamaClientErrorOptions, 'code'> & {
140
- skillName: string;
141
- });
142
- }
143
- declare class OllamaSkillInvalidError extends OllamaClientError {
144
- readonly skillName: string;
145
- readonly path?: string | undefined;
146
- constructor(message: string, options: Omit<OllamaClientErrorOptions, 'code'> & {
147
- skillName: string;
148
- path?: string | undefined;
149
- });
150
- }
151
- declare class OllamaGenericClientError extends OllamaClientError {
152
- constructor(message: string, options?: Omit<OllamaClientErrorOptions, 'code'> | undefined);
153
- }
154
- /**
155
- * Maps arbitrary thrown exceptions into structured OllamaClientError instances.
156
- */
157
- declare function mapError(error: unknown, context?: {
158
- request?: OllamaErrorRequestContext | undefined;
159
- response?: OllamaErrorResponseContext | undefined;
160
- }): OllamaClientError;
161
-
162
- /**
163
- * Token usage and duration calculation utilities.
164
- */
165
- declare const NANOS_PER_MS = 1000000;
166
- declare const NANOS_PER_SECOND = 1000000000;
167
- interface TokenUsage {
168
- readonly promptTokens: number;
169
- readonly completionTokens: number;
170
- readonly totalTokens: number;
171
- readonly tokensPerSecond?: number | undefined;
172
- readonly loadDurationMs?: number | undefined;
173
- readonly promptEvalDurationMs?: number | undefined;
174
- readonly evalDurationMs?: number | undefined;
175
- readonly totalDurationMs?: number | undefined;
176
- }
177
- interface RawUsageSource {
178
- readonly prompt_eval_count?: number | undefined;
179
- readonly eval_count?: number | undefined;
180
- readonly total_duration?: number | undefined;
181
- readonly load_duration?: number | undefined;
182
- readonly prompt_eval_duration?: number | undefined;
183
- readonly eval_duration?: number | undefined;
184
- }
185
- /**
186
- * Extracts and normalizes token usage metrics from an Ollama response.
187
- */
188
- declare function extractUsage(raw: RawUsageSource): TokenUsage;
189
-
190
- /**
191
- * Streaming event types, listener contracts, and aggregated result shapes.
192
- */
193
-
194
- interface TokenEvent {
195
- readonly type: 'token';
196
- readonly data: {
197
- readonly delta: string;
198
- readonly role?: string | undefined;
199
- };
200
- }
201
- interface ThinkingEvent {
202
- readonly type: 'thinking';
203
- readonly data: {
204
- readonly delta: string;
205
- };
206
- }
207
- interface ToolCallEvent {
208
- readonly type: 'tool_call';
209
- readonly data: {
210
- readonly toolCall: ToolCall;
211
- };
212
- }
213
- interface MessageEvent<TChunk> {
214
- readonly type: 'message';
215
- readonly data: {
216
- readonly chunk: TChunk;
217
- };
218
- }
219
- interface DoneEvent<TFinal> {
220
- readonly type: 'done';
221
- readonly data: {
222
- readonly result: TFinal;
223
- };
224
- }
225
- interface ErrorEvent {
226
- readonly type: 'error';
227
- readonly data: {
228
- readonly error: OllamaClientError;
229
- };
230
- }
231
- type OllamaStreamEvent<TChunk, TFinal> = TokenEvent | ThinkingEvent | ToolCallEvent | MessageEvent<TChunk> | DoneEvent<TFinal> | ErrorEvent;
232
- type OllamaStreamEventType = OllamaStreamEvent<unknown, unknown>['type'];
233
- interface ChatStreamResult {
234
- readonly message: Message;
235
- readonly model: string;
236
- readonly done: boolean;
237
- /** Mirrors the final chunk's `done_reason` (e.g. `"stop"`, `"load"`, `"unload"`). */
238
- readonly doneReason?: string | undefined;
239
- readonly totalDurationMs?: number | undefined;
240
- readonly usage?: TokenUsage | undefined;
241
- readonly raw?: ChatResponse | undefined;
242
- }
243
- interface GenerateStreamResult {
244
- readonly response: string;
245
- readonly model: string;
246
- readonly done: boolean;
247
- /** Mirrors the final chunk's `done_reason` (e.g. `"stop"`, `"load"`, `"unload"`). */
248
- readonly doneReason?: string | undefined;
249
- readonly totalDurationMs?: number | undefined;
250
- readonly usage?: TokenUsage | undefined;
251
- readonly raw?: GenerateResponse | undefined;
252
- }
253
- interface ProgressStreamResult {
254
- readonly status: string;
255
- readonly completed?: number | undefined;
256
- readonly total?: number | undefined;
257
- readonly done: boolean;
258
- readonly raw?: ProgressResponse | undefined;
259
- }
260
- interface AbortableAsyncIterable<T> extends AsyncIterable<T> {
261
- abort?: (() => void) | undefined;
262
- }
263
-
264
- /**
265
- * Structured logger and request lifecycle interfaces.
266
- */
267
- interface LogFn {
268
- (message: string, context?: Record<string, unknown>): void;
269
- }
270
- interface Logger {
271
- readonly debug: LogFn;
272
- readonly info: LogFn;
273
- readonly warn: LogFn;
274
- readonly error: LogFn;
275
- }
276
- interface LifecycleStartEvent {
277
- readonly type: 'start';
278
- readonly requestId: string;
279
- readonly method: string;
280
- readonly url: string;
281
- readonly timestamp: number;
282
- }
283
- interface LifecycleSuccessEvent {
284
- readonly type: 'success';
285
- readonly requestId: string;
286
- readonly durationMs: number;
287
- readonly status: number;
288
- readonly timestamp: number;
289
- }
290
- interface LifecycleRetryEvent {
291
- readonly type: 'retry';
292
- readonly requestId: string;
293
- readonly attempt: number;
294
- readonly error: Error;
295
- readonly delayMs: number;
296
- readonly timestamp: number;
297
- }
298
- interface LifecycleErrorEvent {
299
- readonly type: 'error';
300
- readonly requestId: string;
301
- readonly durationMs: number;
302
- readonly error: Error;
303
- readonly timestamp: number;
304
- }
305
- type RequestLifecycleEvent = LifecycleStartEvent | LifecycleSuccessEvent | LifecycleRetryEvent | LifecycleErrorEvent;
306
- interface RequestLifecycleHook {
307
- (event: RequestLifecycleEvent): void;
308
- }
309
- declare const NOOP_LOGGER: Logger;
310
- declare function createConsoleLogger(prefix?: string): Logger;
311
-
312
- /**
313
- * Request/response middleware pipeline.
314
- */
315
- interface RequestContext {
316
- readonly url: string;
317
- readonly method: string;
318
- readonly headers: Record<string, string>;
319
- readonly body?: unknown;
320
- readonly signal?: AbortSignal;
321
- }
322
- interface ResponseContext {
323
- readonly status: number;
324
- readonly headers: Record<string, string>;
325
- readonly body: unknown;
326
- }
327
- type NextFunction = () => Promise<ResponseContext>;
328
- interface MiddlewareContext {
329
- readonly request: RequestContext;
330
- readonly next: NextFunction;
331
- }
332
- interface Middleware {
333
- (ctx: MiddlewareContext): Promise<ResponseContext>;
334
- }
335
- declare function composeMiddleware(middlewares: readonly Middleware[], finalHandler: (req: RequestContext) => Promise<ResponseContext>): (req: RequestContext) => Promise<ResponseContext>;
336
-
337
12
  /**
338
13
  * Exponential backoff with full jitter calculation.
339
14
  */
@@ -362,39 +37,7 @@ declare const DEFAULT_RETRY_CONFIG: RetryConfig;
362
37
  /**
363
38
  * Executes an async operation with retries according to config.
364
39
  */
365
- declare function withRetry<T>(operation: (attempt: number) => Promise<T>, config?: RetryConfig): Promise<T>;
366
-
367
- /**
368
- * Native fetch HTTP transport client for Ollama API.
369
- */
370
-
371
- type FetchLike = typeof globalThis.fetch;
372
- type BinaryBody = Uint8Array | ArrayBuffer | string | Blob | ReadableStream<Uint8Array>;
373
- type HttpBody = unknown;
374
- interface HttpClientOptions {
375
- readonly baseUrl: string;
376
- readonly apiKey?: string | undefined;
377
- readonly headers?: Record<string, string> | undefined;
378
- readonly fetch?: FetchLike | undefined;
379
- }
380
- interface HttpRequestOptions {
381
- readonly path: string;
382
- readonly method?: 'GET' | 'POST' | 'DELETE' | 'HEAD' | undefined;
383
- readonly body?: HttpBody;
384
- readonly rawBody?: BinaryBody | undefined;
385
- readonly headers?: Record<string, string> | undefined;
386
- readonly signal?: AbortSignal | undefined;
387
- }
388
- declare class HttpClient {
389
- readonly baseUrl: string;
390
- private readonly apiKey?;
391
- private readonly defaultHeaders;
392
- private readonly fetchImpl;
393
- constructor(options: HttpClientOptions);
394
- private buildHeaders;
395
- request<T>(options: HttpRequestOptions): Promise<T>;
396
- requestStream<T>(options: HttpRequestOptions): Promise<AbortableAsyncIterable<T>>;
397
- }
40
+ declare function withRetry<T>(operation: (attempt: number) => Promise<T>, config?: RetryConfig, signal?: AbortSignal): Promise<T>;
398
41
 
399
42
  /**
400
43
  * Multi-endpoint registry with priority routing and circuit breaker failover.
@@ -662,7 +305,7 @@ interface EndpointHealthCheckResult {
662
305
  readonly version?: string;
663
306
  readonly error?: string;
664
307
  }
665
- declare function checkEndpointHealth(endpoint: OllamaEndpoint, fetchImpl?: FetchLike, timeoutMs?: number): Promise<EndpointHealthCheckResult>;
308
+ declare function checkEndpointHealth(endpoint: OllamaEndpoint, fetchImpl?: FetchLike, timeoutMs?: number, middleware?: readonly Middleware[] | undefined, onLifecycleEvent?: RequestLifecycleHook | undefined): Promise<EndpointHealthCheckResult>;
666
309
 
667
310
  /**
668
311
  * Model capability detection and runtime environment inference.
@@ -677,7 +320,11 @@ interface ModelCapabilities {
677
320
  readonly supportsEmbedding: boolean;
678
321
  readonly supportsCompletion: boolean;
679
322
  readonly supportsThinking: boolean;
323
+ /** Model-defined thinking values and default, when /api/show reports them. */
324
+ readonly thinking?: ThinkingMetadata | undefined;
680
325
  readonly supportsStreaming: true;
326
+ /** Maximum model context length reported by /api/show model_info, when available. */
327
+ readonly contextLength?: number | undefined;
681
328
  /**
682
329
  * Best-effort inference, not a guarantee: Ollama's `/api/show` does not report structured
683
330
  * output support as a queryable capability, so this is inferred from {@link inferRuntimeMode}
@@ -691,7 +338,7 @@ interface ModelCapabilities {
691
338
  readonly supportsStructuredOutputRequest: boolean;
692
339
  }
693
340
  declare function inferRuntimeMode(baseUrl: string): RuntimeMode;
694
- declare function detectModelCapabilities(http: HttpClient, model: string): Promise<ModelCapabilities>;
341
+ declare function detectModelCapabilities(http: HttpClient, model: string, signal?: AbortSignal): Promise<ModelCapabilities>;
695
342
  declare function listAvailableModels(http: HttpClient): Promise<ModelResponse[]>;
696
343
 
697
344
  /**
@@ -710,7 +357,8 @@ declare class OllamaStream<TChunk, TFinal> implements AsyncIterable<OllamaStream
710
357
  private readonly finalResultPromise;
711
358
  private resolveFinal;
712
359
  private rejectFinal;
713
- constructor(source: AbortableAsyncIterable<TChunk>, mapChunk: ChunkMapper<TChunk, TFinal>, aggregate: Aggregator<TChunk, TFinal>, initial: TFinal);
360
+ private removeAbortListener;
361
+ constructor(source: AbortableAsyncIterable<TChunk>, mapChunk: ChunkMapper<TChunk, TFinal>, aggregate: Aggregator<TChunk, TFinal>, initial: TFinal, signal?: AbortSignal);
714
362
  get finalResult(): Promise<TFinal>;
715
363
  abort(): void;
716
364
  on<TType extends OllamaStreamEventType>(type: TType, listener: (event: Extract<OllamaStreamEvent<TChunk, TFinal>, {
@@ -722,17 +370,22 @@ declare class OllamaStream<TChunk, TFinal> implements AsyncIterable<OllamaStream
722
370
  }
723
371
 
724
372
  /**
725
- * Model and blob management operations.
373
+ * Shared request-runner contract used by native and compatibility clients.
726
374
  */
727
375
 
728
376
  type RequestRunner = <T>(op: (http: HttpClient, signal: AbortSignal) => Promise<T>, opts?: {
729
- signal?: AbortSignal | undefined;
730
- timeoutMs?: number | undefined;
731
- singleEndpoint?: boolean | undefined;
732
- model?: string | undefined;
733
- /** See `OllamaClient.executeWithFailover`'s `holdUntil` doc. */
734
- holdUntil?: ((result: T) => Promise<unknown>) | undefined;
377
+ readonly signal?: AbortSignal | undefined;
378
+ readonly timeoutMs?: number | undefined;
379
+ readonly singleEndpoint?: boolean | undefined;
380
+ readonly model?: string | undefined;
381
+ /** Defers endpoint capacity release until the returned promise settles. */
382
+ readonly holdUntil?: ((result: T) => Promise<unknown>) | undefined;
735
383
  }) => Promise<T>;
384
+
385
+ /**
386
+ * Model and blob management operations.
387
+ */
388
+
736
389
  /**
737
390
  * Every operation here targets one specific Ollama server's local model catalog or blob
738
391
  * store — unlike `chat`/`generate`/`embed`, a different endpoint isn't an interchangeable
@@ -801,11 +454,26 @@ interface OpenAIToolCall {
801
454
  readonly arguments: string;
802
455
  };
803
456
  }
457
+ interface OpenAITextContentPart {
458
+ readonly type: 'text';
459
+ readonly text: string;
460
+ }
461
+ interface OpenAIImageUrlContentPart {
462
+ readonly type: 'image_url';
463
+ /** Ollama accepts a data/image URL string or the standard OpenAI URL object. */
464
+ readonly image_url: string | {
465
+ readonly url: string;
466
+ readonly detail?: 'auto' | 'low' | 'high' | 'original' | undefined;
467
+ };
468
+ }
469
+ type OpenAIContentPart = OpenAITextContentPart | OpenAIImageUrlContentPart;
804
470
  interface OpenAIMessage {
805
471
  readonly role: 'system' | 'user' | 'assistant' | 'tool';
806
- readonly content: string;
472
+ readonly content: string | readonly OpenAIContentPart[];
807
473
  readonly name?: string | undefined;
808
474
  readonly tool_calls?: readonly OpenAIToolCall[] | undefined;
475
+ /** Ollama may emit model reasoning alongside assistant content. */
476
+ readonly reasoning?: string | undefined;
809
477
  /** Set on a `role: 'tool'` message to identify which call this is a result for. */
810
478
  readonly tool_call_id?: string | undefined;
811
479
  }
@@ -822,6 +490,15 @@ interface OpenAITool {
822
490
  readonly type: 'function';
823
491
  readonly function: OpenAIFunctionDefinition;
824
492
  }
493
+ type OpenAIReasoningEffort = 'high' | 'medium' | 'low' | 'max' | 'none' | 'minimal' | 'xhigh' | 'ultra' | (string & {});
494
+ type OpenAIResponseFormat = {
495
+ readonly type: 'text';
496
+ } | {
497
+ readonly type: 'json_object';
498
+ } | {
499
+ readonly type: 'json_schema';
500
+ readonly json_schema: Record<string, unknown>;
501
+ };
825
502
  interface OpenAIChatCompletionRequest {
826
503
  readonly model: string;
827
504
  readonly messages: readonly OpenAIMessage[];
@@ -832,9 +509,16 @@ interface OpenAIChatCompletionRequest {
832
509
  readonly stream_options?: OpenAIStreamOptions | undefined;
833
510
  readonly max_tokens?: number | undefined;
834
511
  readonly stop?: readonly string[] | undefined;
512
+ readonly response_format?: OpenAIResponseFormat | undefined;
513
+ readonly seed?: number | undefined;
835
514
  readonly presence_penalty?: number | undefined;
836
515
  readonly frequency_penalty?: number | undefined;
837
516
  readonly user?: string | undefined;
517
+ readonly logit_bias?: Record<string, number> | undefined;
518
+ readonly n?: number | undefined;
519
+ /** Ollama exposes log probabilities for supported reasoning/chat models. */
520
+ readonly logprobs?: boolean | undefined;
521
+ readonly top_logprobs?: number | undefined;
838
522
  readonly tools?: readonly OpenAITool[] | undefined;
839
523
  /**
840
524
  * @remarks Accepted for OpenAI compatibility but ignored by Ollama — every tool the
@@ -855,33 +539,92 @@ interface OpenAIChatCompletionRequest {
855
539
  * Effort level for thinking models (e.g. `deepseek-r1`, `qwen3`). Equivalent to
856
540
  * `reasoning.effort`; only effective for models that support reasoning/thinking.
857
541
  */
858
- readonly reasoning_effort?: 'high' | 'medium' | 'low' | 'max' | 'none' | undefined;
542
+ readonly reasoning_effort?: OpenAIReasoningEffort | undefined;
859
543
  /**
860
544
  * Effort level for thinking models (e.g. `deepseek-r1`, `qwen3`), nested OpenAI-style.
861
545
  * Equivalent to `reasoning_effort`; only effective for models that support
862
546
  * reasoning/thinking.
863
547
  */
864
548
  readonly reasoning?: {
865
- readonly effort?: 'high' | 'medium' | 'low' | 'max' | 'none' | undefined;
549
+ readonly effort?: OpenAIReasoningEffort | undefined;
866
550
  } | undefined;
867
551
  }
552
+ /** Ollama Chat Completions supports text plus base64 image content via a string image URL. */
553
+ type OllamaOpenAIChatContentPart = OpenAITextContentPart | {
554
+ readonly type: 'image_url';
555
+ /** Ollama's current compatibility docs accept an image URL string, including data URLs. */
556
+ readonly image_url: string;
557
+ };
558
+ type OllamaOpenAIReasoningEffort = 'high' | 'medium' | 'low' | 'max' | 'none';
559
+ type OllamaOpenAIChatMessage = Omit<OpenAIMessage, 'content'> & {
560
+ readonly content: string | readonly OllamaOpenAIChatContentPart[];
561
+ };
562
+ /** Strict Ollama-documented Chat Completions request; excludes only the SDK-only parallel tool flag. */
563
+ type OllamaOpenAIChatCompletionRequest = Omit<OpenAIChatCompletionRequest, 'messages' | 'parallel_tool_calls' | 'reasoning_effort' | 'reasoning'> & {
564
+ readonly messages: readonly OllamaOpenAIChatMessage[];
565
+ readonly reasoning_effort?: OllamaOpenAIReasoningEffort | undefined;
566
+ readonly reasoning?: {
567
+ readonly effort?: OllamaOpenAIReasoningEffort | undefined;
568
+ } | undefined;
569
+ };
868
570
  interface OpenAIChatCompletionChoice {
869
571
  readonly index: number;
870
572
  readonly message: OpenAIMessage;
871
573
  readonly finish_reason: string;
574
+ readonly logprobs?: Record<string, unknown> | null | undefined;
872
575
  }
873
- interface OpenAIChatCompletionResponse {
576
+ interface OpenAIToolCallDelta {
577
+ readonly index: number;
578
+ readonly id?: string | undefined;
579
+ readonly type?: 'function' | undefined;
580
+ readonly function?: {
581
+ readonly name?: string | undefined;
582
+ readonly arguments?: string | undefined;
583
+ } | undefined;
584
+ }
585
+ interface OpenAIChatCompletionDelta {
586
+ readonly role?: OpenAIMessage['role'] | undefined;
587
+ readonly content?: string | null | undefined;
588
+ readonly reasoning?: string | null | undefined;
589
+ readonly refusal?: string | null | undefined;
590
+ readonly tool_calls?: readonly OpenAIToolCallDelta[] | undefined;
591
+ }
592
+ interface OpenAIChatCompletionChunkChoice {
593
+ readonly index: number;
594
+ readonly delta: OpenAIChatCompletionDelta;
595
+ readonly finish_reason?: string | null | undefined;
596
+ readonly logprobs?: Record<string, unknown> | null | undefined;
597
+ }
598
+ interface OpenAIChatCompletionChunk {
874
599
  readonly id: string;
875
- readonly object: 'chat.completion';
600
+ readonly object: 'chat.completion.chunk';
876
601
  readonly created: number;
877
602
  readonly model: string;
878
- readonly choices: readonly OpenAIChatCompletionChoice[];
603
+ readonly system_fingerprint?: string | undefined;
604
+ readonly choices: readonly OpenAIChatCompletionChunkChoice[];
879
605
  readonly usage?: {
880
606
  readonly prompt_tokens: number;
881
607
  readonly completion_tokens: number;
882
608
  readonly total_tokens: number;
609
+ } | null | undefined;
610
+ }
611
+ interface OpenAIUsage {
612
+ readonly prompt_tokens: number;
613
+ readonly completion_tokens: number;
614
+ readonly total_tokens: number;
615
+ readonly prompt_tokens_details?: {
616
+ readonly cached_tokens?: number | undefined;
883
617
  } | undefined;
884
618
  }
619
+ interface OpenAIChatCompletionResponse {
620
+ readonly id: string;
621
+ readonly object: 'chat.completion';
622
+ readonly created: number;
623
+ readonly model: string;
624
+ readonly system_fingerprint?: string | undefined;
625
+ readonly choices: readonly OpenAIChatCompletionChoice[];
626
+ readonly usage?: OpenAIUsage | undefined;
627
+ }
885
628
  interface OpenAIModelItem {
886
629
  readonly id: string;
887
630
  readonly object: 'model';
@@ -892,6 +635,87 @@ interface OpenAIListModelsResponse {
892
635
  readonly object: 'list';
893
636
  readonly data: readonly OpenAIModelItem[];
894
637
  }
638
+ interface OpenAICompletionRequest {
639
+ readonly model: string;
640
+ /** Ollama currently accepts a string prompt for /v1/completions. */
641
+ readonly prompt: string;
642
+ /** Number of log probability alternatives requested for completion tokens. */
643
+ readonly logprobs?: number | undefined;
644
+ readonly frequency_penalty?: number | undefined;
645
+ readonly presence_penalty?: number | undefined;
646
+ readonly seed?: number | undefined;
647
+ readonly stop?: readonly string[] | undefined;
648
+ readonly stream?: boolean | undefined;
649
+ readonly stream_options?: OpenAIStreamOptions | undefined;
650
+ readonly temperature?: number | undefined;
651
+ readonly top_p?: number | undefined;
652
+ readonly max_tokens?: number | undefined;
653
+ readonly suffix?: string | undefined;
654
+ readonly best_of?: number | undefined;
655
+ readonly echo?: boolean | undefined;
656
+ readonly logit_bias?: Record<string, number> | undefined;
657
+ readonly user?: string | undefined;
658
+ readonly n?: number | undefined;
659
+ }
660
+ /** Strict Ollama-documented Completions request. */
661
+ type OllamaOpenAICompletionRequest = OpenAICompletionRequest;
662
+ interface OpenAICompletionChoice {
663
+ readonly text: string;
664
+ readonly index: number;
665
+ readonly logprobs?: Record<string, unknown> | null | undefined;
666
+ readonly finish_reason: string | null;
667
+ }
668
+ interface OpenAICompletionChunk {
669
+ readonly id: string;
670
+ readonly object: 'text_completion';
671
+ readonly created: number;
672
+ readonly model: string;
673
+ readonly system_fingerprint?: string | undefined;
674
+ readonly choices: readonly {
675
+ readonly text: string;
676
+ readonly index: number;
677
+ readonly logprobs?: Record<string, unknown> | null | undefined;
678
+ readonly finish_reason?: string | null | undefined;
679
+ }[];
680
+ readonly usage?: {
681
+ readonly prompt_tokens: number;
682
+ readonly completion_tokens: number;
683
+ readonly total_tokens: number;
684
+ } | null | undefined;
685
+ }
686
+ interface OpenAICompletionResponse {
687
+ readonly id: string;
688
+ readonly object: 'text_completion';
689
+ readonly created: number;
690
+ readonly model: string;
691
+ readonly system_fingerprint?: string | undefined;
692
+ readonly choices: readonly OpenAICompletionChoice[];
693
+ readonly usage?: OpenAIUsage | undefined;
694
+ }
695
+ type OpenAIEmbeddingInput = string | readonly string[] | readonly number[] | readonly (readonly number[])[];
696
+ interface OpenAIEmbeddingRequest {
697
+ readonly model: string;
698
+ readonly input: OpenAIEmbeddingInput;
699
+ readonly encoding_format?: 'float' | 'base64' | undefined;
700
+ readonly dimensions?: number | undefined;
701
+ readonly user?: string | undefined;
702
+ }
703
+ /** Strict Ollama-documented Embeddings request. */
704
+ type OllamaOpenAIEmbeddingRequest = OpenAIEmbeddingRequest;
705
+ interface OpenAIEmbeddingItem {
706
+ readonly object: 'embedding';
707
+ readonly embedding: readonly number[] | string;
708
+ readonly index: number;
709
+ }
710
+ interface OpenAIEmbeddingResponse {
711
+ readonly object: 'list';
712
+ readonly data: readonly OpenAIEmbeddingItem[];
713
+ readonly model: string;
714
+ readonly usage?: {
715
+ readonly prompt_tokens: number;
716
+ readonly total_tokens: number;
717
+ } | undefined;
718
+ }
895
719
  /**
896
720
  * Request body for OpenAI's Responses API (`/v1/responses`), added in Ollama v0.13.3.
897
721
  *
@@ -915,93 +739,601 @@ interface OpenAIResponsesRequest {
915
739
  /** @remarks Not supported by Ollama, which is stateless across calls — accepted but ignored. */
916
740
  readonly conversation?: string | undefined;
917
741
  readonly truncation?: string | undefined;
742
+ readonly reasoning?: {
743
+ readonly effort?: OpenAIReasoningEffort | undefined;
744
+ } | undefined;
745
+ /** Ollama extension: boolean, model-defined string, or null for model default. */
746
+ readonly think?: boolean | string | null | undefined;
747
+ }
748
+ /** Strict Ollama-documented Responses request; excludes stateful and SDK-only request fields. */
749
+ /** Strict Ollama-documented Responses request; excludes only unsupported stateful fields. */
750
+ type OllamaOpenAIResponsesRequest = Omit<OpenAIResponsesRequest, 'previous_response_id' | 'conversation'>;
751
+ type OpenAIResponsesStatus = 'completed' | 'failed' | 'in_progress' | 'cancelled' | 'queued' | 'incomplete';
752
+ interface OpenAIResponsesError {
753
+ readonly code?: string | undefined;
754
+ readonly message?: string | undefined;
755
+ readonly [key: string]: unknown;
756
+ }
757
+ interface OpenAIResponsesIncompleteDetails {
758
+ readonly reason?: string | undefined;
759
+ readonly [key: string]: unknown;
918
760
  }
919
761
  interface OpenAIResponsesOutputTextContent {
920
762
  readonly type: 'output_text';
921
763
  readonly text: string;
764
+ readonly annotations?: readonly Record<string, unknown>[] | undefined;
765
+ readonly logprobs?: readonly Record<string, unknown>[] | undefined;
922
766
  }
767
+ interface OpenAIResponsesOutputRefusal {
768
+ readonly type: 'refusal';
769
+ readonly refusal: string;
770
+ }
771
+ type OpenAIResponsesOutputContent = OpenAIResponsesOutputTextContent | OpenAIResponsesOutputRefusal;
923
772
  interface OpenAIResponsesOutputMessage {
924
773
  readonly type: 'message';
774
+ readonly id?: string | undefined;
775
+ readonly status?: OpenAIResponsesStatus | undefined;
925
776
  readonly role?: string | undefined;
926
- readonly content: readonly OpenAIResponsesOutputTextContent[];
777
+ readonly phase?: string | undefined;
778
+ readonly content: readonly OpenAIResponsesOutputContent[];
927
779
  }
928
- /** Non-stateful response shape for `/v1/responses`; see {@link OpenAIResponsesRequest}. */
780
+ interface OpenAIResponsesOutputFunctionCall {
781
+ readonly type: 'function_call';
782
+ readonly id?: string | undefined;
783
+ readonly call_id?: string | undefined;
784
+ readonly name: string;
785
+ readonly arguments: string;
786
+ readonly status?: OpenAIResponsesStatus | undefined;
787
+ }
788
+ interface OpenAIResponsesOutputReasoning {
789
+ readonly type: 'reasoning';
790
+ readonly id?: string | undefined;
791
+ readonly status?: OpenAIResponsesStatus | undefined;
792
+ readonly summary?: readonly {
793
+ readonly type: 'summary_text';
794
+ readonly text: string;
795
+ }[] | undefined;
796
+ readonly text?: string | undefined;
797
+ readonly encrypted_content?: string | undefined;
798
+ }
799
+ type OpenAIResponsesOutputItem = OpenAIResponsesOutputMessage | OpenAIResponsesOutputFunctionCall | OpenAIResponsesOutputReasoning;
800
+ interface OpenAIResponsesUsage {
801
+ readonly input_tokens: number;
802
+ readonly output_tokens: number;
803
+ readonly total_tokens: number;
804
+ readonly input_tokens_details?: Record<string, unknown> | undefined;
805
+ readonly output_tokens_details?: Record<string, unknown> | undefined;
806
+ }
807
+ /** Non-stateful response shape for the Ollama Responses compatibility endpoint. */
929
808
  interface OpenAIResponsesResponse {
930
809
  readonly id: string;
931
810
  readonly object: 'response';
932
811
  readonly created: number;
812
+ readonly created_at?: number | undefined;
813
+ readonly status?: OpenAIResponsesStatus | undefined;
814
+ readonly completed_at?: number | null | undefined;
815
+ readonly error?: OpenAIResponsesError | null | undefined;
816
+ readonly incomplete_details?: OpenAIResponsesIncompleteDetails | null | undefined;
933
817
  readonly model: string;
934
- readonly output: readonly OpenAIResponsesOutputMessage[];
935
- readonly usage?: {
936
- readonly input_tokens: number;
937
- readonly output_tokens: number;
938
- readonly total_tokens: number;
939
- } | undefined;
818
+ readonly output: readonly OpenAIResponsesOutputItem[];
819
+ readonly output_text?: string | undefined;
820
+ readonly previous_response_id?: string | null | undefined;
821
+ readonly parallel_tool_calls?: boolean | undefined;
822
+ readonly usage?: OpenAIResponsesUsage | undefined;
823
+ }
824
+ declare class OpenAIResponsesStreamError extends OllamaClientError {
825
+ readonly responsePayload: OpenAIResponsesResponse;
826
+ constructor(message: string, responsePayload: OpenAIResponsesResponse);
827
+ }
828
+ declare class OpenAIChatCompletionStream implements AsyncIterable<OpenAIChatCompletionChunk> {
829
+ private readonly source;
830
+ private readonly finalResultPromise;
831
+ private resolveFinal;
832
+ private rejectFinal;
833
+ private removeAbortListener;
834
+ constructor(source: AbortableAsyncIterable<SseEvent>, signal?: AbortSignal);
835
+ get finalResult(): Promise<OpenAIChatCompletionResponse>;
836
+ abort(): void;
837
+ [Symbol.asyncIterator](): AsyncGenerator<OpenAIChatCompletionChunk, void, undefined>;
838
+ }
839
+ declare class OpenAICompletionStream implements AsyncIterable<OpenAICompletionChunk> {
840
+ private readonly source;
841
+ private readonly finalResultPromise;
842
+ private resolveFinal;
843
+ private rejectFinal;
844
+ private removeAbortListener;
845
+ constructor(source: AbortableAsyncIterable<SseEvent>, signal?: AbortSignal);
846
+ get finalResult(): Promise<OpenAICompletionResponse>;
847
+ abort(): void;
848
+ [Symbol.asyncIterator](): AsyncGenerator<OpenAICompletionChunk, void, undefined>;
849
+ }
850
+ interface OpenAIResponsesEventBase {
851
+ readonly response_id?: string | undefined;
852
+ readonly sequence_number?: number | undefined;
853
+ }
854
+ interface OpenAIResponsesOutputTextDeltaEvent extends OpenAIResponsesEventBase {
855
+ readonly type: 'response.output_text.delta';
856
+ readonly item_id: string;
857
+ readonly output_index: number;
858
+ readonly content_index: number;
859
+ readonly delta: string;
860
+ }
861
+ interface OpenAIResponsesOutputTextDoneEvent extends OpenAIResponsesEventBase {
862
+ readonly type: 'response.output_text.done';
863
+ readonly item_id: string;
864
+ readonly output_index: number;
865
+ readonly content_index: number;
866
+ readonly text: string;
867
+ }
868
+ interface OpenAIResponsesFunctionCallArgumentsDeltaEvent extends OpenAIResponsesEventBase {
869
+ readonly type: 'response.function_call_arguments.delta';
870
+ readonly item_id: string;
871
+ readonly output_index: number;
872
+ readonly delta: string;
873
+ }
874
+ interface OpenAIResponsesFunctionCallArgumentsDoneEvent extends OpenAIResponsesEventBase {
875
+ readonly type: 'response.function_call_arguments.done';
876
+ readonly item_id: string;
877
+ readonly output_index: number;
878
+ readonly arguments: string;
879
+ readonly name?: string | undefined;
880
+ }
881
+ interface OpenAIResponsesReasoningTextDeltaEvent extends OpenAIResponsesEventBase {
882
+ readonly type: 'response.reasoning_text.delta';
883
+ readonly item_id: string;
884
+ readonly output_index: number;
885
+ readonly content_index: number;
886
+ readonly delta: string;
887
+ }
888
+ interface OpenAIResponsesReasoningTextDoneEvent extends OpenAIResponsesEventBase {
889
+ readonly type: 'response.reasoning_text.done';
890
+ readonly item_id: string;
891
+ readonly output_index: number;
892
+ readonly content_index: number;
893
+ readonly text: string;
894
+ }
895
+ interface OpenAIResponsesReasoningSummaryPartAddedEvent extends OpenAIResponsesEventBase {
896
+ readonly type: 'response.reasoning_summary_part.added';
897
+ readonly item_id: string;
898
+ readonly output_index: number;
899
+ readonly summary_index: number;
900
+ readonly part: {
901
+ readonly type: 'summary_text';
902
+ readonly text: string;
903
+ };
904
+ }
905
+ interface OpenAIResponsesReasoningSummaryPartDoneEvent extends OpenAIResponsesEventBase {
906
+ readonly type: 'response.reasoning_summary_part.done';
907
+ readonly item_id: string;
908
+ readonly output_index: number;
909
+ readonly summary_index: number;
910
+ readonly part: {
911
+ readonly type: 'summary_text';
912
+ readonly text: string;
913
+ };
914
+ readonly status?: 'incomplete' | undefined;
915
+ }
916
+ interface OpenAIResponsesReasoningSummaryTextDeltaEvent extends OpenAIResponsesEventBase {
917
+ readonly type: 'response.reasoning_summary_text.delta';
918
+ readonly item_id: string;
919
+ readonly output_index: number;
920
+ readonly summary_index: number;
921
+ readonly delta: string;
922
+ }
923
+ interface OpenAIResponsesReasoningSummaryTextDoneEvent extends OpenAIResponsesEventBase {
924
+ readonly type: 'response.reasoning_summary_text.done';
925
+ readonly item_id: string;
926
+ readonly output_index: number;
927
+ readonly summary_index: number;
928
+ readonly text: string;
929
+ }
930
+ interface OpenAIResponsesOutputItemAddedEvent extends OpenAIResponsesEventBase {
931
+ readonly type: 'response.output_item.added';
932
+ readonly item: OpenAIResponsesOutputItem;
933
+ readonly output_index: number;
934
+ }
935
+ interface OpenAIResponsesOutputItemDoneEvent extends OpenAIResponsesEventBase {
936
+ readonly type: 'response.output_item.done';
937
+ readonly item: OpenAIResponsesOutputItem;
938
+ readonly output_index: number;
939
+ }
940
+ interface OpenAIResponsesContentPartAddedEvent extends OpenAIResponsesEventBase {
941
+ readonly type: 'response.content_part.added';
942
+ readonly item_id: string;
943
+ readonly output_index: number;
944
+ readonly content_index: number;
945
+ readonly part: OpenAIResponsesOutputContent | {
946
+ readonly type: string;
947
+ readonly [key: string]: unknown;
948
+ };
949
+ }
950
+ interface OpenAIResponsesContentPartDoneEvent extends OpenAIResponsesEventBase {
951
+ readonly type: 'response.content_part.done';
952
+ readonly item_id: string;
953
+ readonly output_index: number;
954
+ readonly content_index: number;
955
+ readonly part: OpenAIResponsesOutputContent | {
956
+ readonly type: string;
957
+ readonly [key: string]: unknown;
958
+ };
959
+ }
960
+ interface OpenAIResponsesRefusalDeltaEvent extends OpenAIResponsesEventBase {
961
+ readonly type: 'response.refusal.delta';
962
+ readonly item_id: string;
963
+ readonly output_index: number;
964
+ readonly content_index: number;
965
+ readonly delta: string;
966
+ }
967
+ interface OpenAIResponsesRefusalDoneEvent extends OpenAIResponsesEventBase {
968
+ readonly type: 'response.refusal.done';
969
+ readonly item_id: string;
970
+ readonly output_index: number;
971
+ readonly content_index: number;
972
+ readonly refusal: string;
973
+ }
974
+ interface OpenAIResponsesCreatedEvent extends OpenAIResponsesEventBase {
975
+ readonly type: 'response.created';
976
+ readonly response: OpenAIResponsesResponse;
977
+ }
978
+ interface OpenAIResponsesInProgressEvent extends OpenAIResponsesEventBase {
979
+ readonly type: 'response.in_progress';
980
+ readonly response: OpenAIResponsesResponse;
981
+ }
982
+ interface OpenAIResponsesQueuedEvent extends OpenAIResponsesEventBase {
983
+ readonly type: 'response.queued';
984
+ readonly response: OpenAIResponsesResponse;
985
+ }
986
+ interface OpenAIResponsesCompletedEvent extends OpenAIResponsesEventBase {
987
+ readonly type: 'response.completed' | 'response.done';
988
+ readonly response: OpenAIResponsesResponse;
989
+ }
990
+ interface OpenAIResponsesFailedEvent extends OpenAIResponsesEventBase {
991
+ readonly type: 'response.failed';
992
+ readonly response: OpenAIResponsesResponse;
993
+ }
994
+ interface OpenAIResponsesIncompleteEvent extends OpenAIResponsesEventBase {
995
+ readonly type: 'response.incomplete';
996
+ readonly response: OpenAIResponsesResponse;
997
+ }
998
+ type OpenAIResponsesStreamEvent = OpenAIResponsesOutputTextDeltaEvent | OpenAIResponsesOutputTextDoneEvent | OpenAIResponsesFunctionCallArgumentsDeltaEvent | OpenAIResponsesFunctionCallArgumentsDoneEvent | OpenAIResponsesReasoningTextDeltaEvent | OpenAIResponsesReasoningTextDoneEvent | OpenAIResponsesReasoningSummaryPartAddedEvent | OpenAIResponsesReasoningSummaryPartDoneEvent | OpenAIResponsesReasoningSummaryTextDeltaEvent | OpenAIResponsesReasoningSummaryTextDoneEvent | OpenAIResponsesOutputItemAddedEvent | OpenAIResponsesOutputItemDoneEvent | OpenAIResponsesContentPartAddedEvent | OpenAIResponsesContentPartDoneEvent | OpenAIResponsesRefusalDeltaEvent | OpenAIResponsesRefusalDoneEvent | OpenAIResponsesCreatedEvent | OpenAIResponsesInProgressEvent | OpenAIResponsesQueuedEvent | OpenAIResponsesCompletedEvent | OpenAIResponsesFailedEvent | OpenAIResponsesIncompleteEvent | {
999
+ readonly type: string;
1000
+ readonly [key: string]: unknown;
1001
+ };
1002
+ declare class OpenAIResponsesStream implements AsyncIterable<OpenAIResponsesStreamEvent> {
1003
+ private readonly source;
1004
+ private readonly finalResultPromise;
1005
+ private resolveFinal;
1006
+ private rejectFinal;
1007
+ private removeAbortListener;
1008
+ constructor(source: AbortableAsyncIterable<SseEvent>, signal?: AbortSignal);
1009
+ get finalResult(): Promise<OpenAIResponsesResponse>;
1010
+ abort(): void;
1011
+ [Symbol.asyncIterator](): AsyncGenerator<OpenAIResponsesStreamEvent, void, undefined>;
940
1012
  }
941
1013
  declare class OpenAICompatClient {
942
1014
  private readonly http;
943
- constructor(http: HttpClient);
944
- createChatCompletion(request: OpenAIChatCompletionRequest, signal?: AbortSignal): Promise<OpenAIChatCompletionResponse>;
945
- chatCompletions(request: OpenAIChatCompletionRequest, signal?: AbortSignal): Promise<OpenAIChatCompletionResponse>;
1015
+ private readonly runner?;
1016
+ constructor(http: HttpClient, runner?: RequestRunner | undefined);
1017
+ private request;
1018
+ createChatCompletion(request: OpenAIChatCompletionRequest & {
1019
+ stream: true;
1020
+ }, signal?: AbortSignal): Promise<OpenAIChatCompletionStream>;
1021
+ createChatCompletion(request: OpenAIChatCompletionRequest & {
1022
+ stream?: false | undefined;
1023
+ }, signal?: AbortSignal): Promise<OpenAIChatCompletionResponse>;
1024
+ chatCompletions(request: OpenAIChatCompletionRequest & {
1025
+ stream: true;
1026
+ }, signal?: AbortSignal): Promise<OpenAIChatCompletionStream>;
1027
+ chatCompletions(request: OpenAIChatCompletionRequest & {
1028
+ stream?: false | undefined;
1029
+ }, signal?: AbortSignal): Promise<OpenAIChatCompletionResponse>;
946
1030
  listModels(signal?: AbortSignal): Promise<OpenAIListModelsResponse>;
947
- createResponses(request: OpenAIResponsesRequest, signal?: AbortSignal): Promise<OpenAIResponsesResponse>;
948
- responses(request: OpenAIResponsesRequest, signal?: AbortSignal): Promise<OpenAIResponsesResponse>;
1031
+ retrieveModel(model: string, signal?: AbortSignal): Promise<OpenAIModelItem>;
1032
+ getModel(model: string, signal?: AbortSignal): Promise<OpenAIModelItem>;
1033
+ createCompletion(request: OpenAICompletionRequest & {
1034
+ stream: true;
1035
+ }, signal?: AbortSignal): Promise<OpenAICompletionStream>;
1036
+ createCompletion(request: OpenAICompletionRequest & {
1037
+ stream?: false | undefined;
1038
+ }, signal?: AbortSignal): Promise<OpenAICompletionResponse>;
1039
+ completions(request: OpenAICompletionRequest & {
1040
+ stream: true;
1041
+ }, signal?: AbortSignal): Promise<OpenAICompletionStream>;
1042
+ completions(request: OpenAICompletionRequest & {
1043
+ stream?: false | undefined;
1044
+ }, signal?: AbortSignal): Promise<OpenAICompletionResponse>;
1045
+ createEmbedding(request: OpenAIEmbeddingRequest, signal?: AbortSignal): Promise<OpenAIEmbeddingResponse>;
1046
+ embeddings(request: OpenAIEmbeddingRequest, signal?: AbortSignal): Promise<OpenAIEmbeddingResponse>;
1047
+ createResponses(request: OpenAIResponsesRequest & {
1048
+ stream: true;
1049
+ }, signal?: AbortSignal): Promise<OpenAIResponsesStream>;
1050
+ createResponses(request: OpenAIResponsesRequest & {
1051
+ stream?: false | undefined;
1052
+ }, signal?: AbortSignal): Promise<OpenAIResponsesResponse>;
1053
+ responses(request: OpenAIResponsesRequest & {
1054
+ stream: true;
1055
+ }, signal?: AbortSignal): Promise<OpenAIResponsesStream>;
1056
+ responses(request: OpenAIResponsesRequest & {
1057
+ stream?: false | undefined;
1058
+ }, signal?: AbortSignal): Promise<OpenAIResponsesResponse>;
949
1059
  }
950
1060
 
951
1061
  /**
952
1062
  * Anthropic Compatibility interfaces and client helpers for Ollama.
953
- * Ollama supports Anthropic Messages API format.
954
- *
955
- * @remarks
956
- * This is a typed pass-through to Ollama's Anthropic-compatible `/v1/messages` endpoint
957
- * — a subset of Anthropic's Messages API (text content, system prompt, sampling
958
- * parameters, ephemeral prompt-caching hints via `cache_control`), not the full Anthropic
959
- * surface. Tool use (`tool_use`/`tool_result` content blocks), extended thinking,
960
- * citations, files, token counting, and the Batches API are not modeled here.
1063
+ * Ollama supports the Anthropic Messages API format.
961
1064
  */
962
1065
 
963
1066
  interface AnthropicCacheControl {
964
1067
  readonly type: 'ephemeral';
1068
+ readonly ttl?: '5m' | '1h' | undefined;
965
1069
  }
966
- interface AnthropicContentBlock {
1070
+ interface AnthropicTextContentBlock {
967
1071
  readonly type: 'text';
968
1072
  readonly text: string;
969
- /** Marks this block as a prompt-caching breakpoint (Anthropic's ephemeral cache). */
970
1073
  readonly cache_control?: AnthropicCacheControl | undefined;
971
1074
  }
1075
+ interface AnthropicImageContentBlock {
1076
+ readonly type: 'image';
1077
+ readonly source: {
1078
+ readonly type: 'base64';
1079
+ readonly media_type: string;
1080
+ readonly data: string;
1081
+ };
1082
+ }
1083
+ interface AnthropicToolUseContentBlock {
1084
+ readonly type: 'tool_use';
1085
+ readonly id: string;
1086
+ readonly name: string;
1087
+ readonly input: Record<string, unknown>;
1088
+ }
1089
+ interface AnthropicToolResultContentBlock {
1090
+ readonly type: 'tool_result';
1091
+ readonly tool_use_id: string;
1092
+ readonly content?: string | readonly AnthropicTextContentBlock[] | undefined;
1093
+ readonly is_error?: boolean | undefined;
1094
+ }
1095
+ interface AnthropicThinkingContentBlock {
1096
+ readonly type: 'thinking';
1097
+ readonly thinking: string;
1098
+ readonly signature?: string | undefined;
1099
+ }
1100
+ interface AnthropicRedactedThinkingContentBlock {
1101
+ readonly type: 'redacted_thinking';
1102
+ readonly data: string;
1103
+ }
1104
+ type AnthropicContentBlock = AnthropicTextContentBlock | AnthropicImageContentBlock | AnthropicToolUseContentBlock | AnthropicToolResultContentBlock | AnthropicThinkingContentBlock | AnthropicRedactedThinkingContentBlock;
972
1105
  interface AnthropicMessage {
973
1106
  readonly role: 'user' | 'assistant';
974
1107
  readonly content: string | readonly AnthropicContentBlock[];
975
1108
  }
1109
+ interface AnthropicSystemTextBlock {
1110
+ readonly type: 'text';
1111
+ readonly text: string;
1112
+ readonly cache_control?: AnthropicCacheControl | undefined;
1113
+ }
1114
+ type AnthropicSystem = string | readonly AnthropicSystemTextBlock[];
1115
+ interface AnthropicTool {
1116
+ readonly name: string;
1117
+ readonly description?: string | undefined;
1118
+ readonly input_schema: Record<string, unknown>;
1119
+ readonly eager_input_streaming?: boolean | undefined;
1120
+ }
1121
+ type AnthropicToolChoice = {
1122
+ readonly type: 'auto';
1123
+ readonly disable_parallel_tool_use?: boolean | undefined;
1124
+ } | {
1125
+ readonly type: 'any';
1126
+ readonly disable_parallel_tool_use?: boolean | undefined;
1127
+ } | {
1128
+ readonly type: 'tool';
1129
+ readonly name: string;
1130
+ readonly disable_parallel_tool_use?: boolean | undefined;
1131
+ } | {
1132
+ readonly type: 'none';
1133
+ };
1134
+ interface AnthropicThinkingConfig {
1135
+ readonly type: 'enabled' | 'disabled' | 'adaptive';
1136
+ readonly display?: 'omitted' | 'summarized' | 'updates' | undefined;
1137
+ /** Accepted by Ollama for compatibility but currently not enforced by the server. */
1138
+ readonly budget_tokens?: number | undefined;
1139
+ }
1140
+ interface AnthropicOutputConfig {
1141
+ readonly effort?: string | undefined;
1142
+ }
1143
+ interface AnthropicMetadata {
1144
+ readonly user_id?: string | undefined;
1145
+ }
976
1146
  interface AnthropicMessagesRequest {
977
1147
  readonly model: string;
978
1148
  readonly messages: readonly AnthropicMessage[];
979
- readonly system?: string | undefined;
1149
+ readonly system?: AnthropicSystem | undefined;
980
1150
  readonly max_tokens?: number | undefined;
981
1151
  readonly temperature?: number | undefined;
982
1152
  readonly top_p?: number | undefined;
983
1153
  readonly top_k?: number | undefined;
1154
+ readonly stop_sequences?: readonly string[] | undefined;
984
1155
  readonly stream?: boolean | undefined;
985
- }
1156
+ readonly tools?: readonly AnthropicTool[] | undefined;
1157
+ readonly thinking?: AnthropicThinkingConfig | undefined;
1158
+ readonly output_config?: AnthropicOutputConfig | undefined;
1159
+ /**
1160
+ * Accepted for Anthropic compatibility but currently ignored by Ollama.
1161
+ * Tool selection cannot be forced through the Ollama compatibility endpoint.
1162
+ */
1163
+ readonly tool_choice?: AnthropicToolChoice | undefined;
1164
+ /** Accepted for compatibility but currently ignored by Ollama. */
1165
+ readonly metadata?: AnthropicMetadata | undefined;
1166
+ }
1167
+ /** Strict Ollama-documented Messages request; excludes fields Ollama marks unsupported. */
1168
+ type OllamaAnthropicTextContentBlock = Omit<AnthropicTextContentBlock, 'cache_control'>;
1169
+ type OllamaAnthropicTool = Omit<AnthropicTool, 'eager_input_streaming'>;
1170
+ type OllamaAnthropicThinkingConfig = {
1171
+ readonly type: 'enabled' | 'disabled';
1172
+ /** Accepted by Ollama for compatibility but currently not enforced by the server. */
1173
+ readonly budget_tokens?: number | undefined;
1174
+ };
1175
+ type OllamaAnthropicToolResultContentBlock = Omit<AnthropicToolResultContentBlock, 'content'> & {
1176
+ readonly content?: string | readonly OllamaAnthropicTextContentBlock[] | undefined;
1177
+ };
1178
+ type OllamaAnthropicContentBlock = OllamaAnthropicTextContentBlock | AnthropicImageContentBlock | AnthropicToolUseContentBlock | OllamaAnthropicToolResultContentBlock | AnthropicThinkingContentBlock;
1179
+ type OllamaAnthropicMessage = Omit<AnthropicMessage, 'content'> & {
1180
+ readonly content: string | readonly OllamaAnthropicContentBlock[];
1181
+ };
1182
+ type OllamaAnthropicSystemTextBlock = Omit<AnthropicSystemTextBlock, 'cache_control'>;
1183
+ type OllamaAnthropicSystem = string | readonly OllamaAnthropicSystemTextBlock[];
1184
+ /** Strict Ollama-documented Messages request; excludes unsupported caching/tool-choice metadata. */
1185
+ type OllamaAnthropicMessagesRequest = Omit<AnthropicMessagesRequest, 'messages' | 'system' | 'tools' | 'thinking' | 'tool_choice' | 'metadata'> & {
1186
+ readonly messages: readonly OllamaAnthropicMessage[];
1187
+ readonly system?: OllamaAnthropicSystem | undefined;
1188
+ readonly tools?: readonly OllamaAnthropicTool[] | undefined;
1189
+ readonly thinking?: OllamaAnthropicThinkingConfig | undefined;
1190
+ };
986
1191
  interface AnthropicMessagesResponse {
987
1192
  readonly id: string;
988
1193
  readonly type: 'message';
989
1194
  readonly role: 'assistant';
990
1195
  readonly content: readonly AnthropicContentBlock[];
991
1196
  readonly model: string;
992
- readonly stop_reason: string;
1197
+ readonly stop_reason: string | null;
1198
+ readonly stop_sequence?: string | null | undefined;
993
1199
  readonly usage?: {
994
1200
  readonly input_tokens: number;
995
1201
  readonly output_tokens: number;
1202
+ readonly cache_creation_input_tokens?: number | undefined;
1203
+ readonly cache_read_input_tokens?: number | undefined;
1204
+ readonly cache_creation?: Record<string, unknown> | undefined;
996
1205
  } | undefined;
997
1206
  }
1207
+ interface AnthropicMessageStartEvent {
1208
+ readonly type: 'message_start';
1209
+ readonly message: AnthropicMessagesResponse;
1210
+ }
1211
+ interface AnthropicContentBlockStartEvent {
1212
+ readonly type: 'content_block_start';
1213
+ readonly index: number;
1214
+ readonly content_block: AnthropicContentBlock;
1215
+ }
1216
+ type AnthropicContentBlockDelta = {
1217
+ readonly type: 'text_delta';
1218
+ readonly text: string;
1219
+ } | {
1220
+ readonly type: 'input_json_delta';
1221
+ readonly partial_json: string;
1222
+ } | {
1223
+ readonly type: 'thinking_delta';
1224
+ readonly thinking: string;
1225
+ } | {
1226
+ readonly type: 'signature_delta';
1227
+ readonly signature: string;
1228
+ };
1229
+ interface AnthropicContentBlockDeltaEvent {
1230
+ readonly type: 'content_block_delta';
1231
+ readonly index: number;
1232
+ readonly delta: AnthropicContentBlockDelta;
1233
+ }
1234
+ interface AnthropicContentBlockStopEvent {
1235
+ readonly type: 'content_block_stop';
1236
+ readonly index: number;
1237
+ }
1238
+ interface AnthropicMessageDeltaEvent {
1239
+ readonly type: 'message_delta';
1240
+ readonly delta: {
1241
+ readonly stop_reason?: string | null | undefined;
1242
+ readonly stop_sequence?: string | null | undefined;
1243
+ };
1244
+ readonly usage?: {
1245
+ readonly input_tokens?: number | undefined;
1246
+ readonly output_tokens: number;
1247
+ readonly cache_creation_input_tokens?: number | undefined;
1248
+ readonly cache_read_input_tokens?: number | undefined;
1249
+ readonly cache_creation?: Record<string, unknown> | undefined;
1250
+ } | undefined;
1251
+ }
1252
+ interface AnthropicMessageStopEvent {
1253
+ readonly type: 'message_stop';
1254
+ }
1255
+ interface AnthropicPingEvent {
1256
+ readonly type: 'ping';
1257
+ }
1258
+ interface AnthropicErrorEvent {
1259
+ readonly type: 'error';
1260
+ readonly error: {
1261
+ readonly type: string;
1262
+ readonly message: string;
1263
+ };
1264
+ }
1265
+ interface AnthropicUnknownStreamEvent {
1266
+ /** Forward-compatible event type not yet modeled by this SDK. */
1267
+ readonly type: string;
1268
+ readonly [key: string]: unknown;
1269
+ }
1270
+ type AnthropicMessageStreamEvent = AnthropicMessageStartEvent | AnthropicContentBlockStartEvent | AnthropicContentBlockDeltaEvent | AnthropicContentBlockStopEvent | AnthropicMessageDeltaEvent | AnthropicMessageStopEvent | AnthropicPingEvent | AnthropicErrorEvent | AnthropicUnknownStreamEvent;
1271
+ declare class AnthropicMessagesStream implements AsyncIterable<AnthropicMessageStreamEvent> {
1272
+ private readonly source;
1273
+ private readonly finalResultPromise;
1274
+ private resolveFinal;
1275
+ private rejectFinal;
1276
+ private removeAbortListener;
1277
+ constructor(source: AbortableAsyncIterable<SseEvent>, signal?: AbortSignal);
1278
+ get finalResult(): Promise<AnthropicMessagesResponse>;
1279
+ abort(): void;
1280
+ [Symbol.asyncIterator](): AsyncGenerator<AnthropicMessageStreamEvent, void, undefined>;
1281
+ }
998
1282
  declare class AnthropicCompatClient {
999
1283
  private readonly http;
1000
- constructor(http: HttpClient);
1001
- createMessage(request: AnthropicMessagesRequest, signal?: AbortSignal): Promise<AnthropicMessagesResponse>;
1002
- messages(request: AnthropicMessagesRequest, signal?: AbortSignal): Promise<AnthropicMessagesResponse>;
1284
+ private readonly runner?;
1285
+ constructor(http: HttpClient, runner?: RequestRunner | undefined);
1286
+ private request;
1287
+ createMessage(request: AnthropicMessagesRequest & {
1288
+ stream: true;
1289
+ }, signal?: AbortSignal): Promise<AnthropicMessagesStream>;
1290
+ createMessage(request: AnthropicMessagesRequest & {
1291
+ stream?: false | undefined;
1292
+ }, signal?: AbortSignal): Promise<AnthropicMessagesResponse>;
1293
+ createMessage(request: AnthropicMessagesRequest, signal?: AbortSignal): Promise<AnthropicMessagesResponse | AnthropicMessagesStream>;
1294
+ messages(request: AnthropicMessagesRequest & {
1295
+ stream: true;
1296
+ }, signal?: AbortSignal): Promise<AnthropicMessagesStream>;
1297
+ messages(request: AnthropicMessagesRequest & {
1298
+ stream?: false | undefined;
1299
+ }, signal?: AbortSignal): Promise<AnthropicMessagesResponse>;
1300
+ messages(request: AnthropicMessagesRequest, signal?: AbortSignal): Promise<AnthropicMessagesResponse | AnthropicMessagesStream>;
1003
1301
  }
1004
1302
 
1303
+ /**
1304
+ * High-level Ollama client — the original, hand-written API surface.
1305
+ *
1306
+ * **Wave 8 (ADR 0018) deprecation notice:**
1307
+ *
1308
+ * For new code, prefer the generated `NativeApi` from
1309
+ * {@link ./generated/runtime/runtime.js} + {@link ./generated/api/native-api.js}
1310
+ * instead. The generated surface:
1311
+ *
1312
+ * - Inherits every contract-layer guarantee (environment guards, version
1313
+ * guards, streaming defaults) automatically from the canonical IR.
1314
+ * - Stays in sync with the OpenAPI spec by construction — no hand-written
1315
+ * surface to drift.
1316
+ * - Uses the same `HttpClient` (and therefore the same middleware,
1317
+ * retry, telemetry, and streaming pipeline) as this client.
1318
+ *
1319
+ * The migration path is non-breaking:
1320
+ *
1321
+ * ```ts
1322
+ * // Before (still works, no breaking changes):
1323
+ * const client = new OllamaClient({ baseUrl: 'http://localhost:11434' });
1324
+ * const res = await client.chat({ model, messages });
1325
+ *
1326
+ * // After (recommended for new code):
1327
+ * const http = new HttpClient({ baseUrl: 'http://localhost:11434' });
1328
+ * const runtime = new OllamaRuntime({ http });
1329
+ * const api = new NativeApi(runtime);
1330
+ * const res = await api.chat({ model, messages, stream: false });
1331
+ * ```
1332
+ *
1333
+ * `OllamaClient` is preserved verbatim — existing callers do not need to
1334
+ * change anything. New methods and operations will land on the generated
1335
+ * surface first; `OllamaClient` will receive them only as a follow-up.
1336
+ */
1005
1337
  declare class OllamaClient {
1006
1338
  readonly registry: EndpointRegistry;
1007
1339
  readonly models: ModelsClient;
@@ -1010,6 +1342,8 @@ declare class OllamaClient {
1010
1342
  private readonly failoverCodes;
1011
1343
  private readonly fetchImpl;
1012
1344
  private readonly logger;
1345
+ private readonly middleware;
1346
+ private readonly onLifecycleEvent;
1013
1347
  /**
1014
1348
  * API key for Ollama's hosted web tools (`webSearch`/`webFetch`), which always target
1015
1349
  * `OLLAMA_CLOUD_BASE_URL` regardless of `config.endpoints` — an Ollama account API key
@@ -1020,6 +1354,31 @@ declare class OllamaClient {
1020
1354
  private readonly cloudApiKey;
1021
1355
  constructor(config?: OllamaClientConfig);
1022
1356
  get modelsClient(): ModelsClient;
1357
+ /**
1358
+ * Return a generated {@link OllamaRuntime} that shares this client's
1359
+ * transport (HttpClient + middleware + retry + telemetry).
1360
+ *
1361
+ * Wave 8 (ADR 0018) bridge: lets callers mix the existing `OllamaClient`
1362
+ * API with the generated `NativeApi` / `OpenAIApi` / `AnthropicApi`
1363
+ * surface without configuring two separate HttpClient instances.
1364
+ *
1365
+ * The returned runtime is bound to the registry's first candidate
1366
+ * endpoint (or the resolved single-endpoint config if no `endpoints`
1367
+ * array was provided). For multi-endpoint configs that need per-call
1368
+ * routing, prefer constructing `OllamaRuntime` directly with a
1369
+ * specific HttpClient:
1370
+ *
1371
+ * ```ts
1372
+ * const http = new HttpClient({ baseUrl: 'http://host-a:11434' });
1373
+ * const runtime = new OllamaRuntime({ http });
1374
+ * const api = new NativeApi(runtime);
1375
+ * ```
1376
+ *
1377
+ * The runtime is cached on first call — subsequent calls return the
1378
+ * same instance.
1379
+ */
1380
+ get runtime(): OllamaRuntime;
1381
+ private _runtime;
1023
1382
  /**
1024
1383
  * Fail-fast guard for `format` (structured output) requests: throws before any network
1025
1384
  * call if the candidate endpoint is inferred as Ollama Cloud, which does not currently
@@ -1120,7 +1479,7 @@ declare class OllamaClient {
1120
1479
  * multi-candidate loop, since `webSearch`/`webFetch` only ever have the one endpoint.
1121
1480
  */
1122
1481
  private executeCloudRequest;
1123
- capabilities(model: string): Promise<ModelCapabilities>;
1482
+ capabilities(model: string, signal?: AbortSignal): Promise<ModelCapabilities>;
1124
1483
  runtimeMode(): RuntimeMode;
1125
1484
  healthCheck(): Promise<EndpointHealthCheckResult[]>;
1126
1485
  endpointStatus(): EndpointHealth[];
@@ -1144,9 +1503,9 @@ declare function createTimeoutSignal(timeoutMs?: number, userSignal?: AbortSigna
1144
1503
  * Normalization mappers and aggregators for Ollama streaming responses.
1145
1504
  */
1146
1505
 
1147
- declare function normalizeChatStream(source: AbortableAsyncIterable<ChatResponse>): OllamaStream<ChatResponse, ChatStreamResult>;
1148
- declare function normalizeGenerateStream(source: AbortableAsyncIterable<GenerateResponse>): OllamaStream<GenerateResponse, GenerateStreamResult>;
1149
- declare function normalizeProgressStream(source: AbortableAsyncIterable<ProgressResponse>): OllamaStream<ProgressResponse, ProgressStreamResult>;
1506
+ declare function normalizeChatStream(source: AbortableAsyncIterable<ChatResponse>, signal?: AbortSignal): OllamaStream<ChatResponse, ChatStreamResult>;
1507
+ declare function normalizeGenerateStream(source: AbortableAsyncIterable<GenerateResponse>, signal?: AbortSignal): OllamaStream<GenerateResponse, GenerateStreamResult>;
1508
+ declare function normalizeProgressStream(source: AbortableAsyncIterable<ProgressResponse>, signal?: AbortSignal): OllamaStream<ProgressResponse, ProgressStreamResult>;
1150
1509
 
1151
1510
  /**
1152
1511
  * NDJSON (newline-delimited JSON) stream reader for native fetch Response bodies.
@@ -1294,44 +1653,36 @@ interface DefineToolOptions<TParams, TResult> {
1294
1653
  */
1295
1654
  declare function defineTool<TParams, TResult>(options: DefineToolOptions<TParams, TResult>): Tool<TParams, TResult>;
1296
1655
 
1297
- /**
1298
- * Duck-typed MCP (Model Context Protocol) client interfaces.
1299
- * Decoupled from any specific MCP SDK.
1300
- */
1301
- interface McpToolDescriptor {
1302
- readonly name: string;
1303
- readonly description?: string;
1304
- readonly inputSchema?: Record<string, unknown>;
1305
- }
1306
- interface McpListToolsResult {
1307
- readonly tools: readonly McpToolDescriptor[];
1308
- }
1309
- interface McpContentBlock {
1310
- readonly type: string;
1311
- readonly text?: string;
1312
- readonly [key: string]: unknown;
1313
- }
1314
- interface McpCallToolResult {
1315
- readonly content: readonly McpContentBlock[];
1316
- readonly isError?: boolean;
1317
- }
1318
- interface McpClientLike {
1319
- listTools: () => Promise<McpListToolsResult>;
1320
- callTool: (params: {
1321
- readonly name: string;
1322
- readonly arguments?: Record<string, unknown>;
1323
- }) => Promise<McpCallToolResult>;
1324
- }
1325
-
1326
1656
  /**
1327
1657
  * Converts MCP tools into Ollama-compatible tools.
1328
1658
  */
1329
1659
 
1660
+ type McpToolResultMode = 'text' | 'structured';
1330
1661
  interface LoadMcpToolsOptions {
1331
- readonly namePrefix?: string;
1662
+ readonly namePrefix?: string | undefined;
1663
+ /** Maximum number of paginated tools/list responses to traverse. */
1664
+ readonly maxPages?: number | undefined;
1665
+ /**
1666
+ * Return MCP's raw CallToolResult to programmatic callers instead of the legacy
1667
+ * model-oriented text representation. The default preserves existing behavior.
1668
+ */
1669
+ readonly resultMode?: McpToolResultMode | undefined;
1670
+ }
1671
+ declare function listAllMcpTools(mcpClient: McpClientLike, options?: LoadMcpToolsOptions, signal?: AbortSignal): Promise<McpToolDescriptor[]>;
1672
+ declare function loadMcpTools(mcpClient: McpClientLike, options?: LoadMcpToolsOptions, signal?: AbortSignal): Promise<AnyTool[]>;
1673
+ declare function registerMcpTools(registry: ToolRegistry, mcpClient: McpClientLike, options?: LoadMcpToolsOptions, signal?: AbortSignal): Promise<void>;
1674
+
1675
+ type McpBridgeOptions = LoadMcpToolsOptions;
1676
+ declare class McpBridge {
1677
+ private readonly client;
1678
+ private readonly options;
1679
+ constructor(client: McpClientLike, options?: McpBridgeOptions);
1680
+ static toOllamaTools(tools: readonly McpToolDescriptor[], options?: McpBridgeOptions): ToolDefinition[];
1681
+ listTools(signal?: AbortSignal): Promise<readonly McpToolDescriptor[]>;
1682
+ definitions(signal?: AbortSignal): Promise<ToolDefinition[]>;
1683
+ loadTools(signal?: AbortSignal): Promise<AnyTool[]>;
1684
+ register(registry: ToolRegistry, signal?: AbortSignal): Promise<void>;
1332
1685
  }
1333
- declare function loadMcpTools(mcpClient: McpClientLike, options?: LoadMcpToolsOptions): Promise<AnyTool[]>;
1334
- declare function registerMcpTools(registry: ToolRegistry, mcpClient: McpClientLike, options?: LoadMcpToolsOptions): Promise<void>;
1335
1686
 
1336
1687
  /**
1337
1688
  * Agent loop options, turn state, and execution hooks.
@@ -1359,13 +1710,22 @@ interface AgentHooks {
1359
1710
  interface AgentConfig {
1360
1711
  readonly tools?: ToolRegistry | undefined;
1361
1712
  readonly maxIterations?: number | undefined;
1713
+ /** Maximum total tool calls allowed during one agent run. */
1714
+ readonly maxToolCalls?: number | undefined;
1362
1715
  readonly hooks?: AgentHooks | undefined;
1716
+ /** Validate tool support from /api/show before starting a tool-enabled run. Default: true. */
1717
+ readonly validateToolCapability?: boolean | undefined;
1718
+ /**
1719
+ * Automatic context size for tool-enabled runs when options.num_ctx is not supplied.
1720
+ * Defaults to 32768 and is clamped to the model-reported maximum when available.
1721
+ */
1722
+ readonly toolContextSize?: number | undefined;
1363
1723
  }
1364
1724
  interface AgentRunInput {
1365
1725
  readonly model: string;
1366
1726
  readonly messages: readonly Message[];
1367
1727
  readonly options?: ModelOptions | undefined;
1368
- readonly think?: boolean | 'low' | 'medium' | 'high' | 'max' | undefined;
1728
+ readonly think?: ThinkValue | undefined;
1369
1729
  readonly signal?: AbortSignal | undefined;
1370
1730
  }
1371
1731
 
@@ -1374,12 +1734,13 @@ interface AgentRunInput {
1374
1734
  */
1375
1735
 
1376
1736
  interface AgentChatClient {
1737
+ capabilities?: ((model: string, signal?: AbortSignal) => Promise<ModelCapabilities>) | undefined;
1377
1738
  chat(request: {
1378
1739
  readonly model: string;
1379
1740
  readonly messages: readonly Message[];
1380
1741
  readonly tools?: readonly ToolDefinition[] | undefined;
1381
1742
  readonly options?: ModelOptions | undefined;
1382
- readonly think?: boolean | 'low' | 'medium' | 'high' | 'max' | undefined;
1743
+ readonly think?: ThinkValue | undefined;
1383
1744
  readonly stream?: false | undefined;
1384
1745
  readonly signal?: AbortSignal | undefined;
1385
1746
  }): Promise<{
@@ -1390,9 +1751,9 @@ interface AgentChatClient {
1390
1751
  * Runs a multi-turn `chat` + tool-execution loop until the model responds without
1391
1752
  * requesting further tool calls, or `maxIterations` is exceeded. Tool calls within a
1392
1753
  * single turn are handed to `ToolRegistry.executeToolCalls` and their results are
1393
- * appended to history in the same order the model requested them, each tagged with the
1394
- * originating call's `tool_call_id` — see the {@link ToolCall} type docs for how that id
1395
- * is produced (Ollama's native tool-calling protocol has none; this SDK synthesizes one).
1754
+ * appended to history in the same order the model requested them. Native Ollama tool-result
1755
+ * messages use `tool_name` on the wire; the SDK-generated `toolCallId` remains execution
1756
+ * metadata and is not sent to Ollama.
1396
1757
  * `Agent` assigns ids defensively even when `AgentChatClient` isn't `OllamaClient` (e.g. a
1397
1758
  * custom/test implementation), so this guarantee holds regardless of which chat client is
1398
1759
  * supplied.
@@ -1401,7 +1762,10 @@ declare class Agent {
1401
1762
  private readonly client;
1402
1763
  private readonly tools?;
1403
1764
  private readonly maxIterations;
1765
+ private readonly maxToolCalls?;
1404
1766
  private readonly hooks?;
1767
+ private readonly validateToolCapability;
1768
+ private readonly toolContextSize;
1405
1769
  constructor(client: AgentChatClient, config?: AgentConfig);
1406
1770
  run(input: AgentRunInput): Promise<AgentResult>;
1407
1771
  private runLoop;
@@ -1476,4 +1840,4 @@ declare const GEN_AI_SYSTEM_OLLAMA = "ollama";
1476
1840
  */
1477
1841
  declare function encodeImage(image: Uint8Array | string): Promise<string>;
1478
1842
 
1479
- export { ATTR_GEN_AI_OPERATION_NAME, ATTR_GEN_AI_REQUEST_MODEL, ATTR_GEN_AI_RESPONSE_MODEL, ATTR_GEN_AI_SYSTEM, ATTR_GEN_AI_TOOL_CALL_ID, ATTR_GEN_AI_TOOL_NAME, ATTR_GEN_AI_USAGE_INPUT_TOKENS, ATTR_GEN_AI_USAGE_OUTPUT_TOKENS, ATTR_HTTP_REQUEST_METHOD, ATTR_HTTP_RESPONSE_STATUS_CODE, ATTR_OLLAMA_AGENT_ITERATION, ATTR_OLLAMA_AGENT_MAX_ITERATIONS, ATTR_OLLAMA_ENDPOINT_ATTEMPT, ATTR_OLLAMA_ENDPOINT_NAME, ATTR_SERVER_ADDRESS, ATTR_SERVER_PORT, ATTR_URL_FULL, type AbortableAsyncIterable, Agent, type AgentChatClient, type AgentConfig, type AgentHooks, type AgentResult, type AgentRunInput, type AgentTurn, type AnthropicCacheControl, AnthropicCompatClient, type AnthropicContentBlock, type AnthropicMessage, type AnthropicMessagesRequest, type AnthropicMessagesResponse, AnyTool, type BackoffOptions, ChatRequestOptions, ChatResponse, type ChatStreamResult, CopyRequestOptions, CreateRequestOptions, DEFAULT_BACKOFF, DEFAULT_BASE_URL, DEFAULT_FAILOVER_CODES, DEFAULT_RETRY_CONFIG, DEFAULT_TIMEOUT_MS, type DefineToolOptions, DeleteRequestOptions, type DoneEvent, EmbedRequestOptions, EmbedResponse, EmbeddingsRequestOptions, EmbeddingsResponse, type EndpointHealth, type EndpointHealthCheckResult, EndpointRegistry, type EndpointRegistryOptions, type ErrorEvent, type FetchLike, GEN_AI_SYSTEM_OLLAMA, GenerateRequestOptions, GenerateResponse, type GenerateStreamResult, type HttpBody, HttpClient, type HttpClientOptions, type HttpRequestOptions, type LifecycleErrorEvent, type LifecycleRetryEvent, type LifecycleStartEvent, type LifecycleSuccessEvent, type LoadMcpToolsOptions, type LogFn, type Logger, type McpCallToolResult, type McpClientLike, type McpContentBlock, type McpListToolsResult, type McpToolDescriptor, Message, type MessageEvent, type Middleware, type MiddlewareContext, type ModelCapabilities, ModelOptions, ModelResponse, ModelsClient, NANOS_PER_MS, NANOS_PER_SECOND, NOOP_LOGGER, type NextFunction, OLLAMA_CLOUD_BASE_URL, OllamaAbortError, OllamaAgentMaxIterationsError, OllamaAuthError, OllamaClient, type OllamaClientConfig, OllamaClientError, type OllamaClientErrorOptions, type OllamaCloudFreeTierQuotaBudgets, type OllamaCredentialConfig, type OllamaEndpoint, type OllamaErrorRequestContext, type OllamaErrorResponseContext, OllamaGenericClientError, OllamaMcpError, OllamaModelRoutingError, OllamaNetworkError, OllamaNotFoundError, OllamaQuotaExceededError, OllamaRateLimitError, OllamaServerError, OllamaSkillInvalidError, OllamaSkillNotFoundError, OllamaStream, type OllamaStreamEvent, type OllamaStreamEventType, OllamaTimeoutError, OllamaToolTimeoutError, OllamaToolValidationError, OllamaUnsupportedCapabilityError, type OpenAIChatCompletionChoice, type OpenAIChatCompletionRequest, type OpenAIChatCompletionResponse, OpenAICompatClient, type OpenAIFunctionDefinition, type OpenAIListModelsResponse, type OpenAIMessage, type OpenAIModelItem, type OpenAIResponsesOutputMessage, type OpenAIResponsesOutputTextContent, type OpenAIResponsesRequest, type OpenAIResponsesResponse, type OpenAIStreamOptions, type OpenAITool, type OpenAIToolCall, ProgressResponse, type ProgressStreamResult, PsResponse, PullRequestOptions, PushRequestOptions, QuotaManager, type QuotaManagerOptions, type QuotaWindowConfig, type QuotaWindowStatus, type RawUsageSource, type RequestContext, type RequestLifecycleEvent, type RequestLifecycleHook, type RequestRunner, type ResponseContext, type RetryConfig, type RuntimeMode, ShowRequestOptions, ShowResponse, type SpanAttributeValue, type SpanAttributes, StatusResponse, type SupportedSchema, type ThinkingEvent, type TimeoutSignal, type TokenEvent, type TokenUsage, Tool, ToolCall, type ToolCallEvent, ToolDefinition, ToolExecutionResult, ToolHandler, ToolRegistry, VersionResponse, WebFetchRequestOptions, WebFetchResponse, WebSearchRequestOptions, WebSearchResponse, addSpanEvent, calculateBackoff, checkEndpointHealth, composeMiddleware, createConsoleLogger, createOllamaCloudFreeTierQuota, createTimeoutSignal, defineTool, detectModelCapabilities, encodeImage, extractUsage, inferRuntimeMode, listAvailableModels, loadMcpTools, mapError, normalizeChatStream, normalizeGenerateStream, normalizeProgressStream, parseNdjsonStream, parseStructuredOutput, registerMcpTools, resolveCredentialEndpoints, setSpanError, toDataStream, toResponse, toTextStream, withRetry, withSpan, zodToJsonSchema };
1843
+ export { ATTR_GEN_AI_OPERATION_NAME, ATTR_GEN_AI_REQUEST_MODEL, ATTR_GEN_AI_RESPONSE_MODEL, ATTR_GEN_AI_SYSTEM, ATTR_GEN_AI_TOOL_CALL_ID, ATTR_GEN_AI_TOOL_NAME, ATTR_GEN_AI_USAGE_INPUT_TOKENS, ATTR_GEN_AI_USAGE_OUTPUT_TOKENS, ATTR_HTTP_REQUEST_METHOD, ATTR_HTTP_RESPONSE_STATUS_CODE, ATTR_OLLAMA_AGENT_ITERATION, ATTR_OLLAMA_AGENT_MAX_ITERATIONS, ATTR_OLLAMA_ENDPOINT_ATTEMPT, ATTR_OLLAMA_ENDPOINT_NAME, ATTR_SERVER_ADDRESS, ATTR_SERVER_PORT, ATTR_URL_FULL, AbortableAsyncIterable, Agent, type AgentChatClient, type AgentConfig, type AgentHooks, type AgentResult, type AgentRunInput, type AgentTurn, type AnthropicCacheControl, AnthropicCompatClient, type AnthropicContentBlock, type AnthropicImageContentBlock, type AnthropicMessage, type AnthropicMessageStreamEvent, type AnthropicMessagesRequest, type AnthropicMessagesResponse, AnthropicMessagesStream, type AnthropicMetadata, type AnthropicOutputConfig, type AnthropicRedactedThinkingContentBlock, type AnthropicSystem, type AnthropicSystemTextBlock, type AnthropicTextContentBlock, type AnthropicThinkingConfig, type AnthropicThinkingContentBlock, type AnthropicTool, type AnthropicToolChoice, type AnthropicToolResultContentBlock, type AnthropicToolUseContentBlock, type AnthropicUnknownStreamEvent, AnyTool, type BackoffOptions, ChatRequestOptions, ChatResponse, ChatStreamResult, CopyRequestOptions, CreateRequestOptions, DEFAULT_BACKOFF, DEFAULT_BASE_URL, DEFAULT_FAILOVER_CODES, DEFAULT_RETRY_CONFIG, DEFAULT_TIMEOUT_MS, type DefineToolOptions, DeleteRequestOptions, EmbedRequestOptions, EmbedResponse, EmbeddingsRequestOptions, EmbeddingsResponse, type EndpointHealth, type EndpointHealthCheckResult, EndpointRegistry, type EndpointRegistryOptions, FetchLike, GEN_AI_SYSTEM_OLLAMA, GenerateRequestOptions, GenerateResponse, GenerateStreamResult, HttpClient, type LoadMcpToolsOptions, Logger, McpBridge, type McpBridgeOptions, McpClientLike, McpToolDescriptor, Message, Middleware, type ModelCapabilities, ModelOptions, ModelResponse, ModelsClient, OLLAMA_CLOUD_BASE_URL, type OllamaAnthropicContentBlock, type OllamaAnthropicMessage, type OllamaAnthropicMessagesRequest, type OllamaAnthropicSystem, type OllamaAnthropicSystemTextBlock, type OllamaAnthropicTextContentBlock, type OllamaAnthropicThinkingConfig, type OllamaAnthropicTool, type OllamaAnthropicToolResultContentBlock, OllamaClient, type OllamaClientConfig, OllamaClientError, type OllamaCloudFreeTierQuotaBudgets, type OllamaCredentialConfig, type OllamaEndpoint, type OllamaOpenAIChatCompletionRequest, type OllamaOpenAICompletionRequest, type OllamaOpenAIEmbeddingRequest, type OllamaOpenAIReasoningEffort, type OllamaOpenAIResponsesRequest, OllamaStream, OllamaStreamEvent, OllamaStreamEventType, type OpenAIChatCompletionChoice, type OpenAIChatCompletionChunk, type OpenAIChatCompletionChunkChoice, type OpenAIChatCompletionDelta, type OpenAIChatCompletionRequest, type OpenAIChatCompletionResponse, OpenAIChatCompletionStream, OpenAICompatClient, type OpenAICompletionChoice, type OpenAICompletionChunk, type OpenAICompletionRequest, type OpenAICompletionResponse, OpenAICompletionStream, type OpenAIContentPart, type OpenAIEmbeddingInput, type OpenAIEmbeddingItem, type OpenAIEmbeddingRequest, type OpenAIEmbeddingResponse, type OpenAIFunctionDefinition, type OpenAIImageUrlContentPart, type OpenAIListModelsResponse, type OpenAIMessage, type OpenAIModelItem, type OpenAIReasoningEffort, type OpenAIResponseFormat, type OpenAIResponsesCompletedEvent, type OpenAIResponsesContentPartAddedEvent, type OpenAIResponsesContentPartDoneEvent, type OpenAIResponsesCreatedEvent, type OpenAIResponsesError, type OpenAIResponsesEventBase, type OpenAIResponsesFailedEvent, type OpenAIResponsesFunctionCallArgumentsDeltaEvent, type OpenAIResponsesFunctionCallArgumentsDoneEvent, type OpenAIResponsesInProgressEvent, type OpenAIResponsesIncompleteDetails, type OpenAIResponsesIncompleteEvent, type OpenAIResponsesOutputContent, type OpenAIResponsesOutputFunctionCall, type OpenAIResponsesOutputItem, type OpenAIResponsesOutputItemAddedEvent, type OpenAIResponsesOutputItemDoneEvent, type OpenAIResponsesOutputMessage, type OpenAIResponsesOutputReasoning, type OpenAIResponsesOutputRefusal, type OpenAIResponsesOutputTextContent, type OpenAIResponsesOutputTextDeltaEvent, type OpenAIResponsesOutputTextDoneEvent, type OpenAIResponsesQueuedEvent, type OpenAIResponsesReasoningSummaryPartAddedEvent, type OpenAIResponsesReasoningSummaryPartDoneEvent, type OpenAIResponsesReasoningSummaryTextDeltaEvent, type OpenAIResponsesReasoningSummaryTextDoneEvent, type OpenAIResponsesReasoningTextDeltaEvent, type OpenAIResponsesReasoningTextDoneEvent, type OpenAIResponsesRefusalDeltaEvent, type OpenAIResponsesRefusalDoneEvent, type OpenAIResponsesRequest, type OpenAIResponsesResponse, type OpenAIResponsesStatus, OpenAIResponsesStream, OpenAIResponsesStreamError, type OpenAIResponsesStreamEvent, type OpenAIResponsesUsage, type OpenAIStreamOptions, type OpenAITextContentPart, type OpenAITool, type OpenAIToolCall, type OpenAIToolCallDelta, type OpenAIUsage, ProgressResponse, ProgressStreamResult, PsResponse, PullRequestOptions, PushRequestOptions, QuotaManager, type QuotaManagerOptions, type QuotaWindowConfig, type QuotaWindowStatus, RawUsageSource, RequestLifecycleHook, type RequestRunner, type RetryConfig, type RuntimeMode, ShowRequestOptions, ShowResponse, type SpanAttributeValue, type SpanAttributes, SseEvent, StatusResponse, type SupportedSchema, ThinkValue, ThinkingMetadata, type TimeoutSignal, TokenUsage, Tool, ToolCall, ToolDefinition, ToolExecutionResult, ToolHandler, ToolRegistry, VersionResponse, WebFetchRequestOptions, WebFetchResponse, WebSearchRequestOptions, WebSearchResponse, addSpanEvent, calculateBackoff, checkEndpointHealth, createOllamaCloudFreeTierQuota, createTimeoutSignal, defineTool, detectModelCapabilities, encodeImage, inferRuntimeMode, listAllMcpTools, listAvailableModels, loadMcpTools, normalizeChatStream, normalizeGenerateStream, normalizeProgressStream, parseNdjsonStream, parseStructuredOutput, registerMcpTools, resolveCredentialEndpoints, setSpanError, toDataStream, toResponse, toTextStream, withRetry, withSpan, zodToJsonSchema };