@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/dist/index.js CHANGED
@@ -391,6 +391,36 @@ var OllamaGenericClientError = class extends OllamaClientError {
391
391
  function isDomAbortError(error) {
392
392
  return typeof DOMException !== "undefined" && error instanceof DOMException && error.name === "AbortError";
393
393
  }
394
+ var NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
395
+ "ECONNRESET",
396
+ "ECONNREFUSED",
397
+ "EPIPE",
398
+ "ETIMEDOUT",
399
+ "ECONNABORTED",
400
+ "EHOSTUNREACH",
401
+ "ENETUNREACH",
402
+ "ENOTFOUND",
403
+ "EAI_AGAIN",
404
+ "UND_ERR_SOCKET",
405
+ "UND_ERR_CONNECT_TIMEOUT",
406
+ "UND_ERR_HEADERS_TIMEOUT",
407
+ "UND_ERR_BODY_TIMEOUT",
408
+ "UND_ERR_CLOSED"
409
+ ]);
410
+ var MAX_CAUSE_DEPTH = 4;
411
+ function isNetworkLevelError(error) {
412
+ let current = error;
413
+ for (let depth = 0; depth < MAX_CAUSE_DEPTH && current !== void 0 && current !== null; depth += 1) {
414
+ if (typeof current === "object" && "code" in current) {
415
+ const code = current.code;
416
+ if (typeof code === "string" && NETWORK_ERROR_CODES.has(code)) {
417
+ return true;
418
+ }
419
+ }
420
+ current = current.cause;
421
+ }
422
+ return false;
423
+ }
394
424
  function statusToError(status, message, options) {
395
425
  if (status === 401 || status === 403) {
396
426
  return new OllamaAuthError(message, { ...options, status });
@@ -422,6 +452,13 @@ function mapError(error, context = {}) {
422
452
  request: context.request
423
453
  });
424
454
  }
