@nemesis-oss/ollama-sdk 1.5.1 → 1.7.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.d.cts CHANGED
@@ -1,12 +1,12 @@
1
- import { F as FetchLike, M as Middleware, L as Logger, R as RequestLifecycleHook, H as HttpClient, c as OllamaStreamEvent, A as AbortableAsyncIterable, d as OllamaStreamEventType, P as ProgressStreamResult, B as BinaryBody, e as SseEvent, f as OllamaClientError, O as OllamaRuntime, C as ChatStreamResult, G as GenerateStreamResult, g as RawUsageSource, T as TokenUsage } from './runtime-IxRpUBjN.cjs';
2
- export { D as DoneEvent, E as ErrorEvent, h as HttpBody, i as HttpClientOptions, j as HttpRequestOptions, k as LifecycleErrorEvent, l as LifecycleRetryEvent, m as LifecycleStartEvent, n as LifecycleSuccessEvent, o as LogFn, p as MessageEvent, q as MiddlewareContext, N as NANOS_PER_MS, r as NANOS_PER_SECOND, s as NOOP_LOGGER, t as NextFunction, u as OllamaAbortError, v as OllamaAgentMaxIterationsError, w as OllamaAgentMaxToolCallsError, x as OllamaAuthError, y as OllamaClientErrorOptions, z as OllamaErrorRequestContext, J as OllamaErrorResponseContext, K as OllamaGenericClientError, Q as OllamaIncompatibleModelError, U as OllamaMcpError, V as OllamaModelRoutingError, W as OllamaNetworkError, X as OllamaNotFoundError, Y as OllamaQuotaExceededError, Z as OllamaRateLimitError, _ as OllamaRequestValidationError, $ as OllamaServerError, a0 as OllamaSkillInvalidError, a1 as OllamaSkillNotFoundError, a2 as OllamaTimeoutError, a3 as OllamaToolTimeoutError, a4 as OllamaToolValidationError, a5 as OllamaUnsupportedCapabilityError, a6 as RequestContext, a7 as RequestLifecycleEvent, a8 as ResponseContext, a9 as ThinkingEvent, aa as TokenEvent, ab as ToolCallEvent, ac as composeMiddleware, ad as createConsoleLogger, ae as extractUsage, af as mapError, ag as parseSseStream } from './runtime-IxRpUBjN.cjs';
1
+ import { F as FetchLike, M as Middleware, L as Logger, R as RequestLifecycleHook, H as HttpClient, c as OllamaStreamEvent, A as AbortableAsyncIterable, d as OllamaStreamEventType, P as ProgressStreamResult, B as BinaryBody, e as SseEvent, f as OllamaClientError, O as OllamaRuntime, C as ChatStreamResult, G as GenerateStreamResult, g as RawUsageSource, T as TokenUsage } from './runtime-bQ48I-RC.cjs';
2
+ export { D as DoneEvent, E as ErrorEvent, h as HttpBody, i as HttpClientOptions, j as HttpRequestOptions, k as LifecycleErrorEvent, l as LifecycleRetryEvent, m as LifecycleStartEvent, n as LifecycleSuccessEvent, o as LogFn, p as MessageEvent, q as MiddlewareContext, N as NANOS_PER_MS, r as NANOS_PER_SECOND, s as NOOP_LOGGER, t as NextFunction, u as OllamaAbortError, v as OllamaAgentMaxIterationsError, w as OllamaAgentMaxToolCallsError, x as OllamaAuthError, y as OllamaClientErrorOptions, z as OllamaErrorRequestContext, J as OllamaErrorResponseContext, K as OllamaGenericClientError, Q as OllamaIncompatibleModelError, U as OllamaMcpError, V as OllamaModelRoutingError, W as OllamaNetworkError, X as OllamaNotFoundError, Y as OllamaQuotaExceededError, Z as OllamaRateLimitError, _ as OllamaRequestValidationError, $ as OllamaServerError, a0 as OllamaSkillInvalidError, a1 as OllamaSkillNotFoundError, a2 as OllamaTimeoutError, a3 as OllamaToolTimeoutError, a4 as OllamaToolValidationError, a5 as OllamaUnsupportedCapabilityError, a6 as RequestContext, a7 as RequestLifecycleEvent, a8 as ResponseContext, a9 as ThinkingEvent, aa as TokenEvent, ab as ToolCallEvent, ac as composeMiddleware, ad as createConsoleLogger, ae as extractUsage, af as mapError, ag as parseSseStream } from './runtime-bQ48I-RC.cjs';
3
3
  import { T as ThinkingMetadata, M as ModelResponse, 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 ChatRequestOptions, h as ChatResponse, G as GenerateRequestOptions, i as GenerateResponse, E as EmbedRequestOptions, j as EmbedResponse, k as EmbeddingsRequestOptions, l as EmbeddingsResponse, W as WebSearchRequestOptions, m as WebSearchResponse, n as WebFetchRequestOptions, o as WebFetchResponse, p as ToolDefinition, q as ToolCall, r as Message, s as ModelOptions, t as ThinkValue } from './types-5PAjLoCp.cjs';
4
4
  export { F as FormatOption, L as ListResponse, u as Logprob, v as LogprobToken, w as ModelDetails, R as RequestCancellationOptions, x as Role, y as ToolCallFunction, z as ToolFunctionDefinition, A as ToolParameters, B as ToolProperty, H as WebSearchResult } from './types-5PAjLoCp.cjs';
5
5
  import { z } from 'zod';
6
6
  import { T as ToolHandler, a as Tool, A as AnyTool, b as ToolRegistry, c as ToolExecutionResult } from './compose-DS-UWFx8.cjs';
7
7
  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-DS-UWFx8.cjs';
8
- import { M as McpClientLike, a as McpToolDescriptor } from './types-MOsWXEE7.cjs';
9
- export { b as McpCallToolResult, c as McpContentBlock, d as McpIcon, e as McpListToolsParams, f as McpListToolsResult, g as McpRequestOptions, h as McpToolAnnotations, i as McpToolExecution } from './types-MOsWXEE7.cjs';
8
+ import { M as McpClientLike, a as McpToolDescriptor, b as McpTask, c as McpCallToolResult } from './types-CI-gM2u5.cjs';
9
+ export { d as McpContentBlock, e as McpCreateTaskResult, f as McpElicitationFormRequest, g as McpElicitationHandlers, h as McpElicitationRequest, i as McpElicitationResult, j as McpElicitationUrlRequest, k as McpIcon, l as McpInputRequiredResult, m as McpListToolsParams, n as McpListToolsResult, o as McpRequestOptions, p as McpServerCapabilities, q as McpTaskMethod, r as McpTaskRequest, s as McpTaskStatus, t as McpToolAnnotations, u as McpToolCallResult, v as McpToolExecution } from './types-CI-gM2u5.cjs';
10
10
  import * as Otel from '@opentelemetry/api';
11
11
 
12
12
  /**
@@ -1667,6 +1667,12 @@ interface LoadMcpToolsOptions {
1667
1667
  * model-oriented text representation. The default preserves existing behavior.
1668
1668
  */
1669
1669
  readonly resultMode?: McpToolResultMode | undefined;
