@nemesis-oss/ollama-sdk 1.18.0 → 1.19.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 (40) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +1 -1
  3. package/dist/{anthropic-BvHOsidk.d.cts → anthropic-CAvwqIjx.d.ts} +3 -3
  4. package/dist/{anthropic-CvGVSoVP.d.ts → anthropic-DIPnBwlf.d.cts} +3 -3
  5. package/dist/{compose-CeFbHJeO.d.ts → compose-75UFDzOO.d.ts} +1 -1
  6. package/dist/{compose-DFkmtUOP.d.cts → compose-C4QxEZOS.d.cts} +1 -1
  7. package/dist/generated-api.cjs +5 -3
  8. package/dist/generated-api.cjs.map +1 -1
  9. package/dist/generated-api.d.cts +9 -9
  10. package/dist/generated-api.d.ts +9 -9
  11. package/dist/generated-api.js +5 -3
  12. package/dist/generated-api.js.map +1 -1
  13. package/dist/generated-runtime.cjs +22 -4
  14. package/dist/generated-runtime.cjs.map +1 -1
  15. package/dist/generated-runtime.d.cts +2 -2
  16. package/dist/generated-runtime.d.ts +2 -2
  17. package/dist/generated-runtime.js +22 -4
  18. package/dist/generated-runtime.js.map +1 -1
  19. package/dist/index.cjs +48 -14
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +76 -36
  22. package/dist/index.d.ts +76 -36
  23. package/dist/index.js +48 -15
  24. package/dist/index.js.map +1 -1
  25. package/dist/mcp/tools.json +3 -3
  26. package/dist/mcp-generated.cjs +5 -3
  27. package/dist/mcp-generated.cjs.map +1 -1
  28. package/dist/mcp-generated.d.cts +2 -2
  29. package/dist/mcp-generated.d.ts +2 -2
  30. package/dist/mcp-generated.js +5 -3
  31. package/dist/mcp-generated.js.map +1 -1
  32. package/dist/{runtime-CdZP-N7j.d.cts → runtime-C28YEAHC.d.cts} +28 -5
  33. package/dist/{runtime-CFuv7Ifh.d.ts → runtime-DYCxYGG-.d.ts} +28 -5
  34. package/dist/skills.cjs.map +1 -1
  35. package/dist/skills.d.cts +3 -3
  36. package/dist/skills.d.ts +3 -3
  37. package/dist/skills.js.map +1 -1
  38. package/dist/{types-DbPnfVh-.d.cts → types-Y3u0FtdN.d.cts} +10 -0
  39. package/dist/{types-DbPnfVh-.d.ts → types-Y3u0FtdN.d.ts} +10 -0
  40. package/package.json +2 -1
package/dist/index.cjs CHANGED
@@ -193,6 +193,11 @@ var OllamaAuthError = class extends OllamaClientError {
193
193
  super(message, { ...options, code: "auth_error", retryable: false });
194
194
  }
195
195
  };
