@nemesis-oss/ollama-sdk 1.18.0 → 1.19.1

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 +45 -0
  2. package/README.md +9 -9
  3. package/dist/{anthropic-CvGVSoVP.d.ts → anthropic-Bf16hGLL.d.cts} +3 -3
  4. package/dist/{anthropic-BvHOsidk.d.cts → anthropic-BmFk4Pjq.d.ts} +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 +163 -28
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +145 -66
  22. package/dist/index.d.ts +145 -66
  23. package/dist/index.js +162 -29
  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-CjCriL5A.d.cts} +56 -5
  33. package/dist/{runtime-CFuv7Ifh.d.ts → runtime-EwyUaNnZ.d.ts} +56 -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.d.cts CHANGED
@@ -1,12 +1,12 @@
1
- import { T as ThinkingMetadata, M as ModelResponse, R as RequestCancellationOptions, S as ShowRequestOptions, a as ShowResponse, P as PullRequestOptions, b as ProgressResponse, c as PushRequestOptions, C as CreateRequestOptions, D as DeleteRequestOptions, d as StatusResponse, e as CopyRequestOptions, f as PsResponse, V as VersionResponse, g as ToolParameters, h as ThinkValue, i as ToolCall, j as ChatRequestOptions, k as ModelOptions, l as ToolDefinition, F as FormatOption, m as ChatResponse, n as Message, G as GenerateRequestOptions, o as GenerateResponse, E as EmbedRequestOptions, p as EmbedResponse, q as EmbeddingsRequestOptions, r as EmbeddingsResponse, W as WebSearchRequestOptions, s as WebSearchResponse, t as WebFetchRequestOptions, u as WebFetchResponse, U as UsageRequestOptions, B as BalanceRequestOptions, v as PingResult, w as VisionInput } from './types-DbPnfVh-.cjs';
2
- export { L as ListResponse, x as Logprob, y as LogprobToken, z as ModelDetails, A as Role, H as ToolCallFunction, I as ToolFunctionDefinition, J as ToolProperty, K as UsageRange, N as UsageScope, O as WebSearchResult, Q as imageStringNeedsResolution, X as resolveImageInput } from './types-DbPnfVh-.cjs';
3
- import { H as HttpClient, F as FetchLike, M as Middleware, L as Logger, R as RequestLifecycleHook, c as OllamaStreamEvent, A as AbortableAsyncIterable, d as OllamaStreamEventType, P as ProgressStreamResult, B as BinaryBody, O as OllamaRuntime, C as ChatStreamResult, G as GenerateStreamResult, e as RawUsageSource, T as TokenUsage } from './runtime-CdZP-N7j.cjs';
4
- export { D as DoneEvent, E as ErrorEvent, f as HttpBody, g as HttpClientOptions, h as HttpRequestOptions, i as LifecycleErrorEvent, j as LifecycleRetryEvent, k as LifecycleStartEvent, l as LifecycleSuccessEvent, m as LogFn, n as MessageEvent, o as MiddlewareContext, N as NANOS_PER_MS, p as NANOS_PER_SECOND, q as NETWORK_ERROR_CODES, r as NOOP_LOGGER, s as NextFunction, t as OllamaAbortError, u as OllamaAgentMaxIterationsError, v as OllamaAgentMaxToolCallsError, w as OllamaAgentToolLoopError, x as OllamaAuthError, y as OllamaBadGatewayError, z as OllamaClientError, J as OllamaClientErrorOptions, K as OllamaErrorRequestContext, Q as OllamaErrorResponseContext, U as OllamaGenericClientError, V as OllamaIncompatibleModelError, W as OllamaMcpError, X as OllamaModelRoutingError, Y as OllamaNetworkError, Z as OllamaNotFoundError, _ as OllamaOverloadedError, $ as OllamaQuotaExceededError, a0 as OllamaRateLimitError, a1 as OllamaRequestTooLargeError, a2 as OllamaRequestValidationError, a3 as OllamaResponseValidationError, a4 as OllamaServerError, a5 as OllamaServerVersionUnknownError, a6 as OllamaSkillInvalidError, a7 as OllamaSkillNotFoundError, a8 as OllamaStreamError, a9 as OllamaTimeoutError, aa as OllamaToolTimeoutError, ab as OllamaToolValidationError, ac as OllamaUnsupportedCapabilityError, ad as RequestContext, ae as RequestLifecycleEvent, af as ResponseContext, ag as SseEvent, ah as ThinkingEvent, ai as TokenEvent, aj as ToolCallEvent, ak as composeMiddleware, al as createConsoleLogger, am as extractUsage, an as isNetworkLevelError, ao as mapError, ap as parseSseStream } from './runtime-CdZP-N7j.cjs';
1
+ import { T as ThinkingMetadata, M as ModelResponse, R as RequestCancellationOptions, S as ShowRequestOptions, a as ShowResponse, P as PullRequestOptions, b as ProgressResponse, c as PushRequestOptions, C as CreateRequestOptions, D as DeleteRequestOptions, d as StatusResponse, e as CopyRequestOptions, f as PsResponse, V as VersionResponse, g as ToolParameters, h as ThinkValue, i as ToolCall, j as ChatRequestOptions, k as ModelOptions, l as ToolDefinition, F as FormatOption, m as ChatResponse, n as Message, G as GenerateRequestOptions, o as GenerateResponse, E as EmbedRequestOptions, p as EmbedResponse, q as EmbeddingsRequestOptions, r as EmbeddingsResponse, W as WebSearchRequestOptions, s as WebSearchResponse, t as WebFetchRequestOptions, u as WebFetchResponse, U as UsageRequestOptions, B as BalanceRequestOptions, v as PingResult, w as VisionInput } from './types-Y3u0FtdN.cjs';
2
+ export { L as ListResponse, x as Logprob, y as LogprobToken, z as ModelDetails, A as Role, H as ToolCallFunction, I as ToolFunctionDefinition, J as ToolProperty, K as UsageRange, N as UsageScope, O as WebSearchResult, Q as imageStringNeedsResolution, X as resolveImageInput } from './types-Y3u0FtdN.cjs';
3
+ import { H as HttpClient, F as FetchLike, M as Middleware, L as Logger, R as RequestLifecycleHook, c as OllamaStreamEvent, A as AbortableAsyncIterable, d as OllamaStreamEventType, P as ProgressStreamResult, B as BinaryBody, O as OllamaRuntime, C as ChatStreamResult, G as GenerateStreamResult, e as RawUsageSource, T as TokenUsage } from './runtime-CjCriL5A.cjs';
4
+ export { D as DoneEvent, E as ErrorEvent, f as HttpBody, g as HttpClientOptions, h as HttpRequestOptions, i as LifecycleErrorEvent, j as LifecycleRetryEvent, k as LifecycleStartEvent, l as LifecycleSuccessEvent, m as LogFn, n as MessageEvent, o as MiddlewareContext, N as NANOS_PER_MS, p as NANOS_PER_SECOND, q as NETWORK_ERROR_CODES, r as NOOP_LOGGER, s as NextFunction, t as OllamaAbortError, u as OllamaAgentMaxIterationsError, v as OllamaAgentMaxToolCallsError, w as OllamaAgentToolLoopError, x as OllamaAuthError, y as OllamaBadGatewayError, z as OllamaClientError, J as OllamaClientErrorOptions, K as OllamaErrorRequestContext, Q as OllamaErrorResponseContext, U as OllamaGenericClientError, V as OllamaIncompatibleModelError, W as OllamaMcpError, X as OllamaModelRoutingError, Y as OllamaNetworkError, Z as OllamaNotFoundError, _ as OllamaOverloadedError, $ as OllamaPaymentRequiredError, a0 as OllamaQuotaExceededError, a1 as OllamaRateLimitError, a2 as OllamaRequestTooLargeError, a3 as OllamaRequestValidationError, a4 as OllamaResponseValidationError, a5 as OllamaServerError, a6 as OllamaServerVersionUnknownError, a7 as OllamaSkillInvalidError, a8 as OllamaSkillNotFoundError, a9 as OllamaStreamError, aa as OllamaTimeoutError, ab as OllamaToolTimeoutError, ac as OllamaToolValidationError, ad as OllamaUnsupportedCapabilityError, ae as RequestContext, af as RequestLifecycleEvent, ag as ResponseContext, ah as SseEvent, ai as ThinkingEvent, aj as TokenEvent, ak as ToolCallEvent, al as composeMiddleware, am as createConsoleLogger, an as extractUsage, ao as isNetworkLevelError, ap as mapError, aq as parseRetryAfterMs, ar as parseSseStream } from './runtime-CjCriL5A.cjs';
5
5
  import { z } from 'zod';