1670
+ /** Validate structuredContent against a tool's MCP outputSchema. Defaults to true. */
1671
+ readonly validateOutputSchema?: boolean | undefined;
1672
+ /** Invoke optional task-capable tools as legacy MCP tasks when supported. */
1673
+ readonly taskMode?: 'required-only' | 'all-supported' | undefined;
1674
+ /** Requested lifetime for legacy task-augmented tool calls, in milliseconds. */
1675
+ readonly taskTtlMs?: number | undefined;
1670
1676
  }
1671
1677
  declare function listAllMcpTools(mcpClient: McpClientLike, options?: LoadMcpToolsOptions, signal?: AbortSignal): Promise<McpToolDescriptor[]>;
1672
1678
  declare function loadMcpTools(mcpClient: McpClientLike, options?: LoadMcpToolsOptions, signal?: AbortSignal): Promise<AnyTool[]>;
@@ -1682,6 +1688,15 @@ declare class McpBridge {
1682
1688
  definitions(signal?: AbortSignal): Promise<ToolDefinition[]>;
1683
1689
  loadTools(signal?: AbortSignal): Promise<AnyTool[]>;
1684
1690
  register(registry: ToolRegistry, signal?: AbortSignal): Promise<void>;
1691
+ /** Refreshes the current MCP tool catalog into an existing registry without clearing local tools. */
1692
+ refresh(registry: ToolRegistry, signal?: AbortSignal): Promise<void>;
1693
+ /** Fetches one legacy MCP task's current status without starting a polling loop. */
1694
+ getTaskStatus(taskId: string, signal?: AbortSignal): Promise<McpTask>;
1695
+ /** Retrieves a completed legacy MCP task's result. */
1696
+ getTaskResult(taskId: string, signal?: AbortSignal): Promise<McpCallToolResult>;
1697
+ /** Cancels one legacy MCP task. */
1698
+ cancelTask(taskId: string, signal?: AbortSignal): Promise<McpTask>;
1699
+ private requestTask;
1685
1700
  }
1686
1701
 
1687
1702
  /**
@@ -1840,4 +1855,4 @@ declare const GEN_AI_SYSTEM_OLLAMA = "ollama";
1840
1855
  */
1841
1856
  declare function encodeImage(image: Uint8Array | string): Promise<string>;
1842
1857
 
