@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.js CHANGED
@@ -182,6 +182,35 @@ var OllamaRequestValidationError = class extends OllamaClientError {
182
182
  this.issues = options.issues;
183
183
  }
184
184
  };
185
+ var OllamaRequestTooLargeError = class extends OllamaClientError {
186
+ operationId;
187
+ actualBytes;
188
+ maxBytes;
189
+ constructor(message, options) {
190
+ super(message, { ...options, code: "request_too_large", retryable: false, status: 413 });
191
+ this.operationId = options.operationId;
192
+ this.actualBytes = options.actualBytes;
193
+ this.maxBytes = options.maxBytes;
194
+ }
195
+ };
196
+ var OllamaResponseValidationError = class extends OllamaClientError {
197
+ operationId;
198
+ issues;
199
+ constructor(message, options) {
200
+ super(message, { ...options, code: "response_validation_error", retryable: false });
201
+ this.operationId = options.operationId;
202
+ this.issues = options.issues;
203
+ }
204
+ };
205
+ var OllamaServerVersionUnknownError = class extends OllamaClientError {
206
+ operationId;
207
+ minRequiredVersion;
208
+ constructor(message, options) {
209
+ super(message, { ...options, code: "server_version_unknown", retryable: false });
210
+ this.operationId = options.operationId;
211
+ this.minRequiredVersion = options.minRequiredVersion;
212
+ }
213
+ };
185
214
  var OllamaToolTimeoutError = class extends OllamaClientError {
186
215
  toolName;
187
216
  timeoutMs;
@@ -237,10 +266,12 @@ var OllamaAgentMaxIterationsError = class extends OllamaClientError {
237
266
  var OllamaMcpError = class extends OllamaClientError {
238
267
  mcpMethod;
239
268
  toolName;
269
+ issues;
240
270
  constructor(message, options) {
241
271
  super(message, { ...options, code: "mcp_error", retryable: options.retryable ?? false });
242
272
  this.mcpMethod = options.mcpMethod;
243
273
  this.toolName = options.toolName;
274
+ this.issues = options.issues;
244
275
  }
245
276
  };
246
277
  var OllamaSkillNotFoundError = class extends OllamaClientError {
@@ -1883,8 +1914,9 @@ var ModelsClient = class {
1883
1914
  { singleEndpoint: true }
1884
1915
  );
1885
1916
  return true;
1886
- } catch {
1887
- return false;
1917
+ } catch (err) {
1918
+ if (err instanceof OllamaNotFoundError) return false;
1919
+ throw err;
1888
1920
  }
1889
1921
  }
1890
1922
  };
@@ -2794,28 +2826,45 @@ var ChatRequestSchema = z.object({
2794
2826
  logprobs: z.boolean().optional(),
2795
2827
  top_logprobs: z.number().optional()
2796
2828
  });