6
- import { R as RequestRunner, S as SystemOneChoiceAnswer, o as SystemOneNoulAnswer, p as SystemOneScoreAnswer, q as SystemOneChoiceQuestion, r as SystemOneNoulQuestion, s as SystemOneScoreQuestion, t as SystemOneRequest$1, u as SystemOneResponse$1, v as SystemOneContent, N as NativeApi, w as OpenAICompatClient, x as AnthropicCompatClient } from './anthropic-BvHOsidk.cjs';
7
- export { y as AnthropicCacheControl, z as AnthropicContentBlock, B as AnthropicImageContentBlock, C as AnthropicMessage, n as AnthropicMessageStreamEvent, A as AnthropicMessagesRequest, m as AnthropicMessagesResponse, D as AnthropicMessagesStream, E as AnthropicMetadata, F as AnthropicOutputConfig, G as AnthropicRedactedThinkingContentBlock, H as AnthropicSystem, I as AnthropicSystemTextBlock, J as AnthropicTextContentBlock, K as AnthropicThinkingConfig, L as AnthropicThinkingContentBlock, M as AnthropicTool, P as AnthropicToolChoice, Q as AnthropicToolResultContentBlock, T as AnthropicToolUseContentBlock, U as AnthropicUnknownStreamEvent, V as OllamaAnthropicContentBlock, W as OllamaAnthropicMessage, X as OllamaAnthropicMessagesRequest, Y as OllamaAnthropicSystem, Z as OllamaAnthropicSystemTextBlock, _ as OllamaAnthropicTextContentBlock, $ as OllamaAnthropicThinkingConfig, a0 as OllamaAnthropicTool, a1 as OllamaAnthropicToolResultContentBlock, a2 as OllamaOpenAIChatCompletionRequest, a3 as OllamaOpenAIChatContentPart, a4 as OllamaOpenAIChatMessage, a5 as OllamaOpenAICompletionRequest, a6 as OllamaOpenAIEmbeddingRequest, a7 as OllamaOpenAIImageDataUrl, a8 as OllamaOpenAIReasoningEffort, a9 as OllamaOpenAIResponsesRequest, aa as OpenAIChatCompletionChoice, b as OpenAIChatCompletionChunk, ab as OpenAIChatCompletionChunkChoice, ac as OpenAIChatCompletionDelta, O as OpenAIChatCompletionRequest, a as OpenAIChatCompletionResponse, ad as OpenAIChatCompletionStream, ae as OpenAICompletionChoice, e as OpenAICompletionChunk, c as OpenAICompletionRequest, d as OpenAICompletionResponse, af as OpenAICompletionStream, ag as OpenAIContentPart, ah as OpenAIEmbeddingInput, ai as OpenAIEmbeddingItem, f as OpenAIEmbeddingRequest, g as OpenAIEmbeddingResponse, aj as OpenAIFunctionDefinition, ak as OpenAIImageUrlContentPart, h as OpenAIListModelsResponse, al as OpenAIMessage, i as OpenAIModelItem, am as OpenAIReasoningEffort, an as OpenAIResponseFormat, ao as OpenAIResponsesCompletedEvent, ap as OpenAIResponsesContentPartAddedEvent, aq as OpenAIResponsesContentPartDoneEvent, ar as OpenAIResponsesCreatedEvent, as as OpenAIResponsesError, at as OpenAIResponsesEventBase, au as OpenAIResponsesFailedEvent, av as OpenAIResponsesFunctionCallArgumentsDeltaEvent, aw as OpenAIResponsesFunctionCallArgumentsDoneEvent, ax as OpenAIResponsesInProgressEvent, ay as OpenAIResponsesIncompleteDetails, az as OpenAIResponsesIncompleteEvent, aA as OpenAIResponsesOutputContent, aB as OpenAIResponsesOutputFunctionCall, aC as OpenAIResponsesOutputItem, aD as OpenAIResponsesOutputItemAddedEvent, aE as OpenAIResponsesOutputItemDoneEvent, aF as OpenAIResponsesOutputMessage, aG as OpenAIResponsesOutputReasoning, aH as OpenAIResponsesOutputRefusal, aI as OpenAIResponsesOutputTextContent, aJ as OpenAIResponsesOutputTextDeltaEvent, aK as OpenAIResponsesOutputTextDoneEvent, aL as OpenAIResponsesQueuedEvent, aM as OpenAIResponsesReasoningSummaryPartAddedEvent, aN as OpenAIResponsesReasoningSummaryPartDoneEvent, aO as OpenAIResponsesReasoningSummaryTextDeltaEvent, aP as OpenAIResponsesReasoningSummaryTextDoneEvent, aQ as OpenAIResponsesReasoningTextDeltaEvent, aR as OpenAIResponsesReasoningTextDoneEvent, aS as OpenAIResponsesRefusalDeltaEvent, aT as OpenAIResponsesRefusalDoneEvent, j as OpenAIResponsesRequest, k as OpenAIResponsesResponse, aU as OpenAIResponsesStatus, aV as OpenAIResponsesStream, aW as OpenAIResponsesStreamError, l as OpenAIResponsesStreamEvent, aX as OpenAIResponsesUsage, aY as OpenAIStreamOptions, aZ as OpenAITextContentPart, a_ as OpenAITool, a$ as OpenAIToolCall, b0 as OpenAIToolCallDelta, b1 as OpenAIUsage, b2 as SystemOneConfidence, b3 as SystemOneProbabilities } from './anthropic-BvHOsidk.cjs';
8
- import { T as ToolHandler, a as Tool, A as AnyTool, b as ToolRegistry, c as ToolExecutionResult } from './compose-DFkmtUOP.cjs';
9
- export { d as AppliedSkillResult, e as ApplySkillOptions, P as ParsedFrontmatter, S as Skill, f as SkillFrontmatter, g as SkillSummary, h as ToolExecutionContext, i as ToolExecutionFailure, j as ToolExecutionSuccess, k as ToolRegistryOptions, l as applySkill, p as parseFrontmatter } from './compose-DFkmtUOP.cjs';
6
+ import { R as RequestRunner, S as SystemOneChoiceAnswer, o as SystemOneNoulAnswer, p as SystemOneScoreAnswer, q as SystemOneChoiceQuestion, r as SystemOneNoulQuestion, s as SystemOneScoreQuestion, t as SystemOneRequest$1, u as SystemOneResponse$1, v as SystemOneContent, N as NativeApi, w as OpenAICompatClient, x as AnthropicCompatClient } from './anthropic-Bf16hGLL.cjs';
7
+ export { y as AnthropicCacheControl, z as AnthropicContentBlock, B as AnthropicImageContentBlock, C as AnthropicMessage, n as AnthropicMessageStreamEvent, A as AnthropicMessagesRequest, m as AnthropicMessagesResponse, D as AnthropicMessagesStream, E as AnthropicMetadata, F as AnthropicOutputConfig, G as AnthropicRedactedThinkingContentBlock, H as AnthropicSystem, I as AnthropicSystemTextBlock, J as AnthropicTextContentBlock, K as AnthropicThinkingConfig, L as AnthropicThinkingContentBlock, M as AnthropicTool, P as AnthropicToolChoice, Q as AnthropicToolResultContentBlock, T as AnthropicToolUseContentBlock, U as AnthropicUnknownStreamEvent, V as OllamaAnthropicContentBlock, W as OllamaAnthropicMessage, X as OllamaAnthropicMessagesRequest, Y as OllamaAnthropicSystem, Z as OllamaAnthropicSystemTextBlock, _ as OllamaAnthropicTextContentBlock, $ as OllamaAnthropicThinkingConfig, a0 as OllamaAnthropicTool, a1 as OllamaAnthropicToolResultContentBlock, a2 as OllamaOpenAIChatCompletionRequest, a3 as OllamaOpenAIChatContentPart, a4 as OllamaOpenAIChatMessage, a5 as OllamaOpenAICompletionRequest, a6 as OllamaOpenAIEmbeddingRequest, a7 as OllamaOpenAIImageDataUrl, a8 as OllamaOpenAIReasoningEffort, a9 as OllamaOpenAIResponsesRequest, aa as OpenAIChatCompletionChoice, b as OpenAIChatCompletionChunk, ab as OpenAIChatCompletionChunkChoice, ac as OpenAIChatCompletionDelta, O as OpenAIChatCompletionRequest, a as OpenAIChatCompletionResponse, ad as OpenAIChatCompletionStream, ae as OpenAICompletionChoice, e as OpenAICompletionChunk, c as OpenAICompletionRequest, d as OpenAICompletionResponse, af as OpenAICompletionStream, ag as OpenAIContentPart, ah as OpenAIEmbeddingInput, ai as OpenAIEmbeddingItem, f as OpenAIEmbeddingRequest, g as OpenAIEmbeddingResponse, aj as OpenAIFunctionDefinition, ak as OpenAIImageUrlContentPart, h as OpenAIListModelsResponse, al as OpenAIMessage, i as OpenAIModelItem, am as OpenAIReasoningEffort, an as OpenAIResponseFormat, ao as OpenAIResponsesCompletedEvent, ap as OpenAIResponsesContentPartAddedEvent, aq as OpenAIResponsesContentPartDoneEvent, ar as OpenAIResponsesCreatedEvent, as as OpenAIResponsesError, at as OpenAIResponsesEventBase, au as OpenAIResponsesFailedEvent, av as OpenAIResponsesFunctionCallArgumentsDeltaEvent, aw as OpenAIResponsesFunctionCallArgumentsDoneEvent, ax as OpenAIResponsesInProgressEvent, ay as OpenAIResponsesIncompleteDetails, az as OpenAIResponsesIncompleteEvent, aA as OpenAIResponsesOutputContent, aB as OpenAIResponsesOutputFunctionCall, aC as OpenAIResponsesOutputItem, aD as OpenAIResponsesOutputItemAddedEvent, aE as OpenAIResponsesOutputItemDoneEvent, aF as OpenAIResponsesOutputMessage, aG as OpenAIResponsesOutputReasoning, aH as OpenAIResponsesOutputRefusal, aI as OpenAIResponsesOutputTextContent, aJ as OpenAIResponsesOutputTextDeltaEvent, aK as OpenAIResponsesOutputTextDoneEvent, aL as OpenAIResponsesQueuedEvent, aM as OpenAIResponsesReasoningSummaryPartAddedEvent, aN as OpenAIResponsesReasoningSummaryPartDoneEvent, aO as OpenAIResponsesReasoningSummaryTextDeltaEvent, aP as OpenAIResponsesReasoningSummaryTextDoneEvent, aQ as OpenAIResponsesReasoningTextDeltaEvent, aR as OpenAIResponsesReasoningTextDoneEvent, aS as OpenAIResponsesRefusalDeltaEvent, aT as OpenAIResponsesRefusalDoneEvent, j as OpenAIResponsesRequest, k as OpenAIResponsesResponse, aU as OpenAIResponsesStatus, aV as OpenAIResponsesStream, aW as OpenAIResponsesStreamError, l as OpenAIResponsesStreamEvent, aX as OpenAIResponsesUsage, aY as OpenAIStreamOptions, aZ as OpenAITextContentPart, a_ as OpenAITool, a$ as OpenAIToolCall, b0 as OpenAIToolCallDelta, b1 as OpenAIUsage, b2 as SystemOneConfidence, b3 as SystemOneProbabilities } from './anthropic-Bf16hGLL.cjs';
8
+ import { T as ToolHandler, a as Tool, A as AnyTool, b as ToolRegistry, c as ToolExecutionResult } from './compose-C4QxEZOS.cjs';
9
+ export { d as AppliedSkillResult, e as ApplySkillOptions, P as ParsedFrontmatter, S as Skill, f as SkillFrontmatter, g as SkillSummary, h as ToolExecutionContext, i as ToolExecutionFailure, j as ToolExecutionSuccess, k as ToolRegistryOptions, l as applySkill, p as parseFrontmatter } from './compose-C4QxEZOS.cjs';
10
10
  import { M as McpClientLike, a as McpToolDescriptor, b as McpTask, c as McpCallToolResult } from './types-CI-gM2u5.cjs';
