@nemesis-oss/ollama-sdk 1.7.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 (39) hide show
  1. package/CHANGELOG.md +10 -1
  2. package/dist/anthropic-B_UXplNF.d.ts +1647 -0
  3. package/dist/anthropic-CVDFy_a0.d.cts +1647 -0
  4. package/dist/generated-api.cjs +74 -6
  5. package/dist/generated-api.cjs.map +1 -1
  6. package/dist/generated-api.d.cts +230 -629
  7. package/dist/generated-api.d.ts +230 -629
  8. package/dist/generated-api.js +72 -7
  9. package/dist/generated-api.js.map +1 -1
  10. package/dist/generated-models-schemas.cjs +89 -1
  11. package/dist/generated-models-schemas.cjs.map +1 -1
  12. package/dist/generated-models-schemas.d.cts +121 -1
  13. package/dist/generated-models-schemas.d.ts +121 -1
  14. package/dist/generated-models-schemas.js +79 -2
  15. package/dist/generated-models-schemas.js.map +1 -1
  16. package/dist/generated-runtime.cjs +576 -57
  17. package/dist/generated-runtime.cjs.map +1 -1
  18. package/dist/generated-runtime.d.cts +21 -23
  19. package/dist/generated-runtime.d.ts +21 -23
  20. package/dist/generated-runtime.js +575 -58
  21. package/dist/generated-runtime.js.map +1 -1
  22. package/dist/index.cjs +1078 -75
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +378 -874
  25. package/dist/index.d.ts +378 -874
  26. package/dist/index.js +1075 -76
  27. package/dist/index.js.map +1 -1
  28. package/dist/mcp/tools.json +287 -73
  29. package/dist/mcp-generated.cjs +96 -7
  30. package/dist/mcp-generated.cjs.map +1 -1
  31. package/dist/mcp-generated.d.cts +1 -1
  32. package/dist/mcp-generated.d.ts +1 -1
  33. package/dist/mcp-generated.js +96 -7
  34. package/dist/mcp-generated.js.map +1 -1
  35. package/dist/{runtime-qwD72cpn.d.ts → runtime-C6UYtBRB.d.ts} +218 -4
  36. package/dist/{runtime-bQ48I-RC.d.cts → runtime-DTmUeU6K.d.cts} +218 -4
  37. package/dist/skills.cjs.map +1 -1
  38. package/dist/skills.js.map +1 -1
  39. package/package.json +3 -2
@@ -195,6 +195,61 @@ declare class OllamaRequestValidationError extends OllamaClientError {
195
195
  issues: readonly z.ZodIssue[];
196
196
  });
197
197
  }