1843
- 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, Agent, type AgentChatClient, type AgentConfig, type AgentHooks, type AgentResult, type AgentRunInput, type AgentTurn, type AnthropicCacheControl, AnthropicCompatClient, type AnthropicContentBlock, type AnthropicImageContentBlock, type AnthropicMessage, type AnthropicMessageStreamEvent, type AnthropicMessagesRequest, type AnthropicMessagesResponse, AnthropicMessagesStream, type AnthropicMetadata, type AnthropicOutputConfig, type AnthropicRedactedThinkingContentBlock, type AnthropicSystem, type AnthropicSystemTextBlock, type AnthropicTextContentBlock, type AnthropicThinkingConfig, type AnthropicThinkingContentBlock, type AnthropicTool, type AnthropicToolChoice, type AnthropicToolResultContentBlock, type AnthropicToolUseContentBlock, type AnthropicUnknownStreamEvent, AnyTool, type BackoffOptions, ChatRequestOptions, ChatResponse, ChatStreamResult, CopyRequestOptions, CreateRequestOptions, DEFAULT_BACKOFF, DEFAULT_BASE_URL, DEFAULT_FAILOVER_CODES, DEFAULT_RETRY_CONFIG, DEFAULT_TIMEOUT_MS, type DefineToolOptions, DeleteRequestOptions, EmbedRequestOptions, EmbedResponse, EmbeddingsRequestOptions, EmbeddingsResponse, type EndpointHealth, type EndpointHealthCheckResult, EndpointRegistry, type EndpointRegistryOptions, FetchLike, GEN_AI_SYSTEM_OLLAMA, GenerateRequestOptions, GenerateResponse, GenerateStreamResult, HttpClient, type LoadMcpToolsOptions, Logger, McpBridge, type McpBridgeOptions, McpClientLike, McpToolDescriptor, Message, Middleware, type ModelCapabilities, ModelOptions, ModelResponse, ModelsClient, OLLAMA_CLOUD_BASE_URL, type OllamaAnthropicContentBlock, type OllamaAnthropicMessage, type OllamaAnthropicMessagesRequest, type OllamaAnthropicSystem, type OllamaAnthropicSystemTextBlock, type OllamaAnthropicTextContentBlock, type OllamaAnthropicThinkingConfig, type OllamaAnthropicTool, type OllamaAnthropicToolResultContentBlock, OllamaClient, type OllamaClientConfig, OllamaClientError, type OllamaCloudFreeTierQuotaBudgets, type OllamaCredentialConfig, type OllamaEndpoint, type OllamaOpenAIChatCompletionRequest, type OllamaOpenAICompletionRequest, type OllamaOpenAIEmbeddingRequest, type OllamaOpenAIReasoningEffort, type OllamaOpenAIResponsesRequest, OllamaStream, OllamaStreamEvent, OllamaStreamEventType, type OpenAIChatCompletionChoice, type OpenAIChatCompletionChunk, type OpenAIChatCompletionChunkChoice, type OpenAIChatCompletionDelta, type OpenAIChatCompletionRequest, type OpenAIChatCompletionResponse, OpenAIChatCompletionStream, OpenAICompatClient, type OpenAICompletionChoice, type OpenAICompletionChunk, type OpenAICompletionRequest, type OpenAICompletionResponse, OpenAICompletionStream, type OpenAIContentPart, type OpenAIEmbeddingInput, type OpenAIEmbeddingItem, type OpenAIEmbeddingRequest, type OpenAIEmbeddingResponse, type OpenAIFunctionDefinition, type OpenAIImageUrlContentPart, type OpenAIListModelsResponse, type OpenAIMessage, type OpenAIModelItem, type OpenAIReasoningEffort, type OpenAIResponseFormat, type OpenAIResponsesCompletedEvent, type OpenAIResponsesContentPartAddedEvent, type OpenAIResponsesContentPartDoneEvent, type OpenAIResponsesCreatedEvent, type OpenAIResponsesError, type OpenAIResponsesEventBase, type OpenAIResponsesFailedEvent, type OpenAIResponsesFunctionCallArgumentsDeltaEvent, type OpenAIResponsesFunctionCallArgumentsDoneEvent, type OpenAIResponsesInProgressEvent, type OpenAIResponsesIncompleteDetails, type OpenAIResponsesIncompleteEvent, type OpenAIResponsesOutputContent, type OpenAIResponsesOutputFunctionCall, type OpenAIResponsesOutputItem, type OpenAIResponsesOutputItemAddedEvent, type OpenAIResponsesOutputItemDoneEvent, type OpenAIResponsesOutputMessage, type OpenAIResponsesOutputReasoning, type OpenAIResponsesOutputRefusal, type OpenAIResponsesOutputTextContent, type OpenAIResponsesOutputTextDeltaEvent, type OpenAIResponsesOutputTextDoneEvent, type OpenAIResponsesQueuedEvent, type OpenAIResponsesReasoningSummaryPartAddedEvent, type OpenAIResponsesReasoningSummaryPartDoneEvent, type OpenAIResponsesReasoningSummaryTextDeltaEvent, type OpenAIResponsesReasoningSummaryTextDoneEvent, type OpenAIResponsesReasoningTextDeltaEvent, type OpenAIResponsesReasoningTextDoneEvent, type OpenAIResponsesRefusalDeltaEvent, type OpenAIResponsesRefusalDoneEvent, type OpenAIResponsesRequest, type OpenAIResponsesResponse, type OpenAIResponsesStatus, OpenAIResponsesStream, OpenAIResponsesStreamError, type OpenAIResponsesStreamEvent, type OpenAIResponsesUsage, type OpenAIStreamOptions, type OpenAITextContentPart, type OpenAITool, type OpenAIToolCall, type OpenAIToolCallDelta, type OpenAIUsage, ProgressResponse, ProgressStreamResult, PsResponse, PullRequestOptions, PushRequestOptions, QuotaManager, type QuotaManagerOptions, type QuotaWindowConfig, type QuotaWindowStatus, RawUsageSource, RequestLifecycleHook, type RequestRunner, type RetryConfig, type RuntimeMode, ShowRequestOptions, ShowResponse, type SpanAttributeValue, type SpanAttributes, SseEvent, StatusResponse, type SupportedSchema, ThinkValue, ThinkingMetadata, type TimeoutSignal, TokenUsage, Tool, ToolCall, ToolDefinition, ToolExecutionResult, ToolHandler, ToolRegistry, VersionResponse, WebFetchRequestOptions, WebFetchResponse, WebSearchRequestOptions, WebSearchResponse, addSpanEvent, calculateBackoff, checkEndpointHealth, createOllamaCloudFreeTierQuota, createTimeoutSignal, defineTool, detectModelCapabilities, encodeImage, inferRuntimeMode, listAllMcpTools, listAvailableModels, loadMcpTools, normalizeChatStream, normalizeGenerateStream, normalizeProgressStream, parseNdjsonStream, parseStructuredOutput, registerMcpTools, resolveCredentialEndpoints, setSpanError, toDataStream, toResponse, toTextStream, withRetry, withSpan, zodToJsonSchema };
1858
+ 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, Agent, type AgentChatClient, type AgentConfig, type AgentHooks, type AgentResult, type AgentRunInput, type AgentTurn, type AnthropicCacheControl, AnthropicCompatClient, type AnthropicContentBlock, type AnthropicImageContentBlock, type AnthropicMessage, type AnthropicMessageStreamEvent, type AnthropicMessagesRequest, type AnthropicMessagesResponse, AnthropicMessagesStream, type AnthropicMetadata, type AnthropicOutputConfig, type AnthropicRedactedThinkingContentBlock, type AnthropicSystem, type AnthropicSystemTextBlock, type AnthropicTextContentBlock, type AnthropicThinkingConfig, type AnthropicThinkingContentBlock, type AnthropicTool, type AnthropicToolChoice, type AnthropicToolResultContentBlock, type AnthropicToolUseContentBlock, type AnthropicUnknownStreamEvent, AnyTool, type BackoffOptions, ChatRequestOptions, ChatResponse, ChatStreamResult, CopyRequestOptions, CreateRequestOptions, DEFAULT_BACKOFF, DEFAULT_BASE_URL, DEFAULT_FAILOVER_CODES, DEFAULT_RETRY_CONFIG, DEFAULT_TIMEOUT_MS, type DefineToolOptions, DeleteRequestOptions, EmbedRequestOptions, EmbedResponse, EmbeddingsRequestOptions, EmbeddingsResponse, type EndpointHealth, type EndpointHealthCheckResult, EndpointRegistry, type EndpointRegistryOptions, FetchLike, GEN_AI_SYSTEM_OLLAMA, GenerateRequestOptions, GenerateResponse, GenerateStreamResult, HttpClient, type LoadMcpToolsOptions, Logger, McpBridge, type McpBridgeOptions, McpCallToolResult, McpClientLike, McpTask, McpToolDescriptor, Message, Middleware, type ModelCapabilities, ModelOptions, ModelResponse, ModelsClient, OLLAMA_CLOUD_BASE_URL, type OllamaAnthropicContentBlock, type OllamaAnthropicMessage, type OllamaAnthropicMessagesRequest, type OllamaAnthropicSystem, type OllamaAnthropicSystemTextBlock, type OllamaAnthropicTextContentBlock, type OllamaAnthropicThinkingConfig, type OllamaAnthropicTool, type OllamaAnthropicToolResultContentBlock, OllamaClient, type OllamaClientConfig, OllamaClientError, type OllamaCloudFreeTierQuotaBudgets, type OllamaCredentialConfig, type OllamaEndpoint, type OllamaOpenAIChatCompletionRequest, type OllamaOpenAICompletionRequest, type OllamaOpenAIEmbeddingRequest, type OllamaOpenAIReasoningEffort, type OllamaOpenAIResponsesRequest, OllamaStream, OllamaStreamEvent, OllamaStreamEventType, type OpenAIChatCompletionChoice, type OpenAIChatCompletionChunk, type OpenAIChatCompletionChunkChoice, type OpenAIChatCompletionDelta, type OpenAIChatCompletionRequest, type OpenAIChatCompletionResponse, OpenAIChatCompletionStream, OpenAICompatClient, type OpenAICompletionChoice, type OpenAICompletionChunk, type OpenAICompletionRequest, type OpenAICompletionResponse, OpenAICompletionStream, type OpenAIContentPart, type OpenAIEmbeddingInput, type OpenAIEmbeddingItem, type OpenAIEmbeddingRequest, type OpenAIEmbeddingResponse, type OpenAIFunctionDefinition, type OpenAIImageUrlContentPart, type OpenAIListModelsResponse, type OpenAIMessage, type OpenAIModelItem, type OpenAIReasoningEffort, type OpenAIResponseFormat, type OpenAIResponsesCompletedEvent, type OpenAIResponsesContentPartAddedEvent, type OpenAIResponsesContentPartDoneEvent, type OpenAIResponsesCreatedEvent, type OpenAIResponsesError, type OpenAIResponsesEventBase, type OpenAIResponsesFailedEvent, type OpenAIResponsesFunctionCallArgumentsDeltaEvent, type OpenAIResponsesFunctionCallArgumentsDoneEvent, type OpenAIResponsesInProgressEvent, type OpenAIResponsesIncompleteDetails, type OpenAIResponsesIncompleteEvent, type OpenAIResponsesOutputContent, type OpenAIResponsesOutputFunctionCall, type OpenAIResponsesOutputItem, type OpenAIResponsesOutputItemAddedEvent, type OpenAIResponsesOutputItemDoneEvent, type OpenAIResponsesOutputMessage, type OpenAIResponsesOutputReasoning, type OpenAIResponsesOutputRefusal, type OpenAIResponsesOutputTextContent, type OpenAIResponsesOutputTextDeltaEvent, type OpenAIResponsesOutputTextDoneEvent, type OpenAIResponsesQueuedEvent, type OpenAIResponsesReasoningSummaryPartAddedEvent, type OpenAIResponsesReasoningSummaryPartDoneEvent, type OpenAIResponsesReasoningSummaryTextDeltaEvent, type OpenAIResponsesReasoningSummaryTextDoneEvent, type OpenAIResponsesReasoningTextDeltaEvent, type OpenAIResponsesReasoningTextDoneEvent, type OpenAIResponsesRefusalDeltaEvent, type OpenAIResponsesRefusalDoneEvent, type OpenAIResponsesRequest, type OpenAIResponsesResponse, type OpenAIResponsesStatus, OpenAIResponsesStream, OpenAIResponsesStreamError, type OpenAIResponsesStreamEvent, type OpenAIResponsesUsage, type OpenAIStreamOptions, type OpenAITextContentPart, type OpenAITool, type OpenAIToolCall, type OpenAIToolCallDelta, type OpenAIUsage, ProgressResponse, ProgressStreamResult, PsResponse, PullRequestOptions, PushRequestOptions, QuotaManager, type QuotaManagerOptions, type QuotaWindowConfig, type QuotaWindowStatus, RawUsageSource, RequestLifecycleHook, type RequestRunner, type RetryConfig, type RuntimeMode, ShowRequestOptions, ShowResponse, type SpanAttributeValue, type SpanAttributes, SseEvent, StatusResponse, type SupportedSchema, ThinkValue, ThinkingMetadata, type TimeoutSignal, TokenUsage, Tool, ToolCall, ToolDefinition, ToolExecutionResult, ToolHandler, ToolRegistry, VersionResponse, WebFetchRequestOptions, WebFetchResponse, WebSearchRequestOptions, WebSearchResponse, addSpanEvent, calculateBackoff, checkEndpointHealth, createOllamaCloudFreeTierQuota, createTimeoutSignal, defineTool, detectModelCapabilities, encodeImage, inferRuntimeMode, listAllMcpTools, listAvailableModels, loadMcpTools, normalizeChatStream, normalizeGenerateStream, normalizeProgressStream, parseNdjsonStream, parseStructuredOutput, registerMcpTools, resolveCredentialEndpoints, setSpanError, toDataStream, toResponse, toTextStream, withRetry, withSpan, zodToJsonSchema };
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { F as FetchLike, M as Middleware, L as Logger, R as RequestLifecycleHook, H as HttpClient, c as OllamaStreamEvent, A as AbortableAsyncIterable, d as OllamaStreamEventType, P as ProgressStreamResult, B as BinaryBody, e as SseEvent, f as OllamaClientError, O as OllamaRuntime, C as ChatStreamResult, G as GenerateStreamResult, g as RawUsageSource, T as TokenUsage } from './runtime-CVQkbYgF.js';
2
- export { D as DoneEvent, E as ErrorEvent, h as HttpBody, i as HttpClientOptions, j as HttpRequestOptions, k as LifecycleErrorEvent, l as LifecycleRetryEvent, m as LifecycleStartEvent, n as LifecycleSuccessEvent, o as LogFn, p as MessageEvent, q as MiddlewareContext, N as NANOS_PER_MS, r as NANOS_PER_SECOND, s as NOOP_LOGGER, t as NextFunction, u as OllamaAbortError, v as OllamaAgentMaxIterationsError, w as OllamaAgentMaxToolCallsError, x as OllamaAuthError, y as OllamaClientErrorOptions, z as OllamaErrorRequestContext, J as OllamaErrorResponseContext, K as OllamaGenericClientError, Q as OllamaIncompatibleModelError, U as OllamaMcpError, V as OllamaModelRoutingError, W as OllamaNetworkError, X as OllamaNotFoundError, Y as OllamaQuotaExceededError, Z as OllamaRateLimitError, _ as OllamaRequestValidationError, $ as OllamaServerError, a0 as OllamaSkillInvalidError, a1 as OllamaSkillNotFoundError, a2 as OllamaTimeoutError, a3 as OllamaToolTimeoutError, a4 as OllamaToolValidationError, a5 as OllamaUnsupportedCapabilityError, a6 as RequestContext, a7 as RequestLifecycleEvent, a8 as ResponseContext, a9 as ThinkingEvent, aa as TokenEvent, ab as ToolCallEvent, ac as composeMiddleware, ad as createConsoleLogger, ae as extractUsage, af as mapError, ag as parseSseStream } from './runtime-CVQkbYgF.js';
1
+ import { F as FetchLike, M as Middleware, L as Logger, R as RequestLifecycleHook, H as HttpClient, c as OllamaStreamEvent, A as AbortableAsyncIterable, d as OllamaStreamEventType, P as ProgressStreamResult, B as BinaryBody, e as SseEvent, f as OllamaClientError, O as OllamaRuntime, C as ChatStreamResult, G as GenerateStreamResult, g as RawUsageSource, T as TokenUsage } from './runtime-qwD72cpn.js';
2
+ export { D as DoneEvent, E as ErrorEvent, h as HttpBody, i as HttpClientOptions, j as HttpRequestOptions, k as LifecycleErrorEvent, l as LifecycleRetryEvent, m as LifecycleStartEvent, n as LifecycleSuccessEvent, o as LogFn, p as MessageEvent, q as MiddlewareContext, N as NANOS_PER_MS, r as NANOS_PER_SECOND, s as NOOP_LOGGER, t as NextFunction, u as OllamaAbortError, v as OllamaAgentMaxIterationsError, w as OllamaAgentMaxToolCallsError, x as OllamaAuthError, y as OllamaClientErrorOptions, z as OllamaErrorRequestContext, J as OllamaErrorResponseContext, K as OllamaGenericClientError, Q as OllamaIncompatibleModelError, U as OllamaMcpError, V as OllamaModelRoutingError, W as OllamaNetworkError, X as OllamaNotFoundError, Y as OllamaQuotaExceededError, Z as OllamaRateLimitError, _ as OllamaRequestValidationError, $ as OllamaServerError, a0 as OllamaSkillInvalidError, a1 as OllamaSkillNotFoundError, a2 as OllamaTimeoutError, a3 as OllamaToolTimeoutError, a4 as OllamaToolValidationError, a5 as OllamaUnsupportedCapabilityError, a6 as RequestContext, a7 as RequestLifecycleEvent, a8 as ResponseContext, a9 as ThinkingEvent, aa as TokenEvent, ab as ToolCallEvent, ac as composeMiddleware, ad as createConsoleLogger, ae as extractUsage, af as mapError, ag as parseSseStream } from './runtime-qwD72cpn.js';
3
3
  import { T as ThinkingMetadata, M as ModelResponse, 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 ChatRequestOptions, h as ChatResponse, G as GenerateRequestOptions, i as GenerateResponse, E as EmbedRequestOptions, j as EmbedResponse, k as EmbeddingsRequestOptions, l as EmbeddingsResponse, W as WebSearchRequestOptions, m as WebSearchResponse, n as WebFetchRequestOptions, o as WebFetchResponse, p as ToolDefinition, q as ToolCall, r as Message, s as ModelOptions, t as ThinkValue } from './types-5PAjLoCp.js';
