@nemesis-oss/ollama-sdk 1.6.0 → 1.8.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 (56) hide show
  1. package/CHANGELOG.md +14 -2
  2. package/README.md +31 -0
  3. package/dist/anthropic-B_UXplNF.d.ts +1647 -0
  4. package/dist/anthropic-CVDFy_a0.d.cts +1647 -0
  5. package/dist/generated-api.cjs +74 -6
  6. package/dist/generated-api.cjs.map +1 -1
  7. package/dist/generated-api.d.cts +230 -629
  8. package/dist/generated-api.d.ts +230 -629
  9. package/dist/generated-api.js +72 -7
  10. package/dist/generated-api.js.map +1 -1
  11. package/dist/generated-models-schemas.cjs +89 -1
  12. package/dist/generated-models-schemas.cjs.map +1 -1
  13. package/dist/generated-models-schemas.d.cts +121 -1
  14. package/dist/generated-models-schemas.d.ts +121 -1
  15. package/dist/generated-models-schemas.js +79 -2
  16. package/dist/generated-models-schemas.js.map +1 -1
  17. package/dist/generated-runtime.cjs +576 -57
  18. package/dist/generated-runtime.cjs.map +1 -1
  19. package/dist/generated-runtime.d.cts +21 -23
  20. package/dist/generated-runtime.d.ts +21 -23
  21. package/dist/generated-runtime.js +575 -58
  22. package/dist/generated-runtime.js.map +1 -1
  23. package/dist/index.cjs +1210 -81
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.cts +395 -876
  26. package/dist/index.d.ts +395 -876
  27. package/dist/index.js +1207 -82
  28. package/dist/index.js.map +1 -1
  29. package/dist/mcp/tools.json +287 -73
  30. package/dist/mcp-generated.cjs +96 -7
  31. package/dist/mcp-generated.cjs.map +1 -1
  32. package/dist/mcp-generated.d.cts +3 -3
  33. package/dist/mcp-generated.d.ts +3 -3
  34. package/dist/mcp-generated.js +96 -7
  35. package/dist/mcp-generated.js.map +1 -1
  36. package/dist/mcp-http.cjs +43 -4
  37. package/dist/mcp-http.cjs.map +1 -1
  38. package/dist/mcp-http.d.cts +5 -1
  39. package/dist/mcp-http.d.ts +5 -1
  40. package/dist/mcp-http.js +43 -4
  41. package/dist/mcp-http.js.map +1 -1
  42. package/dist/mcp-stdio.cjs +43 -4
  43. package/dist/mcp-stdio.cjs.map +1 -1
  44. package/dist/mcp-stdio.d.cts +5 -1
  45. package/dist/mcp-stdio.d.ts +5 -1
  46. package/dist/mcp-stdio.js +43 -4
  47. package/dist/mcp-stdio.js.map +1 -1
  48. package/dist/{runtime-CVQkbYgF.d.ts → runtime-C6UYtBRB.d.ts} +222 -6
  49. package/dist/{runtime-IxRpUBjN.d.cts → runtime-DTmUeU6K.d.cts} +222 -6
  50. package/dist/skills.cjs.map +1 -1
  51. package/dist/skills.js.map +1 -1
  52. package/dist/types-CI-gM2u5.d.cts +139 -0
  53. package/dist/types-CI-gM2u5.d.ts +139 -0
  54. package/package.json +4 -2
  55. package/dist/types-MOsWXEE7.d.cts +0 -66
  56. package/dist/types-MOsWXEE7.d.ts +0 -66
package/dist/index.d.cts CHANGED
@@ -1,12 +1,14 @@
1
- import { F as FetchLike, M as Middleware, L as Logger, R as RequestLifecycleHook, H as HttpClient, c as OllamaStreamEvent, A as AbortableAsyncIterable, d as OllamaStreamEventType, P as ProgressStreamResult, B as BinaryBody, e as SseEvent, f as OllamaClientError, O as OllamaRuntime, C as ChatStreamResult, G as GenerateStreamResult, g as RawUsageSource, T as TokenUsage } from './runtime-IxRpUBjN.cjs';
2
- export { D as DoneEvent, E as ErrorEvent, h as HttpBody, i as HttpClientOptions, j as HttpRequestOptions, k as LifecycleErrorEvent, l as LifecycleRetryEvent, m as LifecycleStartEvent, n as LifecycleSuccessEvent, o as LogFn, p as MessageEvent, q as MiddlewareContext, N as NANOS_PER_MS, r as NANOS_PER_SECOND, s as NOOP_LOGGER, t as NextFunction, u as OllamaAbortError, v as OllamaAgentMaxIterationsError, w as OllamaAgentMaxToolCallsError, x as OllamaAuthError, y as OllamaClientErrorOptions, z as OllamaErrorRequestContext, J as OllamaErrorResponseContext, K as OllamaGenericClientError, Q as OllamaIncompatibleModelError, U as OllamaMcpError, V as OllamaModelRoutingError, W as OllamaNetworkError, X as OllamaNotFoundError, Y as OllamaQuotaExceededError, Z as OllamaRateLimitError, _ as OllamaRequestValidationError, $ as OllamaServerError, a0 as OllamaSkillInvalidError, a1 as OllamaSkillNotFoundError, a2 as OllamaTimeoutError, a3 as OllamaToolTimeoutError, a4 as OllamaToolValidationError, a5 as OllamaUnsupportedCapabilityError, a6 as RequestContext, a7 as RequestLifecycleEvent, a8 as ResponseContext, a9 as ThinkingEvent, aa as TokenEvent, ab as ToolCallEvent, ac as composeMiddleware, ad as createConsoleLogger, ae as extractUsage, af as mapError, ag as parseSseStream } from './runtime-IxRpUBjN.cjs';
1
+ import { F as FetchLike, M as Middleware, L as Logger, R as RequestLifecycleHook, H as HttpClient, c as OllamaStreamEvent, A as AbortableAsyncIterable, d as OllamaStreamEventType, P as ProgressStreamResult, B as BinaryBody, O as OllamaRuntime, C as ChatStreamResult, G as GenerateStreamResult, e as RawUsageSource, T as TokenUsage } from './runtime-DTmUeU6K.cjs';
2
+ export { D as DoneEvent, E as ErrorEvent, f as HttpBody, g as HttpClientOptions, h as HttpRequestOptions, i as LifecycleErrorEvent, j as LifecycleRetryEvent, k as LifecycleStartEvent, l as LifecycleSuccessEvent, m as LogFn, n as MessageEvent, o as MiddlewareContext, N as NANOS_PER_MS, p as NANOS_PER_SECOND, q as NOOP_LOGGER, r as NextFunction, s as OllamaAbortError, t as OllamaAgentMaxIterationsError, u as OllamaAgentMaxToolCallsError, v as OllamaAuthError, w as OllamaClientError, x as OllamaClientErrorOptions, y as OllamaErrorRequestContext, z as OllamaErrorResponseContext, J as OllamaGenericClientError, K as OllamaIncompatibleModelError, Q as OllamaMcpError, U as OllamaModelRoutingError, V as OllamaNetworkError, W as OllamaNotFoundError, X as OllamaQuotaExceededError, Y as OllamaRateLimitError, Z as OllamaRequestTooLargeError, _ as OllamaRequestValidationError, $ as OllamaResponseValidationError, a0 as OllamaServerError, a1 as OllamaServerVersionUnknownError, a2 as OllamaSkillInvalidError, a3 as OllamaSkillNotFoundError, a4 as OllamaTimeoutError, a5 as OllamaToolTimeoutError, a6 as OllamaToolValidationError, a7 as OllamaUnsupportedCapabilityError, a8 as RequestContext, a9 as RequestLifecycleEvent, aa as ResponseContext, ab as SseEvent, ac as ThinkingEvent, ad as TokenEvent, ae as ToolCallEvent, af as composeMiddleware, ag as createConsoleLogger, ah as extractUsage, ai as mapError, aj as parseSseStream } from './runtime-DTmUeU6K.cjs';
3
3
  import { T as ThinkingMetadata, M as ModelResponse, S as ShowRequestOptions, a as ShowResponse, P as PullRequestOptions, b as ProgressResponse, c as PushRequestOptions, C as CreateRequestOptions, D as DeleteRequestOptions, d as StatusResponse, e as CopyRequestOptions, f as PsResponse, V as VersionResponse, g as ChatRequestOptions, h as ChatResponse, G as GenerateRequestOptions, i as GenerateResponse, E as EmbedRequestOptions, j as EmbedResponse, k as EmbeddingsRequestOptions, l as EmbeddingsResponse, W as WebSearchRequestOptions, m as WebSearchResponse, n as WebFetchRequestOptions, o as WebFetchResponse, p as ToolDefinition, q as ToolCall, r as Message, s as ModelOptions, t as ThinkValue } from './types-5PAjLoCp.cjs';