2797
- var GenerateRequestSchema = z.object({
2798
- model: z.string(),
2799
- prompt: z.string().optional(),
2800
- suffix: z.string().optional(),
2801
- images: z.array(z.string()).optional(),
2802
- format: z.union([z.string(), z.object({})]).optional(),
2803
- system: z.string().optional(),
2804
- stream: z.boolean().optional(),
2805
- think: ThinkValueSchema.optional(),
2806
- raw: z.boolean().optional(),
2807
- keep_alive: z.union([z.string(), z.number()]).optional(),
2808
- options: ModelOptionsSchema.optional(),
2809
- logprobs: z.boolean().optional(),
2810
- top_logprobs: z.number().optional()
2829
+ var TokenLogprobSchema = z.object({
2830
+ token: z.string().optional(),
2831
+ logprob: z.number().optional(),
2832
+ bytes: z.array(z.number()).optional()
2811
2833
  });
2812
- var EmbedRequestSchema = z.object({
2813
- model: z.string(),
2814
- input: z.union([z.string(), z.array(z.string())]),
2815
- truncate: z.boolean().optional(),
2816
- dimensions: z.number().optional(),
2817
- keep_alive: z.string().optional(),
2818
- options: ModelOptionsSchema.optional()
2834
+
2835
+ // src/generated/models/Logprob.schema.ts
2836
+ var LogprobSchema = z.object({
2837
+ token: z.string().optional(),
2838
+ logprob: z.number().optional(),
2839
+ bytes: z.array(z.number()).optional(),
2840
+ top_logprobs: z.array(TokenLogprobSchema).optional()
2841
+ });
2842
+
2843
+ // src/generated/models/ChatResponse.schema.ts
2844
+ var ChatResponseSchema = z.object({
2845
+ model: z.string().optional(),
2846
+ created_at: z.string().optional(),
2847
+ message: z.object({
2848
+ role: z.enum(["assistant"]).optional(),
2849
+ content: z.string().optional(),
2850
+ thinking: z.string().optional(),
2851
+ tool_calls: z.array(ToolCallSchema).optional(),
2852
+ images: z.array(z.string()).optional()
2853
+ }).optional(),
2854
+ done: z.boolean().optional(),
2855
+ done_reason: z.string().optional(),
2856
+ total_duration: z.number().optional(),
2857
+ load_duration: z.number().optional(),
2858
+ prompt_eval_count: z.number().optional(),
2859
+ prompt_eval_cached_count: z.number().optional(),
2860
+ prompt_eval_duration: z.number().optional(),
2861
+ eval_count: z.number().optional(),
2862
+ eval_duration: z.number().optional(),
2863
+ logprobs: z.array(LogprobSchema).optional()
2864
+ });
2865
+ var CopyRequestSchema = z.object({
2866
+ source: z.string(),
2867
+ destination: z.string()
2819
2868
  });
2820
2869
  var CreateRequestSchema = z.object({
2821
2870
  model: z.string(),
@@ -2834,13 +2883,91 @@ var CreateRequestSchema = z.object({
2834
2883
  requires: z.string().optional(),
2835
2884
  stream: z.boolean().optional()
2836
2885
  });
2837
- var CopyRequestSchema = z.object({
2838
- source: z.string(),
2839
- destination: z.string()
2840
- });
2841
2886
  var DeleteRequestSchema = z.object({
2842
2887
  model: z.string()
2843
2888
  });
2889
+ var EmbedRequestSchema = z.object({
2890
+ model: z.string(),
2891
+ input: z.union([z.string(), z.array(z.string())]),
2892
+ truncate: z.boolean().optional(),
2893
+ dimensions: z.number().optional(),
2894
+ keep_alive: z.string().optional(),
2895
+ options: ModelOptionsSchema.optional()
2896
+ });
2897
+ var EmbedResponseSchema = z.object({
2898
+ model: z.string().optional(),
2899
+ embeddings: z.array(z.array(z.number())).optional(),
2900
+ total_duration: z.number().optional(),
2901
+ load_duration: z.number().optional(),
2902
+ prompt_eval_count: z.number().optional()
2903
+ });
2904
+ var GenerateRequestSchema = z.object({
2905
+ model: z.string(),
2906
+ prompt: z.string().optional(),
2907
+ suffix: z.string().optional(),
2908
+ images: z.array(z.string()).optional(),
2909
+ format: z.union([z.string(), z.object({})]).optional(),
2910
+ system: z.string().optional(),
2911
+ stream: z.boolean().optional(),
2912
+ think: ThinkValueSchema.optional(),
2913
+ raw: z.boolean().optional(),
2914
+ keep_alive: z.union([z.string(), z.number()]).optional(),
2915
+ options: ModelOptionsSchema.optional(),
2916
+ logprobs: z.boolean().optional(),
2917
+ top_logprobs: z.number().optional()
2918
+ });
2919
+ var GenerateResponseSchema = z.object({
2920
+ model: z.string().optional(),
2921
+ created_at: z.string().optional(),
2922
+ response: z.string().optional(),
2923
+ thinking: z.string().optional(),
2924
+ done: z.boolean().optional(),
2925
+ done_reason: z.string().optional(),
2926
+ total_duration: z.number().optional(),
2927
+ load_duration: z.number().optional(),
2928
+ prompt_eval_count: z.number().optional(),
2929
+ prompt_eval_cached_count: z.number().optional(),
2930
+ prompt_eval_duration: z.number().optional(),
2931
+ eval_count: z.number().optional(),
2932
+ eval_duration: z.number().optional(),
2933
+ logprobs: z.array(LogprobSchema).optional()
2934
+ });
2935
+ var ModelSummarySchema = z.object({
2936
+ name: z.string().optional(),
2937
+ model: z.string().optional(),
2938
+ remote_model: z.string().optional(),
2939
+ remote_host: z.string().optional(),
2940
+ modified_at: z.string().optional(),
2941
+ size: z.number().optional(),
2942
+ digest: z.string().optional(),
2943
+ details: z.object({
2944
+ format: z.string().optional(),
2945
+ family: z.string().optional(),
2946
+ families: z.array(z.string()).optional(),
2947
+ parameter_size: z.string().optional(),
2948
+ quantization_level: z.string().optional()
2949
+ }).optional()
2950
+ });
2951
+
2952
+ // src/generated/models/ListResponse.schema.ts
2953
+ var ListResponseSchema = z.object({
2954
+ models: z.array(ModelSummarySchema).optional()
2955
+ });
2956
+ var PsSchema = z.object({
2957
+ name: z.string().optional(),
2958
+ model: z.string().optional(),
2959
+ size: z.number().optional(),
2960
+ digest: z.string().optional(),
2961
+ details: z.object({}).optional(),
2962
+ expires_at: z.string().optional(),
2963
+ size_vram: z.number().optional(),
2964
+ context_length: z.number().optional()
2965
+ });
2966
+
2967
+ // src/generated/models/PsResponse.schema.ts
2968
+ var PsResponseSchema = z.object({
2969
+ models: z.array(PsSchema).optional()
2970
+ });
2844
2971
  var PullRequestSchema = z.object({
2845
2972
  model: z.string(),
2846
2973
  insecure: z.boolean().optional(),
@@ -2855,27 +2982,164 @@ var ShowRequestSchema = z.object({
2855
2982
  model: z.string(),
2856
2983
  verbose: z.boolean().optional()
2857
2984
  });
2985
+ var ThinkingSchema = z.object({
2986
+ values: z.array(z.union([z.boolean(), z.string()])),
2987
+ default: z.union([z.boolean(), z.string()])
2988
+ });
2989
+
2990
+ // src/generated/models/ShowResponse.schema.ts
2991
+ var ShowResponseSchema = z.object({
2992
+ thinking: ThinkingSchema.optional(),
2993
+ parameters: z.string().optional(),
2994
+ license: z.string().optional(),
2995
+ modified_at: z.string().optional(),
2996
+ details: z.object({}).optional(),
2997
+ template: z.string().optional(),
2998
+ capabilities: z.array(z.string()).optional(),
2999
+ model_info: z.object({}).optional()
3000
+ });
3001
+ var StatusResponseSchema = z.object({
3002
+ status: z.string().optional()
3003
+ });
3004
+ var SystemOneContentSchema = z.union([
3005
+ z.string().regex(new RegExp("\\S")),
3006
+ z.object({}).catchall(z.unknown()),
3007
+ z.array(z.unknown())
3008
+ ]);
3009
+
3010
+ // src/generated/models/SystemOneChoiceQuestion.schema.ts
3011
+ var SystemOneChoiceQuestionSchema = z.object({
3012
+ type: z.enum(["choice"]),
3013
+ instructions: SystemOneContentSchema,
3014
+ criteria: z.object({}).catchall(z.union([z.string(), z.null()])).refine((v) => Object.keys(v).length >= 2, { message: "must have at least 2 properties" }).refine((v) => Object.keys(v).length <= 26, { message: "must have at most 26 properties" }).refine((v) => Object.keys(v).every((k) => new RegExp("\\S").test(k)), {
3015
+ message: 'property names must match pattern "\\S"'
3016
+ })
3017
+ });
3018
+ var SystemOneNoulQuestionSchema = z.object({
3019
+ type: z.enum(["noul"]),
3020
+ instructions: SystemOneContentSchema,
3021
+ criteria: z.object({
3022
+ false: z.string().optional(),
3023
+ true: z.string().optional()
3024
+ }).optional()
3025
+ });
3026
+ var SystemOneScoreQuestionSchema = z.object({
3027
+ type: z.enum(["score"]),
3028
+ instructions: SystemOneContentSchema,
3029
+ criteria: z.array(z.string()).min(2).max(26)
3030
+ });
3031
+
3032
+ // src/generated/models/SystemOneRequest.schema.ts
3033
+ var SystemOneRequestSchema = z.object({
3034
+ model: z.string().regex(new RegExp("\\S")),
3035
+ state: SystemOneContentSchema,
3036
+ images: z.array(z.string()).optional(),
3037
+ questions: z.object({}).catchall(
3038
+ z.union([
3039
+ SystemOneChoiceQuestionSchema,
3040
+ SystemOneNoulQuestionSchema,
3041
+ SystemOneScoreQuestionSchema
3042
+ ])
3043
+ ).refine((v) => Object.keys(v).length >= 1, { message: "must have at least 1 properties" }).refine((v) => Object.keys(v).length <= 64, { message: "must have at most 64 properties" }).refine((v) => Object.keys(v).every((k) => new RegExp("\\S").test(k)), {
3044
+ message: 'property names must match pattern "\\S"'
3045
+ }),
3046
+ keep_alive: z.union([z.string(), z.number()]).optional()
3047
+ });
3048
+ var SystemOneConfidenceSchema = z.number().min(0).max(1);
3049
+ var SystemOneProbabilitiesSchema = z.object({}).catchall(z.number().min(0).max(1));
3050
+
3051
+ // src/generated/models/SystemOneChoiceAnswer.schema.ts
3052
+ var SystemOneChoiceAnswerSchema = z.object({
3053
+ type: z.enum(["choice"]),
3054
+ choice: z.string(),
3055
+ probabilities: SystemOneProbabilitiesSchema,
3056
+ confidence: SystemOneConfidenceSchema
3057
+ });
3058
+ var SystemOneNoulAnswerSchema = z.object({
3059
+ type: z.enum(["noul"]),
3060
+ noul: z.number().min(0).max(1)
3061
+ });
3062
+ var SystemOneScoreAnswerSchema = z.object({
3063
+ type: z.enum(["score"]),
3064
+ score: z.number().min(0).max(25),
3065
+ legend: z.object({}).catchall(z.string()),
3066
+ probabilities: SystemOneProbabilitiesSchema,
3067
+ confidence: SystemOneConfidenceSchema
3068
+ });
3069
+
3070
+ // src/generated/models/SystemOneResponse.schema.ts
3071
+ var SystemOneResponseSchema = z.object({
3072
+ model: z.string(),
3073
+ answers: z.object({}).catchall(
3074
+ z.union([SystemOneChoiceAnswerSchema, SystemOneNoulAnswerSchema, SystemOneScoreAnswerSchema])
3075
+ ),
3076
+ usage: z.object({
3077
+ input_tokens: z.number().min(0),
3078
+ output_tokens: z.number().min(0)
3079
+ })
3080
+ });
3081
+ var VersionResponseSchema = z.object({
3082
+ version: z.string().optional()
3083
+ });
3084
+ var WebFetchRequestSchema = z.object({
3085
+ url: z.string()
3086
+ });
3087
+ var WebFetchResponseSchema = z.object({
3088
+ title: z.string().optional(),
3089
+ content: z.string().optional(),
3090
+ links: z.array(z.string()).optional()
3091
+ });
3092
+ var WebSearchRequestSchema = z.object({
3093
+ query: z.string(),
3094
+ max_results: z.number().min(1).max(10).optional()
3095
+ });
3096
+ var WebSearchResultSchema = z.object({
3097
+ title: z.string().optional(),
3098
+ url: z.string().optional(),
3099
+ content: z.string().optional()
3100
+ });
3101
+
3102
+ // src/generated/models/WebSearchResponse.schema.ts
3103
+ var WebSearchResponseSchema = z.object({
3104
+ results: z.array(WebSearchResultSchema).optional()
3105
+ });
2858
3106
 
2859
3107
  // src/generated/runtime/schema-registry.ts
2860
3108
  var requestSchemas = {
2861
3109
  chat: ChatRequestSchema,
2862
- generate: GenerateRequestSchema,
2863
- embed: EmbedRequestSchema,
2864
- create: CreateRequestSchema,
2865
3110
  copy: CopyRequestSchema,
3111
+ create: CreateRequestSchema,
2866
3112
  delete: DeleteRequestSchema,
3113
+ embed: EmbedRequestSchema,
3114
+ generate: GenerateRequestSchema,
2867
3115
  pull: PullRequestSchema,
2868
3116
  push: PushRequestSchema,
2869
- show: ShowRequestSchema
2870
- // Operations without a registered request schema (blobs, ps, tags,
2871
- // version, systemOne, openai*, anthropic*) skip validation. This is
2872
- // deliberate — the OpenAPI spec doesn't define request bodies for
2873
- // GET/HEAD operations, and the compat-surface request schemas (OpenAI,
2874
- // Anthropic) are richer than what the IR currently models.
3117
+ show: ShowRequestSchema,
3118
+ systemOne: SystemOneRequestSchema,
3119
+ webFetch: WebFetchRequestSchema,
3120
+ webSearch: WebSearchRequestSchema
3121
+ };
3122
+ var responseSchemas = {
3123
+ chat: ChatResponseSchema,
3124
+ create: StatusResponseSchema,
3125
+ embed: EmbedResponseSchema,
3126
+ generate: GenerateResponseSchema,
3127
+ ps: PsResponseSchema,
3128
+ pull: StatusResponseSchema,
3129
+ push: StatusResponseSchema,
3130
+ show: ShowResponseSchema,
3131
+ systemOne: SystemOneResponseSchema,
3132
+ tags: ListResponseSchema,
3133
+ version: VersionResponseSchema,
3134
+ webFetch: WebFetchResponseSchema,
3135
+ webSearch: WebSearchResponseSchema
2875
3136
  };
2876
3137
  function getRequestSchema(operationId) {
2877
3138
  return requestSchemas[operationId];
2878
3139
  }
3140
+ function getResponseSchema(operationId) {
3141
+ return responseSchemas[operationId];
3142
+ }
2879
3143
 
2880
3144
  // src/generated/runtime/runtime.ts
2881
3145
  function compareVersions(a, b) {
@@ -2888,18 +3152,13 @@ function compareVersions(a, b) {
2888
3152
  }
2889
3153
  return 0;
2890
3154
  }
2891
- function assertOperationAllowed(operation, options) {
2892
- const localMode = options.localMode ?? true;
2893
- if (!localMode && !operation.environment.cloud) {
2894
- throw new OllamaGenericClientError(
2895
- `Operation ${operation.operationId} (${operation.method} ${operation.path}) is local-only and not supported in cloud mode.`
2896
- );
2897
- }
2898
- if (operation.constraints?.minOllamaVersion && options.serverVersion && compareVersions(options.serverVersion, operation.constraints.minOllamaVersion) < 0) {
2899
- throw new OllamaGenericClientError(
2900
- `Operation ${operation.operationId} (${operation.method} ${operation.path}) requires Ollama >= ${operation.constraints.minOllamaVersion} (server reports ${options.serverVersion}).`
2901
- );
2902
- }
3155
+ async function fetchServerVersion(http) {
3156
+ const result = await http.request({
3157
+ path: "/api/version",
3158
+ method: "GET"
3159
+ });
3160
+ if (result && typeof result.version === "string") return result.version;
3161
+ return void 0;
2903
3162
  }
2904
3163
  function shouldStream(req) {
2905
3164
  if (req.body && typeof req.body === "object" && "stream" in req.body) {
@@ -2922,6 +3181,35 @@ var OllamaRuntime = class {
2922
3181
  this.options = options;
2923
3182
  }
2924
3183
  options;
3184
+ /**
3185
+ * Cached promise of the Ollama server version, populated lazily the first
3186
+ * time a version-gated operation is invoked. `undefined` until then.
3187
+ *
3188
+ * Wave 12 (P0 #5): see {@link OllamaRuntimeOptions.enforceVersion}.
3189
+ */
3190
+ serverVersionCache;
3191
+ /**
3192
+ * Wave 15 (P0): resolve the HTTP backend for a given operation.
3193
+ *
3194
+ * Operations with a declared `host` (e.g. web search/fetch at
3195
+ * https://ollama.com) must route to a HttpClient pointed at that host,
3196
+ * not the default one. The runtime accepts an optional `cloudHttp`
3197
+ * backend for this purpose — if the operation declares a host and no
3198
+ * cloud backend is configured, the runtime throws rather than silently
3199
+ * sending the request to the wrong server.
3200
+ */
3201
+ resolveHttpBackend(operation) {
3202
+ if (operation.host) {
3203
+ const cloudHttp = this.options.cloudHttp;
3204
+ if (!cloudHttp) {
3205
+ throw new OllamaGenericClientError(
3206
+ `Operation ${operation.operationId} (${operation.method} ${operation.path}) targets host "${operation.host}" but the runtime has no cloudHttp backend configured. Use OllamaClient.webSearch() / OllamaClient.webFetch() for cloud-hosted operations, or construct OllamaRuntime with a cloudHttp option.`
3207
+ );
3208
+ }
3209
+ return cloudHttp;
3210
+ }
3211
+ return this.options.http;
3212
+ }
2925
3213
  /**
2926
3214
  * Invoke an operation. Called by every generated API method.
2927
3215
  *
@@ -2930,7 +3218,7 @@ var OllamaRuntime = class {
2930
3218
  * class's overloads pick the right return type at compile time.
2931
3219
  */
2932
3220
  async invoke(req) {
2933
- assertOperationAllowed(req.operation, this.options);
3221
+ await this.assertOperationAllowed(req.operation);
2934
3222
  let body = buildBody(req);
2935
3223
  if (this.options.validateRequests === true && body !== void 0) {
2936
3224
  const schema = getRequestSchema(req.operation.operationId);
@@ -2949,32 +3237,668 @@ var OllamaRuntime = class {
2949
3237
  body = result.data;
2950
3238
  }
2951
3239
  }
3240
+ if (body !== void 0) {
3241
+ const serialized = serializeForByteCount(body);
3242
+ const hasImages = bodyHasImages(body);
3243
+ const maxBytesWithImages = req.operation.constraints?.maxRequestBytesWithImages;
3244
+ const maxBytesBase = req.operation.constraints?.maxRequestBytes;
3245
+ const applicableLimit = hasImages && maxBytesWithImages !== void 0 ? maxBytesWithImages : maxBytesBase;
3246
+ if (applicableLimit !== void 0 && serialized.byteLength > applicableLimit) {
3247
+ throw new OllamaRequestTooLargeError(
3248
+ `Operation ${req.operation.operationId} (${req.operation.method} ${req.operation.path}) request body is ${serialized.byteLength} bytes, exceeding the contract limit of ${applicableLimit} bytes` + (hasImages ? " (images limit)." : "."),
3249
+ {
3250
+ operationId: req.operation.operationId,
3251
+ actualBytes: serialized.byteLength,
3252
+ maxBytes: applicableLimit,
3253
+ request: { method: req.operation.method, url: req.operation.path }
3254
+ }
3255
+ );
3256
+ }
3257
+ }
2952
3258
  const streaming = shouldStream(req);
3259
+ const resolvedPath = resolvePathParams(req.operation.path, req.pathParams);
3260
+ const model = req.model ?? extractModelFromBody(body);
2953
3261
  const httpReq = {
2954
- path: req.operation.path,
3262
+ path: resolvedPath,
2955
3263
  method: req.operation.method,
2956
3264
  ...body !== void 0 ? { body } : {},
2957
3265
  ...req.signal !== void 0 ? { signal: req.signal } : {},
2958
- // For streaming calls, request the raw Response so we can pipe it
2959
- // through parseNdjsonStream directly. This inherits middleware,
2960
- // retry, telemetry, and error-mapping from HttpClient — the
2961
- // previous Wave 3 implementation bypassed them with a direct
2962
- // `fetch()` call.
2963
- ...streaming ? { raw: true } : {}
3266
+ ...streaming ? { raw: true } : {},
3267
+ ...model !== void 0 ? { model } : {}
2964
3268
  };
2965
3269
  if (!streaming) {
2966
- return await this.options.http.request(httpReq);
3270
+ const result = await this.resolveHttpBackend(req.operation).request(httpReq);
3271
+ if (this.options.validateResponses === true) {
3272
+ const responseSchema = getResponseSchema(req.operation.operationId);
3273
+ if (responseSchema) {
3274
+ const result2 = responseSchema.safeParse(result);
3275
+ if (!result2.success) {
3276
+ throw new OllamaResponseValidationError(
3277
+ `Response validation failed for operation "${req.operation.operationId}" (${req.operation.method} ${req.operation.path}): ` + result2.error.issues.map((i) => `${i.path.join(".") || "<root>"}: ${i.message}`).join("; "),
3278
+ {
3279
+ operationId: req.operation.operationId,
3280
+ issues: result2.error.issues,
3281
+ request: { method: req.operation.method, url: req.operation.path }
3282
+ }
3283
+ );
3284
+ }
3285
+ }
3286
+ }
3287
+ return result;
2967
3288
  }
2968
- const response = await this.options.http.request(httpReq);
3289
+ const response = await this.resolveHttpBackend(req.operation).request(httpReq);
2969
3290
  if (!response.body) {
2970
3291
  throw new OllamaGenericClientError(
2971
3292
  `Operation ${req.operation.operationId}: streaming response had no body.`
2972
3293
  );
2973
3294
  }
2974
- return parseNdjsonStream(response.body);
3295
+ return parseStreamByMode(req.operation.transport.mode, response.body);
3296
+ }
3297
+ /**
3298
+ * Apply environment + version guards before delegating to HttpClient.
3299
+ *
3300
+ * Throws {@link OllamaGenericClientError} when:
3301
+ * - The operation is local-only and the runtime is in cloud mode.
3302
+ * - The operation has `constraints.minOllamaVersion` and the server is older.
3303
+ *
3304
+ * Wave 12 (P0 #5): when `minOllamaVersion` is declared but the runtime's
3305
+ * `serverVersion` is unknown AND `enforceVersion` is `'auto'` or
3306
+ * `'strict'`, the runtime lazily fetches `/api/version` (cached on the
3307
+ * runtime instance) so the constraint is actually enforced even when the
3308
+ * caller didn't supply it. Previously the constraint was only enforced
3309
+ * when `serverVersion` was manually supplied — meaning in practice it was
3310
+ * almost never enforced.
3311
+ */
3312
+ async assertOperationAllowed(operation) {
3313
+ const localMode = this.options.localMode ?? true;
3314
+ if (!localMode && !operation.environment.cloud) {
3315
+ throw new OllamaGenericClientError(
3316
+ `Operation ${operation.operationId} (${operation.method} ${operation.path}) is local-only and not supported in cloud mode.`
3317
+ );
3318
+ }
3319
+ const minVersion = operation.constraints?.minOllamaVersion;
3320
+ if (!minVersion) return;
3321
+ let serverVersion = this.options.serverVersion;
3322
+ const policy = this.options.enforceVersion ?? "auto";
3323
+ if (!serverVersion && policy !== "off") {
3324
+ if (!this.serverVersionCache) {
3325
+ const p = fetchServerVersion(this.options.http).catch((err) => {
3326
+ if (policy === "strict") {
3327
+ throw new OllamaServerVersionUnknownError(
3328
+ `Operation ${operation.operationId} requires Ollama >= ${minVersion} but the runtime could not determine the server version (enforceVersion: 'strict').`,
3329
+ {
3330
+ operationId: operation.operationId,
3331
+ minRequiredVersion: minVersion,
3332
+ cause: err
3333
+ }
3334
+ );
3335
+ }
3336
+ return void 0;
3337
+ });
3338
+ this.serverVersionCache = p;
3339
+ }
3340
+ serverVersion = await this.serverVersionCache ?? void 0;
3341
+ }
3342
+ if (serverVersion && compareVersions(serverVersion, minVersion) < 0) {
3343
+ throw new OllamaGenericClientError(
3344
+ `Operation ${operation.operationId} (${operation.method} ${operation.path}) requires Ollama >= ${minVersion} (server reports ${serverVersion}).`
3345
+ );
3346
+ }
3347
+ }
3348
+ };
3349
+ function parseStreamByMode(mode, body) {
3350
+ if (mode === "ndjson") {
3351
+ return parseNdjsonStream(body);
3352
+ }
3353
+ if (mode === "sse") {
3354
+ return parseSseStreamAsJson(body);
3355
+ }
3356
+ throw new OllamaGenericClientError(
3357
+ `Transport mode "${mode}" is not a streaming mode; cannot parse a stream for it.`
3358
+ );
3359
+ }
3360
+ async function* parseSseStreamAsJson(body) {
3361
+ for await (const event of parseSseStream(body)) {
3362
+ const data = event.data;
3363
+ if (!data) continue;
3364
+ if (data === "[DONE]") return;
3365
+ try {
3366
+ yield JSON.parse(data);
3367
+ } catch (err) {
3368
+ throw new OllamaGenericClientError(`Failed to parse SSE event data as JSON: ${data}`, {
3369
+ cause: err
3370
+ });
3371
+ }
3372
+ }
3373
+ }
3374
+ function serializeForByteCount(body) {
3375
+ if (body instanceof Uint8Array) return body;
3376
+ if (typeof body === "string") return new TextEncoder().encode(body);
3377
+ const json = JSON.stringify(body);
3378
+ return new TextEncoder().encode(json);
3379
+ }
3380
+ function bodyHasImages(body) {
3381
+ if (typeof body !== "object" || body === null) return false;
3382
+ const obj = body;
3383
+ const images = obj.images;
3384
+ return Array.isArray(images) && images.length > 0;
3385
+ }
3386
+ function resolvePathParams(pathTemplate, pathParams) {
3387
+ if (!pathTemplate.includes("{")) return pathTemplate;
3388
+ const params = pathParams ?? {};
3389
+ return pathTemplate.replace(/\{([^}]+)\}/g, (_match, name) => {
3390
+ const value = params[name];
3391
+ if (value === void 0) {
3392
+ throw new OllamaGenericClientError(
3393
+ `Missing path parameter "${name}" for path template "${pathTemplate}". Provide it via the pathParams field on the invoke() request.`
3394
+ );
3395
+ }
3396
+ return encodeURIComponent(value);
3397
+ });
3398
+ }
3399
+ function extractModelFromBody(body) {
3400
+ if (typeof body !== "object" || body === null) return void 0;
3401
+ const obj = body;
3402
+ const model = obj.model;
3403
+ return typeof model === "string" ? model : void 0;
3404
+ }
3405
+
3406
+ // src/generated/api/operations.ts
3407
+ var blobsOp = {
3408
+ operationId: "blobs",
3409
+ method: "HEAD",
3410
+ path: "/api/blobs/{digest}",
3411
+ environment: { local: true, cloud: false },
3412
+ parameters: [{ name: "digest", in: "path", required: true, schema: { type: "string" } }],
3413
+ transport: { mode: "json", streaming: false },
3414
+ capabilities: {},
3415
+ status: { documented: true },
3416
+ domain: "native",
3417
+ notes: [
3418
+ "HEAD-only endpoint for blob existence checks; declared in OpenAPI but not in the legacy parity manifest."
3419
+ ]
3420
+ };
3421
+ var chatOp = {
3422
+ operationId: "chat",
3423
+ method: "POST",
3424
+ path: "/api/chat",
3425
+ request: { $ref: "#/schemas/ChatRequest" },
3426
+ response: { $ref: "#/schemas/ChatResponse" },
3427
+ environment: { local: true, cloud: true },
3428
+ transport: { mode: "ndjson", streaming: true, streamingDefault: true },
3429
+ capabilities: {
3430
+ thinking: "model-dependent",
3431
+ tools: "model-dependent",
3432
+ vision: "model-dependent",
3433
+ structuredOutput: "supported",
3434
+ logprobs: "supported"
3435
+ },
3436
+ status: { documented: true },
3437
+ domain: "native",
3438
+ notes: [
3439
+ "Use /api/show to discover model-specific thinking values and defaults.",
3440
+ "Structured output (format field) is rejected by Ollama Cloud."
3441
+ ]
3442
+ };
3443
+ var copyOp = {
3444
+ operationId: "copy",
3445
+ method: "POST",
3446
+ path: "/api/copy",
3447
+ request: { $ref: "#/schemas/CopyRequest" },
3448
+ environment: { local: true, cloud: false },
3449
+ transport: { mode: "json", streaming: false },
3450
+ capabilities: {},
3451
+ status: { documented: true },
3452
+ domain: "native"
3453
+ };
3454
+ var createOp = {
3455
+ operationId: "create",
3456
+ method: "POST",
3457
+ path: "/api/create",
3458
+ request: { $ref: "#/schemas/CreateRequest" },
3459
+ response: { $ref: "#/schemas/StatusResponse" },
3460
+ environment: { local: true, cloud: false },
3461
+ transport: { mode: "ndjson", streaming: true, streamingDefault: true },
3462
+ capabilities: { thinking: "unsupported", tools: "unsupported" },
3463
+ status: { documented: true },
3464
+ domain: "native",
3465
+ notes: ["Model creation is local-only; Ollama Cloud does not support it."]
3466
+ };
3467
+ var deleteOp = {
3468
+ operationId: "delete",
3469
+ method: "DELETE",
3470
+ path: "/api/delete",
3471
+ request: { $ref: "#/schemas/DeleteRequest" },
3472
+ environment: { local: true, cloud: false },
3473
+ transport: { mode: "json", streaming: false },
3474
+ capabilities: {},
3475
+ status: { documented: true },
3476
+ domain: "native"
3477
+ };
3478
+ var embedOp = {
3479
+ operationId: "embed",
3480
+ method: "POST",
3481
+ path: "/api/embed",
3482
+ request: { $ref: "#/schemas/EmbedRequest" },
3483
+ response: { $ref: "#/schemas/EmbedResponse" },
3484
+ environment: { local: true, cloud: true },
3485
+ transport: { mode: "json", streaming: false },
3486
+ capabilities: { embeddings: "supported" },
3487
+ status: { documented: true },
3488
+ domain: "native"
3489
+ };
3490
+ var generateOp = {
3491
+ operationId: "generate",
3492
+ method: "POST",
3493
+ path: "/api/generate",
3494
+ request: { $ref: "#/schemas/GenerateRequest" },
3495
+ response: { $ref: "#/schemas/GenerateResponse" },
3496
+ environment: { local: true, cloud: true },
3497
+ transport: { mode: "ndjson", streaming: true, streamingDefault: true },
3498
+ capabilities: {
3499
+ thinking: "model-dependent",
3500
+ vision: "supported",
3501
+ structuredOutput: "supported",
3502
+ logprobs: "supported"
3503
+ },
3504
+ status: { documented: true },
3505
+ domain: "native"
3506
+ };
3507
+ var psOp = {
3508
+ operationId: "ps",
3509
+ method: "GET",
3510
+ path: "/api/ps",
3511
+ response: { $ref: "#/schemas/PsResponse" },
3512
+ environment: { local: true, cloud: true },
3513
+ transport: { mode: "json", streaming: false },
3514
+ capabilities: {},
3515
+ status: { documented: true },
3516
+ domain: "native"
3517
+ };
3518
+ var pullOp = {
3519
+ operationId: "pull",
3520
+ method: "POST",
3521
+ path: "/api/pull",
3522
+ request: { $ref: "#/schemas/PullRequest" },
3523
+ response: { $ref: "#/schemas/StatusResponse" },
3524
+ environment: { local: true, cloud: false },
3525
+ transport: { mode: "ndjson", streaming: true, streamingDefault: true },
3526
+ capabilities: {},
3527
+ status: { documented: true },
3528
+ domain: "native"
3529
+ };
3530
+ var pushOp = {
3531
+ operationId: "push",
3532
+ method: "POST",
3533
+ path: "/api/push",
3534
+ request: { $ref: "#/schemas/PushRequest" },
3535
+ response: { $ref: "#/schemas/StatusResponse" },
3536
+ environment: { local: true, cloud: false },
3537
+ transport: { mode: "ndjson", streaming: true, streamingDefault: true },
3538
+ capabilities: {},
3539
+ status: { documented: true },
3540
+ domain: "native"
3541
+ };
3542
+ var showOp = {
3543
+ operationId: "show",
3544
+ method: "POST",
3545
+ path: "/api/show",
3546
+ request: { $ref: "#/schemas/ShowRequest" },
3547
+ response: { $ref: "#/schemas/ShowResponse" },
3548
+ environment: { local: true, cloud: true },
3549
+ transport: { mode: "json", streaming: false },
3550
+ capabilities: {},
3551
+ status: { documented: true },
3552
+ domain: "native",
3553
+ notes: [
3554
+ "Capabilities source: /api/show is the runtime source of truth for model-dependent capability values (tools, vision, thinking, embeddings)."
3555
+ ]
3556
+ };
3557
+ var systemOneOp = {
3558
+ operationId: "systemOne",
3559
+ method: "POST",
3560
+ path: "/v1/systemone",
3561
+ request: { $ref: "#/schemas/SystemOneRequest" },
3562
+ response: { $ref: "#/schemas/SystemOneResponse" },
3563
+ environment: { local: true, cloud: false },
3564
+ transport: { mode: "json", streaming: false },
3565
+ capabilities: {
3566
+ thinking: "unsupported",
3567
+ tools: "unsupported",
3568
+ vision: "model-dependent",
3569
+ structuredOutput: "unsupported",
3570
+ logprobs: "unsupported",
3571
+ embeddings: "unsupported"
3572
+ },
3573
+ constraints: {
3574
+ minOllamaVersion: "0.35.0",
3575
+ maxRequestBytes: 65536,
3576
+ maxRequestBytesWithImages: 33554432
3577
+ },
3578
+ status: { documented: true, experimental: true },
3579
+ domain: "native",
3580
+ notes: [
3581
+ "Local-only; Ollama Cloud rejects /v1/systemone.",
3582
+ "64 KiB request limit without images, 32 MiB with images (includes JSON/base64 overhead).",
3583
+ "No tools, no generation controls (temperature, top_p, etc.).",
3584
+ "Vision is model-dependent: images are accepted by vision-weighted models (Clef/Clef Flash) but not by text-only models.",
3585
+ "Experimental: behavioral surface may change between Ollama releases."
3586
+ ]
3587
+ };
3588
+ var tagsOp = {
3589
+ operationId: "tags",
3590
+ method: "GET",
3591
+ path: "/api/tags",
3592
+ response: { $ref: "#/schemas/ListResponse" },
3593
+ environment: { local: true, cloud: true },
3594
+ transport: { mode: "json", streaming: false },
3595
+ capabilities: {},
3596
+ status: { documented: true },
3597
+ domain: "native"
3598
+ };
3599
+ var versionOp = {
3600
+ operationId: "version",
3601
+ method: "GET",
3602
+ path: "/api/version",
3603
+ response: { $ref: "#/schemas/VersionResponse" },
3604
+ environment: { local: true, cloud: true },
3605
+ transport: { mode: "json", streaming: false },
3606
+ capabilities: {},
3607
+ status: { documented: true },
3608
+ domain: "native"
3609
+ };
3610
+
3611
+ // src/generated/api/native-api.ts
3612
+ var NativeApi = class {
3613
+ constructor(runtime) {
3614
+ this.runtime = runtime;
3615
+ }
3616
+ runtime;
3617
+ blobs(digest, options) {
3618
+ return this.runtime.invoke({
3619
+ operation: blobsOp,
3620
+ body: void 0,
3621
+ pathParams: { digest },
3622
+ ...options?.signal !== void 0 ? { signal: options.signal } : {}
3623
+ });
3624
+ }
3625
+ chat(request) {
3626
+ return this.runtime.invoke({
3627
+ operation: chatOp,
3628
+ body: request,
3629
+ streamingDefault: true
3630
+ });
3631
+ }
3632
+ copy(request) {
3633
+ return this.runtime.invoke({
3634
+ operation: copyOp,
3635
+ body: request
3636
+ });
3637
+ }
3638
+ create(request) {
3639
+ return this.runtime.invoke({
3640
+ operation: createOp,
3641
+ body: request,
3642
+ streamingDefault: true
3643
+ });
3644
+ }
3645
+ delete(request) {
3646
+ return this.runtime.invoke({
3647
+ operation: deleteOp,
3648
+ body: request
3649
+ });
3650
+ }
3651
+ embed(request) {
3652
+ return this.runtime.invoke({
3653
+ operation: embedOp,
3654
+ body: request
3655
+ });
3656
+ }
3657
+ generate(request) {
3658
+ return this.runtime.invoke({
3659
+ operation: generateOp,
3660
+ body: request,
3661
+ streamingDefault: true
3662
+ });
3663
+ }
3664
+ ps(options) {
3665
+ return this.runtime.invoke({
3666
+ operation: psOp,
3667
+ body: void 0,
3668
+ ...options?.signal !== void 0 ? { signal: options.signal } : {}
3669
+ });
3670
+ }
3671
+ pull(request) {
3672
+ return this.runtime.invoke({
3673
+ operation: pullOp,
3674
+ body: request,
3675
+ streamingDefault: true
3676
+ });
3677
+ }
3678
+ push(request) {
3679
+ return this.runtime.invoke({
3680
+ operation: pushOp,
3681
+ body: request,
3682
+ streamingDefault: true
3683
+ });
3684
+ }
3685
+ show(request) {
3686
+ return this.runtime.invoke({
3687
+ operation: showOp,
3688
+ body: request
3689
+ });
3690
+ }
3691
+ systemOne(request) {
3692
+ return this.runtime.invoke({
3693
+ operation: systemOneOp,
3694
+ body: request
3695
+ });
3696
+ }
3697
+ tags(options) {
3698
+ return this.runtime.invoke({
3699
+ operation: tagsOp,
3700
+ body: void 0,
3701
+ ...options?.signal !== void 0 ? { signal: options.signal } : {}
3702
+ });
3703
+ }
3704
+ version(options) {
3705
+ return this.runtime.invoke({
3706
+ operation: versionOp,
3707
+ body: void 0,
3708
+ ...options?.signal !== void 0 ? { signal: options.signal } : {}
3709
+ });
2975
3710
  }
2976
3711
  };
2977
3712
 
3713
+ // src/failover-http-client.ts
3714
+ var FailoverHttpClient = class {
3715
+ constructor(client, baseUrl) {
3716
+ this.client = client;
3717
+ this.baseUrl = baseUrl;
3718
+ }
3719
+ client;
3720
+ /**
3721
+ * The first candidate endpoint's base URL. Used for inferRuntimeMode()
3722
+ * checks (local vs cloud). The actual request routing picks the best
3723
+ * healthy endpoint per call.
3724
+ */
3725
+ baseUrl;
3726
+ /**
3727
+ * Route a request through OllamaClient's failover machinery.
3728
+ *
3729
+ * Each call to request() goes through executeWithFailover, which:
3730
+ * - Picks the best healthy endpoint from the registry
3731
+ * - Applies retry/backoff within that endpoint
3732
+ * - Fails over to the next candidate on retryable errors
3733
+ * - Reports success/failure to the endpoint health tracker
3734
+ *
3735
+ * Wave 15 (P1): the model is extracted from the request body by the
3736
+ * runtime and passed via the `model` field on the options. This lets
3737
+ * the failover layer filter endpoints by `OllamaEndpoint.models`
3738
+ * (credential-scoped routing). If no model is provided, all endpoints
3739
+ * are considered.
3740
+ *
3741
+ * The `raw` option (for streaming responses) is passed through
3742
+ * unchanged — executeWithFailover returns whatever the operation
3743
+ * callback returns, including raw Response objects.
3744
+ */
3745
+ async request(options) {
3746
+ const { model, ...httpOptions } = options;
3747
+ return this.client.executeWithFailover(
3748
+ async (http, signal) => {
3749
+ const mergedOptions = {
3750
+ ...httpOptions,
3751
+ ...httpOptions.signal !== void 0 ? { signal } : { signal }
3752
+ };
3753
+ return http.request(mergedOptions);
3754
+ },
3755
+ {
3756
+ singleEndpoint: false,
3757
+ ...model !== void 0 ? { model } : {}
3758
+ }
3759
+ );
3760
+ }
3761
+ };
3762
+
3763
+ // src/decision.ts
3764
+ function createDecision(client) {
3765
+ return {
3766
+ async choice(params) {
3767
+ const response = await client.systemOne({
3768
+ model: params.model,
3769
+ state: params.state,
3770
+ ...params.images ? { images: params.images } : {},
3771
+ questions: {
3772
+ decision: {
3773
+ type: "choice",
3774
+ instructions: params.instructions,
3775
+ criteria: params.criteria
3776
+ }
3777
+ },
3778
+ ...params.keepAlive !== void 0 ? { keep_alive: params.keepAlive } : {}
3779
+ });
3780
+ const answer = response.answers.decision;
3781
+ return {
3782
+ choice: answer.choice,
3783
+ probabilities: answer.probabilities,
3784
+ confidence: answer.confidence,
3785
+ usage: response.usage
3786
+ };
3787
+ },
3788
+ async noul(params) {
3789
+ const response = await client.systemOne({
3790
+ model: params.model,
3791
+ state: params.state,
3792
+ ...params.images ? { images: params.images } : {},
3793
+ questions: {
3794
+ decision: {
3795
+ type: "noul",
3796
+ instructions: params.instructions
3797
+ }
3798
+ },
3799
+ ...params.keepAlive !== void 0 ? { keep_alive: params.keepAlive } : {}
3800
+ });
3801
+ const answer = response.answers.decision;
3802
+ return {
3803
+ noul: answer.noul,
3804
+ bool: answer.noul >= 0.5,
3805
+ usage: response.usage
3806
+ };
3807
+ },
3808
+ async score(params) {
3809
+ const response = await client.systemOne({
3810
+ model: params.model,
3811
+ state: params.state,
3812
+ ...params.images ? { images: params.images } : {},
3813
+ questions: {
3814
+ decision: {
3815
+ type: "score",
3816
+ instructions: params.instructions,
3817
+ criteria: params.criteria
3818
+ }
3819
+ },
3820
+ ...params.keepAlive !== void 0 ? { keep_alive: params.keepAlive } : {}
3821
+ });
3822
+ const answer = response.answers.decision;
3823
+ return {
3824
+ score: answer.score,
3825
+ legend: answer.legend,
3826
+ probabilities: answer.probabilities,
3827
+ confidence: answer.confidence,
3828
+ usage: response.usage
3829
+ };
3830
+ },
3831
+ async route(params) {
3832
+ const response = await client.systemOne({
3833
+ model: params.model,
3834
+ state: params.state,
3835
+ ...params.images ? { images: params.images } : {},
3836
+ questions: {
3837
+ decision: {
3838
+ type: "choice",
3839
+ instructions: params.instructions,
3840
+ criteria: params.criteria
3841
+ }
3842
+ },
3843
+ ...params.keepAlive !== void 0 ? { keep_alive: params.keepAlive } : {}
3844
+ });
3845
+ const answer = response.answers.decision;
3846
+ return {
3847
+ route: answer.choice,
3848
+ confidence: answer.confidence
3849
+ };
3850
+ },
3851
+ async verify(params) {
3852
+ const state = {
3853
+ claim: params.claim,
3854
+ evidence: params.evidence
3855
+ };
3856
+ const response = await client.systemOne({
3857
+ model: params.model,
3858
+ state,
3859
+ ...params.images ? { images: params.images } : {},
3860
+ questions: {
3861
+ decision: {
3862
+ type: "noul",
3863
+ instructions: params.instructions ?? "Is the claim supported by the evidence?"
3864
+ }
3865
+ },
3866
+ ...params.keepAlive !== void 0 ? { keep_alive: params.keepAlive } : {}
3867
+ });
3868
+ const answer = response.answers.decision;
3869
+ return {
3870
+ verified: answer.noul >= 0.5,
3871
+ probability: answer.noul
3872
+ };
3873
+ },
3874
+ async rank(params) {
3875
+ const promises = params.candidates.map(async (candidate) => {
3876
+ const response = await client.systemOne({
3877
+ model: params.model,
3878
+ state: candidate.state,
3879
+ ...params.images ? { images: params.images } : {},
3880
+ questions: {
3881
+ decision: {
3882
+ type: "score",
3883
+ instructions: params.instructions,
3884
+ criteria: params.criteria
3885
+ }
3886
+ },
3887
+ ...params.keepAlive !== void 0 ? { keep_alive: params.keepAlive } : {}
3888
+ });
3889
+ const answer = response.answers.decision;
3890
+ return {
3891
+ candidate: candidate.id,
3892
+ score: answer.score,
3893
+ confidence: answer.confidence
3894
+ };
3895
+ });
3896
+ const results = await Promise.all(promises);
3897
+ return results.sort((a, b) => b.score - a.score);
3898
+ }
3899
+ };
3900
+ }
3901
+
2978
3902
  // src/client.ts
2979
3903
  var logicalRequestSequence = 0;
2980
3904
  function createLogicalRequestId() {
@@ -3035,42 +3959,82 @@ var OllamaClient = class {
3035
3959
  * API with the generated `NativeApi` / `OpenAIApi` / `AnthropicApi`
3036
3960
  * surface without configuring two separate HttpClient instances.
3037
3961
  *
3038
- * The returned runtime is bound to the registry's first candidate
3039
- * endpoint (or the resolved single-endpoint config if no `endpoints`
3040
- * array was provided). For multi-endpoint configs that need per-call
3041
- * routing, prefer constructing `OllamaRuntime` directly with a
3042
- * specific HttpClient:
3043
- *
3044
- * ```ts
3045
- * const http = new HttpClient({ baseUrl: 'http://host-a:11434' });
3046
- * const runtime = new OllamaRuntime({ http });
3047
- * const api = new NativeApi(runtime);
3048
- * ```
3962
+ * Wave 14: the runtime now participates in multi-endpoint failover.
3963
+ * Each request is routed through this client's `executeWithFailover`
3964
+ * machinery via a {@link FailoverHttpClient} wrapper. If the first
3965
+ * candidate endpoint is down, requests automatically fail over to
3966
+ * the next healthy candidate — matching the behavior of the
3967
+ * hand-written OllamaClient methods (chat, generate, etc.).
3049
3968
  *
3050
3969
  * The runtime is cached on first call — subsequent calls return the
3051
- * same instance.
3970
+ * same instance. The `FailoverHttpClient` holds a reference to this
3971
+ * client, so it always sees the current endpoint registry state.
3052
3972
  */
3053
3973
  get runtime() {
3054
3974
  if (this._runtime === void 0) {
3055
3975
  const candidates = this.registry.candidates();
3056
3976
  const endpoint = candidates[0];
3057
3977
  const baseUrl = endpoint?.baseUrl ?? "http://localhost:11434";
3058
- const http = new HttpClient({
3059
- baseUrl,
3060
- ...endpoint?.apiKey !== void 0 ? { apiKey: endpoint.apiKey } : {},
3061
- ...endpoint?.headers !== void 0 ? { headers: endpoint.headers } : {},
3978
+ const http = new FailoverHttpClient(this, baseUrl);
3979
+ const cloudHttp = new HttpClient({
3980
+ baseUrl: OLLAMA_CLOUD_BASE_URL,
3981
+ ...this.cloudApiKey !== void 0 ? { apiKey: this.cloudApiKey } : {},
3062
3982
  fetch: this.fetchImpl,
3063
3983
  ...this.middleware !== void 0 ? { middleware: this.middleware } : {},
3064
3984
  ...this.onLifecycleEvent !== void 0 ? { onLifecycleEvent: this.onLifecycleEvent } : {}
3065
3985
  });
3066
3986
  this._runtime = new OllamaRuntime({
3067
3987
  http,
3988
+ cloudHttp,
3068
3989
  localMode: inferRuntimeMode(baseUrl) === "local"
3069
3990
  });
3070
3991
  }
3071
3992
  return this._runtime;
3072
3993
  }
3073
3994
  _runtime;
3995
+ /**
3996
+ * Lazily-constructed `NativeApi` bound to this client's runtime. Exposes
3997
+ * the full generated native API surface (chat, generate, embed, systemOne,
3998
+ * etc.) with contract-driven types and runtime enforcement.
3999
+ *
4000
+ * Wave 13: `systemOne()` delegates to this accessor.
4001
+ */
4002
+ get native() {
4003
+ if (this._nativeApi === void 0) {
4004
+ this._nativeApi = new NativeApi(this.runtime);
4005
+ }
4006
+ return this._nativeApi;
4007
+ }
4008
+ _nativeApi;
4009
+ /**
4010
+ * Higher-level System One decision helpers (Wave 14B).
4011
+ *
4012
+ * Ergonomic wrappers around `systemOne()` for the six most common
4013
+ * decision patterns: `choice()`, `noul()`, `score()`, `route()`,
4014
+ * `verify()`, `rank()`. Each constructs a single-question request
4015
+ * and extracts the typed answer.
4016
+ *
4017
+ * ```ts
4018
+ * const result = await client.decision.choice({
4019
+ * model: 'tev1:4b',
4020
+ * state: 'Customer was charged twice',
4021
+ * instructions: 'What is the primary intent?',
4022
+ * criteria: {
4023
+ * refund: 'Customer wants a refund',
4024
+ * duplicate_charge: 'Customer reports multiple charges',
4025
+ * },
4026
+ * });
4027
+ * console.log(result.choice); // 'duplicate_charge'
4028
+ * console.log(result.confidence); // 0.89
4029
+ * ```
4030
+ */
4031
+ get decision() {
4032
+ if (this._decision === void 0) {
4033
+ this._decision = createDecision(this);
4034
+ }
4035
+ return this._decision;
4036
+ }
4037
+ _decision;
3074
4038
  /**
3075
4039
  * Fail-fast guard for `format` (structured output) requests: throws before any network
3076
4040
  * call if the candidate endpoint is inferred as Ollama Cloud, which does not currently
@@ -3343,6 +4307,43 @@ var OllamaClient = class {
3343
4307
  version = () => this.models.version();
3344
4308
  createBlob = (digest, data) => this.models.createBlob(digest, data);
3345
4309
  checkBlob = (digest) => this.models.checkBlob(digest);
4310
+ // --- System One (Wave 13) ---
4311
+ /**
4312
+ * Ollama's System One decision layer (`POST /v1/systemone`) — evaluates
4313
+ * 1–64 typed questions (choice, noul, or score) against a provided state
4314
+ * and returns typed answers with probabilities and confidence.
4315
+ *
4316
+ * Local-only; requires Ollama >= 0.35.0. The runtime enforces the
4317
+ * version constraint automatically (lazily fetching `/api/version` when
4318
+ * `enforceVersion` is `'auto'` or `'strict'`) and rejects cloud-mode
4319
+ * calls. Request size is checked client-side: 64 KiB without images,
4320
+ * 32 MiB with images.
4321
+ *
4322
+ * The generic `Q` parameter captures the caller's question map at
4323
+ * compile time, giving key-safe answer access:
4324
+ *
4325
+ * ```ts
4326
+ * const result = await ollama.systemOne({
4327
+ * model: 'tev1:4b',
4328
+ * state: { ticket: 'Customer was charged twice' },
4329
+ * questions: {
4330
+ * intent: { type: 'choice', instructions: '...', criteria: { ... } },
4331
+ * urgent: { type: 'noul', instructions: '...' },
4332
+ * },
4333
+ * });
4334
+ * result.answers.intent // ✓ SystemOneAnswer (choice)
4335
+ * result.answers.urgent // ✓ SystemOneAnswer (noul)
4336
+ * result.answers.typo // ✗ TypeScript error
4337
+ * ```
4338
+ *
4339
+ * For the low-level generated API (without the generic wrapper), use
4340
+ * `client.native.systemOne(request)` directly.
4341
+ */
4342
+ async systemOne(request) {
4343
+ return this.native.systemOne(
4344
+ request
4345
+ );
4346
+ }
3346
4347
  // --- Web Endpoints ---
3347
4348
  /**
3348
4349
  * Ollama's hosted web search tool (`POST https://ollama.com/api/web_search`) — a fixed
@@ -4004,6 +5005,22 @@ async function listAllMcpTools(mcpClient, options = {}, signal) {
4004
5005
  const params = cursor !== void 0 ? { cursor } : void 0;
4005
5006
  const requestOptions = signal !== void 0 ? { signal } : void 0;
4006
5007
  const page = await mcpClient.listTools(params, requestOptions);
5008
+ const pageNames = /* @__PURE__ */ new Set();
5009
+ for (const tool of page.tools) {
5010
+ if (pageNames.has(tool.name)) {
5011
+ throw new OllamaMcpError(
5012
+ `MCP tools/list returned duplicate tool name "${tool.name}"`,
5013
+ { mcpMethod: "listTools", toolName: tool.name }
5014
+ );
5015
+ }
5016
+ pageNames.add(tool.name);
5017
+ if (tools.some((existing) => existing.name === tool.name)) {
5018
+ throw new OllamaMcpError(
5019
+ `MCP tools/list returned duplicate tool name "${tool.name}" across pages`,
5020
+ { mcpMethod: "listTools", toolName: tool.name }
5021
+ );
5022
+ }
5023
+ }
4007
5024
  tools.push(...page.tools);
4008
5025
  if (page.nextCursor === void 0) {
4009
5026
  return tools;
@@ -4017,6 +5034,9 @@ async function listAllMcpTools(mcpClient, options = {}, signal) {
4017
5034
  throw new Error("MCP tools/list exceeded maxPages (" + maxPages + ")");
4018
5035
  }
4019
5036
  function formatMcpToolResult(result) {
5037
+ if ("resultType" in result || "task" in result) {
5038
+ return JSON.stringify(result) ?? String(result);
5039
+ }
4020
5040
  const parts = result.content.map((block) => {
4021
5041
  if (block.type === "text" && typeof block.text === "string") {
4022
5042
  return block.text;
@@ -4038,6 +5058,20 @@ function formatMcpToolResult(result) {
4038
5058
  }
4039
5059
  return parts.join("\n");
4040
5060
  }
5061
+ function supportsTaskCalls(mcpClient) {
5062
+ return mcpClient.getServerCapabilities?.()?.tasks?.requests?.tools?.call !== void 0;
5063
+ }
5064
+ function shouldCallAsTask(descriptor, options, serverSupportsTasks) {
5065
+ const support = descriptor.execution?.taskSupport;
5066
+ if (support === "required" && !serverSupportsTasks) {
5067
+ throw new OllamaMcpError(
5068
+ `MCP tool "${descriptor.name}" requires task execution, but the server does not advertise tasks.requests.tools.call`,
5069
+ { mcpMethod: "callTool", toolName: descriptor.name }
5070
+ );
5071
+ }
5072
+ if (!serverSupportsTasks || support === void 0 || support === "forbidden") return false;
5073
+ return support === "required" || options.taskMode === "all-supported";
5074
+ }
4041
5075
  function createInputValidator(inputSchema) {
4042
5076
  return z.custom().superRefine((value, ctx) => {
4043
5077
  const issues = validateJsonSchema(value, inputSchema);
@@ -4050,7 +5084,7 @@ function createInputValidator(inputSchema) {
4050
5084
  }
4051
5085
  });
4052
5086
  }
4053
- function convertMcpDescriptorToTool(descriptor, mcpClient, namePrefix = "", resultMode = "text") {
5087
+ function convertMcpDescriptorToTool(descriptor, mcpClient, namePrefix = "", resultMode = "text", validateOutputSchema = true, executeAsTask = false, taskTtlMs) {
4054
5088
  const toolName = `${namePrefix}${descriptor.name}`;
4055
5089
  const inputSchema = descriptor.inputSchema ?? { type: "object", properties: {} };
4056
5090
  const properties = inputSchema["properties"] ?? {};
@@ -4070,10 +5104,27 @@ function convertMcpDescriptorToTool(descriptor, mcpClient, namePrefix = "", resu
4070
5104
  const result = await mcpClient.callTool(
4071
5105
  {
4072
5106
  name: descriptor.name,
4073
- arguments: args
5107
+ arguments: args,
5108
+ ...executeAsTask ? { task: taskTtlMs !== void 0 ? { ttl: taskTtlMs } : {} } : {}
4074
5109
  },
4075
- context.signal !== void 0 ? { signal: context.signal } : void 0
5110
+ {
5111
+ ...context.signal !== void 0 ? { signal: context.signal } : {},
5112
+ allowInputRequired: true
5113
+ }
4076
5114
  );
5115
+ if (!("resultType" in result) && !("task" in result) && validateOutputSchema && descriptor.outputSchema !== void 0 && result.structuredContent !== void 0) {
5116
+ const issues = validateJsonSchema(result.structuredContent, descriptor.outputSchema);
5117
+ if (issues.length > 0) {
5118
+ throw new OllamaMcpError(
5119
+ `MCP tool "${descriptor.name}" returned structuredContent that violates outputSchema`,
5120
+ {
5121
+ mcpMethod: "tools/call",
5122
+ toolName: descriptor.name,
5123
+ issues
5124
+ }
5125
+ );
5126
+ }
5127
+ }
4077
5128
  return resultMode === "structured" ? result : formatMcpToolResult(result);
4078
5129
  } catch (err) {
4079
5130
  if (err instanceof OllamaMcpError) throw err;
@@ -4096,9 +5147,29 @@ function convertMcpDescriptorToTool(descriptor, mcpClient, namePrefix = "", resu
4096
5147
  }
4097
5148
  async function loadMcpTools(mcpClient, options = {}, signal) {
4098
5149
  try {
5150
+ if (options.taskTtlMs !== void 0 && (!Number.isFinite(options.taskTtlMs) || options.taskTtlMs <= 0)) {
5151
+ throw new RangeError("MCP taskTtlMs must be a positive finite number");
5152
+ }
4099
5153
  const tools = await listAllMcpTools(mcpClient, options, signal);
4100
- return tools.map((t) => convertMcpDescriptorToTool(t, mcpClient, options.namePrefix, options.resultMode));
5154
+ const serverSupportsTasks = supportsTaskCalls(mcpClient);
5155
+ return tools.map((tool) => {
5156
+ const taskCall = shouldCallAsTask(
5157
+ tool,
5158
+ options,
5159
+ serverSupportsTasks
5160
+ );
5161
+ return convertMcpDescriptorToTool(
5162
+ tool,
5163
+ mcpClient,
5164
+ options.namePrefix,
5165
+ options.resultMode,
5166
+ options.validateOutputSchema ?? true,
5167
+ taskCall,
5168
+ options.taskTtlMs
5169
+ );
5170
+ });
4101
5171
  } catch (err) {
5172
+ if (err instanceof OllamaMcpError) throw err;
4102
5173
  throw new OllamaMcpError("Failed listing MCP tools from client", {
4103
5174
  mcpMethod: "listTools",
4104
5175
  cause: err
@@ -4109,8 +5180,18 @@ async function registerMcpTools(registry, mcpClient, options = {}, signal) {
4109
5180
  const tools = await loadMcpTools(mcpClient, options, signal);
4110
5181
  registry.registerMany(tools);
4111
5182
  }
4112
-
4113
- // src/mcp/bridge.ts
5183
+ var taskSchema = z.object({
5184
+ taskId: z.string(),
5185
+ status: z.enum(["working", "input_required", "completed", "failed", "cancelled"]),
5186
+ statusMessage: z.string().optional(),
5187
+ createdAt: z.string(),
5188
+ lastUpdatedAt: z.string(),
5189
+ ttl: z.number().optional(),
5190
+ pollInterval: z.number().optional()
5191
+ }).passthrough();
5192
+ var callToolResultSchema = z.custom(
5193
+ (value) => typeof value === "object" && value !== null && "content" in value && Array.isArray(value.content)
5194
+ );
4114
5195
  var McpBridge = class _McpBridge {
4115
5196
  constructor(client, options = {}) {
4116
5197
  this.client = client;
@@ -4145,6 +5226,50 @@ var McpBridge = class _McpBridge {
4145
5226
  async register(registry, signal) {
4146
5227
  await registry.registerMany(await this.loadTools(signal));
4147
5228
  }
5229
+ /** Refreshes the current MCP tool catalog into an existing registry without clearing local tools. */
5230
+ async refresh(registry, signal) {
5231
+ await registry.registerMany(await this.loadTools(signal));
5232
+ }
5233
+ /** Fetches one legacy MCP task's current status without starting a polling loop. */
5234
+ async getTaskStatus(taskId, signal) {
5235
+ return this.requestTask(
5236
+ "tasks/get",
5237
+ taskId,
5238
+ taskSchema,
5239
+ signal
5240
+ );
5241
+ }
5242
+ /** Retrieves a completed legacy MCP task's result. */
5243
+ async getTaskResult(taskId, signal) {
5244
+ return this.requestTask(
5245
+ "tasks/result",
5246
+ taskId,
5247
+ callToolResultSchema,
5248
+ signal
5249
+ );
5250
+ }
5251
+ /** Cancels one legacy MCP task. */
5252
+ async cancelTask(taskId, signal) {
5253
+ return this.requestTask(
5254
+ "tasks/cancel",
5255
+ taskId,
5256
+ taskSchema,
5257
+ signal
5258
+ );
5259
+ }
5260
+ requestTask(method, taskId, resultSchema, signal) {
5261
+ if (this.client.request === void 0) {
5262
+ throw new OllamaMcpError(
5263
+ `MCP client does not support ${method} requests`,
5264
+ { mcpMethod: method }
5265
+ );
5266
+ }
5267
+ return this.client.request(
5268
+ { method, params: { taskId } },
5269
+ resultSchema,
5270
+ signal !== void 0 ? { signal } : void 0
5271
+ );
5272
+ }
4148
5273
  };
4149
5274
 
4150
5275
  // src/skills/frontmatter.ts
@@ -4370,6 +5495,6 @@ var Agent = class {
4370
5495
  }
4371
5496
  };
4372
5497
 
4373
- 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, Agent, AnthropicCompatClient, AnthropicMessagesStream, DEFAULT_BACKOFF, DEFAULT_BASE_URL, DEFAULT_FAILOVER_CODES, DEFAULT_RETRY_CONFIG, DEFAULT_TIMEOUT_MS, EndpointRegistry, GEN_AI_SYSTEM_OLLAMA, HttpClient, McpBridge, ModelsClient, NANOS_PER_MS, NANOS_PER_SECOND, NOOP_LOGGER, OLLAMA_CLOUD_BASE_URL, OllamaAbortError, OllamaAgentMaxIterationsError, OllamaAgentMaxToolCallsError, OllamaAuthError, OllamaClient, OllamaClientError, OllamaGenericClientError, OllamaIncompatibleModelError, OllamaMcpError, OllamaModelRoutingError, OllamaNetworkError, OllamaNotFoundError, OllamaQuotaExceededError, OllamaRateLimitError, OllamaRequestValidationError, OllamaServerError, OllamaSkillInvalidError, OllamaSkillNotFoundError, OllamaStream, OllamaTimeoutError, OllamaToolTimeoutError, OllamaToolValidationError, OllamaUnsupportedCapabilityError, OpenAIChatCompletionStream, OpenAICompatClient, OpenAICompletionStream, OpenAIResponsesStream, OpenAIResponsesStreamError, QuotaManager, ToolRegistry, addSpanEvent, applySkill, calculateBackoff, checkEndpointHealth, composeMiddleware, createConsoleLogger, createOllamaCloudFreeTierQuota, createTimeoutSignal, defineTool, detectModelCapabilities, encodeImage, extractUsage, inferRuntimeMode, listAllMcpTools, listAvailableModels, loadMcpTools, mapError, normalizeChatStream, normalizeGenerateStream, normalizeProgressStream, parseFrontmatter, parseNdjsonStream, parseSseStream, parseStructuredOutput, registerMcpTools, resolveCredentialEndpoints, setSpanError, toDataStream, toResponse, toTextStream, withRetry, withSpan, zodToJsonSchema };
5498
+ 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, Agent, AnthropicCompatClient, AnthropicMessagesStream, DEFAULT_BACKOFF, DEFAULT_BASE_URL, DEFAULT_FAILOVER_CODES, DEFAULT_RETRY_CONFIG, DEFAULT_TIMEOUT_MS, EndpointRegistry, GEN_AI_SYSTEM_OLLAMA, HttpClient, McpBridge, ModelsClient, NANOS_PER_MS, NANOS_PER_SECOND, NOOP_LOGGER, OLLAMA_CLOUD_BASE_URL, OllamaAbortError, OllamaAgentMaxIterationsError, OllamaAgentMaxToolCallsError, OllamaAuthError, OllamaClient, OllamaClientError, OllamaGenericClientError, OllamaIncompatibleModelError, OllamaMcpError, OllamaModelRoutingError, OllamaNetworkError, OllamaNotFoundError, OllamaQuotaExceededError, OllamaRateLimitError, OllamaRequestTooLargeError, OllamaRequestValidationError, OllamaResponseValidationError, OllamaServerError, OllamaServerVersionUnknownError, OllamaSkillInvalidError, OllamaSkillNotFoundError, OllamaStream, OllamaTimeoutError, OllamaToolTimeoutError, OllamaToolValidationError, OllamaUnsupportedCapabilityError, OpenAIChatCompletionStream, OpenAICompatClient, OpenAICompletionStream, OpenAIResponsesStream, OpenAIResponsesStreamError, QuotaManager, ToolRegistry, addSpanEvent, applySkill, calculateBackoff, checkEndpointHealth, composeMiddleware, createConsoleLogger, createDecision, createOllamaCloudFreeTierQuota, createTimeoutSignal, defineTool, detectModelCapabilities, encodeImage, extractUsage, inferRuntimeMode, listAllMcpTools, listAvailableModels, loadMcpTools, mapError, normalizeChatStream, normalizeGenerateStream, normalizeProgressStream, parseFrontmatter, parseNdjsonStream, parseSseStream, parseStructuredOutput, registerMcpTools, resolveCredentialEndpoints, setSpanError, toDataStream, toResponse, toTextStream, withRetry, withSpan, zodToJsonSchema };
4374
5499
  //# sourceMappingURL=index.js.map
4375
5500
  //# sourceMappingURL=index.js.map