@nemesis-oss/ollama-sdk 1.14.0 → 1.16.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 +42 -0
- package/README.md +131 -6
- package/dist/{anthropic-DrDUfbfQ.d.ts → anthropic-AKbXnWJU.d.cts} +1 -1
- package/dist/{anthropic-UeaVjLeP.d.cts → anthropic-CTv2acbj.d.ts} +1 -1
- package/dist/generated-api.d.cts +4 -4
- package/dist/generated-api.d.ts +4 -4
- package/dist/generated-runtime.cjs.map +1 -1
- package/dist/generated-runtime.d.cts +1 -1
- package/dist/generated-runtime.d.ts +1 -1
- package/dist/generated-runtime.js.map +1 -1
- package/dist/index.cjs +217 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +310 -5
- package/dist/index.d.ts +310 -5
- package/dist/index.js +213 -7
- package/dist/index.js.map +1 -1
- package/dist/mcp-generated.d.cts +1 -1
- package/dist/mcp-generated.d.ts +1 -1
- package/dist/{runtime-BIjr5ME4.d.ts → runtime-CFuv7Ifh.d.ts} +29 -1
- package/dist/{runtime-C4RRHqOs.d.cts → runtime-CdZP-N7j.d.cts} +29 -1
- package/dist/skills.cjs.map +1 -1
- package/dist/skills.js.map +1 -1
- package/dist/testing.cjs +13 -11
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +48 -8
- package/dist/testing.d.ts +48 -8
- package/dist/testing.js +13 -11
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { T as ThinkingMetadata, M as ModelResponse, R as RequestCancellationOptions, S as ShowRequestOptions, a as ShowResponse, P as PullRequestOptions, b as ProgressResponse, c as PushRequestOptions, C as CreateRequestOptions, D as DeleteRequestOptions, d as StatusResponse, e as CopyRequestOptions, f as PsResponse, V as VersionResponse, g as ToolParameters, h as ThinkValue, i as ToolCall, j as ChatRequestOptions, k as ModelOptions, l as ToolDefinition, F as FormatOption, m as ChatResponse, n as Message, G as GenerateRequestOptions, o as GenerateResponse, E as EmbedRequestOptions, p as EmbedResponse, q as EmbeddingsRequestOptions, r as EmbeddingsResponse, W as WebSearchRequestOptions, s as WebSearchResponse, t as WebFetchRequestOptions, u as WebFetchResponse, U as UsageRequestOptions, B as BalanceRequestOptions, v as PingResult, w as VisionInput } from './types-DbPnfVh-.js';
|
|
2
2
|
export { L as ListResponse, x as Logprob, y as LogprobToken, z as ModelDetails, A as Role, H as ToolCallFunction, I as ToolFunctionDefinition, J as ToolProperty, K as UsageRange, N as UsageScope, O as WebSearchResult, Q as imageStringNeedsResolution, X as resolveImageInput } from './types-DbPnfVh-.js';
|
|
3
|
-
import { H as HttpClient, F as FetchLike, M as Middleware, L as Logger, R as RequestLifecycleHook, c as OllamaStreamEvent, A as AbortableAsyncIterable, d as OllamaStreamEventType, P as ProgressStreamResult, B as BinaryBody, O as OllamaRuntime, C as ChatStreamResult, G as GenerateStreamResult, e as RawUsageSource, T as TokenUsage } from './runtime-
|
|
4
|
-
export { D as DoneEvent, E as ErrorEvent, f as HttpBody, g as HttpClientOptions, h as HttpRequestOptions, i as LifecycleErrorEvent, j as LifecycleRetryEvent, k as LifecycleStartEvent, l as LifecycleSuccessEvent, m as LogFn, n as MessageEvent, o as MiddlewareContext, N as NANOS_PER_MS, p as NANOS_PER_SECOND, q as
|
|
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-CFuv7Ifh.js';
|
|
4
|
+
export { D as DoneEvent, E as ErrorEvent, f as HttpBody, g as HttpClientOptions, h as HttpRequestOptions, i as LifecycleErrorEvent, j as LifecycleRetryEvent, k as LifecycleStartEvent, l as LifecycleSuccessEvent, m as LogFn, n as MessageEvent, o as MiddlewareContext, N as NANOS_PER_MS, p as NANOS_PER_SECOND, q as NETWORK_ERROR_CODES, r as NOOP_LOGGER, s as NextFunction, t as OllamaAbortError, u as OllamaAgentMaxIterationsError, v as OllamaAgentMaxToolCallsError, w as OllamaAgentToolLoopError, x as OllamaAuthError, y as OllamaBadGatewayError, z as OllamaClientError, J as OllamaClientErrorOptions, K as OllamaErrorRequestContext, Q as OllamaErrorResponseContext, U as OllamaGenericClientError, V as OllamaIncompatibleModelError, W as OllamaMcpError, X as OllamaModelRoutingError, Y as OllamaNetworkError, Z as OllamaNotFoundError, _ as OllamaOverloadedError, $ as OllamaQuotaExceededError, a0 as OllamaRateLimitError, a1 as OllamaRequestTooLargeError, a2 as OllamaRequestValidationError, a3 as OllamaResponseValidationError, a4 as OllamaServerError, a5 as OllamaServerVersionUnknownError, a6 as OllamaSkillInvalidError, a7 as OllamaSkillNotFoundError, a8 as OllamaStreamError, a9 as OllamaTimeoutError, aa as OllamaToolTimeoutError, ab as OllamaToolValidationError, ac as OllamaUnsupportedCapabilityError, ad as RequestContext, ae as RequestLifecycleEvent, af as ResponseContext, ag as SseEvent, ah as ThinkingEvent, ai as TokenEvent, aj as ToolCallEvent, ak as composeMiddleware, al as createConsoleLogger, am as extractUsage, an as isNetworkLevelError, ao as mapError, ap as parseSseStream } from './runtime-CFuv7Ifh.js';
|
|
5
5
|
import { z } from 'zod';
|
|
6
|
-
import { R as RequestRunner, S as SystemOneChoiceAnswer, o as SystemOneNoulAnswer, p as SystemOneScoreAnswer, q as SystemOneChoiceQuestion, r as SystemOneNoulQuestion, s as SystemOneScoreQuestion, t as SystemOneRequest$1, u as SystemOneResponse$1, v as SystemOneContent, N as NativeApi, w as OpenAICompatClient, x as AnthropicCompatClient } from './anthropic-
|
|
7
|
-
export { y as AnthropicCacheControl, z as AnthropicContentBlock, B as AnthropicImageContentBlock, C as AnthropicMessage, n as AnthropicMessageStreamEvent, A as AnthropicMessagesRequest, m as AnthropicMessagesResponse, D as AnthropicMessagesStream, E as AnthropicMetadata, F as AnthropicOutputConfig, G as AnthropicRedactedThinkingContentBlock, H as AnthropicSystem, I as AnthropicSystemTextBlock, J as AnthropicTextContentBlock, K as AnthropicThinkingConfig, L as AnthropicThinkingContentBlock, M as AnthropicTool, P as AnthropicToolChoice, Q as AnthropicToolResultContentBlock, T as AnthropicToolUseContentBlock, U as AnthropicUnknownStreamEvent, V as OllamaAnthropicContentBlock, W as OllamaAnthropicMessage, X as OllamaAnthropicMessagesRequest, Y as OllamaAnthropicSystem, Z as OllamaAnthropicSystemTextBlock, _ as OllamaAnthropicTextContentBlock, $ as OllamaAnthropicThinkingConfig, a0 as OllamaAnthropicTool, a1 as OllamaAnthropicToolResultContentBlock, a2 as OllamaOpenAIChatCompletionRequest, a3 as OllamaOpenAIChatContentPart, a4 as OllamaOpenAIChatMessage, a5 as OllamaOpenAICompletionRequest, a6 as OllamaOpenAIEmbeddingRequest, a7 as OllamaOpenAIImageDataUrl, a8 as OllamaOpenAIReasoningEffort, a9 as OllamaOpenAIResponsesRequest, aa as OpenAIChatCompletionChoice, b as OpenAIChatCompletionChunk, ab as OpenAIChatCompletionChunkChoice, ac as OpenAIChatCompletionDelta, O as OpenAIChatCompletionRequest, a as OpenAIChatCompletionResponse, ad as OpenAIChatCompletionStream, ae as OpenAICompletionChoice, e as OpenAICompletionChunk, c as OpenAICompletionRequest, d as OpenAICompletionResponse, af as OpenAICompletionStream, ag as OpenAIContentPart, ah as OpenAIEmbeddingInput, ai as OpenAIEmbeddingItem, f as OpenAIEmbeddingRequest, g as OpenAIEmbeddingResponse, aj as OpenAIFunctionDefinition, ak as OpenAIImageUrlContentPart, h as OpenAIListModelsResponse, al as OpenAIMessage, i as OpenAIModelItem, am as OpenAIReasoningEffort, an as OpenAIResponseFormat, ao as OpenAIResponsesCompletedEvent, ap as OpenAIResponsesContentPartAddedEvent, aq as OpenAIResponsesContentPartDoneEvent, ar as OpenAIResponsesCreatedEvent, as as OpenAIResponsesError, at as OpenAIResponsesEventBase, au as OpenAIResponsesFailedEvent, av as OpenAIResponsesFunctionCallArgumentsDeltaEvent, aw as OpenAIResponsesFunctionCallArgumentsDoneEvent, ax as OpenAIResponsesInProgressEvent, ay as OpenAIResponsesIncompleteDetails, az as OpenAIResponsesIncompleteEvent, aA as OpenAIResponsesOutputContent, aB as OpenAIResponsesOutputFunctionCall, aC as OpenAIResponsesOutputItem, aD as OpenAIResponsesOutputItemAddedEvent, aE as OpenAIResponsesOutputItemDoneEvent, aF as OpenAIResponsesOutputMessage, aG as OpenAIResponsesOutputReasoning, aH as OpenAIResponsesOutputRefusal, aI as OpenAIResponsesOutputTextContent, aJ as OpenAIResponsesOutputTextDeltaEvent, aK as OpenAIResponsesOutputTextDoneEvent, aL as OpenAIResponsesQueuedEvent, aM as OpenAIResponsesReasoningSummaryPartAddedEvent, aN as OpenAIResponsesReasoningSummaryPartDoneEvent, aO as OpenAIResponsesReasoningSummaryTextDeltaEvent, aP as OpenAIResponsesReasoningSummaryTextDoneEvent, aQ as OpenAIResponsesReasoningTextDeltaEvent, aR as OpenAIResponsesReasoningTextDoneEvent, aS as OpenAIResponsesRefusalDeltaEvent, aT as OpenAIResponsesRefusalDoneEvent, j as OpenAIResponsesRequest, k as OpenAIResponsesResponse, aU as OpenAIResponsesStatus, aV as OpenAIResponsesStream, aW as OpenAIResponsesStreamError, l as OpenAIResponsesStreamEvent, aX as OpenAIResponsesUsage, aY as OpenAIStreamOptions, aZ as OpenAITextContentPart, a_ as OpenAITool, a$ as OpenAIToolCall, b0 as OpenAIToolCallDelta, b1 as OpenAIUsage, b2 as SystemOneConfidence, b3 as SystemOneProbabilities } from './anthropic-
|
|
6
|
+
import { R as RequestRunner, S as SystemOneChoiceAnswer, o as SystemOneNoulAnswer, p as SystemOneScoreAnswer, q as SystemOneChoiceQuestion, r as SystemOneNoulQuestion, s as SystemOneScoreQuestion, t as SystemOneRequest$1, u as SystemOneResponse$1, v as SystemOneContent, N as NativeApi, w as OpenAICompatClient, x as AnthropicCompatClient } from './anthropic-CTv2acbj.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-CTv2acbj.js';
|
|
8
8
|
import { T as ToolHandler, a as Tool, A as AnyTool, b as ToolRegistry, c as ToolExecutionResult } from './compose-CeFbHJeO.js';
|
|
9
9
|
export { d as AppliedSkillResult, e as ApplySkillOptions, P as ParsedFrontmatter, S as Skill, f as SkillFrontmatter, g as SkillSummary, h as ToolExecutionContext, i as ToolExecutionFailure, j as ToolExecutionSuccess, k as ToolRegistryOptions, l as applySkill, p as parseFrontmatter } from './compose-CeFbHJeO.js';
|
|
10
10
|
import { M as McpClientLike, a as McpToolDescriptor, b as McpTask, c as McpCallToolResult } from './types-CI-gM2u5.js';
|
|
@@ -2780,6 +2780,140 @@ declare function toDataStream<TChunk, TFinal>(stream: OllamaStream<TChunk, TFina
|
|
|
2780
2780
|
*/
|
|
2781
2781
|
declare function toResponse<TChunk, TFinal>(stream: OllamaStream<TChunk, TFinal>, init?: ResponseInit): Response;
|
|
2782
2782
|
|
|
2783
|
+
/**
|
|
2784
|
+
* Zero-copy stream observation — the safe alternative to `ReadableStream.tee()`
|
|
2785
|
+
* for multi-sink consumption (audit logging, token counting, telemetry taps).
|
|
2786
|
+
*
|
|
2787
|
+
* ## The `tee()` hazard this exists for
|
|
2788
|
+
*
|
|
2789
|
+
* Developers streaming to a UI while also feeding a logger (or a token
|
|
2790
|
+
* counter, or an OpenTelemetry exporter) typically reach for:
|
|
2791
|
+
*
|
|
2792
|
+
* ```ts
|
|
2793
|
+
* // VULNERABLE PATTERN — do not do this
|
|
2794
|
+
* const [forUi, forLogger] = response.body.tee();
|
|
2795
|
+
* ```
|
|
2796
|
+
*
|
|
2797
|
+
* WHATWG `tee()` branches share a single upstream pull mechanism: a branch
|
|
2798
|
+
* that reads slower than its sibling forces every intermediate chunk to be
|
|
2799
|
+
* retained in that branch's internal queue until it catches up. If the slow
|
|
2800
|
+
* consumer is a logger waiting on a database write — or never drains at all —
|
|
2801
|
+
* the queue grows without bound, and because both branches apply shared
|
|
2802
|
+
* backpressure, the *fast* consumer is throttled by the slowest one. In a
|
|
2803
|
+
* long-lived streaming server this is a slow, silent heap leak.
|
|
2804
|
+
*
|
|
2805
|
+
* ## What `observeStream` does instead
|
|
2806
|
+
*
|
|
2807
|
+
* A single-pass wrapper: chunks flow from the source through the observer
|
|
2808
|
+
* callbacks to the primary consumer with **no second queue and no forked
|
|
2809
|
+
* stream**. The contract is deliberately one-sided in favor of the primary
|
|
2810
|
+
* consumer:
|
|
2811
|
+
*
|
|
2812
|
+
* - **Never blocks.** Observer callbacks run on a serialized microtask
|
|
2813
|
+
* chain, not on the hot path. A slow async observer (a logger waiting on
|
|
2814
|
+
* I/O) delays only its own tail — the primary consumer keeps receiving
|
|
2815
|
+
* chunks at source speed.
|
|
2816
|
+
* - **Never fails.** An observer that throws (sync) or rejects (async) is
|
|
2817
|
+
* routed to `onListenerError` and otherwise discarded. Observer failures
|
|
2818
|
+
* can never poison the primary pipeline.
|
|
2819
|
+
* - **Never leaks via the wrapper.** There is no second branch to
|
|
2820
|
+
* backpressure. The only retained state is one closure per backlogged
|
|
2821
|
+
* observer callback; if your observer can stall *forever*, bound it on
|
|
2822
|
+
* your side (queue, drop policy) — the wrapper will keep enqueueing
|
|
2823
|
+
* otherwise, exactly like any fire-and-forget log sink.
|
|
2824
|
+
* - **Ordered.** Observer callbacks run strictly FIFO, one at a time —
|
|
2825
|
+
* async sinks see chunks in stream order, and `onDone` is enqueued only
|
|
2826
|
+
* after the last chunk's callback settles. (This is intentionally
|
|
2827
|
+
* stricter than a naive `void onChunk(chunk)` fire-and-forget, which
|
|
2828
|
+
* runs concurrent, out-of-order observers and turns a rejected async
|
|
2829
|
+
* callback into an unhandled rejection.)
|
|
2830
|
+
*
|
|
2831
|
+
* ## Lifecycle
|
|
2832
|
+
*
|
|
2833
|
+
* - Source completes naturally → `onDone` (enqueued after the last chunk
|
|
2834
|
+
* callback settles, so a logger has flushed everything it saw).
|
|
2835
|
+
* - Source throws → `onError(err)` immediately, then the error re-throws to
|
|
2836
|
+
* the primary consumer (the observer is transparent, not a circuit
|
|
2837
|
+
* breaker).
|
|
2838
|
+
* - Primary consumer stops early (`break` / `return` / `throw` inside the
|
|
2839
|
+
* `for await` loop) → `onAbandon()` immediately. This is distinct from
|
|
2840
|
+
* completion: the source's iterator-`return()` has already closed the
|
|
2841
|
+
* underlying transport by the time `onAbandon` fires.
|
|
2842
|
+
*
|
|
2843
|
+
* Works over any `AsyncIterable<T>` — the SDK's `OllamaStream` (streaming
|
|
2844
|
+
* `chat`/`generate`), the raw NDJSON chunk iterables, or your own sources.
|
|
2845
|
+
* Note that `OllamaStream` itself is dual-mode but mode-exclusive (`.on()`
|
|
2846
|
+
* listeners cannot be combined with `for await`); `observeStream` is the
|
|
2847
|
+
* supported way to tap a stream you are already iterating.
|
|
2848
|
+
*/
|
|
2849
|
+
/**
|
|
2850
|
+
* Lifecycle phase an observer failure came from. `'chunk'` and `'done'`
|
|
2851
|
+
* failures arrive from the serialized callback chain; `'error'` and
|
|
2852
|
+
* `'abandon'` failures come from those terminal hooks themselves.
|
|
2853
|
+
*/
|
|
2854
|
+
type StreamObserverPhase = 'chunk' | 'done' | 'error' | 'abandoned';
|
|
2855
|
+
/** Passive, best-effort observer hooks — see the module docs for semantics. */
|
|
2856
|
+
interface StreamObserverCallbacks<T> {
|
|
2857
|
+
/**
|
|
2858
|
+
* Called once per chunk, in stream order, FIFO, never overlapping with a
|
|
2859
|
+
* previous still-running call. May be sync (`void`) or async
|
|
2860
|
+
* (`Promise<void>`); async return values are awaited *on the observer
|
|
2861
|
+
* chain only* — they never delay the primary consumer. Rejections (and
|
|
2862
|
+
* sync throws) route to {@link StreamObserverCallbacks.onListenerError}.
|
|
2863
|
+
*/
|
|
2864
|
+
onChunk?: ((chunk: T) => void | Promise<void>) | undefined;
|
|
2865
|
+
/**
|
|
2866
|
+
* Called with the source's error immediately before that error is re-thrown
|
|
2867
|
+
* to the primary consumer. A throwing `onError` hook cannot mask the
|
|
2868
|
+
* original error — it is reported via {@link StreamObserverCallbacks.onListenerError}
|
|
2869
|
+
* and the original error still propagates.
|
|
2870
|
+
*/
|
|
2871
|
+
onError?: ((error: unknown) => void) | undefined;
|
|
2872
|
+
/**
|
|
2873
|
+
* Called when the source completes naturally — enqueued after the last
|
|
2874
|
+
* chunk's observer callback settles, so a flushed logger has seen every
|
|
2875
|
+
* chunk before its "done" marker.
|
|
2876
|
+
*/
|
|
2877
|
+
onDone?: (() => void | Promise<void>) | undefined;
|
|
2878
|
+
/**
|
|
2879
|
+
* Called when the primary consumer stops early (`break`/`return`/`throw` in
|
|
2880
|
+
* the consuming loop). The source has already been closed via the
|
|
2881
|
+
* iterator-`return()` protocol when this fires. `onDone` does not fire in
|
|
2882
|
+
* this case.
|
|
2883
|
+
*/
|
|
2884
|
+
onAbandon?: (() => void) | undefined;
|
|
2885
|
+
/**
|
|
2886
|
+
* The observation failure channel: any observer hook that throws or rejects
|
|
2887
|
+
* is reported here together with the phase it came from, and then
|
|
2888
|
+
* discarded. If this hook itself throws, the failure is swallowed — an
|
|
2889
|
+
* error reporter must never become the next unhandled rejection.
|
|
2890
|
+
*/
|
|
2891
|
+
onListenerError?: ((error: unknown, phase: StreamObserverPhase) => void) | undefined;
|
|
2892
|
+
}
|
|
2893
|
+
/**
|
|
2894
|
+
* Wraps an `AsyncIterable` with passive observer hooks without creating a
|
|
2895
|
+
* secondary buffered stream queue — avoiding the memory retention and shared
|
|
2896
|
+
* backpressure penalties of `ReadableStream.tee()`.
|
|
2897
|
+
*
|
|
2898
|
+
* @example
|
|
2899
|
+
* ```ts
|
|
2900
|
+
* const stream = await client.chat({ model: 'llama4', messages, stream: true });
|
|
2901
|
+
* let tokens = 0;
|
|
2902
|
+
* const observed = observeStream(stream, {
|
|
2903
|
+
* onChunk: (event) => {
|
|
2904
|
+
* if (event.type === 'token') tokens += 1;
|
|
2905
|
+
* auditLog.write(event); // slow async sink — never delays the consumer
|
|
2906
|
+
* },
|
|
2907
|
+
* onDone: () => auditLog.flush(),
|
|
2908
|
+
* onListenerError: (err) => telemetry.count('audit_log_failure', err),
|
|
2909
|
+
* });
|
|
2910
|
+
* for await (const event of observed) {
|
|
2911
|
+
* ui.render(event); // primary consumer — full speed, full order
|
|
2912
|
+
* }
|
|
2913
|
+
* ```
|
|
2914
|
+
*/
|
|
2915
|
+
declare function observeStream<T>(source: AsyncIterable<T>, callbacks?: StreamObserverCallbacks<T>): AsyncGenerator<T, void, unknown>;
|
|
2916
|
+
|
|
2783
2917
|
/**
|
|
2784
2918
|
* Client-side usage budgeting.
|
|
2785
2919
|
*
|
|
@@ -3443,6 +3577,151 @@ interface FormattedTelemetry {
|
|
|
3443
3577
|
*/
|
|
3444
3578
|
declare function formatTelemetry(raw: RawOllamaMetrics): FormattedTelemetry;
|
|
3445
3579
|
|
|
3580
|
+
/**
|
|
3581
|
+
* Speculative-decoding draft benchmark — measures whether the runtime
|
|
3582
|
+
* `draft_num_predict` option provides a net throughput gain for a specific
|
|
3583
|
+
* prompt (October 13 digest; see ADR 0030).
|
|
3584
|
+
*
|
|
3585
|
+
* Upstream Ollama does not emit a dedicated draft-token acceptance counter —
|
|
3586
|
+
* speculative efficiency is only observable as effective throughput
|
|
3587
|
+
* (`eval_count` / `eval_duration`). And the signal is noisy: rejected draft
|
|
3588
|
+
* predictions *add* compute (high-temperature, creative, non-deterministic
|
|
3589
|
+
* prompts), while accepted drafts dramatically cut `eval_duration` on
|
|
3590
|
+
* predictable workloads (structured code generation, JSON extraction). A
|
|
3591
|
+
* single run therefore proves nothing — this helper implements the
|
|
3592
|
+
* deterministic profiling protocol the upstream observations call for:
|
|
3593
|
+
*
|
|
3594
|
+
* - **Deterministic sampling** — `temperature: 0` is forced and a fixed
|
|
3595
|
+
* `seed` (default 42) is stamped on every measured run, so both sides
|
|
3596
|
+
* generate comparable token streams.
|
|
3597
|
+
* - **Warm-up discard** — one throwaway `num_predict: 1` generation per
|
|
3598
|
+
* setting pays the model load (`load_duration`) before any sample is
|
|
3599
|
+
* taken.
|
|
3600
|
+
* - **Identical prompt, both sides** — baseline (`draft_num_predict: 0`,
|
|
3601
|
+
* drafting disabled) vs. speculative (`draft_num_predict: N`), several
|
|
3602
|
+
* samples each, **median** compared (single samples mislead).
|
|
3603
|
+
* - Throughput comes from `formatTelemetry` — the official Usage-doc
|
|
3604
|
+
* tokens/second math, never hand-rolled nanosecond division.
|
|
3605
|
+
*
|
|
3606
|
+
* `effectiveGain` is true when the reported `speedupMultiplier` exceeds
|
|
3607
|
+
* `gainThreshold` (default 1.05 — five percent, past run-to-run noise). A
|
|
3608
|
+
* speedup of about 1.0 usually means the model has **no draft network** (and
|
|
3609
|
+
* no embedded MTP tensors): the server silently ignores the option and both
|
|
3610
|
+
* sides measure the same — see `lab/15-speculative-draft` for a per-setting
|
|
3611
|
+
* table over 0/4/8/16.
|
|
3612
|
+
*
|
|
3613
|
+
* ```ts
|
|
3614
|
+
* import { OllamaClient, compareDraftPerformance } from '@nemesis-oss/ollama-sdk';
|
|
3615
|
+
*
|
|
3616
|
+
* const comparison = await compareDraftPerformance(new OllamaClient(), {
|
|
3617
|
+
* model: 'llama3.1',
|
|
3618
|
+
* prompt: 'Extract the sender, subject, and date from this email as JSON: ...',
|
|
3619
|
+
* });
|
|
3620
|
+
* if (comparison.effectiveGain) {
|
|
3621
|
+
* // drafting pays off for this prompt
|
|
3622
|
+
* }
|
|
3623
|
+
* ```
|
|
3624
|
+
*/
|
|
3625
|
+
|
|
3626
|
+
/**
|
|
3627
|
+
* Structural dependency of {@link compareDraftPerformance}: anything that can
|
|
3628
|
+
* run a non-streaming `/api/generate` call. `OllamaClient` satisfies it
|
|
3629
|
+
* without being named (same discipline as the model-affinity router's
|
|
3630
|
+
* structural client), so tests and alternative transports can substitute a
|
|
3631
|
+
* minimal object.
|
|
3632
|
+
*/
|
|
3633
|
+
interface DraftBenchmarkClient {
|
|
3634
|
+
generate(req: GenerateRequestOptions & {
|
|
3635
|
+
stream?: false | undefined;
|
|
3636
|
+
}): Promise<GenerateResponse>;
|
|
3637
|
+
}
|
|
3638
|
+
/** Options for {@link compareDraftPerformance}. */
|
|
3639
|
+
interface CompareDraftPerformanceOptions {
|
|
3640
|
+
/** Model to benchmark — must be a name the target server can load. */
|
|
3641
|
+
readonly model: string;
|
|
3642
|
+
/**
|
|
3643
|
+
* The prompt both sides generate. The comparison is only meaningful with a
|
|
3644
|
+
* fixed prompt: draft acceptance — and thus speedup — is workload-dependent
|
|
3645
|
+
* (structured/predictable prompts gain the most; creative ones can lose).
|
|
3646
|
+
*/
|
|
3647
|
+
readonly prompt: string;
|
|
3648
|
+
/**
|
|
3649
|
+
* Draft tokens per step for the speculative side. Default `4` (Ollama's
|
|
3650
|
+
* default for separate draft models). Must be >= 1 — the baseline side
|
|
3651
|
+
* always measures with drafting disabled (`0`).
|
|
3652
|
+
*/
|
|
3653
|
+
readonly draftNumPredict?: number | undefined;
|
|
3654
|
+
/**
|
|
3655
|
+
* Measured runs per setting; the median is reported. Default `5`. Single
|
|
3656
|
+
* samples mislead — noisy small-model runs swing tens of percent.
|
|
3657
|
+
*/
|
|
3658
|
+
readonly samples?: number | undefined;
|
|
3659
|
+
/** `num_predict` cap per measured run. Default `256`. */
|
|
3660
|
+
readonly numPredict?: number | undefined;
|
|
3661
|
+
/** Fixed sampling seed stamped on every run (with `temperature: 0`). Default `42`. */
|
|
3662
|
+
readonly seed?: number | undefined;
|
|
3663
|
+
/**
|
|
3664
|
+
* Run one throwaway `num_predict: 1` generation per setting before sampling
|
|
3665
|
+
* (pays the model load). Default `true`.
|
|
3666
|
+
*/
|
|
3667
|
+
readonly warmup?: boolean | undefined;
|
|
3668
|
+
/**
|
|
3669
|
+
* `speedupMultiplier` above this reports `effectiveGain: true`. Default
|
|
3670
|
+
* `1.05` — five percent, past typical run-to-run noise.
|
|
3671
|
+
*/
|
|
3672
|
+
readonly gainThreshold?: number | undefined;
|
|
3673
|
+
/** Abort signal — checked before every run and forwarded to each generate call. */
|
|
3674
|
+
readonly signal?: AbortSignal | undefined;
|
|
3675
|
+
}
|
|
3676
|
+
/** One side's measurement detail (see {@link DraftPerformanceComparison}). */
|
|
3677
|
+
interface DraftRunStats {
|
|
3678
|
+
/** The `draft_num_predict` value this side ran with (`0` = baseline). */
|
|
3679
|
+
readonly draftNumPredict: number;
|
|
3680
|
+
/** Median tokens/second across the valid samples (unrounded). */
|
|
3681
|
+
readonly medianTokensPerSecond: number;
|
|
3682
|
+
/** Every valid sample's tokens/second, in run order. */
|
|
3683
|
+
readonly sampleTokensPerSecond: readonly number[];
|
|
3684
|
+
/** Median generation-phase duration (`eval_duration`) in milliseconds. */
|
|
3685
|
+
readonly medianEvalDurationMs: number;
|
|
3686
|
+
}
|
|
3687
|
+
/** Result of {@link compareDraftPerformance}. */
|
|
3688
|
+
interface DraftPerformanceComparison {
|
|
3689
|
+
/** The model that was benchmarked. */
|
|
3690
|
+
readonly model: string;
|
|
3691
|
+
/** The prompt both sides generated. */
|
|
3692
|
+
readonly prompt: string;
|
|
3693
|
+
/** The speculative side's `draft_num_predict` (the baseline always ran `0`). */
|
|
3694
|
+
readonly draftNumPredict: number;
|
|
3695
|
+
/** Baseline median tokens/second, rounded to 1 decimal. */
|
|
3696
|
+
readonly baselineTokensPerSec: number;
|
|
3697
|
+
/** Speculative median tokens/second, rounded to 1 decimal. */
|
|
3698
|
+
readonly speculativeTokensPerSec: number;
|
|
3699
|
+
/** `speculativeTokensPerSec / baselineTokensPerSec`, rounded to 2 decimals. */
|
|
3700
|
+
readonly speedupMultiplier: number;
|
|
3701
|
+
/** `true` when the reported `speedupMultiplier` exceeds `gainThreshold`. */
|
|
3702
|
+
readonly effectiveGain: boolean;
|
|
3703
|
+
/** The threshold `effectiveGain` was evaluated against. */
|
|
3704
|
+
readonly gainThreshold: number;
|
|
3705
|
+
/** Full baseline detail (samples, medians). */
|
|
3706
|
+
readonly baseline: DraftRunStats;
|
|
3707
|
+
/** Full speculative detail (samples, medians). */
|
|
3708
|
+
readonly speculative: DraftRunStats;
|
|
3709
|
+
}
|
|
3710
|
+
/**
|
|
3711
|
+
* Measure whether speculative drafting pays off for a specific prompt:
|
|
3712
|
+
* identical prompt, deterministic sampling (`temperature: 0` + fixed `seed`),
|
|
3713
|
+
* warm-up discard, several samples per setting, median baseline
|
|
3714
|
+
* (`draft_num_predict: 0`) vs. median speculative (`draft_num_predict: N`)
|
|
3715
|
+
* compared as `speedupMultiplier`.
|
|
3716
|
+
*
|
|
3717
|
+
* Both sides run through the client's non-streaming `generate` — the raw
|
|
3718
|
+
* counters come back on the response and throughput is derived by
|
|
3719
|
+
* `formatTelemetry`. Non-positive/unusable samples are skipped; if a side
|
|
3720
|
+
* ends up with none, an `OllamaClientError` explains why (wrong model name /
|
|
3721
|
+
* empty generations) rather than reporting a fabricated zero.
|
|
3722
|
+
*/
|
|
3723
|
+
declare function compareDraftPerformance(client: DraftBenchmarkClient, options: CompareDraftPerformanceOptions): Promise<DraftPerformanceComparison>;
|
|
3724
|
+
|
|
3446
3725
|
/**
|
|
3447
3726
|
* Cross-runtime helpers with no Node.js API dependency, so they stay safe to import from
|
|
3448
3727
|
* the core client bundle (see ADR 0006 — Edge Runtime CI).
|
|
@@ -3550,7 +3829,33 @@ interface ContextCheck {
|
|
|
3550
3829
|
readonly windowSource: ContextWindowSource;
|
|
3551
3830
|
/** True when the estimate crossed the warning threshold of the effective window. */
|
|
3552
3831
|
readonly exceedsThreshold: boolean;
|
|
3832
|
+
/**
|
|
3833
|
+
* Present only when `exceedsThreshold` is `true`: the smallest power-of-two
|
|
3834
|
+
* window with ~30% generation headroom above the estimate (see
|
|
3835
|
+
* {@link recommendContextWindow}). A starting point, not a verdict — check
|
|
3836
|
+
* the model's native ceiling with `client.models.getContextLength()` before
|
|
3837
|
+
* adopting it; a prompt that outgrows the native maximum needs compaction
|
|
3838
|
+
* or history truncation, not a bigger `num_ctx`.
|
|
3839
|
+
*/
|
|
3840
|
+
readonly recommendedNumCtx?: number | undefined;
|
|
3553
3841
|
}
|
|
3842
|
+
/**
|
|
3843
|
+
* Smallest power-of-two context window that comfortably fits
|
|
3844
|
+
* `estimatedTokens` — ~30% headroom for the response, floored at 4096 (the
|
|
3845
|
+
* common modern server default when `num_ctx` is unset).
|
|
3846
|
+
*
|
|
3847
|
+
* Uses an exact doubling loop rather than
|
|
3848
|
+
* `Math.pow(2, Math.ceil(Math.log2(x)))`: floating-point `log2` of exact
|
|
3849
|
+
* powers of two can land marginally above the integer (e.g.
|
|
3850
|
+
* `Math.log2(8) > 3` on some platforms), which rounds a perfect fit *up* a
|
|
3851
|
+
* whole power of two. The loop has no such boundary bugs.
|
|
3852
|
+
*
|
|
3853
|
+
* Non-finite / non-positive inputs return the 4096 floor rather than throwing:
|
|
3854
|
+
* callers use this to *suggest* a window after their own estimate already
|
|
3855
|
+
* flagged a problem, so garbage-in should degrade to a conservative
|
|
3856
|
+
* suggestion, not a second error path.
|
|
3857
|
+
*/
|
|
3858
|
+
declare function recommendContextWindow(estimatedTokens: number): number;
|
|
3554
3859
|
interface ContextCheckOptions {
|
|
3555
3860
|
/** Client `defaultContextLength`, applied when the request doesn't set `num_ctx`. */
|
|
3556
3861
|
readonly defaultContextLength?: number | undefined;
|
|
@@ -3717,4 +4022,4 @@ declare class ModelAffinityScheduler {
|
|
|
3717
4022
|
/** Convenience factory — `createModelAffinityScheduler(client, opts)` reads better in setups. */
|
|
3718
4023
|
declare function createModelAffinityScheduler(client: ModelAffinityClient | OllamaClient, options?: ModelAffinitySchedulerOptions): ModelAffinityScheduler;
|
|
3719
4024
|
|
|
3720
|
-
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 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 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 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, 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, parseNdjsonStream, parseStructuredOutput, registerMcpTools, resolveContextLength, resolveCredentialEndpoints, sanitizeHistoryForNextTurn, setSpanError, toDataStream, toResponse, toTextStream, withRetry, withSpan, zodToJsonSchema };
|
|
4025
|
+
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 };
|