196
+ var OllamaPaymentRequiredError = class extends OllamaClientError {
197
+ constructor(message, options) {
198
+ super(message, { ...options, code: "payment_required", retryable: false, status: 402 });
199
+ }
200
+ };
196
201
  var OllamaNotFoundError = class extends OllamaClientError {
197
202
  constructor(message, options) {
198
203
  super(message, { ...options, code: "not_found", retryable: false });
@@ -427,6 +432,9 @@ function statusToError(status, message, options) {
427
432
  if (status === 401 || status === 403) {
428
433
  return new OllamaAuthError(message, { ...options, status });
429
434
  }
435
+ if (status === 402) {
436
+ return new OllamaPaymentRequiredError(message, options);
437
+ }
430
438
  if (status === 404) {
431
439
  return new OllamaNotFoundError(message, { ...options, status });
432
440
  }
@@ -4425,14 +4433,25 @@ var OllamaRuntime = class {
4425
4433
  const hasImages = bodyHasImages(body);
4426
4434
  const maxBytesWithImages = req.operation.constraints?.maxRequestBytesWithImages;
4427
4435
  const maxBytesBase = req.operation.constraints?.maxRequestBytes;
4428
- const applicableLimit = hasImages && maxBytesWithImages !== void 0 ? maxBytesWithImages : maxBytesBase;
4429
- if (applicableLimit !== void 0 && serialized.byteLength > applicableLimit) {
4436
+ const textAndSchemaBytes = hasImages ? serializeWithoutImages(body).byteLength : serialized.byteLength;
4437
+ if (maxBytesBase !== void 0 && textAndSchemaBytes > maxBytesBase) {
4430
4438
  throw new OllamaRequestTooLargeError(
4431
- `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)." : "."),
4439
+ `Operation ${req.operation.operationId} (${req.operation.method} ${req.operation.path}) text and schema (images excluded) is ${textAndSchemaBytes} bytes, exceeding the contract limit of ${maxBytesBase} bytes.`,
4440
+ {
4441
+ operationId: req.operation.operationId,
4442
+ actualBytes: textAndSchemaBytes,
4443
+ maxBytes: maxBytesBase,
4444
+ request: { method: req.operation.method, url: req.operation.path }
4445
+ }
4446
+ );
4447
+ }
4448
+ if (maxBytesWithImages !== void 0 && serialized.byteLength > maxBytesWithImages) {
4449
+ throw new OllamaRequestTooLargeError(
4450
+ `Operation ${req.operation.operationId} (${req.operation.method} ${req.operation.path}) request body is ${serialized.byteLength} bytes, exceeding the contract limit of ${maxBytesWithImages} bytes (whole request, images included).`,
4432
4451
  {
4433
4452
  operationId: req.operation.operationId,
4434
4453
  actualBytes: serialized.byteLength,
4435
- maxBytes: applicableLimit,
4454
+ maxBytes: maxBytesWithImages,
4436
4455
  request: { method: req.operation.method, url: req.operation.path }
4437
4456
  }
4438
4457
  );
@@ -4574,6 +4593,13 @@ function bodyHasImages(body) {
4574
4593
  const images = obj.images;
4575
4594
  return Array.isArray(images) && images.length > 0;
4576
4595
  }
4596
+ function serializeWithoutImages(body) {
4597
+ if (typeof body === "object" && body !== null && !Array.isArray(body)) {
4598
+ const { images: _images, ...rest } = body;
4599
+ return serializeForByteCount(rest);
4600
+ }
4601
+ return serializeForByteCount(body);
4602
+ }
4577
4603
  function resolvePathParams(pathTemplate, pathParams) {
4578
4604
  if (!pathTemplate.includes("{")) return pathTemplate;
4579
4605
  const params = pathParams ?? {};
@@ -5326,7 +5352,7 @@ var systemOneOp = {
5326
5352
  path: "/v1/systemone",
5327
5353
  request: { $ref: "#/schemas/SystemOneRequest" },
5328
5354
  response: { $ref: "#/schemas/SystemOneResponse" },
5329
- environment: { local: true, cloud: false },
5355
+ environment: { local: true, cloud: true },
5330
5356
  transport: { mode: "json", streaming: false },
5331
5357
  capabilities: {
5332
5358
  thinking: "unsupported",
@@ -5344,8 +5370,10 @@ var systemOneOp = {
5344
5370
  status: { documented: true, experimental: true },
5345
5371
  domain: "native",
5346
5372
  notes: [
5347
- "Local-only; Ollama Cloud rejects /v1/systemone.",
5348
- "64 KiB request limit without images, 32 MiB with images (includes JSON/base64 overhead).",
5373
+ "Local and cloud: model accepts cloud models (e.g. clef:cloud); cloud models require Ollama >= 0.40.5 or the hosted https://ollama.com endpoint.",
5374
+ "Local dual cap: text and schema (excluding images) within 64 KiB AND the whole request within 32 MiB, including base64 and JSON overhead.",
5375
+ "Cloud requests: paid plan or usage credits required; up to 64 questions named with up to 100 ASCII letters, digits, `_`, `.`, or `-`; up to 4 images of at most 4 MiB and 16 megapixels each (8 MiB total); requests within 13 MiB; input within the model's 65,536-token context window.",
5376
+ "401 when a cloud model is requested without signing in or with an invalid API key (through a local server the response includes a signin_url); 402 when the cloud model is not included in the Free plan or a payment fails.",
5349
5377
  "No tools, no generation controls (temperature, top_p, etc.).",
5350
5378
  "Vision is model-dependent: images are accepted by vision-weighted models (Clef/Clef Flash) but not by text-only models.",
5351
5379
  "Experimental: behavioral surface may change between Ollama releases."
@@ -6301,11 +6329,15 @@ var OllamaClient = class _OllamaClient {
6301
6329
  * 1–64 typed questions (choice, noul, or score) against a provided state
6302
6330
  * and returns typed answers with probabilities and confidence.
6303
6331
  *
6304
- * Local-only; requires Ollama >= 0.35.0. The runtime enforces the
6305
- * version constraint automatically (lazily fetching `/api/version` when
6306
- * `enforceVersion` is `'auto'` or `'strict'`) and rejects cloud-mode
6307
- * calls. Request size is checked client-side: 64 KiB without images,
6308
- * 32 MiB with images.
6332
+ * Local and cloud (since the 2026-10-16 upstream System One cloud
6333
+ * launch): `model` also accepts cloud models such as `clef:cloud` —
6334
+ * cloud models require Ollama >= 0.40.5 or the hosted
6335
+ * `https://ollama.com` endpoint. Requires Ollama >= 0.35.0 locally.
6336
+ * The runtime enforces the version constraint automatically (lazily
6337
+ * fetching `/api/version` when `enforceVersion` is `'auto'` or
6338
+ * `'strict'`). Request size is checked client-side as a dual cap:
6339
+ * text and schema (images excluded) within 64 KiB AND the whole
6340
+ * request within 32 MiB.
6309
6341
  *
6310
6342
  * The generic `Q` parameter captures the caller's question map at
6311
6343
  * compile time, giving key-safe answer access:
@@ -8256,8 +8288,9 @@ function createModelAffinityScheduler(client, options) {
8256
8288
  // src/system-one.ts
8257
8289
  var MAX_SYSTEM_ONE_IMAGES_BYTES = 32 * 1024 * 1024;
8258
8290
  var MAX_SYSTEM_ONE_REQUEST_BYTES = 64 * 1024;
8259
- function estimateSystemOneRequestBytes(request) {
8260
- return new TextEncoder().encode(JSON.stringify(request)).byteLength;
8291
+ function estimateSystemOneRequestBytes(request, options) {
8292
+ const body = options?.excludeImages && request.images !== void 0 ? { ...request, images: void 0 } : request;
8293
+ return new TextEncoder().encode(JSON.stringify(body)).byteLength;
8261
8294
  }
8262
8295
 
8263
8296
  exports.ATTR_GEN_AI_OPERATION_NAME = ATTR_GEN_AI_OPERATION_NAME;
@@ -8325,6 +8358,7 @@ exports.OllamaModelRoutingError = OllamaModelRoutingError;
8325
8358
  exports.OllamaNetworkError = OllamaNetworkError;
8326
8359
  exports.OllamaNotFoundError = OllamaNotFoundError;
8327
8360
  exports.OllamaOverloadedError = OllamaOverloadedError;
8361
+ exports.OllamaPaymentRequiredError = OllamaPaymentRequiredError;
8328
8362
  exports.OllamaQuotaExceededError = OllamaQuotaExceededError;
8329
8363
  exports.OllamaRateLimitError = OllamaRateLimitError;
8330
8364
  exports.OllamaRequestTooLargeError = OllamaRequestTooLargeError;