4
4
  export { F as FormatOption, L as ListResponse, u as Logprob, v as LogprobToken, w as ModelDetails, R as RequestCancellationOptions, x as Role, y as ToolCallFunction, z as ToolFunctionDefinition, A as ToolParameters, B as ToolProperty, H as WebSearchResult } from './types-5PAjLoCp.js';
5
5
  import { z } from 'zod';
6
6
  import { T as ToolHandler, a as Tool, A as AnyTool, b as ToolRegistry, c as ToolExecutionResult } from './compose-DLStUfaF.js';
7
7
  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-DLStUfaF.js';
8
- import { M as McpClientLike, a as McpToolDescriptor } from './types-MOsWXEE7.js';
9
- export { b as McpCallToolResult, c as McpContentBlock, d as McpIcon, e as McpListToolsParams, f as McpListToolsResult, g as McpRequestOptions, h as McpToolAnnotations, i as McpToolExecution } from './types-MOsWXEE7.js';
8
+ import { M as McpClientLike, a as McpToolDescriptor, b as McpTask, c as McpCallToolResult } from './types-CI-gM2u5.js';
9
+ export { d as McpContentBlock, e as McpCreateTaskResult, f as McpElicitationFormRequest, g as McpElicitationHandlers, h as McpElicitationRequest, i as McpElicitationResult, j as McpElicitationUrlRequest, k as McpIcon, l as McpInputRequiredResult, m as McpListToolsParams, n as McpListToolsResult, o as McpRequestOptions, p as McpServerCapabilities, q as McpTaskMethod, r as McpTaskRequest, s as McpTaskStatus, t as McpToolAnnotations, u as McpToolCallResult, v as McpToolExecution } from './types-CI-gM2u5.js';
10
10
  import * as Otel from '@opentelemetry/api';
