@opencode-ai/ai
Advanced tools
+1
-1
@@ -204,3 +204,3 @@ import { Effect, JsonSchema, Schema } from "effect"; | ||
| } | undefined; | ||
| readonly classification?: "context-overflow" | undefined; | ||
| readonly classification?: "context-overflow" | "payload-too-large" | undefined; | ||
| })[]; | ||
@@ -207,0 +207,0 @@ get usage(): import("./schema").Usage | undefined; |
@@ -675,3 +675,3 @@ import { Effect, Schema } from "effect"; | ||
| } | undefined; | ||
| readonly classification?: "context-overflow" | undefined; | ||
| readonly classification?: "context-overflow" | "payload-too-large" | undefined; | ||
| })[]], LLMError, never>; | ||
@@ -678,0 +678,0 @@ /** |
@@ -253,3 +253,3 @@ import { Effect } from "effect"; | ||
| } | undefined; | ||
| readonly classification?: "context-overflow" | undefined; | ||
| readonly classification?: "context-overflow" | "payload-too-large" | undefined; | ||
| })[]; | ||
@@ -447,3 +447,3 @@ }, LLMError, never>; | ||
| } | undefined; | ||
| readonly classification?: "context-overflow" | undefined; | ||
| readonly classification?: "context-overflow" | "payload-too-large" | undefined; | ||
| })[]; | ||
@@ -638,5 +638,5 @@ }, LLMError, never>; | ||
| } | undefined; | ||
| readonly classification?: "context-overflow" | undefined; | ||
| readonly classification?: "context-overflow" | "payload-too-large" | undefined; | ||
| })[]; | ||
| }, LLMError, never>; | ||
| export * as ToolStream from "./tool-stream"; |
| import { LLMError, type HttpContext, type HttpRateLimitDetails, type ProviderMetadata } from "./schema"; | ||
| export declare const isContextOverflow: (message: string) => boolean; | ||
| export declare const isPayloadTooLarge: (message: string) => boolean; | ||
| export declare const isContextOverflowFailure: (failure: unknown) => boolean; | ||
@@ -4,0 +5,0 @@ export interface ProviderFailure { |
@@ -5,3 +5,2 @@ import { Option, Schema } from "effect"; | ||
| /prompt is too long/i, | ||
| /request_too_large/i, | ||
| /input is too long for requested model/i, | ||
@@ -23,3 +22,2 @@ /exceeds the context window/i, | ||
| /context[_ ]length[_ ]exceeded/i, | ||
| /request entity too large/i, | ||
| /context length is only \d+ tokens/i, | ||
@@ -34,5 +32,7 @@ /input length.*exceeds.*context length/i, | ||
| ]; | ||
| const payloadPatterns = [/request_too_large/i, /request entity too large/i, /payload too large/i, /request too large/i]; | ||
| const exclusions = [/^(throttling error|service unavailable):/i, /rate limit/i, /too many requests/i]; | ||
| export const isContextOverflow = (message) => !exclusions.some((pattern) => pattern.test(message)) && | ||
| (patterns.some((pattern) => pattern.test(message)) || /^4(00|13)\s*(status code)?\s*\(no body\)/i.test(message)); | ||
| (patterns.some((pattern) => pattern.test(message)) || /^400\s*(status code)?\s*\(no body\)/i.test(message)); | ||
| export const isPayloadTooLarge = (message) => payloadPatterns.some((pattern) => pattern.test(message)); | ||
| export const isContextOverflowFailure = (failure) => failure instanceof LLMError | ||
@@ -72,2 +72,4 @@ ? failure.reason._tag === "InvalidRequest" && failure.reason.classification === "context-overflow" | ||
| return new InvalidRequestReason({ ...common, classification: "context-overflow" }); | ||
| if (input.status === 413 || isPayloadTooLarge(text)) | ||
| return new InvalidRequestReason({ ...common, classification: "payload-too-large" }); | ||
| if (CONTENT_POLICY_TEXT.test(text)) | ||
@@ -118,6 +120,3 @@ return new ContentPolicyReason(common); | ||
| return new InvalidRequestReason(common); | ||
| if (input.status === 400 || | ||
| input.status === 404 || | ||
| input.status === 413 || | ||
| input.status === 422) | ||
| if (input.status === 400 || input.status === 404 || input.status === 413 || input.status === 422) | ||
| return new InvalidRequestReason(common); | ||
@@ -124,0 +123,0 @@ return new UnknownProviderReason({ ...common, status: input.status }); |
@@ -335,3 +335,3 @@ import { Context, Effect, Layer, Schema, Stream } from "effect"; | ||
| } | undefined; | ||
| readonly classification?: "context-overflow" | undefined; | ||
| readonly classification?: "context-overflow" | "payload-too-large" | undefined; | ||
| }, LLMError, Service>; | ||
@@ -338,0 +338,0 @@ export declare const layer: Layer.Layer<Service, never, RequestExecutor.Service>; |
| import { Schema } from "effect"; | ||
| import { Tool } from "@opencode-ai/schema/tool"; | ||
| export declare const ProviderFailureClassification: Schema.Literal<"context-overflow">; | ||
| export declare const ProviderFailureClassification: Schema.Literals<readonly ["context-overflow", "payload-too-large"]>; | ||
| export type ProviderFailureClassification = typeof ProviderFailureClassification.Type; | ||
@@ -40,3 +40,3 @@ declare const HttpRequestDetails_base: Schema.Class<HttpRequestDetails, Schema.Struct<{ | ||
| readonly parameter: Schema.optional<Schema.String>; | ||
| readonly classification: Schema.optional<Schema.Literal<"context-overflow">>; | ||
| readonly classification: Schema.optional<Schema.Literals<readonly ["context-overflow", "payload-too-large"]>>; | ||
| readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>; | ||
@@ -43,0 +43,0 @@ readonly http: Schema.optional<typeof HttpContext>; |
| import { Schema } from "effect"; | ||
| import { Tool } from "@opencode-ai/schema/tool"; | ||
| import { ModelID, ProviderID, ProviderMetadata, RouteID } from "./ids"; | ||
| export const ProviderFailureClassification = Schema.Literal("context-overflow"); | ||
| export const ProviderFailureClassification = Schema.Literals(["context-overflow", "payload-too-large"]); | ||
| export class HttpRequestDetails extends Schema.Class("LLM.HttpRequestDetails")({ | ||
@@ -6,0 +6,0 @@ method: Schema.String, |
@@ -209,3 +209,3 @@ export * as TestLLM from "./testing"; | ||
| } | undefined; | ||
| readonly classification?: "context-overflow" | undefined; | ||
| readonly classification?: "context-overflow" | "payload-too-large" | undefined; | ||
| })[]; | ||
@@ -392,3 +392,3 @@ export declare const stop: (...events: readonly LLMEvent[]) => ({ | ||
| } | undefined; | ||
| readonly classification?: "context-overflow" | undefined; | ||
| readonly classification?: "context-overflow" | "payload-too-large" | undefined; | ||
| })[]; | ||
@@ -575,3 +575,3 @@ export declare const toolCalls: (...events: readonly LLMEvent[]) => ({ | ||
| } | undefined; | ||
| readonly classification?: "context-overflow" | undefined; | ||
| readonly classification?: "context-overflow" | "payload-too-large" | undefined; | ||
| })[]; | ||
@@ -758,3 +758,3 @@ export declare const text: (value: string, id: string) => ({ | ||
| } | undefined; | ||
| readonly classification?: "context-overflow" | undefined; | ||
| readonly classification?: "context-overflow" | "payload-too-large" | undefined; | ||
| })[]; | ||
@@ -941,3 +941,3 @@ export declare const textWithUsage: (value: string, id: string, inputTokens: number) => ({ | ||
| } | undefined; | ||
| readonly classification?: "context-overflow" | undefined; | ||
| readonly classification?: "context-overflow" | "payload-too-large" | undefined; | ||
| })[]; | ||
@@ -1124,3 +1124,3 @@ export declare const tool: (id: string, name: string, input: unknown) => ({ | ||
| } | undefined; | ||
| readonly classification?: "context-overflow" | undefined; | ||
| readonly classification?: "context-overflow" | "payload-too-large" | undefined; | ||
| })[]; | ||
@@ -1307,3 +1307,3 @@ export declare const failAfter: (error: LLMError, ...events: readonly LLMEvent[]) => Stream.Stream<{ | ||
| } | undefined; | ||
| readonly classification?: "context-overflow" | undefined; | ||
| readonly classification?: "context-overflow" | "payload-too-large" | undefined; | ||
| }, LLMError, never>; | ||
@@ -1490,3 +1490,3 @@ export declare const hangAfter: (...events: readonly LLMEvent[]) => Stream.Stream<{ | ||
| } | undefined; | ||
| readonly classification?: "context-overflow" | undefined; | ||
| readonly classification?: "context-overflow" | "payload-too-large" | undefined; | ||
| }, never, never>; | ||
@@ -1493,0 +1493,0 @@ export declare const layer: (options?: LayerOptions) => Layer.Layer<Service, never, never>; |
+3
-3
| { | ||
| "$schema": "https://json.schemastore.org/package.json", | ||
| "version": "0.0.0-next-16664", | ||
| "version": "0.0.0-next-16665", | ||
| "name": "@opencode-ai/ai", | ||
@@ -33,3 +33,3 @@ "type": "module", | ||
| "@effect/platform-node": "4.0.0-beta.101", | ||
| "@opencode-ai/http-recorder": "0.0.0-next-16664", | ||
| "@opencode-ai/http-recorder": "0.0.0-next-16665", | ||
| "@tsconfig/bun": "1.0.9", | ||
@@ -43,3 +43,3 @@ "@types/bun": "1.3.13", | ||
| "@smithy/util-utf8": "4.2.2", | ||
| "@opencode-ai/schema": "0.0.0-next-16664", | ||
| "@opencode-ai/schema": "0.0.0-next-16665", | ||
| "aws4fetch": "1.0.20", | ||
@@ -46,0 +46,0 @@ "effect": "4.0.0-beta.101", |
Sorry, the diff of this file is too big to display
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
1116171
0.12%+ Added
- Removed