@nemesis-oss/ollama-sdk 1.8.0 → 1.9.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.
- package/CHANGELOG.md +158 -0
- package/README.md +181 -10
- package/dist/{anthropic-B_UXplNF.d.ts → anthropic-5oYIRS6D.d.ts} +4 -2
- package/dist/{anthropic-CVDFy_a0.d.cts → anthropic-BIh45UXj.d.cts} +4 -2
- package/dist/{compose-DLStUfaF.d.ts → compose-DCVYMvOL.d.ts} +1 -1
- package/dist/{compose-DS-UWFx8.d.cts → compose-Dj6FdF2n.d.cts} +1 -1
- package/dist/generated-api.cjs +42 -3
- package/dist/generated-api.cjs.map +1 -1
- package/dist/generated-api.d.cts +96 -6
- package/dist/generated-api.d.ts +96 -6
- package/dist/generated-api.js +41 -4
- package/dist/generated-api.js.map +1 -1
- package/dist/generated-models-schemas.cjs +62 -2
- package/dist/generated-models-schemas.cjs.map +1 -1
- package/dist/generated-models-schemas.d.cts +108 -3
- package/dist/generated-models-schemas.d.ts +108 -3
- package/dist/generated-models-schemas.js +56 -3
- package/dist/generated-models-schemas.js.map +1 -1
- package/dist/generated-runtime.cjs +105 -5
- package/dist/generated-runtime.cjs.map +1 -1
- package/dist/generated-runtime.d.cts +2 -2
- package/dist/generated-runtime.d.ts +2 -2
- package/dist/generated-runtime.js +105 -5
- package/dist/generated-runtime.js.map +1 -1
- package/dist/index.cjs +1384 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1312 -14
- package/dist/index.d.ts +1312 -14
- package/dist/index.js +1352 -52
- package/dist/index.js.map +1 -1
- package/dist/mcp/tools.json +43 -24
- package/dist/mcp-generated.cjs +43 -1
- package/dist/mcp-generated.cjs.map +1 -1
- package/dist/mcp-generated.d.cts +2 -2
- package/dist/mcp-generated.d.ts +2 -2
- package/dist/mcp-generated.js +43 -1
- package/dist/mcp-generated.js.map +1 -1
- package/dist/{runtime-C6UYtBRB.d.ts → runtime-C3rfpkZw.d.ts} +69 -2
- package/dist/{runtime-DTmUeU6K.d.cts → runtime-D2W9TfCJ.d.cts} +69 -2
- package/dist/skills.cjs.map +1 -1
- package/dist/skills.d.cts +3 -3
- package/dist/skills.d.ts +3 -3
- package/dist/skills.js.map +1 -1
- package/dist/{types-5PAjLoCp.d.cts → types-DVcX_zMp.d.cts} +110 -10
- package/dist/{types-5PAjLoCp.d.ts → types-DVcX_zMp.d.ts} +110 -10
- package/package.json +8 -5
package/dist/skills.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.ts","../src/skills/frontmatter.ts","../src/skills/compose.ts","../src/skills/skill-registry.ts"],"names":[],"mappings":";;;;AA0BO,IAAM,iBAAA,GAAN,cAAgC,KAAA,CAAM;AAAA,EAClC,IAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EAET,WAAA,CAAY,SAAiB,OAAA,EAAmC;AAC9D,IAAA,KAAA,CAAM,OAAA,EAAS,EAAE,KAAA,EAAO,OAAA,CAAQ,OAAO,CAAA;AACvC,IAAA,IAAA,CAAK,IAAA,GAAO,KAAK,WAAA,CAAY,IAAA;AAC7B,IAAA,IAAA,CAAK,OAAO,OAAA,CAAQ,IAAA;AACpB,IAAA,IAAA,CAAK,SAAS,OAAA,CAAQ,MAAA;AACtB,IAAA,IAAA,CAAK,SAAA,GAAY,QAAQ,SAAA,IAAa,KAAA;AACtC,IAAA,IAAA,CAAK,UAAU,OAAA,CAAQ,OAAA;AACvB,IAAA,IAAA,CAAK,WAAW,OAAA,CAAQ,QAAA;AAAA,EAC1B;AACF,CAAA;AAqWO,IAAM,wBAAA,GAAN,cAAuC,iBAAA,CAAkB;AAAA,EACrD,SAAA;AAAA,EACT,WAAA,CACE,SACA,OAAA,EACA;AACA,IAAA,KAAA,CAAM,OAAA,EAAS,EAAE,GAAG,OAAA,EAAS,MAAM,iBAAA,EAAmB,SAAA,EAAW,OA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AAA,UAChC,IAAA,EAAM;AAAA,SACP,CAAA;AAAA,MACH,CAAA,CAAA,MAAQ;AAAA,MAER;AAAA,IACF;AAEA,IAAA,OAAO,SAAA;AAAA,EACT;AAAA,EAEA,MAAM,KAAK,IAAA,EAA8B;AACvC,IAAA,MAAM,SAAA,GAAY,IAAA,CAAK,IAAA,CAAK,SAAA,EAAW,MAAM,UAAU,CAAA;AACvD,IAAA,IAAI;AACF,MAAA,MAAM,OAAA,GAAU,MAAM,QAAA,CAAS,SAAA,EAAW,OAAO,CAAA;AACjD,MAAA,MAAM,MAAA,GAAS,gBAAA,CAAiB,OAAA,EAAS,SAAS,CAAA;AAClD,MAAA,OAAO;AAAA,QACL,IAAA,EAAM,OAAO,WAAA,CAAY,IAAA;AAAA,QACzB,WAAA,EAAa,OAAO,WAAA,CAAY,WAAA;AAAA,QAChC,IAAA,EAAM,SAAA;AAAA,QACN,aAAa,MAAA,CAAO,WAAA;AAAA,QACpB,MAAM,MAAA,CAAO,IAAA;AAAA,QACb,YAAA,EAAc,MAAA,CAAO,WAAA,CAAY,eAAe;AAAA,OAClD;AAAA,IACF,SAAS,GAAA,EAAK;AACZ,MAAA,MAAM,IAAI,wBAAA,CAAyB,CAAA,OAAA,EAAU,IAAI,CAAA,eAAA,EAAkB,SAAS,CAAA,CAAA,EAAI;AAAA,QAC9E,SAAA,EAAW,IAAA;AAAA,QACX,KAAA,EAAO;AAAA,OACR,CAAA;AAAA,IACH;AAAA,EACF;AACF","file":"skills.js","sourcesContent":["/**\n * Structured, typed error hierarchy for OllamaClient.\n */\n\nimport type { z } from 'zod';\n\nexport interface OllamaErrorRequestContext {\n readonly method?: string | undefined;\n readonly url?: string | undefined;\n readonly model?: string | undefined;\n}\n\nexport interface OllamaErrorResponseContext {\n readonly status?: number | undefined;\n readonly headers?: Record<string, string> | undefined;\n readonly body?: unknown;\n}\n\nexport interface OllamaClientErrorOptions extends ErrorOptions {\n readonly code: string;\n readonly status?: number | undefined;\n readonly retryable?: boolean | undefined;\n readonly request?: OllamaErrorRequestContext | undefined;\n readonly response?: OllamaErrorResponseContext | undefined;\n}\n\nexport class OllamaClientError extends Error {\n readonly code: string;\n readonly status?: number | undefined;\n readonly retryable: boolean;\n readonly request?: OllamaErrorRequestContext | undefined;\n readonly response?: OllamaErrorResponseContext | undefined;\n\n constructor(message: string, options: OllamaClientErrorOptions) {\n super(message, { cause: options.cause });\n this.name = this.constructor.name;\n this.code = options.code;\n this.status = options.status;\n this.retryable = options.retryable ?? false;\n this.request = options.request;\n this.response = options.response;\n }\n}\n\nexport class OllamaNetworkError extends OllamaClientError {\n constructor(\n message: string,\n options?: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> | undefined,\n ) {\n super(message, { ...options, code: 'network_error', retryable: true });\n }\n}\n\nexport class OllamaTimeoutError extends OllamaClientError {\n readonly timeoutMs?: number | undefined;\n constructor(\n message: string,\n options?:\n | (Omit<OllamaClientErrorOptions, 'code' | 'retryable'> & { timeoutMs?: number | undefined })\n | undefined,\n ) {\n super(message, { ...options, code: 'timeout', retryable: true });\n this.timeoutMs = options?.timeoutMs;\n }\n}\n\nexport class OllamaAuthError extends OllamaClientError {\n constructor(\n message: string,\n options?: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> | undefined,\n ) {\n super(message, { ...options, code: 'auth_error', retryable: false });\n }\n}\n\nexport class OllamaNotFoundError extends OllamaClientError {\n constructor(\n message: string,\n options?: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> | undefined,\n ) {\n super(message, { ...options, code: 'not_found', retryable: false });\n }\n}\n\nexport class OllamaRateLimitError extends OllamaClientError {\n readonly retryAfterMs?: number | undefined;\n constructor(\n message: string,\n options?:\n | (Omit<OllamaClientErrorOptions, 'code' | 'retryable'> & {\n retryAfterMs?: number | undefined;\n })\n | undefined,\n ) {\n super(message, { ...options, code: 'rate_limited', retryable: true });\n this.retryAfterMs = options?.retryAfterMs;\n }\n}\n\n/**\n * Thrown client-side, before a network request is made, by `QuotaManager.assertCanProceed`\n * (see `src/quota.ts`) when issuing the request would exceed a configured usage budget for\n * one of its rolling windows. This is distinct from `OllamaRateLimitError`, which reflects\n * the server's own 429 response — Ollama Cloud does not expose account-level quota via the\n * API, so `QuotaManager` tracks usage against budgets the caller configures locally and\n * fails fast rather than waiting for the server to reject the request.\n */\nexport class OllamaQuotaExceededError extends OllamaClientError {\n readonly windowId: string;\n readonly resetAt: number;\n constructor(\n message: string,\n options: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> & {\n windowId: string;\n resetAt: number;\n },\n ) {\n super(message, { ...options, code: 'quota_exceeded', retryable: false });\n this.windowId = options.windowId;\n this.resetAt = options.resetAt;\n }\n}\n\nexport class OllamaServerError extends OllamaClientError {\n constructor(\n message: string,\n options?: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> | undefined,\n ) {\n super(message, { ...options, code: 'server_error', retryable: true });\n }\n}\n\nexport class OllamaAbortError extends OllamaClientError {\n constructor(\n message: string,\n options?: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> | undefined,\n ) {\n super(message, { ...options, code: 'aborted', retryable: false });\n }\n}\n\nexport class OllamaToolValidationError extends OllamaClientError {\n readonly toolName: string;\n readonly issues?: unknown;\n constructor(\n message: string,\n options: Omit<OllamaClientErrorOptions, 'code'> & { toolName: string; issues?: unknown },\n ) {\n super(message, { ...options, code: 'tool_validation_error', retryable: false });\n this.toolName = options.toolName;\n this.issues = options.issues;\n }\n}\n\n/**\n * Thrown by `OllamaRuntime.invoke` when `validateRequests: true` is set and\n * the request body fails Zod validation against the operation's registered\n * schema. See ADR 0020 (runtime Zod validation).\n *\n * The error carries the original Zod issues so callers can inspect which\n * fields failed. No HTTP request is made when this error is thrown.\n */\nexport class OllamaRequestValidationError extends OllamaClientError {\n readonly operationId: string;\n readonly issues: readonly z.ZodIssue[];\n constructor(\n message: string,\n options: Omit<OllamaClientErrorOptions, 'code'> & {\n operationId: string;\n issues: readonly z.ZodIssue[];\n },\n ) {\n super(message, { ...options, code: 'request_validation_error', retryable: false });\n this.operationId = options.operationId;\n this.issues = options.issues;\n }\n}\n\n/**\n * Thrown by `OllamaRuntime.invoke` BEFORE any HTTP request is made when the\n * serialized request body exceeds the operation's declared\n * `constraints.maxRequestBytes`. The Ollama server returns 413 for such\n * payloads; this client-side check fails fast so the round-trip is avoided.\n *\n * Wave 12 (P0 #5): the IR has carried `maxRequestBytes` for System One\n * (64 KiB) since v1.7.0, but the runtime never enforced it. This closes\n * that contract/runtime gap.\n */\nexport class OllamaRequestTooLargeError extends OllamaClientError {\n readonly operationId: string;\n readonly actualBytes: number;\n readonly maxBytes: number;\n constructor(\n message: string,\n options: Omit<OllamaClientErrorOptions, 'code' | 'retryable' | 'status'> & {\n operationId: string;\n actualBytes: number;\n maxBytes: number;\n },\n ) {\n super(message, { ...options, code: 'request_too_large', retryable: false, status: 413 });\n this.operationId = options.operationId;\n this.actualBytes = options.actualBytes;\n this.maxBytes = options.maxBytes;\n }\n}\n\n/**\n * Thrown by `OllamaRuntime.invoke` AFTER the HTTP response is received\n * when `validateResponses: true` is set and the response body fails Zod\n * validation against the operation's registered response schema.\n *\n * Wave 13: the runtime previously never validated responses (see ADR\n * 0020). This opt-in error gives callers a way to detect wire-format\n * mismatches for operations where typed response semantics are critical\n * (e.g. System One). The error carries the original Zod issues so\n * callers can inspect which fields failed.\n */\nexport class OllamaResponseValidationError extends OllamaClientError {\n readonly operationId: string;\n readonly issues: readonly z.ZodIssue[];\n constructor(\n message: string,\n options: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> & {\n operationId: string;\n issues: readonly z.ZodIssue[];\n },\n ) {\n super(message, { ...options, code: 'response_validation_error', retryable: false });\n this.operationId = options.operationId;\n this.issues = options.issues;\n }\n}\n\n/**\n * Thrown by `OllamaRuntime.invoke` BEFORE any HTTP request is made when the\n * operation declares `constraints.minOllamaVersion` and the runtime could\n * not obtain a server version to compare against (e.g. `enforceVersion:\n * 'strict'` was set and `/api/version` was unreachable). Distinct from\n * {@link OllamaGenericClientError} so callers can branch on the failure\n * mode rather than parsing the message.\n */\nexport class OllamaServerVersionUnknownError extends OllamaClientError {\n readonly operationId: string;\n readonly minRequiredVersion: string;\n constructor(\n message: string,\n options: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> & {\n operationId: string;\n minRequiredVersion: string;\n },\n ) {\n super(message, { ...options, code: 'server_version_unknown', retryable: false });\n this.operationId = options.operationId;\n this.minRequiredVersion = options.minRequiredVersion;\n }\n}\n\nexport class OllamaToolTimeoutError extends OllamaClientError {\n readonly toolName: string;\n readonly timeoutMs: number;\n constructor(\n message: string,\n options: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> & {\n toolName: string;\n timeoutMs: number;\n },\n ) {\n super(message, { ...options, code: 'tool_timeout', retryable: false });\n this.toolName = options.toolName;\n this.timeoutMs = options.timeoutMs;\n }\n}\n\n/**\n * Thrown client-side, before a network request is made, when a request asks for a\n * capability an endpoint is known not to support (e.g. structured output `format` against\n * an Ollama Cloud endpoint — see `ModelCapabilities.supportsStructuredOutputRequest` in\n * `src/capabilities/capabilities.ts`). Its `code` is included in `DEFAULT_FAILOVER_CODES`\n * by default, so in a multi-endpoint setup it causes failover to the next candidate rather\n * than failing outright — it only surfaces to the caller if every candidate is rejected.\n */\nexport class OllamaUnsupportedCapabilityError extends OllamaClientError {\n readonly capability: string;\n constructor(\n message: string,\n options: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> & { capability: string },\n ) {\n super(message, { ...options, code: 'unsupported_capability', retryable: false });\n this.capability = options.capability;\n }\n}\n\n/**\n * Thrown client-side, before any network call, when `config.endpoints` uses\n * `OllamaEndpoint.models` to scope endpoints/credentials to specific models and the\n * requested `model` isn't in any configured endpoint's allow-list. This is a routing\n * misconfiguration, not a connectivity problem — the SDK deliberately does not \"probe\"\n * unauthorized endpoints to find one that happens to work (that would burn quota on keys\n * that were never entitled to the model and produce non-deterministic startup behavior).\n */\nexport class OllamaModelRoutingError extends OllamaClientError {\n readonly model: string;\n readonly availableModels: readonly string[];\n constructor(\n message: string,\n options: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> & {\n model: string;\n availableModels: readonly string[];\n },\n ) {\n super(message, { ...options, code: 'model_routing_error', retryable: false });\n this.model = options.model;\n this.availableModels = options.availableModels;\n }\n}\n\n/**\n * Thrown before an agent tool loop starts when the selected model's /api/show metadata\n * does not advertise a capability required by the loop.\n */\nexport class OllamaIncompatibleModelError extends OllamaClientError {\n readonly model: string;\n readonly capability: string;\n readonly reportedCapabilities: readonly string[];\n\n constructor(\n message: string,\n options: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> & {\n model: string;\n capability: string;\n reportedCapabilities: readonly string[];\n },\n ) {\n super(message, { ...options, code: 'incompatible_model', retryable: false });\n this.model = options.model;\n this.capability = options.capability;\n this.reportedCapabilities = options.reportedCapabilities;\n }\n}\nexport class OllamaAgentMaxToolCallsError extends OllamaClientError {\n readonly maxToolCalls: number;\n readonly toolCallsExecuted: number;\n\n constructor(\n message: string,\n options: Omit<OllamaClientErrorOptions, 'code'> & {\n maxToolCalls: number;\n toolCallsExecuted: number;\n },\n ) {\n super(message, { ...options, code: 'agent_max_tool_calls_exceeded', retryable: false });\n this.maxToolCalls = options.maxToolCalls;\n this.toolCallsExecuted = options.toolCallsExecuted;\n }\n}\n\nexport class OllamaAgentMaxIterationsError extends OllamaClientError {\n readonly maxIterations: number;\n constructor(\n message: string,\n options: Omit<OllamaClientErrorOptions, 'code'> & { maxIterations: number },\n ) {\n super(message, { ...options, code: 'agent_max_iterations_exceeded', retryable: false });\n this.maxIterations = options.maxIterations;\n }\n}\n\nexport class OllamaMcpError extends OllamaClientError {\n readonly mcpMethod:\n | 'listTools'\n | 'callTool'\n | 'tools/call'\n | 'tasks/get'\n | 'tasks/result'\n | 'tasks/cancel';\n readonly toolName?: string | undefined;\n readonly issues?: unknown;\n constructor(\n message: string,\n options: Omit<OllamaClientErrorOptions, 'code'> & {\n mcpMethod:\n | 'listTools'\n | 'callTool'\n | 'tools/call'\n | 'tasks/get'\n | 'tasks/result'\n | 'tasks/cancel';\n toolName?: string | undefined;\n issues?: unknown;\n },\n ) {\n super(message, { ...options, code: 'mcp_error', retryable: options.retryable ?? false });\n this.mcpMethod = options.mcpMethod;\n this.toolName = options.toolName;\n this.issues = options.issues;\n }\n}\n\nexport class OllamaSkillNotFoundError extends OllamaClientError {\n readonly skillName: string;\n constructor(\n message: string,\n options: Omit<OllamaClientErrorOptions, 'code'> & { skillName: string },\n ) {\n super(message, { ...options, code: 'skill_not_found', retryable: false });\n this.skillName = options.skillName;\n }\n}\n\nexport class OllamaSkillInvalidError extends OllamaClientError {\n readonly skillName: string;\n readonly path?: string | undefined;\n constructor(\n message: string,\n options: Omit<OllamaClientErrorOptions, 'code'> & {\n skillName: string;\n path?: string | undefined;\n },\n ) {\n super(message, { ...options, code: 'skill_invalid', retryable: false });\n this.skillName = options.skillName;\n this.path = options.path;\n }\n}\n\nexport class OllamaGenericClientError extends OllamaClientError {\n constructor(message: string, options?: Omit<OllamaClientErrorOptions, 'code'> | undefined) {\n super(message, { ...options, code: 'client_error' });\n }\n}\n\nfunction isDomAbortError(error: unknown): error is DOMException {\n return (\n typeof DOMException !== 'undefined' &&\n error instanceof DOMException &&\n error.name === 'AbortError'\n );\n}\n\nfunction statusToError(\n status: number,\n message: string,\n options: Omit<OllamaClientErrorOptions, 'code' | 'status'>,\n): OllamaClientError {\n if (status === 401 || status === 403) {\n return new OllamaAuthError(message, { ...options, status });\n }\n if (status === 404) {\n return new OllamaNotFoundError(message, { ...options, status });\n }\n if (status === 429) {\n return new OllamaRateLimitError(message, { ...options, status });\n }\n if (status >= 500) {\n return new OllamaServerError(message, { ...options, status });\n }\n return new OllamaGenericClientError(message, { ...options, status });\n}\n\n/**\n * Maps arbitrary thrown exceptions into structured OllamaClientError instances.\n */\nexport function mapError(\n error: unknown,\n context: {\n request?: OllamaErrorRequestContext | undefined;\n response?: OllamaErrorResponseContext | undefined;\n } = {},\n): OllamaClientError {\n if (error instanceof OllamaClientError) {\n return error;\n }\n if (isDomAbortError(error)) {\n return new OllamaAbortError(error.message || 'Request was aborted', {\n cause: error,\n request: context.request,\n });\n }\n if (error instanceof TypeError) {\n return new OllamaNetworkError(error.message || 'Network request failed', {\n cause: error,\n request: context.request,\n });\n }\n if (context.response?.status !== undefined) {\n const message = error instanceof Error ? error.message : String(error);\n return statusToError(context.response.status, message, {\n cause: error,\n request: context.request,\n response: context.response,\n });\n }\n const message = error instanceof Error ? error.message : String(error);\n return new OllamaGenericClientError(message, {\n cause: error,\n request: context.request,\n response: context.response,\n });\n}\n","/**\n * Lightweight frontmatter parser for SKILL.md files.\n */\n\nimport { OllamaSkillInvalidError } from '../errors.js';\nimport type { SkillFrontmatter } from './types.js';\n\nexport interface ParsedFrontmatter {\n readonly frontmatter: SkillFrontmatter;\n readonly body: string;\n}\n\nfunction parseYamlValue(raw: string): unknown {\n const trimmed = raw.trim();\n if (trimmed === 'true') return true;\n if (trimmed === 'false') return false;\n if (!Number.isNaN(Number(trimmed)) && trimmed !== '') return Number(trimmed);\n if (\n (trimmed.startsWith('\"') && trimmed.endsWith('\"')) ||\n (trimmed.startsWith(\"'\") && trimmed.endsWith(\"'\"))\n ) {\n return trimmed.slice(1, -1);\n }\n return trimmed;\n}\n\nfunction parseYamlBlock(yamlText: string): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n const lines = yamlText.split('\\n');\n let currentKey: string | undefined;\n let currentList: unknown[] | undefined;\n\n for (const line of lines) {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith('#')) continue;\n\n if (trimmed.startsWith('- ') && currentKey) {\n if (!currentList) {\n currentList = [];\n result[currentKey] = currentList;\n }\n currentList.push(parseYamlValue(trimmed.slice(2)));\n continue;\n }\n\n currentList = undefined;\n const colonIndex = line.indexOf(':');\n if (colonIndex > 0) {\n const key = line.slice(0, colonIndex).trim();\n const valStr = line.slice(colonIndex + 1).trim();\n currentKey = key;\n if (valStr.length > 0) {\n result[key] = parseYamlValue(valStr);\n }\n }\n }\n\n return result;\n}\n\nexport function parseFrontmatter(source: string, path = ''): ParsedFrontmatter {\n const match = source.match(/^---\\r?\\n([\\s\\S]*?)\\r?\\n---\\r?\\n?([\\s\\S]*)$/);\n if (!match) {\n throw new OllamaSkillInvalidError('Missing YAML frontmatter delimiters (---)', {\n skillName: path || 'unknown',\n path,\n });\n }\n\n const rawYaml = match[1] ?? '';\n const body = match[2]?.trim() ?? '';\n const parsed = parseYamlBlock(rawYaml);\n\n if (!parsed['name'] || typeof parsed['name'] !== 'string') {\n throw new OllamaSkillInvalidError('Frontmatter missing required string \"name\"', {\n skillName: String(parsed['name'] ?? 'unknown'),\n path,\n });\n }\n if (!parsed['description'] || typeof parsed['description'] !== 'string') {\n throw new OllamaSkillInvalidError('Frontmatter missing required string \"description\"', {\n skillName: parsed['name'],\n path,\n });\n }\n\n return {\n frontmatter: parsed as unknown as SkillFrontmatter,\n body,\n };\n}\n","/**\n * Skill composition and context injection.\n */\n\nimport type { Message } from '../types.js';\nimport type { ToolRegistry } from '../tools/registry.js';\nimport type { Skill } from './types.js';\n\nexport interface ApplySkillOptions {\n readonly messages: readonly Message[];\n readonly tools?: ToolRegistry;\n}\n\nexport interface AppliedSkillResult {\n readonly messages: readonly Message[];\n readonly tools?: ToolRegistry;\n}\n\n/**\n * Injects a skill's body into messages as a system prompt and applies allowed tool filters.\n */\nexport function applySkill(skill: Skill, options: ApplySkillOptions): AppliedSkillResult {\n const systemPrompt = `[Skill: ${skill.name}]\\n${skill.description}\\n\\n${skill.body}`;\n const messages = [...options.messages];\n const systemIndex = messages.findIndex((m) => m.role === 'system');\n\n if (systemIndex >= 0) {\n const existing = messages[systemIndex];\n if (existing) {\n messages[systemIndex] = {\n role: 'system',\n content: `${existing.content}\\n\\n${systemPrompt}`,\n };\n }\n } else {\n messages.unshift({ role: 'system', content: systemPrompt });\n }\n\n return {\n messages,\n ...(options.tools !== undefined ? { tools: options.tools } : {}),\n };\n}\n","/**\n * Node.js filesystem skill registry for SKILL.md packages.\n */\n\nimport { readdir, readFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { OllamaSkillNotFoundError } from '../errors.js';\nimport { parseFrontmatter } from './frontmatter.js';\nimport type { Skill, SkillSummary } from './types.js';\n\nexport interface SkillRegistryOptions {\n readonly directory: string;\n}\n\nexport class SkillRegistry {\n readonly directory: string;\n\n constructor(options: SkillRegistryOptions) {\n this.directory = options.directory;\n }\n\n async list(): Promise<SkillSummary[]> {\n const entries = await readdir(this.directory, { withFileTypes: true });\n const summaries: SkillSummary[] = [];\n\n for (const entry of entries) {\n if (!entry.isDirectory()) continue;\n const skillPath = join(this.directory, entry.name, 'SKILL.md');\n try {\n const content = await readFile(skillPath, 'utf-8');\n const parsed = parseFrontmatter(content, skillPath);\n summaries.push({\n name: parsed.frontmatter.name,\n description: parsed.frontmatter.description,\n path: skillPath,\n });\n } catch {\n // Skip directories without valid SKILL.md\n }\n }\n\n return summaries;\n }\n\n async load(name: string): Promise<Skill> {\n const skillPath = join(this.directory, name, 'SKILL.md');\n try {\n const content = await readFile(skillPath, 'utf-8');\n const parsed = parseFrontmatter(content, skillPath);\n return {\n name: parsed.frontmatter.name,\n description: parsed.frontmatter.description,\n path: skillPath,\n frontmatter: parsed.frontmatter,\n body: parsed.body,\n allowedTools: parsed.frontmatter['allowed-tools'],\n };\n } catch (err) {\n throw new OllamaSkillNotFoundError(`Skill \"${name}\" not found at ${skillPath}`, {\n skillName: name,\n cause: err,\n });\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/skills/frontmatter.ts","../src/skills/compose.ts","../src/skills/skill-registry.ts"],"names":[],"mappings":";;;;AA0BO,IAAM,iBAAA,GAAN,cAAgC,KAAA,CAAM;AAAA,EAClC,IAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EAET,WAAA,CAAY,SAAiB,OAAA,EAAmC;AAC9D,IAAA,KAAA,C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AA,EAAc,MAAA,CAAO,WAAA,CAAY,eAAe;AAAA,OAClD;AAAA,IACF,SAAS,GAAA,EAAK;AACZ,MAAA,MAAM,IAAI,wBAAA,CAAyB,CAAA,OAAA,EAAU,IAAI,CAAA,eAAA,EAAkB,SAAS,CAAA,CAAA,EAAI;AAAA,QAC9E,SAAA,EAAW,IAAA;AAAA,QACX,KAAA,EAAO;AAAA,OACR,CAAA;AAAA,IACH;AAAA,EACF;AACF","file":"skills.js","sourcesContent":["/**\n * Structured, typed error hierarchy for OllamaClient.\n */\n\nimport type { z } from 'zod';\n\nexport interface OllamaErrorRequestContext {\n readonly method?: string | undefined;\n readonly url?: string | undefined;\n readonly model?: string | undefined;\n}\n\nexport interface OllamaErrorResponseContext {\n readonly status?: number | undefined;\n readonly headers?: Record<string, string> | undefined;\n readonly body?: unknown;\n}\n\nexport interface OllamaClientErrorOptions extends ErrorOptions {\n readonly code: string;\n readonly status?: number | undefined;\n readonly retryable?: boolean | undefined;\n readonly request?: OllamaErrorRequestContext | undefined;\n readonly response?: OllamaErrorResponseContext | undefined;\n}\n\nexport class OllamaClientError extends Error {\n readonly code: string;\n readonly status?: number | undefined;\n readonly retryable: boolean;\n readonly request?: OllamaErrorRequestContext | undefined;\n readonly response?: OllamaErrorResponseContext | undefined;\n\n constructor(message: string, options: OllamaClientErrorOptions) {\n super(message, { cause: options.cause });\n this.name = this.constructor.name;\n this.code = options.code;\n this.status = options.status;\n this.retryable = options.retryable ?? false;\n this.request = options.request;\n this.response = options.response;\n }\n}\n\nexport class OllamaNetworkError extends OllamaClientError {\n constructor(\n message: string,\n options?: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> | undefined,\n ) {\n super(message, { ...options, code: 'network_error', retryable: true });\n }\n}\n\nexport class OllamaTimeoutError extends OllamaClientError {\n readonly timeoutMs?: number | undefined;\n constructor(\n message: string,\n options?:\n | (Omit<OllamaClientErrorOptions, 'code' | 'retryable'> & { timeoutMs?: number | undefined })\n | undefined,\n ) {\n super(message, { ...options, code: 'timeout', retryable: true });\n this.timeoutMs = options?.timeoutMs;\n }\n}\n\nexport class OllamaAuthError extends OllamaClientError {\n constructor(\n message: string,\n options?: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> | undefined,\n ) {\n super(message, { ...options, code: 'auth_error', retryable: false });\n }\n}\n\nexport class OllamaNotFoundError extends OllamaClientError {\n constructor(\n message: string,\n options?: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> | undefined,\n ) {\n super(message, { ...options, code: 'not_found', retryable: false });\n }\n}\n\nexport class OllamaRateLimitError extends OllamaClientError {\n readonly retryAfterMs?: number | undefined;\n constructor(\n message: string,\n options?:\n | (Omit<OllamaClientErrorOptions, 'code' | 'retryable'> & {\n retryAfterMs?: number | undefined;\n })\n | undefined,\n ) {\n super(message, { ...options, code: 'rate_limited', retryable: true });\n this.retryAfterMs = options?.retryAfterMs;\n }\n}\n\n/**\n * Thrown client-side, before a network request is made, by `QuotaManager.assertCanProceed`\n * (see `src/quota.ts`) when issuing the request would exceed a configured usage budget for\n * one of its rolling windows. This is distinct from `OllamaRateLimitError`, which reflects\n * the server's own 429 response — Ollama Cloud does not expose account-level quota via the\n * API, so `QuotaManager` tracks usage against budgets the caller configures locally and\n * fails fast rather than waiting for the server to reject the request.\n */\nexport class OllamaQuotaExceededError extends OllamaClientError {\n readonly windowId: string;\n readonly resetAt: number;\n constructor(\n message: string,\n options: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> & {\n windowId: string;\n resetAt: number;\n },\n ) {\n super(message, { ...options, code: 'quota_exceeded', retryable: false });\n this.windowId = options.windowId;\n this.resetAt = options.resetAt;\n }\n}\n\nexport class OllamaServerError extends OllamaClientError {\n constructor(\n message: string,\n options?: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> | undefined,\n ) {\n super(message, { ...options, code: 'server_error', retryable: true });\n }\n}\n\n/**\n * Thrown when the Ollama server returns HTTP **503 Service Unavailable**,\n * indicating that the request queue is saturated (`OLLAMA_MAX_QUEUE`\n * exceeded, default 512 — see the FAQ).\n *\n * Semantically a specialization of {@link OllamaServerError} (503 is a\n * kind of 5xx server error), but extends {@link OllamaClientError}\n * directly to preserve the subclass-specific `code: 'overloaded'` —\n * `OllamaServerError`'s constructor unconditionally forces\n * `code: 'server_error'`. Callers wanting to catch any 5xx should\n * use `error.status >= 500 && error.status < 600` OR explicitly\n * list both `OllamaServerError` and `OllamaOverloadedError`/\n * `OllamaBadGatewayError` in their `instanceof` checks.\n *\n * `retryable` is `true` because the queue will eventually drain;\n * callers using {@link withRetry} will get automatic backoff.\n */\nexport class OllamaOverloadedError extends OllamaClientError {\n constructor(\n message: string,\n options?: Omit<OllamaClientErrorOptions, 'code' | 'retryable' | 'status'> | undefined,\n ) {\n super(message, { ...options, code: 'overloaded', status: 503, retryable: true });\n }\n}\n\n/**\n * Thrown when the Ollama server returns HTTP **502 Bad Gateway**,\n * indicating that a cloud model could not be reached by the\n * Ollama Cloud proxy. The model may be temporarily down, the\n * cloud provider may be experiencing an outage, or the model\n * may have been deprovisioned.\n *\n * Semantically a specialization of {@link OllamaServerError} (502 is a\n * kind of 5xx server error), but extends {@link OllamaClientError}\n * directly to preserve the subclass-specific `code: 'bad_gateway'` —\n * see {@link OllamaOverloadedError} for the rationale. Callers wanting\n * to catch any 5xx should use `error.status >= 500 && error.status < 600`\n * OR explicitly list both classes in their `instanceof` checks.\n *\n * `retryable` is `true` for transient cloud-provider outages.\n */\nexport class OllamaBadGatewayError extends OllamaClientError {\n constructor(\n message: string,\n options?: Omit<OllamaClientErrorOptions, 'code' | 'retryable' | 'status'> | undefined,\n ) {\n super(message, { ...options, code: 'bad_gateway', status: 502, retryable: true });\n }\n}\n\n/**\n * Thrown when the Ollama server emits an in-band error frame inside\n * an NDJSON stream (chat / generate / pull / push / create).\n *\n * Ollama streams start with HTTP 200 OK and chunked transfer encoding.\n * If an error occurs mid-generation (GPU OOM, driver crash, context\n * window overflow, model unload race, etc.), the server emits a final\n * JSON chunk of the form `{\"error\": \"...\"}` and closes the stream.\n * The HTTP status code never changes from 200, so HTTP-status-based\n * error detection misses these errors entirely — they would silently\n * bleed into the assistant's content stream as garbage tokens or\n * undefined-field accesses.\n *\n * `partialContent` carries whatever was accumulated before the error\n * frame, so callers can log/diagnose what the model produced before\n * failing. For chat streams this is the concatenated `message.content`;\n * for generate streams it's the concatenated `response`; for pull/push\n * streams it's empty (progress events don't accumulate content).\n *\n * See: https://github.com/ollama/ollama/blob/main/docs/api.md\n */\nexport class OllamaStreamError extends OllamaClientError {\n /** Content accumulated before the in-band error frame, or '' if none. */\n readonly partialContent: string;\n constructor(\n message: string,\n options?: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> & {\n partialContent?: string | undefined;\n },\n ) {\n super(message, { ...options, code: 'stream_error', retryable: false });\n this.partialContent = options?.partialContent ?? '';\n }\n}\n\nexport class OllamaAbortError extends OllamaClientError {\n constructor(\n message: string,\n options?: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> | undefined,\n ) {\n super(message, { ...options, code: 'aborted', retryable: false });\n }\n}\n\nexport class OllamaToolValidationError extends OllamaClientError {\n readonly toolName: string;\n readonly issues?: unknown;\n constructor(\n message: string,\n options: Omit<OllamaClientErrorOptions, 'code'> & { toolName: string; issues?: unknown },\n ) {\n super(message, { ...options, code: 'tool_validation_error', retryable: false });\n this.toolName = options.toolName;\n this.issues = options.issues;\n }\n}\n\n/**\n * Thrown by `OllamaRuntime.invoke` when `validateRequests: true` is set and\n * the request body fails Zod validation against the operation's registered\n * schema. See ADR 0020 (runtime Zod validation).\n *\n * The error carries the original Zod issues so callers can inspect which\n * fields failed. No HTTP request is made when this error is thrown.\n */\nexport class OllamaRequestValidationError extends OllamaClientError {\n readonly operationId: string;\n readonly issues: readonly z.ZodIssue[];\n constructor(\n message: string,\n options: Omit<OllamaClientErrorOptions, 'code'> & {\n operationId: string;\n issues: readonly z.ZodIssue[];\n },\n ) {\n super(message, { ...options, code: 'request_validation_error', retryable: false });\n this.operationId = options.operationId;\n this.issues = options.issues;\n }\n}\n\n/**\n * Thrown by `OllamaRuntime.invoke` BEFORE any HTTP request is made when the\n * serialized request body exceeds the operation's declared\n * `constraints.maxRequestBytes`. The Ollama server returns 413 for such\n * payloads; this client-side check fails fast so the round-trip is avoided.\n *\n * Wave 12 (P0 #5): the IR has carried `maxRequestBytes` for System One\n * (64 KiB) since v1.7.0, but the runtime never enforced it. This closes\n * that contract/runtime gap.\n */\nexport class OllamaRequestTooLargeError extends OllamaClientError {\n readonly operationId: string;\n readonly actualBytes: number;\n readonly maxBytes: number;\n constructor(\n message: string,\n options: Omit<OllamaClientErrorOptions, 'code' | 'retryable' | 'status'> & {\n operationId: string;\n actualBytes: number;\n maxBytes: number;\n },\n ) {\n super(message, { ...options, code: 'request_too_large', retryable: false, status: 413 });\n this.operationId = options.operationId;\n this.actualBytes = options.actualBytes;\n this.maxBytes = options.maxBytes;\n }\n}\n\n/**\n * Thrown by `OllamaRuntime.invoke` AFTER the HTTP response is received\n * when `validateResponses: true` is set and the response body fails Zod\n * validation against the operation's registered response schema.\n *\n * Wave 13: the runtime previously never validated responses (see ADR\n * 0020). This opt-in error gives callers a way to detect wire-format\n * mismatches for operations where typed response semantics are critical\n * (e.g. System One). The error carries the original Zod issues so\n * callers can inspect which fields failed.\n */\nexport class OllamaResponseValidationError extends OllamaClientError {\n readonly operationId: string;\n readonly issues: readonly z.ZodIssue[];\n constructor(\n message: string,\n options: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> & {\n operationId: string;\n issues: readonly z.ZodIssue[];\n },\n ) {\n super(message, { ...options, code: 'response_validation_error', retryable: false });\n this.operationId = options.operationId;\n this.issues = options.issues;\n }\n}\n\n/**\n * Thrown by `OllamaRuntime.invoke` BEFORE any HTTP request is made when the\n * operation declares `constraints.minOllamaVersion` and the runtime could\n * not obtain a server version to compare against (e.g. `enforceVersion:\n * 'strict'` was set and `/api/version` was unreachable). Distinct from\n * {@link OllamaGenericClientError} so callers can branch on the failure\n * mode rather than parsing the message.\n */\nexport class OllamaServerVersionUnknownError extends OllamaClientError {\n readonly operationId: string;\n readonly minRequiredVersion: string;\n constructor(\n message: string,\n options: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> & {\n operationId: string;\n minRequiredVersion: string;\n },\n ) {\n super(message, { ...options, code: 'server_version_unknown', retryable: false });\n this.operationId = options.operationId;\n this.minRequiredVersion = options.minRequiredVersion;\n }\n}\n\nexport class OllamaToolTimeoutError extends OllamaClientError {\n readonly toolName: string;\n readonly timeoutMs: number;\n constructor(\n message: string,\n options: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> & {\n toolName: string;\n timeoutMs: number;\n },\n ) {\n super(message, { ...options, code: 'tool_timeout', retryable: false });\n this.toolName = options.toolName;\n this.timeoutMs = options.timeoutMs;\n }\n}\n\n/**\n * Thrown client-side, before a network request is made, when a request asks for a\n * capability an endpoint is known not to support (e.g. structured output `format` against\n * an Ollama Cloud endpoint — see `ModelCapabilities.supportsStructuredOutputRequest` in\n * `src/capabilities/capabilities.ts`). Its `code` is included in `DEFAULT_FAILOVER_CODES`\n * by default, so in a multi-endpoint setup it causes failover to the next candidate rather\n * than failing outright — it only surfaces to the caller if every candidate is rejected.\n */\nexport class OllamaUnsupportedCapabilityError extends OllamaClientError {\n readonly capability: string;\n constructor(\n message: string,\n options: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> & { capability: string },\n ) {\n super(message, { ...options, code: 'unsupported_capability', retryable: false });\n this.capability = options.capability;\n }\n}\n\n/**\n * Thrown client-side, before any network call, when `config.endpoints` uses\n * `OllamaEndpoint.models` to scope endpoints/credentials to specific models and the\n * requested `model` isn't in any configured endpoint's allow-list. This is a routing\n * misconfiguration, not a connectivity problem — the SDK deliberately does not \"probe\"\n * unauthorized endpoints to find one that happens to work (that would burn quota on keys\n * that were never entitled to the model and produce non-deterministic startup behavior).\n */\nexport class OllamaModelRoutingError extends OllamaClientError {\n readonly model: string;\n readonly availableModels: readonly string[];\n constructor(\n message: string,\n options: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> & {\n model: string;\n availableModels: readonly string[];\n },\n ) {\n super(message, { ...options, code: 'model_routing_error', retryable: false });\n this.model = options.model;\n this.availableModels = options.availableModels;\n }\n}\n\n/**\n * Thrown before an agent tool loop starts when the selected model's /api/show metadata\n * does not advertise a capability required by the loop.\n */\nexport class OllamaIncompatibleModelError extends OllamaClientError {\n readonly model: string;\n readonly capability: string;\n readonly reportedCapabilities: readonly string[];\n\n constructor(\n message: string,\n options: Omit<OllamaClientErrorOptions, 'code' | 'retryable'> & {\n model: string;\n capability: string;\n reportedCapabilities: readonly string[];\n },\n ) {\n super(message, { ...options, code: 'incompatible_model', retryable: false });\n this.model = options.model;\n this.capability = options.capability;\n this.reportedCapabilities = options.reportedCapabilities;\n }\n}\nexport class OllamaAgentMaxToolCallsError extends OllamaClientError {\n readonly maxToolCalls: number;\n readonly toolCallsExecuted: number;\n\n constructor(\n message: string,\n options: Omit<OllamaClientErrorOptions, 'code'> & {\n maxToolCalls: number;\n toolCallsExecuted: number;\n },\n ) {\n super(message, { ...options, code: 'agent_max_tool_calls_exceeded', retryable: false });\n this.maxToolCalls = options.maxToolCalls;\n this.toolCallsExecuted = options.toolCallsExecuted;\n }\n}\n\nexport class OllamaAgentMaxIterationsError extends OllamaClientError {\n readonly maxIterations: number;\n constructor(\n message: string,\n options: Omit<OllamaClientErrorOptions, 'code'> & { maxIterations: number },\n ) {\n super(message, { ...options, code: 'agent_max_iterations_exceeded', retryable: false });\n this.maxIterations = options.maxIterations;\n }\n}\n\nexport class OllamaMcpError extends OllamaClientError {\n readonly mcpMethod:\n | 'listTools'\n | 'callTool'\n | 'tools/call'\n | 'tasks/get'\n | 'tasks/result'\n | 'tasks/cancel';\n readonly toolName?: string | undefined;\n readonly issues?: unknown;\n constructor(\n message: string,\n options: Omit<OllamaClientErrorOptions, 'code'> & {\n mcpMethod:\n | 'listTools'\n | 'callTool'\n | 'tools/call'\n | 'tasks/get'\n | 'tasks/result'\n | 'tasks/cancel';\n toolName?: string | undefined;\n issues?: unknown;\n },\n ) {\n super(message, { ...options, code: 'mcp_error', retryable: options.retryable ?? false });\n this.mcpMethod = options.mcpMethod;\n this.toolName = options.toolName;\n this.issues = options.issues;\n }\n}\n\nexport class OllamaSkillNotFoundError extends OllamaClientError {\n readonly skillName: string;\n constructor(\n message: string,\n options: Omit<OllamaClientErrorOptions, 'code'> & { skillName: string },\n ) {\n super(message, { ...options, code: 'skill_not_found', retryable: false });\n this.skillName = options.skillName;\n }\n}\n\nexport class OllamaSkillInvalidError extends OllamaClientError {\n readonly skillName: string;\n readonly path?: string | undefined;\n constructor(\n message: string,\n options: Omit<OllamaClientErrorOptions, 'code'> & {\n skillName: string;\n path?: string | undefined;\n },\n ) {\n super(message, { ...options, code: 'skill_invalid', retryable: false });\n this.skillName = options.skillName;\n this.path = options.path;\n }\n}\n\nexport class OllamaGenericClientError extends OllamaClientError {\n constructor(message: string, options?: Omit<OllamaClientErrorOptions, 'code'> | undefined) {\n super(message, { ...options, code: 'client_error' });\n }\n}\n\nfunction isDomAbortError(error: unknown): error is DOMException {\n return (\n typeof DOMException !== 'undefined' &&\n error instanceof DOMException &&\n error.name === 'AbortError'\n );\n}\n\nfunction statusToError(\n status: number,\n message: string,\n options: Omit<OllamaClientErrorOptions, 'code' | 'status'>,\n): OllamaClientError {\n if (status === 401 || status === 403) {\n return new OllamaAuthError(message, { ...options, status });\n }\n if (status === 404) {\n return new OllamaNotFoundError(message, { ...options, status });\n }\n if (status === 429) {\n return new OllamaRateLimitError(message, { ...options, status });\n }\n if (status === 502) {\n // Cloud model could not be reached. Distinct from generic 5xx so\n // callers running multi-model agents can branch on cloud-provider\n // failures specifically (fail over to a different model/endpoint\n // rather than blindly retrying the same one).\n return new OllamaBadGatewayError(message, { ...options });\n }\n if (status === 503) {\n // Queue saturation (OLLAMA_MAX_QUEUE exceeded). Retryable — the\n // queue will eventually drain. Distinct from generic 5xx so\n // callers running parallel swarms can branch on saturation.\n return new OllamaOverloadedError(message, { ...options });\n }\n if (status >= 500) {\n return new OllamaServerError(message, { ...options, status });\n }\n return new OllamaGenericClientError(message, { ...options, status });\n}\n\n/**\n * Maps arbitrary thrown exceptions into structured OllamaClientError instances.\n */\nexport function mapError(\n error: unknown,\n context: {\n request?: OllamaErrorRequestContext | undefined;\n response?: OllamaErrorResponseContext | undefined;\n } = {},\n): OllamaClientError {\n if (error instanceof OllamaClientError) {\n return error;\n }\n if (isDomAbortError(error)) {\n return new OllamaAbortError(error.message || 'Request was aborted', {\n cause: error,\n request: context.request,\n });\n }\n if (error instanceof TypeError) {\n return new OllamaNetworkError(error.message || 'Network request failed', {\n cause: error,\n request: context.request,\n });\n }\n if (context.response?.status !== undefined) {\n const message = error instanceof Error ? error.message : String(error);\n return statusToError(context.response.status, message, {\n cause: error,\n request: context.request,\n response: context.response,\n });\n }\n const message = error instanceof Error ? error.message : String(error);\n return new OllamaGenericClientError(message, {\n cause: error,\n request: context.request,\n response: context.response,\n });\n}\n","/**\n * Lightweight frontmatter parser for SKILL.md files.\n */\n\nimport { OllamaSkillInvalidError } from '../errors.js';\nimport type { SkillFrontmatter } from './types.js';\n\nexport interface ParsedFrontmatter {\n readonly frontmatter: SkillFrontmatter;\n readonly body: string;\n}\n\nfunction parseYamlValue(raw: string): unknown {\n const trimmed = raw.trim();\n if (trimmed === 'true') return true;\n if (trimmed === 'false') return false;\n if (!Number.isNaN(Number(trimmed)) && trimmed !== '') return Number(trimmed);\n if (\n (trimmed.startsWith('\"') && trimmed.endsWith('\"')) ||\n (trimmed.startsWith(\"'\") && trimmed.endsWith(\"'\"))\n ) {\n return trimmed.slice(1, -1);\n }\n return trimmed;\n}\n\nfunction parseYamlBlock(yamlText: string): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n const lines = yamlText.split('\\n');\n let currentKey: string | undefined;\n let currentList: unknown[] | undefined;\n\n for (const line of lines) {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith('#')) continue;\n\n if (trimmed.startsWith('- ') && currentKey) {\n if (!currentList) {\n currentList = [];\n result[currentKey] = currentList;\n }\n currentList.push(parseYamlValue(trimmed.slice(2)));\n continue;\n }\n\n currentList = undefined;\n const colonIndex = line.indexOf(':');\n if (colonIndex > 0) {\n const key = line.slice(0, colonIndex).trim();\n const valStr = line.slice(colonIndex + 1).trim();\n currentKey = key;\n if (valStr.length > 0) {\n result[key] = parseYamlValue(valStr);\n }\n }\n }\n\n return result;\n}\n\nexport function parseFrontmatter(source: string, path = ''): ParsedFrontmatter {\n const match = source.match(/^---\\r?\\n([\\s\\S]*?)\\r?\\n---\\r?\\n?([\\s\\S]*)$/);\n if (!match) {\n throw new OllamaSkillInvalidError('Missing YAML frontmatter delimiters (---)', {\n skillName: path || 'unknown',\n path,\n });\n }\n\n const rawYaml = match[1] ?? '';\n const body = match[2]?.trim() ?? '';\n const parsed = parseYamlBlock(rawYaml);\n\n if (!parsed['name'] || typeof parsed['name'] !== 'string') {\n throw new OllamaSkillInvalidError('Frontmatter missing required string \"name\"', {\n skillName: String(parsed['name'] ?? 'unknown'),\n path,\n });\n }\n if (!parsed['description'] || typeof parsed['description'] !== 'string') {\n throw new OllamaSkillInvalidError('Frontmatter missing required string \"description\"', {\n skillName: parsed['name'],\n path,\n });\n }\n\n return {\n frontmatter: parsed as unknown as SkillFrontmatter,\n body,\n };\n}\n","/**\n * Skill composition and context injection.\n */\n\nimport type { Message } from '../types.js';\nimport type { ToolRegistry } from '../tools/registry.js';\nimport type { Skill } from './types.js';\n\nexport interface ApplySkillOptions {\n readonly messages: readonly Message[];\n readonly tools?: ToolRegistry;\n}\n\nexport interface AppliedSkillResult {\n readonly messages: readonly Message[];\n readonly tools?: ToolRegistry;\n}\n\n/**\n * Injects a skill's body into messages as a system prompt and applies allowed tool filters.\n */\nexport function applySkill(skill: Skill, options: ApplySkillOptions): AppliedSkillResult {\n const systemPrompt = `[Skill: ${skill.name}]\\n${skill.description}\\n\\n${skill.body}`;\n const messages = [...options.messages];\n const systemIndex = messages.findIndex((m) => m.role === 'system');\n\n if (systemIndex >= 0) {\n const existing = messages[systemIndex];\n if (existing) {\n messages[systemIndex] = {\n role: 'system',\n content: `${existing.content}\\n\\n${systemPrompt}`,\n };\n }\n } else {\n messages.unshift({ role: 'system', content: systemPrompt });\n }\n\n return {\n messages,\n ...(options.tools !== undefined ? { tools: options.tools } : {}),\n };\n}\n","/**\n * Node.js filesystem skill registry for SKILL.md packages.\n */\n\nimport { readdir, readFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { OllamaSkillNotFoundError } from '../errors.js';\nimport { parseFrontmatter } from './frontmatter.js';\nimport type { Skill, SkillSummary } from './types.js';\n\nexport interface SkillRegistryOptions {\n readonly directory: string;\n}\n\nexport class SkillRegistry {\n readonly directory: string;\n\n constructor(options: SkillRegistryOptions) {\n this.directory = options.directory;\n }\n\n async list(): Promise<SkillSummary[]> {\n const entries = await readdir(this.directory, { withFileTypes: true });\n const summaries: SkillSummary[] = [];\n\n for (const entry of entries) {\n if (!entry.isDirectory()) continue;\n const skillPath = join(this.directory, entry.name, 'SKILL.md');\n try {\n const content = await readFile(skillPath, 'utf-8');\n const parsed = parseFrontmatter(content, skillPath);\n summaries.push({\n name: parsed.frontmatter.name,\n description: parsed.frontmatter.description,\n path: skillPath,\n });\n } catch {\n // Skip directories without valid SKILL.md\n }\n }\n\n return summaries;\n }\n\n async load(name: string): Promise<Skill> {\n const skillPath = join(this.directory, name, 'SKILL.md');\n try {\n const content = await readFile(skillPath, 'utf-8');\n const parsed = parseFrontmatter(content, skillPath);\n return {\n name: parsed.frontmatter.name,\n description: parsed.frontmatter.description,\n path: skillPath,\n frontmatter: parsed.frontmatter,\n body: parsed.body,\n allowedTools: parsed.frontmatter['allowed-tools'],\n };\n } catch (err) {\n throw new OllamaSkillNotFoundError(`Skill \"${name}\" not found at ${skillPath}`, {\n skillName: name,\n cause: err,\n });\n }\n }\n}\n"]}
|
|
@@ -1,6 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Universal vision asset resolution — the SDK-side half of Ollama's documented
|
|
3
|
+
* vision ingestion convention.
|
|
4
|
+
*
|
|
5
|
+
* Ollama's REST API strictly requires raw base64 strings in the `images`
|
|
6
|
+
* arrays of `/api/chat` and `/api/generate` (no `data:image/...;base64,` URI
|
|
7
|
+
* prefixes). The official SDKs, however, are expected to accept polymorphic
|
|
8
|
+
* image sources — local file paths, web URLs, or raw byte buffers — and
|
|
9
|
+
* normalize them to that wire format on the caller's behalf. This module is
|
|
10
|
+
* that normalization layer for this SDK.
|
|
11
|
+
*
|
|
12
|
+
* Resolution order for `string` inputs:
|
|
13
|
+
*
|
|
14
|
+
* 1. `data:image/...;base64,` data URIs — the header is stripped, the
|
|
15
|
+
* payload passed through.
|
|
16
|
+
* 2. `http://` / `https://` URLs — fetched with the platform's global
|
|
17
|
+
* `fetch`, then base64-encoded.
|
|
18
|
+
* 3. Strings with a known image file extension (`.png`, `.jpg`, `.webp`,
|
|
19
|
+
* ...) — treated as a local file path and read via a *dynamically
|
|
20
|
+
* imported* `node:fs` (Node.js only). If the read fails, the string is
|
|
21
|
+
* passed through unchanged (it may have been a base64 payload that
|
|
22
|
+
* happened to end in an image-like suffix — rare, but the safe
|
|
23
|
+
* fallback). In browsers/edge runtimes, where `node:fs` does not exist,
|
|
24
|
+
* a path-shaped string throws a descriptive error instead of silently
|
|
25
|
+
* shipping garbage to the server.
|
|
26
|
+
* 4. Anything else — assumed to already be raw base64 and passed through.
|
|
27
|
+
*
|
|
28
|
+
* `Buffer` and `Uint8Array` inputs are base64-encoded via the runtime's
|
|
29
|
+
* universal base64 primitive (`Buffer` on Node, `btoa` on the web), matching
|
|
30
|
+
* {@link encodeImage}.
|
|
31
|
+
*
|
|
32
|
+
* Everything here is dependency-free and safe to import from the core client
|
|
33
|
+
* bundle: the `node:fs` import is dynamic and guarded, so browser/edge builds
|
|
34
|
+
* never pull it in (see ADR 0006 — Edge Runtime CI).
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
* Polymorphic vision input accepted anywhere this SDK takes an `images` entry.
|
|
38
|
+
*
|
|
39
|
+
* - `string` — a raw base64 payload, a `data:image/...;base64,` data URI, an
|
|
40
|
+
* `http(s)://` URL, or (on Node.js) a local file path.
|
|
41
|
+
* - `Buffer` / `Uint8Array` — raw image bytes, base64-encoded automatically.
|
|
42
|
+
*/
|
|
43
|
+
type VisionInput = string | Buffer | Uint8Array;
|
|
44
|
+
/**
|
|
45
|
+
* Cheap synchronous check: does this string input require async resolution
|
|
46
|
+
* (data-URI stripping, URL fetch, or file read), or is it already wire-ready
|
|
47
|
+
* base64? Used to keep the hot path in `withEncodedImages` allocation-free
|
|
48
|
+
* when callers pass pre-encoded strings (the overwhelmingly common case).
|
|
49
|
+
*/
|
|
50
|
+
declare function imageStringNeedsResolution(input: string): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Resolves any supported vision input into the raw base64 string Ollama's
|
|
53
|
+
* REST API expects — no data-URI headers, no URL/path indirection left
|
|
54
|
+
* behind. See the module doc for the full resolution order.
|
|
55
|
+
*
|
|
56
|
+
* @throws {OllamaClientError} if a URL fetch fails (non-2xx), or if a
|
|
57
|
+
* path-shaped string is passed in a runtime without `node:fs` (browser/edge)
|
|
58
|
+
* — in that environment, read the file yourself and pass the bytes.
|
|
59
|
+
*/
|
|
60
|
+
declare function resolveImageInput(input: VisionInput, signal?: AbortSignal | undefined): Promise<string>;
|
|
61
|
+
|
|
1
62
|
/**
|
|
2
63
|
* Core protocol and message types for the Ollama REST API.
|
|
3
64
|
*/
|
|
65
|
+
|
|
4
66
|
type Role = 'system' | 'user' | 'assistant' | 'tool' | 'thought';
|
|
5
67
|
/** Ollama native thinking control: booleans, null for model default, or model-defined levels. */
|
|
6
68
|
type ThinkValue = boolean | string | null;
|
|
@@ -34,11 +96,14 @@ interface Message {
|
|
|
34
96
|
readonly role: Role;
|
|
35
97
|
readonly content: string;
|
|
36
98
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
99
|
+
* Polymorphic vision inputs, resolved automatically before the request reaches
|
|
100
|
+
* the wire (see {@link resolveImageInput}): raw base64 strings pass through;
|
|
101
|
+
* `data:image/...;base64,` data URIs are stripped to their payload; `http(s)://`
|
|
102
|
+
* URLs are fetched and encoded; local file paths (`.png`/`.jpg`/`.webp`/...) are
|
|
103
|
+
* read via `node:fs` on Node.js; and `Buffer`/`Uint8Array` bytes are base64-encoded.
|
|
104
|
+
* Ollama's REST API only ever receives raw base64 strings.
|
|
40
105
|
*/
|
|
41
|
-
readonly images?: readonly
|
|
106
|
+
readonly images?: readonly VisionInput[] | undefined;
|
|
42
107
|
readonly tool_calls?: readonly ToolCall[] | undefined;
|
|
43
108
|
/**
|
|
44
109
|
* Ollama's native `/api/chat` field identifying which tool produced this result.
|
|
@@ -183,11 +248,14 @@ interface GenerateRequestOptions extends RequestCancellationOptions {
|
|
|
183
248
|
readonly raw?: boolean | undefined;
|
|
184
249
|
readonly format?: FormatOption | undefined;
|
|
185
250
|
/**
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
251
|
+
* Polymorphic vision inputs, resolved automatically before the request reaches
|
|
252
|
+
* the wire (see {@link resolveImageInput}): raw base64 strings pass through;
|
|
253
|
+
* `data:image/...;base64,` data URIs are stripped to their payload; `http(s)://`
|
|
254
|
+
* URLs are fetched and encoded; local file paths (`.png`/`.jpg`/`.webp`/...) are
|
|
255
|
+
* read via `node:fs` on Node.js; and `Buffer`/`Uint8Array` bytes are base64-encoded.
|
|
256
|
+
* Ollama's REST API only ever receives raw base64 strings.
|
|
189
257
|
*/
|
|
190
|
-
readonly images?: readonly
|
|
258
|
+
readonly images?: readonly VisionInput[] | undefined;
|
|
191
259
|
readonly options?: ModelOptions | undefined;
|
|
192
260
|
readonly keep_alive?: string | number | undefined;
|
|
193
261
|
readonly think?: ThinkValue | undefined;
|
|
@@ -256,7 +324,7 @@ interface ModelDetails {
|
|
|
256
324
|
readonly parent_model?: string | undefined;
|
|
257
325
|
readonly format: string;
|
|
258
326
|
readonly family: string;
|
|
259
|
-
readonly families?: readonly string[] | undefined;
|
|
327
|
+
readonly families?: readonly string[] | null | undefined;
|
|
260
328
|
readonly parameter_size: string;
|
|
261
329
|
readonly quantization_level: string;
|
|
262
330
|
}
|
|
@@ -342,6 +410,12 @@ interface CreateRequestOptions extends RequestCancellationOptions {
|
|
|
342
410
|
readonly messages?: readonly Message[] | undefined;
|
|
343
411
|
/** Minimum Ollama version required by the model. */
|
|
344
412
|
readonly requires?: string | undefined;
|
|
413
|
+
/**
|
|
414
|
+
* Capabilities to add without removing inherited or inferred capabilities
|
|
415
|
+
* (e.g. `decision` for compatible decision models). Mirrors the official
|
|
416
|
+
* `/api/create` payload.
|
|
417
|
+
*/
|
|
418
|
+
readonly capabilities?: readonly string[] | undefined;
|
|
345
419
|
}
|
|
346
420
|
interface DeleteRequestOptions extends RequestCancellationOptions {
|
|
347
421
|
readonly model: string;
|
|
@@ -399,5 +473,31 @@ interface WebFetchResponse {
|
|
|
399
473
|
readonly content: string;
|
|
400
474
|
readonly links?: readonly string[] | undefined;
|
|
401
475
|
}
|
|
476
|
+
/**
|
|
477
|
+
* `usage`/`balance` report Ollama Cloud account activity at `https://ollama.com` —
|
|
478
|
+
* fixed cloud services, unrelated to any locally-configured `baseUrl`/`endpoints` —
|
|
479
|
+
* and require an Ollama account API key (`apiKey`/`OLLAMA_API_KEY`). See
|
|
480
|
+
* {@link OllamaClient.usage}.
|
|
481
|
+
*/
|
|
482
|
+
interface UsageRequestOptions extends RequestCancellationOptions {
|
|
483
|
+
/**
|
|
484
|
+
* Completed UTC hours or days to include, plus the current partial hour or
|
|
485
|
+
* day. Server default: `'7d'`. `granularity` is derived server-side
|
|
486
|
+
* (`'hour'` for `'24h'`, `'day'` for `'7d'`/`'30d'`).
|
|
487
|
+
*/
|
|
488
|
+
readonly range?: UsageRange | undefined;
|
|
489
|
+
/** Whose requests are reported. Server default: `'self'`; `'team'` requires a team admin. */
|
|
490
|
+
readonly scope?: UsageScope | undefined;
|
|
491
|
+
}
|
|
492
|
+
/** Time range for {@link OllamaClient.usage} (`range` query parameter). */
|
|
493
|
+
type UsageRange = '24h' | '7d' | '30d';
|
|
494
|
+
/** Reporting scope for {@link OllamaClient.usage} (`scope` query parameter). */
|
|
495
|
+
type UsageScope = 'self' | 'team';
|
|
496
|
+
/**
|
|
497
|
+
* See {@link UsageRequestOptions} — same fixed Ollama Cloud endpoint and auth.
|
|
498
|
+
* `GET /api/balance` takes no parameters; the options object exists for
|
|
499
|
+
* cancellation (`signal` / `timeoutMs`) only.
|
|
500
|
+
*/
|
|
501
|
+
type BalanceRequestOptions = RequestCancellationOptions;
|
|
402
502
|
|
|
403
|
-
export type
|
|
503
|
+
export { type ToolCallFunction as A, type BalanceRequestOptions as B, type CreateRequestOptions as C, type DeleteRequestOptions as D, type EmbedRequestOptions as E, type FormatOption as F, type GenerateRequestOptions as G, type ToolFunctionDefinition as H, type ToolProperty as I, type UsageRange as J, type UsageScope as K, type ListResponse as L, type ModelResponse as M, type WebSearchResult as N, imageStringNeedsResolution as O, type PullRequestOptions as P, resolveImageInput as Q, type RequestCancellationOptions as R, type ShowRequestOptions as S, type ThinkingMetadata as T, type UsageRequestOptions as U, type VersionResponse as V, type WebSearchRequestOptions as W, type ShowResponse as a, type ProgressResponse as b, type PushRequestOptions as c, type StatusResponse as d, type CopyRequestOptions as e, type PsResponse as f, type ToolParameters as g, type ThinkValue as h, type ToolCall as i, type ChatRequestOptions as j, type ModelOptions as k, type ToolDefinition as l, type ChatResponse as m, type Message as n, type GenerateResponse as o, type EmbedResponse as p, type EmbeddingsRequestOptions as q, type EmbeddingsResponse as r, type WebSearchResponse as s, type WebFetchRequestOptions as t, type WebFetchResponse as u, type VisionInput as v, type Logprob as w, type LogprobToken as x, type ModelDetails as y, type Role as z };
|
|
@@ -1,6 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Universal vision asset resolution — the SDK-side half of Ollama's documented
|
|
3
|
+
* vision ingestion convention.
|
|
4
|
+
*
|
|
5
|
+
* Ollama's REST API strictly requires raw base64 strings in the `images`
|
|
6
|
+
* arrays of `/api/chat` and `/api/generate` (no `data:image/...;base64,` URI
|
|
7
|
+
* prefixes). The official SDKs, however, are expected to accept polymorphic
|
|
8
|
+
* image sources — local file paths, web URLs, or raw byte buffers — and
|
|
9
|
+
* normalize them to that wire format on the caller's behalf. This module is
|
|
10
|
+
* that normalization layer for this SDK.
|
|
11
|
+
*
|
|
12
|
+
* Resolution order for `string` inputs:
|
|
13
|
+
*
|
|
14
|
+
* 1. `data:image/...;base64,` data URIs — the header is stripped, the
|
|
15
|
+
* payload passed through.
|
|
16
|
+
* 2. `http://` / `https://` URLs — fetched with the platform's global
|
|
17
|
+
* `fetch`, then base64-encoded.
|
|
18
|
+
* 3. Strings with a known image file extension (`.png`, `.jpg`, `.webp`,
|
|
19
|
+
* ...) — treated as a local file path and read via a *dynamically
|
|
20
|
+
* imported* `node:fs` (Node.js only). If the read fails, the string is
|
|
21
|
+
* passed through unchanged (it may have been a base64 payload that
|
|
22
|
+
* happened to end in an image-like suffix — rare, but the safe
|
|
23
|
+
* fallback). In browsers/edge runtimes, where `node:fs` does not exist,
|
|
24
|
+
* a path-shaped string throws a descriptive error instead of silently
|
|
25
|
+
* shipping garbage to the server.
|
|
26
|
+
* 4. Anything else — assumed to already be raw base64 and passed through.
|
|
27
|
+
*
|
|
28
|
+
* `Buffer` and `Uint8Array` inputs are base64-encoded via the runtime's
|
|
29
|
+
* universal base64 primitive (`Buffer` on Node, `btoa` on the web), matching
|
|
30
|
+
* {@link encodeImage}.
|
|
31
|
+
*
|
|
32
|
+
* Everything here is dependency-free and safe to import from the core client
|
|
33
|
+
* bundle: the `node:fs` import is dynamic and guarded, so browser/edge builds
|
|
34
|
+
* never pull it in (see ADR 0006 — Edge Runtime CI).
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
* Polymorphic vision input accepted anywhere this SDK takes an `images` entry.
|
|
38
|
+
*
|
|
39
|
+
* - `string` — a raw base64 payload, a `data:image/...;base64,` data URI, an
|
|
40
|
+
* `http(s)://` URL, or (on Node.js) a local file path.
|
|
41
|
+
* - `Buffer` / `Uint8Array` — raw image bytes, base64-encoded automatically.
|
|
42
|
+
*/
|
|
43
|
+
type VisionInput = string | Buffer | Uint8Array;
|
|
44
|
+
/**
|
|
45
|
+
* Cheap synchronous check: does this string input require async resolution
|
|
46
|
+
* (data-URI stripping, URL fetch, or file read), or is it already wire-ready
|
|
47
|
+
* base64? Used to keep the hot path in `withEncodedImages` allocation-free
|
|
48
|
+
* when callers pass pre-encoded strings (the overwhelmingly common case).
|
|
49
|
+
*/
|
|
50
|
+
declare function imageStringNeedsResolution(input: string): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Resolves any supported vision input into the raw base64 string Ollama's
|
|
53
|
+
* REST API expects — no data-URI headers, no URL/path indirection left
|
|
54
|
+
* behind. See the module doc for the full resolution order.
|
|
55
|
+
*
|
|
56
|
+
* @throws {OllamaClientError} if a URL fetch fails (non-2xx), or if a
|
|
57
|
+
* path-shaped string is passed in a runtime without `node:fs` (browser/edge)
|
|
58
|
+
* — in that environment, read the file yourself and pass the bytes.
|
|
59
|
+
*/
|
|
60
|
+
declare function resolveImageInput(input: VisionInput, signal?: AbortSignal | undefined): Promise<string>;
|
|
61
|
+
|
|
1
62
|
/**
|
|
2
63
|
* Core protocol and message types for the Ollama REST API.
|
|
3
64
|
*/
|
|
65
|
+
|
|
4
66
|
type Role = 'system' | 'user' | 'assistant' | 'tool' | 'thought';
|
|
5
67
|
/** Ollama native thinking control: booleans, null for model default, or model-defined levels. */
|
|
6
68
|
type ThinkValue = boolean | string | null;
|
|
@@ -34,11 +96,14 @@ interface Message {
|
|
|
34
96
|
readonly role: Role;
|
|
35
97
|
readonly content: string;
|
|
36
98
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
99
|
+
* Polymorphic vision inputs, resolved automatically before the request reaches
|
|
100
|
+
* the wire (see {@link resolveImageInput}): raw base64 strings pass through;
|
|
101
|
+
* `data:image/...;base64,` data URIs are stripped to their payload; `http(s)://`
|
|
102
|
+
* URLs are fetched and encoded; local file paths (`.png`/`.jpg`/`.webp`/...) are
|
|
103
|
+
* read via `node:fs` on Node.js; and `Buffer`/`Uint8Array` bytes are base64-encoded.
|
|
104
|
+
* Ollama's REST API only ever receives raw base64 strings.
|
|
40
105
|
*/
|
|
41
|
-
readonly images?: readonly
|
|
106
|
+
readonly images?: readonly VisionInput[] | undefined;
|
|
42
107
|
readonly tool_calls?: readonly ToolCall[] | undefined;
|
|
43
108
|
/**
|
|
44
109
|
* Ollama's native `/api/chat` field identifying which tool produced this result.
|
|
@@ -183,11 +248,14 @@ interface GenerateRequestOptions extends RequestCancellationOptions {
|
|
|
183
248
|
readonly raw?: boolean | undefined;
|
|
184
249
|
readonly format?: FormatOption | undefined;
|
|
185
250
|
/**
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
251
|
+
* Polymorphic vision inputs, resolved automatically before the request reaches
|
|
252
|
+
* the wire (see {@link resolveImageInput}): raw base64 strings pass through;
|
|
253
|
+
* `data:image/...;base64,` data URIs are stripped to their payload; `http(s)://`
|
|
254
|
+
* URLs are fetched and encoded; local file paths (`.png`/`.jpg`/`.webp`/...) are
|
|
255
|
+
* read via `node:fs` on Node.js; and `Buffer`/`Uint8Array` bytes are base64-encoded.
|
|
256
|
+
* Ollama's REST API only ever receives raw base64 strings.
|
|
189
257
|
*/
|
|
190
|
-
readonly images?: readonly
|
|
258
|
+
readonly images?: readonly VisionInput[] | undefined;
|
|
191
259
|
readonly options?: ModelOptions | undefined;
|
|
192
260
|
readonly keep_alive?: string | number | undefined;
|
|
193
261
|
readonly think?: ThinkValue | undefined;
|
|
@@ -256,7 +324,7 @@ interface ModelDetails {
|
|
|
256
324
|
readonly parent_model?: string | undefined;
|
|
257
325
|
readonly format: string;
|
|
258
326
|
readonly family: string;
|
|
259
|
-
readonly families?: readonly string[] | undefined;
|
|
327
|
+
readonly families?: readonly string[] | null | undefined;
|
|
260
328
|
readonly parameter_size: string;
|
|
261
329
|
readonly quantization_level: string;
|
|
262
330
|
}
|
|
@@ -342,6 +410,12 @@ interface CreateRequestOptions extends RequestCancellationOptions {
|
|
|
342
410
|
readonly messages?: readonly Message[] | undefined;
|
|
343
411
|
/** Minimum Ollama version required by the model. */
|
|
344
412
|
readonly requires?: string | undefined;
|
|
413
|
+
/**
|
|
414
|
+
* Capabilities to add without removing inherited or inferred capabilities
|
|
415
|
+
* (e.g. `decision` for compatible decision models). Mirrors the official
|
|
416
|
+
* `/api/create` payload.
|
|
417
|
+
*/
|
|
418
|
+
readonly capabilities?: readonly string[] | undefined;
|
|
345
419
|
}
|
|
346
420
|
interface DeleteRequestOptions extends RequestCancellationOptions {
|
|
347
421
|
readonly model: string;
|
|
@@ -399,5 +473,31 @@ interface WebFetchResponse {
|
|
|
399
473
|
readonly content: string;
|
|
400
474
|
readonly links?: readonly string[] | undefined;
|
|
401
475
|
}
|
|
476
|
+
/**
|
|
477
|
+
* `usage`/`balance` report Ollama Cloud account activity at `https://ollama.com` —
|
|
478
|
+
* fixed cloud services, unrelated to any locally-configured `baseUrl`/`endpoints` —
|
|
479
|
+
* and require an Ollama account API key (`apiKey`/`OLLAMA_API_KEY`). See
|
|
480
|
+
* {@link OllamaClient.usage}.
|
|
481
|
+
*/
|
|
482
|
+
interface UsageRequestOptions extends RequestCancellationOptions {
|
|
483
|
+
/**
|
|
484
|
+
* Completed UTC hours or days to include, plus the current partial hour or
|
|
485
|
+
* day. Server default: `'7d'`. `granularity` is derived server-side
|
|
486
|
+
* (`'hour'` for `'24h'`, `'day'` for `'7d'`/`'30d'`).
|
|
487
|
+
*/
|
|
488
|
+
readonly range?: UsageRange | undefined;
|
|
489
|
+
/** Whose requests are reported. Server default: `'self'`; `'team'` requires a team admin. */
|
|
490
|
+
readonly scope?: UsageScope | undefined;
|
|
491
|
+
}
|
|
492
|
+
/** Time range for {@link OllamaClient.usage} (`range` query parameter). */
|
|
493
|
+
type UsageRange = '24h' | '7d' | '30d';
|
|
494
|
+
/** Reporting scope for {@link OllamaClient.usage} (`scope` query parameter). */
|
|
495
|
+
type UsageScope = 'self' | 'team';
|
|
496
|
+
/**
|
|
497
|
+
* See {@link UsageRequestOptions} — same fixed Ollama Cloud endpoint and auth.
|
|
498
|
+
* `GET /api/balance` takes no parameters; the options object exists for
|
|
499
|
+
* cancellation (`signal` / `timeoutMs`) only.
|
|
500
|
+
*/
|
|
501
|
+
type BalanceRequestOptions = RequestCancellationOptions;
|
|
402
502
|
|
|
403
|
-
export type
|
|
503
|
+
export { type ToolCallFunction as A, type BalanceRequestOptions as B, type CreateRequestOptions as C, type DeleteRequestOptions as D, type EmbedRequestOptions as E, type FormatOption as F, type GenerateRequestOptions as G, type ToolFunctionDefinition as H, type ToolProperty as I, type UsageRange as J, type UsageScope as K, type ListResponse as L, type ModelResponse as M, type WebSearchResult as N, imageStringNeedsResolution as O, type PullRequestOptions as P, resolveImageInput as Q, type RequestCancellationOptions as R, type ShowRequestOptions as S, type ThinkingMetadata as T, type UsageRequestOptions as U, type VersionResponse as V, type WebSearchRequestOptions as W, type ShowResponse as a, type ProgressResponse as b, type PushRequestOptions as c, type StatusResponse as d, type CopyRequestOptions as e, type PsResponse as f, type ToolParameters as g, type ThinkValue as h, type ToolCall as i, type ChatRequestOptions as j, type ModelOptions as k, type ToolDefinition as l, type ChatResponse as m, type Message as n, type GenerateResponse as o, type EmbedResponse as p, type EmbeddingsRequestOptions as q, type EmbeddingsResponse as r, type WebSearchResponse as s, type WebFetchRequestOptions as t, type WebFetchResponse as u, type VisionInput as v, type Logprob as w, type LogprobToken as x, type ModelDetails as y, type Role as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nemesis-oss/ollama-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "Production-grade TypeScript SDK for Ollama with native fetch, high availability failover, multi-turn tool calling, structured outputs, reasoning stream tokens, OpenAI/Anthropic bridges, MCP, Web Stream adapters, and a contract-first hybrid architecture that generates TypeScript types, API classes, MCP tools, and Zod schemas from a single canonical IR.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ollama",
|
|
@@ -189,7 +189,10 @@
|
|
|
189
189
|
"example": "tsx",
|
|
190
190
|
"lab": "tsx lab/run.ts",
|
|
191
191
|
"lab:live": "npm run build && tsx lab/live-tour.ts",
|
|
192
|
-
"prepublishOnly": "npm run verify:release"
|
|
192
|
+
"prepublishOnly": "npm run verify:release",
|
|
193
|
+
"docs:dev": "cd docs-site && npm run dev",
|
|
194
|
+
"docs:build": "cd docs-site && npm run build",
|
|
195
|
+
"docs:preview": "cd docs-site && npm run preview"
|
|
193
196
|
},
|
|
194
197
|
"peerDependencies": {
|
|
195
198
|
"@modelcontextprotocol/client": "^2.1.0",
|
|
@@ -214,10 +217,10 @@
|
|
|
214
217
|
"@opentelemetry/sdk-trace-base": "^1.30.1",
|
|
215
218
|
"@types/js-yaml": "^4.0.9",
|
|
216
219
|
"@types/node": "^22.20.0",
|
|
217
|
-
"@vitest/coverage-v8": "^4.1.
|
|
220
|
+
"@vitest/coverage-v8": "^4.1.11",
|
|
218
221
|
"cross-env": "^10.1.0",
|
|
219
222
|
"dotenv": "^17.4.2",
|
|
220
|
-
"esbuild": "^0.
|
|
223
|
+
"esbuild": "^0.28.2",
|
|
221
224
|
"eslint": "^9.39.4",
|
|
222
225
|
"eslint-config-prettier": "^9.1.2",
|
|
223
226
|
"js-yaml": "^5.4.2",
|
|
@@ -226,7 +229,7 @@
|
|
|
226
229
|
"tsx": "^4.23.0",
|
|
227
230
|
"typescript": "^5.9.3",
|
|
228
231
|
"typescript-eslint": "^8.62.1",
|
|
229
|
-
"vitest": "^4.1.
|
|
232
|
+
"vitest": "^4.1.11",
|
|
230
233
|
"zod": "^4.0.0"
|
|
231
234
|
}
|
|
232
235
|
}
|