11
11
  export { d as McpContentBlock, e as McpCreateTaskResult, f as McpElicitationFormRequest, g as McpElicitationHandlers, h as McpElicitationRequest, i as McpElicitationResult, j as McpElicitationUrlRequest, k as McpIcon, l as McpInputRequiredResult, m as McpListToolsParams, n as McpListToolsResult, o as McpRequestOptions, p as McpServerCapabilities, q as McpTaskMethod, r as McpTaskRequest, s as McpTaskStatus, t as McpToolAnnotations, u as McpToolCallResult, v as McpToolExecution } from './types-CI-gM2u5.cjs';
12
12
  import * as Otel from '@opentelemetry/api';
@@ -219,7 +219,10 @@ declare function listAvailableModels(http: HttpClient): Promise<ModelResponse[]>
219
219
  * Dynamic context-window discovery.
220
220
  *
221
221
  * Guessing context windows ("it's probably 2048… or 4096?") is how silent
222
- * truncation happens. Ollama advertises the real numbers in two places, and
222
+ * truncation happens — and current daemons make the guess worse, not better:
223
+ * the unset-`num_ctx` default is tiered by VRAM (4k / 32k / 256k), so a
224
+ * hardcoded assumption is now wrong in both directions. Ollama advertises
225
+ * the real numbers in two places, and
223
226
  * they answer *different questions*:
