@nemesis-oss/ollama-sdk 1.17.0 → 1.19.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 +58 -0
- package/README.md +79 -0
- package/dist/{anthropic-AKbXnWJU.d.cts → anthropic-CAvwqIjx.d.ts} +5 -5
- package/dist/{anthropic-CTv2acbj.d.ts → anthropic-DIPnBwlf.d.cts} +5 -5
- package/dist/{compose-CeFbHJeO.d.ts → compose-75UFDzOO.d.ts} +1 -1
- package/dist/{compose-DFkmtUOP.d.cts → compose-C4QxEZOS.d.cts} +1 -1
- package/dist/generated-api.cjs +5 -3
- package/dist/generated-api.cjs.map +1 -1
- package/dist/generated-api.d.cts +9 -9
- package/dist/generated-api.d.ts +9 -9
- package/dist/generated-api.js +5 -3
- package/dist/generated-api.js.map +1 -1
- package/dist/generated-models-schemas.cjs +2 -2
- package/dist/generated-models-schemas.cjs.map +1 -1
- package/dist/generated-models-schemas.js +2 -2
- package/dist/generated-models-schemas.js.map +1 -1
- package/dist/generated-runtime.cjs +24 -6
- 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 +24 -6
- package/dist/generated-runtime.js.map +1 -1
- package/dist/index.cjs +132 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +294 -40
- package/dist/index.d.ts +294 -40
- package/dist/index.js +128 -21
- package/dist/index.js.map +1 -1
- package/dist/mcp/tools.json +8 -10
- package/dist/mcp-generated.cjs +5 -3
- 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 +5 -3
- package/dist/mcp-generated.js.map +1 -1
- package/dist/{runtime-CdZP-N7j.d.cts → runtime-C28YEAHC.d.cts} +28 -5
- package/dist/{runtime-CFuv7Ifh.d.ts → runtime-DYCxYGG-.d.ts} +28 -5
- 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-DbPnfVh-.d.cts → types-Y3u0FtdN.d.cts} +10 -0
- package/dist/{types-DbPnfVh-.d.ts → types-Y3u0FtdN.d.ts} +10 -0
- package/package.json +2 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { T as ThinkingMetadata, M as ModelResponse, R as RequestCancellationOptions, S as ShowRequestOptions, a as ShowResponse, P as PullRequestOptions, b as ProgressResponse, c as PushRequestOptions, C as CreateRequestOptions, D as DeleteRequestOptions, d as StatusResponse, e as CopyRequestOptions, f as PsResponse, V as VersionResponse, g as ToolParameters, h as ThinkValue, i as ToolCall, j as ChatRequestOptions, k as ModelOptions, l as ToolDefinition, F as FormatOption, m as ChatResponse, n as Message, G as GenerateRequestOptions, o as GenerateResponse, E as EmbedRequestOptions, p as EmbedResponse, q as EmbeddingsRequestOptions, r as EmbeddingsResponse, W as WebSearchRequestOptions, s as WebSearchResponse, t as WebFetchRequestOptions, u as WebFetchResponse, U as UsageRequestOptions, B as BalanceRequestOptions, v as PingResult, w as VisionInput } from './types-
|
|
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-
|
|
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
|
|
1
|
+
import { T as ThinkingMetadata, M as ModelResponse, R as RequestCancellationOptions, S as ShowRequestOptions, a as ShowResponse, P as PullRequestOptions, b as ProgressResponse, c as PushRequestOptions, C as CreateRequestOptions, D as DeleteRequestOptions, d as StatusResponse, e as CopyRequestOptions, f as PsResponse, V as VersionResponse, g as ToolParameters, h as ThinkValue, i as ToolCall, j as ChatRequestOptions, k as ModelOptions, l as ToolDefinition, F as FormatOption, m as ChatResponse, n as Message, G as GenerateRequestOptions, o as GenerateResponse, E as EmbedRequestOptions, p as EmbedResponse, q as EmbeddingsRequestOptions, r as EmbeddingsResponse, W as WebSearchRequestOptions, s as WebSearchResponse, t as WebFetchRequestOptions, u as WebFetchResponse, U as UsageRequestOptions, B as BalanceRequestOptions, v as PingResult, w as VisionInput } from './types-Y3u0FtdN.cjs';
|
|
2
|
+
export { L as ListResponse, x as Logprob, y as LogprobToken, z as ModelDetails, A as Role, H as ToolCallFunction, I as ToolFunctionDefinition, J as ToolProperty, K as UsageRange, N as UsageScope, O as WebSearchResult, Q as imageStringNeedsResolution, X as resolveImageInput } from './types-Y3u0FtdN.cjs';
|
|
3
|
+
import { H as HttpClient, F as FetchLike, M as Middleware, L as Logger, R as RequestLifecycleHook, c as OllamaStreamEvent, A as AbortableAsyncIterable, d as OllamaStreamEventType, P as ProgressStreamResult, B as BinaryBody, O as OllamaRuntime, C as ChatStreamResult, G as GenerateStreamResult, e as RawUsageSource, T as TokenUsage } from './runtime-C28YEAHC.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 parseSseStream } from './runtime-C28YEAHC.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-
|
|
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-DIPnBwlf.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-DIPnBwlf.cjs';
|
|
8
|
+
import { T as ToolHandler, a as Tool, A as AnyTool, b as ToolRegistry, c as ToolExecutionResult } from './compose-C4QxEZOS.cjs';
|
|
9
|
+
export { d as AppliedSkillResult, e as ApplySkillOptions, P as ParsedFrontmatter, S as Skill, f as SkillFrontmatter, g as SkillSummary, h as ToolExecutionContext, i as ToolExecutionFailure, j as ToolExecutionSuccess, k as ToolRegistryOptions, l as applySkill, p as parseFrontmatter } from './compose-C4QxEZOS.cjs';
|
|
10
10
|
import { M as McpClientLike, a as McpToolDescriptor, b as McpTask, c as McpCallToolResult } from './types-CI-gM2u5.cjs';
|
|
11
11
|
export { d as McpContentBlock, e as McpCreateTaskResult, f as McpElicitationFormRequest, g as McpElicitationHandlers, h as McpElicitationRequest, i as McpElicitationResult, j as McpElicitationUrlRequest, k as McpIcon, l as McpInputRequiredResult, m as McpListToolsParams, n as McpListToolsResult, o as McpRequestOptions, p as McpServerCapabilities, q as McpTaskMethod, r as McpTaskRequest, s as McpTaskStatus, t as McpToolAnnotations, u as McpToolCallResult, v as McpToolExecution } from './types-CI-gM2u5.cjs';
|
|
12
12
|
import * as Otel from '@opentelemetry/api';
|
|
@@ -1655,25 +1655,34 @@ declare function batchEmbed(client: OllamaClient, options: EmbedBatchOptions): P
|
|
|
1655
1655
|
*/
|
|
1656
1656
|
|
|
1657
1657
|
/**
|
|
1658
|
-
*
|
|
1659
|
-
*
|
|
1658
|
+
* Whole-request size cap, in bytes, for `/v1/systemone` — the maximum
|
|
1659
|
+
* serialized size of the complete request, base64 image bytes included.
|
|
1660
1660
|
*
|
|
1661
|
-
*
|
|
1661
|
+
* Part of the dual cap clarified upstream on 2026-10-16: every request
|
|
1662
|
+
* must satisfy BOTH bounds simultaneously — this whole-request cap AND
|
|
1663
|
+
* the text-and-schema cap of {@link MAX_SYSTEM_ONE_REQUEST_BYTES}
|
|
1664
|
+
* (64 KiB, images excluded). The bumped whole-request cap exists
|
|
1665
|
+
* specifically to accommodate base64-encoded image bytes shared across
|
|
1666
|
+
* all questions in a single System One call; the text and schema
|
|
1667
|
+
* portion may never exceed 64 KiB regardless of whether images are
|
|
1668
|
+
* attached.
|
|
1669
|
+
*
|
|
1670
|
+
* The Ollama server enforces both bounds server-side and rejects
|
|
1662
1671
|
* oversized payloads with HTTP 413. The SDK's runtime also enforces
|
|
1663
|
-
*
|
|
1672
|
+
* them client-side (see `OllamaRuntime`'s `maxRequestBytesWithImages`
|
|
1664
1673
|
* handling) so the round-trip is avoided.
|
|
1665
|
-
*
|
|
1666
|
-
* Without images, the limit is the much smaller
|
|
1667
|
-
* {@link MAX_SYSTEM_ONE_REQUEST_BYTES} (64 KiB) — the bumped
|
|
1668
|
-
* images-cap exists specifically to accommodate base64-encoded image
|
|
1669
|
-
* bytes shared across all questions in a single System One call.
|
|
1670
1674
|
*/
|
|
1671
1675
|
declare const MAX_SYSTEM_ONE_IMAGES_BYTES: number;
|
|
1672
1676
|
/**
|
|
1673
|
-
*
|
|
1674
|
-
*
|
|
1675
|
-
*
|
|
1676
|
-
*
|
|
1677
|
+
* Text-and-schema size cap, in bytes, for `/v1/systemone` — the maximum
|
|
1678
|
+
* serialized size of the request with its `images` array excluded.
|
|
1679
|
+
*
|
|
1680
|
+
* Part of the dual cap clarified upstream on 2026-10-16: this bound
|
|
1681
|
+
* applies to EVERY request, images or not — attaching images raises
|
|
1682
|
+
* the whole-request ceiling to {@link MAX_SYSTEM_ONE_IMAGES_BYTES}
|
|
1683
|
+
* (32 MiB) but never relaxes this 64 KiB text-and-schema ceiling. The
|
|
1684
|
+
* runtime enforces both bounds client-side (see `OllamaRuntime`'s
|
|
1685
|
+
* `maxRequestBytes` handling).
|
|
1677
1686
|
*/
|
|
1678
1687
|
declare const MAX_SYSTEM_ONE_REQUEST_BYTES: number;
|
|
1679
1688
|
/**
|
|
@@ -1740,16 +1749,33 @@ type SystemOneAnswers<Q extends SystemOneQuestions = SystemOneQuestions> = {
|
|
|
1740
1749
|
* ## Image support
|
|
1741
1750
|
*
|
|
1742
1751
|
* The `images` field accepts up to N base64-encoded images shared by
|
|
1743
|
-
* all questions in the request.
|
|
1744
|
-
*
|
|
1745
|
-
*
|
|
1746
|
-
* {@link MAX_SYSTEM_ONE_REQUEST_BYTES} (64 KiB)
|
|
1752
|
+
* all questions in the request. The dual cap (2026-10-16 upstream
|
|
1753
|
+
* clarification) applies to every request simultaneously: the text and
|
|
1754
|
+
* schema portion (images excluded) must stay within
|
|
1755
|
+
* {@link MAX_SYSTEM_ONE_REQUEST_BYTES} (64 KiB), and the whole payload
|
|
1756
|
+
* (JSON + images) within {@link MAX_SYSTEM_ONE_IMAGES_BYTES} (32 MiB).
|
|
1747
1757
|
*
|
|
1748
1758
|
* Use {@link estimateSystemOneRequestBytes} for a client-side pre-flight
|
|
1749
1759
|
* check before sending a large multi-image batch — the runtime also
|
|
1750
|
-
* enforces
|
|
1760
|
+
* enforces both caps, but the early check avoids the round-trip when
|
|
1751
1761
|
* the caller already knows the payload is too large.
|
|
1752
1762
|
*
|
|
1763
|
+
* ## Context window
|
|
1764
|
+
*
|
|
1765
|
+
* Beyond the byte caps, upstream requires the complete input (state,
|
|
1766
|
+
* questions, and images) to fit the model's loaded context window, and
|
|
1767
|
+
* System One never truncates input — oversized prompts are rejected by
|
|
1768
|
+
* the server with HTTP 400 locally ("a rendered prompt that exceeds the
|
|
1769
|
+
* loaded context"), not 413 (which is reserved for the byte caps
|
|
1770
|
+
* above); for cloud requests, upstream documents 413 for input that
|
|
1771
|
+
* exceeds the model's context window (65,536 tokens) as well as for
|
|
1772
|
+
* requests over 13 MiB.
|
|
1773
|
+
* Decision models (Nimble, Tev) additionally reserve two token
|
|
1774
|
+
* positions at the end of the window for scoring. The SDK deliberately
|
|
1775
|
+
* does not estimate this client-side (upstream documents no
|
|
1776
|
+
* tokenization formula); callers who need the real limit can use
|
|
1777
|
+
* `client.models.getContextLength()`.
|
|
1778
|
+
*
|
|
1753
1779
|
* Requires Clef or Clef Flash with vision weights. URLs and data URLs
|
|
1754
1780
|
* are NOT supported — pre-encode the bytes to base64 before adding to
|
|
1755
1781
|
* the array.
|
|
@@ -1768,8 +1794,12 @@ interface SystemOneResponse<Q extends SystemOneQuestions = SystemOneQuestions> e
|
|
|
1768
1794
|
}
|
|
1769
1795
|
/**
|
|
1770
1796
|
* Estimate the on-the-wire byte size of a System One request body, for
|
|
1771
|
-
* pre-flight
|
|
1772
|
-
*
|
|
1797
|
+
* pre-flight validation against the dual cap (2026-10-16 upstream
|
|
1798
|
+
* clarification): the whole body against
|
|
1799
|
+
* {@link MAX_SYSTEM_ONE_IMAGES_BYTES} (32 MiB) and, when `images` is
|
|
1800
|
+
* attached, the images-excluded portion against
|
|
1801
|
+
* {@link MAX_SYSTEM_ONE_REQUEST_BYTES} (64 KiB) — pass
|
|
1802
|
+
* `{ excludeImages: true }` to measure the text-and-schema portion.
|
|
1773
1803
|
*
|
|
1774
1804
|
* The estimate is conservative: it uses `JSON.stringify` length and
|
|
1775
1805
|
* assumes UTF-8 encoding. The actual wire size may differ slightly due
|
|
@@ -1781,12 +1811,18 @@ interface SystemOneResponse<Q extends SystemOneQuestions = SystemOneQuestions> e
|
|
|
1781
1811
|
* ```ts
|
|
1782
1812
|
* const request: SystemOneRequest = { ... };
|
|
1783
1813
|
* const bytes = estimateSystemOneRequestBytes(request);
|
|
1784
|
-
* const
|
|
1785
|
-
*
|
|
1814
|
+
* const textBytes = request.images?.length
|
|
1815
|
+
* ? estimateSystemOneRequestBytes(request, { excludeImages: true })
|
|
1816
|
+
* : bytes;
|
|
1817
|
+
* if (textBytes > MAX_SYSTEM_ONE_REQUEST_BYTES || bytes > MAX_SYSTEM_ONE_IMAGES_BYTES) {
|
|
1818
|
+
* throw new Error(`payload ${bytes}B (text ${textBytes}B) exceeds the dual cap`);
|
|
1819
|
+
* }
|
|
1786
1820
|
* await client.systemOne(request);
|
|
1787
1821
|
* ```
|
|
1788
1822
|
*/
|
|
1789
|
-
declare function estimateSystemOneRequestBytes(request: SystemOneRequest | SystemOneRequest$1
|
|
1823
|
+
declare function estimateSystemOneRequestBytes(request: SystemOneRequest | SystemOneRequest$1, options?: {
|
|
1824
|
+
readonly excludeImages?: boolean;
|
|
1825
|
+
}): number;
|
|
1790
1826
|
|
|
1791
1827
|
/**
|
|
1792
1828
|
* Higher-level System One decision helpers.
|
|
@@ -1817,6 +1853,14 @@ interface ChoiceDecision {
|
|
|
1817
1853
|
readonly probabilities: Record<string, number>;
|
|
1818
1854
|
/** Distribution concentration (0–1). NOT a guarantee of correctness. */
|
|
1819
1855
|
readonly confidence: number;
|
|
1856
|
+
/**
|
|
1857
|
+
* Present only when `minConfidence` was configured: `true` when
|
|
1858
|
+
* `confidence >= minConfidence`. Autonomous flows should treat `false` as
|
|
1859
|
+
* "do not act on this decision" — the official System One docs warn that a
|
|
1860
|
+
* high confidence does not guarantee correctness, and a barely-majority
|
|
1861
|
+
* choice (e.g. 0.51) is rarely safe to act on unattended.
|
|
1862
|
+
*/
|
|
1863
|
+
readonly isConfident?: boolean;
|
|
1820
1864
|
/** Token usage for the call. */
|
|
1821
1865
|
readonly usage: {
|
|
1822
1866
|
readonly input_tokens: number;
|
|
@@ -1830,7 +1874,11 @@ interface ChoiceDecision {
|
|
|
1830
1874
|
interface NoulDecision {
|
|
1831
1875
|
/** Probability of true (0–1). */
|
|
1832
1876
|
readonly noul: number;
|
|
1833
|
-
/**
|
|
1877
|
+
/**
|
|
1878
|
+
* Boolean decision: `true` if `noul >= minProbability` (default 0.5).
|
|
1879
|
+
* Raise the bar for safety gates with `minProbability` — e.g. 0.8 for
|
|
1880
|
+
* irreversible actions.
|
|
1881
|
+
*/
|
|
1834
1882
|
readonly bool: boolean;
|
|
1835
1883
|
/** Token usage for the call. */
|
|
1836
1884
|
readonly usage: {
|
|
@@ -1852,6 +1900,8 @@ interface ScoreDecision {
|
|
|
1852
1900
|
readonly probabilities: Record<string, number>;
|
|
1853
1901
|
/** Distribution concentration (0–1). NOT a guarantee of correctness. */
|
|
1854
1902
|
readonly confidence: number;
|
|
1903
|
+
/** Present only when `minConfidence` was configured: `confidence >= minConfidence`. */
|
|
1904
|
+
readonly isConfident?: boolean;
|
|
1855
1905
|
/** Token usage for the call. */
|
|
1856
1906
|
readonly usage: {
|
|
1857
1907
|
readonly input_tokens: number;
|
|
@@ -1866,6 +1916,8 @@ interface RankResult<T extends string> {
|
|
|
1866
1916
|
readonly candidate: T;
|
|
1867
1917
|
readonly score: number;
|
|
1868
1918
|
readonly confidence: number;
|
|
1919
|
+
/** Present only when `minConfidence` was configured: `confidence >= minConfidence`. */
|
|
1920
|
+
readonly isConfident?: boolean;
|
|
1869
1921
|
}
|
|
1870
1922
|
/**
|
|
1871
1923
|
* Higher-level System One decision helpers.
|
|
@@ -1906,6 +1958,12 @@ interface Decision {
|
|
|
1906
1958
|
criteria: Record<string, string | null>;
|
|
1907
1959
|
images?: string[];
|
|
1908
1960
|
keepAlive?: string | number;
|
|
1961
|
+
/**
|
|
1962
|
+
* Opt-in confidence gate in (0, 1]. When set, the result carries
|
|
1963
|
+
* `isConfident: confidence >= minConfidence` so autonomous flows can
|
|
1964
|
+
* refuse to act on barely-majority decisions. Off by default.
|
|
1965
|
+
*/
|
|
1966
|
+
minConfidence?: number;
|
|
1909
1967
|
}): Promise<ChoiceDecision>;
|
|
1910
1968
|
/**
|
|
1911
1969
|
* Ask a single yes/no (noul) question. Returns the probability of
|
|
@@ -1920,6 +1978,12 @@ interface Decision {
|
|
|
1920
1978
|
instructions: SystemOneContent;
|
|
1921
1979
|
images?: string[];
|
|
1922
1980
|
keepAlive?: string | number;
|
|
1981
|
+
/**
|
|
1982
|
+
* Inclusive lower bound in (0, 1] the probability of `true` must meet
|
|
1983
|
+
* for `bool` to be `true`. Default 0.5 (a coin-flip majority). Raise it
|
|
1984
|
+
* (e.g. 0.8) for safety gates and irreversible actions.
|
|
1985
|
+
*/
|
|
1986
|
+
minProbability?: number;
|
|
1923
1987
|
}): Promise<NoulDecision>;
|
|
1924
1988
|
/**
|
|
1925
1989
|
* Ask a single score question. Returns the probability-weighted
|
|
@@ -1932,10 +1996,12 @@ interface Decision {
|
|
|
1932
1996
|
model: string;
|
|
1933
1997
|
state: SystemOneContent;
|
|
1934
1998
|
instructions: SystemOneContent;
|
|
1935
|
-
/** Ordered criteria from lowest (index 0) to highest. 2–
|
|
1999
|
+
/** Ordered criteria from lowest (index 0) to highest. 2–10 items. */
|
|
1936
2000
|
criteria: string[];
|
|
1937
2001
|
images?: string[];
|
|
1938
2002
|
keepAlive?: string | number;
|
|
2003
|
+
/** Opt-in confidence gate in (0, 1] — see {@link Decision.choice}. */
|
|
2004
|
+
minConfidence?: number;
|
|
1939
2005
|
}): Promise<ScoreDecision>;
|
|
1940
2006
|
/**
|
|
1941
2007
|
* Route a request to one of N named options. Convenience wrapper
|
|
@@ -1951,9 +2017,12 @@ interface Decision {
|
|
|
1951
2017
|
criteria: Record<T, string | null>;
|
|
1952
2018
|
images?: string[];
|
|
1953
2019
|
keepAlive?: string | number;
|
|
2020
|
+
/** Opt-in confidence gate in (0, 1] — see {@link Decision.choice}. */
|
|
2021
|
+
minConfidence?: number;
|
|
1954
2022
|
}): Promise<{
|
|
1955
2023
|
readonly route: T;
|
|
1956
2024
|
readonly confidence: number;
|
|
2025
|
+
readonly isConfident?: boolean;
|
|
1957
2026
|
}>;
|
|
1958
2027
|
/**
|
|
1959
2028
|
* Verify whether a claim is supported by evidence. Convenience
|
|
@@ -1972,6 +2041,11 @@ interface Decision {
|
|
|
1972
2041
|
instructions?: SystemOneContent;
|
|
1973
2042
|
images?: string[];
|
|
1974
2043
|
keepAlive?: string | number;
|
|
2044
|
+
/**
|
|
2045
|
+
* Inclusive lower bound in (0, 1] the probability of `true` must meet
|
|
2046
|
+
* for `verified`. Default 0.5. See {@link Decision.noul}.
|
|
2047
|
+
*/
|
|
2048
|
+
minProbability?: number;
|
|
1975
2049
|
}): Promise<{
|
|
1976
2050
|
readonly verified: boolean;
|
|
1977
2051
|
readonly probability: number;
|
|
@@ -1991,7 +2065,7 @@ interface Decision {
|
|
|
1991
2065
|
rank<T extends string>(params: {
|
|
1992
2066
|
model: string;
|
|
1993
2067
|
instructions: SystemOneContent;
|
|
1994
|
-
/** Ordered criteria from lowest (index 0) to highest. 2–
|
|
2068
|
+
/** Ordered criteria from lowest (index 0) to highest. 2–10 items. */
|
|
1995
2069
|
criteria: string[];
|
|
1996
2070
|
candidates: ReadonlyArray<{
|
|
1997
2071
|
readonly id: T;
|
|
@@ -1999,6 +2073,8 @@ interface Decision {
|
|
|
1999
2073
|
}>;
|
|
2000
2074
|
images?: string[];
|
|
2001
2075
|
keepAlive?: string | number;
|
|
2076
|
+
/** Opt-in confidence gate in (0, 1] — flags each result with `isConfident`. */
|
|
2077
|
+
minConfidence?: number;
|
|
2002
2078
|
}): Promise<ReadonlyArray<RankResult<T>>>;
|
|
2003
2079
|
}
|
|
2004
2080
|
/** Create a Decision helper bound to an OllamaClient. */
|
|
@@ -2323,11 +2399,15 @@ declare class OllamaClient {
|
|
|
2323
2399
|
* 1–64 typed questions (choice, noul, or score) against a provided state
|
|
2324
2400
|
* and returns typed answers with probabilities and confidence.
|
|
2325
2401
|
*
|
|
2326
|
-
* Local
|
|
2327
|
-
*
|
|
2328
|
-
*
|
|
2329
|
-
*
|
|
2330
|
-
*
|
|
2402
|
+
* Local and cloud (since the 2026-10-16 upstream System One cloud
|
|
2403
|
+
* launch): `model` also accepts cloud models such as `clef:cloud` —
|
|
2404
|
+
* cloud models require Ollama >= 0.40.5 or the hosted
|
|
2405
|
+
* `https://ollama.com` endpoint. Requires Ollama >= 0.35.0 locally.
|
|
2406
|
+
* The runtime enforces the version constraint automatically (lazily
|
|
2407
|
+
* fetching `/api/version` when `enforceVersion` is `'auto'` or
|
|
2408
|
+
* `'strict'`). Request size is checked client-side as a dual cap:
|
|
2409
|
+
* text and schema (images excluded) within 64 KiB AND the whole
|
|
2410
|
+
* request within 32 MiB.
|
|
2331
2411
|
*
|
|
2332
2412
|
* The generic `Q` parameter captures the caller's question map at
|
|
2333
2413
|
* compile time, giving key-safe answer access:
|
|
@@ -2807,6 +2887,180 @@ declare function toDataStream<TChunk, TFinal>(stream: OllamaStream<TChunk, TFina
|
|
|
2807
2887
|
*/
|
|
2808
2888
|
declare function toResponse<TChunk, TFinal>(stream: OllamaStream<TChunk, TFinal>, init?: ResponseInit): Response;
|
|
2809
2889
|
|
|
2890
|
+
/**
|
|
2891
|
+
* Typed progress callback helpers for `/api/pull` and `/api/push` streams.
|
|
2892
|
+
*
|
|
2893
|
+
* Ollama emits newline-delimited progress frames of the shape:
|
|
2894
|
+
*
|
|
2895
|
+
* ```json
|
|
2896
|
+
* {"status":"pulling manifest"}
|
|
2897
|
+
* {"status":"downloading","digest":"sha256:...","total":1234567,"completed":123}
|
|
2898
|
+
* {"status":"verifying sha256 digest"}
|
|
2899
|
+
* {"status":"writing manifest","digest":"sha256:...","total":42,"completed":42}
|
|
2900
|
+
* {"status":"success"}
|
|
2901
|
+
* ```
|
|
2902
|
+
*
|
|
2903
|
+
* The SDK already exposes these as a typed {@link OllamaStream} via
|
|
2904
|
+
* {@link ModelsClient.pull} / {@link ModelsClient.push} when called
|
|
2905
|
+
* with `{ stream: true }`. This file adds a higher-level helper that
|
|
2906
|
+
* invokes a typed callback on every progress event with a pre-computed
|
|
2907
|
+
* `percent` field — for callers who want a fire-and-forget pull/push
|
|
2908
|
+
* without manually iterating the stream.
|
|
2909
|
+
*
|
|
2910
|
+
* ## When to use this vs. the raw `OllamaStream`
|
|
2911
|
+
*
|
|
2912
|
+
* - **`onProgress(stream, cb)`** — best for download/upload UIs that
|
|
2913
|
+
* just need to render a progress bar. Resolves on `success`,
|
|
2914
|
+
* rejects on stream error.
|
|
2915
|
+
* - **Raw `for await ... of stream`** — best for callers who want
|
|
2916
|
+
* every chunk as a typed event (e.g. for structured logging, or
|
|
2917
|
+
* to react to specific `status` values like `"downloading"` vs
|
|
2918
|
+
* `"verifying sha256 digest"`).
|
|
2919
|
+
*/
|
|
2920
|
+
|
|
2921
|
+
/**
|
|
2922
|
+
* A single progress event delivered to {@link onProgress}'s callback.
|
|
2923
|
+
*
|
|
2924
|
+
* `percent` is `undefined` when the server hasn't reported byte
|
|
2925
|
+
* totals (e.g. for `pulling manifest`, `verifying sha256 digest`,
|
|
2926
|
+
* `success` — these status lines carry no `total`/`completed`).
|
|
2927
|
+
* For `downloading` / `writing manifest` / `writing layer` style
|
|
2928
|
+
* events, `percent` is the ratio of `completed / total`, clamped
|
|
2929
|
+
* to `[0, 100]` and rounded to two decimals.
|
|
2930
|
+
*
|
|
2931
|
+
* `bytesPerSecond` and `etaSeconds` are populated by {@link onProgress}
|
|
2932
|
+
* (via {@link createProgressSpeedTracker}) once at least two
|
|
2933
|
+
* byte-bearing frames for the same layer have arrived. Callers using
|
|
2934
|
+
* {@link toPullProgressEvent} directly get them from their own tracker
|
|
2935
|
+
* — the pure wrapper never measures time.
|
|
2936
|
+
*/
|
|
2937
|
+
interface PullProgressEvent {
|
|
2938
|
+
/** Ollama's status string (`"pulling manifest"`, `"downloading"`, `"success"`, …). */
|
|
2939
|
+
readonly status: string;
|
|
2940
|
+
/** SHA-256 digest of the layer being transferred, when applicable. */
|
|
2941
|
+
readonly digest?: string | undefined;
|
|
2942
|
+
/** Total bytes for this transfer, when the server has reported it. */
|
|
2943
|
+
readonly total?: number | undefined;
|
|
2944
|
+
/** Bytes transferred so far, when the server has reported it. */
|
|
2945
|
+
readonly completed?: number | undefined;
|
|
2946
|
+
/** Completion percentage in `[0, 100]`, or `undefined` when no byte total. */
|
|
2947
|
+
readonly percent?: number | undefined;
|
|
2948
|
+
/**
|
|
2949
|
+
* Cumulative-average transfer speed for the current layer, in bytes per
|
|
2950
|
+
* second (measured since the layer's first byte-bearing frame). `undefined`
|
|
2951
|
+
* until a second byte-bearing frame of the same layer arrives.
|
|
2952
|
+
*/
|
|
2953
|
+
readonly bytesPerSecond?: number | undefined;
|
|
2954
|
+
/**
|
|
2955
|
+
* Estimated seconds remaining for the current layer at the observed
|
|
2956
|
+
* speed: `(total - completed) / bytesPerSecond`. `undefined` while the
|
|
2957
|
+
* speed is unknown or the server hasn't reported a total; `0` once
|
|
2958
|
+
* `completed >= total`.
|
|
2959
|
+
*/
|
|
2960
|
+
readonly etaSeconds?: number | undefined;
|
|
2961
|
+
/** The raw upstream frame, for callers who need fields this helper skips. */
|
|
2962
|
+
readonly raw: ProgressResponse;
|
|
2963
|
+
}
|
|
2964
|
+
/**
|
|
2965
|
+
* Callback shape accepted by {@link onProgress}.
|
|
2966
|
+
*/
|
|
2967
|
+
type ProgressCallback = (event: PullProgressEvent) => void;
|
|
2968
|
+
/**
|
|
2969
|
+
* Compute the completion percentage from a progress chunk.
|
|
2970
|
+
*
|
|
2971
|
+
* Returns `undefined` when either `total` or `completed` is missing
|
|
2972
|
+
* or zero (the server emits byte totals only for `downloading` /
|
|
2973
|
+
* `writing manifest` / `writing layer` style events; for
|
|
2974
|
+
* `pulling manifest`, `verifying sha256 digest`, `success`, etc. the
|
|
2975
|
+
* totals are absent and percent is undefined).
|
|
2976
|
+
*
|
|
2977
|
+
* When both are present, returns `Math.round((completed / total) * 10000) / 100`
|
|
2978
|
+
* — i.e. percent with two decimal places (e.g. `42.37`), clamped to
|
|
2979
|
+
* `[0, 100]` to guard against upstream reporting inconsistencies
|
|
2980
|
+
* (sometimes the server briefly reports `completed > total` during
|
|
2981
|
+
* dedup / verification phases).
|
|
2982
|
+
*/
|
|
2983
|
+
declare function computeProgressPercent(chunk: ProgressResponse): number | undefined;
|
|
2984
|
+
/**
|
|
2985
|
+
* Wrap a {@link ProgressResponse} into a {@link PullProgressEvent}
|
|
2986
|
+
* with a pre-computed `percent` field.
|
|
2987
|
+
*/
|
|
2988
|
+
declare function toPullProgressEvent(chunk: ProgressResponse): PullProgressEvent;
|
|
2989
|
+
/**
|
|
2990
|
+
* Speed/ETA readings produced by {@link createProgressSpeedTracker}.
|
|
2991
|
+
*/
|
|
2992
|
+
interface ProgressSpeed {
|
|
2993
|
+
/** Cumulative-average bytes/second for the current layer, once measurable. */
|
|
2994
|
+
readonly bytesPerSecond?: number | undefined;
|
|
2995
|
+
/** Estimated seconds remaining for the current layer; `0` once complete. */
|
|
2996
|
+
readonly etaSeconds?: number | undefined;
|
|
2997
|
+
}
|
|
2998
|
+
/**
|
|
2999
|
+
* A stateful per-layer transfer-speed measurer. Feed it every raw
|
|
3000
|
+
* `ProgressResponse` chunk, in arrival order; it returns the current
|
|
3001
|
+
* speed/ETA readings for that chunk's layer.
|
|
3002
|
+
*
|
|
3003
|
+
* This is the building block {@link onProgress} uses internally, exported
|
|
3004
|
+
* for consumers who iterate the raw `OllamaStream` themselves (structured
|
|
3005
|
+
* logging, custom dashboards) and would otherwise have to hand-roll a
|
|
3006
|
+
* stateful byte counter.
|
|
3007
|
+
*
|
|
3008
|
+
* Semantics:
|
|
3009
|
+
* - **Per-layer epochs.** A pull/push transfers several layers; each has
|
|
3010
|
+
* its own `digest` and byte range, and `completed` restarts from a low
|
|
3011
|
+
* value when the next layer begins. The tracker starts a fresh epoch
|
|
3012
|
+
* whenever the digest changes or `completed` regresses, so the speed
|
|
3013
|
+
* never averages across layers.
|
|
3014
|
+
* - **Cumulative average.** Speed is measured from the layer's first
|
|
3015
|
+
* byte-bearing frame — `(completed - firstCompleted) / elapsed` — which
|
|
3016
|
+
* is stable for progress bars (instantaneous frame-to-frame rates jitter
|
|
3017
|
+
* wildly).
|
|
3018
|
+
* - **Monotonic clock.** `performance.now()`, immune to wall-clock
|
|
3019
|
+
* adjustments.
|
|
3020
|
+
*
|
|
3021
|
+
* @example
|
|
3022
|
+
* ```ts
|
|
3023
|
+
* const speed = createProgressSpeedTracker();
|
|
3024
|
+
* const stream = await client.models.pull({ model: 'llama3.2', stream: true });
|
|
3025
|
+
* for await (const event of stream) {
|
|
3026
|
+
* if (event.type === 'message') {
|
|
3027
|
+
* const { bytesPerSecond, etaSeconds } = speed(event.data.chunk);
|
|
3028
|
+
* // render: 42.37% at 8.1 MiB/s, ETA 3s
|
|
3029
|
+
* }
|
|
3030
|
+
* }
|
|
3031
|
+
* ```
|
|
3032
|
+
*/
|
|
3033
|
+
declare function createProgressSpeedTracker(): (chunk: ProgressResponse) => ProgressSpeed;
|
|
3034
|
+
/**
|
|
3035
|
+
* Subscribe to a pull/push stream with a typed progress callback.
|
|
3036
|
+
*
|
|
3037
|
+
* Iterates the stream, invokes `callback` on every progress event
|
|
3038
|
+
* with a pre-computed `percent` field, and resolves when the stream
|
|
3039
|
+
* completes (`success` status). Rejects with {@link OllamaStreamError}
|
|
3040
|
+
* if the stream emits an in-band `{"error": "..."}` frame, or with
|
|
3041
|
+
* whatever error the underlying transport surfaces for HTTP-level
|
|
3042
|
+
* failures.
|
|
3043
|
+
*
|
|
3044
|
+
* @example
|
|
3045
|
+
* ```ts
|
|
3046
|
+
* const stream = await client.models.pull({ model: 'llama3.2', stream: true });
|
|
3047
|
+
* await onProgress(stream, (event) => {
|
|
3048
|
+
* if (event.percent !== undefined) {
|
|
3049
|
+
* console.log(`${event.status}: ${event.percent}% (${event.digest?.slice(0, 12) ?? '-'})`);
|
|
3050
|
+
* } else {
|
|
3051
|
+
* console.log(event.status);
|
|
3052
|
+
* }
|
|
3053
|
+
* });
|
|
3054
|
+
* console.log('pull complete');
|
|
3055
|
+
* ```
|
|
3056
|
+
*
|
|
3057
|
+
* @param stream The `OllamaStream` returned by `models.pull({ stream: true })`.
|
|
3058
|
+
* @param callback Invoked on every progress event.
|
|
3059
|
+
* @returns A promise that resolves to the final {@link ProgressStreamResult}
|
|
3060
|
+
* (carrying `status: 'success'`) when the stream completes.
|
|
3061
|
+
*/
|
|
3062
|
+
declare function onProgress(stream: OllamaStream<ProgressResponse, ProgressStreamResult>, callback: ProgressCallback): Promise<ProgressStreamResult>;
|
|
3063
|
+
|
|
2810
3064
|
/**
|
|
2811
3065
|
* Zero-copy stream observation — the safe alternative to `ReadableStream.tee()`
|
|
2812
3066
|
* for multi-sink consumption (audit logging, token counting, telemetry taps).
|
|
@@ -4049,4 +4303,4 @@ declare class ModelAffinityScheduler {
|
|
|
4049
4303
|
/** Convenience factory — `createModelAffinityScheduler(client, opts)` reads better in setups. */
|
|
4050
4304
|
declare function createModelAffinityScheduler(client: ModelAffinityClient | OllamaClient, options?: ModelAffinitySchedulerOptions): ModelAffinityScheduler;
|
|
4051
4305
|
|
|
4052
|
-
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, ProgressResponse, ProgressStreamResult, PsResponse, 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, contextWarningMessage, createDecision, createModelAffinityScheduler, createOllamaCloudFreeTierQuota, 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, parseNdjsonStream, parseStructuredOutput, recommendContextWindow, registerMcpTools, resolveContextLength, resolveCredentialEndpoints, sanitizeHistoryForNextTurn, setSpanError, toDataStream, toResponse, toTextStream, withRetry, withSpan, zodToJsonSchema };
|
|
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 };
|