@nemesis-oss/ollama-sdk 1.19.0 → 1.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/README.md +8 -8
- package/dist/{anthropic-CAvwqIjx.d.ts → anthropic-BFOC6eI7.d.ts} +7 -1
- package/dist/{anthropic-DIPnBwlf.d.cts → anthropic-C2-qaxjI.d.cts} +7 -1
- package/dist/{compose-C4QxEZOS.d.cts → compose-BXXgHmrS.d.cts} +1 -1
- package/dist/{compose-75UFDzOO.d.ts → compose-DaG83yId.d.ts} +1 -1
- package/dist/generated-api.cjs +1 -1
- package/dist/generated-api.cjs.map +1 -1
- package/dist/generated-api.d.cts +7 -7
- package/dist/generated-api.d.ts +7 -7
- package/dist/generated-api.js +1 -1
- package/dist/generated-api.js.map +1 -1
- package/dist/generated-models-schemas.cjs +25 -2
- package/dist/generated-models-schemas.cjs.map +1 -1
- package/dist/generated-models-schemas.d.cts +97 -5
- package/dist/generated-models-schemas.d.ts +97 -5
- package/dist/generated-models-schemas.js +24 -3
- package/dist/generated-models-schemas.js.map +1 -1
- package/dist/generated-runtime.cjs +23 -2
- package/dist/generated-runtime.cjs.map +1 -1
- package/dist/generated-runtime.d.cts +2 -2
- package/dist/generated-runtime.d.ts +2 -2
- package/dist/generated-runtime.js +23 -2
- package/dist/generated-runtime.js.map +1 -1
- package/dist/index.cjs +227 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +169 -46
- package/dist/index.d.ts +169 -46
- package/dist/index.js +222 -29
- package/dist/index.js.map +1 -1
- package/dist/mcp/tools.json +1 -1
- package/dist/mcp-generated.cjs +1 -1
- package/dist/mcp-generated.cjs.map +1 -1
- package/dist/mcp-generated.d.cts +2 -2
- package/dist/mcp-generated.d.ts +2 -2
- package/dist/mcp-generated.js +1 -1
- package/dist/mcp-generated.js.map +1 -1
- package/dist/{runtime-C28YEAHC.d.cts → runtime-CpO3H6yy.d.cts} +55 -2
- package/dist/{runtime-DYCxYGG-.d.ts → runtime-DPSrPwAa.d.ts} +55 -2
- package/dist/skills.cjs.map +1 -1
- package/dist/skills.d.cts +3 -3
- package/dist/skills.d.ts +3 -3
- package/dist/skills.js.map +1 -1
- package/dist/{types-Y3u0FtdN.d.cts → types-CnsZ24tm.d.cts} +17 -1
- package/dist/{types-Y3u0FtdN.d.ts → types-CnsZ24tm.d.ts} +17 -1
- package/package.json +1 -1
package/dist/index.d.ts
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-
|
|
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
|
|
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
|
|
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-CnsZ24tm.js';
|
|
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 UsageGroupBy, N as UsageRange, O as UsageScope, Q as WebSearchResult, X as imageStringNeedsResolution, Y as resolveImageInput } from './types-CnsZ24tm.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-DPSrPwAa.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 OllamaCloudModelVersionError, Q as OllamaErrorRequestContext, U as OllamaErrorResponseContext, V as OllamaGenericClientError, W as OllamaIncompatibleModelError, X as OllamaMcpError, Y as OllamaModelRoutingError, Z as OllamaNetworkError, _ as OllamaNotFoundError, $ as OllamaOverloadedError, a0 as OllamaPaymentRequiredError, a1 as OllamaQuotaExceededError, a2 as OllamaRateLimitError, a3 as OllamaRequestTooLargeError, a4 as OllamaRequestValidationError, a5 as OllamaResponseValidationError, a6 as OllamaServerError, a7 as OllamaServerVersionUnknownError, a8 as OllamaSkillInvalidError, a9 as OllamaSkillNotFoundError, aa as OllamaStreamError, ab as OllamaTimeoutError, ac as OllamaToolTimeoutError, ad as OllamaToolValidationError, ae as OllamaUnsupportedCapabilityError, af as RequestContext, ag as RequestLifecycleEvent, ah as ResponseContext, ai as SseEvent, aj as ThinkingEvent, ak as TokenEvent, al as ToolCallEvent, am as composeMiddleware, an as createConsoleLogger, ao as extractUsage, ap as isNetworkLevelError, aq as mapError, ar as parseRetryAfterMs, as as parseSseStream } from './runtime-DPSrPwAa.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-
|
|
8
|
-
import { T as ToolHandler, a as Tool, A as AnyTool, b as ToolRegistry, c as ToolExecutionResult } from './compose-
|
|
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-
|
|
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-BFOC6eI7.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-BFOC6eI7.js';
|
|
8
|
+
import { T as ToolHandler, a as Tool, A as AnyTool, b as ToolRegistry, c as ToolExecutionResult } from './compose-DaG83yId.js';
|
|
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-DaG83yId.js';
|
|
10
10
|
import { M as McpClientLike, a as McpToolDescriptor, b as McpTask, c as McpCallToolResult } from './types-CI-gM2u5.js';
|
|
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.js';
|
|
12
12
|
import * as Otel from '@opentelemetry/api';
|
|
@@ -72,7 +72,7 @@ interface LegacyIncludedBalance {
|
|
|
72
72
|
* See ADR 0013 and ADR 0014 for the contract-first architecture.
|
|
73
73
|
*/
|
|
74
74
|
|
|
75
|
-
type UsageBucket =
|
|
75
|
+
type UsageBucket = UsageSummary & {
|
|
76
76
|
/** Start of the bucket in UTC, inclusive. */
|
|
77
77
|
readonly from: string;
|
|
78
78
|
/** End of the bucket in UTC, exclusive. */
|
|
@@ -81,6 +81,17 @@ type UsageBucket = UsageMetrics & {
|
|
|
81
81
|
readonly partial?: boolean | undefined;
|
|
82
82
|
};
|
|
83
83
|
|
|
84
|
+
/**
|
|
85
|
+
* AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
|
|
86
|
+
* Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
|
|
87
|
+
* See ADR 0013 and ADR 0014 for the contract-first architecture.
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
type UsageGroup = UsageMetrics & {
|
|
91
|
+
/** Model name. */
|
|
92
|
+
readonly model: string;
|
|
93
|
+
};
|
|
94
|
+
|
|
84
95
|
/**
|
|
85
96
|
* AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
|
|
86
97
|
* Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
|
|
@@ -112,16 +123,31 @@ interface UsageResponse {
|
|
|
112
123
|
readonly scope: 'self' | 'team';
|
|
113
124
|
/** Set automatically: hour for 24h, day for 7d and 30d. */
|
|
114
125
|
readonly granularity: 'hour' | 'day';
|
|
126
|
+
/** Selected grouping. Present when group_by is requested. */
|
|
127
|
+
readonly group_by?: 'model' | undefined;
|
|
115
128
|
/** Start of the range in UTC, inclusive. */
|
|
116
129
|
readonly from: string;
|
|
117
130
|
/** End of the range in UTC, exclusive. */
|
|
118
131
|
readonly until: string;
|
|
119
|
-
/** Usage across the entire range. */
|
|
120
|
-
readonly totals:
|
|
132
|
+
/** Usage across the entire range, including groups in the remainder. */
|
|
133
|
+
readonly totals: UsageSummary;
|
|
121
134
|
/** Usage in chronological order, including buckets with no recorded requests. */
|
|
122
135
|
readonly buckets: readonly UsageBucket[];
|
|
123
136
|
}
|
|
124
137
|
|
|
138
|
+
/**
|
|
139
|
+
* AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
|
|
140
|
+
* Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
|
|
141
|
+
* See ADR 0013 and ADR 0014 for the contract-first architecture.
|
|
142
|
+
*/
|
|
143
|
+
|
|
144
|
+
type UsageSummary = UsageMetrics & {
|
|
145
|
+
/** Present when group_by is requested. Currently returns up to 10 groups selected across the entire range, ranked by usage_usd or by request_count when the range includes legacy requests. Groups use the same order in every bucket; groups without requests in a bucket are omitted. */
|
|
146
|
+
readonly groups?: readonly UsageGroup[] | undefined;
|
|
147
|
+
/** Combined usage from groups outside the current limit. Omitted when there are no requests from additional groups. */
|
|
148
|
+
readonly remainder?: UsageMetrics | undefined;
|
|
149
|
+
};
|
|
150
|
+
|
|
125
151
|
/**
|
|
126
152
|
* Model capability detection and runtime environment inference.
|
|
127
153
|
*/
|
|
@@ -219,7 +245,10 @@ declare function listAvailableModels(http: HttpClient): Promise<ModelResponse[]>
|
|
|
219
245
|
* Dynamic context-window discovery.
|
|
220
246
|
*
|
|
221
247
|
* Guessing context windows ("it's probably 2048… or 4096?") is how silent
|
|
222
|
-
* truncation happens
|
|
248
|
+
* truncation happens — and current daemons make the guess worse, not better:
|
|
249
|
+
* the unset-`num_ctx` default is tiered by VRAM (4k / 32k / 256k), so a
|
|
250
|
+
* hardcoded assumption is now wrong in both directions. Ollama advertises
|
|
251
|
+
* the real numbers in two places, and
|
|
223
252
|
* they answer *different questions*:
|
|
224
253
|
*
|
|
225
254
|
* - **`GET /api/ps`** reports `context_length` for every currently-running
|
|
@@ -262,14 +291,14 @@ type ContextLengthSource =
|
|
|
262
291
|
| 'parameters'
|
|
263
292
|
/** `POST /api/show` `model_info["*.context_length"]` — native GGUF maximum. */
|
|
264
293
|
| 'model-info'
|
|
265
|
-
/** Nothing discoverable —
|
|
294
|
+
/** Nothing discoverable — the 2048 worst-case floor for the unset-`num_ctx` window (current daemons tier by VRAM: 4k / 32k / 256k). */
|
|
266
295
|
| 'fallback';
|
|
267
296
|
/** Result of {@link ModelsClient.getContextLength}. */
|
|
268
297
|
interface DiscoveredContextLength {
|
|
269
298
|
/**
|
|
270
299
|
* The effective context window to program against, resolved by precedence:
|
|
271
300
|
* `running` (exact, when loaded) → `parameters` (Modelfile default) →
|
|
272
|
-
* `model-info` (native max) → `2048` fallback.
|
|
301
|
+
* `model-info` (native max) → worst-case `2048` fallback.
|
|
273
302
|
*/
|
|
274
303
|
readonly contextLength: number;
|
|
275
304
|
/** Which source produced {@link contextLength}. */
|
|
@@ -329,7 +358,9 @@ interface ContextLengthSignals {
|
|
|
329
358
|
* (Ollama's conservative default), so native is a *ceiling*, not an
|
|
330
359
|
* expectation.
|
|
331
360
|
* 4. **Fallback** — {@link OLLAMA_FALLBACK_CONTEXT_LENGTH} (2048), the
|
|
332
|
-
*
|
|
361
|
+
* worst-case floor for the unset-`num_ctx` window (current daemons tier
|
|
362
|
+
* by VRAM up to 262,144), so the result is always actionable and can
|
|
363
|
+
* never over-estimate a real window.
|
|
333
364
|
*
|
|
334
365
|
* Pure — used by `ModelsClient.getContextLength()` and exported for callers
|
|
335
366
|
* that already hold `/api/ps` / `/api/show` responses.
|
|
@@ -363,6 +394,13 @@ interface RetryConfig {
|
|
|
363
394
|
declare const DEFAULT_RETRY_CONFIG: RetryConfig;
|
|
364
395
|
/**
|
|
365
396
|
* Executes an async operation with retries according to config.
|
|
397
|
+
*
|
|
398
|
+
* Retry pacing: a 429 whose `Retry-After` header produced
|
|
399
|
+
* `OllamaRateLimitError.retryAfterMs` sleeps exactly that long before the
|
|
400
|
+
* next attempt (server authority — see {@link retryDelayMs}); all other
|
|
401
|
+
* retryable errors sleep a full-jitter exponential backoff. The delay
|
|
402
|
+
* actually used is reported to `onRetry` either way, and remains abortable
|
|
403
|
+
* through `signal` for the whole wait.
|
|
366
404
|
*/
|
|
367
405
|
declare function withRetry<T>(operation: (attempt: number) => Promise<T>, config?: RetryConfig, signal?: AbortSignal): Promise<T>;
|
|
368
406
|
|
|
@@ -758,9 +796,11 @@ interface OllamaClientConfig {
|
|
|
758
796
|
* Default context window (`num_ctx`) applied to every `chat`/`generate`
|
|
759
797
|
* request that doesn't set `options.num_ctx` itself. Injected as
|
|
760
798
|
* `options.num_ctx` on the wire, making the effective window explicit
|
|
761
|
-
* instead of leaving it to Ollama's server default (
|
|
762
|
-
*
|
|
763
|
-
*
|
|
799
|
+
* instead of leaving it to Ollama's VRAM-tiered server default (4,096
|
|
800
|
+
* tokens below 24 GiB, 32,768 at 24–48 GiB, 262,144 at 48 GiB and up;
|
|
801
|
+
* daemon-wide override via `OLLAMA_CONTEXT_LENGTH`) — which **silently
|
|
802
|
+
* truncates** prompts that don't fit, with no error and no warning. See
|
|
803
|
+
* `src/context-safety.ts`.
|
|
764
804
|
*/
|
|
765
805
|
readonly defaultContextLength?: number;
|
|
766
806
|
/**
|
|
@@ -887,7 +927,8 @@ declare class ModelsClient {
|
|
|
887
927
|
ps(request?: RequestCancellationOptions): Promise<PsResponse>;
|
|
888
928
|
/**
|
|
889
929
|
* Discovers the model's real context window from the server — no more
|
|
890
|
-
*
|
|
930
|
+
* default-window guesswork (current daemons tier the unset-`num_ctx`
|
|
931
|
+
* default by VRAM: 4k / 32k / 256k). Consults, in precedence order:
|
|
891
932
|
*
|
|
892
933
|
* 1. `GET /api/ps` — the window the **running instance actually
|
|
893
934
|
* allocated** (exact, reflects the Modelfile `num_ctx` default and
|
|
@@ -899,7 +940,7 @@ declare class ModelsClient {
|
|
|
899
940
|
* 3. `POST /api/show` `model_info["<arch>.context_length"]` — the
|
|
900
941
|
* model's **native GGUF maximum** (a ceiling to raise `num_ctx`
|
|
901
942
|
* toward, not the allocated window).
|
|
902
|
-
* 4. Fallback —
|
|
943
|
+
* 4. Fallback — the 2048 worst-case floor for the unset-`num_ctx` window.
|
|
903
944
|
*
|
|
904
945
|
* The result carries every signal it found, so `nativeContextLength:
|
|
905
946
|
* 131072` vs `contextLength: 4096` (a 32× gap seen in the official API
|
|
@@ -1378,8 +1419,8 @@ declare function sanitizeHistoryForNextTurn(messages: readonly Message[], option
|
|
|
1378
1419
|
interface SessionCompactionOptions {
|
|
1379
1420
|
/**
|
|
1380
1421
|
* Token budget for the compacted history. Defaults to the session's own
|
|
1381
|
-
* window: `options.num_ctx` from the session config, or
|
|
1382
|
-
*
|
|
1422
|
+
* window: `options.num_ctx` from the session config, or the 2048
|
|
1423
|
+
* worst-case fallback when unset — pair with
|
|
1383
1424
|
* `client.models.getContextLength()` to program against the real window.
|
|
1384
1425
|
*/
|
|
1385
1426
|
readonly maxEstimatedTokens?: number | undefined;
|
|
@@ -1685,6 +1726,41 @@ declare const MAX_SYSTEM_ONE_IMAGES_BYTES: number;
|
|
|
1685
1726
|
* `maxRequestBytes` handling).
|
|
1686
1727
|
*/
|
|
1687
1728
|
declare const MAX_SYSTEM_ONE_REQUEST_BYTES: number;
|
|
1729
|
+
/**
|
|
1730
|
+
* Suffix that marks a System One cloud model (e.g. `clef:cloud`).
|
|
1731
|
+
*
|
|
1732
|
+
* Since the 2026-10-16 upstream cloud launch, `/v1/systemone` accepts
|
|
1733
|
+
* cloud models on the model field. A local Ollama server fronts these
|
|
1734
|
+
* requests to Ollama's cloud — but only from Ollama >= 0.40.5
|
|
1735
|
+
* ({@link CLOUD_MODEL_MIN_OLLAMA_VERSION}); the hosted
|
|
1736
|
+
* `https://ollama.com` endpoint always supports them.
|
|
1737
|
+
*/
|
|
1738
|
+
declare const CLOUD_MODEL_SUFFIX = ":cloud";
|
|
1739
|
+
/**
|
|
1740
|
+
* Minimum local Ollama server version that can front cloud models
|
|
1741
|
+
* (`clef:cloud` and friends) for `/v1/systemone`, per the upstream
|
|
1742
|
+
* System One cloud-launch documentation. The blanket operation-level
|
|
1743
|
+
* floor (0.35.0) stays on the IR constraint; this finer, model-dependent
|
|
1744
|
+
* gate is enforced by `OllamaClient.systemOne` before the request is
|
|
1745
|
+
* sent — closing a docs-vs-runtime gap where the 0.40.5 requirement was
|
|
1746
|
+
* documented but never implemented (ADR 0036).
|
|
1747
|
+
*/
|
|
1748
|
+
declare const CLOUD_MODEL_MIN_OLLAMA_VERSION = "0.40.5";
|
|
1749
|
+
/**
|
|
1750
|
+
* Whether `model` names a System One cloud model (ends with
|
|
1751
|
+
* {@link CLOUD_MODEL_SUFFIX}, e.g. `clef:cloud`).
|
|
1752
|
+
*/
|
|
1753
|
+
declare function isCloudModel(model: string): boolean;
|
|
1754
|
+
/**
|
|
1755
|
+
* Compare two dot-separated Ollama version strings numerically
|
|
1756
|
+
* (e.g. `'0.40.5'` vs `'0.9.0'` → positive — 40 > 9 component-wise,
|
|
1757
|
+
* NOT lexicographic). Mirrors the generated runtime's private
|
|
1758
|
+
* `compareVersions` so the client-side cloud-model gate ranks versions
|
|
1759
|
+
* identically to the IR-constraint gate.
|
|
1760
|
+
*
|
|
1761
|
+
* Returns negative when `a < b`, `0` when equal, positive when `a > b`.
|
|
1762
|
+
*/
|
|
1763
|
+
declare function compareOllamaVersions(a: string, b: string): number;
|
|
1688
1764
|
/**
|
|
1689
1765
|
* Discriminated union of the three question kinds. The upstream OpenAPI
|
|
1690
1766
|
* defines this inline as `oneOf` within SystemOneRequest.questions; we
|
|
@@ -2403,9 +2479,13 @@ declare class OllamaClient {
|
|
|
2403
2479
|
* launch): `model` also accepts cloud models such as `clef:cloud` —
|
|
2404
2480
|
* cloud models require Ollama >= 0.40.5 or the hosted
|
|
2405
2481
|
* `https://ollama.com` endpoint. Requires Ollama >= 0.35.0 locally.
|
|
2406
|
-
*
|
|
2482
|
+
* Both version constraints are enforced client-side before the request
|
|
2483
|
+
* is sent: the blanket 0.35.0 floor by the generated runtime (lazily
|
|
2407
2484
|
* fetching `/api/version` when `enforceVersion` is `'auto'` or
|
|
2408
|
-
* `'strict'`)
|
|
2485
|
+
* `'strict'`), and the model-dependent 0.40.5 cloud gate by this
|
|
2486
|
+
* wrapper — a cloud model through a local server older than 0.40.5
|
|
2487
|
+
* throws {@link OllamaCloudModelVersionError} without a round-trip
|
|
2488
|
+
* (ADR 0036). Request size is checked client-side as a dual cap:
|
|
2409
2489
|
* text and schema (images excluded) within 64 KiB AND the whole
|
|
2410
2490
|
* request within 32 MiB.
|
|
2411
2491
|
*
|
|
@@ -2430,13 +2510,27 @@ declare class OllamaClient {
|
|
|
2430
2510
|
* `client.native.systemOne(request)` directly.
|
|
2431
2511
|
*/
|
|
2432
2512
|
systemOne<Q extends SystemOneQuestions = SystemOneQuestions>(request: SystemOneRequest<Q>): Promise<SystemOneResponse<Q>>;
|
|
2513
|
+
/**
|
|
2514
|
+
* Cloud-model version gate for {@link systemOne} — throws
|
|
2515
|
+
* {@link OllamaCloudModelVersionError} when a cloud model is requested
|
|
2516
|
+
* through a local server older than {@link CLOUD_MODEL_MIN_OLLAMA_VERSION}
|
|
2517
|
+
* (0.40.5). No-op for non-cloud models and for cloud-mode clients
|
|
2518
|
+
* (hosted `ollama.com`). The `/api/version` probe goes through the normal
|
|
2519
|
+
* failover machinery and is cached per client instance (reset on failure,
|
|
2520
|
+
* so a later gated call retries), so at most one extra round-trip happens
|
|
2521
|
+
* across all gated calls.
|
|
2522
|
+
*/
|
|
2523
|
+
private assertCloudModelSupported;
|
|
2524
|
+
private serverVersionCache;
|
|
2433
2525
|
/**
|
|
2434
2526
|
* Ollama's hosted web search tool (`POST https://ollama.com/api/web_search`) — a fixed
|
|
2435
2527
|
* Ollama Cloud service, unrelated to `config.endpoints`/`baseUrl` and not proxied
|
|
2436
2528
|
* through a local server. Requires an Ollama account API key: pass `apiKey` to the
|
|
2437
2529
|
* client constructor or set `OLLAMA_API_KEY`. Applies the same default `timeoutMs` and
|
|
2438
2530
|
* retry policy as inference calls, but never cross-endpoint-fails-over — there is only
|
|
2439
|
-
* ever the one cloud endpoint to call.
|
|
2531
|
+
* ever the one cloud endpoint to call. If the service answers 429 with a `Retry-After`
|
|
2532
|
+
* header, the transport parses it into `OllamaRateLimitError.retryAfterMs` and the
|
|
2533
|
+
* retry loop sleeps exactly that long instead of jittered backoff (see ADR 0035).
|
|
2440
2534
|
*/
|
|
2441
2535
|
webSearch(req: WebSearchRequestOptions): Promise<WebSearchResponse>;
|
|
2442
2536
|
/**
|
|
@@ -2451,14 +2545,24 @@ declare class OllamaClient {
|
|
|
2451
2545
|
* web search, and web fetch, bucketed by hour (`range: '24h'`) or day (`'7d'`/`'30d'`).
|
|
2452
2546
|
*
|
|
2453
2547
|
* See {@link OllamaClient.webSearch} for the cloud-endpoint/auth/timeout/retry
|
|
2454
|
-
* behavior, which applies identically here.
|
|
2455
|
-
* endpoint
|
|
2456
|
-
*
|
|
2548
|
+
* behavior, which applies identically here. The pinned contract documents this
|
|
2549
|
+
* endpoint's 429 with a `Retry-After` header ("Seconds to wait before retrying"),
|
|
2550
|
+
* which the SDK parses into `OllamaRateLimitError.retryAfterMs` and honors verbatim
|
|
2551
|
+
* when retrying. Query parameters mirror the official endpoint: `range`
|
|
2552
|
+
* (`'24h' | '7d' | '30d'`, server default `'7d'`), `scope`
|
|
2553
|
+
* (`'self' | 'team'`, server default `'self'`; team scope requires a team
|
|
2554
|
+
* admin), and — since the 2026-10-22 pin (upstream 2476d5e) — `groupBy`
|
|
2555
|
+
* (`group_by=model`), which makes `totals` and every bucket carry up to 10
|
|
2556
|
+
* per-model `UsageGroup` entries plus a `remainder` roll-up, with the
|
|
2557
|
+
* selection echoed back as `group_by` on the response.
|
|
2457
2558
|
* Omitted options are left unset so the server applies its own defaults.
|
|
2458
2559
|
*
|
|
2459
2560
|
* ```ts
|
|
2460
|
-
* const usage = await client.usage({ range: '24h' });
|
|
2561
|
+
* const usage = await client.usage({ range: '24h', groupBy: 'model' });
|
|
2461
2562
|
* console.log(usage.totals.request_count, usage.totals.usage_usd);
|
|
2563
|
+
* for (const group of usage.totals.groups ?? []) {
|
|
2564
|
+
* console.log(group.model, group.usage_usd);
|
|
2565
|
+
* }
|
|
2462
2566
|
* for (const bucket of usage.buckets) {
|
|
2463
2567
|
* if (bucket.partial) continue; // current hour, still in progress
|
|
2464
2568
|
* // ...
|
|
@@ -2472,7 +2576,9 @@ declare class OllamaClient {
|
|
|
2472
2576
|
* object (`balance_usd`/`allowance_usd`/`period`) or, on legacy plans, session/weekly
|
|
2473
2577
|
* percentage limits; the shape is discriminated at runtime by the server response.
|
|
2474
2578
|
* See {@link OllamaClient.webSearch} for the cloud-endpoint/auth/timeout/retry
|
|
2475
|
-
* behavior, which applies identically here.
|
|
2579
|
+
* behavior, which applies identically here. Like `/api/usage`, the pinned contract
|
|
2580
|
+
* documents this endpoint's 429 with a `Retry-After` header, parsed into
|
|
2581
|
+
* `OllamaRateLimitError.retryAfterMs` and honored verbatim when retrying (ADR 0035).
|
|
2476
2582
|
*
|
|
2477
2583
|
* ```ts
|
|
2478
2584
|
* const balance = await client.balance();
|
|
@@ -2584,8 +2690,11 @@ declare function createTimeoutSignal(timeoutMs?: number, userSignal?: AbortSigna
|
|
|
2584
2690
|
* fan-out embed batches, speculative-decoding pipelines) can't always
|
|
2585
2691
|
* predict saturation ahead of time, so the SDK exposes this helper —
|
|
2586
2692
|
* a thin wrapper around `fetch` that retries 503/429 responses with
|
|
2587
|
-
* the same
|
|
2588
|
-
*
|
|
2693
|
+
* the same retry discipline used by the SDK's internal transport (see
|
|
2694
|
+
* `./backoff.ts` and `./retry.ts`): jittered exponential backoff, except
|
|
2695
|
+
* that a 429 carrying `Retry-After` (RFC 9110 § 10.2.3) is honored
|
|
2696
|
+
* verbatim — the server said when to retry, and sleeping less than that
|
|
2697
|
+
* would only compound the rate limiting.
|
|
2589
2698
|
*
|
|
2590
2699
|
* The helper is intentionally standalone: it works with any
|
|
2591
2700
|
* `fetch`-shaped function (browser `globalThis.fetch`, `undici`, an
|
|
@@ -2624,8 +2733,10 @@ interface FetchWithBackoffConfig {
|
|
|
2624
2733
|
*
|
|
2625
2734
|
* Receives the attempt index (0-based for the original request,
|
|
2626
2735
|
* 1+ for retries), the HTTP status that triggered the retry
|
|
2627
|
-
* (or `0` for network-level failures), and the
|
|
2628
|
-
* in milliseconds (
|
|
2736
|
+
* (or `0` for network-level failures), and the delay
|
|
2737
|
+
* in milliseconds that will be slept (the server's `Retry-After`
|
|
2738
|
+
* verbatim on a 429 that carried one; otherwise the jittered
|
|
2739
|
+
* backoff sample).
|
|
2629
2740
|
*/
|
|
2630
2741
|
readonly onRetry?: ((attempt: number, status: number, delayMs: number) => void) | undefined;
|
|
2631
2742
|
/**
|
|
@@ -2667,11 +2778,14 @@ declare const DEFAULT_FETCH_BACKOFF_CONFIG: {
|
|
|
2667
2778
|
* Wrapper around any `fetch`-shaped function that retries HTTP 429 / 503
|
|
2668
2779
|
* responses with jittered exponential backoff (full-jitter strategy —
|
|
2669
2780
|
* see `./backoff.ts` for the rationale and AWS Architecture Blog
|
|
2670
|
-
* citation).
|
|
2781
|
+
* citation), honoring `Retry-After` on 429s when the server sends it.
|
|
2671
2782
|
*
|
|
2672
2783
|
* The wrapper:
|
|
2673
2784
|
* - forwards `input`/`init` unchanged to every attempt,
|
|
2674
|
-
* - sleeps before each retry using the configured backoff
|
|
2785
|
+
* - sleeps before each retry using the configured backoff — or the
|
|
2786
|
+
* server's `Retry-After` value verbatim when a 429 carries one
|
|
2787
|
+
* (no jitter, no clamping; same policy as the SDK's internal
|
|
2788
|
+
* `withRetry`, see `./retry.ts`),
|
|
2675
2789
|
* - retries up to `maxRetries` times (default 3), then returns the
|
|
2676
2790
|
* final `Response` (whatever its status) so the caller can
|
|
2677
2791
|
* branch on it,
|
|
@@ -4025,11 +4139,14 @@ declare function encodeImage(image: VisionInput): Promise<string>;
|
|
|
4025
4139
|
* Context-window safety: client-side token estimation and pre-flight overflow
|
|
4026
4140
|
* warnings for `/api/chat` and `/api/generate`.
|
|
4027
4141
|
*
|
|
4028
|
-
* Why this exists: when `options.num_ctx` is left unset, Ollama
|
|
4029
|
-
*
|
|
4030
|
-
*
|
|
4031
|
-
*
|
|
4032
|
-
*
|
|
4142
|
+
* Why this exists: when `options.num_ctx` is left unset, Ollama sizes the
|
|
4143
|
+
* default context window by available VRAM (4,096 tokens below 24 GiB,
|
|
4144
|
+
* 32,768 at 24–48 GiB, 262,144 at 48 GiB and up; daemon-wide override via
|
|
4145
|
+
* `OLLAMA_CONTEXT_LENGTH`, and cloud models run at their maximum — see the
|
|
4146
|
+
* "Context length" page in the Ollama docs) and **silently truncates** any
|
|
4147
|
+
* prompt that doesn't fit — the model just loses the top of the conversation
|
|
4148
|
+
* with no error, no warning, and often no visible symptom beyond degraded
|
|
4149
|
+
* answers. This module
|
|
4033
4150
|
* estimates the prompt size client-side (a fast heuristic — no tokenizer
|
|
4034
4151
|
* download, no model dependency) and surfaces a warning *before* the request
|
|
4035
4152
|
* is sent, when the estimate approaches the effective context window.
|
|
@@ -4098,7 +4215,7 @@ type ContextWindowSource =
|
|
|
4098
4215
|
'request'
|
|
4099
4216
|
/** Client `defaultContextLength` config — injected as `num_ctx` by the pipeline. */
|
|
4100
4217
|
| 'client-default'
|
|
4101
|
-
/** Neither set; Ollama's server default applies (
|
|
4218
|
+
/** Neither set; Ollama's VRAM-tiered server default applies (4k / 32k / 256k). */
|
|
4102
4219
|
| 'server-fallback';
|
|
4103
4220
|
/** What the pre-flight check concluded about one request. */
|
|
4104
4221
|
interface ContextCheck {
|
|
@@ -4154,9 +4271,15 @@ declare function checkChatContext(req: ChatRequestOptions, options?: ContextChec
|
|
|
4154
4271
|
*/
|
|
4155
4272
|
declare function checkGenerateContext(req: GenerateRequestOptions, options?: ContextCheckOptions): ContextCheck;
|
|
4156
4273
|
/**
|
|
4157
|
-
*
|
|
4158
|
-
*
|
|
4159
|
-
*
|
|
4274
|
+
* 2048 — the worst-case floor for the window a daemon allocates when
|
|
4275
|
+
* `num_ctx` is unset, used to warn about *likely* truncation even when no
|
|
4276
|
+
* effective window is known client-side. Deliberately not a prediction:
|
|
4277
|
+
* current daemons tier the unset default by VRAM (4,096 / 32,768 / 262,144
|
|
4278
|
+
* tokens), older daemons defaulted lower, and an admin can pin any value via
|
|
4279
|
+
* `OLLAMA_CONTEXT_LENGTH`. Sizing the floor at the minimum plausible window
|
|
4280
|
+
* keeps this check unable to over-estimate a real window — over-estimation
|
|
4281
|
+
* is the failure that silently re-enables truncation. Use
|
|
4282
|
+
* `client.models.getContextLength()` when the real number matters.
|
|
4160
4283
|
*/
|
|
4161
4284
|
declare const OLLAMA_FALLBACK_CONTEXT_LENGTH = 2048;
|
|
4162
4285
|
/**
|
|
@@ -4303,4 +4426,4 @@ declare class ModelAffinityScheduler {
|
|
|
4303
4426
|
/** Convenience factory — `createModelAffinityScheduler(client, opts)` reads better in setups. */
|
|
4304
4427
|
declare function createModelAffinityScheduler(client: ModelAffinityClient | OllamaClient, options?: ModelAffinitySchedulerOptions): ModelAffinityScheduler;
|
|
4305
4428
|
|
|
4306
|
-
export { ATTR_GEN_AI_OPERATION_NAME, ATTR_GEN_AI_REQUEST_MODEL, ATTR_GEN_AI_RESPONSE_MODEL, ATTR_GEN_AI_SYSTEM, ATTR_GEN_AI_TOOL_CALL_ID, ATTR_GEN_AI_TOOL_NAME, ATTR_GEN_AI_USAGE_INPUT_TOKENS, ATTR_GEN_AI_USAGE_OUTPUT_TOKENS, ATTR_HTTP_REQUEST_METHOD, ATTR_HTTP_RESPONSE_STATUS_CODE, ATTR_OLLAMA_AGENT_ITERATION, ATTR_OLLAMA_AGENT_MAX_ITERATIONS, ATTR_OLLAMA_ENDPOINT_ATTEMPT, ATTR_OLLAMA_ENDPOINT_NAME, ATTR_SERVER_ADDRESS, ATTR_SERVER_PORT, ATTR_URL_FULL, AbortableAsyncIterable, type AffinityRunningModel, Agent, type AgentChatClient, type AgentConfig, type AgentHooks, type AgentResult, type AgentRunInput, type AgentTurn, type AnswerFor, AnthropicCompatClient, AnyTool, type BackoffOptions, BalanceRequestOptions, type BalanceResponse, type BlobUploadResult, ChatRequestOptions, ChatResponse, ChatStreamResult, type ChoiceDecision, type CompactionOptions, type CompareDraftPerformanceOptions, type ContextCheck, type ContextCheckOptions, type ContextDiscoveryRequestOptions, type ContextLengthSignals, type ContextLengthSource, type ContextWindowSource, type ConversationSendOptions, ConversationSession, type ConversationSessionOptions, CopyRequestOptions, type CreateModelFromGgufOptions, CreateRequestOptions, type CumulativeCacheStats, DEFAULT_BACKOFF, DEFAULT_BASE_URL, DEFAULT_CONTEXT_WARNING_THRESHOLD, DEFAULT_EMBED_BATCH_SIZE, DEFAULT_EMBED_CONCURRENCY, DEFAULT_FAILOVER_CODES, DEFAULT_FETCH_BACKOFF_CONFIG, DEFAULT_RETRY_CONFIG, DEFAULT_TIMEOUT_MS, type Decision, type DefineToolOptions, DeleteRequestOptions, type DiscoveredContextLength, type DraftBenchmarkClient, type DraftPerformanceComparison, type DraftRunStats, type EmbedBatchOptions, type EmbedBatchResult, EmbedRequestOptions, EmbedResponse, EmbeddingsRequestOptions, EmbeddingsResponse, type EndpointHealth, type EndpointHealthCheckResult, EndpointRegistry, type EndpointRegistryOptions, FetchLike, type FetchWithBackoffConfig, FormatOption, type FormattedTelemetry, GEN_AI_SYSTEM_OLLAMA, GenerateRequestOptions, GenerateResponse, GenerateStreamResult, type HistorySanitizeOptions, HttpClient, IMAGE_TOKEN_ESTIMATE, type IncludedBalance, KEEP_ALIVE_INDEFINITE, KEEP_ALIVE_UNLOAD, KNOWN_DONE_REASONS, type KeepAlive, type KnownDoneReason, type LegacyBalanceLimit, type LegacyIncludedBalance, type LoadMcpToolsOptions, Logger, MAX_SYSTEM_ONE_IMAGES_BYTES, MAX_SYSTEM_ONE_REQUEST_BYTES, MESSAGE_OVERHEAD_TOKENS, McpBridge, type McpBridgeOptions, McpCallToolResult, McpClientLike, McpTask, McpToolDescriptor, Message, Middleware, type ModelAffinityClient, ModelAffinityRouter, type ModelAffinityRoutingOptions, ModelAffinityScheduler, type ModelAffinitySchedulerOptions, type ModelAffinitySnapshot, type ModelAffinityStats, type ModelCapabilities, ModelOptions, ModelResponse, ModelsClient, type NoulDecision, OLLAMA_CLOUD_BASE_URL, OLLAMA_FALLBACK_CONTEXT_LENGTH, OllamaClient, type OllamaClientConfig, type OllamaCloudFreeTierQuotaBudgets, type OllamaCredentialConfig, type OllamaEndpoint, OllamaStream, OllamaStreamEvent, OllamaStreamEventType, OpenAICompatClient, type OversizedEmbedInput, type ParallelToolCallBehavior, PingResult, type ProgressCallback, ProgressResponse, type ProgressSpeed, ProgressStreamResult, PsResponse, type PullProgressEvent, PullRequestOptions, PushRequestOptions, QuotaManager, type QuotaManagerOptions, type QuotaWindowConfig, type QuotaWindowStatus, RETRYABLE_STATUS_CODES, type RankResult, type RawOllamaMetrics, RawUsageSource, RequestCancellationOptions, RequestLifecycleHook, RequestRunner, type ResponsesCreateRequest, type ResponsesCreateResponse, ResponsesModule, type ResponsesReasoningEffort, type ResponsesStreamEvent, type ResponsesToolDefinition, type ResponsesUsage, type RetryConfig, type RuntimeMode, type ScoreDecision, type SessionCompactionOptions, type SessionCompactionResult, type SessionTurn, ShowRequestOptions, ShowResponse, type SpanAttributeValue, type SpanAttributes, StatusResponse, type StreamObserverCallbacks, type StreamObserverPhase, type SupportedSchema, type SystemOneAnswer, type SystemOneAnswers, SystemOneChoiceAnswer, SystemOneChoiceQuestion, SystemOneContent, SystemOneNoulAnswer, SystemOneNoulQuestion, type SystemOneQuestion, type SystemOneQuestions, type SystemOneRequest, type SystemOneResponse, SystemOneScoreAnswer, SystemOneScoreQuestion, type SystemOneUsage, ThinkValue, ThinkingMetadata, type TimeoutSignal, TokenUsage, Tool, ToolCall, ToolCallAccumulator, ToolDefinition, ToolExecutionResult, ToolHandler, ToolParameters, ToolRegistry, type TurnCacheStats, type UsageBucket, type UsageMetrics, UsageRequestOptions, type UsageResponse, VersionResponse, VisionInput, WEB_FETCH_TOOL_NAME, WEB_SEARCH_TOOL_NAME, WebFetchRequestOptions, WebFetchResponse, type WebFetchToolParams, WebSearchRequestOptions, WebSearchResponse, type WebSearchToolParams, type WebToolsClient, type WebToolsOptions, addSpanEvent, batchEmbed, calculateBackoff, canonicalToolCallSignature, checkChatContext, checkEndpointHealth, checkGenerateContext, compactConversationHistory, compareDraftPerformance, computeProgressPercent, contextWarningMessage, createDecision, createModelAffinityScheduler, createOllamaCloudFreeTierQuota, createProgressSpeedTracker, createTimeoutSignal, createWebFetchTool, createWebSearchTool, createWebTools, defineTool, detectModelCapabilities, embedBatchOverflowMessage, encodeImage, estimateChatRequestTokens, estimateGenerateRequestTokens, estimateMessageTokens, estimateSystemOneRequestBytes, estimateTokens, extractContextLength as extractNativeContextLength, extractParameterNumCtx, fetchWithBackoff, findOversizedEmbedInputs, findRunningModelContextLength, formatTelemetry, formatWebFetchResult, formatWebSearchResult, inferRuntimeMode, isKeepAliveSugar, isKnownDoneReason, isModelResident, isSameToolCall, listAllMcpTools, listAvailableModels, loadMcpTools, mergeToolCall, mergeToolCallArgumentsString, mergeToolCallArrays, normalizeChatStream, normalizeGenerateStream, normalizeKeepAlive, normalizeProgressStream, observeStream, onProgress, parseNdjsonStream, parseStructuredOutput, recommendContextWindow, registerMcpTools, resolveContextLength, resolveCredentialEndpoints, sanitizeHistoryForNextTurn, setSpanError, toDataStream, toPullProgressEvent, toResponse, toTextStream, withRetry, withSpan, zodToJsonSchema };
|
|
4429
|
+
export { ATTR_GEN_AI_OPERATION_NAME, ATTR_GEN_AI_REQUEST_MODEL, ATTR_GEN_AI_RESPONSE_MODEL, ATTR_GEN_AI_SYSTEM, ATTR_GEN_AI_TOOL_CALL_ID, ATTR_GEN_AI_TOOL_NAME, ATTR_GEN_AI_USAGE_INPUT_TOKENS, ATTR_GEN_AI_USAGE_OUTPUT_TOKENS, ATTR_HTTP_REQUEST_METHOD, ATTR_HTTP_RESPONSE_STATUS_CODE, ATTR_OLLAMA_AGENT_ITERATION, ATTR_OLLAMA_AGENT_MAX_ITERATIONS, ATTR_OLLAMA_ENDPOINT_ATTEMPT, ATTR_OLLAMA_ENDPOINT_NAME, ATTR_SERVER_ADDRESS, ATTR_SERVER_PORT, ATTR_URL_FULL, AbortableAsyncIterable, type AffinityRunningModel, Agent, type AgentChatClient, type AgentConfig, type AgentHooks, type AgentResult, type AgentRunInput, type AgentTurn, type AnswerFor, AnthropicCompatClient, AnyTool, type BackoffOptions, BalanceRequestOptions, type BalanceResponse, type BlobUploadResult, CLOUD_MODEL_MIN_OLLAMA_VERSION, CLOUD_MODEL_SUFFIX, ChatRequestOptions, ChatResponse, ChatStreamResult, type ChoiceDecision, type CompactionOptions, type CompareDraftPerformanceOptions, type ContextCheck, type ContextCheckOptions, type ContextDiscoveryRequestOptions, type ContextLengthSignals, type ContextLengthSource, type ContextWindowSource, type ConversationSendOptions, ConversationSession, type ConversationSessionOptions, CopyRequestOptions, type CreateModelFromGgufOptions, CreateRequestOptions, type CumulativeCacheStats, DEFAULT_BACKOFF, DEFAULT_BASE_URL, DEFAULT_CONTEXT_WARNING_THRESHOLD, DEFAULT_EMBED_BATCH_SIZE, DEFAULT_EMBED_CONCURRENCY, DEFAULT_FAILOVER_CODES, DEFAULT_FETCH_BACKOFF_CONFIG, DEFAULT_RETRY_CONFIG, DEFAULT_TIMEOUT_MS, type Decision, type DefineToolOptions, DeleteRequestOptions, type DiscoveredContextLength, type DraftBenchmarkClient, type DraftPerformanceComparison, type DraftRunStats, type EmbedBatchOptions, type EmbedBatchResult, EmbedRequestOptions, EmbedResponse, EmbeddingsRequestOptions, EmbeddingsResponse, type EndpointHealth, type EndpointHealthCheckResult, EndpointRegistry, type EndpointRegistryOptions, FetchLike, type FetchWithBackoffConfig, FormatOption, type FormattedTelemetry, GEN_AI_SYSTEM_OLLAMA, GenerateRequestOptions, GenerateResponse, GenerateStreamResult, type HistorySanitizeOptions, HttpClient, IMAGE_TOKEN_ESTIMATE, type IncludedBalance, KEEP_ALIVE_INDEFINITE, KEEP_ALIVE_UNLOAD, KNOWN_DONE_REASONS, type KeepAlive, type KnownDoneReason, type LegacyBalanceLimit, type LegacyIncludedBalance, type LoadMcpToolsOptions, Logger, MAX_SYSTEM_ONE_IMAGES_BYTES, MAX_SYSTEM_ONE_REQUEST_BYTES, MESSAGE_OVERHEAD_TOKENS, McpBridge, type McpBridgeOptions, McpCallToolResult, McpClientLike, McpTask, McpToolDescriptor, Message, Middleware, type ModelAffinityClient, ModelAffinityRouter, type ModelAffinityRoutingOptions, ModelAffinityScheduler, type ModelAffinitySchedulerOptions, type ModelAffinitySnapshot, type ModelAffinityStats, type ModelCapabilities, ModelOptions, ModelResponse, ModelsClient, type NoulDecision, OLLAMA_CLOUD_BASE_URL, OLLAMA_FALLBACK_CONTEXT_LENGTH, OllamaClient, type OllamaClientConfig, type OllamaCloudFreeTierQuotaBudgets, type OllamaCredentialConfig, type OllamaEndpoint, OllamaStream, OllamaStreamEvent, OllamaStreamEventType, OpenAICompatClient, type OversizedEmbedInput, type ParallelToolCallBehavior, PingResult, type ProgressCallback, ProgressResponse, type ProgressSpeed, ProgressStreamResult, PsResponse, type PullProgressEvent, PullRequestOptions, PushRequestOptions, QuotaManager, type QuotaManagerOptions, type QuotaWindowConfig, type QuotaWindowStatus, RETRYABLE_STATUS_CODES, type RankResult, type RawOllamaMetrics, RawUsageSource, RequestCancellationOptions, RequestLifecycleHook, RequestRunner, type ResponsesCreateRequest, type ResponsesCreateResponse, ResponsesModule, type ResponsesReasoningEffort, type ResponsesStreamEvent, type ResponsesToolDefinition, type ResponsesUsage, type RetryConfig, type RuntimeMode, type ScoreDecision, type SessionCompactionOptions, type SessionCompactionResult, type SessionTurn, ShowRequestOptions, ShowResponse, type SpanAttributeValue, type SpanAttributes, StatusResponse, type StreamObserverCallbacks, type StreamObserverPhase, type SupportedSchema, type SystemOneAnswer, type SystemOneAnswers, SystemOneChoiceAnswer, SystemOneChoiceQuestion, SystemOneContent, SystemOneNoulAnswer, SystemOneNoulQuestion, type SystemOneQuestion, type SystemOneQuestions, type SystemOneRequest, type SystemOneResponse, SystemOneScoreAnswer, SystemOneScoreQuestion, type SystemOneUsage, ThinkValue, ThinkingMetadata, type TimeoutSignal, TokenUsage, Tool, ToolCall, ToolCallAccumulator, ToolDefinition, ToolExecutionResult, ToolHandler, ToolParameters, ToolRegistry, type TurnCacheStats, type UsageBucket, type UsageGroup, type UsageMetrics, UsageRequestOptions, type UsageResponse, type UsageSummary, VersionResponse, VisionInput, WEB_FETCH_TOOL_NAME, WEB_SEARCH_TOOL_NAME, WebFetchRequestOptions, WebFetchResponse, type WebFetchToolParams, WebSearchRequestOptions, WebSearchResponse, type WebSearchToolParams, type WebToolsClient, type WebToolsOptions, addSpanEvent, batchEmbed, calculateBackoff, canonicalToolCallSignature, checkChatContext, checkEndpointHealth, checkGenerateContext, compactConversationHistory, compareDraftPerformance, compareOllamaVersions, computeProgressPercent, contextWarningMessage, createDecision, createModelAffinityScheduler, createOllamaCloudFreeTierQuota, createProgressSpeedTracker, createTimeoutSignal, createWebFetchTool, createWebSearchTool, createWebTools, defineTool, detectModelCapabilities, embedBatchOverflowMessage, encodeImage, estimateChatRequestTokens, estimateGenerateRequestTokens, estimateMessageTokens, estimateSystemOneRequestBytes, estimateTokens, extractContextLength as extractNativeContextLength, extractParameterNumCtx, fetchWithBackoff, findOversizedEmbedInputs, findRunningModelContextLength, formatTelemetry, formatWebFetchResult, formatWebSearchResult, inferRuntimeMode, isCloudModel, isKeepAliveSugar, isKnownDoneReason, isModelResident, isSameToolCall, listAllMcpTools, listAvailableModels, loadMcpTools, mergeToolCall, mergeToolCallArgumentsString, mergeToolCallArrays, normalizeChatStream, normalizeGenerateStream, normalizeKeepAlive, normalizeProgressStream, observeStream, onProgress, parseNdjsonStream, parseStructuredOutput, recommendContextWindow, registerMcpTools, resolveContextLength, resolveCredentialEndpoints, sanitizeHistoryForNextTurn, setSpanError, toDataStream, toPullProgressEvent, toResponse, toTextStream, withRetry, withSpan, zodToJsonSchema };
|