@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/CHANGELOG.md CHANGED
@@ -1,8 +1,20 @@
1
1
  # Changelog
2
2
 
3
- ## Unreleased
3
+ ## [1.8.0] - 2026-10-02
4
4
 
5
- - **Runtime Zod validation (Wave 10).** `OllamaRuntime` now accepts a `validateRequests: true` option. When enabled, every request body is validated against the operation's generated Zod schema BEFORE any HTTP request is made. Malformed requests throw `OllamaRequestValidationError` (a new `OllamaClientError` subclass) with the Zod issues attached. Unknown fields are stripped (Zod's default behavior), so callers can't accidentally send extra fields the contract doesn't allow. Opt-in — zero overhead when disabled (the default). See [ADR 0020](./docs/adr/0020-runtime-zod-validation.md).
5
+ - **Contract execution completion (Waves 12-16).** The SDK's contract-first architecture is now fully executable: every operation in the canonical IR is represented, generated, typed, and runtime-enforced with no `Record<string, unknown>` escape hatches on the generated surface.
6
+ - **Wave 12** — Contract execution hardening: transport-mode dispatch (SSE for compat, NDJSON for native), `maxRequestBytes` enforcement (413 client-side), auto-fetch `minOllamaVersion` via cached `/api/version`, typed OpenAI/Anthropic generated APIs, fully generated System One types, MCP input schemas from path params, generated schema-registry, Web Search/Web Fetch in the IR, structural path parameters, `checkBlob` 404-only semantics, single `verify:release` gate, deterministic IR.
7
+ - **Wave 13** — System One contract completion: exact upstream OpenAPI schemas (correct `confidence: number`, `noul: number`, `score: number`, `legend: Record`, `probabilities: Record`), string `pattern`/`minLength`/`maxLength` enforcement, conditional request size limits (64 KiB / 32 MiB with images), `OllamaClient.systemOne<Q>()` with key-safe generic answer access, opt-in `validateResponses` runtime path, live System One conformance against real Ollama with `tev1:0.8b`.
8
+ - **Wave 14** — Failover + decision helpers: `OllamaClient.runtime` participates in multi-endpoint failover via `FailoverHttpClient`, higher-level System One decision helpers (`choice()`, `noul()`, `score()`, `route()`, `verify()`, `rank()`).
9
+ - **Wave 15** — Contract execution completion: path parameter substitution (`{model}` → `gpt-4` with URI encoding), host-aware execution (web search/fetch route to `https://ollama.com` via `cloudHttp` backend), model-aware failover routing, MCP argument routing (path params split from body), `contract:validate` in CI and release, method+path operation-level discovery (catches missing HTTP methods on declared paths).
10
+ - **Wave 16** — Final hardening: security invariant tests (path traversal prevention, host injection prevention, abort propagation), System One exact generic answer correlation (`AnswerFor<Q>`), decision helper `verify()` semantic fix (`probability` not `confidence`), ADR 0022 documenting hybrid compatibility typing policy, version bump to 1.8.0.
11
+
12
+ - **System One live-tour coverage.** The live feature tour now exercises `/v1/systemone` when the server is Ollama 0.35.0 or newer and a compatible local model is installed; otherwise it records a clear skip reason.
13
+
14
+ ## [1.7.0] - 2026-10-01
15
+
16
+ - **Interactive MCP elicitation and task handling.** The stdio and HTTP connectors now support host-managed form/URL elicitation and configurable manual or automatic `input_required` handling. The bridge preserves task responses and exposes explicit task status, result, and cancellation methods without starting background polling.
17
+ - **Consolidated live Ollama tour.** Added `npm run lab:live` to exercise the built public SDK against a local Ollama server, with real-time request/stream logs, JSONL results, and opt-in cloud/vision checks.
6
18
 
7
19
  ## [1.4.1] - 2026-10-01
8
20
 
package/README.md CHANGED
@@ -73,6 +73,8 @@ The SDK exposes a transport-neutral `McpBridge` that converts MCP `tools/list` d
73
73
  - MCP JSON Schema is preserved in the generated Ollama tool definition.
74
74
  - `structuredContent` and non-text MCP content blocks are retained in the model-visible tool result.
75
75
  - MCP `isError: true` results remain model-readable; they are not treated as transport failures.
76
+ - Manual `input_required` responses and legacy task creation/status results are preserved without silently polling.
77
+ - Tools declaring `execution.taskSupport: "required"` are invoked as tasks only when the server advertises task calls; optional task use is opt-in.
76
78
 
77
79
  `loadMcpTools()` keeps the historical model-oriented string result by default. Set `resultMode: 'structured'` when application code needs the raw MCP `CallToolResult`, including `structuredContent`, content blocks, `isError`, and `_meta`:
78
80
 
@@ -113,6 +115,35 @@ await connection.close();
113
115
  console.log(result.finalMessage.content);
114
116
  ```
115
117
 
118
+ The stdio and HTTP connectors accept host-provided elicitation handlers. The requested modes are declared as client capabilities before connection, and the host retains control over user interaction. Form handlers should display and validate the requested fields; URL handlers should show the destination and obtain consent before accepting or opening it. No URL is opened automatically:
119
+
120
+ ```typescript
121
+ const connection = await connectStdioMcpClient(
122
+ { command: 'npx', args: ['-y', '@modelcontextprotocol/server-example'] },
123
+ {
124
+ elicitation: {
125
+ form: async (request) => collectAndValidateForm(request),
126
+ url: async (request) => {
127
+ const approved = await askUserToOpen(request.url, request.message);
128
+ return { action: approved ? 'accept' : 'decline' };
129
+ },
130
+ },
131
+ inputRequiredMode: 'manual',
132
+ },
133
+ );
134
+ ```
135
+
136
+ `inputRequiredMode` defaults to `manual` on these connectors. The bridge forwards `input_required` results unchanged (use `resultMode: 'structured'` for raw values), including their opaque `requestState` and keyed `inputRequests`; it does not solicit data or retry the tool call itself. Set `inputRequiredMode: 'automatic'` to let the MCP client use the registered elicitation handlers and retry internally. In manual mode, the host can gather responses and retry with the same `requestState`:
137
+
138
+ ```typescript
139
+ await connection.client.callTool(
140
+ { name, arguments: args, inputResponses, requestState },
141
+ { allowInputRequired: true },
142
+ );
143
+ ```
144
+
145
+ For legacy task-capable servers, required task tools are invoked using task augmentation. Optional task-capable tools remain synchronous unless `taskMode: 'all-supported'` is set. Set `taskTtlMs` to request a task lifetime. Task creation and `input_required` task statuses are preserved (serialized as JSON in text mode); no polling starts automatically. The host controls progress with `bridge.getTaskStatus(taskId)`, retrieves a completed payload with `bridge.getTaskResult(taskId)`, and can stop work with `bridge.cancelTask(taskId)`.
146
+
116
147
  Use `connection.terminateSession()` when the remote Streamable HTTP server exposes a session you want to terminate explicitly. Legacy SSE connections do not expose that method.
117
148
 
118
149
  The MCP TypeScript SDK v2 treats Streamable HTTP as the preferred remote transport and keeps SSE as a legacy fallback during migration. citeturn514654search0turn514654search6