4
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-5PAjLoCp.cjs';
5
5
  import { z } from 'zod';
6
+ import { R as RequestRunner, S as SystemOneChoiceAnswer, o as SystemOneNoulAnswer, p as SystemOneScoreAnswer, q as SystemOneChoiceQuestion, r as SystemOneNoulQuestion, s as SystemOneScoreQuestion, t as SystemOneRequest$1, u as SystemOneResponse$1, v as SystemOneContent, N as NativeApi, w as OpenAICompatClient, x as AnthropicCompatClient } from './anthropic-CVDFy_a0.cjs';
7
+ export { y as AnthropicCacheControl, z as AnthropicContentBlock, B as AnthropicImageContentBlock, C as AnthropicMessage, n as AnthropicMessageStreamEvent, A as AnthropicMessagesRequest, m as AnthropicMessagesResponse, D as AnthropicMessagesStream, E as AnthropicMetadata, F as AnthropicOutputConfig, G as AnthropicRedactedThinkingContentBlock, H as AnthropicSystem, I as AnthropicSystemTextBlock, J as AnthropicTextContentBlock, K as AnthropicThinkingConfig, L as AnthropicThinkingContentBlock, M as AnthropicTool, P as AnthropicToolChoice, Q as AnthropicToolResultContentBlock, T as AnthropicToolUseContentBlock, U as AnthropicUnknownStreamEvent, V as OllamaAnthropicContentBlock, W as OllamaAnthropicMessage, X as OllamaAnthropicMessagesRequest, Y as OllamaAnthropicSystem, Z as OllamaAnthropicSystemTextBlock, _ as OllamaAnthropicTextContentBlock, $ as OllamaAnthropicThinkingConfig, a0 as OllamaAnthropicTool, a1 as OllamaAnthropicToolResultContentBlock, a2 as OllamaOpenAIChatCompletionRequest, a3 as OllamaOpenAICompletionRequest, a4 as OllamaOpenAIEmbeddingRequest, a5 as OllamaOpenAIReasoningEffort, a6 as OllamaOpenAIResponsesRequest, a7 as OpenAIChatCompletionChoice, b as OpenAIChatCompletionChunk, a8 as OpenAIChatCompletionChunkChoice, a9 as OpenAIChatCompletionDelta, O as OpenAIChatCompletionRequest, a as OpenAIChatCompletionResponse, aa as OpenAIChatCompletionStream, ab as OpenAICompletionChoice, e as OpenAICompletionChunk, c as OpenAICompletionRequest, d as OpenAICompletionResponse, ac as OpenAICompletionStream, ad as OpenAIContentPart, ae as OpenAIEmbeddingInput, af as OpenAIEmbeddingItem, f as OpenAIEmbeddingRequest, g as OpenAIEmbeddingResponse, ag as OpenAIFunctionDefinition, ah as OpenAIImageUrlContentPart, h as OpenAIListModelsResponse, ai as OpenAIMessage, i as OpenAIModelItem, aj as OpenAIReasoningEffort, ak as OpenAIResponseFormat, al as OpenAIResponsesCompletedEvent, am as OpenAIResponsesContentPartAddedEvent, an as OpenAIResponsesContentPartDoneEvent, ao as OpenAIResponsesCreatedEvent, ap as OpenAIResponsesError, aq as OpenAIResponsesEventBase, ar as OpenAIResponsesFailedEvent, as as OpenAIResponsesFunctionCallArgumentsDeltaEvent, at as OpenAIResponsesFunctionCallArgumentsDoneEvent, au as OpenAIResponsesInProgressEvent, av as OpenAIResponsesIncompleteDetails, aw as OpenAIResponsesIncompleteEvent, ax as OpenAIResponsesOutputContent, ay as OpenAIResponsesOutputFunctionCall, az as OpenAIResponsesOutputItem, aA as OpenAIResponsesOutputItemAddedEvent, aB as OpenAIResponsesOutputItemDoneEvent, aC as OpenAIResponsesOutputMessage, aD as OpenAIResponsesOutputReasoning, aE as OpenAIResponsesOutputRefusal, aF as OpenAIResponsesOutputTextContent, aG as OpenAIResponsesOutputTextDeltaEvent, aH as OpenAIResponsesOutputTextDoneEvent, aI as OpenAIResponsesQueuedEvent, aJ as OpenAIResponsesReasoningSummaryPartAddedEvent, aK as OpenAIResponsesReasoningSummaryPartDoneEvent, aL as OpenAIResponsesReasoningSummaryTextDeltaEvent, aM as OpenAIResponsesReasoningSummaryTextDoneEvent, aN as OpenAIResponsesReasoningTextDeltaEvent, aO as OpenAIResponsesReasoningTextDoneEvent, aP as OpenAIResponsesRefusalDeltaEvent, aQ as OpenAIResponsesRefusalDoneEvent, j as OpenAIResponsesRequest, k as OpenAIResponsesResponse, aR as OpenAIResponsesStatus, aS as OpenAIResponsesStream, aT as OpenAIResponsesStreamError, l as OpenAIResponsesStreamEvent, aU as OpenAIResponsesUsage, aV as OpenAIStreamOptions, aW as OpenAITextContentPart, aX as OpenAITool, aY as OpenAIToolCall, aZ as OpenAIToolCallDelta, a_ as OpenAIUsage, a$ as SystemOneConfidence, b0 as SystemOneProbabilities } from './anthropic-CVDFy_a0.cjs';
6
8
  import { T as ToolHandler, a as Tool, A as AnyTool, b as ToolRegistry, c as ToolExecutionResult } from './compose-DS-UWFx8.cjs';