198
+ /**
199
+ * Thrown by `OllamaRuntime.invoke` BEFORE any HTTP request is made when the
200
+ * serialized request body exceeds the operation's declared
201
+ * `constraints.maxRequestBytes`. The Ollama server returns 413 for such
202
+ * payloads; this client-side check fails fast so the round-trip is avoided.
203
+ *
204
+ * Wave 12 (P0 #5): the IR has carried `maxRequestBytes` for System One
205
+ * (64 KiB) since v1.7.0, but the runtime never enforced it. This closes
206
+ * that contract/runtime gap.
207
+ */
208
+ declare class OllamaRequestTooLargeError extends OllamaClientError {
209
+ readonly operationId: string;
210
+ readonly actualBytes: number;
211
+ readonly maxBytes: number;
212
+ constructor(message: string, options: Omit<OllamaClientErrorOptions, 'code' | 'retryable' | 'status'> & {
213
+ operationId: string;
214
+ actualBytes: number;
215
+ maxBytes: number;
216
+ });
217
+ }
218
+ /**
219
+ * Thrown by `OllamaRuntime.invoke` AFTER the HTTP response is received
220
+ * when `validateResponses: true` is set and the response body fails Zod
221
+ * validation against the operation's registered response schema.
222
+ *
223
+ * Wave 13: the runtime previously never validated responses (see ADR
224
+ * 0020). This opt-in error gives callers a way to detect wire-format
225
+ * mismatches for operations where typed response semantics are critical
226
+ * (e.g. System One). The error carries the original Zod issues so
227
+ * callers can inspect which fields failed.
228
+ */
229
+ declare class OllamaResponseValidationError extends OllamaClientError {
230
+ readonly operationId: string;
231
+ readonly issues: readonly z.ZodIssue[];
232
+ constructor(message: string, options: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> & {
233
+ operationId: string;
234
+ issues: readonly z.ZodIssue[];
235
+ });
236
+ }
237
+ /**
238
+ * Thrown by `OllamaRuntime.invoke` BEFORE any HTTP request is made when the
239
+ * operation declares `constraints.minOllamaVersion` and the runtime could
240
+ * not obtain a server version to compare against (e.g. `enforceVersion:
241
+ * 'strict'` was set and `/api/version` was unreachable). Distinct from
242
+ * {@link OllamaGenericClientError} so callers can branch on the failure
243
+ * mode rather than parsing the message.
244
+ */
245
+ declare class OllamaServerVersionUnknownError extends OllamaClientError {
246
+ readonly operationId: string;
247
+ readonly minRequiredVersion: string;
248
+ constructor(message: string, options: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> & {
249
+ operationId: string;
250
+ minRequiredVersion: string;
251
+ });
252
+ }
198
253
  declare class OllamaToolTimeoutError extends OllamaClientError {
199
254
  readonly toolName: string;
200
255
  readonly timeoutMs: number;
@@ -494,6 +549,21 @@ type CapabilitySupport = 'supported' | 'unsupported' | 'model-dependent' | 'vers
494
549
  interface SchemaRef {
495
550
  readonly $ref: string;
496
551
  }
552
+ /**
553
+ * Wave 15 (P0): structural parameter on an operation. Mirrors
554
+ * {@link OperationParameter} from the canonical IR. Path parameters
555
+ * are substituted into the operation's path template at runtime;
556
+ * query and header parameters are attached to the HTTP request.
557
+ */
558
+ interface OperationParameter {
559
+ readonly name: string;
560
+ readonly in: 'path' | 'query' | 'header';
561
+ readonly required: boolean;
562
+ readonly schema?: {
563
+ readonly type?: string;
564
+ };
565
+ readonly description?: string;
566
+ }
497
567
  /** Behavioral contract a generated operation carries into the runtime. */
498
568
  interface OperationDefinition {
499
569
  readonly operationId: string;
@@ -505,6 +575,25 @@ interface OperationDefinition {
505
575
  readonly local: boolean;
506
576
  readonly cloud: boolean;
507
577
  };
578
+ /**
579
+ * Wave 12 (P1 #7): host this operation targets, when different from
580
+ * the runtime's default HttpClient base URL. Cloud-hosted capability
581
+ * endpoints (web search, web fetch) live at `https://ollama.com/api/...`
582
+ * rather than the local Ollama server. The runtime rejects operations
583
+ * with a non-default host when the runtime's HttpClient isn't
584
+ * configured for that host — callers must use OllamaClient.webSearch /
585
+ * OllamaClient.webFetch (which spin up a dedicated cloud HttpClient)
586
+ * for these operations.
587
+ */
588
+ readonly host?: string;
589
+ /**
590
+ * Wave 15 (P0): structural parameters derived from the path template
591
+ * and OpenAPI declarations. Path parameters are substituted into the
592
+ * URL at runtime; query and header parameters are attached to the
593
+ * HTTP request. The runtime uses this to URI-encode and substitute
594
+ * `{name}` segments in the path.
595
+ */
596
+ readonly parameters?: readonly OperationParameter[];
508
597
  readonly transport: {
509
598
  readonly mode: TransportMode;
510
599
  readonly streaming: boolean;
@@ -521,6 +610,8 @@ interface OperationDefinition {
521
610
  readonly constraints?: {
522
611
  readonly minOllamaVersion?: string;
523
612
  readonly maxRequestBytes?: number;
613
+ /** Wave 13: limit when body contains images (e.g. System One: 32 MiB). */
614
+ readonly maxRequestBytesWithImages?: number;
524
615
  };
525
616
  readonly status: {
526
617
  readonly documented: boolean;
@@ -544,6 +635,28 @@ interface InvokeRequest {
544
635
  * doesn't explicitly set `stream`.
545
636
  */
546
637
  readonly streamingDefault?: boolean;
638
+ /**
639
+ * Wave 15 (P0): path parameter values keyed by parameter name. The
640
+ * runtime substitutes these into the operation's path template
641
+ * (e.g. `{model}` → `gpt-4`) with URI encoding.
642
+ */
643
+ readonly pathParams?: Readonly<Record<string, string>>;
644
+ /**
645
+ * Wave 15 (P0): query parameter values keyed by parameter name.
646
+ * The runtime attaches these to the HTTP request URL.
647
+ */
648
+ readonly queryParams?: Readonly<Record<string, string>>;
649
+ /**
650
+ * Wave 15 (P0): header parameter values keyed by header name.
651
+ * The runtime attaches these to the HTTP request headers.
652
+ */
653
+ readonly headerParams?: Readonly<Record<string, string>>;
654
+ /**
655
+ * Wave 15 (P1): model name for routing. Extracted from the request
656
+ * body when possible; used by the failover layer to filter endpoints
657
+ * by `OllamaEndpoint.models` (credential-scoped routing).
658
+ */
659
+ readonly model?: string;
547
660
  }
548
661
 
549
662
  /**
@@ -570,9 +683,30 @@ interface InvokeRequest {
570
683
  * existing HttpClient.
571
684
  */
572
685
 
686
+ /**
687
+ * Minimal HTTP client surface the runtime consumes. Either a full
688
+ * {@link HttpClient} or a {@link FailoverHttpClient} — the runtime only
689
+ * calls `request()`.
690
+ *
691
+ * Wave 14: widened from `HttpClient` to allow the failover-aware wrapper
692
+ * without breaking existing callers that pass a plain HttpClient.
693
+ */
694
+ type RuntimeHttpBackend = Pick<HttpClient, 'baseUrl' | 'request'>;
573
695
  /** Constructor options for {@link OllamaRuntime}. */
574
696
  interface OllamaRuntimeOptions {
575
- readonly http: HttpClient;
697
+ readonly http: RuntimeHttpBackend;
698
+ /**
699
+ * Wave 15 (P0): HTTP backend for operations that declare a non-default
700
+ * `host` (e.g. web search/fetch at `https://ollama.com`). When an
701
+ * operation has `host: 'https://ollama.com'` and `cloudHttp` is
702
+ * configured, the runtime routes the request through this backend
703
+ * instead of the default `http`. When `cloudHttp` is not configured
704
+ * and a host-bearing operation is invoked, the runtime throws.
705
+ *
706
+ * OllamaClient.runtime sets this to a dedicated cloud HttpClient
707
+ * pointed at `https://ollama.com` with the configured API key.
708
+ */
709
+ readonly cloudHttp?: RuntimeHttpBackend;
576
710
  /**
577
711
  * Whether this runtime is targeting a local Ollama instance. Defaults to
578
712
  * `true`. When `false`, operations marked `environment.cloud === false`
@@ -583,6 +717,10 @@ interface OllamaRuntimeOptions {
583
717
  * Server version, if known (typically from a prior `/api/version` call).
584
718
  * When set, operations with `constraints.minOllamaVersion` are checked
585
719
  * against this value at request time.
720
+ *
721
+ * Wave 12 (P0 #5): when unset, the runtime will lazily fetch and cache
722
+ * the server version the first time a version-gated operation is
723
+ * invoked. The fetch policy is controlled by {@link enforceVersion}.
586
724
  */
587
725
  readonly serverVersion?: string;
588
726
  /**
@@ -601,15 +739,75 @@ interface OllamaRuntimeOptions {
601
739
  * `/v1/systemone`, OpenAI/Anthropic compat surfaces), validation is
602
740
  * skipped silently.
603
741
  *
604
- * Response validation is intentionally NOT enabled — see ADR 0020 for
605
- * the rationale (forward-compat with wire-format extensions).
742
+ * Response validation is intentionally NOT enabled by default — see
743
+ * ADR 0020 for the rationale (forward-compat with wire-format
744
+ * extensions).
745
+ *
746
+ * Wave 13: an opt-in `validateResponses` option is now available for
747
+ * operations where typed response semantics are the entire point
748
+ * (e.g. System One). When enabled, the runtime validates the HTTP
749
+ * response body against the operation's registered response schema
750
+ * before returning it to the caller. On failure, throws
751
+ * {@link OllamaResponseValidationError}.
606
752
  */
607
753
  readonly validateRequests?: boolean;
754
+ /**
755
+ * Wave 13: when `true`, the runtime validates every response body
756
+ * against the operation's registered response schema before returning
757
+ * it. Defaults to `false` — opt-in. Only operations with a registered
758
+ * response schema are validated; others pass through unchanged.
759
+ *
760
+ * On validation failure, throws {@link OllamaResponseValidationError}
761
+ * with the Zod issues attached. The HTTP response is still consumed.
762
+ *
763
+ * Use this for operations where typed response semantics are critical
764
+ * (System One, structured output). Don't enable globally — legitimate
765
+ * forward-compat wire-format extensions would cause false rejections.
766
+ */
767
+ readonly validateResponses?: boolean;
768
+ /**
769
+ * Policy for enforcing `constraints.minOllamaVersion` when
770
+ * {@link serverVersion} is not explicitly supplied.
771
+ *
772
+ * - `'auto'` (default): lazily fetch `/api/version` once and cache the
773
+ * result; subsequent version-gated invocations reuse the cached
774
+ * value. If the fetch fails, the operation is allowed through
775
+ * (fail-open) — the server will reject it if it truly doesn't
776
+ * support it.
777
+ * - `'strict'`: same as `'auto'`, but if the version fetch fails the
778
+ * invocation throws {@link OllamaServerVersionUnknownError} rather
779
+ * than fail-open. Use this when the caller wants hard guarantees
780
+ * that a version-gated operation will not be sent to a server that
781
+ * can't handle it.
782
+ * - `'off'`: never fetch `/api/version` automatically. The runtime
783
+ * only enforces the version constraint when {@link serverVersion}
784
+ * was explicitly supplied. Useful in tests that mock fetch and want
785
+ * to avoid spurious version probes.
786
+ */
787
+ readonly enforceVersion?: 'auto' | 'strict' | 'off';
608
788
  }
609
789
  /** The runtime seam. */
610
790
  declare class OllamaRuntime {
611
791
  private readonly options;
792
+ /**
793
+ * Cached promise of the Ollama server version, populated lazily the first
794
+ * time a version-gated operation is invoked. `undefined` until then.
795
+ *
796
+ * Wave 12 (P0 #5): see {@link OllamaRuntimeOptions.enforceVersion}.
797
+ */
798
+ private serverVersionCache;
612
799
  constructor(options: OllamaRuntimeOptions);
800
+ /**
801
+ * Wave 15 (P0): resolve the HTTP backend for a given operation.
802
+ *
803
+ * Operations with a declared `host` (e.g. web search/fetch at
804
+ * https://ollama.com) must route to a HttpClient pointed at that host,
805
+ * not the default one. The runtime accepts an optional `cloudHttp`
806
+ * backend for this purpose — if the operation declares a host and no
807
+ * cloud backend is configured, the runtime throws rather than silently
808
+ * sending the request to the wrong server.
809
+ */
810
+ private resolveHttpBackend;
613
811
  /**
614
812
  * Invoke an operation. Called by every generated API method.
615
813
  *
@@ -618,6 +816,22 @@ declare class OllamaRuntime {
618
816
  * class's overloads pick the right return type at compile time.
619
817
  */
620
818
  invoke<T = unknown>(req: InvokeRequest): Promise<T>;
819
+ /**
820
+ * Apply environment + version guards before delegating to HttpClient.
821
+ *
822
+ * Throws {@link OllamaGenericClientError} when:
823
+ * - The operation is local-only and the runtime is in cloud mode.
824
+ * - The operation has `constraints.minOllamaVersion` and the server is older.
825
+ *
826
+ * Wave 12 (P0 #5): when `minOllamaVersion` is declared but the runtime's
827
+ * `serverVersion` is unknown AND `enforceVersion` is `'auto'` or
828
+ * `'strict'`, the runtime lazily fetches `/api/version` (cached on the
829
+ * runtime instance) so the constraint is actually enforced even when the
830
+ * caller didn't supply it. Previously the constraint was only enforced
831
+ * when `serverVersion` was manually supplied — meaning in practice it was
832
+ * almost never enforced.
833
+ */
834
+ private assertOperationAllowed;
621
835
  }
622
836
 
623
- export { OllamaServerError as $, type AbortableAsyncIterable as A, type BinaryBody as B, type ChatStreamResult as C, type DoneEvent as D, type ErrorEvent as E, type FetchLike as F, type GenerateStreamResult as G, HttpClient as H, type InvokeRequest as I, type OllamaErrorResponseContext as J, OllamaGenericClientError as K, type Logger as L, type Middleware as M, NANOS_PER_MS as N, OllamaRuntime as O, type ProgressStreamResult as P, OllamaIncompatibleModelError as Q, type RequestLifecycleHook as R, type SchemaRef as S, type TokenUsage as T, OllamaMcpError as U, OllamaModelRoutingError as V, OllamaNetworkError as W, OllamaNotFoundError as X, OllamaQuotaExceededError as Y, OllamaRateLimitError as Z, OllamaRequestValidationError as _, type OperationDefinition as a, OllamaSkillInvalidError as a0, OllamaSkillNotFoundError as a1, OllamaTimeoutError as a2, OllamaToolTimeoutError as a3, OllamaToolValidationError as a4, OllamaUnsupportedCapabilityError as a5, type RequestContext as a6, type RequestLifecycleEvent as a7, type ResponseContext as a8, type ThinkingEvent as a9, type TokenEvent as aa, type ToolCallEvent as ab, composeMiddleware as ac, createConsoleLogger as ad, extractUsage as ae, mapError as af, parseSseStream as ag, type OllamaRuntimeOptions as b, type OllamaStreamEvent as c, type OllamaStreamEventType as d, type SseEvent as e, OllamaClientError as f, type RawUsageSource as g, type HttpBody as h, type HttpClientOptions as i, type HttpRequestOptions as j, type LifecycleErrorEvent as k, type LifecycleRetryEvent as l, type LifecycleStartEvent as m, type LifecycleSuccessEvent as n, type LogFn as o, type MessageEvent as p, type MiddlewareContext as q, NANOS_PER_SECOND as r, NOOP_LOGGER as s, type NextFunction as t, OllamaAbortError as u, OllamaAgentMaxIterationsError as v, OllamaAgentMaxToolCallsError as w, OllamaAuthError as x, type OllamaClientErrorOptions as y, type OllamaErrorRequestContext as z };
837
+ export { OllamaResponseValidationError as $, type AbortableAsyncIterable as A, type BinaryBody as B, type ChatStreamResult as C, type DoneEvent as D, type ErrorEvent as E, type FetchLike as F, type GenerateStreamResult as G, HttpClient as H, type InvokeRequest as I, OllamaGenericClientError as J, OllamaIncompatibleModelError as K, type Logger as L, type Middleware as M, NANOS_PER_MS as N, OllamaRuntime as O, type ProgressStreamResult as P, OllamaMcpError as Q, type RequestLifecycleHook as R, type SchemaRef as S, type TokenUsage as T, OllamaModelRoutingError as U, OllamaNetworkError as V, OllamaNotFoundError as W, OllamaQuotaExceededError as X, OllamaRateLimitError as Y, OllamaRequestTooLargeError as Z, OllamaRequestValidationError as _, type OperationDefinition as a, OllamaServerError as a0, OllamaServerVersionUnknownError as a1, OllamaSkillInvalidError as a2, OllamaSkillNotFoundError as a3, OllamaTimeoutError as a4, OllamaToolTimeoutError as a5, OllamaToolValidationError as a6, OllamaUnsupportedCapabilityError as a7, type RequestContext as a8, type RequestLifecycleEvent as a9, type ResponseContext as aa, type SseEvent as ab, type ThinkingEvent as ac, type TokenEvent as ad, type ToolCallEvent as ae, composeMiddleware as af, createConsoleLogger as ag, extractUsage as ah, mapError as ai, parseSseStream as aj, type OllamaRuntimeOptions as b, type OllamaStreamEvent as c, type OllamaStreamEventType as d, type RawUsageSource as e, type HttpBody as f, type HttpClientOptions as g, type HttpRequestOptions as h, type LifecycleErrorEvent as i, type LifecycleRetryEvent as j, type LifecycleStartEvent as k, type LifecycleSuccessEvent as l, type LogFn as m, type MessageEvent as n, type MiddlewareContext as o, NANOS_PER_SECOND as p, NOOP_LOGGER as q, type NextFunction as r, OllamaAbortError as s, OllamaAgentMaxIterationsError as t, OllamaAgentMaxToolCallsError as u, OllamaAuthError as v, OllamaClientError as w, type OllamaClientErrorOptions as x, type OllamaErrorRequestContext as y, type OllamaErrorResponseContext as z };
@@ -195,6 +195,61 @@ declare class OllamaRequestValidationError extends OllamaClientError {
195
195
  issues: readonly z.ZodIssue[];
196
196
  });
197
197
  }
198
+ /**
199
+ * Thrown by `OllamaRuntime.invoke` BEFORE any HTTP request is made when the
200
+ * serialized request body exceeds the operation's declared
201
+ * `constraints.maxRequestBytes`. The Ollama server returns 413 for such
202
+ * payloads; this client-side check fails fast so the round-trip is avoided.
203
+ *
204
+ * Wave 12 (P0 #5): the IR has carried `maxRequestBytes` for System One
205
+ * (64 KiB) since v1.7.0, but the runtime never enforced it. This closes
206
+ * that contract/runtime gap.
207
+ */
208
+ declare class OllamaRequestTooLargeError extends OllamaClientError {
209
+ readonly operationId: string;
210
+ readonly actualBytes: number;
211
+ readonly maxBytes: number;
212
+ constructor(message: string, options: Omit<OllamaClientErrorOptions, 'code' | 'retryable' | 'status'> & {
213
+ operationId: string;
214
+ actualBytes: number;
215
+ maxBytes: number;
216
+ });
217
+ }
218
+ /**
219
+ * Thrown by `OllamaRuntime.invoke` AFTER the HTTP response is received
220
+ * when `validateResponses: true` is set and the response body fails Zod
221
+ * validation against the operation's registered response schema.
222
+ *
223
+ * Wave 13: the runtime previously never validated responses (see ADR
224
+ * 0020). This opt-in error gives callers a way to detect wire-format
225
+ * mismatches for operations where typed response semantics are critical
226
+ * (e.g. System One). The error carries the original Zod issues so
227
+ * callers can inspect which fields failed.
228
+ */
229
+ declare class OllamaResponseValidationError extends OllamaClientError {
230
+ readonly operationId: string;
231
+ readonly issues: readonly z.ZodIssue[];
232
+ constructor(message: string, options: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> & {
233
+ operationId: string;
234
+ issues: readonly z.ZodIssue[];
235
+ });
236
+ }
237
+ /**
238
+ * Thrown by `OllamaRuntime.invoke` BEFORE any HTTP request is made when the
239
+ * operation declares `constraints.minOllamaVersion` and the runtime could
240
+ * not obtain a server version to compare against (e.g. `enforceVersion:
241
+ * 'strict'` was set and `/api/version` was unreachable). Distinct from
242
+ * {@link OllamaGenericClientError} so callers can branch on the failure
243
+ * mode rather than parsing the message.
244
+ */
245
+ declare class OllamaServerVersionUnknownError extends OllamaClientError {
246
+ readonly operationId: string;
247
+ readonly minRequiredVersion: string;
248
+ constructor(message: string, options: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> & {
249
+ operationId: string;
250
+ minRequiredVersion: string;
251
+ });
252
+ }
198
253
  declare class OllamaToolTimeoutError extends OllamaClientError {
199
254
  readonly toolName: string;
200
255
  readonly timeoutMs: number;
@@ -494,6 +549,21 @@ type CapabilitySupport = 'supported' | 'unsupported' | 'model-dependent' | 'vers
494
549
  interface SchemaRef {
495
550
  readonly $ref: string;
496
551
  }
552
+ /**
553
+ * Wave 15 (P0): structural parameter on an operation. Mirrors
554
+ * {@link OperationParameter} from the canonical IR. Path parameters
555
+ * are substituted into the operation's path template at runtime;
556
+ * query and header parameters are attached to the HTTP request.
557
+ */
558
+ interface OperationParameter {
559
+ readonly name: string;
560
+ readonly in: 'path' | 'query' | 'header';
561
+ readonly required: boolean;
562
+ readonly schema?: {
563
+ readonly type?: string;
564
+ };
565
+ readonly description?: string;
566
+ }
497
567
  /** Behavioral contract a generated operation carries into the runtime. */
498
568
  interface OperationDefinition {
499
569
  readonly operationId: string;
@@ -505,6 +575,25 @@ interface OperationDefinition {
505
575
  readonly local: boolean;
506
576
  readonly cloud: boolean;
507
577
  };
578
+ /**
579
+ * Wave 12 (P1 #7): host this operation targets, when different from
580
+ * the runtime's default HttpClient base URL. Cloud-hosted capability
581
+ * endpoints (web search, web fetch) live at `https://ollama.com/api/...`
582
+ * rather than the local Ollama server. The runtime rejects operations
583
+ * with a non-default host when the runtime's HttpClient isn't
584
+ * configured for that host — callers must use OllamaClient.webSearch /
585
+ * OllamaClient.webFetch (which spin up a dedicated cloud HttpClient)
586
+ * for these operations.
587
+ */
588
+ readonly host?: string;
589
+ /**
590
+ * Wave 15 (P0): structural parameters derived from the path template
591
+ * and OpenAPI declarations. Path parameters are substituted into the
592
+ * URL at runtime; query and header parameters are attached to the
593
+ * HTTP request. The runtime uses this to URI-encode and substitute
594
+ * `{name}` segments in the path.
595
+ */
596
+ readonly parameters?: readonly OperationParameter[];
508
597
  readonly transport: {
509
598
  readonly mode: TransportMode;
510
599
  readonly streaming: boolean;
@@ -521,6 +610,8 @@ interface OperationDefinition {
521
610
  readonly constraints?: {
522
611
  readonly minOllamaVersion?: string;
523
612
  readonly maxRequestBytes?: number;
613
+ /** Wave 13: limit when body contains images (e.g. System One: 32 MiB). */
614
+ readonly maxRequestBytesWithImages?: number;
524
615
  };
525
616
  readonly status: {
526
617
  readonly documented: boolean;
@@ -544,6 +635,28 @@ interface InvokeRequest {
544
635
  * doesn't explicitly set `stream`.
545
636
  */
546
637
  readonly streamingDefault?: boolean;
638
+ /**
639
+ * Wave 15 (P0): path parameter values keyed by parameter name. The
640
+ * runtime substitutes these into the operation's path template
641
+ * (e.g. `{model}` → `gpt-4`) with URI encoding.
642
+ */
643
+ readonly pathParams?: Readonly<Record<string, string>>;
644
+ /**
645
+ * Wave 15 (P0): query parameter values keyed by parameter name.
646
+ * The runtime attaches these to the HTTP request URL.
647
+ */
648
+ readonly queryParams?: Readonly<Record<string, string>>;
649
+ /**
650
+ * Wave 15 (P0): header parameter values keyed by header name.
651
+ * The runtime attaches these to the HTTP request headers.
652
+ */
653
+ readonly headerParams?: Readonly<Record<string, string>>;
654
+ /**
655
+ * Wave 15 (P1): model name for routing. Extracted from the request
656
+ * body when possible; used by the failover layer to filter endpoints
657
+ * by `OllamaEndpoint.models` (credential-scoped routing).
658
+ */
659
+ readonly model?: string;
547
660
  }
548
661
 
549
662
  /**
@@ -570,9 +683,30 @@ interface InvokeRequest {
570
683
  * existing HttpClient.
571
684
  */
572
685
 
686
+ /**
687
+ * Minimal HTTP client surface the runtime consumes. Either a full
688
+ * {@link HttpClient} or a {@link FailoverHttpClient} — the runtime only
689
+ * calls `request()`.
690
+ *
691
+ * Wave 14: widened from `HttpClient` to allow the failover-aware wrapper
692
+ * without breaking existing callers that pass a plain HttpClient.
693
+ */
694
+ type RuntimeHttpBackend = Pick<HttpClient, 'baseUrl' | 'request'>;
573
695
  /** Constructor options for {@link OllamaRuntime}. */
574
696
  interface OllamaRuntimeOptions {
575
- readonly http: HttpClient;
697
+ readonly http: RuntimeHttpBackend;
698
+ /**
699
+ * Wave 15 (P0): HTTP backend for operations that declare a non-default
700
+ * `host` (e.g. web search/fetch at `https://ollama.com`). When an
701
+ * operation has `host: 'https://ollama.com'` and `cloudHttp` is
702
+ * configured, the runtime routes the request through this backend
703
+ * instead of the default `http`. When `cloudHttp` is not configured
704
+ * and a host-bearing operation is invoked, the runtime throws.
705
+ *
706
+ * OllamaClient.runtime sets this to a dedicated cloud HttpClient
707
+ * pointed at `https://ollama.com` with the configured API key.
708
+ */
709
+ readonly cloudHttp?: RuntimeHttpBackend;
576
710
  /**
577
711
  * Whether this runtime is targeting a local Ollama instance. Defaults to
578
712
  * `true`. When `false`, operations marked `environment.cloud === false`
@@ -583,6 +717,10 @@ interface OllamaRuntimeOptions {
583
717
  * Server version, if known (typically from a prior `/api/version` call).
584
718
  * When set, operations with `constraints.minOllamaVersion` are checked
585
719
  * against this value at request time.
720
+ *
721
+ * Wave 12 (P0 #5): when unset, the runtime will lazily fetch and cache
722
+ * the server version the first time a version-gated operation is
723
+ * invoked. The fetch policy is controlled by {@link enforceVersion}.
586
724
  */
587
725
  readonly serverVersion?: string;
588
726
  /**
@@ -601,15 +739,75 @@ interface OllamaRuntimeOptions {
601
739
  * `/v1/systemone`, OpenAI/Anthropic compat surfaces), validation is
602
740
  * skipped silently.
603
741
  *
604
- * Response validation is intentionally NOT enabled — see ADR 0020 for
605
- * the rationale (forward-compat with wire-format extensions).
742
+ * Response validation is intentionally NOT enabled by default — see
743
+ * ADR 0020 for the rationale (forward-compat with wire-format
744
+ * extensions).
745
+ *
746
+ * Wave 13: an opt-in `validateResponses` option is now available for
747
+ * operations where typed response semantics are the entire point
748
+ * (e.g. System One). When enabled, the runtime validates the HTTP
749
+ * response body against the operation's registered response schema
750
+ * before returning it to the caller. On failure, throws
751
+ * {@link OllamaResponseValidationError}.
606
752
  */
607
753
  readonly validateRequests?: boolean;
754
+ /**
755
+ * Wave 13: when `true`, the runtime validates every response body
756
+ * against the operation's registered response schema before returning
757
+ * it. Defaults to `false` — opt-in. Only operations with a registered
758
+ * response schema are validated; others pass through unchanged.
759
+ *
760
+ * On validation failure, throws {@link OllamaResponseValidationError}
761
+ * with the Zod issues attached. The HTTP response is still consumed.
762
+ *
763
+ * Use this for operations where typed response semantics are critical
764
+ * (System One, structured output). Don't enable globally — legitimate
765
+ * forward-compat wire-format extensions would cause false rejections.
766
+ */
767
+ readonly validateResponses?: boolean;
768
+ /**
769
+ * Policy for enforcing `constraints.minOllamaVersion` when
770
+ * {@link serverVersion} is not explicitly supplied.
771
+ *
772
+ * - `'auto'` (default): lazily fetch `/api/version` once and cache the
773
+ * result; subsequent version-gated invocations reuse the cached
774
+ * value. If the fetch fails, the operation is allowed through
775
+ * (fail-open) — the server will reject it if it truly doesn't
776
+ * support it.
777
+ * - `'strict'`: same as `'auto'`, but if the version fetch fails the
778
+ * invocation throws {@link OllamaServerVersionUnknownError} rather
779
+ * than fail-open. Use this when the caller wants hard guarantees
780
+ * that a version-gated operation will not be sent to a server that
781
+ * can't handle it.
782
+ * - `'off'`: never fetch `/api/version` automatically. The runtime
783
+ * only enforces the version constraint when {@link serverVersion}
784
+ * was explicitly supplied. Useful in tests that mock fetch and want
785
+ * to avoid spurious version probes.
786
+ */
787
+ readonly enforceVersion?: 'auto' | 'strict' | 'off';
608
788
  }
609
789
  /** The runtime seam. */
610
790
  declare class OllamaRuntime {
611
791
  private readonly options;
792
+ /**
793
+ * Cached promise of the Ollama server version, populated lazily the first
794
+ * time a version-gated operation is invoked. `undefined` until then.
795
+ *
796
+ * Wave 12 (P0 #5): see {@link OllamaRuntimeOptions.enforceVersion}.
797
+ */
798
+ private serverVersionCache;
612
799
  constructor(options: OllamaRuntimeOptions);
800
+ /**
801
+ * Wave 15 (P0): resolve the HTTP backend for a given operation.
802
+ *
803
+ * Operations with a declared `host` (e.g. web search/fetch at
804
+ * https://ollama.com) must route to a HttpClient pointed at that host,
805
+ * not the default one. The runtime accepts an optional `cloudHttp`
806
+ * backend for this purpose — if the operation declares a host and no
807
+ * cloud backend is configured, the runtime throws rather than silently
808
+ * sending the request to the wrong server.
809
+ */
810
+ private resolveHttpBackend;
613
811
  /**
614
812
  * Invoke an operation. Called by every generated API method.
615
813
  *
@@ -618,6 +816,22 @@ declare class OllamaRuntime {
618
816
  * class's overloads pick the right return type at compile time.
619
817
  */
620
818
  invoke<T = unknown>(req: InvokeRequest): Promise<T>;
819
+ /**
820
+ * Apply environment + version guards before delegating to HttpClient.
821
+ *
822
+ * Throws {@link OllamaGenericClientError} when:
823
+ * - The operation is local-only and the runtime is in cloud mode.
824
+ * - The operation has `constraints.minOllamaVersion` and the server is older.
825
+ *
826
+ * Wave 12 (P0 #5): when `minOllamaVersion` is declared but the runtime's
827
+ * `serverVersion` is unknown AND `enforceVersion` is `'auto'` or
828
+ * `'strict'`, the runtime lazily fetches `/api/version` (cached on the
829
+ * runtime instance) so the constraint is actually enforced even when the
830
+ * caller didn't supply it. Previously the constraint was only enforced
831
+ * when `serverVersion` was manually supplied — meaning in practice it was
832
+ * almost never enforced.
833
+ */
834
+ private assertOperationAllowed;
621
835
  }
622
836
 
623
- export { OllamaServerError as $, type AbortableAsyncIterable as A, type BinaryBody as B, type ChatStreamResult as C, type DoneEvent as D, type ErrorEvent as E, type FetchLike as F, type GenerateStreamResult as G, HttpClient as H, type InvokeRequest as I, type OllamaErrorResponseContext as J, OllamaGenericClientError as K, type Logger as L, type Middleware as M, NANOS_PER_MS as N, OllamaRuntime as O, type ProgressStreamResult as P, OllamaIncompatibleModelError as Q, type RequestLifecycleHook as R, type SchemaRef as S, type TokenUsage as T, OllamaMcpError as U, OllamaModelRoutingError as V, OllamaNetworkError as W, OllamaNotFoundError as X, OllamaQuotaExceededError as Y, OllamaRateLimitError as Z, OllamaRequestValidationError as _, type OperationDefinition as a, OllamaSkillInvalidError as a0, OllamaSkillNotFoundError as a1, OllamaTimeoutError as a2, OllamaToolTimeoutError as a3, OllamaToolValidationError as a4, OllamaUnsupportedCapabilityError as a5, type RequestContext as a6, type RequestLifecycleEvent as a7, type ResponseContext as a8, type ThinkingEvent as a9, type TokenEvent as aa, type ToolCallEvent as ab, composeMiddleware as ac, createConsoleLogger as ad, extractUsage as ae, mapError as af, parseSseStream as ag, type OllamaRuntimeOptions as b, type OllamaStreamEvent as c, type OllamaStreamEventType as d, type SseEvent as e, OllamaClientError as f, type RawUsageSource as g, type HttpBody as h, type HttpClientOptions as i, type HttpRequestOptions as j, type LifecycleErrorEvent as k, type LifecycleRetryEvent as l, type LifecycleStartEvent as m, type LifecycleSuccessEvent as n, type LogFn as o, type MessageEvent as p, type MiddlewareContext as q, NANOS_PER_SECOND as r, NOOP_LOGGER as s, type NextFunction as t, OllamaAbortError as u, OllamaAgentMaxIterationsError as v, OllamaAgentMaxToolCallsError as w, OllamaAuthError as x, type OllamaClientErrorOptions as y, type OllamaErrorRequestContext as z };
837
+ export { OllamaResponseValidationError as $, type AbortableAsyncIterable as A, type BinaryBody as B, type ChatStreamResult as C, type DoneEvent as D, type ErrorEvent as E, type FetchLike as F, type GenerateStreamResult as G, HttpClient as H, type InvokeRequest as I, OllamaGenericClientError as J, OllamaIncompatibleModelError as K, type Logger as L, type Middleware as M, NANOS_PER_MS as N, OllamaRuntime as O, type ProgressStreamResult as P, OllamaMcpError as Q, type RequestLifecycleHook as R, type SchemaRef as S, type TokenUsage as T, OllamaModelRoutingError as U, OllamaNetworkError as V, OllamaNotFoundError as W, OllamaQuotaExceededError as X, OllamaRateLimitError as Y, OllamaRequestTooLargeError as Z, OllamaRequestValidationError as _, type OperationDefinition as a, OllamaServerError as a0, OllamaServerVersionUnknownError as a1, OllamaSkillInvalidError as a2, OllamaSkillNotFoundError as a3, OllamaTimeoutError as a4, OllamaToolTimeoutError as a5, OllamaToolValidationError as a6, OllamaUnsupportedCapabilityError as a7, type RequestContext as a8, type RequestLifecycleEvent as a9, type ResponseContext as aa, type SseEvent as ab, type ThinkingEvent as ac, type TokenEvent as ad, type ToolCallEvent as ae, composeMiddleware as af, createConsoleLogger as ag, extractUsage as ah, mapError as ai, parseSseStream as aj, type OllamaRuntimeOptions as b, type OllamaStreamEvent as c, type OllamaStreamEventType as d, type RawUsageSource as e, type HttpBody as f, type HttpClientOptions as g, type HttpRequestOptions as h, type LifecycleErrorEvent as i, type LifecycleRetryEvent as j, type LifecycleStartEvent as k, type LifecycleSuccessEvent as l, type LogFn as m, type MessageEvent as n, type MiddlewareContext as o, NANOS_PER_SECOND as p, NOOP_LOGGER as q, type NextFunction as r, OllamaAbortError as s, OllamaAgentMaxIterationsError as t, OllamaAgentMaxToolCallsError as u, OllamaAuthError as v, OllamaClientError as w, type OllamaClientErrorOptions as x, type OllamaErrorRequestContext as y, type OllamaErrorResponseContext as z };