@nemesis-oss/ollama-sdk 1.12.0 → 1.13.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
@@ -1763,9 +1763,10 @@ var ModelAffinityRouter = class {
1763
1763
  this.now = options.now ?? Date.now;
1764
1764
  }
1765
1765
  /**
1766
- * Synchronously reorders `candidates` so endpoints whose fresh `/api/ps`
1766
+ * Synchronously reorders `candidates` so that, within each priority tier
1767
+ * (run of consecutive equal `priority`), endpoints whose fresh `/api/ps`
1767
1768
  * snapshot shows `model` resident come first (relative order preserved within
1768
- * each group). Returns the input unchanged — and kicks a background refresh —
1769
+ * each group). Never moves an endpoint across tiers. Returns the input unchanged — and kicks a background refresh —
1769
1770
  * when any candidate's snapshot is missing or stale: a wrong reorder is worse
1770
1771
  * than no reorder, and the first request after a cache miss simply isn't
1771
1772
  * reordered. No-op without a `model` or with fewer than two candidates.
@@ -1782,13 +1783,28 @@ var ModelAffinityRouter = class {
1782
1783
  }
1783
1784
  }
1784
1785
  if (!allFresh) return candidates;
1785
- const resident = candidates.filter((ep) => {
1786
+ const isResident = (ep) => {
1786
1787
  const entry = this.cache.get(ep.name);
1787
1788
  return entry !== void 0 && isModelResident(entry.models, model);
1788
- });
1789
- if (resident.length === 0 || resident.length === candidates.length) return candidates;
1790
- const residentSet = new Set(resident.map((ep) => ep.name));
1791
- return [...resident, ...candidates.filter((ep) => !residentSet.has(ep.name))];
1789
+ };
1790
+ const reordered = [];
1791
+ let changed = false;
1792
+ for (let start = 0; start < candidates.length; ) {
1793
+ const tierPriority = candidates[start].priority ?? 0;
1794
+ let end = start + 1;
1795
+ while (end < candidates.length && (candidates[end].priority ?? 0) === tierPriority) end++;
1796
+ const tier = candidates.slice(start, end);
1797
+ const resident = tier.filter(isResident);
1798
+ if (resident.length === 0 || resident.length === tier.length) {
1799
+ reordered.push(...tier);
1800
+ } else {
1801
+ const tierOrder = [...resident, ...tier.filter((ep) => !isResident(ep))];
1802
+ changed ||= tierOrder.some((ep, i) => ep !== tier[i]);
1803
+ reordered.push(...tierOrder);
1804
+ }
1805
+ start = end;
1806
+ }
1807
+ return changed ? reordered : candidates;
1792
1808
  }
1793
1809
  /**
1794
1810
  * Forces a refresh of the affinity cache for the given endpoints (deduped with
@@ -2833,7 +2849,11 @@ var ModelsClient = class {
2833
2849
  var OpenAIResponsesStreamError = class extends OllamaClientError {
2834
2850
  responsePayload;
2835
2851
  constructor(message, responsePayload) {
2836
- super(message, { code: "openai_responses_stream_error", retryable: false, response: { body: responsePayload } });
2852
+ super(message, {
2853
+ code: "openai_responses_stream_error",
2854
+ retryable: false,
2855
+ response: { body: responsePayload }
2856
+ });
2837
2857
  this.responsePayload = responsePayload;
2838
2858
  }
2839
2859
  };
@@ -2975,7 +2995,9 @@ var OpenAIChatCompletionStream = class {
2975
2995
  } finally {
2976
2996
  if (!completed) {
2977
2997
  this.source.abort?.();
2978
- this.rejectFinal(new OllamaAbortError("OpenAI Chat Completion stream ended before completion"));
2998
+ this.rejectFinal(
2999
+ new OllamaAbortError("OpenAI Chat Completion stream ended before completion")
3000
+ );
2979
3001
  }
2980
3002
  }
2981
3003
  }
@@ -3104,7 +3126,14 @@ var OpenAIResponsesStream = class {
3104
3126
  existing.kind = kind;
3105
3127
  return existing;
3106
3128
  }
3107
- const state = { itemId, kind, content: /* @__PURE__ */ new Map(), summary: /* @__PURE__ */ new Map(), arguments: "", reasoningText: "" };
3129
+ const state = {
3130
+ itemId,
3131
+ kind,
3132
+ content: /* @__PURE__ */ new Map(),
3133
+ summary: /* @__PURE__ */ new Map(),
3134
+ arguments: "",
3135
+ reasoningText: ""
3136
+ };
3108
3137
  outputs.set(outputIndex, state);
