@nemesis-oss/ollama-sdk 1.25.0 → 1.25.2
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/{anthropic-DTQ01pAS.d.cts → anthropic-DA9flTv_.d.ts} +4 -1
- package/dist/{anthropic-DdaNgdG_.d.ts → anthropic-DnsaK9Ui.d.cts} +4 -1
- package/dist/generated-api.d.cts +4 -4
- package/dist/generated-api.d.ts +4 -4
- package/dist/generated-runtime.cjs +14 -16
- package/dist/generated-runtime.cjs.map +1 -1
- package/dist/generated-runtime.d.cts +1 -1
- package/dist/generated-runtime.d.ts +1 -1
- package/dist/generated-runtime.js +14 -16
- package/dist/generated-runtime.js.map +1 -1
- package/dist/index.cjs +106 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +106 -61
- package/dist/index.js.map +1 -1
- package/dist/mcp-generated.d.cts +1 -1
- package/dist/mcp-generated.d.ts +1 -1
- package/dist/{runtime-CUzw4GAE.d.cts → runtime-BoTPAvJH.d.cts} +9 -3
- package/dist/{runtime-D_rMXIVT.d.ts → runtime-DQRudJFP.d.ts} +9 -3
- package/package.json +10 -10
package/dist/index.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { T as ThinkingMetadata, M as ModelResponse, R as RequestCancellationOptions, I as ImageResolutionPolicy, S as ShowRequestOptions, a as ShowResponse, P as PullRequestOptions, b as ProgressResponse, c as PushRequestOptions, C as CreateRequestOptions, D as DeleteRequestOptions, d as StatusResponse, e as CopyRequestOptions, f as PsResponse, V as VersionResponse, g as ToolParameters, h as ThinkValue, i as ToolCall, j as ChatRequestOptions, k as ModelOptions, l as ToolDefinition, F as FormatOption, m as ChatResponse, n as Message, G as GenerateRequestOptions, o as GenerateResponse, E as EmbedRequestOptions, p as EmbedResponse, q as EmbeddingsRequestOptions, r as EmbeddingsResponse, W as WebSearchRequestOptions, s as WebSearchResponse, t as WebFetchRequestOptions, u as WebFetchResponse, U as UsageRequestOptions, B as BalanceRequestOptions, v as PingResult, w as VisionInput } from './types-CH3pdrak.cjs';
|
|
2
2
|
export { x as ImageAddress, y as ImageFetchLike, L as ListResponse, z as Logprob, A as LogprobToken, H as ModelDetails, J as Role, K as ToolCallFunction, N as ToolFunctionDefinition, O as ToolProperty, Q as UsageGroupBy, X as UsageRange, Y as UsageScope, Z as WebSearchResult, _ as imageStringNeedsResolution, $ as resolveImageInput } from './types-CH3pdrak.cjs';
|
|
3
|
-
import { H as HttpClient, F as FetchLike, M as Middleware, L as Logger, R as RequestLifecycleHook, c as OllamaStreamEvent, A as AbortableAsyncIterable, d as OllamaStreamEventType, P as ProgressStreamResult, B as BinaryBody, O as OllamaRuntime, C as ChatStreamResult, G as GenerateStreamResult, e as RawUsageSource, T as TokenUsage } from './runtime-
|
|
4
|
-
export { D as DoneEvent, E as ErrorEvent, f as HttpBody, g as HttpClientOptions, h as HttpRequestOptions, i as LifecycleErrorEvent, j as LifecycleRetryEvent, k as LifecycleStartEvent, l as LifecycleSuccessEvent, m as LogFn, n as MessageEvent, o as MiddlewareContext, N as NANOS_PER_MS, p as NANOS_PER_SECOND, q as NETWORK_ERROR_CODES, r as NOOP_LOGGER, s as NextFunction, t as OllamaAbortError, u as OllamaAgentMaxIterationsError, v as OllamaAgentMaxToolCallsError, w as OllamaAgentToolLoopError, x as OllamaAuthError, y as OllamaBadGatewayError, z as OllamaClientError, J as OllamaClientErrorOptions, K as OllamaCloudModelVersionError, Q as OllamaErrorRequestContext, U as OllamaErrorResponseContext, V as OllamaGenericClientError, W as OllamaIncompatibleModelError, X as OllamaMcpError, Y as OllamaModelRoutingError, Z as OllamaNetworkError, _ as OllamaNotFoundError, $ as OllamaOverloadedError, a0 as OllamaPaymentRequiredError, a1 as OllamaQuotaExceededError, a2 as OllamaRateLimitError, a3 as OllamaRequestTooLargeError, a4 as OllamaRequestValidationError, a5 as OllamaResponseValidationError, a6 as OllamaServerError, a7 as OllamaServerVersionUnknownError, a8 as OllamaSkillInvalidError, a9 as OllamaSkillNotFoundError, aa as OllamaStreamError, ab as OllamaTimeoutError, ac as OllamaToolTimeoutError, ad as OllamaToolValidationError, ae as OllamaUnsupportedCapabilityError, af as RequestContext, ag as RequestLifecycleEvent, ah as ResponseContext, ai as SseEvent, aj as ThinkingEvent, ak as TokenEvent, al as ToolCallEvent, am as composeMiddleware, an as createConsoleLogger, ao as extractUsage, ap as isNetworkLevelError, aq as mapError, ar as parseRetryAfterMs, as as parseSseStream } from './runtime-
|
|
3
|
+
import { H as HttpClient, F as FetchLike, M as Middleware, L as Logger, R as RequestLifecycleHook, c as OllamaStreamEvent, A as AbortableAsyncIterable, d as OllamaStreamEventType, P as ProgressStreamResult, B as BinaryBody, O as OllamaRuntime, C as ChatStreamResult, G as GenerateStreamResult, e as RawUsageSource, T as TokenUsage } from './runtime-BoTPAvJH.cjs';
|
|
4
|
+
export { D as DoneEvent, E as ErrorEvent, f as HttpBody, g as HttpClientOptions, h as HttpRequestOptions, i as LifecycleErrorEvent, j as LifecycleRetryEvent, k as LifecycleStartEvent, l as LifecycleSuccessEvent, m as LogFn, n as MessageEvent, o as MiddlewareContext, N as NANOS_PER_MS, p as NANOS_PER_SECOND, q as NETWORK_ERROR_CODES, r as NOOP_LOGGER, s as NextFunction, t as OllamaAbortError, u as OllamaAgentMaxIterationsError, v as OllamaAgentMaxToolCallsError, w as OllamaAgentToolLoopError, x as OllamaAuthError, y as OllamaBadGatewayError, z as OllamaClientError, J as OllamaClientErrorOptions, K as OllamaCloudModelVersionError, Q as OllamaErrorRequestContext, U as OllamaErrorResponseContext, V as OllamaGenericClientError, W as OllamaIncompatibleModelError, X as OllamaMcpError, Y as OllamaModelRoutingError, Z as OllamaNetworkError, _ as OllamaNotFoundError, $ as OllamaOverloadedError, a0 as OllamaPaymentRequiredError, a1 as OllamaQuotaExceededError, a2 as OllamaRateLimitError, a3 as OllamaRequestTooLargeError, a4 as OllamaRequestValidationError, a5 as OllamaResponseValidationError, a6 as OllamaServerError, a7 as OllamaServerVersionUnknownError, a8 as OllamaSkillInvalidError, a9 as OllamaSkillNotFoundError, aa as OllamaStreamError, ab as OllamaTimeoutError, ac as OllamaToolTimeoutError, ad as OllamaToolValidationError, ae as OllamaUnsupportedCapabilityError, af as RequestContext, ag as RequestLifecycleEvent, ah as ResponseContext, ai as SseEvent, aj as ThinkingEvent, ak as TokenEvent, al as ToolCallEvent, am as composeMiddleware, an as createConsoleLogger, ao as extractUsage, ap as isNetworkLevelError, aq as mapError, ar as parseRetryAfterMs, as as parseSseStream } from './runtime-BoTPAvJH.cjs';
|
|
5
5
|
import { z } from 'zod';
|
|
6
|
-
import { R as RequestRunner, S as SystemOneChoiceAnswer, o as SystemOneNoulAnswer, p as SystemOneScoreAnswer, q as SystemOneChoiceQuestion, r as SystemOneNoulQuestion, s as SystemOneScoreQuestion, t as SystemOneRequest$1, u as SystemOneResponse$1, v as SystemOneContent, N as NativeApi, w as OpenAICompatClient, x as AnthropicCompatClient } from './anthropic-
|
|
7
|
-
export { y as AnthropicCacheControl, z as AnthropicContentBlock, B as AnthropicImageContentBlock, C as AnthropicMessage, n as AnthropicMessageStreamEvent, A as AnthropicMessagesRequest, m as AnthropicMessagesResponse, D as AnthropicMessagesStream, E as AnthropicMetadata, F as AnthropicOutputConfig, G as AnthropicRedactedThinkingContentBlock, H as AnthropicSystem, I as AnthropicSystemTextBlock, J as AnthropicTextContentBlock, K as AnthropicThinkingConfig, L as AnthropicThinkingContentBlock, M as AnthropicTool, P as AnthropicToolChoice, Q as AnthropicToolResultContentBlock, T as AnthropicToolUseContentBlock, U as AnthropicUnknownStreamEvent, V as OllamaAnthropicContentBlock, W as OllamaAnthropicMessage, X as OllamaAnthropicMessagesRequest, Y as OllamaAnthropicSystem, Z as OllamaAnthropicSystemTextBlock, _ as OllamaAnthropicTextContentBlock, $ as OllamaAnthropicThinkingConfig, a0 as OllamaAnthropicTool, a1 as OllamaAnthropicToolResultContentBlock, a2 as OllamaOpenAIChatCompletionRequest, a3 as OllamaOpenAIChatContentPart, a4 as OllamaOpenAIChatMessage, a5 as OllamaOpenAICompletionRequest, a6 as OllamaOpenAIEmbeddingRequest, a7 as OllamaOpenAIImageDataUrl, a8 as OllamaOpenAIReasoningEffort, a9 as OllamaOpenAIResponsesRequest, aa as OllamaOpenAISpeechRequest, ab as OpenAIChatCompletionChoice, b as OpenAIChatCompletionChunk, ac as OpenAIChatCompletionChunkChoice, ad as OpenAIChatCompletionDelta, O as OpenAIChatCompletionRequest, a as OpenAIChatCompletionResponse, ae as OpenAIChatCompletionStream, af as OpenAICompletionChoice, e as OpenAICompletionChunk, c as OpenAICompletionRequest, d as OpenAICompletionResponse, ag as OpenAICompletionStream, ah as OpenAIContentPart, ai as OpenAIEmbeddingInput, aj as OpenAIEmbeddingItem, f as OpenAIEmbeddingRequest, g as OpenAIEmbeddingResponse, ak as OpenAIFunctionDefinition, al as OpenAIImageUrlContentPart, h as OpenAIListModelsResponse, am as OpenAIMessage, i as OpenAIModelItem, an as OpenAIReasoningEffort, ao as OpenAIResponseFormat, ap as OpenAIResponsesCompletedEvent, aq as OpenAIResponsesContentPartAddedEvent, ar as OpenAIResponsesContentPartDoneEvent, as as OpenAIResponsesCreatedEvent, at as OpenAIResponsesError, au as OpenAIResponsesEventBase, av as OpenAIResponsesFailedEvent, aw as OpenAIResponsesFunctionCallArgumentsDeltaEvent, ax as OpenAIResponsesFunctionCallArgumentsDoneEvent, ay as OpenAIResponsesInProgressEvent, az as OpenAIResponsesIncompleteDetails, aA as OpenAIResponsesIncompleteEvent, aB as OpenAIResponsesOutputContent, aC as OpenAIResponsesOutputFunctionCall, aD as OpenAIResponsesOutputItem, aE as OpenAIResponsesOutputItemAddedEvent, aF as OpenAIResponsesOutputItemDoneEvent, aG as OpenAIResponsesOutputMessage, aH as OpenAIResponsesOutputReasoning, aI as OpenAIResponsesOutputRefusal, aJ as OpenAIResponsesOutputTextContent, aK as OpenAIResponsesOutputTextDeltaEvent, aL as OpenAIResponsesOutputTextDoneEvent, aM as OpenAIResponsesQueuedEvent, aN as OpenAIResponsesReasoningSummaryPartAddedEvent, aO as OpenAIResponsesReasoningSummaryPartDoneEvent, aP as OpenAIResponsesReasoningSummaryTextDeltaEvent, aQ as OpenAIResponsesReasoningSummaryTextDoneEvent, aR as OpenAIResponsesReasoningTextDeltaEvent, aS as OpenAIResponsesReasoningTextDoneEvent, aT as OpenAIResponsesRefusalDeltaEvent, aU as OpenAIResponsesRefusalDoneEvent, j as OpenAIResponsesRequest, k as OpenAIResponsesResponse, aV as OpenAIResponsesStatus, aW as OpenAIResponsesStream, aX as OpenAIResponsesStreamError, l as OpenAIResponsesStreamEvent, aY as OpenAIResponsesUsage, aZ as OpenAISpeechRequest, a_ as OpenAIStreamOptions, a$ as OpenAITextContentPart, b0 as OpenAITool, b1 as OpenAIToolCall, b2 as OpenAIToolCallDelta, b3 as OpenAIUsage, b4 as SystemOneConfidence, b5 as SystemOneProbabilities } from './anthropic-
|
|
6
|
+
import { R as RequestRunner, S as SystemOneChoiceAnswer, o as SystemOneNoulAnswer, p as SystemOneScoreAnswer, q as SystemOneChoiceQuestion, r as SystemOneNoulQuestion, s as SystemOneScoreQuestion, t as SystemOneRequest$1, u as SystemOneResponse$1, v as SystemOneContent, N as NativeApi, w as OpenAICompatClient, x as AnthropicCompatClient } from './anthropic-DnsaK9Ui.cjs';
|
|
7
|
+
export { y as AnthropicCacheControl, z as AnthropicContentBlock, B as AnthropicImageContentBlock, C as AnthropicMessage, n as AnthropicMessageStreamEvent, A as AnthropicMessagesRequest, m as AnthropicMessagesResponse, D as AnthropicMessagesStream, E as AnthropicMetadata, F as AnthropicOutputConfig, G as AnthropicRedactedThinkingContentBlock, H as AnthropicSystem, I as AnthropicSystemTextBlock, J as AnthropicTextContentBlock, K as AnthropicThinkingConfig, L as AnthropicThinkingContentBlock, M as AnthropicTool, P as AnthropicToolChoice, Q as AnthropicToolResultContentBlock, T as AnthropicToolUseContentBlock, U as AnthropicUnknownStreamEvent, V as OllamaAnthropicContentBlock, W as OllamaAnthropicMessage, X as OllamaAnthropicMessagesRequest, Y as OllamaAnthropicSystem, Z as OllamaAnthropicSystemTextBlock, _ as OllamaAnthropicTextContentBlock, $ as OllamaAnthropicThinkingConfig, a0 as OllamaAnthropicTool, a1 as OllamaAnthropicToolResultContentBlock, a2 as OllamaOpenAIChatCompletionRequest, a3 as OllamaOpenAIChatContentPart, a4 as OllamaOpenAIChatMessage, a5 as OllamaOpenAICompletionRequest, a6 as OllamaOpenAIEmbeddingRequest, a7 as OllamaOpenAIImageDataUrl, a8 as OllamaOpenAIReasoningEffort, a9 as OllamaOpenAIResponsesRequest, aa as OllamaOpenAISpeechRequest, ab as OpenAIChatCompletionChoice, b as OpenAIChatCompletionChunk, ac as OpenAIChatCompletionChunkChoice, ad as OpenAIChatCompletionDelta, O as OpenAIChatCompletionRequest, a as OpenAIChatCompletionResponse, ae as OpenAIChatCompletionStream, af as OpenAICompletionChoice, e as OpenAICompletionChunk, c as OpenAICompletionRequest, d as OpenAICompletionResponse, ag as OpenAICompletionStream, ah as OpenAIContentPart, ai as OpenAIEmbeddingInput, aj as OpenAIEmbeddingItem, f as OpenAIEmbeddingRequest, g as OpenAIEmbeddingResponse, ak as OpenAIFunctionDefinition, al as OpenAIImageUrlContentPart, h as OpenAIListModelsResponse, am as OpenAIMessage, i as OpenAIModelItem, an as OpenAIReasoningEffort, ao as OpenAIResponseFormat, ap as OpenAIResponsesCompletedEvent, aq as OpenAIResponsesContentPartAddedEvent, ar as OpenAIResponsesContentPartDoneEvent, as as OpenAIResponsesCreatedEvent, at as OpenAIResponsesError, au as OpenAIResponsesEventBase, av as OpenAIResponsesFailedEvent, aw as OpenAIResponsesFunctionCallArgumentsDeltaEvent, ax as OpenAIResponsesFunctionCallArgumentsDoneEvent, ay as OpenAIResponsesInProgressEvent, az as OpenAIResponsesIncompleteDetails, aA as OpenAIResponsesIncompleteEvent, aB as OpenAIResponsesOutputContent, aC as OpenAIResponsesOutputFunctionCall, aD as OpenAIResponsesOutputItem, aE as OpenAIResponsesOutputItemAddedEvent, aF as OpenAIResponsesOutputItemDoneEvent, aG as OpenAIResponsesOutputMessage, aH as OpenAIResponsesOutputReasoning, aI as OpenAIResponsesOutputRefusal, aJ as OpenAIResponsesOutputTextContent, aK as OpenAIResponsesOutputTextDeltaEvent, aL as OpenAIResponsesOutputTextDoneEvent, aM as OpenAIResponsesQueuedEvent, aN as OpenAIResponsesReasoningSummaryPartAddedEvent, aO as OpenAIResponsesReasoningSummaryPartDoneEvent, aP as OpenAIResponsesReasoningSummaryTextDeltaEvent, aQ as OpenAIResponsesReasoningSummaryTextDoneEvent, aR as OpenAIResponsesReasoningTextDeltaEvent, aS as OpenAIResponsesReasoningTextDoneEvent, aT as OpenAIResponsesRefusalDeltaEvent, aU as OpenAIResponsesRefusalDoneEvent, j as OpenAIResponsesRequest, k as OpenAIResponsesResponse, aV as OpenAIResponsesStatus, aW as OpenAIResponsesStream, aX as OpenAIResponsesStreamError, l as OpenAIResponsesStreamEvent, aY as OpenAIResponsesUsage, aZ as OpenAISpeechRequest, a_ as OpenAIStreamOptions, a$ as OpenAITextContentPart, b0 as OpenAITool, b1 as OpenAIToolCall, b2 as OpenAIToolCallDelta, b3 as OpenAIUsage, b4 as SystemOneConfidence, b5 as SystemOneProbabilities } from './anthropic-DnsaK9Ui.cjs';
|
|
8
8
|
import { T as ToolHandler, a as Tool, A as AnyTool, b as ToolRegistry, c as ToolExecutionResult } from './compose-Bjpsu3Y1.cjs';
|
|
9
9
|
export { d as AppliedSkillResult, e as ApplySkillOptions, P as ParsedFrontmatter, S as Skill, f as SkillFrontmatter, g as SkillSummary, h as ToolExecutionContext, i as ToolExecutionFailure, j as ToolExecutionSuccess, k as ToolRegistryOptions, l as applySkill, p as parseFrontmatter } from './compose-Bjpsu3Y1.cjs';
|
|
10
10
|
import { M as McpClientLike, a as McpToolDescriptor, b as McpTask, c as McpCallToolResult } from './types-CI-gM2u5.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { T as ThinkingMetadata, M as ModelResponse, R as RequestCancellationOptions, I as ImageResolutionPolicy, S as ShowRequestOptions, a as ShowResponse, P as PullRequestOptions, b as ProgressResponse, c as PushRequestOptions, C as CreateRequestOptions, D as DeleteRequestOptions, d as StatusResponse, e as CopyRequestOptions, f as PsResponse, V as VersionResponse, g as ToolParameters, h as ThinkValue, i as ToolCall, j as ChatRequestOptions, k as ModelOptions, l as ToolDefinition, F as FormatOption, m as ChatResponse, n as Message, G as GenerateRequestOptions, o as GenerateResponse, E as EmbedRequestOptions, p as EmbedResponse, q as EmbeddingsRequestOptions, r as EmbeddingsResponse, W as WebSearchRequestOptions, s as WebSearchResponse, t as WebFetchRequestOptions, u as WebFetchResponse, U as UsageRequestOptions, B as BalanceRequestOptions, v as PingResult, w as VisionInput } from './types-CH3pdrak.js';
|
|
2
2
|
export { x as ImageAddress, y as ImageFetchLike, L as ListResponse, z as Logprob, A as LogprobToken, H as ModelDetails, J as Role, K as ToolCallFunction, N as ToolFunctionDefinition, O as ToolProperty, Q as UsageGroupBy, X as UsageRange, Y as UsageScope, Z as WebSearchResult, _ as imageStringNeedsResolution, $ as resolveImageInput } from './types-CH3pdrak.js';
|
|
3
|
-
import { H as HttpClient, F as FetchLike, M as Middleware, L as Logger, R as RequestLifecycleHook, c as OllamaStreamEvent, A as AbortableAsyncIterable, d as OllamaStreamEventType, P as ProgressStreamResult, B as BinaryBody, O as OllamaRuntime, C as ChatStreamResult, G as GenerateStreamResult, e as RawUsageSource, T as TokenUsage } from './runtime-
|
|
4
|
-
export { D as DoneEvent, E as ErrorEvent, f as HttpBody, g as HttpClientOptions, h as HttpRequestOptions, i as LifecycleErrorEvent, j as LifecycleRetryEvent, k as LifecycleStartEvent, l as LifecycleSuccessEvent, m as LogFn, n as MessageEvent, o as MiddlewareContext, N as NANOS_PER_MS, p as NANOS_PER_SECOND, q as NETWORK_ERROR_CODES, r as NOOP_LOGGER, s as NextFunction, t as OllamaAbortError, u as OllamaAgentMaxIterationsError, v as OllamaAgentMaxToolCallsError, w as OllamaAgentToolLoopError, x as OllamaAuthError, y as OllamaBadGatewayError, z as OllamaClientError, J as OllamaClientErrorOptions, K as OllamaCloudModelVersionError, Q as OllamaErrorRequestContext, U as OllamaErrorResponseContext, V as OllamaGenericClientError, W as OllamaIncompatibleModelError, X as OllamaMcpError, Y as OllamaModelRoutingError, Z as OllamaNetworkError, _ as OllamaNotFoundError, $ as OllamaOverloadedError, a0 as OllamaPaymentRequiredError, a1 as OllamaQuotaExceededError, a2 as OllamaRateLimitError, a3 as OllamaRequestTooLargeError, a4 as OllamaRequestValidationError, a5 as OllamaResponseValidationError, a6 as OllamaServerError, a7 as OllamaServerVersionUnknownError, a8 as OllamaSkillInvalidError, a9 as OllamaSkillNotFoundError, aa as OllamaStreamError, ab as OllamaTimeoutError, ac as OllamaToolTimeoutError, ad as OllamaToolValidationError, ae as OllamaUnsupportedCapabilityError, af as RequestContext, ag as RequestLifecycleEvent, ah as ResponseContext, ai as SseEvent, aj as ThinkingEvent, ak as TokenEvent, al as ToolCallEvent, am as composeMiddleware, an as createConsoleLogger, ao as extractUsage, ap as isNetworkLevelError, aq as mapError, ar as parseRetryAfterMs, as as parseSseStream } from './runtime-
|
|
3
|
+
import { H as HttpClient, F as FetchLike, M as Middleware, L as Logger, R as RequestLifecycleHook, c as OllamaStreamEvent, A as AbortableAsyncIterable, d as OllamaStreamEventType, P as ProgressStreamResult, B as BinaryBody, O as OllamaRuntime, C as ChatStreamResult, G as GenerateStreamResult, e as RawUsageSource, T as TokenUsage } from './runtime-DQRudJFP.js';
|
|
4
|
+
export { D as DoneEvent, E as ErrorEvent, f as HttpBody, g as HttpClientOptions, h as HttpRequestOptions, i as LifecycleErrorEvent, j as LifecycleRetryEvent, k as LifecycleStartEvent, l as LifecycleSuccessEvent, m as LogFn, n as MessageEvent, o as MiddlewareContext, N as NANOS_PER_MS, p as NANOS_PER_SECOND, q as NETWORK_ERROR_CODES, r as NOOP_LOGGER, s as NextFunction, t as OllamaAbortError, u as OllamaAgentMaxIterationsError, v as OllamaAgentMaxToolCallsError, w as OllamaAgentToolLoopError, x as OllamaAuthError, y as OllamaBadGatewayError, z as OllamaClientError, J as OllamaClientErrorOptions, K as OllamaCloudModelVersionError, Q as OllamaErrorRequestContext, U as OllamaErrorResponseContext, V as OllamaGenericClientError, W as OllamaIncompatibleModelError, X as OllamaMcpError, Y as OllamaModelRoutingError, Z as OllamaNetworkError, _ as OllamaNotFoundError, $ as OllamaOverloadedError, a0 as OllamaPaymentRequiredError, a1 as OllamaQuotaExceededError, a2 as OllamaRateLimitError, a3 as OllamaRequestTooLargeError, a4 as OllamaRequestValidationError, a5 as OllamaResponseValidationError, a6 as OllamaServerError, a7 as OllamaServerVersionUnknownError, a8 as OllamaSkillInvalidError, a9 as OllamaSkillNotFoundError, aa as OllamaStreamError, ab as OllamaTimeoutError, ac as OllamaToolTimeoutError, ad as OllamaToolValidationError, ae as OllamaUnsupportedCapabilityError, af as RequestContext, ag as RequestLifecycleEvent, ah as ResponseContext, ai as SseEvent, aj as ThinkingEvent, ak as TokenEvent, al as ToolCallEvent, am as composeMiddleware, an as createConsoleLogger, ao as extractUsage, ap as isNetworkLevelError, aq as mapError, ar as parseRetryAfterMs, as as parseSseStream } from './runtime-DQRudJFP.js';
|
|
5
5
|
import { z } from 'zod';
|
|
6
|
-
import { R as RequestRunner, S as SystemOneChoiceAnswer, o as SystemOneNoulAnswer, p as SystemOneScoreAnswer, q as SystemOneChoiceQuestion, r as SystemOneNoulQuestion, s as SystemOneScoreQuestion, t as SystemOneRequest$1, u as SystemOneResponse$1, v as SystemOneContent, N as NativeApi, w as OpenAICompatClient, x as AnthropicCompatClient } from './anthropic-
|
|
7
|
-
export { y as AnthropicCacheControl, z as AnthropicContentBlock, B as AnthropicImageContentBlock, C as AnthropicMessage, n as AnthropicMessageStreamEvent, A as AnthropicMessagesRequest, m as AnthropicMessagesResponse, D as AnthropicMessagesStream, E as AnthropicMetadata, F as AnthropicOutputConfig, G as AnthropicRedactedThinkingContentBlock, H as AnthropicSystem, I as AnthropicSystemTextBlock, J as AnthropicTextContentBlock, K as AnthropicThinkingConfig, L as AnthropicThinkingContentBlock, M as AnthropicTool, P as AnthropicToolChoice, Q as AnthropicToolResultContentBlock, T as AnthropicToolUseContentBlock, U as AnthropicUnknownStreamEvent, V as OllamaAnthropicContentBlock, W as OllamaAnthropicMessage, X as OllamaAnthropicMessagesRequest, Y as OllamaAnthropicSystem, Z as OllamaAnthropicSystemTextBlock, _ as OllamaAnthropicTextContentBlock, $ as OllamaAnthropicThinkingConfig, a0 as OllamaAnthropicTool, a1 as OllamaAnthropicToolResultContentBlock, a2 as OllamaOpenAIChatCompletionRequest, a3 as OllamaOpenAIChatContentPart, a4 as OllamaOpenAIChatMessage, a5 as OllamaOpenAICompletionRequest, a6 as OllamaOpenAIEmbeddingRequest, a7 as OllamaOpenAIImageDataUrl, a8 as OllamaOpenAIReasoningEffort, a9 as OllamaOpenAIResponsesRequest, aa as OllamaOpenAISpeechRequest, ab as OpenAIChatCompletionChoice, b as OpenAIChatCompletionChunk, ac as OpenAIChatCompletionChunkChoice, ad as OpenAIChatCompletionDelta, O as OpenAIChatCompletionRequest, a as OpenAIChatCompletionResponse, ae as OpenAIChatCompletionStream, af as OpenAICompletionChoice, e as OpenAICompletionChunk, c as OpenAICompletionRequest, d as OpenAICompletionResponse, ag as OpenAICompletionStream, ah as OpenAIContentPart, ai as OpenAIEmbeddingInput, aj as OpenAIEmbeddingItem, f as OpenAIEmbeddingRequest, g as OpenAIEmbeddingResponse, ak as OpenAIFunctionDefinition, al as OpenAIImageUrlContentPart, h as OpenAIListModelsResponse, am as OpenAIMessage, i as OpenAIModelItem, an as OpenAIReasoningEffort, ao as OpenAIResponseFormat, ap as OpenAIResponsesCompletedEvent, aq as OpenAIResponsesContentPartAddedEvent, ar as OpenAIResponsesContentPartDoneEvent, as as OpenAIResponsesCreatedEvent, at as OpenAIResponsesError, au as OpenAIResponsesEventBase, av as OpenAIResponsesFailedEvent, aw as OpenAIResponsesFunctionCallArgumentsDeltaEvent, ax as OpenAIResponsesFunctionCallArgumentsDoneEvent, ay as OpenAIResponsesInProgressEvent, az as OpenAIResponsesIncompleteDetails, aA as OpenAIResponsesIncompleteEvent, aB as OpenAIResponsesOutputContent, aC as OpenAIResponsesOutputFunctionCall, aD as OpenAIResponsesOutputItem, aE as OpenAIResponsesOutputItemAddedEvent, aF as OpenAIResponsesOutputItemDoneEvent, aG as OpenAIResponsesOutputMessage, aH as OpenAIResponsesOutputReasoning, aI as OpenAIResponsesOutputRefusal, aJ as OpenAIResponsesOutputTextContent, aK as OpenAIResponsesOutputTextDeltaEvent, aL as OpenAIResponsesOutputTextDoneEvent, aM as OpenAIResponsesQueuedEvent, aN as OpenAIResponsesReasoningSummaryPartAddedEvent, aO as OpenAIResponsesReasoningSummaryPartDoneEvent, aP as OpenAIResponsesReasoningSummaryTextDeltaEvent, aQ as OpenAIResponsesReasoningSummaryTextDoneEvent, aR as OpenAIResponsesReasoningTextDeltaEvent, aS as OpenAIResponsesReasoningTextDoneEvent, aT as OpenAIResponsesRefusalDeltaEvent, aU as OpenAIResponsesRefusalDoneEvent, j as OpenAIResponsesRequest, k as OpenAIResponsesResponse, aV as OpenAIResponsesStatus, aW as OpenAIResponsesStream, aX as OpenAIResponsesStreamError, l as OpenAIResponsesStreamEvent, aY as OpenAIResponsesUsage, aZ as OpenAISpeechRequest, a_ as OpenAIStreamOptions, a$ as OpenAITextContentPart, b0 as OpenAITool, b1 as OpenAIToolCall, b2 as OpenAIToolCallDelta, b3 as OpenAIUsage, b4 as SystemOneConfidence, b5 as SystemOneProbabilities } from './anthropic-
|
|
6
|
+
import { R as RequestRunner, S as SystemOneChoiceAnswer, o as SystemOneNoulAnswer, p as SystemOneScoreAnswer, q as SystemOneChoiceQuestion, r as SystemOneNoulQuestion, s as SystemOneScoreQuestion, t as SystemOneRequest$1, u as SystemOneResponse$1, v as SystemOneContent, N as NativeApi, w as OpenAICompatClient, x as AnthropicCompatClient } from './anthropic-DA9flTv_.js';
|
|
7
|
+
export { y as AnthropicCacheControl, z as AnthropicContentBlock, B as AnthropicImageContentBlock, C as AnthropicMessage, n as AnthropicMessageStreamEvent, A as AnthropicMessagesRequest, m as AnthropicMessagesResponse, D as AnthropicMessagesStream, E as AnthropicMetadata, F as AnthropicOutputConfig, G as AnthropicRedactedThinkingContentBlock, H as AnthropicSystem, I as AnthropicSystemTextBlock, J as AnthropicTextContentBlock, K as AnthropicThinkingConfig, L as AnthropicThinkingContentBlock, M as AnthropicTool, P as AnthropicToolChoice, Q as AnthropicToolResultContentBlock, T as AnthropicToolUseContentBlock, U as AnthropicUnknownStreamEvent, V as OllamaAnthropicContentBlock, W as OllamaAnthropicMessage, X as OllamaAnthropicMessagesRequest, Y as OllamaAnthropicSystem, Z as OllamaAnthropicSystemTextBlock, _ as OllamaAnthropicTextContentBlock, $ as OllamaAnthropicThinkingConfig, a0 as OllamaAnthropicTool, a1 as OllamaAnthropicToolResultContentBlock, a2 as OllamaOpenAIChatCompletionRequest, a3 as OllamaOpenAIChatContentPart, a4 as OllamaOpenAIChatMessage, a5 as OllamaOpenAICompletionRequest, a6 as OllamaOpenAIEmbeddingRequest, a7 as OllamaOpenAIImageDataUrl, a8 as OllamaOpenAIReasoningEffort, a9 as OllamaOpenAIResponsesRequest, aa as OllamaOpenAISpeechRequest, ab as OpenAIChatCompletionChoice, b as OpenAIChatCompletionChunk, ac as OpenAIChatCompletionChunkChoice, ad as OpenAIChatCompletionDelta, O as OpenAIChatCompletionRequest, a as OpenAIChatCompletionResponse, ae as OpenAIChatCompletionStream, af as OpenAICompletionChoice, e as OpenAICompletionChunk, c as OpenAICompletionRequest, d as OpenAICompletionResponse, ag as OpenAICompletionStream, ah as OpenAIContentPart, ai as OpenAIEmbeddingInput, aj as OpenAIEmbeddingItem, f as OpenAIEmbeddingRequest, g as OpenAIEmbeddingResponse, ak as OpenAIFunctionDefinition, al as OpenAIImageUrlContentPart, h as OpenAIListModelsResponse, am as OpenAIMessage, i as OpenAIModelItem, an as OpenAIReasoningEffort, ao as OpenAIResponseFormat, ap as OpenAIResponsesCompletedEvent, aq as OpenAIResponsesContentPartAddedEvent, ar as OpenAIResponsesContentPartDoneEvent, as as OpenAIResponsesCreatedEvent, at as OpenAIResponsesError, au as OpenAIResponsesEventBase, av as OpenAIResponsesFailedEvent, aw as OpenAIResponsesFunctionCallArgumentsDeltaEvent, ax as OpenAIResponsesFunctionCallArgumentsDoneEvent, ay as OpenAIResponsesInProgressEvent, az as OpenAIResponsesIncompleteDetails, aA as OpenAIResponsesIncompleteEvent, aB as OpenAIResponsesOutputContent, aC as OpenAIResponsesOutputFunctionCall, aD as OpenAIResponsesOutputItem, aE as OpenAIResponsesOutputItemAddedEvent, aF as OpenAIResponsesOutputItemDoneEvent, aG as OpenAIResponsesOutputMessage, aH as OpenAIResponsesOutputReasoning, aI as OpenAIResponsesOutputRefusal, aJ as OpenAIResponsesOutputTextContent, aK as OpenAIResponsesOutputTextDeltaEvent, aL as OpenAIResponsesOutputTextDoneEvent, aM as OpenAIResponsesQueuedEvent, aN as OpenAIResponsesReasoningSummaryPartAddedEvent, aO as OpenAIResponsesReasoningSummaryPartDoneEvent, aP as OpenAIResponsesReasoningSummaryTextDeltaEvent, aQ as OpenAIResponsesReasoningSummaryTextDoneEvent, aR as OpenAIResponsesReasoningTextDeltaEvent, aS as OpenAIResponsesReasoningTextDoneEvent, aT as OpenAIResponsesRefusalDeltaEvent, aU as OpenAIResponsesRefusalDoneEvent, j as OpenAIResponsesRequest, k as OpenAIResponsesResponse, aV as OpenAIResponsesStatus, aW as OpenAIResponsesStream, aX as OpenAIResponsesStreamError, l as OpenAIResponsesStreamEvent, aY as OpenAIResponsesUsage, aZ as OpenAISpeechRequest, a_ as OpenAIStreamOptions, a$ as OpenAITextContentPart, b0 as OpenAITool, b1 as OpenAIToolCall, b2 as OpenAIToolCallDelta, b3 as OpenAIUsage, b4 as SystemOneConfidence, b5 as SystemOneProbabilities } from './anthropic-DA9flTv_.js';
|
|
8
8
|
import { T as ToolHandler, a as Tool, A as AnyTool, b as ToolRegistry, c as ToolExecutionResult } from './compose-DxAQ2z26.js';
|
|
9
9
|
export { d as AppliedSkillResult, e as ApplySkillOptions, P as ParsedFrontmatter, S as Skill, f as SkillFrontmatter, g as SkillSummary, h as ToolExecutionContext, i as ToolExecutionFailure, j as ToolExecutionSuccess, k as ToolRegistryOptions, l as applySkill, p as parseFrontmatter } from './compose-DxAQ2z26.js';
|
|
10
10
|
import { M as McpClientLike, a as McpToolDescriptor, b as McpTask, c as McpCallToolResult } from './types-CI-gM2u5.js';
|
package/dist/index.js
CHANGED
|
@@ -1352,34 +1352,32 @@ async function* parseSseStream(stream) {
|
|
|
1352
1352
|
}
|
|
1353
1353
|
return void 0;
|
|
1354
1354
|
};
|
|
1355
|
-
|
|
1356
|
-
while (true) {
|
|
1357
|
-
const { done, value } = await reader.read();
|
|
1358
|
-
if (done) break;
|
|
1359
|
-
buffer += decoder.decode(value, { stream: true });
|
|
1355
|
+
function* drainLines(endOfStream) {
|
|
1360
1356
|
while (true) {
|
|
1361
1357
|
const lf = buffer.indexOf("\n");
|
|
1362
1358
|
const cr = buffer.indexOf("\r");
|
|
1363
|
-
if (lf === -1 && cr === -1)
|
|
1364
|
-
if (
|
|
1359
|
+
if (lf === -1 && cr === -1) return;
|
|
1360
|
+
if (!endOfStream && lf === -1 && cr === buffer.length - 1) return;
|
|
1365
1361
|
const lineEnd = lf === -1 ? cr : cr === -1 ? lf : Math.min(lf, cr);
|
|
1366
|
-
|
|
1367
|
-
if (buffer[lineEnd] === "\r" && buffer[lineEnd + 1] === "\n") {
|
|
1368
|
-
separatorLength = 2;
|
|
1369
|
-
}
|
|
1362
|
+
const separatorLength = buffer[lineEnd] === "\r" && buffer[lineEnd + 1] === "\n" ? 2 : 1;
|
|
1370
1363
|
const line = buffer.slice(0, lineEnd);
|
|
1371
1364
|
buffer = buffer.slice(lineEnd + separatorLength);
|
|
1372
1365
|
const event = processLine(line);
|
|
1373
1366
|
if (event) yield event;
|
|
1374
1367
|
}
|
|
1375
1368
|
}
|
|
1369
|
+
const _reader = __using(_stack, disposableReader(reader), true);
|
|
1370
|
+
while (true) {
|
|
1371
|
+
const { done, value } = await reader.read();
|
|
1372
|
+
if (done) break;
|
|
1373
|
+
buffer += decoder.decode(value, { stream: true });
|
|
1374
|
+
yield* drainLines(false);
|
|
1375
|
+
}
|
|
1376
1376
|
buffer += decoder.decode();
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1377
|
+
yield* drainLines(true);
|
|
1378
|
+
if (data.length > 0 || buffer.length > 0) {
|
|
1379
|
+
throw new OllamaStreamError("SSE stream ended mid-event; the incomplete event was discarded");
|
|
1380
1380
|
}
|
|
1381
|
-
const terminal = dispatch(eventType, data, lastEventId, retry);
|
|
1382
|
-
if (terminal) yield terminal;
|
|
1383
1381
|
} catch (_) {
|
|
1384
1382
|
var _error = _, _hasError = true;
|
|
1385
1383
|
} finally {
|
|
@@ -1536,6 +1534,52 @@ function retryAfterHeaderFrom(response) {
|
|
|
1536
1534
|
return void 0;
|
|
1537
1535
|
}
|
|
1538
1536
|
}
|
|
1537
|
+
function parseJsonOrText(raw) {
|
|
1538
|
+
try {
|
|
1539
|
+
return JSON.parse(raw);
|
|
1540
|
+
} catch {
|
|
1541
|
+
return raw;
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
function isAbortLike(error) {
|
|
1545
|
+
return typeof error === "object" && error !== null && error.name === "AbortError";
|
|
1546
|
+
}
|
|
1547
|
+
async function readErrorBody(response) {
|
|
1548
|
+
try {
|
|
1549
|
+
if (typeof response.text === "function") {
|
|
1550
|
+
const raw = await response.text();
|
|
1551
|
+
return { raw, parsed: parseJsonOrText(raw) };
|
|
1552
|
+
}
|
|
1553
|
+
if (typeof response.json === "function") {
|
|
1554
|
+
const parsed = await response.json();
|
|
1555
|
+
return { raw: JSON.stringify(parsed) ?? "", parsed };
|
|
1556
|
+
}
|
|
1557
|
+
} catch (err) {
|
|
1558
|
+
if (isAbortLike(err)) throw err;
|
|
1559
|
+
}
|
|
1560
|
+
return { raw: "", parsed: "" };
|
|
1561
|
+
}
|
|
1562
|
+
function bridgeAbortSignal(signal) {
|
|
1563
|
+
const controller = new AbortController();
|
|
1564
|
+
if (signal === void 0) {
|
|
1565
|
+
return { controller, detach: () => void 0 };
|
|
1566
|
+
}
|
|
1567
|
+
if (signal.aborted) {
|
|
1568
|
+
controller.abort(signal.reason);
|
|
1569
|
+
return { controller, detach: () => void 0 };
|
|
1570
|
+
}
|
|
1571
|
+
const onAbort = () => controller.abort(signal.reason);
|
|
1572
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
1573
|
+
let attached = true;
|
|
1574
|
+
return {
|
|
1575
|
+
controller,
|
|
1576
|
+
detach: () => {
|
|
1577
|
+
if (!attached) return;
|
|
1578
|
+
attached = false;
|
|
1579
|
+
signal.removeEventListener("abort", onAbort);
|
|
1580
|
+
}
|
|
1581
|
+
};
|
|
1582
|
+
}
|
|
1539
1583
|
var HttpClient = class {
|
|
1540
1584
|
baseUrl;
|
|
1541
1585
|
apiKey;
|
|
@@ -1705,12 +1749,7 @@ var HttpClient = class {
|
|
|
1705
1749
|
});
|
|
1706
1750
|
span?.setAttribute(ATTR_HTTP_RESPONSE_STATUS_CODE, response.status);
|
|
1707
1751
|
if (!response.ok) {
|
|
1708
|
-
|
|
1709
|
-
try {
|
|
1710
|
-
errorBody = await response.json();
|
|
1711
|
-
} catch {
|
|
1712
|
-
errorBody = await response.text();
|
|
1713
|
-
}
|
|
1752
|
+
const { parsed: errorBody } = await readErrorBody(response);
|
|
1714
1753
|
const message = typeof errorBody === "object" && errorBody !== null && "error" in errorBody ? String(errorBody.error) : `HTTP ${response.status} ${response.statusText}`;
|
|
1715
1754
|
throw mapError(new Error(message), {
|
|
1716
1755
|
request: { method, url },
|
|
@@ -1758,29 +1797,18 @@ var HttpClient = class {
|
|
|
1758
1797
|
`${method} ${routeTemplate(options.path)}`,
|
|
1759
1798
|
httpSpanAttributes(method, url),
|
|
1760
1799
|
async (span) => {
|
|
1800
|
+
const bridge = bridgeAbortSignal(options.signal);
|
|
1761
1801
|
try {
|
|
1762
|
-
const controller = new AbortController();
|
|
1763
|
-
const removeAbortListener = options.signal !== void 0 ? (() => {
|
|
1764
|
-
if (options.signal.aborted) {
|
|
1765
|
-
controller.abort(options.signal.reason);
|
|
1766
|
-
} else {
|
|
1767
|
-
const onAbort = () => controller.abort(options.signal?.reason);
|
|
1768
|
-
options.signal.addEventListener("abort", onAbort, { once: true });
|
|
1769
|
-
return () => options.signal?.removeEventListener("abort", onAbort);
|
|
1770
|
-
}
|
|
1771
|
-
return void 0;
|
|
1772
|
-
})() : void 0;
|
|
1773
1802
|
const response = await this.fetchWithMiddleware({
|
|
1774
1803
|
url,
|
|
1775
1804
|
method,
|
|
1776
1805
|
headers,
|
|
1777
1806
|
...options.body !== void 0 ? { body: JSON.stringify(options.body) } : {},
|
|
1778
|
-
signal: controller.signal
|
|
1807
|
+
signal: bridge.controller.signal
|
|
1779
1808
|
});
|
|
1780
1809
|
span?.setAttribute(ATTR_HTTP_RESPONSE_STATUS_CODE, response.status);
|
|
1781
1810
|
if (!response.ok) {
|
|
1782
|
-
|
|
1783
|
-
const errorText = await response.text();
|
|
1811
|
+
const errorText = (await readErrorBody(response)).raw;
|
|
1784
1812
|
throw mapError(new Error(errorText || `HTTP ${response.status}`), {
|
|
1785
1813
|
request: { method, url },
|
|
1786
1814
|
response: {
|
|
@@ -1791,16 +1819,16 @@ var HttpClient = class {
|
|
|
1791
1819
|
});
|
|
1792
1820
|
}
|
|
1793
1821
|
if (!response.body) {
|
|
1794
|
-
removeAbortListener?.();
|
|
1795
1822
|
throw mapError(new Error("Response body is null, cannot stream SSE"), {
|
|
1796
1823
|
request: { method, url }
|
|
1797
1824
|
});
|
|
1798
1825
|
}
|
|
1826
|
+
const body = response.body;
|
|
1799
1827
|
const stream = (async function* () {
|
|
1800
1828
|
try {
|
|
1801
|
-
yield* parseSseStream(
|
|
1829
|
+
yield* parseSseStream(body);
|
|
1802
1830
|
} finally {
|
|
1803
|
-
|
|
1831
|
+
bridge.detach();
|
|
1804
1832
|
}
|
|
1805
1833
|
})();
|
|
1806
1834
|
return {
|
|
@@ -1808,11 +1836,12 @@ var HttpClient = class {
|
|
|
1808
1836
|
return stream[Symbol.asyncIterator]();
|
|
1809
1837
|
},
|
|
1810
1838
|
abort: () => {
|
|
1811
|
-
|
|
1812
|
-
controller.abort();
|
|
1839
|
+
bridge.detach();
|
|
1840
|
+
bridge.controller.abort();
|
|
1813
1841
|
}
|
|
1814
1842
|
};
|
|
1815
1843
|
} catch (err) {
|
|
1844
|
+
bridge.detach();
|
|
1816
1845
|
throw mapError(err, { request: { method, url } });
|
|
1817
1846
|
}
|
|
1818
1847
|
}
|
|
@@ -1826,29 +1855,18 @@ var HttpClient = class {
|
|
|
1826
1855
|
`${method} ${routeTemplate(options.path)}`,
|
|
1827
1856
|
httpSpanAttributes(method, url),
|
|
1828
1857
|
async (span) => {
|
|
1858
|
+
const bridge = bridgeAbortSignal(options.signal);
|
|
1829
1859
|
try {
|
|
1830
|
-
const controller = new AbortController();
|
|
1831
|
-
const removeAbortListener = options.signal !== void 0 ? (() => {
|
|
1832
|
-
if (options.signal.aborted) {
|
|
1833
|
-
controller.abort(options.signal.reason);
|
|
1834
|
-
} else {
|
|
1835
|
-
const onAbort = () => controller.abort(options.signal?.reason);
|
|
1836
|
-
options.signal.addEventListener("abort", onAbort, { once: true });
|
|
1837
|
-
return () => options.signal?.removeEventListener("abort", onAbort);
|
|
1838
|
-
}
|
|
1839
|
-
return void 0;
|
|
1840
|
-
})() : void 0;
|
|
1841
1860
|
const response = await this.fetchWithMiddleware({
|
|
1842
1861
|
url,
|
|
1843
1862
|
method,
|
|
1844
1863
|
headers,
|
|
1845
1864
|
...options.body !== void 0 ? { body: JSON.stringify(options.body) } : {},
|
|
1846
|
-
signal: controller.signal
|
|
1865
|
+
signal: bridge.controller.signal
|
|
1847
1866
|
});
|
|
1848
1867
|
span?.setAttribute(ATTR_HTTP_RESPONSE_STATUS_CODE, response.status);
|
|
1849
1868
|
if (!response.ok) {
|
|
1850
|
-
|
|
1851
|
-
const errorText = await response.text();
|
|
1869
|
+
const errorText = (await readErrorBody(response)).raw;
|
|
1852
1870
|
throw mapError(new Error(errorText || `HTTP ${response.status}`), {
|
|
1853
1871
|
request: { method, url },
|
|
1854
1872
|
response: {
|
|
@@ -1859,7 +1877,6 @@ var HttpClient = class {
|
|
|
1859
1877
|
});
|
|
1860
1878
|
}
|
|
1861
1879
|
if (!response.body) {
|
|
1862
|
-
removeAbortListener?.();
|
|
1863
1880
|
throw mapError(new Error("Response body is null, cannot stream"), {
|
|
1864
1881
|
request: { method, url }
|
|
1865
1882
|
});
|
|
@@ -1871,17 +1888,18 @@ var HttpClient = class {
|
|
|
1871
1888
|
try {
|
|
1872
1889
|
yield* stream;
|
|
1873
1890
|
} finally {
|
|
1874
|
-
|
|
1891
|
+
bridge.detach();
|
|
1875
1892
|
}
|
|
1876
1893
|
})()[Symbol.asyncIterator]();
|
|
1877
1894
|
},
|
|
1878
1895
|
abort: () => {
|
|
1879
|
-
|
|
1880
|
-
controller.abort();
|
|
1896
|
+
bridge.detach();
|
|
1897
|
+
bridge.controller.abort();
|
|
1881
1898
|
}
|
|
1882
1899
|
};
|
|
1883
1900
|
return abortable;
|
|
1884
1901
|
} catch (err) {
|
|
1902
|
+
bridge.detach();
|
|
1885
1903
|
throw mapError(err, { request: { method, url } });
|
|
1886
1904
|
}
|
|
1887
1905
|
}
|
|
@@ -3488,10 +3506,12 @@ var OpenAIChatCompletionStream = class {
|
|
|
3488
3506
|
resolveFinal;
|
|
3489
3507
|
rejectFinal;
|
|
3490
3508
|
removeAbortListener;
|
|
3509
|
+
abortRequested = false;
|
|
3491
3510
|
get finalResult() {
|
|
3492
3511
|
return this.finalResultPromise;
|
|
3493
3512
|
}
|
|
3494
3513
|
abort() {
|
|
3514
|
+
this.abortRequested = true;
|
|
3495
3515
|
this.removeAbortListener?.();
|
|
3496
3516
|
this.removeAbortListener = void 0;
|
|
3497
3517
|
this.source.abort?.();
|
|
@@ -3505,9 +3525,13 @@ var OpenAIChatCompletionStream = class {
|
|
|
3505
3525
|
let systemFingerprint;
|
|
3506
3526
|
let usage;
|
|
3507
3527
|
let completed = false;
|
|
3528
|
+
let sawDone = false;
|
|
3508
3529
|
try {
|
|
3509
3530
|
for await (const event of this.source) {
|
|
3510
|
-
if (event.data === "[DONE]")
|
|
3531
|
+
if (event.data === "[DONE]") {
|
|
3532
|
+
sawDone = true;
|
|
3533
|
+
break;
|
|
3534
|
+
}
|
|
3511
3535
|
let chunk;
|
|
3512
3536
|
try {
|
|
3513
3537
|
chunk = JSON.parse(event.data);
|
|
@@ -3580,6 +3604,9 @@ var OpenAIChatCompletionStream = class {
|
|
|
3580
3604
|
}
|
|
3581
3605
|
yield chunk;
|
|
3582
3606
|
}
|
|
3607
|
+
if (!sawDone) {
|
|
3608
|
+
throw this.abortRequested ? new OllamaAbortError("OpenAI Chat Completion stream aborted") : new OllamaStreamError("OpenAI Chat Completion stream ended without [DONE]");
|
|
3609
|
+
}
|
|
3583
3610
|
const response = {
|
|
3584
3611
|
id,
|
|
3585
3612
|
object: "chat.completion",
|
|
@@ -3633,10 +3660,12 @@ var OpenAICompletionStream = class {
|
|
|
3633
3660
|
resolveFinal;
|
|
3634
3661
|
rejectFinal;
|
|
3635
3662
|
removeAbortListener;
|
|
3663
|
+
abortRequested = false;
|
|
3636
3664
|
get finalResult() {
|
|
3637
3665
|
return this.finalResultPromise;
|
|
3638
3666
|
}
|
|
3639
3667
|
abort() {
|
|
3668
|
+
this.abortRequested = true;
|
|
3640
3669
|
this.removeAbortListener?.();
|
|
3641
3670
|
this.removeAbortListener = void 0;
|
|
3642
3671
|
this.source.abort?.();
|
|
@@ -3649,9 +3678,13 @@ var OpenAICompletionStream = class {
|
|
|
3649
3678
|
let created = 0;
|
|
3650
3679
|
let usage;
|
|
3651
3680
|
let completed = false;
|
|
3681
|
+
let sawDone = false;
|
|
3652
3682
|
try {
|
|
3653
3683
|
for await (const event of this.source) {
|
|
3654
|
-
if (event.data === "[DONE]")
|
|
3684
|
+
if (event.data === "[DONE]") {
|
|
3685
|
+
sawDone = true;
|
|
3686
|
+
break;
|
|
3687
|
+
}
|
|
3655
3688
|
const chunk = JSON.parse(event.data);
|
|
3656
3689
|
id = chunk.id || id;
|
|
3657
3690
|
model = chunk.model || model;
|
|
@@ -3668,6 +3701,9 @@ var OpenAICompletionStream = class {
|
|
|
3668
3701
|
}
|
|
3669
3702
|
yield chunk;
|
|
3670
3703
|
}
|
|
3704
|
+
if (!sawDone) {
|
|
3705
|
+
throw this.abortRequested ? new OllamaAbortError("OpenAI Completion stream aborted") : new OllamaStreamError("OpenAI Completion stream ended without [DONE]");
|
|
3706
|
+
}
|
|
3671
3707
|
const response = {
|
|
3672
3708
|
id,
|
|
3673
3709
|
object: "text_completion",
|
|
@@ -4202,10 +4238,12 @@ var AnthropicMessagesStream = class {
|
|
|
4202
4238
|
resolveFinal;
|
|
4203
4239
|
rejectFinal;
|
|
4204
4240
|
removeAbortListener;
|
|
4241
|
+
abortRequested = false;
|
|
4205
4242
|
get finalResult() {
|
|
4206
4243
|
return this.finalResultPromise;
|
|
4207
4244
|
}
|
|
4208
4245
|
abort() {
|
|
4246
|
+
this.abortRequested = true;
|
|
4209
4247
|
this.removeAbortListener?.();
|
|
4210
4248
|
this.removeAbortListener = void 0;
|
|
4211
4249
|
this.source.abort?.();
|
|
@@ -4216,6 +4254,7 @@ var AnthropicMessagesStream = class {
|
|
|
4216
4254
|
const blocks = /* @__PURE__ */ new Map();
|
|
4217
4255
|
const toolInputJson = /* @__PURE__ */ new Map();
|
|
4218
4256
|
let completed = false;
|
|
4257
|
+
let sawMessageStop = false;
|
|
4219
4258
|
try {
|
|
4220
4259
|
for await (const rawEvent of this.source) {
|
|
4221
4260
|
let event;
|
|
@@ -4231,6 +4270,9 @@ var AnthropicMessagesStream = class {
|
|
|
4231
4270
|
if (event.type === "error") {
|
|
4232
4271
|
throw new Error(event.error.message);
|
|
4233
4272
|
}
|
|
4273
|
+
if (event.type === "message_stop") {
|
|
4274
|
+
sawMessageStop = true;
|
|
4275
|
+
}
|
|
4234
4276
|
if (event.type === "message_start") {
|
|
4235
4277
|
message = {
|
|
4236
4278
|
...event.message,
|
|
@@ -4291,6 +4333,9 @@ var AnthropicMessagesStream = class {
|
|
|
4291
4333
|
if (!message) {
|
|
4292
4334
|
throw new Error("Anthropic Messages stream ended without message_start");
|
|
4293
4335
|
}
|
|
4336
|
+
if (!sawMessageStop) {
|
|
4337
|
+
throw this.abortRequested ? new OllamaAbortError("Anthropic Messages stream aborted") : new OllamaStreamError("Anthropic Messages stream ended without message_stop");
|
|
4338
|
+
}
|
|
4294
4339
|
const final = {
|
|
4295
4340
|
...message,
|
|
4296
4341
|
content: [...blocks.entries()].sort(([a], [b]) => a - b).map(([, block]) => block)
|