7
9
  export { d as AppliedSkillResult, e as ApplySkillOptions, P as ParsedFrontmatter, S as Skill, f as SkillFrontmatter, g as SkillSummary, h as ToolExecutionContext, i as ToolExecutionFailure, j as ToolExecutionSuccess, k as ToolRegistryOptions, l as applySkill, p as parseFrontmatter } from './compose-DS-UWFx8.cjs';
8
- import { M as McpClientLike, a as McpToolDescriptor } from './types-MOsWXEE7.cjs';
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-MOsWXEE7.cjs';
10
+ import { M as McpClientLike, a as McpToolDescriptor, b as McpTask, c as McpCallToolResult } from './types-CI-gM2u5.cjs';
11
+ export { d as McpContentBlock, e as McpCreateTaskResult, f as McpElicitationFormRequest, g as McpElicitationHandlers, h as McpElicitationRequest, i as McpElicitationResult, j as McpElicitationUrlRequest, k as McpIcon, l as McpInputRequiredResult, m as McpListToolsParams, n as McpListToolsResult, o as McpRequestOptions, p as McpServerCapabilities, q as McpTaskMethod, r as McpTaskRequest, s as McpTaskStatus, t as McpToolAnnotations, u as McpToolCallResult, v as McpToolExecution } from './types-CI-gM2u5.cjs';
10
12
  import * as Otel from '@opentelemetry/api';
11
13
 
12
14
  /**
@@ -369,19 +371,6 @@ declare class OllamaStream<TChunk, TFinal> implements AsyncIterable<OllamaStream
369
371
  [Symbol.asyncIterator](): AsyncGenerator<OllamaStreamEvent<TChunk, TFinal>, void, undefined>;
370
372
  }
371
373
 
372
- /**
373
- * Shared request-runner contract used by native and compatibility clients.
374
- */
375
-
376
- type RequestRunner = <T>(op: (http: HttpClient, signal: AbortSignal) => Promise<T>, opts?: {
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;
383
- }) => Promise<T>;
384
-
385
374
  /**
386
375
  * Model and blob management operations.
387
376
  */
@@ -429,876 +418,330 @@ declare class ModelsClient {
429
418
  }
430
419
 
431
420
  /**
432
- * OpenAI Compatibility interfaces and client helpers for Ollama.
433
- * Ollama exposes OpenAI-compatible /v1 endpoints.
421
+ * Ergonomic System One types — key-safe generics on top of the generated
422
+ * contract models.
423
+ *
424
+ * The generated `SystemOneRequest` and `SystemOneResponse` (in
425
+ * `src/generated/models/`) use `Record<string, ...>` for the
426
+ * questions/answers maps. That's structurally correct but loses the
427
+ * connection between the question names the caller sends and the answer
428
+ * names they receive back — `response.answers.someRandomKey` would
429
+ * compile even though the caller never asked that question.
434
430
  *
435
- * @remarks
436
- * This is a typed pass-through to Ollama's own OpenAI-compatible `/v1` endpoints — it
437
- * implements the subset of the OpenAI API surface that Ollama documents as supported
438
- * (https://docs.ollama.com/api/openai-compatibility), not the full OpenAI surface (hosted
439
- * tools like web/file search, computer use, code interpreter, or stateful server-side
440
- * conversation state). Notably, `tools` is supported by Ollama's compat layer but
441
- * `tool_choice` and `parallel_tool_calls` are not — both are still typed on
442
- * {@link OpenAIChatCompletionRequest} (accepted-but-ignored) so consumers passing a
443
- * standard OpenAI request object don't get spurious type errors; see the `@remarks` on
444
- * each field. `/v1/responses` is supported non-statefully — see
445
- * {@link OpenAIResponsesRequest}.
431
+ * This file adds a generic layer:
432
+ *
433
+ * ```ts
434
+ * const result = await ollama.systemOne({
435
+ * model: 'tev1:4b',
436
+ * state: { ticket: 'charged twice' },
437
+ * questions: {
438
+ * intent: { type: 'choice', ... },
439
+ * urgent: { type: 'noul', ... },
440
+ * },
441
+ * });
442
+ *
443
+ * // Key-safe: 'intent' and 'urgent' are the only valid keys.
444
+ * result.answers.intent // ✓ SystemOneAnswer
445
+ * result.answers.urgent // ✓ SystemOneAnswer
446
+ * result.answers.typo // ✗ TypeScript error
447
+ * ```
448
+ *
449
+ * The generic is purely a compile-time wrapper — the runtime behavior is
450
+ * unchanged. The generated types remain the canonical contract; these
451
+ * types are an SDK-level convenience that OpenAPI cannot express.
452
+ *
453
+ * Wave 13.
446
454
  */