3109
3138
  return state;
3110
3139
  };
@@ -3135,9 +3164,33 @@ var OpenAIResponsesStream = class {
3135
3164
  const reconstructedOutput = () => [...outputs.entries()].sort(([a], [b]) => a - b).map(([outputIndex, state]) => {
3136
3165
  const canonical = canonicalOutputItems.get(outputIndex);
3137
3166
  if (canonical) return canonical;
3138
- if (state.kind === "message") return { type: "message", ...state.itemId ? { id: state.itemId } : {}, ...state.status ? { status: state.status } : {}, role: state.role ?? "assistant", ...state.phase ? { phase: state.phase } : {}, content: [...state.content.entries()].sort(([a], [b]) => a - b).map(([, p]) => p) };
3139
- if (state.kind === "function_call") return { type: "function_call", ...state.itemId ? { id: state.itemId } : {}, ...state.callId ? { call_id: state.callId } : {}, ...state.status ? { status: state.status } : {}, name: state.name ?? "", arguments: state.arguments };
3140
- return { type: "reasoning", ...state.itemId ? { id: state.itemId } : {}, ...state.status ? { status: state.status } : {}, ...state.summary.size ? { summary: [...state.summary.entries()].sort(([a], [b]) => a - b).map(([, text]) => ({ type: "summary_text", text })) } : {}, ...state.reasoningText ? { text: state.reasoningText } : {} };
3167
+ if (state.kind === "message")
3168
+ return {
3169
+ type: "message",
3170
+ ...state.itemId ? { id: state.itemId } : {},
3171
+ ...state.status ? { status: state.status } : {},
3172
+ role: state.role ?? "assistant",
3173
+ ...state.phase ? { phase: state.phase } : {},
3174
+ content: [...state.content.entries()].sort(([a], [b]) => a - b).map(([, p]) => p)
3175
+ };
3176
+ if (state.kind === "function_call")
3177
+ return {
3178
+ type: "function_call",
3179
+ ...state.itemId ? { id: state.itemId } : {},
3180
+ ...state.callId ? { call_id: state.callId } : {},
3181
+ ...state.status ? { status: state.status } : {},
3182
+ name: state.name ?? "",
3183
+ arguments: state.arguments
3184
+ };
3185
+ return {
3186
+ type: "reasoning",
3187
+ ...state.itemId ? { id: state.itemId } : {},
3188
+ ...state.status ? { status: state.status } : {},
3189
+ ...state.summary.size ? {
3190
+ summary: [...state.summary.entries()].sort(([a], [b]) => a - b).map(([, text]) => ({ type: "summary_text", text }))
3191
+ } : {},
3192
+ ...state.reasoningText ? { text: state.reasoningText } : {}
3193
+ };
3141
3194
  });
3142
3195
  try {
3143
3196
  for await (const event of this.source) {
@@ -3181,7 +3234,12 @@ var OpenAIResponsesStream = class {
3181
3234
  case "response.content_part.done": {
3182
3235
  const e = payload;
3183
3236
  if (e.part.type === "output_text" && "text" in e.part && typeof e.part.text === "string" || e.part.type === "refusal" && "refusal" in e.part && typeof e.part.refusal === "string") {
3184
- applyContentPart(e.output_index, e.item_id, e.content_index, e.part);
3237
+ applyContentPart(
3238
+ e.output_index,
3239
+ e.item_id,
3240
+ e.content_index,
3241
+ e.part
3242
+ );
3185
3243
  }
3186
3244
  break;
3187
3245
  }
@@ -3189,7 +3247,10 @@ var OpenAIResponsesStream = class {
3189
3247
  const e = payload;
3190
3248
  const s = ensureState(e.output_index, e.item_id, "message");
3191
3249
  const p = s.content.get(e.content_index);
3192
- s.content.set(e.content_index, { type: "output_text", text: (p?.type === "output_text" ? p.text : "") + e.delta });
3250
+ s.content.set(e.content_index, {
3251
+ type: "output_text",
3252
+ text: (p?.type === "output_text" ? p.text : "") + e.delta
3253
+ });
3193
3254
  break;
3194
3255
  }
3195
3256
  case "response.output_text.done": {
@@ -3202,7 +3263,10 @@ var OpenAIResponsesStream = class {
3202
3263
  const e = payload;
3203
3264
  const s = ensureState(e.output_index, e.item_id, "message");
3204
3265
  const p = s.content.get(e.content_index);
3205
- s.content.set(e.content_index, { type: "refusal", refusal: (p?.type === "refusal" ? p.refusal : "") + e.delta });
3266
+ s.content.set(e.content_index, {
3267
+ type: "refusal",
3268
+ refusal: (p?.type === "refusal" ? p.refusal : "") + e.delta
3269
+ });
3206
3270
  break;
3207
3271
  }
3208
3272
  case "response.refusal.done": {
@@ -3264,20 +3328,31 @@ var OpenAIResponsesStream = class {
3264
3328
  const response = terminalFailure ?? terminalIncomplete;
3265
3329
  const status = terminalFailure ? "failed" : "incomplete";
3266
3330
  const detail = response.error?.message ?? response.incomplete_details?.reason ?? "unknown error";
3267
- throw new OpenAIResponsesStreamError("OpenAI Responses stream " + status + ": " + detail, response);
3331
+ throw new OpenAIResponsesStreamError(
3332
+ "OpenAI Responses stream " + status + ": " + detail,
3333
+ response
3334
+ );
3268
3335
  }
3269
3336
  if (!finalResponse) {
3270
- if (!responseMeta) throw new Error("OpenAI Responses stream ended without a terminal response payload");
3337
+ if (!responseMeta)
3338
+ throw new Error("OpenAI Responses stream ended without a terminal response payload");
3271
3339
  if (responseMeta.status === "failed" || responseMeta.status === "incomplete") {
3272
3340
  const detail = responseMeta.error?.message ?? responseMeta.incomplete_details?.reason ?? "unknown error";
3273
- throw new OpenAIResponsesStreamError("OpenAI Responses stream " + responseMeta.status + ": " + detail, responseMeta);
3341
+ throw new OpenAIResponsesStreamError(
3342
+ "OpenAI Responses stream " + responseMeta.status + ": " + detail,
3343
+ responseMeta
3344
+ );
3274
3345
  }
3275
3346
  finalResponse = { ...responseMeta, output: reconstructedOutput(), status: "completed" };
3276
3347
  } else if (finalResponse.status === "failed" || finalResponse.status === "incomplete") {
3277
3348
  const detail = finalResponse.error?.message ?? finalResponse.incomplete_details?.reason ?? "unknown error";
3278
- throw new OpenAIResponsesStreamError("OpenAI Responses stream " + finalResponse.status + ": " + detail, finalResponse);
3349
+ throw new OpenAIResponsesStreamError(
3350
+ "OpenAI Responses stream " + finalResponse.status + ": " + detail,
3351
+ finalResponse
3352
+ );
3279
3353
  }
3280
- if (finalResponse.output.length === 0 && outputs.size > 0) finalResponse = { ...finalResponse, output: reconstructedOutput() };
3354
+ if (finalResponse.output.length === 0 && outputs.size > 0)
3355
+ finalResponse = { ...finalResponse, output: reconstructedOutput() };
3281
3356
  completed = true;
3282
3357
  this.removeAbortListener?.();
3283
3358
  this.removeAbortListener = void 0;
@@ -3302,14 +3377,11 @@ var OpenAICompatClient = class {
3302
3377
  }
3303
3378
  request(operation, model, signal, holdUntil) {
3304
3379
  if (this.runner) {
3305
- return this.runner(
3306
- (http, runnerSignal) => operation(http, runnerSignal),
3307
- {
3308
- ...model !== void 0 ? { model } : {},
3309
- ...signal !== void 0 ? { signal } : {},
3310
- ...holdUntil !== void 0 ? { holdUntil } : {}
3311
- }
3312
- );
3380
+ return this.runner((http, runnerSignal) => operation(http, runnerSignal), {
3381
+ ...model !== void 0 ? { model } : {},
3382
+ ...signal !== void 0 ? { signal } : {},
3383
+ ...holdUntil !== void 0 ? { holdUntil } : {}
3384
+ });
3313
3385
  }
3314
3386
  return operation(this.http, signal);
3315
3387
  }
@@ -3938,7 +4010,7 @@ var SystemOneContentSchema = z.union([
3938
4010
  var SystemOneChoiceQuestionSchema = z.object({
3939
4011
  type: z.enum(["choice"]),
3940
4012
  instructions: SystemOneContentSchema,
3941
- criteria: z.object({}).catchall(z.union([z.string(), z.null()])).refine((v) => Object.keys(v).length >= 2, { message: "must have at least 2 properties" }).refine((v) => Object.keys(v).length <= 26, { message: "must have at most 26 properties" }).refine((v) => Object.keys(v).every((k) => new RegExp("\\S").test(k)), {
4013
+ criteria: z.object({}).catchall(z.union([z.string(), z.null()])).refine((v) => Object.keys(v).length >= 2, { message: "must have at least 2 properties" }).refine((v) => Object.keys(v).length <= 255, { message: "must have at most 255 properties" }).refine((v) => Object.keys(v).every((k) => new RegExp("\\S").test(k)), {
3942
4014
  message: 'property names must match pattern "\\S"'
3943
4015
  })
3944
4016
  });
@@ -4077,6 +4149,7 @@ var requestSchemas = {
4077
4149
  var responseSchemas = {
4078
4150
  balance: BalanceResponseSchema,
4079
4151
  chat: ChatResponseSchema,
4152
+ copy: StatusResponseSchema,
4080
4153
  create: StatusResponseSchema,
4081
4154
  embed: EmbedResponseSchema,
4082
4155
  generate: GenerateResponseSchema,
@@ -4983,6 +5056,7 @@ var copyOp = {
4983
5056
  method: "POST",
4984
5057
  path: "/api/copy",
4985
5058
  request: { $ref: "#/schemas/CopyRequest" },
5059
+ response: { $ref: "#/schemas/StatusResponse" },
4986
5060
  environment: { local: true, cloud: false },
4987
5061
  transport: { mode: "json", streaming: false },
4988
5062
  capabilities: {},
@@ -6869,6 +6943,93 @@ var ToolRegistry = class {
6869
6943
  };
6870
6944
  }
6871
6945
  };
6946
+ var WEB_SEARCH_TOOL_NAME = "web_search";
6947
+ var WEB_FETCH_TOOL_NAME = "web_fetch";
6948
+ var DEFAULT_MAX_OUTPUT_CHARS = 2e3 * 4;
6949
+ var DEFAULT_MAX_LINKS = 25;
6950
+ var TRUNCATION_MARKER = "\u2026[truncated]";
6951
+ var webSearchSchema = z.object({
6952
+ query: z.string().min(1).describe("The search query string"),
6953
+ max_results: z.number().int().min(1).max(10).optional().describe("Maximum results to return (default 5, max 10)")
6954
+ });
6955
+ var webFetchSchema = z.object({
6956
+ url: z.string().min(1).describe("The URL of the web page to fetch")
6957
+ });
6958
+ function positiveInt2(value, fallback, name) {
6959
+ if (value === void 0) return fallback;
6960
+ if (!Number.isInteger(value) || value < 1) {
6961
+ throw new RangeError(`${name} must be a positive integer, received ${String(value)}`);
6962
+ }
6963
+ return value;
6964
+ }
6965
+ function truncate(text, maxChars) {
6966
+ if (text.length <= maxChars) return text;
6967
+ if (maxChars <= TRUNCATION_MARKER.length) return text.slice(0, maxChars);
6968
+ return text.slice(0, maxChars - TRUNCATION_MARKER.length) + TRUNCATION_MARKER;
6969
+ }
6970
+ function formatWebSearchResult(res, maxChars) {
6971
+ const results = res.results.map(({ title, url, content }) => ({ title, url, content }));
6972
+ const full = JSON.stringify({ results });
6973
+ if (full.length <= maxChars || results.length === 0) return truncate(full, maxChars);
6974
+ const overhead = JSON.stringify({
6975
+ results: results.map((r) => ({ ...r, content: "" }))
6976
+ }).length;
6977
+ const perResult = Math.max(0, Math.floor((maxChars - overhead) / results.length));
6978
+ const trimmed = JSON.stringify({
6979
+ results: results.map((r) => ({ ...r, content: truncate(r.content, perResult) }))
6980
+ });
6981
+ return trimmed.length <= maxChars ? trimmed : truncate(trimmed, maxChars);
6982
+ }
6983
+ function formatWebFetchResult(res, maxChars, maxLinks = DEFAULT_MAX_LINKS) {
6984
+ const page = {
6985
+ title: res.title ?? "",
6986
+ content: res.content,
6987
+ links: (res.links ?? []).slice(0, maxLinks)
6988
+ };
6989
+ const full = JSON.stringify(page);
6990
+ if (full.length <= maxChars) return full;
6991
+ const overhead = JSON.stringify({ ...page, content: "" }).length;
6992
+ const trimmed = JSON.stringify({
6993
+ ...page,
6994
+ content: truncate(page.content, Math.max(0, maxChars - overhead))
6995
+ });
6996
+ return trimmed.length <= maxChars ? trimmed : truncate(trimmed, maxChars);
6997
+ }
6998
+ function createWebSearchTool(client, options = {}) {
6999
+ const maxChars = positiveInt2(options.maxOutputChars, DEFAULT_MAX_OUTPUT_CHARS, "maxOutputChars");
7000
+ const defaultMaxResults = options.defaultMaxResults === void 0 ? void 0 : Math.min(positiveInt2(options.defaultMaxResults, 5, "defaultMaxResults"), 10);
7001
+ return defineTool({
7002
+ name: WEB_SEARCH_TOOL_NAME,
7003
+ description: "Search the web for current information. Returns a list of results, each with a title, url, and relevant content snippet.",
7004
+ schema: webSearchSchema,
7005
+ timeoutMs: options.timeoutMs,
7006
+ execute: async ({ query, max_results }, { signal }) => {
7007
+ const res = await client.webSearch({
7008
+ query,
7009
+ ...(max_results ?? defaultMaxResults) !== void 0 ? { max_results: max_results ?? defaultMaxResults } : {},
7010
+ ...signal !== void 0 ? { signal } : {}
7011
+ });
7012
+ return formatWebSearchResult(res, maxChars);
7013
+ }
7014
+ });
7015
+ }
7016
+ function createWebFetchTool(client, options = {}) {
7017
+ const maxChars = positiveInt2(options.maxOutputChars, DEFAULT_MAX_OUTPUT_CHARS, "maxOutputChars");
7018
+ const maxLinks = positiveInt2(options.maxLinks, DEFAULT_MAX_LINKS, "maxLinks");
7019
+ return defineTool({
7020
+ name: WEB_FETCH_TOOL_NAME,
7021
+ description: "Fetch a single web page by URL. Returns the page title, its main content, and links found on the page.",
7022
+ schema: webFetchSchema,
7023
+ timeoutMs: options.timeoutMs,
7024
+ execute: async ({ url }, { signal }) => {
7025
+ const res = await client.webFetch({ url, ...signal !== void 0 ? { signal } : {} });
7026
+ return formatWebFetchResult(res, maxChars, maxLinks);
7027
+ }
7028
+ });
7029
+ }
7030
+ function createWebTools(client, options = {}) {
7031
+ return [createWebSearchTool(client, options), createWebFetchTool(client, options)];
7032
+ }
6872
7033
 
6873
7034
  // src/mcp/json-schema.ts
6874
7035
  function label(path) {
@@ -7716,6 +7877,6 @@ function estimateSystemOneRequestBytes(request) {
7716
7877
  return new TextEncoder().encode(JSON.stringify(request)).byteLength;
7717
7878
  }
7718
7879
 
7719
- 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, addSpanEvent, applySkill, batchEmbed, calculateBackoff, canonicalToolCallSignature, checkChatContext, checkEndpointHealth, checkGenerateContext, compactConversationHistory, composeMiddleware, contextWarningMessage, createConsoleLogger, createDecision, createModelAffinityScheduler, createOllamaCloudFreeTierQuota, createTimeoutSignal, defineTool, detectModelCapabilities, embedBatchOverflowMessage, encodeImage, estimateChatRequestTokens, estimateGenerateRequestTokens, estimateMessageTokens, estimateSystemOneRequestBytes, estimateTokens, extractContextLength as extractNativeContextLength, extractParameterNumCtx, extractUsage, fetchWithBackoff, findOversizedEmbedInputs, findRunningModelContextLength, formatTelemetry, 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 };
7880
+ 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 };
7720
7881
  //# sourceMappingURL=index.js.map
7721
7882
  //# sourceMappingURL=index.js.map