11
11
 
12
12
  /**
@@ -1667,6 +1667,12 @@ interface LoadMcpToolsOptions {
1667
1667
  * model-oriented text representation. The default preserves existing behavior.
1668
1668
  */
1669
1669
  readonly resultMode?: McpToolResultMode | undefined;
1670
+ /** Validate structuredContent against a tool's MCP outputSchema. Defaults to true. */
1671
+ readonly validateOutputSchema?: boolean | undefined;
1672
+ /** Invoke optional task-capable tools as legacy MCP tasks when supported. */
1673
+ readonly taskMode?: 'required-only' | 'all-supported' | undefined;
1674
+ /** Requested lifetime for legacy task-augmented tool calls, in milliseconds. */
1675
+ readonly taskTtlMs?: number | undefined;
1670
1676
  }
1671
1677
  declare function listAllMcpTools(mcpClient: McpClientLike, options?: LoadMcpToolsOptions, signal?: AbortSignal): Promise<McpToolDescriptor[]>;
1672
1678
  declare function loadMcpTools(mcpClient: McpClientLike, options?: LoadMcpToolsOptions, signal?: AbortSignal): Promise<AnyTool[]>;
@@ -1682,6 +1688,15 @@ declare class McpBridge {
1682
1688
  definitions(signal?: AbortSignal): Promise<ToolDefinition[]>;
1683
1689
  loadTools(signal?: AbortSignal): Promise<AnyTool[]>;
1684
1690
  register(registry: ToolRegistry, signal?: AbortSignal): Promise<void>;
1691
+ /** Refreshes the current MCP tool catalog into an existing registry without clearing local tools. */
1692
+ refresh(registry: ToolRegistry, signal?: AbortSignal): Promise<void>;
1693
+ /** Fetches one legacy MCP task's current status without starting a polling loop. */
1694
+ getTaskStatus(taskId: string, signal?: AbortSignal): Promise<McpTask>;
1695
+ /** Retrieves a completed legacy MCP task's result. */
1696
+ getTaskResult(taskId: string, signal?: AbortSignal): Promise<McpCallToolResult>;
1697
+ /** Cancels one legacy MCP task. */
1698
+ cancelTask(taskId: string, signal?: AbortSignal): Promise<McpTask>;
1699
+ private requestTask;
1685
1700
  }
1686
1701
 
1687
1702
  /**
@@ -1840,4 +1855,4 @@ declare const GEN_AI_SYSTEM_OLLAMA = "ollama";
1840
1855
  */
1841
1856
  declare function encodeImage(image: Uint8Array | string): Promise<string>;
1842
1857
 