224
227
  *
225
228
  * - **`GET /api/ps`** reports `context_length` for every currently-running
@@ -262,14 +265,14 @@ type ContextLengthSource =
262
265
  | 'parameters'
263
266
  /** `POST /api/show` `model_info["*.context_length"]` — native GGUF maximum. */
264
267
  | 'model-info'
265
- /** Nothing discoverable — Ollama's conservative unset-`num_ctx` default (2048). */
268
+ /** Nothing discoverable — the 2048 worst-case floor for the unset-`num_ctx` window (current daemons tier by VRAM: 4k / 32k / 256k). */
266
269
  | 'fallback';
267
270
  /** Result of {@link ModelsClient.getContextLength}. */
268
271
  interface DiscoveredContextLength {
269
272
  /**
270
273
  * The effective context window to program against, resolved by precedence:
271
274
  * `running` (exact, when loaded) → `parameters` (Modelfile default) →
272
- * `model-info` (native max) → `2048` fallback.
275
+ * `model-info` (native max) → worst-case `2048` fallback.
273
276
  */
274
277
  readonly contextLength: number;
275
278
  /** Which source produced {@link contextLength}. */
@@ -329,7 +332,9 @@ interface ContextLengthSignals {
329
332
  * (Ollama's conservative default), so native is a *ceiling*, not an
330
333
  * expectation.
331
334
  * 4. **Fallback** — {@link OLLAMA_FALLBACK_CONTEXT_LENGTH} (2048), the
332
- * conservative server-side default, so the result is always actionable.
335
+ * worst-case floor for the unset-`num_ctx` window (current daemons tier
336
+ * by VRAM up to 262,144), so the result is always actionable and can
337
+ * never over-estimate a real window.
333
338
  *
334
339
  * Pure — used by `ModelsClient.getContextLength()` and exported for callers
335
340
  * that already hold `/api/ps` / `/api/show` responses.
@@ -363,6 +368,13 @@ interface RetryConfig {
363
368
  declare const DEFAULT_RETRY_CONFIG: RetryConfig;
364
369
  /**
365
370
  * Executes an async operation with retries according to config.
371
+ *
372
+ * Retry pacing: a 429 whose `Retry-After` header produced
373
+ * `OllamaRateLimitError.retryAfterMs` sleeps exactly that long before the
374
+ * next attempt (server authority — see {@link retryDelayMs}); all other
375
+ * retryable errors sleep a full-jitter exponential backoff. The delay
376
+ * actually used is reported to `onRetry` either way, and remains abortable
377
+ * through `signal` for the whole wait.
366
378
  */
367
379
  declare function withRetry<T>(operation: (attempt: number) => Promise<T>, config?: RetryConfig, signal?: AbortSignal): Promise<T>;
368
380
 
@@ -758,9 +770,11 @@ interface OllamaClientConfig {
758
770
  * Default context window (`num_ctx`) applied to every `chat`/`generate`
759
771
  * request that doesn't set `options.num_ctx` itself. Injected as
760
772
  * `options.num_ctx` on the wire, making the effective window explicit
761
- * instead of leaving it to Ollama's server default (commonly 2048–4096,
762
- * model-dependent) — which **silently truncates** prompts that don't fit,
763
- * with no error and no warning. See `src/context-safety.ts`.
773
+ * instead of leaving it to Ollama's VRAM-tiered server default (4,096
774
+ * tokens below 24 GiB, 32,768 at 24–48 GiB, 262,144 at 48 GiB and up;
775
+ * daemon-wide override via `OLLAMA_CONTEXT_LENGTH`) — which **silently
776
+ * truncates** prompts that don't fit, with no error and no warning. See
777
+ * `src/context-safety.ts`.
764
778
  */
765
779
  readonly defaultContextLength?: number;
766
780
  /**
@@ -887,7 +901,8 @@ declare class ModelsClient {
887
901
  ps(request?: RequestCancellationOptions): Promise<PsResponse>;
888
902
  /**
889
903
  * Discovers the model's real context window from the server — no more
890
- * 2048/4096 guesswork. Consults, in precedence order:
904
+ * default-window guesswork (current daemons tier the unset-`num_ctx`
905
+ * default by VRAM: 4k / 32k / 256k). Consults, in precedence order:
891
906
  *
892
907
  * 1. `GET /api/ps` — the window the **running instance actually
893
908
  * allocated** (exact, reflects the Modelfile `num_ctx` default and
@@ -899,7 +914,7 @@ declare class ModelsClient {
899
914
  * 3. `POST /api/show` `model_info["<arch>.context_length"]` — the
900
915
  * model's **native GGUF maximum** (a ceiling to raise `num_ctx`
901
916
  * toward, not the allocated window).
902
- * 4. Fallback — Ollama's conservative unset-`num_ctx` default (2048).
917
+ * 4. Fallback — the 2048 worst-case floor for the unset-`num_ctx` window.
903
918
  *
904
919
  * The result carries every signal it found, so `nativeContextLength:
905
920
  * 131072` vs `contextLength: 4096` (a 32× gap seen in the official API
@@ -1378,8 +1393,8 @@ declare function sanitizeHistoryForNextTurn(messages: readonly Message[], option
1378
1393
  interface SessionCompactionOptions {
1379
1394
  /**
1380
1395
  * Token budget for the compacted history. Defaults to the session's own
1381
- * window: `options.num_ctx` from the session config, or Ollama's
1382
- * conservative 2048 fallback when unset — pair with
1396
+ * window: `options.num_ctx` from the session config, or the 2048
1397
+ * worst-case fallback when unset — pair with
1383
1398
  * `client.models.getContextLength()` to program against the real window.
1384
1399
  */
1385
1400
  readonly maxEstimatedTokens?: number | undefined;
@@ -1655,25 +1670,34 @@ declare function batchEmbed(client: OllamaClient, options: EmbedBatchOptions): P
1655
1670
  */
1656
1671
 
1657
1672
  /**
1658
- * Maximum total request size, in bytes, accepted by `/v1/systemone`
1659
- * when the request body carries a non-empty `images` array.
1673
+ * Whole-request size cap, in bytes, for `/v1/systemone` — the maximum
1674
+ * serialized size of the complete request, base64 image bytes included.
1675
+ *
1676
+ * Part of the dual cap clarified upstream on 2026-10-16: every request
1677
+ * must satisfy BOTH bounds simultaneously — this whole-request cap AND
1678
+ * the text-and-schema cap of {@link MAX_SYSTEM_ONE_REQUEST_BYTES}
1679
+ * (64 KiB, images excluded). The bumped whole-request cap exists
1680
+ * specifically to accommodate base64-encoded image bytes shared across
1681
+ * all questions in a single System One call; the text and schema
1682
+ * portion may never exceed 64 KiB regardless of whether images are
1683
+ * attached.
1660
1684
  *
1661
- * The Ollama server enforces this limit server-side and rejects
1685
+ * The Ollama server enforces both bounds server-side and rejects
1662
1686
  * oversized payloads with HTTP 413. The SDK's runtime also enforces
1663
- * it client-side (see `OllamaRuntime`'s `maxRequestBytesWithImages`
1687
+ * them client-side (see `OllamaRuntime`'s `maxRequestBytesWithImages`
1664
1688
  * handling) so the round-trip is avoided.
1665
- *
1666
- * Without images, the limit is the much smaller
1667
- * {@link MAX_SYSTEM_ONE_REQUEST_BYTES} (64 KiB) — the bumped
1668
- * images-cap exists specifically to accommodate base64-encoded image
1669
- * bytes shared across all questions in a single System One call.
1670
1689
  */
1671
1690
  declare const MAX_SYSTEM_ONE_IMAGES_BYTES: number;
1672
1691
  /**
1673
- * Maximum total request size, in bytes, for `/v1/systemone` when no
1674
- * images are attached. The Ollama server caps the JSON-only payload
1675
- * at 64 KiB; the runtime enforces this client-side (see
1676
- * `OllamaRuntime`'s `maxRequestBytes`).
1692
+ * Text-and-schema size cap, in bytes, for `/v1/systemone` — the maximum
1693
+ * serialized size of the request with its `images` array excluded.
1694
+ *
1695
+ * Part of the dual cap clarified upstream on 2026-10-16: this bound
1696
+ * applies to EVERY request, images or not — attaching images raises
1697
+ * the whole-request ceiling to {@link MAX_SYSTEM_ONE_IMAGES_BYTES}
1698
+ * (32 MiB) but never relaxes this 64 KiB text-and-schema ceiling. The
1699
+ * runtime enforces both bounds client-side (see `OllamaRuntime`'s
1700
+ * `maxRequestBytes` handling).
1677
1701
  */
1678
1702
  declare const MAX_SYSTEM_ONE_REQUEST_BYTES: number;
1679
1703
  /**
@@ -1740,16 +1764,33 @@ type SystemOneAnswers<Q extends SystemOneQuestions = SystemOneQuestions> = {
1740
1764
  * ## Image support
1741
1765
  *
1742
1766
  * The `images` field accepts up to N base64-encoded images shared by
1743
- * all questions in the request. Total request payload (JSON + images)
1744
- * must remain within {@link MAX_SYSTEM_ONE_IMAGES_BYTES} (32 MiB);
1745
- * requests without images are capped at
1746
- * {@link MAX_SYSTEM_ONE_REQUEST_BYTES} (64 KiB).
1767
+ * all questions in the request. The dual cap (2026-10-16 upstream
1768
+ * clarification) applies to every request simultaneously: the text and
1769
+ * schema portion (images excluded) must stay within
1770
+ * {@link MAX_SYSTEM_ONE_REQUEST_BYTES} (64 KiB), and the whole payload
1771
+ * (JSON + images) within {@link MAX_SYSTEM_ONE_IMAGES_BYTES} (32 MiB).
1747
1772
  *
1748
1773
  * Use {@link estimateSystemOneRequestBytes} for a client-side pre-flight
1749
1774
  * check before sending a large multi-image batch — the runtime also
1750
- * enforces the limit, but the early check avoids the round-trip when
1775
+ * enforces both caps, but the early check avoids the round-trip when
1751
1776
  * the caller already knows the payload is too large.
1752
1777
  *
1778
+ * ## Context window
1779
+ *
1780
+ * Beyond the byte caps, upstream requires the complete input (state,
1781
+ * questions, and images) to fit the model's loaded context window, and
1782
+ * System One never truncates input — oversized prompts are rejected by
1783
+ * the server with HTTP 400 locally ("a rendered prompt that exceeds the
1784
+ * loaded context"), not 413 (which is reserved for the byte caps
1785
+ * above); for cloud requests, upstream documents 413 for input that
1786
+ * exceeds the model's context window (65,536 tokens) as well as for
1787
+ * requests over 13 MiB.
1788
+ * Decision models (Nimble, Tev) additionally reserve two token
1789
+ * positions at the end of the window for scoring. The SDK deliberately
1790
+ * does not estimate this client-side (upstream documents no
1791
+ * tokenization formula); callers who need the real limit can use
1792
+ * `client.models.getContextLength()`.
1793
+ *
1753
1794
  * Requires Clef or Clef Flash with vision weights. URLs and data URLs
1754
1795
  * are NOT supported — pre-encode the bytes to base64 before adding to
1755
1796
  * the array.
@@ -1768,8 +1809,12 @@ interface SystemOneResponse<Q extends SystemOneQuestions = SystemOneQuestions> e
1768
1809
  }
1769
1810
  /**
1770
1811
  * Estimate the on-the-wire byte size of a System One request body, for
1771
- * pre-flight size validation against {@link MAX_SYSTEM_ONE_REQUEST_BYTES}
1772
- * (no images) or {@link MAX_SYSTEM_ONE_IMAGES_BYTES} (with images).
1812
+ * pre-flight validation against the dual cap (2026-10-16 upstream
1813
+ * clarification): the whole body against
1814
+ * {@link MAX_SYSTEM_ONE_IMAGES_BYTES} (32 MiB) and, when `images` is
1815
+ * attached, the images-excluded portion against
1816
+ * {@link MAX_SYSTEM_ONE_REQUEST_BYTES} (64 KiB) — pass
1817
+ * `{ excludeImages: true }` to measure the text-and-schema portion.
1773
1818
  *
1774
1819
  * The estimate is conservative: it uses `JSON.stringify` length and
1775
1820
  * assumes UTF-8 encoding. The actual wire size may differ slightly due
@@ -1781,12 +1826,18 @@ interface SystemOneResponse<Q extends SystemOneQuestions = SystemOneQuestions> e
1781
1826
  * ```ts
1782
1827
  * const request: SystemOneRequest = { ... };
1783
1828
  * const bytes = estimateSystemOneRequestBytes(request);
1784
- * const cap = request.images?.length ? MAX_SYSTEM_ONE_IMAGES_BYTES : MAX_SYSTEM_ONE_REQUEST_BYTES;
1785
- * if (bytes > cap) throw new Error(`payload ${bytes}B exceeds cap ${cap}B`);
1829
+ * const textBytes = request.images?.length
1830
+ * ? estimateSystemOneRequestBytes(request, { excludeImages: true })
1831
+ * : bytes;
1832
+ * if (textBytes > MAX_SYSTEM_ONE_REQUEST_BYTES || bytes > MAX_SYSTEM_ONE_IMAGES_BYTES) {
1833
+ * throw new Error(`payload ${bytes}B (text ${textBytes}B) exceeds the dual cap`);
1834
+ * }
1786
1835
  * await client.systemOne(request);
1787
1836
  * ```
1788
1837
  */
1789
- declare function estimateSystemOneRequestBytes(request: SystemOneRequest | SystemOneRequest$1): number;
1838
+ declare function estimateSystemOneRequestBytes(request: SystemOneRequest | SystemOneRequest$1, options?: {
1839
+ readonly excludeImages?: boolean;
1840
+ }): number;
1790
1841
 
1791
1842
  /**
1792
1843
  * Higher-level System One decision helpers.
@@ -2363,11 +2414,15 @@ declare class OllamaClient {
2363
2414
  * 1–64 typed questions (choice, noul, or score) against a provided state
2364
2415
  * and returns typed answers with probabilities and confidence.
2365
2416
  *
2366
- * Local-only; requires Ollama >= 0.35.0. The runtime enforces the
2367
- * version constraint automatically (lazily fetching `/api/version` when
2368
- * `enforceVersion` is `'auto'` or `'strict'`) and rejects cloud-mode
2369
- * calls. Request size is checked client-side: 64 KiB without images,
2370
- * 32 MiB with images.
2417
+ * Local and cloud (since the 2026-10-16 upstream System One cloud
2418
+ * launch): `model` also accepts cloud models such as `clef:cloud` —
2419
+ * cloud models require Ollama >= 0.40.5 or the hosted
2420
+ * `https://ollama.com` endpoint. Requires Ollama >= 0.35.0 locally.
2421
+ * The runtime enforces the version constraint automatically (lazily
2422
+ * fetching `/api/version` when `enforceVersion` is `'auto'` or
2423
+ * `'strict'`). Request size is checked client-side as a dual cap:
2424
+ * text and schema (images excluded) within 64 KiB AND the whole
2425
+ * request within 32 MiB.
2371
2426
  *
2372
2427
  * The generic `Q` parameter captures the caller's question map at
2373
2428
  * compile time, giving key-safe answer access:
@@ -2396,7 +2451,9 @@ declare class OllamaClient {
2396
2451
  * through a local server. Requires an Ollama account API key: pass `apiKey` to the
2397
2452
  * client constructor or set `OLLAMA_API_KEY`. Applies the same default `timeoutMs` and
2398
2453
  * retry policy as inference calls, but never cross-endpoint-fails-over — there is only
2399
- * ever the one cloud endpoint to call.
2454
+ * ever the one cloud endpoint to call. If the service answers 429 with a `Retry-After`
2455
+ * header, the transport parses it into `OllamaRateLimitError.retryAfterMs` and the
2456
+ * retry loop sleeps exactly that long instead of jittered backoff (see ADR 0035).
2400
2457
  */
2401
2458
  webSearch(req: WebSearchRequestOptions): Promise<WebSearchResponse>;
2402
2459
  /**
@@ -2411,8 +2468,11 @@ declare class OllamaClient {
2411
2468
  * web search, and web fetch, bucketed by hour (`range: '24h'`) or day (`'7d'`/`'30d'`).
2412
2469
  *
2413
2470
  * See {@link OllamaClient.webSearch} for the cloud-endpoint/auth/timeout/retry
2414
- * behavior, which applies identically here. Query parameters mirror the official
2415
- * endpoint: `range` (`'24h' | '7d' | '30d'`, server default `'7d'`) and `scope`
2471
+ * behavior, which applies identically here. The pinned contract documents this
2472
+ * endpoint's 429 with a `Retry-After` header ("Seconds to wait before retrying"),
2473
+ * which the SDK parses into `OllamaRateLimitError.retryAfterMs` and honors verbatim
2474
+ * when retrying. Query parameters mirror the official endpoint: `range`
2475
+ * (`'24h' | '7d' | '30d'`, server default `'7d'`) and `scope`
2416
2476
  * (`'self' | 'team'`, server default `'self'`; team scope requires a team admin).
2417
2477
  * Omitted options are left unset so the server applies its own defaults.
2418
2478
  *
@@ -2432,7 +2492,9 @@ declare class OllamaClient {
2432
2492
  * object (`balance_usd`/`allowance_usd`/`period`) or, on legacy plans, session/weekly
2433
2493
  * percentage limits; the shape is discriminated at runtime by the server response.
2434
2494
  * See {@link OllamaClient.webSearch} for the cloud-endpoint/auth/timeout/retry
2435
- * behavior, which applies identically here.
2495
+ * behavior, which applies identically here. Like `/api/usage`, the pinned contract
2496
+ * documents this endpoint's 429 with a `Retry-After` header, parsed into
2497
+ * `OllamaRateLimitError.retryAfterMs` and honored verbatim when retrying (ADR 0035).
2436
2498
  *
2437
2499
  * ```ts
2438
2500
  * const balance = await client.balance();
@@ -2544,8 +2606,11 @@ declare function createTimeoutSignal(timeoutMs?: number, userSignal?: AbortSigna
2544
2606
  * fan-out embed batches, speculative-decoding pipelines) can't always
2545
2607
  * predict saturation ahead of time, so the SDK exposes this helper —
2546
2608
  * a thin wrapper around `fetch` that retries 503/429 responses with
2547
- * the same jittered exponential backoff used by the SDK's internal
2548
- * transport (see `./backoff.ts` and `./retry.ts`).
2609
+ * the same retry discipline used by the SDK's internal transport (see
2610
+ * `./backoff.ts` and `./retry.ts`): jittered exponential backoff, except
2611
+ * that a 429 carrying `Retry-After` (RFC 9110 § 10.2.3) is honored
2612
+ * verbatim — the server said when to retry, and sleeping less than that
2613
+ * would only compound the rate limiting.
2549
2614
  *
2550
2615
  * The helper is intentionally standalone: it works with any
2551
2616
  * `fetch`-shaped function (browser `globalThis.fetch`, `undici`, an
@@ -2584,8 +2649,10 @@ interface FetchWithBackoffConfig {
2584
2649
  *
2585
2650
  * Receives the attempt index (0-based for the original request,
2586
2651
  * 1+ for retries), the HTTP status that triggered the retry
2587
- * (or `0` for network-level failures), and the calculated delay
2588
- * in milliseconds (already jittered).
2652
+ * (or `0` for network-level failures), and the delay
2653
+ * in milliseconds that will be slept (the server's `Retry-After`
2654
+ * verbatim on a 429 that carried one; otherwise the jittered
2655
+ * backoff sample).
2589
2656
  */
2590
2657
  readonly onRetry?: ((attempt: number, status: number, delayMs: number) => void) | undefined;
2591
2658
  /**
@@ -2627,11 +2694,14 @@ declare const DEFAULT_FETCH_BACKOFF_CONFIG: {
2627
2694
  * Wrapper around any `fetch`-shaped function that retries HTTP 429 / 503
2628
2695
  * responses with jittered exponential backoff (full-jitter strategy —
2629
2696
  * see `./backoff.ts` for the rationale and AWS Architecture Blog
2630
- * citation).
2697
+ * citation), honoring `Retry-After` on 429s when the server sends it.
2631
2698
  *
2632
2699
  * The wrapper:
2633
2700
  * - forwards `input`/`init` unchanged to every attempt,
2634
- * - sleeps before each retry using the configured backoff,
2701
+ * - sleeps before each retry using the configured backoff — or the
2702
+ * server's `Retry-After` value verbatim when a 429 carries one
2703
+ * (no jitter, no clamping; same policy as the SDK's internal
2704
+ * `withRetry`, see `./retry.ts`),
2635
2705
  * - retries up to `maxRetries` times (default 3), then returns the
2636
2706
  * final `Response` (whatever its status) so the caller can
2637
2707
  * branch on it,
@@ -3985,11 +4055,14 @@ declare function encodeImage(image: VisionInput): Promise<string>;
3985
4055
  * Context-window safety: client-side token estimation and pre-flight overflow
3986
4056
  * warnings for `/api/chat` and `/api/generate`.
3987
4057
  *
3988
- * Why this exists: when `options.num_ctx` is left unset, Ollama loads the
3989
- * model with a conservative default context window (commonly 2048–4096
3990
- * tokens, model-dependent) and **silently truncates** any prompt that doesn't
3991
- * fit — the model just loses the top of the conversation with no error, no
3992
- * warning, and often no visible symptom beyond degraded answers. This module
4058
+ * Why this exists: when `options.num_ctx` is left unset, Ollama sizes the
4059
+ * default context window by available VRAM (4,096 tokens below 24 GiB,
4060
+ * 32,768 at 24–48 GiB, 262,144 at 48 GiB and up; daemon-wide override via
4061
+ * `OLLAMA_CONTEXT_LENGTH`, and cloud models run at their maximum — see the
4062
+ * "Context length" page in the Ollama docs) and **silently truncates** any
4063
+ * prompt that doesn't fit — the model just loses the top of the conversation
4064
+ * with no error, no warning, and often no visible symptom beyond degraded
4065
+ * answers. This module
3993
4066
  * estimates the prompt size client-side (a fast heuristic — no tokenizer
3994
4067
  * download, no model dependency) and surfaces a warning *before* the request
3995
4068
  * is sent, when the estimate approaches the effective context window.
@@ -4058,7 +4131,7 @@ type ContextWindowSource =
4058
4131
  'request'
4059
4132
  /** Client `defaultContextLength` config — injected as `num_ctx` by the pipeline. */
4060
4133
  | 'client-default'
4061
- /** Neither set; Ollama's server default applies (2048–4096, model-dependent). */
4134
+ /** Neither set; Ollama's VRAM-tiered server default applies (4k / 32k / 256k). */
4062
4135
  | 'server-fallback';
4063
4136
  /** What the pre-flight check concluded about one request. */
4064
4137
  interface ContextCheck {
@@ -4114,9 +4187,15 @@ declare function checkChatContext(req: ChatRequestOptions, options?: ContextChec
4114
4187
  */
4115
4188
  declare function checkGenerateContext(req: GenerateRequestOptions, options?: ContextCheckOptions): ContextCheck;
4116
4189
  /**
4117
- * The conservative server-side default (2048) Ollama most commonly applies
4118
- * when `num_ctx` is unset — used to warn about *likely* truncation even when
4119
- * no effective window is known client-side.
4190
+ * 2048 — the worst-case floor for the window a daemon allocates when
4191
+ * `num_ctx` is unset, used to warn about *likely* truncation even when no
4192
+ * effective window is known client-side. Deliberately not a prediction:
4193
+ * current daemons tier the unset default by VRAM (4,096 / 32,768 / 262,144
4194
+ * tokens), older daemons defaulted lower, and an admin can pin any value via
4195
+ * `OLLAMA_CONTEXT_LENGTH`. Sizing the floor at the minimum plausible window
4196
+ * keeps this check unable to over-estimate a real window — over-estimation
4197
+ * is the failure that silently re-enables truncation. Use
4198
+ * `client.models.getContextLength()` when the real number matters.
4120
4199
  */
4121
4200
  declare const OLLAMA_FALLBACK_CONTEXT_LENGTH = 2048;
4122
4201
  /**