447
455
 
448
- interface OpenAIToolCall {
449
- readonly id: string;
450
- readonly type: 'function';
451
- readonly function: {
452
- readonly name: string;
453
- /** JSON-encoded arguments string, matching OpenAI's wire format (not a parsed object). */
454
- readonly arguments: string;
455
- };
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;
470
- interface OpenAIMessage {
471
- readonly role: 'system' | 'user' | 'assistant' | 'tool';
472
- readonly content: string | readonly OpenAIContentPart[];
473
- readonly name?: string | undefined;
474
- readonly tool_calls?: readonly OpenAIToolCall[] | undefined;
475
- /** Ollama may emit model reasoning alongside assistant content. */
476
- readonly reasoning?: string | undefined;
477
- /** Set on a `role: 'tool'` message to identify which call this is a result for. */
478
- readonly tool_call_id?: string | undefined;
479
- }
480
- interface OpenAIStreamOptions {
481
- /** Emit a final SSE chunk carrying `usage` (prompt/completion/total tokens) before `[DONE]`. */
482
- readonly include_usage?: boolean | undefined;
483
- }
484
- interface OpenAIFunctionDefinition {
485
- readonly name: string;
486
- readonly description?: string | undefined;
487
- readonly parameters?: Record<string, unknown> | undefined;
488
- }
489
- interface OpenAITool {
490
- readonly type: 'function';
491
- readonly function: OpenAIFunctionDefinition;
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
- };
502
- interface OpenAIChatCompletionRequest {
503
- readonly model: string;
504
- readonly messages: readonly OpenAIMessage[];
505
- readonly temperature?: number | undefined;
506
- readonly top_p?: number | undefined;
507
- readonly stream?: boolean | undefined;
508
- /** Only meaningful when `stream: true`; ignored otherwise. */
509
- readonly stream_options?: OpenAIStreamOptions | undefined;
510
- readonly max_tokens?: number | undefined;
511
- readonly stop?: readonly string[] | undefined;
512
- readonly response_format?: OpenAIResponseFormat | undefined;
513
- readonly seed?: number | undefined;
514
- readonly presence_penalty?: number | undefined;
515
- readonly frequency_penalty?: number | undefined;
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;
522
- readonly tools?: readonly OpenAITool[] | undefined;
523
- /**
524
- * @remarks Accepted for OpenAI compatibility but ignored by Ollama — every tool the
525
- * model is given remains callable regardless of this value.
526
- */
527
- readonly tool_choice?: 'none' | 'auto' | 'required' | {
528
- readonly type: 'function';
529
- readonly function: {
530
- readonly name: string;
531
- };
532
- } | undefined;
533
- /**
534
- * @remarks Accepted for OpenAI compatibility but ignored by Ollama — Ollama does not
535
- * control tool-call parallelism through this flag.
536
- */
537
- readonly parallel_tool_calls?: boolean | undefined;
538
- /**
539
- * Effort level for thinking models (e.g. `deepseek-r1`, `qwen3`). Equivalent to
540
- * `reasoning.effort`; only effective for models that support reasoning/thinking.
541
- */
542
- readonly reasoning_effort?: OpenAIReasoningEffort | undefined;
543
- /**
544
- * Effort level for thinking models (e.g. `deepseek-r1`, `qwen3`), nested OpenAI-style.
545
- * Equivalent to `reasoning_effort`; only effective for models that support
546
- * reasoning/thinking.
547
- */
548
- readonly reasoning?: {
549
- readonly effort?: OpenAIReasoningEffort | undefined;
550
- } | undefined;
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
- };
570
- interface OpenAIChatCompletionChoice {
571
- readonly index: number;
572
- readonly message: OpenAIMessage;
573
- readonly finish_reason: string;
574
- readonly logprobs?: Record<string, unknown> | null | undefined;
575
- }
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 {
599
- readonly id: string;
600
- readonly object: 'chat.completion.chunk';
601
- readonly created: number;
602
- readonly model: string;
603
- readonly system_fingerprint?: string | undefined;
604
- readonly choices: readonly OpenAIChatCompletionChunkChoice[];
605
- readonly usage?: {
606
- readonly prompt_tokens: number;
607
- readonly completion_tokens: number;
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;
617
- } | undefined;
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
- }
628
- interface OpenAIModelItem {
629
- readonly id: string;
630
- readonly object: 'model';
631
- readonly created: number;
632
- readonly owned_by: string;
633
- }
634
- interface OpenAIListModelsResponse {
635
- readonly object: 'list';
636
- readonly data: readonly OpenAIModelItem[];
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
- }
719
456
  /**
720
- * Request body for OpenAI's Responses API (`/v1/responses`), added in Ollama v0.13.3.
721
- *
722
- * @remarks
723
- * Ollama implements this **non-statefully**: every call is independent, so
724
- * {@link previous_response_id} and {@link conversation} — OpenAI's mechanisms for
725
- * resuming server-side conversation state — are accepted for compatibility but ignored.
726
- * Send the full conversation in `input` on every call, the same as `/api/chat`.
457
+ * Discriminated union of the three question kinds. The upstream OpenAPI
458
+ * defines this inline as `oneOf` within SystemOneRequest.questions; we
459
+ * reconstruct it as a named type for SDK ergonomics.
727
460
  */
728
- interface OpenAIResponsesRequest {
729
- readonly model: string;
730
- readonly input: string | readonly OpenAIMessage[];
731
- readonly instructions?: string | undefined;
732
- readonly tools?: readonly OpenAITool[] | undefined;
733
- readonly stream?: boolean | undefined;
734
- readonly temperature?: number | undefined;
735
- readonly top_p?: number | undefined;
736
- readonly max_output_tokens?: number | undefined;
737
- /** @remarks Not supported by Ollama, which is stateless across calls — accepted but ignored. */
738
- readonly previous_response_id?: string | undefined;
739
- /** @remarks Not supported by Ollama, which is stateless across calls — accepted but ignored. */
740
- readonly conversation?: string | undefined;
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;
760
- }
761
- interface OpenAIResponsesOutputTextContent {
762
- readonly type: 'output_text';
763
- readonly text: string;
764
- readonly annotations?: readonly Record<string, unknown>[] | undefined;
765
- readonly logprobs?: readonly Record<string, unknown>[] | undefined;
766
- }
767
- interface OpenAIResponsesOutputRefusal {
768
- readonly type: 'refusal';
769
- readonly refusal: string;
770
- }
771
- type OpenAIResponsesOutputContent = OpenAIResponsesOutputTextContent | OpenAIResponsesOutputRefusal;
772
- interface OpenAIResponsesOutputMessage {
773
- readonly type: 'message';
774
- readonly id?: string | undefined;
775
- readonly status?: OpenAIResponsesStatus | undefined;
776
- readonly role?: string | undefined;
777
- readonly phase?: string | undefined;
778
- readonly content: readonly OpenAIResponsesOutputContent[];
779
- }
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 {
461
+ type SystemOneQuestion = SystemOneChoiceQuestion | SystemOneNoulQuestion | SystemOneScoreQuestion;
462
+ /**
463
+ * Discriminated union of the three answer kinds. The upstream OpenAPI
464
+ * defines this inline as `oneOf` within SystemOneResponse.answers; we
465
+ * reconstruct it as a named type for SDK ergonomics.
466
+ */
467
+ type SystemOneAnswer = SystemOneChoiceAnswer | SystemOneNoulAnswer | SystemOneScoreAnswer;
468
+ /**
469
+ * Token usage for a System One call. The upstream OpenAPI defines this
470
+ * inline within SystemOneResponse; we reconstruct it as a named type
471
+ * for SDK ergonomics. Carries input_tokens and output_tokens (not
472
+ * prompt_tokens/completion_tokens).
473
+ */
474
+ interface SystemOneUsage {
801
475
  readonly input_tokens: number;
802
476
  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. */
808
- interface OpenAIResponsesResponse {
809
- readonly id: string;
810
- readonly object: 'response';
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;
817
- readonly model: string;
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
477
  }
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;
478
+ /** Map of question id → question descriptor. */
479
+ type SystemOneQuestions = Record<string, SystemOneQuestion>;
480
+ /**
481
+ * Wave 16 (P2): conditional mapping from a question type to its
482
+ * corresponding answer type. This gives compile-time type correlation:
483
+ *
484
+ * choice question → choice answer
485
+ * noul question → noul answer
486
+ * score question → score answer
487
+ *
488
+ * Without this, `SystemOneAnswers<Q>` maps every key to the full
489
+ * `SystemOneAnswer` union, requiring manual narrowing. With this,
490
+ * `result.answers.myChoiceQuestion` is automatically typed as
491
+ * `SystemOneChoiceAnswer`.
492
+ */
493
+ type AnswerFor<Q> = Q extends {
494
+ readonly type: 'choice';
495
+ } ? SystemOneChoiceAnswer : Q extends {
496
+ readonly type: 'noul';
497
+ } ? SystemOneNoulAnswer : Q extends {
498
+ readonly type: 'score';
499
+ } ? SystemOneScoreAnswer : SystemOneAnswer;
500
+ /**
501
+ * Key-safe answers map: for every question key `K` in `Q`, the response
502
+ * carries the answer type that corresponds to that question's type.
503
+ * Wave 16: now uses `AnswerFor<Q[K]>` for exact type correlation.
504
+ */
505
+ type SystemOneAnswers<Q extends SystemOneQuestions = SystemOneQuestions> = {
506
+ readonly [K in keyof Q]: AnswerFor<Q[K]>;
1001
507
  };
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>;
508
+ /**
509
+ * Generic System One request. When `Q` is provided, `questions` is typed
510
+ * as `Q` (the caller's specific question map) rather than the loose
511
+ * `Record<string, SystemOneQuestion>`. The response's `answers` will
512
+ * then carry the same keys.
513
+ *
514
+ * The `model`, `state`, `images`, and `keep_alive` fields are inherited
515
+ * from the generated base type unchanged.
516
+ */
517
+ interface SystemOneRequest<Q extends SystemOneQuestions = SystemOneQuestions> extends Omit<SystemOneRequest$1, 'questions'> {
518
+ readonly questions: Q;
1012
519
  }
1013
- declare class OpenAICompatClient {
1014
- private readonly http;
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>;
1030
- listModels(signal?: AbortSignal): Promise<OpenAIListModelsResponse>;
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>;
520
+ /**
521
+ * Generic System One response. When `Q` is provided, `answers` is typed
522
+ * as `SystemOneAnswers<Q>` — a key-safe map matching the questions the
523
+ * caller asked.
524
+ */
525
+ interface SystemOneResponse<Q extends SystemOneQuestions = SystemOneQuestions> extends Omit<SystemOneResponse$1, 'answers' | 'usage'> {
526
+ readonly answers: SystemOneAnswers<Q>;
527
+ readonly usage: SystemOneUsage;
1059
528
  }
1060
529
 
1061
530
  /**
1062
- * Anthropic Compatibility interfaces and client helpers for Ollama.
1063
- * Ollama supports the Anthropic Messages API format.
531
+ * Higher-level System One decision helpers.
532
+ *
533
+ * Wave 14B: These helpers wrap the low-level `OllamaClient.systemOne()`
534
+ * with ergonomic APIs for the six most common decision patterns. Each
535
+ * helper constructs a single-question request, sends it, and extracts
536
+ * the typed answer — so callers don't have to deal with the question
537
+ * map / answer map indirection for single-decision calls.
538
+ *
539
+ * The helpers return typed results (not generic SystemOneAnswer) so
540
+ * callers can branch on the discriminated union without manual
541
+ * type narrowing.
542
+ *
543
+ * For multi-question calls (e.g. routing + urgency + difficulty in
544
+ * one request), use `OllamaClient.systemOne()` directly with the
545
+ * generic key-safe wrapper.
1064
546
  */
1065
547
 
1066
- interface AnthropicCacheControl {
1067
- readonly type: 'ephemeral';
1068
- readonly ttl?: '5m' | '1h' | undefined;
1069
- }
1070
- interface AnthropicTextContentBlock {
1071
- readonly type: 'text';
1072
- readonly text: string;
1073
- readonly cache_control?: AnthropicCacheControl | undefined;
1074
- }
1075
- interface AnthropicImageContentBlock {
1076
- readonly type: 'image';
1077
- readonly source: {
1078
- readonly type: 'base64';
1079
- readonly media_type: string;
1080
- readonly data: string;
548
+ /**
549
+ * Result of a choice decision: the selected option key + probability
550
+ * distribution + confidence.
551
+ */
552
+ interface ChoiceDecision {
553
+ /** The selected option key (highest probability). */
554
+ readonly choice: string;
555
+ /** Probability distribution over all options. */
556
+ readonly probabilities: Record<string, number>;
557
+ /** Distribution concentration (0–1). NOT a guarantee of correctness. */
558
+ readonly confidence: number;
559
+ /** Token usage for the call. */
560
+ readonly usage: {
561
+ readonly input_tokens: number;
562
+ readonly output_tokens: number;
1081
563
  };
1082
564
  }
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;
1105
- interface AnthropicMessage {
1106
- readonly role: 'user' | 'assistant';
1107
- readonly content: string | readonly AnthropicContentBlock[];
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
- }
1146
- interface AnthropicMessagesRequest {
1147
- readonly model: string;
1148
- readonly messages: readonly AnthropicMessage[];
1149
- readonly system?: AnthropicSystem | undefined;
1150
- readonly max_tokens?: number | undefined;
1151
- readonly temperature?: number | undefined;
1152
- readonly top_p?: number | undefined;
1153
- readonly top_k?: number | undefined;
1154
- readonly stop_sequences?: readonly string[] | undefined;
1155
- readonly stream?: boolean | undefined;
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
- };
1191
- interface AnthropicMessagesResponse {
1192
- readonly id: string;
1193
- readonly type: 'message';
1194
- readonly role: 'assistant';
1195
- readonly content: readonly AnthropicContentBlock[];
1196
- readonly model: string;
1197
- readonly stop_reason: string | null;
1198
- readonly stop_sequence?: string | null | undefined;
1199
- readonly usage?: {
565
+ /**
566
+ * Result of a noul (yes/no) decision: the probability of true + a
567
+ * boolean derived from it (>= 0.5 → true).
568
+ */
569
+ interface NoulDecision {
570
+ /** Probability of true (0–1). */
571
+ readonly noul: number;
572
+ /** Boolean decision: true if noul >= 0.5, false otherwise. */
573
+ readonly bool: boolean;
574
+ /** Token usage for the call. */
575
+ readonly usage: {
1200
576
  readonly input_tokens: number;
1201
577
  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;
1205
- } | undefined;
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
578
  };
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
579
  }
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;
580
+ /**
581
+ * Result of a score decision: the probability-weighted average score,
582
+ * the legend (index → description), the probability distribution, and
583
+ * confidence.
584
+ */
585
+ interface ScoreDecision {
586
+ /** Probability-weighted average of zero-based criterion indices (0 to N-1). */
587
+ readonly score: number;
588
+ /** Zero-based indices as string keys → criterion descriptions. */
589
+ readonly legend: Record<string, string>;
590
+ /** Probabilities keyed by zero-based criterion indices as strings. */
591
+ readonly probabilities: Record<string, number>;
592
+ /** Distribution concentration (0–1). NOT a guarantee of correctness. */
593
+ readonly confidence: number;
594
+ /** Token usage for the call. */
595
+ readonly usage: {
596
+ readonly input_tokens: number;
597
+ readonly output_tokens: number;
1263
598
  };
1264
599
  }
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
- }
1282
- declare class AnthropicCompatClient {
1283
- private readonly http;
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>;
600
+ /**
601
+ * Result of a ranking call: candidates sorted by score (highest first),
602
+ * each with its score and probability distribution.
603
+ */
604
+ interface RankResult<T extends string> {
605
+ readonly candidate: T;
606
+ readonly score: number;
607
+ readonly confidence: number;
1301
608
  }
609
+ /**
610
+ * Higher-level System One decision helpers.
611
+ *
612
+ * Create via `createDecision(client)` or access via `client.decision`
613
+ * (if the accessor is wired). Each helper constructs a single-question
614
+ * System One request and extracts the typed answer.
615
+ *
616
+ * Example:
617
+ * ```ts
618
+ * const decision = createDecision(client);
619
+ * const result = await decision.choice({
620
+ * model: 'tev1:4b',
621
+ * state: 'Customer was charged twice',
622
+ * instructions: 'What is the primary intent?',
623
+ * criteria: {
624
+ * refund: 'Customer wants a refund',
625
+ * duplicate_charge: 'Customer reports multiple charges',
626
+ * cancellation: 'Customer wants to cancel',
627
+ * },
628
+ * });
629
+ * console.log(result.choice); // 'duplicate_charge'
630
+ * console.log(result.confidence); // 0.89
631
+ * ```
632
+ */
633
+ interface Decision {
634
+ /**
635
+ * Ask a single choice question. Returns the selected option + full
636
+ * probability distribution + confidence.
637
+ *
638
+ * Use for: routing, classification, model selection, tool selection,
639
+ * category assignment — any "which one?" decision with bounded options.
640
+ */
641
+ choice(params: {
642
+ model: string;
643
+ state: SystemOneContent;
644
+ instructions: SystemOneContent;
645
+ criteria: Record<string, string | null>;
646
+ images?: string[];
647
+ keepAlive?: string | number;
648
+ }): Promise<ChoiceDecision>;
649
+ /**
650
+ * Ask a single yes/no (noul) question. Returns the probability of
651
+ * true (0–1) + a boolean derived from it (>= 0.5 → true).
652
+ *
653
+ * Use for: gating, verification, safety checks, eligibility, prompt-
654
+ * injection detection — any "is this true?" decision.
655
+ */
656
+ noul(params: {
657
+ model: string;
658
+ state: SystemOneContent;
659
+ instructions: SystemOneContent;
660
+ images?: string[];
661
+ keepAlive?: string | number;
662
+ }): Promise<NoulDecision>;
663
+ /**
664
+ * Ask a single score question. Returns the probability-weighted
665
+ * average score + legend + probability distribution + confidence.
666
+ *
667
+ * Use for: severity, priority, difficulty, relevance, quality — any
668
+ * "how strongly does this fit this ordered rubric?" decision.
669
+ */
670
+ score(params: {
671
+ model: string;
672
+ state: SystemOneContent;
673
+ instructions: SystemOneContent;
674
+ /** Ordered criteria from lowest (index 0) to highest. 2–26 items. */
675
+ criteria: string[];
676
+ images?: string[];
677
+ keepAlive?: string | number;
678
+ }): Promise<ScoreDecision>;
679
+ /**
680
+ * Route a request to one of N named options. Convenience wrapper
681
+ * around `choice()` that returns just the selected route name.
682
+ *
683
+ * Use for: workflow routing, model routing, agent dispatch, tool
684
+ * selection — any "which handler?" decision.
685
+ */
686
+ route<T extends string>(params: {
687
+ model: string;
688
+ state: SystemOneContent;
689
+ instructions: SystemOneContent;
690
+ criteria: Record<T, string | null>;
691
+ images?: string[];
692
+ keepAlive?: string | number;
693
+ }): Promise<{
694
+ readonly route: T;
695
+ readonly confidence: number;
696
+ }>;
697
+ /**
698
+ * Verify whether a claim is supported by evidence. Convenience
699
+ * wrapper around `noul()` that returns a boolean + the probability
700
+ * of true (not System One's confidence score — noul answers don't
701
+ * carry a separate confidence field).
702
+ *
703
+ * Use for: evidence verification, safety gates, prompt-injection
704
+ * detection, compliance checks — any "is this claim true given
705
+ * this evidence?" decision.
706
+ */
707
+ verify(params: {
708
+ model: string;
709
+ claim: SystemOneContent;
710
+ evidence: SystemOneContent;
711
+ instructions?: SystemOneContent;
712
+ images?: string[];
713
+ keepAlive?: string | number;
714
+ }): Promise<{
715
+ readonly verified: boolean;
716
+ readonly probability: number;
717
+ }>;
718
+ /**
719
+ * Rank candidates by score. Sends one System One call per candidate
720
+ * (parallelized), then sorts by score descending.
721
+ *
722
+ * Use for: semantic reranking, candidate ranking, priority scoring,
723
+ * relevance scoring — any "which of these is best?" decision where
724
+ * each candidate is scored independently against the same rubric.
725
+ *
726
+ * Note: this makes N parallel requests (one per candidate). For
727
+ * large candidate sets, consider batching or using a single choice
728
+ * question with all candidates as options instead.
729
+ */
730
+ rank<T extends string>(params: {
731
+ model: string;
732
+ instructions: SystemOneContent;
733
+ /** Ordered criteria from lowest (index 0) to highest. 2–26 items. */
734
+ criteria: string[];
735
+ candidates: ReadonlyArray<{
736
+ readonly id: T;
737
+ readonly state: SystemOneContent;
738
+ }>;
739
+ images?: string[];
740
+ keepAlive?: string | number;
741
+ }): Promise<ReadonlyArray<RankResult<T>>>;
742
+ }
743
+ /** Create a Decision helper bound to an OllamaClient. */
744
+ declare function createDecision(client: OllamaClient): Decision;
1302
745
 
1303
746
  /**
1304
747
  * High-level Ollama client — the original, hand-written API surface.
@@ -1362,23 +805,52 @@ declare class OllamaClient {
1362
805
  * API with the generated `NativeApi` / `OpenAIApi` / `AnthropicApi`
1363
806
  * surface without configuring two separate HttpClient instances.
1364
807
  *
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
- * ```
808
+ * Wave 14: the runtime now participates in multi-endpoint failover.
809
+ * Each request is routed through this client's `executeWithFailover`
810
+ * machinery via a {@link FailoverHttpClient} wrapper. If the first
811
+ * candidate endpoint is down, requests automatically fail over to
812
+ * the next healthy candidate — matching the behavior of the
813
+ * hand-written OllamaClient methods (chat, generate, etc.).
1376
814
  *
1377
815
  * The runtime is cached on first call — subsequent calls return the
1378
- * same instance.
816
+ * same instance. The `FailoverHttpClient` holds a reference to this
817
+ * client, so it always sees the current endpoint registry state.
1379
818
  */
1380
819
  get runtime(): OllamaRuntime;
1381
820
  private _runtime;
821
+ /**
822
+ * Lazily-constructed `NativeApi` bound to this client's runtime. Exposes
823
+ * the full generated native API surface (chat, generate, embed, systemOne,
824
+ * etc.) with contract-driven types and runtime enforcement.
825
+ *
826
+ * Wave 13: `systemOne()` delegates to this accessor.
827
+ */
828
+ get native(): NativeApi;
829
+ private _nativeApi;
830
+ /**
831
+ * Higher-level System One decision helpers (Wave 14B).
832
+ *
833
+ * Ergonomic wrappers around `systemOne()` for the six most common
834
+ * decision patterns: `choice()`, `noul()`, `score()`, `route()`,
835
+ * `verify()`, `rank()`. Each constructs a single-question request
836
+ * and extracts the typed answer.
837
+ *
838
+ * ```ts
839
+ * const result = await client.decision.choice({
840
+ * model: 'tev1:4b',
841
+ * state: 'Customer was charged twice',
842
+ * instructions: 'What is the primary intent?',
843
+ * criteria: {
844
+ * refund: 'Customer wants a refund',
845
+ * duplicate_charge: 'Customer reports multiple charges',
846
+ * },
847
+ * });
848
+ * console.log(result.choice); // 'duplicate_charge'
849
+ * console.log(result.confidence); // 0.89
850
+ * ```
851
+ */
852
+ get decision(): Decision;
853
+ private _decision;
1382
854
  /**
1383
855
  * Fail-fast guard for `format` (structured output) requests: throws before any network
1384
856
  * call if the candidate endpoint is inferred as Ollama Cloud, which does not currently
@@ -1458,6 +930,38 @@ declare class OllamaClient {
1458
930
  readonly version: () => Promise<VersionResponse>;
1459
931
  readonly createBlob: (digest: string, data: BinaryBody) => Promise<void>;
1460
932
  readonly checkBlob: (digest: string) => Promise<boolean>;
933
+ /**
934
+ * Ollama's System One decision layer (`POST /v1/systemone`) — evaluates
935
+ * 1–64 typed questions (choice, noul, or score) against a provided state
936
+ * and returns typed answers with probabilities and confidence.
937
+ *
938
+ * Local-only; requires Ollama >= 0.35.0. The runtime enforces the
939
+ * version constraint automatically (lazily fetching `/api/version` when
940
+ * `enforceVersion` is `'auto'` or `'strict'`) and rejects cloud-mode
941
+ * calls. Request size is checked client-side: 64 KiB without images,
942
+ * 32 MiB with images.
943
+ *
944
+ * The generic `Q` parameter captures the caller's question map at
945
+ * compile time, giving key-safe answer access:
946
+ *
947
+ * ```ts
948
+ * const result = await ollama.systemOne({
949
+ * model: 'tev1:4b',
950
+ * state: { ticket: 'Customer was charged twice' },
951
+ * questions: {
952
+ * intent: { type: 'choice', instructions: '...', criteria: { ... } },
953
+ * urgent: { type: 'noul', instructions: '...' },
954
+ * },
955
+ * });
956
+ * result.answers.intent // ✓ SystemOneAnswer (choice)
957
+ * result.answers.urgent // ✓ SystemOneAnswer (noul)
958
+ * result.answers.typo // ✗ TypeScript error
959
+ * ```
960
+ *
961
+ * For the low-level generated API (without the generic wrapper), use
962
+ * `client.native.systemOne(request)` directly.
963
+ */
964
+ systemOne<Q extends SystemOneQuestions = SystemOneQuestions>(request: SystemOneRequest<Q>): Promise<SystemOneResponse<Q>>;
1461
965
  /**
1462
966
  * Ollama's hosted web search tool (`POST https://ollama.com/api/web_search`) — a fixed
1463
967
  * Ollama Cloud service, unrelated to `config.endpoints`/`baseUrl` and not proxied
@@ -1667,6 +1171,12 @@ interface LoadMcpToolsOptions {
1667
1171
  * model-oriented text representation. The default preserves existing behavior.
1668
1172
  */
1669
1173
  readonly resultMode?: McpToolResultMode | undefined;
1174
+ /** Validate structuredContent against a tool's MCP outputSchema. Defaults to true. */
1175
+ readonly validateOutputSchema?: boolean | undefined;
1176
+ /** Invoke optional task-capable tools as legacy MCP tasks when supported. */
1177
+ readonly taskMode?: 'required-only' | 'all-supported' | undefined;
1178
+ /** Requested lifetime for legacy task-augmented tool calls, in milliseconds. */
1179
+ readonly taskTtlMs?: number | undefined;
1670
1180
  }
1671
1181
  declare function listAllMcpTools(mcpClient: McpClientLike, options?: LoadMcpToolsOptions, signal?: AbortSignal): Promise<McpToolDescriptor[]>;
1672
1182
  declare function loadMcpTools(mcpClient: McpClientLike, options?: LoadMcpToolsOptions, signal?: AbortSignal): Promise<AnyTool[]>;
@@ -1682,6 +1192,15 @@ declare class McpBridge {
1682
1192
  definitions(signal?: AbortSignal): Promise<ToolDefinition[]>;
1683
1193
  loadTools(signal?: AbortSignal): Promise<AnyTool[]>;
1684
1194
  register(registry: ToolRegistry, signal?: AbortSignal): Promise<void>;
1195
+ /** Refreshes the current MCP tool catalog into an existing registry without clearing local tools. */
1196
+ refresh(registry: ToolRegistry, signal?: AbortSignal): Promise<void>;
1197
+ /** Fetches one legacy MCP task's current status without starting a polling loop. */
1198
+ getTaskStatus(taskId: string, signal?: AbortSignal): Promise<McpTask>;
1199
+ /** Retrieves a completed legacy MCP task's result. */
1200
+ getTaskResult(taskId: string, signal?: AbortSignal): Promise<McpCallToolResult>;
1201
+ /** Cancels one legacy MCP task. */
1202
+ cancelTask(taskId: string, signal?: AbortSignal): Promise<McpTask>;
1203
+ private requestTask;
1685
1204
  }
1686
1205
 
1687
1206
  /**
@@ -1840,4 +1359,4 @@ declare const GEN_AI_SYSTEM_OLLAMA = "ollama";
1840
1359
  */
1841
1360
  declare function encodeImage(image: Uint8Array | string): Promise<string>;
1842
1361
 
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 };
1362
+ 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 AnswerFor, AnthropicCompatClient, AnyTool, type BackoffOptions, ChatRequestOptions, ChatResponse, ChatStreamResult, type ChoiceDecision, CopyRequestOptions, CreateRequestOptions, DEFAULT_BACKOFF, DEFAULT_BASE_URL, DEFAULT_FAILOVER_CODES, DEFAULT_RETRY_CONFIG, DEFAULT_TIMEOUT_MS, type Decision, 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, McpCallToolResult, McpClientLike, McpTask, McpToolDescriptor, Message, Middleware, type ModelCapabilities, ModelOptions, ModelResponse, ModelsClient, type NoulDecision, OLLAMA_CLOUD_BASE_URL, OllamaClient, type OllamaClientConfig, type OllamaCloudFreeTierQuotaBudgets, type OllamaCredentialConfig, type OllamaEndpoint, OllamaStream, OllamaStreamEvent, OllamaStreamEventType, OpenAICompatClient, ProgressResponse, ProgressStreamResult, PsResponse, PullRequestOptions, PushRequestOptions, QuotaManager, type QuotaManagerOptions, type QuotaWindowConfig, type QuotaWindowStatus, type RankResult, RawUsageSource, RequestLifecycleHook, RequestRunner, type RetryConfig, type RuntimeMode, type ScoreDecision, ShowRequestOptions, ShowResponse, type SpanAttributeValue, type SpanAttributes, StatusResponse, type SupportedSchema, type SystemOneAnswer, type SystemOneAnswers, SystemOneChoiceAnswer, SystemOneChoiceQuestion, SystemOneContent, SystemOneNoulAnswer, SystemOneNoulQuestion, type SystemOneQuestion, type SystemOneQuestions, type SystemOneRequest, type SystemOneResponse, SystemOneScoreAnswer, SystemOneScoreQuestion, type SystemOneUsage, ThinkValue, ThinkingMetadata, type TimeoutSignal, TokenUsage, Tool, ToolCall, ToolDefinition, ToolExecutionResult, ToolHandler, ToolRegistry, VersionResponse, WebFetchRequestOptions, WebFetchResponse, WebSearchRequestOptions, WebSearchResponse, addSpanEvent, calculateBackoff, checkEndpointHealth, createDecision, createOllamaCloudFreeTierQuota, createTimeoutSignal, defineTool, detectModelCapabilities, encodeImage, inferRuntimeMode, listAllMcpTools, listAvailableModels, loadMcpTools, normalizeChatStream, normalizeGenerateStream, normalizeProgressStream, parseNdjsonStream, parseStructuredOutput, registerMcpTools, resolveCredentialEndpoints, setSpanError, toDataStream, toResponse, toTextStream, withRetry, withSpan, zodToJsonSchema };