455
+ if (isNetworkLevelError(error)) {
456
+ const message2 = error instanceof Error && error.message ? error.message : "Network request failed";
457
+ return new OllamaNetworkError(message2, {
458
+ cause: error,
459
+ request: context.request
460
+ });
461
+ }
425
462
  if (error instanceof TypeError) {
426
463
  return new OllamaNetworkError(error.message || "Network request failed", {
427
464
  cause: error,
@@ -1647,6 +1684,13 @@ function estimateGenerateRequestTokens(req) {
1647
1684
  if (req.images !== void 0) total += req.images.length * IMAGE_TOKEN_ESTIMATE;
1648
1685
  return total;
1649
1686
  }
1687
+ function recommendContextWindow(estimatedTokens) {
1688
+ if (!Number.isFinite(estimatedTokens) || estimatedTokens <= 0) return 4096;
1689
+ const target = estimatedTokens * 1.3;
1690
+ let window = 4096;
1691
+ while (window < target) window *= 2;
1692
+ return window;
1693
+ }
1650
1694
  function checkChatContext(req, options = {}) {
1651
1695
  return check(estimateChatRequestTokens(req), req.options?.num_ctx, options);
1652
1696
  }
@@ -1656,39 +1700,46 @@ function checkGenerateContext(req, options = {}) {
1656
1700
  function check(estimatedPromptTokens, requestNumCtx, options) {
1657
1701
  const threshold = options.threshold ?? DEFAULT_CONTEXT_WARNING_THRESHOLD;
1658
1702
  if (requestNumCtx !== void 0) {
1703
+ const exceeds2 = estimatedPromptTokens > requestNumCtx * threshold;
1659
1704
  return {
1660
1705
  estimatedPromptTokens,
1661
1706
  effectiveContextLength: requestNumCtx,
1662
1707
  windowSource: "request",
1663
- exceedsThreshold: estimatedPromptTokens > requestNumCtx * threshold
1708
+ exceedsThreshold: exceeds2,
1709
+ ...exceeds2 ? { recommendedNumCtx: recommendContextWindow(estimatedPromptTokens) } : {}
1664
1710
  };
1665
1711
  }
1666
1712
  if (options.defaultContextLength !== void 0) {
1713
+ const exceeds2 = estimatedPromptTokens > options.defaultContextLength * threshold;
1667
1714
  return {
1668
1715
  estimatedPromptTokens,
1669
1716
  effectiveContextLength: options.defaultContextLength,
1670
1717
  windowSource: "client-default",
1671
- exceedsThreshold: estimatedPromptTokens > options.defaultContextLength * threshold
1718
+ exceedsThreshold: exceeds2,
1719
+ ...exceeds2 ? { recommendedNumCtx: recommendContextWindow(estimatedPromptTokens) } : {}
1672
1720
  };
1673
1721
  }
1722
+ const exceeds = estimatedPromptTokens > OLLAMA_FALLBACK_CONTEXT_LENGTH;
1674
1723
  return {
1675
1724
  estimatedPromptTokens,
1676
1725
  effectiveContextLength: OLLAMA_FALLBACK_CONTEXT_LENGTH,
1677
1726
  windowSource: "server-fallback",
1678
- exceedsThreshold: estimatedPromptTokens > OLLAMA_FALLBACK_CONTEXT_LENGTH
1727
+ exceedsThreshold: exceeds,
1728
+ ...exceeds ? { recommendedNumCtx: recommendContextWindow(estimatedPromptTokens) } : {}
1679
1729
  };
1680
1730
  }
1681
1731
  var OLLAMA_FALLBACK_CONTEXT_LENGTH = 2048;
1682
1732
  function contextWarningMessage(check2, kind) {
1683
1733
  const where = `OllamaClient.${kind}()`;
1684
1734
  const estimate = `~${check2.estimatedPromptTokens} tokens`;
1735
+ const suggestion = check2.recommendedNumCtx !== void 0 ? ` A window of at least ${check2.recommendedNumCtx} tokens would fit this prompt with ~30% headroom (see \`recommendContextWindow\`) \u2014 verify the model's native maximum via \`client.models.getContextLength()\` before adopting it.` : "";
1685
1736
  if (check2.windowSource === "request") {
1686
- return `${where}: estimated prompt size ${estimate} is close to or beyond the request's context window (num_ctx=${check2.effectiveContextLength}). The server will likely silently truncate the top of the conversation \u2014 the model loses earlier turns with no error. Raise \`options.num_ctx\` or shorten the conversation. Estimates are heuristic (\xB120\u201330%); see \`estimateTokens\`.`;
1737
+ return `${where}: estimated prompt size ${estimate} is close to or beyond the request's context window (num_ctx=${check2.effectiveContextLength}). The server will likely silently truncate the top of the conversation \u2014 the model loses earlier turns with no error. Raise \`options.num_ctx\` or shorten the conversation.${suggestion} Estimates are heuristic (\xB120\u201330%); see \`estimateTokens\`.`;
1687
1738
  }
1688
1739
  if (check2.windowSource === "client-default") {
1689
- return `${where}: estimated prompt size ${estimate} is close to or beyond the client's \`defaultContextLength\` (${check2.effectiveContextLength}, injected as \`num_ctx\`). The server will likely silently truncate the top of the conversation \u2014 the model loses earlier turns with no error. Raise \`defaultContextLength\`, set \`options.num_ctx\` per request, or shorten the conversation. Estimates are heuristic (\xB120\u201330%); see \`estimateTokens\`.`;
1740
+ return `${where}: estimated prompt size ${estimate} is close to or beyond the client's \`defaultContextLength\` (${check2.effectiveContextLength}, injected as \`num_ctx\`). The server will likely silently truncate the top of the conversation \u2014 the model loses earlier turns with no error. Raise \`defaultContextLength\`, set \`options.num_ctx\` per request, or shorten the conversation.${suggestion} Estimates are heuristic (\xB120\u201330%); see \`estimateTokens\`.`;
1690
1741
  }
1691
- return `${where}: estimated prompt size ${estimate} outright exceeds Ollama's conservative server-default context window (${OLLAMA_FALLBACK_CONTEXT_LENGTH}\u20134096 tokens when \`num_ctx\` is unset \u2014 model-dependent). Unless the model's default is larger, the server will silently truncate the top of the conversation \u2014 the model loses earlier turns with no error. Set \`options.num_ctx\` (or the client's \`defaultContextLength\`) to an explicit window to make truncation visible and controllable. Estimates are heuristic (\xB120\u201330%); see \`estimateTokens\`.`;
1742
+ return `${where}: estimated prompt size ${estimate} outright exceeds Ollama's conservative server-default context window (${OLLAMA_FALLBACK_CONTEXT_LENGTH}\u20134096 tokens when \`num_ctx\` is unset \u2014 model-dependent). Unless the model's default is larger, the server will silently truncate the top of the conversation \u2014 the model loses earlier turns with no error. Set \`options.num_ctx\` (or the client's \`defaultContextLength\`) to an explicit window to make truncation visible and controllable.${suggestion} Estimates are heuristic (\xB120\u201330%); see \`estimateTokens\`.`;
1692
1743
  }
1693
1744
 
1694
1745
  // src/context-discovery.ts
@@ -6664,6 +6715,56 @@ function toResponse(stream, init = {}) {
6664
6715
  return new Response(body, { ...init, headers });
6665
6716
  }
6666
6717
 
6718
+ // src/streaming/observe.ts
6719
+ async function* observeStream(source, callbacks = {}) {
6720
+ const { onChunk, onError, onDone, onAbandon, onListenerError } = callbacks;
6721
+ const reportListenerFailure = (error, phase) => {
6722
+ try {
6723
+ onListenerError?.(error, phase);
6724
+ } catch {
6725
+ }
6726
+ };
6727
+ let observerChain = Promise.resolve();
6728
+ const dispatch2 = (phase, task) => {
6729
+ observerChain = observerChain.then(task).then(
6730
+ () => void 0,
6731
+ (error) => {
6732
+ reportListenerFailure(error, phase);
6733
+ }
6734
+ );
6735
+ };
6736
+ let state = "running";
6737
+ try {
6738
+ for await (const chunk of source) {
6739
+ if (onChunk !== void 0) {
6740
+ dispatch2("chunk", () => onChunk(chunk));
6741
+ }
6742
+ yield chunk;
6743
+ }
6744
+ state = "done";
6745
+ if (onDone !== void 0) {
6746
+ dispatch2("done", () => onDone());
6747
+ }
6748
+ } catch (error) {
6749
+ state = "error";
6750
+ try {
6751
+ onError?.(error);
6752
+ } catch (listenerError) {
6753
+ reportListenerFailure(listenerError, "error");
6754
+ }
6755
+ throw error;
6756
+ } finally {
6757
+ if (state === "running") {
6758
+ state = "abandoned";
6759
+ try {
6760
+ onAbandon?.();
6761
+ } catch (listenerError) {
6762
+ reportListenerFailure(listenerError, "abandoned");
6763
+ }
6764
+ }
6765
+ }
6766
+ }
6767
+
6667
6768
  // src/quota.ts
6668
6769
  var QuotaManager = class {
6669
6770
  now;
@@ -7748,6 +7849,111 @@ var Agent = class {
7748
7849
  }
7749
7850
  };
7750
7851
 
7852
+ // src/draft-benchmark.ts
7853
+ var DEFAULT_DRAFT_TOKENS = 4;
7854
+ var DEFAULT_SAMPLES = 5;
7855
+ var DEFAULT_NUM_PREDICT = 256;
7856
+ var DEFAULT_SEED = 42;
7857
+ var DEFAULT_GAIN_THRESHOLD = 1.05;
7858
+ function median(values) {
7859
+ const sorted = [...values].sort((a, b) => a - b);
7860
+ const mid = Math.floor(sorted.length / 2);
7861
+ return sorted.length % 2 === 1 ? sorted[mid] ?? 0 : ((sorted[mid - 1] ?? 0) + (sorted[mid] ?? 0)) / 2;
7862
+ }
7863
+ function roundTo(value, decimals) {
7864
+ const factor = 10 ** decimals;
7865
+ return Math.round(value * factor) / factor;
7866
+ }
7867
+ function requirePositiveInteger(name, value) {
7868
+ if (!Number.isInteger(value) || value < 1) {
7869
+ throw new RangeError(
7870
+ `compareDraftPerformance: ${name} must be an integer >= 1 (got ${value}).`
7871
+ );
7872
+ }
7873
+ }
7874
+ async function runSide(client, options, draftNumPredict, samples, numPredict, seed) {
7875
+ const samplingOptions = {
7876
+ num_predict: numPredict,
7877
+ temperature: 0,
7878
+ seed,
7879
+ draft_num_predict: draftNumPredict
7880
+ };
7881
+ if (options.warmup ?? true) {
7882
+ await client.generate({
7883
+ model: options.model,
7884
+ prompt: options.prompt,
7885
+ options: { ...samplingOptions, num_predict: 1 },
7886
+ stream: false,
7887
+ signal: options.signal
7888
+ });
7889
+ }
7890
+ const tokensPerSecond = [];
7891
+ const generationMs = [];
7892
+ for (let i = 0; i < samples; i++) {
7893
+ options.signal?.throwIfAborted();
7894
+ const response = await client.generate({
7895
+ model: options.model,
7896
+ prompt: options.prompt,
7897
+ options: samplingOptions,
7898
+ stream: false,
7899
+ signal: options.signal
7900
+ });
7901
+ const telemetry = formatTelemetry(response);
7902
+ if (Number.isFinite(telemetry.tokensPerSecond) && telemetry.tokensPerSecond > 0) {
7903
+ tokensPerSecond.push(telemetry.tokensPerSecond);
7904
+ generationMs.push(telemetry.generationMs);
7905
+ }
7906
+ }
7907
+ if (tokensPerSecond.length === 0) {
7908
+ throw new OllamaClientError(
7909
+ `compareDraftPerformance: every draft_num_predict=${draftNumPredict} sample returned a non-positive tokens/second. The model name is likely wrong, or the server returned empty generations.`,
7910
+ { code: "draft_benchmark_no_valid_samples" }
7911
+ );
7912
+ }
7913
+ return {
7914
+ draftNumPredict,
7915
+ medianTokensPerSecond: median(tokensPerSecond),
7916
+ sampleTokensPerSecond: tokensPerSecond,
7917
+ medianEvalDurationMs: median(generationMs)
7918
+ };
7919
+ }
7920
+ async function compareDraftPerformance(client, options) {
7921
+ const draftNumPredict = options.draftNumPredict ?? DEFAULT_DRAFT_TOKENS;
7922
+ requirePositiveInteger("draftNumPredict", draftNumPredict);
7923
+ const samples = options.samples ?? DEFAULT_SAMPLES;
7924
+ requirePositiveInteger("samples", samples);
7925
+ const numPredict = options.numPredict ?? DEFAULT_NUM_PREDICT;
7926
+ requirePositiveInteger("numPredict", numPredict);
7927
+ const seed = options.seed ?? DEFAULT_SEED;
7928
+ if (!Number.isInteger(seed)) {
7929
+ throw new RangeError(`compareDraftPerformance: seed must be an integer (got ${seed}).`);
7930
+ }
7931
+ const gainThreshold = options.gainThreshold ?? DEFAULT_GAIN_THRESHOLD;
7932
+ if (!Number.isFinite(gainThreshold) || gainThreshold <= 0) {
7933
+ throw new RangeError(
7934
+ `compareDraftPerformance: gainThreshold must be a positive finite number (got ${gainThreshold}).`
7935
+ );
7936
+ }
7937
+ options.signal?.throwIfAborted();
7938
+ const baseline = await runSide(client, options, 0, samples, numPredict, seed);
7939
+ const speculative = await runSide(client, options, draftNumPredict, samples, numPredict, seed);
7940
+ const baselineTokensPerSec = roundTo(baseline.medianTokensPerSecond, 1);
7941
+ const speculativeTokensPerSec = roundTo(speculative.medianTokensPerSecond, 1);
7942
+ const speedupMultiplier = baselineTokensPerSec > 0 ? roundTo(speculativeTokensPerSec / baselineTokensPerSec, 2) : 0;
7943
+ return {
7944
+ model: options.model,
7945
+ prompt: options.prompt,
7946
+ draftNumPredict,
7947
+ baselineTokensPerSec,
7948
+ speculativeTokensPerSec,
7949
+ speedupMultiplier,
7950
+ effectiveGain: speedupMultiplier > gainThreshold,
7951
+ gainThreshold,
7952
+ baseline,
7953
+ speculative
7954
+ };
7955
+ }
7956
+
7751
7957
  // src/affinity.ts
7752
7958
  var DEFAULT_CONCURRENT_MODELS = 1;
7753
7959
  var DEFAULT_PER_MODEL_CONCURRENCY = 1;
@@ -7909,6 +8115,6 @@ function estimateSystemOneRequestBytes(request) {
7909
8115
  return new TextEncoder().encode(JSON.stringify(request)).byteLength;
7910
8116
  }
7911
8117
 
7912
- 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, Agent, AnthropicCompatClient, AnthropicMessagesStream, ConversationSession, 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, EndpointRegistry, GEN_AI_SYSTEM_OLLAMA, HttpClient, IMAGE_TOKEN_ESTIMATE, KEEP_ALIVE_INDEFINITE, KEEP_ALIVE_UNLOAD, KNOWN_DONE_REASONS, MAX_SYSTEM_ONE_IMAGES_BYTES, MAX_SYSTEM_ONE_REQUEST_BYTES, MESSAGE_OVERHEAD_TOKENS, McpBridge, ModelAffinityRouter, ModelAffinityScheduler, ModelsClient, NANOS_PER_MS, NANOS_PER_SECOND, NOOP_LOGGER, OLLAMA_CLOUD_BASE_URL, OLLAMA_FALLBACK_CONTEXT_LENGTH, OllamaAbortError, OllamaAgentMaxIterationsError, OllamaAgentMaxToolCallsError, OllamaAgentToolLoopError, OllamaAuthError, OllamaBadGatewayError, OllamaClient, OllamaClientError, OllamaGenericClientError, OllamaIncompatibleModelError, OllamaMcpError, OllamaModelRoutingError, OllamaNetworkError, OllamaNotFoundError, OllamaOverloadedError, OllamaQuotaExceededError, OllamaRateLimitError, OllamaRequestTooLargeError, OllamaRequestValidationError, OllamaResponseValidationError, OllamaServerError, OllamaServerVersionUnknownError, OllamaSkillInvalidError, OllamaSkillNotFoundError, OllamaStream, OllamaStreamError, OllamaTimeoutError, OllamaToolTimeoutError, OllamaToolValidationError, OllamaUnsupportedCapabilityError, OpenAIChatCompletionStream, OpenAICompatClient, OpenAICompletionStream, OpenAIResponsesStream, OpenAIResponsesStreamError, QuotaManager, RETRYABLE_STATUS_CODES, ResponsesModule, ToolCallAccumulator, ToolRegistry, WEB_FETCH_TOOL_NAME, WEB_SEARCH_TOOL_NAME, addSpanEvent, applySkill, batchEmbed, calculateBackoff, canonicalToolCallSignature, checkChatContext, checkEndpointHealth, checkGenerateContext, compactConversationHistory, composeMiddleware, contextWarningMessage, createConsoleLogger, createDecision, createModelAffinityScheduler, createOllamaCloudFreeTierQuota, createTimeoutSignal, createWebFetchTool, createWebSearchTool, createWebTools, defineTool, detectModelCapabilities, embedBatchOverflowMessage, encodeImage, estimateChatRequestTokens, estimateGenerateRequestTokens, estimateMessageTokens, estimateSystemOneRequestBytes, estimateTokens, extractContextLength as extractNativeContextLength, extractParameterNumCtx, extractUsage, fetchWithBackoff, findOversizedEmbedInputs, findRunningModelContextLength, formatTelemetry, formatWebFetchResult, formatWebSearchResult, imageStringNeedsResolution, inferRuntimeMode, isKeepAliveSugar, isKnownDoneReason, isModelResident, isSameToolCall, listAllMcpTools, listAvailableModels, loadMcpTools, mapError, mergeToolCall, mergeToolCallArgumentsString, mergeToolCallArrays, normalizeChatStream, normalizeGenerateStream, normalizeKeepAlive, normalizeProgressStream, parseFrontmatter, parseNdjsonStream, parseSseStream, parseStructuredOutput, registerMcpTools, resolveContextLength, resolveCredentialEndpoints, resolveImageInput, sanitizeHistoryForNextTurn, setSpanError, toDataStream, toResponse, toTextStream, withRetry, withSpan, zodToJsonSchema };
8118
+ 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, Agent, AnthropicCompatClient, AnthropicMessagesStream, ConversationSession, 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, EndpointRegistry, GEN_AI_SYSTEM_OLLAMA, HttpClient, IMAGE_TOKEN_ESTIMATE, KEEP_ALIVE_INDEFINITE, KEEP_ALIVE_UNLOAD, KNOWN_DONE_REASONS, MAX_SYSTEM_ONE_IMAGES_BYTES, MAX_SYSTEM_ONE_REQUEST_BYTES, MESSAGE_OVERHEAD_TOKENS, McpBridge, ModelAffinityRouter, ModelAffinityScheduler, ModelsClient, NANOS_PER_MS, NANOS_PER_SECOND, NETWORK_ERROR_CODES, NOOP_LOGGER, OLLAMA_CLOUD_BASE_URL, OLLAMA_FALLBACK_CONTEXT_LENGTH, OllamaAbortError, OllamaAgentMaxIterationsError, OllamaAgentMaxToolCallsError, OllamaAgentToolLoopError, OllamaAuthError, OllamaBadGatewayError, OllamaClient, OllamaClientError, OllamaGenericClientError, OllamaIncompatibleModelError, OllamaMcpError, OllamaModelRoutingError, OllamaNetworkError, OllamaNotFoundError, OllamaOverloadedError, OllamaQuotaExceededError, OllamaRateLimitError, OllamaRequestTooLargeError, OllamaRequestValidationError, OllamaResponseValidationError, OllamaServerError, OllamaServerVersionUnknownError, OllamaSkillInvalidError, OllamaSkillNotFoundError, OllamaStream, OllamaStreamError, OllamaTimeoutError, OllamaToolTimeoutError, OllamaToolValidationError, OllamaUnsupportedCapabilityError, OpenAIChatCompletionStream, OpenAICompatClient, OpenAICompletionStream, OpenAIResponsesStream, OpenAIResponsesStreamError, QuotaManager, RETRYABLE_STATUS_CODES, ResponsesModule, ToolCallAccumulator, ToolRegistry, WEB_FETCH_TOOL_NAME, WEB_SEARCH_TOOL_NAME, addSpanEvent, applySkill, batchEmbed, calculateBackoff, canonicalToolCallSignature, checkChatContext, checkEndpointHealth, checkGenerateContext, compactConversationHistory, compareDraftPerformance, composeMiddleware, contextWarningMessage, createConsoleLogger, createDecision, createModelAffinityScheduler, createOllamaCloudFreeTierQuota, createTimeoutSignal, createWebFetchTool, createWebSearchTool, createWebTools, defineTool, detectModelCapabilities, embedBatchOverflowMessage, encodeImage, estimateChatRequestTokens, estimateGenerateRequestTokens, estimateMessageTokens, estimateSystemOneRequestBytes, estimateTokens, extractContextLength as extractNativeContextLength, extractParameterNumCtx, extractUsage, fetchWithBackoff, findOversizedEmbedInputs, findRunningModelContextLength, formatTelemetry, formatWebFetchResult, formatWebSearchResult, imageStringNeedsResolution, inferRuntimeMode, isKeepAliveSugar, isKnownDoneReason, isModelResident, isNetworkLevelError, isSameToolCall, listAllMcpTools, listAvailableModels, loadMcpTools, mapError, mergeToolCall, mergeToolCallArgumentsString, mergeToolCallArrays, normalizeChatStream, normalizeGenerateStream, normalizeKeepAlive, normalizeProgressStream, observeStream, parseFrontmatter, parseNdjsonStream, parseSseStream, parseStructuredOutput, recommendContextWindow, registerMcpTools, resolveContextLength, resolveCredentialEndpoints, resolveImageInput, sanitizeHistoryForNextTurn, setSpanError, toDataStream, toResponse, toTextStream, withRetry, withSpan, zodToJsonSchema };
7913
8119
  //# sourceMappingURL=index.js.map
7914
8120
  //# sourceMappingURL=index.js.map