1843
- 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, Agent, type AgentChatClient, type AgentConfig, type AgentHooks, type AgentResult, type AgentRunInput, type AgentTurn, type AnthropicCacheControl, AnthropicCompatClient, type AnthropicContentBlock, type AnthropicImageContentBlock, type AnthropicMessage, type AnthropicMessageStreamEvent, type AnthropicMessagesRequest, type AnthropicMessagesResponse, AnthropicMessagesStream, type AnthropicMetadata, type AnthropicOutputConfig, type AnthropicRedactedThinkingContentBlock, type AnthropicSystem, type AnthropicSystemTextBlock, type AnthropicTextContentBlock, type AnthropicThinkingConfig, type AnthropicThinkingContentBlock, type AnthropicTool, type AnthropicToolChoice, type AnthropicToolResultContentBlock, type AnthropicToolUseContentBlock, type AnthropicUnknownStreamEvent, AnyTool, type BackoffOptions, ChatRequestOptions, ChatResponse, ChatStreamResult, CopyRequestOptions, CreateRequestOptions, DEFAULT_BACKOFF, DEFAULT_BASE_URL, DEFAULT_FAILOVER_CODES, DEFAULT_RETRY_CONFIG, DEFAULT_TIMEOUT_MS, type DefineToolOptions, DeleteRequestOptions, EmbedRequestOptions, EmbedResponse, EmbeddingsRequestOptions, EmbeddingsResponse, type EndpointHealth, type EndpointHealthCheckResult, EndpointRegistry, type EndpointRegistryOptions, FetchLike, GEN_AI_SYSTEM_OLLAMA, GenerateRequestOptions, GenerateResponse, GenerateStreamResult, HttpClient, type LoadMcpToolsOptions, Logger, McpBridge, type McpBridgeOptions, McpClientLike, McpToolDescriptor, Message, Middleware, type ModelCapabilities, ModelOptions, ModelResponse, ModelsClient, OLLAMA_CLOUD_BASE_URL, type OllamaAnthropicContentBlock, type OllamaAnthropicMessage, type OllamaAnthropicMessagesRequest, type OllamaAnthropicSystem, type OllamaAnthropicSystemTextBlock, type OllamaAnthropicTextContentBlock, type OllamaAnthropicThinkingConfig, type OllamaAnthropicTool, type OllamaAnthropicToolResultContentBlock, OllamaClient, type OllamaClientConfig, OllamaClientError, type OllamaCloudFreeTierQuotaBudgets, type OllamaCredentialConfig, type OllamaEndpoint, type OllamaOpenAIChatCompletionRequest, type OllamaOpenAICompletionRequest, type OllamaOpenAIEmbeddingRequest, type OllamaOpenAIReasoningEffort, type OllamaOpenAIResponsesRequest, OllamaStream, OllamaStreamEvent, OllamaStreamEventType, type OpenAIChatCompletionChoice, type OpenAIChatCompletionChunk, type OpenAIChatCompletionChunkChoice, type OpenAIChatCompletionDelta, type OpenAIChatCompletionRequest, type OpenAIChatCompletionResponse, OpenAIChatCompletionStream, OpenAICompatClient, type OpenAICompletionChoice, type OpenAICompletionChunk, type OpenAICompletionRequest, type OpenAICompletionResponse, OpenAICompletionStream, type OpenAIContentPart, type OpenAIEmbeddingInput, type OpenAIEmbeddingItem, type OpenAIEmbeddingRequest, type OpenAIEmbeddingResponse, type OpenAIFunctionDefinition, type OpenAIImageUrlContentPart, type OpenAIListModelsResponse, type OpenAIMessage, type OpenAIModelItem, type OpenAIReasoningEffort, type OpenAIResponseFormat, type OpenAIResponsesCompletedEvent, type OpenAIResponsesContentPartAddedEvent, type OpenAIResponsesContentPartDoneEvent, type OpenAIResponsesCreatedEvent, type OpenAIResponsesError, type OpenAIResponsesEventBase, type OpenAIResponsesFailedEvent, type OpenAIResponsesFunctionCallArgumentsDeltaEvent, type OpenAIResponsesFunctionCallArgumentsDoneEvent, type OpenAIResponsesInProgressEvent, type OpenAIResponsesIncompleteDetails, type OpenAIResponsesIncompleteEvent, type OpenAIResponsesOutputContent, type OpenAIResponsesOutputFunctionCall, type OpenAIResponsesOutputItem, type OpenAIResponsesOutputItemAddedEvent, type OpenAIResponsesOutputItemDoneEvent, type OpenAIResponsesOutputMessage, type OpenAIResponsesOutputReasoning, type OpenAIResponsesOutputRefusal, type OpenAIResponsesOutputTextContent, type OpenAIResponsesOutputTextDeltaEvent, type OpenAIResponsesOutputTextDoneEvent, type OpenAIResponsesQueuedEvent, type OpenAIResponsesReasoningSummaryPartAddedEvent, type OpenAIResponsesReasoningSummaryPartDoneEvent, type OpenAIResponsesReasoningSummaryTextDeltaEvent, type OpenAIResponsesReasoningSummaryTextDoneEvent, type OpenAIResponsesReasoningTextDeltaEvent, type OpenAIResponsesReasoningTextDoneEvent, type OpenAIResponsesRefusalDeltaEvent, type OpenAIResponsesRefusalDoneEvent, type OpenAIResponsesRequest, type OpenAIResponsesResponse, type OpenAIResponsesStatus, OpenAIResponsesStream, OpenAIResponsesStreamError, type OpenAIResponsesStreamEvent, type OpenAIResponsesUsage, type OpenAIStreamOptions, type OpenAITextContentPart, type OpenAITool, type OpenAIToolCall, type OpenAIToolCallDelta, type OpenAIUsage, ProgressResponse, ProgressStreamResult, PsResponse, PullRequestOptions, PushRequestOptions, QuotaManager, type QuotaManagerOptions, type QuotaWindowConfig, type QuotaWindowStatus, RawUsageSource, RequestLifecycleHook, type RequestRunner, type RetryConfig, type RuntimeMode, ShowRequestOptions, ShowResponse, type SpanAttributeValue, type SpanAttributes, SseEvent, StatusResponse, type SupportedSchema, ThinkValue, ThinkingMetadata, type TimeoutSignal, TokenUsage, Tool, ToolCall, ToolDefinition, ToolExecutionResult, ToolHandler, ToolRegistry, VersionResponse, WebFetchRequestOptions, WebFetchResponse, WebSearchRequestOptions, WebSearchResponse, addSpanEvent, calculateBackoff, checkEndpointHealth, createOllamaCloudFreeTierQuota, createTimeoutSignal, defineTool, detectModelCapabilities, encodeImage, inferRuntimeMode, listAllMcpTools, listAvailableModels, loadMcpTools, normalizeChatStream, normalizeGenerateStream, normalizeProgressStream, parseNdjsonStream, parseStructuredOutput, registerMcpTools, resolveCredentialEndpoints, setSpanError, toDataStream, toResponse, toTextStream, withRetry, withSpan, zodToJsonSchema };
1858
+ 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, Agent, type AgentChatClient, type AgentConfig, type AgentHooks, type AgentResult, type AgentRunInput, type AgentTurn, type AnthropicCacheControl, AnthropicCompatClient, type AnthropicContentBlock, type AnthropicImageContentBlock, type AnthropicMessage, type AnthropicMessageStreamEvent, type AnthropicMessagesRequest, type AnthropicMessagesResponse, AnthropicMessagesStream, type AnthropicMetadata, type AnthropicOutputConfig, type AnthropicRedactedThinkingContentBlock, type AnthropicSystem, type AnthropicSystemTextBlock, type AnthropicTextContentBlock, type AnthropicThinkingConfig, type AnthropicThinkingContentBlock, type AnthropicTool, type AnthropicToolChoice, type AnthropicToolResultContentBlock, type AnthropicToolUseContentBlock, type AnthropicUnknownStreamEvent, AnyTool, type BackoffOptions, ChatRequestOptions, ChatResponse, ChatStreamResult, CopyRequestOptions, CreateRequestOptions, DEFAULT_BACKOFF, DEFAULT_BASE_URL, DEFAULT_FAILOVER_CODES, DEFAULT_RETRY_CONFIG, DEFAULT_TIMEOUT_MS, type DefineToolOptions, DeleteRequestOptions, EmbedRequestOptions, EmbedResponse, EmbeddingsRequestOptions, EmbeddingsResponse, type EndpointHealth, type EndpointHealthCheckResult, EndpointRegistry, type EndpointRegistryOptions, FetchLike, GEN_AI_SYSTEM_OLLAMA, GenerateRequestOptions, GenerateResponse, GenerateStreamResult, HttpClient, type LoadMcpToolsOptions, Logger, McpBridge, type McpBridgeOptions, McpCallToolResult, McpClientLike, McpTask, McpToolDescriptor, Message, Middleware, type ModelCapabilities, ModelOptions, ModelResponse, ModelsClient, OLLAMA_CLOUD_BASE_URL, type OllamaAnthropicContentBlock, type OllamaAnthropicMessage, type OllamaAnthropicMessagesRequest, type OllamaAnthropicSystem, type OllamaAnthropicSystemTextBlock, type OllamaAnthropicTextContentBlock, type OllamaAnthropicThinkingConfig, type OllamaAnthropicTool, type OllamaAnthropicToolResultContentBlock, OllamaClient, type OllamaClientConfig, OllamaClientError, type OllamaCloudFreeTierQuotaBudgets, type OllamaCredentialConfig, type OllamaEndpoint, type OllamaOpenAIChatCompletionRequest, type OllamaOpenAICompletionRequest, type OllamaOpenAIEmbeddingRequest, type OllamaOpenAIReasoningEffort, type OllamaOpenAIResponsesRequest, OllamaStream, OllamaStreamEvent, OllamaStreamEventType, type OpenAIChatCompletionChoice, type OpenAIChatCompletionChunk, type OpenAIChatCompletionChunkChoice, type OpenAIChatCompletionDelta, type OpenAIChatCompletionRequest, type OpenAIChatCompletionResponse, OpenAIChatCompletionStream, OpenAICompatClient, type OpenAICompletionChoice, type OpenAICompletionChunk, type OpenAICompletionRequest, type OpenAICompletionResponse, OpenAICompletionStream, type OpenAIContentPart, type OpenAIEmbeddingInput, type OpenAIEmbeddingItem, type OpenAIEmbeddingRequest, type OpenAIEmbeddingResponse, type OpenAIFunctionDefinition, type OpenAIImageUrlContentPart, type OpenAIListModelsResponse, type OpenAIMessage, type OpenAIModelItem, type OpenAIReasoningEffort, type OpenAIResponseFormat, type OpenAIResponsesCompletedEvent, type OpenAIResponsesContentPartAddedEvent, type OpenAIResponsesContentPartDoneEvent, type OpenAIResponsesCreatedEvent, type OpenAIResponsesError, type OpenAIResponsesEventBase, type OpenAIResponsesFailedEvent, type OpenAIResponsesFunctionCallArgumentsDeltaEvent, type OpenAIResponsesFunctionCallArgumentsDoneEvent, type OpenAIResponsesInProgressEvent, type OpenAIResponsesIncompleteDetails, type OpenAIResponsesIncompleteEvent, type OpenAIResponsesOutputContent, type OpenAIResponsesOutputFunctionCall, type OpenAIResponsesOutputItem, type OpenAIResponsesOutputItemAddedEvent, type OpenAIResponsesOutputItemDoneEvent, type OpenAIResponsesOutputMessage, type OpenAIResponsesOutputReasoning, type OpenAIResponsesOutputRefusal, type OpenAIResponsesOutputTextContent, type OpenAIResponsesOutputTextDeltaEvent, type OpenAIResponsesOutputTextDoneEvent, type OpenAIResponsesQueuedEvent, type OpenAIResponsesReasoningSummaryPartAddedEvent, type OpenAIResponsesReasoningSummaryPartDoneEvent, type OpenAIResponsesReasoningSummaryTextDeltaEvent, type OpenAIResponsesReasoningSummaryTextDoneEvent, type OpenAIResponsesReasoningTextDeltaEvent, type OpenAIResponsesReasoningTextDoneEvent, type OpenAIResponsesRefusalDeltaEvent, type OpenAIResponsesRefusalDoneEvent, type OpenAIResponsesRequest, type OpenAIResponsesResponse, type OpenAIResponsesStatus, OpenAIResponsesStream, OpenAIResponsesStreamError, type OpenAIResponsesStreamEvent, type OpenAIResponsesUsage, type OpenAIStreamOptions, type OpenAITextContentPart, type OpenAITool, type OpenAIToolCall, type OpenAIToolCallDelta, type OpenAIUsage, ProgressResponse, ProgressStreamResult, PsResponse, PullRequestOptions, PushRequestOptions, QuotaManager, type QuotaManagerOptions, type QuotaWindowConfig, type QuotaWindowStatus, RawUsageSource, RequestLifecycleHook, type RequestRunner, type RetryConfig, type RuntimeMode, ShowRequestOptions, ShowResponse, type SpanAttributeValue, type SpanAttributes, SseEvent, StatusResponse, type SupportedSchema, ThinkValue, ThinkingMetadata, type TimeoutSignal, TokenUsage, Tool, ToolCall, ToolDefinition, ToolExecutionResult, ToolHandler, ToolRegistry, VersionResponse, WebFetchRequestOptions, WebFetchResponse, WebSearchRequestOptions, WebSearchResponse, addSpanEvent, calculateBackoff, checkEndpointHealth, createOllamaCloudFreeTierQuota, createTimeoutSignal, defineTool, detectModelCapabilities, encodeImage, inferRuntimeMode, listAllMcpTools, listAvailableModels, loadMcpTools, normalizeChatStream, normalizeGenerateStream, normalizeProgressStream, parseNdjsonStream, parseStructuredOutput, registerMcpTools, resolveCredentialEndpoints, setSpanError, toDataStream, toResponse, toTextStream, withRetry, withSpan, zodToJsonSchema };
package/dist/index.js CHANGED
@@ -237,10 +237,12 @@ var OllamaAgentMaxIterationsError = class extends OllamaClientError {
237
237
  var OllamaMcpError = class extends OllamaClientError {
238
238
  mcpMethod;
239
239
  toolName;
240
+ issues;
240
241
  constructor(message, options) {
241
242
  super(message, { ...options, code: "mcp_error", retryable: options.retryable ?? false });
242
243
  this.mcpMethod = options.mcpMethod;
243
244
  this.toolName = options.toolName;
245
+ this.issues = options.issues;
244
246
  }
245
247
  };
246
248
  var OllamaSkillNotFoundError = class extends OllamaClientError {
@@ -4004,6 +4006,22 @@ async function listAllMcpTools(mcpClient, options = {}, signal) {
4004
4006
  const params = cursor !== void 0 ? { cursor } : void 0;
4005
4007
  const requestOptions = signal !== void 0 ? { signal } : void 0;
4006
4008
  const page = await mcpClient.listTools(params, requestOptions);
4009
+ const pageNames = /* @__PURE__ */ new Set();
4010
+ for (const tool of page.tools) {
4011
+ if (pageNames.has(tool.name)) {
4012
+ throw new OllamaMcpError(
4013
+ `MCP tools/list returned duplicate tool name "${tool.name}"`,
4014
+ { mcpMethod: "listTools", toolName: tool.name }
4015
+ );
4016
+ }
4017
+ pageNames.add(tool.name);
4018
+ if (tools.some((existing) => existing.name === tool.name)) {
4019
+ throw new OllamaMcpError(
4020
+ `MCP tools/list returned duplicate tool name "${tool.name}" across pages`,
4021
+ { mcpMethod: "listTools", toolName: tool.name }
4022
+ );
4023
+ }
4024
+ }
4007
4025
  tools.push(...page.tools);
4008
4026
  if (page.nextCursor === void 0) {
4009
4027
  return tools;
@@ -4017,6 +4035,9 @@ async function listAllMcpTools(mcpClient, options = {}, signal) {
4017
4035
  throw new Error("MCP tools/list exceeded maxPages (" + maxPages + ")");
4018
4036
  }
4019
4037
  function formatMcpToolResult(result) {
4038
+ if ("resultType" in result || "task" in result) {
4039
+ return JSON.stringify(result) ?? String(result);
4040
+ }
4020
4041
  const parts = result.content.map((block) => {
4021
4042
  if (block.type === "text" && typeof block.text === "string") {
4022
4043
  return block.text;
@@ -4038,6 +4059,20 @@ function formatMcpToolResult(result) {
4038
4059
  }
4039
4060
  return parts.join("\n");
4040
4061
  }
4062
+ function supportsTaskCalls(mcpClient) {
4063
+ return mcpClient.getServerCapabilities?.()?.tasks?.requests?.tools?.call !== void 0;
4064
+ }
4065
+ function shouldCallAsTask(descriptor, options, serverSupportsTasks) {
4066
+ const support = descriptor.execution?.taskSupport;
4067
+ if (support === "required" && !serverSupportsTasks) {
4068
+ throw new OllamaMcpError(
4069
+ `MCP tool "${descriptor.name}" requires task execution, but the server does not advertise tasks.requests.tools.call`,
4070
+ { mcpMethod: "callTool", toolName: descriptor.name }
4071
+ );
4072
+ }
4073
+ if (!serverSupportsTasks || support === void 0 || support === "forbidden") return false;
4074
+ return support === "required" || options.taskMode === "all-supported";
4075
+ }
4041
4076
  function createInputValidator(inputSchema) {
4042
4077
  return z.custom().superRefine((value, ctx) => {
4043
4078
  const issues = validateJsonSchema(value, inputSchema);
@@ -4050,7 +4085,7 @@ function createInputValidator(inputSchema) {
4050
4085
  }
4051
4086
  });
4052
4087
  }
4053
- function convertMcpDescriptorToTool(descriptor, mcpClient, namePrefix = "", resultMode = "text") {
4088
+ function convertMcpDescriptorToTool(descriptor, mcpClient, namePrefix = "", resultMode = "text", validateOutputSchema = true, executeAsTask = false, taskTtlMs) {
4054
4089
  const toolName = `${namePrefix}${descriptor.name}`;
4055
4090
  const inputSchema = descriptor.inputSchema ?? { type: "object", properties: {} };
4056
4091
  const properties = inputSchema["properties"] ?? {};
@@ -4070,10 +4105,27 @@ function convertMcpDescriptorToTool(descriptor, mcpClient, namePrefix = "", resu
4070
4105
  const result = await mcpClient.callTool(
4071
4106
  {
4072
4107
  name: descriptor.name,
4073
- arguments: args
4108
+ arguments: args,
4109
+ ...executeAsTask ? { task: taskTtlMs !== void 0 ? { ttl: taskTtlMs } : {} } : {}
4074
4110
  },
4075
- context.signal !== void 0 ? { signal: context.signal } : void 0
4111
+ {
4112
+ ...context.signal !== void 0 ? { signal: context.signal } : {},
4113
+ allowInputRequired: true
4114
+ }
4076
4115
  );
4116
+ if (!("resultType" in result) && !("task" in result) && validateOutputSchema && descriptor.outputSchema !== void 0 && result.structuredContent !== void 0) {
4117
+ const issues = validateJsonSchema(result.structuredContent, descriptor.outputSchema);
4118
+ if (issues.length > 0) {
4119
+ throw new OllamaMcpError(
4120
+ `MCP tool "${descriptor.name}" returned structuredContent that violates outputSchema`,
4121
+ {
4122
+ mcpMethod: "tools/call",
4123
+ toolName: descriptor.name,
4124
+ issues
4125
+ }
4126
+ );
4127
+ }
4128
+ }
4077
4129
  return resultMode === "structured" ? result : formatMcpToolResult(result);
4078
4130
  } catch (err) {
4079
4131
  if (err instanceof OllamaMcpError) throw err;
@@ -4096,9 +4148,29 @@ function convertMcpDescriptorToTool(descriptor, mcpClient, namePrefix = "", resu
4096
4148
  }
4097
4149
  async function loadMcpTools(mcpClient, options = {}, signal) {
4098
4150
  try {
4151
+ if (options.taskTtlMs !== void 0 && (!Number.isFinite(options.taskTtlMs) || options.taskTtlMs <= 0)) {
4152
+ throw new RangeError("MCP taskTtlMs must be a positive finite number");
4153
+ }
4099
4154
  const tools = await listAllMcpTools(mcpClient, options, signal);
4100
- return tools.map((t) => convertMcpDescriptorToTool(t, mcpClient, options.namePrefix, options.resultMode));
4155
+ const serverSupportsTasks = supportsTaskCalls(mcpClient);
4156
+ return tools.map((tool) => {
4157
+ const taskCall = shouldCallAsTask(
4158
+ tool,
4159
+ options,
4160
+ serverSupportsTasks
4161
+ );
4162
+ return convertMcpDescriptorToTool(
4163
+ tool,
4164
+ mcpClient,
4165
+ options.namePrefix,
4166
+ options.resultMode,
4167
+ options.validateOutputSchema ?? true,
4168
+ taskCall,
4169
+ options.taskTtlMs
4170
+ );
4171
+ });
4101
4172
  } catch (err) {
4173
+ if (err instanceof OllamaMcpError) throw err;
4102
4174
  throw new OllamaMcpError("Failed listing MCP tools from client", {
4103
4175
  mcpMethod: "listTools",
4104
4176
  cause: err
@@ -4109,8 +4181,18 @@ async function registerMcpTools(registry, mcpClient, options = {}, signal) {
4109
4181
  const tools = await loadMcpTools(mcpClient, options, signal);
4110
4182
  registry.registerMany(tools);
4111
4183
  }
4112
-
4113
- // src/mcp/bridge.ts
4184
+ var taskSchema = z.object({
4185
+ taskId: z.string(),
4186
+ status: z.enum(["working", "input_required", "completed", "failed", "cancelled"]),
4187
+ statusMessage: z.string().optional(),
4188
+ createdAt: z.string(),
4189
+ lastUpdatedAt: z.string(),
4190
+ ttl: z.number().optional(),
4191
+ pollInterval: z.number().optional()
4192
+ }).passthrough();
4193
+ var callToolResultSchema = z.custom(
4194
+ (value) => typeof value === "object" && value !== null && "content" in value && Array.isArray(value.content)
4195
+ );
4114
4196
  var McpBridge = class _McpBridge {
4115
4197
  constructor(client, options = {}) {
4116
4198
  this.client = client;
@@ -4145,6 +4227,50 @@ var McpBridge = class _McpBridge {
4145
4227
  async register(registry, signal) {
4146
4228
  await registry.registerMany(await this.loadTools(signal));
4147
4229
  }
4230
+ /** Refreshes the current MCP tool catalog into an existing registry without clearing local tools. */
4231
+ async refresh(registry, signal) {
4232
+ await registry.registerMany(await this.loadTools(signal));
4233
+ }
4234
+ /** Fetches one legacy MCP task's current status without starting a polling loop. */
4235
+ async getTaskStatus(taskId, signal) {
4236
+ return this.requestTask(
4237
+ "tasks/get",
4238
+ taskId,
4239
+ taskSchema,
4240
+ signal
4241
+ );
4242
+ }
4243
+ /** Retrieves a completed legacy MCP task's result. */
4244
+ async getTaskResult(taskId, signal) {
4245
+ return this.requestTask(
4246
+ "tasks/result",
4247
+ taskId,
4248
+ callToolResultSchema,
4249
+ signal
4250
+ );
4251
+ }
4252
+ /** Cancels one legacy MCP task. */
4253
+ async cancelTask(taskId, signal) {
4254
+ return this.requestTask(
4255
+ "tasks/cancel",
4256
+ taskId,
4257
+ taskSchema,
4258
+ signal
4259
+ );
4260
+ }
4261
+ requestTask(method, taskId, resultSchema, signal) {
4262
+ if (this.client.request === void 0) {
4263
+ throw new OllamaMcpError(
4264
+ `MCP client does not support ${method} requests`,
4265
+ { mcpMethod: method }
4266
+ );
4267
+ }
4268
+ return this.client.request(
4269
+ { method, params: { taskId } },
4270
+ resultSchema,
4271
+ signal !== void 0 ? { signal } : void 0
4272
+ );
4273
+ }
4148
4274
  };
4149
4275
 
4150
4276
  // src/skills/frontmatter.ts