@nemesis-oss/ollama-sdk 1.19.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.
- package/CHANGELOG.md +20 -0
- package/README.md +8 -8
- package/dist/{anthropic-CAvwqIjx.d.ts → anthropic-Bf16hGLL.d.cts} +1 -1
- package/dist/{anthropic-DIPnBwlf.d.cts → anthropic-BmFk4Pjq.d.ts} +1 -1
- package/dist/generated-api.d.cts +4 -4
- package/dist/generated-api.d.ts +4 -4
- package/dist/generated-runtime.cjs.map +1 -1
- package/dist/generated-runtime.d.cts +1 -1
- package/dist/generated-runtime.d.ts +1 -1
- package/dist/generated-runtime.js.map +1 -1
- package/dist/index.cjs +115 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +73 -34
- package/dist/index.d.ts +73 -34
- package/dist/index.js +115 -15
- package/dist/index.js.map +1 -1
- package/dist/mcp-generated.d.cts +1 -1
- package/dist/mcp-generated.d.ts +1 -1
- package/dist/{runtime-C28YEAHC.d.cts → runtime-CjCriL5A.d.cts} +29 -1
- package/dist/{runtime-DYCxYGG-.d.ts → runtime-EwyUaNnZ.d.ts} +29 -1
- package/dist/skills.cjs.map +1 -1
- package/dist/skills.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
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
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-
|
|
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 parseSseStream } from './runtime-
|
|
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-
|
|
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-
|
|
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
8
|
import { T as ToolHandler, a as Tool, A as AnyTool, b as ToolRegistry, c as ToolExecutionResult } from './compose-C4QxEZOS.cjs';
|
|
9
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';
|
|
@@ -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
|
|
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 —
|
|
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
|
-
*
|
|
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 (
|
|
762
|
-
*
|
|
763
|
-
*
|
|
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
|
-
*
|
|
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 —
|
|
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
|
|
1382
|
-
*
|
|
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;
|
|
@@ -2436,7 +2451,9 @@ declare class OllamaClient {
|
|
|
2436
2451
|
* through a local server. Requires an Ollama account API key: pass `apiKey` to the
|
|
2437
2452
|
* client constructor or set `OLLAMA_API_KEY`. Applies the same default `timeoutMs` and
|
|
2438
2453
|
* retry policy as inference calls, but never cross-endpoint-fails-over — there is only
|
|
2439
|
-
* 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).
|
|
2440
2457
|
*/
|
|
2441
2458
|
webSearch(req: WebSearchRequestOptions): Promise<WebSearchResponse>;
|
|
2442
2459
|
/**
|
|
@@ -2451,8 +2468,11 @@ declare class OllamaClient {
|
|
|
2451
2468
|
* web search, and web fetch, bucketed by hour (`range: '24h'`) or day (`'7d'`/`'30d'`).
|
|
2452
2469
|
*
|
|
2453
2470
|
* See {@link OllamaClient.webSearch} for the cloud-endpoint/auth/timeout/retry
|
|
2454
|
-
* behavior, which applies identically here.
|
|
2455
|
-
* endpoint
|
|
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`
|
|
2456
2476
|
* (`'self' | 'team'`, server default `'self'`; team scope requires a team admin).
|
|
2457
2477
|
* Omitted options are left unset so the server applies its own defaults.
|
|
2458
2478
|
*
|
|
@@ -2472,7 +2492,9 @@ declare class OllamaClient {
|
|
|
2472
2492
|
* object (`balance_usd`/`allowance_usd`/`period`) or, on legacy plans, session/weekly
|
|
2473
2493
|
* percentage limits; the shape is discriminated at runtime by the server response.
|
|
2474
2494
|
* See {@link OllamaClient.webSearch} for the cloud-endpoint/auth/timeout/retry
|
|
2475
|
-
* 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).
|
|
2476
2498
|
*
|
|
2477
2499
|
* ```ts
|
|
2478
2500
|
* const balance = await client.balance();
|
|
@@ -2584,8 +2606,11 @@ declare function createTimeoutSignal(timeoutMs?: number, userSignal?: AbortSigna
|
|
|
2584
2606
|
* fan-out embed batches, speculative-decoding pipelines) can't always
|
|
2585
2607
|
* predict saturation ahead of time, so the SDK exposes this helper —
|
|
2586
2608
|
* a thin wrapper around `fetch` that retries 503/429 responses with
|
|
2587
|
-
* the same
|
|
2588
|
-
*
|
|
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.
|
|
2589
2614
|
*
|
|
2590
2615
|
* The helper is intentionally standalone: it works with any
|
|
2591
2616
|
* `fetch`-shaped function (browser `globalThis.fetch`, `undici`, an
|
|
@@ -2624,8 +2649,10 @@ interface FetchWithBackoffConfig {
|
|
|
2624
2649
|
*
|
|
2625
2650
|
* Receives the attempt index (0-based for the original request,
|
|
2626
2651
|
* 1+ for retries), the HTTP status that triggered the retry
|
|
2627
|
-
* (or `0` for network-level failures), and the
|
|
2628
|
-
* in milliseconds (
|
|
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).
|
|
2629
2656
|
*/
|
|
2630
2657
|
readonly onRetry?: ((attempt: number, status: number, delayMs: number) => void) | undefined;
|
|
2631
2658
|
/**
|
|
@@ -2667,11 +2694,14 @@ declare const DEFAULT_FETCH_BACKOFF_CONFIG: {
|
|
|
2667
2694
|
* Wrapper around any `fetch`-shaped function that retries HTTP 429 / 503
|
|
2668
2695
|
* responses with jittered exponential backoff (full-jitter strategy —
|
|
2669
2696
|
* see `./backoff.ts` for the rationale and AWS Architecture Blog
|
|
2670
|
-
* citation).
|
|
2697
|
+
* citation), honoring `Retry-After` on 429s when the server sends it.
|
|
2671
2698
|
*
|
|
2672
2699
|
* The wrapper:
|
|
2673
2700
|
* - forwards `input`/`init` unchanged to every attempt,
|
|
2674
|
-
* - 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`),
|
|
2675
2705
|
* - retries up to `maxRetries` times (default 3), then returns the
|
|
2676
2706
|
* final `Response` (whatever its status) so the caller can
|
|
2677
2707
|
* branch on it,
|
|
@@ -4025,11 +4055,14 @@ declare function encodeImage(image: VisionInput): Promise<string>;
|
|
|
4025
4055
|
* Context-window safety: client-side token estimation and pre-flight overflow
|
|
4026
4056
|
* warnings for `/api/chat` and `/api/generate`.
|
|
4027
4057
|
*
|
|
4028
|
-
* Why this exists: when `options.num_ctx` is left unset, Ollama
|
|
4029
|
-
*
|
|
4030
|
-
*
|
|
4031
|
-
*
|
|
4032
|
-
*
|
|
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
|
|
4033
4066
|
* estimates the prompt size client-side (a fast heuristic — no tokenizer
|
|
4034
4067
|
* download, no model dependency) and surfaces a warning *before* the request
|
|
4035
4068
|
* is sent, when the estimate approaches the effective context window.
|
|
@@ -4098,7 +4131,7 @@ type ContextWindowSource =
|
|
|
4098
4131
|
'request'
|
|
4099
4132
|
/** Client `defaultContextLength` config — injected as `num_ctx` by the pipeline. */
|
|
4100
4133
|
| 'client-default'
|
|
4101
|
-
/** Neither set; Ollama's server default applies (
|
|
4134
|
+
/** Neither set; Ollama's VRAM-tiered server default applies (4k / 32k / 256k). */
|
|
4102
4135
|
| 'server-fallback';
|
|
4103
4136
|
/** What the pre-flight check concluded about one request. */
|
|
4104
4137
|
interface ContextCheck {
|
|
@@ -4154,9 +4187,15 @@ declare function checkChatContext(req: ChatRequestOptions, options?: ContextChec
|
|
|
4154
4187
|
*/
|
|
4155
4188
|
declare function checkGenerateContext(req: GenerateRequestOptions, options?: ContextCheckOptions): ContextCheck;
|
|
4156
4189
|
/**
|
|
4157
|
-
*
|
|
4158
|
-
*
|
|
4159
|
-
*
|
|
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.
|
|
4160
4199
|
*/
|
|
4161
4200
|
declare const OLLAMA_FALLBACK_CONTEXT_LENGTH = 2048;
|
|
4162
4201
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
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.js';
|
|
2
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.js';
|
|
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-
|
|
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 parseSseStream } from './runtime-
|
|
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-EwyUaNnZ.js';
|
|
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-EwyUaNnZ.js';
|
|
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-
|
|
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-
|
|
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-BmFk4Pjq.js';
|
|
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-BmFk4Pjq.js';
|
|
8
8
|
import { T as ToolHandler, a as Tool, A as AnyTool, b as ToolRegistry, c as ToolExecutionResult } from './compose-75UFDzOO.js';
|
|
9
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-75UFDzOO.js';
|
|
10
10
|
import { M as McpClientLike, a as McpToolDescriptor, b as McpTask, c as McpCallToolResult } from './types-CI-gM2u5.js';
|
|
@@ -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
|
|
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 —
|
|
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
|
-
*
|
|
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 (
|
|
762
|
-
*
|
|
763
|
-
*
|
|
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
|
-
*
|
|
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 —
|
|
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
|
|
1382
|
-
*
|
|
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;
|
|
@@ -2436,7 +2451,9 @@ declare class OllamaClient {
|
|
|
2436
2451
|
* through a local server. Requires an Ollama account API key: pass `apiKey` to the
|
|
2437
2452
|
* client constructor or set `OLLAMA_API_KEY`. Applies the same default `timeoutMs` and
|
|
2438
2453
|
* retry policy as inference calls, but never cross-endpoint-fails-over — there is only
|
|
2439
|
-
* 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).
|
|
2440
2457
|
*/
|
|
2441
2458
|
webSearch(req: WebSearchRequestOptions): Promise<WebSearchResponse>;
|
|
2442
2459
|
/**
|
|
@@ -2451,8 +2468,11 @@ declare class OllamaClient {
|
|
|
2451
2468
|
* web search, and web fetch, bucketed by hour (`range: '24h'`) or day (`'7d'`/`'30d'`).
|
|
2452
2469
|
*
|
|
2453
2470
|
* See {@link OllamaClient.webSearch} for the cloud-endpoint/auth/timeout/retry
|
|
2454
|
-
* behavior, which applies identically here.
|
|
2455
|
-
* endpoint
|
|
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`
|
|
2456
2476
|
* (`'self' | 'team'`, server default `'self'`; team scope requires a team admin).
|
|
2457
2477
|
* Omitted options are left unset so the server applies its own defaults.
|
|
2458
2478
|
*
|
|
@@ -2472,7 +2492,9 @@ declare class OllamaClient {
|
|
|
2472
2492
|
* object (`balance_usd`/`allowance_usd`/`period`) or, on legacy plans, session/weekly
|
|
2473
2493
|
* percentage limits; the shape is discriminated at runtime by the server response.
|
|
2474
2494
|
* See {@link OllamaClient.webSearch} for the cloud-endpoint/auth/timeout/retry
|
|
2475
|
-
* 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).
|
|
2476
2498
|
*
|
|
2477
2499
|
* ```ts
|
|
2478
2500
|
* const balance = await client.balance();
|
|
@@ -2584,8 +2606,11 @@ declare function createTimeoutSignal(timeoutMs?: number, userSignal?: AbortSigna
|
|
|
2584
2606
|
* fan-out embed batches, speculative-decoding pipelines) can't always
|
|
2585
2607
|
* predict saturation ahead of time, so the SDK exposes this helper —
|
|
2586
2608
|
* a thin wrapper around `fetch` that retries 503/429 responses with
|
|
2587
|
-
* the same
|
|
2588
|
-
*
|
|
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.
|
|
2589
2614
|
*
|
|
2590
2615
|
* The helper is intentionally standalone: it works with any
|
|
2591
2616
|
* `fetch`-shaped function (browser `globalThis.fetch`, `undici`, an
|
|
@@ -2624,8 +2649,10 @@ interface FetchWithBackoffConfig {
|
|
|
2624
2649
|
*
|
|
2625
2650
|
* Receives the attempt index (0-based for the original request,
|
|
2626
2651
|
* 1+ for retries), the HTTP status that triggered the retry
|
|
2627
|
-
* (or `0` for network-level failures), and the
|
|
2628
|
-
* in milliseconds (
|
|
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).
|
|
2629
2656
|
*/
|
|
2630
2657
|
readonly onRetry?: ((attempt: number, status: number, delayMs: number) => void) | undefined;
|
|
2631
2658
|
/**
|
|
@@ -2667,11 +2694,14 @@ declare const DEFAULT_FETCH_BACKOFF_CONFIG: {
|
|
|
2667
2694
|
* Wrapper around any `fetch`-shaped function that retries HTTP 429 / 503
|
|
2668
2695
|
* responses with jittered exponential backoff (full-jitter strategy —
|
|
2669
2696
|
* see `./backoff.ts` for the rationale and AWS Architecture Blog
|
|
2670
|
-
* citation).
|
|
2697
|
+
* citation), honoring `Retry-After` on 429s when the server sends it.
|
|
2671
2698
|
*
|
|
2672
2699
|
* The wrapper:
|
|
2673
2700
|
* - forwards `input`/`init` unchanged to every attempt,
|
|
2674
|
-
* - 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`),
|
|
2675
2705
|
* - retries up to `maxRetries` times (default 3), then returns the
|
|
2676
2706
|
* final `Response` (whatever its status) so the caller can
|
|
2677
2707
|
* branch on it,
|
|
@@ -4025,11 +4055,14 @@ declare function encodeImage(image: VisionInput): Promise<string>;
|
|
|
4025
4055
|
* Context-window safety: client-side token estimation and pre-flight overflow
|
|
4026
4056
|
* warnings for `/api/chat` and `/api/generate`.
|
|
4027
4057
|
*
|
|
4028
|
-
* Why this exists: when `options.num_ctx` is left unset, Ollama
|
|
4029
|
-
*
|
|
4030
|
-
*
|
|
4031
|
-
*
|
|
4032
|
-
*
|
|
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
|
|
4033
4066
|
* estimates the prompt size client-side (a fast heuristic — no tokenizer
|
|
4034
4067
|
* download, no model dependency) and surfaces a warning *before* the request
|
|
4035
4068
|
* is sent, when the estimate approaches the effective context window.
|
|
@@ -4098,7 +4131,7 @@ type ContextWindowSource =
|
|
|
4098
4131
|
'request'
|
|
4099
4132
|
/** Client `defaultContextLength` config — injected as `num_ctx` by the pipeline. */
|
|
4100
4133
|
| 'client-default'
|
|
4101
|
-
/** Neither set; Ollama's server default applies (
|
|
4134
|
+
/** Neither set; Ollama's VRAM-tiered server default applies (4k / 32k / 256k). */
|
|
4102
4135
|
| 'server-fallback';
|
|
4103
4136
|
/** What the pre-flight check concluded about one request. */
|
|
4104
4137
|
interface ContextCheck {
|
|
@@ -4154,9 +4187,15 @@ declare function checkChatContext(req: ChatRequestOptions, options?: ContextChec
|
|
|
4154
4187
|
*/
|
|
4155
4188
|
declare function checkGenerateContext(req: GenerateRequestOptions, options?: ContextCheckOptions): ContextCheck;
|
|
4156
4189
|
/**
|
|
4157
|
-
*
|
|
4158
|
-
*
|
|
4159
|
-
*
|
|
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.
|
|
4160
4199
|
*/
|
|
4161
4200
|
declare const OLLAMA_FALLBACK_CONTEXT_LENGTH = 2048;
|
|
4162
4201
|
/**
|