@opencode/ai 0.0.0-dev-289 → 0.0.0-dev-306
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/README.md +6 -6
- package/dist/effect.d.ts +2 -2
- package/dist/effect.js +1 -1
- package/dist/index.d.ts +10 -13
- package/dist/index.js +10 -15
- package/dist/llm.d.ts +2 -2
- package/dist/llm.js +3 -12
- package/dist/protocols/alibaba-responses.d.ts +2 -2
- package/dist/protocols/assemblyai-transcription.js +3 -3
- package/dist/protocols/meta-responses.d.ts +4 -4
- package/dist/protocols/open-responses.d.ts +18 -18
- package/dist/protocols/open-responses.js +4 -2
- package/dist/protocols/openai-compatible-responses.d.ts +2 -2
- package/dist/protocols/openai-responses.d.ts +12 -12
- package/dist/protocols/runway-video.js +2 -2
- package/dist/protocols/xai-responses.d.ts +2 -2
- package/dist/protocols/xai-video.js +2 -2
- package/dist/providers/alibaba.d.ts +2 -2
- package/dist/providers/amazon-bedrock-mantle.d.ts +2 -2
- package/dist/providers/azure.d.ts +4 -4
- package/dist/providers/cloudflare-ai-gateway.d.ts +4 -4
- package/dist/providers/digitalocean.d.ts +2 -2
- package/dist/providers/google-vertex-responses.d.ts +2 -2
- package/dist/providers/meta.d.ts +2 -2
- package/dist/providers/minimax.d.ts +2 -2
- package/dist/providers/moonshot.d.ts +2 -2
- package/dist/providers/openai-compatible-responses.d.ts +2 -2
- package/dist/providers/openai.d.ts +2 -2
- package/dist/providers/openrouter/responses.d.ts +1 -2
- package/dist/providers/openrouter.d.ts +36 -23
- package/dist/providers/openrouter.js +29 -10
- package/dist/providers/venice.d.ts +2 -2
- package/dist/providers/zai-coding-plan.d.ts +2 -2
- package/dist/route/media-protocol.d.ts +2 -3
- package/dist/route/media-protocol.js +2 -6
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/dist/tool.d.ts +35 -73
- package/dist/tool.js +27 -18
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -55,16 +55,16 @@ Anthropic Messages, Gemini, Bedrock Converse, and any OpenAI-compatible deployme
|
|
|
55
55
|
`stream` runs one model call; `loop` runs the model's tool calls and calls the model again until it stops calling
|
|
56
56
|
tools. Events from every step arrive on one stream, with a `tool-result` after each tool runs. `until` is checked
|
|
57
57
|
after each step that has tool calls, with every step's `LLMResponse`; returning `true` ends the loop without running
|
|
58
|
-
them. `
|
|
58
|
+
them. `tool` takes a plain `async` execute; a throw or rejection goes back to the model as an error result, and
|
|
59
59
|
`signal` aborts when the loop is interrupted.
|
|
60
|
-
`
|
|
60
|
+
`tool` from `@opencode/ai/effect` takes the same options (including an optional `success` schema) with an Effect execute:
|
|
61
61
|
|
|
62
62
|
```ts
|
|
63
63
|
import { readFile } from "node:fs/promises"
|
|
64
64
|
import { Schema } from "effect"
|
|
65
|
-
import {
|
|
65
|
+
import { tool } from "@opencode/ai"
|
|
66
66
|
|
|
67
|
-
const read_file =
|
|
67
|
+
const read_file = tool({
|
|
68
68
|
description: "Read a UTF-8 file.",
|
|
69
69
|
parameters: Schema.Struct({ path: Schema.String }),
|
|
70
70
|
execute: ({ path }, { signal }) => readFile(path, { encoding: "utf8", signal }),
|
|
@@ -87,7 +87,7 @@ A tool with exactly one required string parameter can set `freeform`, so the mod
|
|
|
87
87
|
instead of JSON arguments: unconstrained `text`, or text matching a `regex` or `lark` grammar.
|
|
88
88
|
|
|
89
89
|
```ts
|
|
90
|
-
const run_code =
|
|
90
|
+
const run_code = tool({
|
|
91
91
|
description: "Run JavaScript",
|
|
92
92
|
parameters: Schema.Struct({ code: Schema.String }),
|
|
93
93
|
freeform: { type: "lark", grammar: JS_GRAMMAR },
|
|
@@ -1158,7 +1158,7 @@ Everything below is exported from `@opencode/ai/effect` unless noted.
|
|
|
1158
1158
|
|
|
1159
1159
|
- **`LLM.request({...})`** — build a provider-neutral `LLMRequest`. Accepts ergonomic inputs (`system: string`, `prompt: string`) that normalize into the canonical Schema classes.
|
|
1160
1160
|
- **`LLM.generate` / `LLM.stream`** — run direct input or an `LLMRequest` through `LLMClient` for one-import use.
|
|
1161
|
-
- **`LLM.loop`** — stream model calls, running `
|
|
1161
|
+
- **`LLM.loop`** — stream model calls, running `tool(...)` tools between them until the model stops calling tools.
|
|
1162
1162
|
- **`Message.user(...)` / `Message.assistant(...)` / `Message.tool(...)`** — message constructors from the canonical schema model.
|
|
1163
1163
|
- **`LanguageModel.make(...)` / `ToolCallPart.make(...)` / `ToolResultPart.make(...)` / `ToolDefinition.make(...)`** — model and tool-related constructors from the canonical schema model.
|
|
1164
1164
|
- **`LLMEvent.is.*`** — typed guards (`is.textDelta`, `is.toolCall`, `is.finish`, …) for filtering streams.
|
package/dist/effect.d.ts
CHANGED
|
@@ -30,9 +30,9 @@ export { DecisionRoute } from "./route/decision.js";
|
|
|
30
30
|
export { Media } from "./media.js";
|
|
31
31
|
export { Generation } from "./generation.js";
|
|
32
32
|
export type { AwaitOptions as GenerationAwaitOptions, Event as GenerationEvent, Poll, Route as GenerationRoute, Snapshot as GenerationSnapshot, Status as GenerationStatus, } from "./generation.js";
|
|
33
|
-
export {
|
|
33
|
+
export { ToolFailure, emptyInputJsonSchema, toDefinitions, tool } from "./tool.js";
|
|
34
34
|
export { ToolRuntime } from "./tool-runtime.js";
|
|
35
35
|
export type { DispatchResult as ToolDispatchResult, ToolSettlement } from "./tool-runtime.js";
|
|
36
|
-
export type {
|
|
36
|
+
export type { ExecutableTool, Tool, ToolExecute, ToolExecuteContext, ToolModelOutputInput, ToolOptions, Tools, ToolSchema, ToolToModelOutput, } from "./tool.js";
|
|
37
37
|
export * as LLM from "./llm.js";
|
|
38
38
|
export type { Definition as ProviderPackageDefinition, Settings as ProviderPackageSettings, } from "./provider-package.js";
|
package/dist/effect.js
CHANGED
|
@@ -22,6 +22,6 @@ export { Decision } from "./decision.js";
|
|
|
22
22
|
export { DecisionRoute } from "./route/decision.js";
|
|
23
23
|
export { Media } from "./media.js";
|
|
24
24
|
export { Generation } from "./generation.js";
|
|
25
|
-
export {
|
|
25
|
+
export { ToolFailure, emptyInputJsonSchema, toDefinitions, tool } from "./tool.js";
|
|
26
26
|
export { ToolRuntime } from "./tool-runtime.js";
|
|
27
27
|
export * as LLM from "./llm.js";
|
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { LanguageModel, type CompactionCheckpointResponse, type CompactionRespon
|
|
|
11
11
|
import type { GenerateObjectDynamicOptions, GenerateObjectOptions, GenerateObjectResponse, LoopInput, RequestInput } from "./llm.js";
|
|
12
12
|
import { type SpeechModel, type SpeechRequest, type SpeechRequestInput } from "./speech.js";
|
|
13
13
|
import { type TranscriptionModel, type TranscriptionRequest, type TranscriptionRequestInput } from "./transcription.js";
|
|
14
|
-
import {
|
|
14
|
+
import { type ToolExecuteContext, type ToolOptions, type ToolSchema } from "./tool.js";
|
|
15
15
|
import { type VideoModel, type VideoRequest, type VideoRequestInput } from "./video.js";
|
|
16
16
|
/**
|
|
17
17
|
* Promise-first entrypoint for scripts and non-Effect callers. One `ManagedRuntime` hosts the LLM, image, video, speech,
|
|
@@ -734,18 +734,14 @@ export declare const make: <R = never>(options?: Options<R>) => {
|
|
|
734
734
|
dispose: () => Promise<void>;
|
|
735
735
|
};
|
|
736
736
|
export type Client<R = never> = ReturnType<typeof make<R>>;
|
|
737
|
-
/**
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
readonly execute: (params: Schema.Schema.Type<Parameters>, context: Partial<ToolExecuteContext> & {
|
|
746
|
-
readonly signal: AbortSignal;
|
|
747
|
-
}) => unknown;
|
|
748
|
-
}) => Tool.ExecutableTool<Parameters, Schema.Unknown>;
|
|
737
|
+
/** `tool` from `@opencode/ai/effect`, with an `execute` that returns a value or a Promise and throws to fail. */
|
|
738
|
+
export declare const tool: <Parameters extends ToolSchema<any> = typeof Schema.Unknown, Success extends ToolSchema<any> = typeof Schema.Unknown, Result extends Schema.Schema.Type<Success> | PromiseLike<Schema.Schema.Type<Success>> = never>(config: ToolOptions<Parameters, Success, (params: Schema.Schema.Type<Parameters>, context: Partial<ToolExecuteContext> & {
|
|
739
|
+
signal: AbortSignal;
|
|
740
|
+
}) => Result>) => ((params: Schema.Schema.Type<Parameters>, context: Partial<ToolExecuteContext> & {
|
|
741
|
+
signal: AbortSignal;
|
|
742
|
+
}) => Result) extends infer T ? T extends (params: Schema.Schema.Type<Parameters>, context: Partial<ToolExecuteContext> & {
|
|
743
|
+
signal: AbortSignal;
|
|
744
|
+
}) => Result ? T extends (...args: never) => never ? import("./tool.js").Tool<Parameters, Success> : import("./tool.js").ExecutableTool<Parameters, Success> : never : never;
|
|
749
745
|
/** Default client over `RequestExecutor.fetchLayer` for scripts; the runtime builds its layer on first use. */
|
|
750
746
|
export declare const ai: {
|
|
751
747
|
run: <A, E>(effect: Effect.Effect<A, E, import("./image-client.js").ImageClientService | import("./effect.js").LLMClientService | RequestExecutor.RequestExecutorService | import("./decision-client.js").Service | import("./speech-client.js").SpeechClientService | import("./transcription-client.js").TranscriptionClientService | import("./video-client.js").VideoClientService>, options?: RunOptions) => Promise<A>;
|
|
@@ -1442,3 +1438,4 @@ export declare const ai: {
|
|
|
1442
1438
|
dispose: () => Promise<void>;
|
|
1443
1439
|
};
|
|
1444
1440
|
export * as AI from "./index.js";
|
|
1441
|
+
export type { ExecutableTool, Tool, ToolOptions, Tools } from "./tool.js";
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { RequestExecutor } from "./route/executor.js";
|
|
|
9
9
|
import { AIError, InvalidRequestError, LanguageModel, } from "./schema/index.js";
|
|
10
10
|
import { Speech } from "./speech.js";
|
|
11
11
|
import { Transcription, } from "./transcription.js";
|
|
12
|
-
import {
|
|
12
|
+
import { ToolFailure, build } from "./tool.js";
|
|
13
13
|
import { fileMediaType } from "./utils/media-type.js";
|
|
14
14
|
import { Video } from "./video.js";
|
|
15
15
|
// Fails with `signal.reason` so aborted calls reject and aborted streams throw like `fetch`: an `AbortError` by default.
|
|
@@ -120,20 +120,15 @@ export const make = (options = {}) => {
|
|
|
120
120
|
};
|
|
121
121
|
};
|
|
122
122
|
const fileError = (message, cause) => new AIError({ reason: new InvalidRequestError({ message, cause }) });
|
|
123
|
-
/**
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
execute: (params, context) => Effect.tryPromise({
|
|
133
|
-
try: async (signal) => (await config.execute(params, { ...context, signal })) ?? null,
|
|
134
|
-
catch: (error) => new ToolFailure({ message: error instanceof Error ? error.message : String(error), error }),
|
|
135
|
-
}),
|
|
136
|
-
});
|
|
123
|
+
/** `tool` from `@opencode/ai/effect`, with an `execute` that returns a value or a Promise and throws to fail. */
|
|
124
|
+
export const tool = (config) => {
|
|
125
|
+
const execute = config.execute;
|
|
126
|
+
return build(config, execute &&
|
|
127
|
+
((params, context) => Effect.tryPromise({
|
|
128
|
+
try: async (signal) => execute(params, { ...context, signal }),
|
|
129
|
+
catch: (error) => new ToolFailure({ message: error instanceof Error ? error.message : String(error), error }),
|
|
130
|
+
})));
|
|
131
|
+
};
|
|
137
132
|
/** Default client over `RequestExecutor.fetchLayer` for scripts; the runtime builds its layer on first use. */
|
|
138
133
|
export const ai = make();
|
|
139
134
|
export * as AI from "./index.js";
|
package/dist/llm.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Effect, JsonSchema, Schema, Stream } from "effect";
|
|
2
2
|
import { Service, type StreamOptions } from "./route/client.js";
|
|
3
3
|
import { GenerationOptions, HttpOptions, AIError, LLMEvent, LLMRequest, LLMResponse, Message, LanguageModel, SystemPart, ToolChoice, type ContentPart, type LanguageModelProviderOptions, type ToolEntryInput } from "./schema/index.js";
|
|
4
|
-
import { type
|
|
4
|
+
import { type ExecutableTool, type ToolSchema } from "./tool.js";
|
|
5
5
|
/** Input accepted by `LLM.request`, normalized into the canonical `LLMRequest` class. */
|
|
6
6
|
export type RequestInput<SelectedLanguageModel extends LanguageModel = LanguageModel> = Omit<ConstructorParameters<typeof LLMRequest>[0], "model" | "system" | "messages" | "tools" | "toolChoice" | "generation" | "http" | "providerOptions"> & {
|
|
7
7
|
readonly model: SelectedLanguageModel;
|
|
@@ -17,7 +17,7 @@ export type RequestInput<SelectedLanguageModel extends LanguageModel = LanguageM
|
|
|
17
17
|
export declare function generate<const Model extends LanguageModel>(input: RequestInput<Model> | LLMRequest, options?: StreamOptions): Effect.Effect<LLMResponse, AIError, Service>;
|
|
18
18
|
export declare function stream<const Model extends LanguageModel>(input: RequestInput<Model> | LLMRequest, options?: StreamOptions): Stream.Stream<LLMEvent, AIError, Service>;
|
|
19
19
|
export type LoopInput<SelectedLanguageModel extends LanguageModel = LanguageModel> = Omit<RequestInput<SelectedLanguageModel>, "tools"> & {
|
|
20
|
-
readonly tools:
|
|
20
|
+
readonly tools: Record<string, ExecutableTool>;
|
|
21
21
|
/** Called after each step that has tool calls; returning `true` ends the loop without running them. */
|
|
22
22
|
readonly until?: (state: {
|
|
23
23
|
readonly steps: ReadonlyArray<LLMResponse>;
|
package/dist/llm.js
CHANGED
|
@@ -2,7 +2,7 @@ import { Effect, JsonSchema, Schema, Stream } from "effect";
|
|
|
2
2
|
import { tryRequest } from "./media-model.js";
|
|
3
3
|
import { LLMClient, Service } from "./route/client.js";
|
|
4
4
|
import { GenerationOptions, HttpOptions, InvalidProviderOutputError, AIError, LLMEvent, LLMRequest, LLMResponse, Message, LanguageModel, SystemPart, ToolChoice, ToolEntry, } from "./schema/index.js";
|
|
5
|
-
import {
|
|
5
|
+
import { tool, toDefinitions } from "./tool.js";
|
|
6
6
|
import { ToolRuntime } from "./tool-runtime.js";
|
|
7
7
|
export function generate(input, options) {
|
|
8
8
|
return requestEffect(input).pipe(Effect.flatMap((request) => LLMClient.generate(request, options)));
|
|
@@ -98,17 +98,8 @@ const runGenerateObject = Effect.fn("LLM.generateObject")(function* (options, to
|
|
|
98
98
|
export function generateObject(options) {
|
|
99
99
|
if ("schema" in options) {
|
|
100
100
|
const { schema, ...rest } = options;
|
|
101
|
-
return runGenerateObject(rest,
|
|
102
|
-
description: GENERATE_OBJECT_TOOL_DESCRIPTION,
|
|
103
|
-
parameters: schema,
|
|
104
|
-
success: Schema.Unknown,
|
|
105
|
-
execute: () => Effect.void,
|
|
106
|
-
}));
|
|
101
|
+
return runGenerateObject(rest, tool({ description: GENERATE_OBJECT_TOOL_DESCRIPTION, parameters: schema }));
|
|
107
102
|
}
|
|
108
103
|
const { jsonSchema, ...rest } = options;
|
|
109
|
-
return runGenerateObject(rest,
|
|
110
|
-
description: GENERATE_OBJECT_TOOL_DESCRIPTION,
|
|
111
|
-
jsonSchema,
|
|
112
|
-
execute: () => Effect.void,
|
|
113
|
-
}));
|
|
104
|
+
return runGenerateObject(rest, tool({ description: GENERATE_OBJECT_TOOL_DESCRIPTION, jsonSchema }));
|
|
114
105
|
}
|
|
@@ -40,7 +40,7 @@ export declare const protocol: Protocol<{
|
|
|
40
40
|
readonly detail?: string | undefined;
|
|
41
41
|
} | {
|
|
42
42
|
readonly type: "input_file";
|
|
43
|
-
readonly filename
|
|
43
|
+
readonly filename?: string | undefined;
|
|
44
44
|
readonly detail?: string | undefined;
|
|
45
45
|
readonly file_data?: string | undefined;
|
|
46
46
|
readonly file_url?: string | undefined;
|
|
@@ -72,7 +72,7 @@ export declare const protocol: Protocol<{
|
|
|
72
72
|
readonly detail?: string | undefined;
|
|
73
73
|
} | {
|
|
74
74
|
readonly type: "input_file";
|
|
75
|
-
readonly filename
|
|
75
|
+
readonly filename?: string | undefined;
|
|
76
76
|
readonly detail?: string | undefined;
|
|
77
77
|
readonly file_data?: string | undefined;
|
|
78
78
|
readonly file_url?: string | undefined;
|
|
@@ -77,19 +77,19 @@ const fromRequest = Effect.fn("AssemblyAITranscription.fromRequest")(function* (
|
|
|
77
77
|
const decodeTranscript = route.decodeJson(Transcript);
|
|
78
78
|
const decodeStart = Effect.fn("AssemblyAITranscription.decodeStart")(function* (response) {
|
|
79
79
|
const output = yield* decodeTranscript(response);
|
|
80
|
-
const status =
|
|
80
|
+
const status = MediaProtocol.status(STATUS, output.value.status);
|
|
81
81
|
return { token: { transcriptID: output.value.id }, snapshot: { id: output.value.id, status } };
|
|
82
82
|
});
|
|
83
83
|
const decodeStatus = Effect.fn("AssemblyAITranscription.decodeStatus")(function* (response, context) {
|
|
84
84
|
const output = yield* decodeTranscript(response);
|
|
85
|
-
const status =
|
|
85
|
+
const status = MediaProtocol.status(STATUS, output.value.status);
|
|
86
86
|
return { id: context.token.transcriptID, status };
|
|
87
87
|
});
|
|
88
88
|
const seconds = (milliseconds) => milliseconds / 1000;
|
|
89
89
|
const decodeResult = Effect.fn("AssemblyAITranscription.decodeResult")(function* (response, context) {
|
|
90
90
|
const output = yield* decodeTranscript(response);
|
|
91
91
|
const transcript = output.value;
|
|
92
|
-
const status =
|
|
92
|
+
const status = MediaProtocol.status(STATUS, transcript.status);
|
|
93
93
|
const error = transcript.error ?? undefined;
|
|
94
94
|
if (status === "failed")
|
|
95
95
|
return yield* output.ended("failed", `${route.name} transcription failed${error === undefined ? "" : `: ${error}`}`);
|
|
@@ -54,7 +54,7 @@ export declare const protocol: Protocol<{
|
|
|
54
54
|
readonly detail?: string | undefined;
|
|
55
55
|
} | {
|
|
56
56
|
readonly type: "input_file";
|
|
57
|
-
readonly filename
|
|
57
|
+
readonly filename?: string | undefined;
|
|
58
58
|
readonly detail?: string | undefined;
|
|
59
59
|
readonly file_data?: string | undefined;
|
|
60
60
|
readonly file_url?: string | undefined;
|
|
@@ -86,7 +86,7 @@ export declare const protocol: Protocol<{
|
|
|
86
86
|
readonly detail?: string | undefined;
|
|
87
87
|
} | {
|
|
88
88
|
readonly type: "input_file";
|
|
89
|
-
readonly filename
|
|
89
|
+
readonly filename?: string | undefined;
|
|
90
90
|
readonly detail?: string | undefined;
|
|
91
91
|
readonly file_data?: string | undefined;
|
|
92
92
|
readonly file_url?: string | undefined;
|
|
@@ -310,7 +310,7 @@ export declare const httpTransport: import("../route/transport/http.js").HttpJso
|
|
|
310
310
|
readonly detail?: string | undefined;
|
|
311
311
|
} | {
|
|
312
312
|
readonly type: "input_file";
|
|
313
|
-
readonly filename
|
|
313
|
+
readonly filename?: string | undefined;
|
|
314
314
|
readonly detail?: string | undefined;
|
|
315
315
|
readonly file_data?: string | undefined;
|
|
316
316
|
readonly file_url?: string | undefined;
|
|
@@ -342,7 +342,7 @@ export declare const httpTransport: import("../route/transport/http.js").HttpJso
|
|
|
342
342
|
readonly detail?: string | undefined;
|
|
343
343
|
} | {
|
|
344
344
|
readonly type: "input_file";
|
|
345
|
-
readonly filename
|
|
345
|
+
readonly filename?: string | undefined;
|
|
346
346
|
readonly detail?: string | undefined;
|
|
347
347
|
readonly file_data?: string | undefined;
|
|
348
348
|
readonly file_url?: string | undefined;
|
|
@@ -19,7 +19,7 @@ export declare const OpenResponsesInputImage: Schema.Struct<{
|
|
|
19
19
|
}>;
|
|
20
20
|
export declare const OpenResponsesInputFile: Schema.Struct<{
|
|
21
21
|
readonly type: Schema.tag<"input_file">;
|
|
22
|
-
readonly filename: Schema.String
|
|
22
|
+
readonly filename: Schema.optional<Schema.String>;
|
|
23
23
|
readonly detail: Schema.optional<Schema.String>;
|
|
24
24
|
readonly file_data: Schema.optional<Schema.String>;
|
|
25
25
|
readonly file_url: Schema.optional<Schema.String>;
|
|
@@ -30,7 +30,7 @@ declare const MediaInput: Schema.Union<readonly [Schema.Struct<{
|
|
|
30
30
|
readonly detail: Schema.optional<Schema.String>;
|
|
31
31
|
}>, Schema.Struct<{
|
|
32
32
|
readonly type: Schema.tag<"input_file">;
|
|
33
|
-
readonly filename: Schema.String
|
|
33
|
+
readonly filename: Schema.optional<Schema.String>;
|
|
34
34
|
readonly detail: Schema.optional<Schema.String>;
|
|
35
35
|
readonly file_data: Schema.optional<Schema.String>;
|
|
36
36
|
readonly file_url: Schema.optional<Schema.String>;
|
|
@@ -134,7 +134,7 @@ export declare const InputItem: Schema.Union<readonly [Schema.Struct<{
|
|
|
134
134
|
readonly detail: Schema.optional<Schema.String>;
|
|
135
135
|
}>, Schema.Struct<{
|
|
136
136
|
readonly type: Schema.tag<"input_file">;
|
|
137
|
-
readonly filename: Schema.String
|
|
137
|
+
readonly filename: Schema.optional<Schema.String>;
|
|
138
138
|
readonly detail: Schema.optional<Schema.String>;
|
|
139
139
|
readonly file_data: Schema.optional<Schema.String>;
|
|
140
140
|
readonly file_url: Schema.optional<Schema.String>;
|
|
@@ -181,7 +181,7 @@ export declare const InputItem: Schema.Union<readonly [Schema.Struct<{
|
|
|
181
181
|
readonly detail: Schema.optional<Schema.String>;
|
|
182
182
|
}>, Schema.Struct<{
|
|
183
183
|
readonly type: Schema.tag<"input_file">;
|
|
184
|
-
readonly filename: Schema.String
|
|
184
|
+
readonly filename: Schema.optional<Schema.String>;
|
|
185
185
|
readonly detail: Schema.optional<Schema.String>;
|
|
186
186
|
readonly file_data: Schema.optional<Schema.String>;
|
|
187
187
|
readonly file_url: Schema.optional<Schema.String>;
|
|
@@ -291,7 +291,7 @@ export declare const coreFields: {
|
|
|
291
291
|
readonly detail: Schema.optional<Schema.String>;
|
|
292
292
|
}>, Schema.Struct<{
|
|
293
293
|
readonly type: Schema.tag<"input_file">;
|
|
294
|
-
readonly filename: Schema.String
|
|
294
|
+
readonly filename: Schema.optional<Schema.String>;
|
|
295
295
|
readonly detail: Schema.optional<Schema.String>;
|
|
296
296
|
readonly file_data: Schema.optional<Schema.String>;
|
|
297
297
|
readonly file_url: Schema.optional<Schema.String>;
|
|
@@ -338,7 +338,7 @@ export declare const coreFields: {
|
|
|
338
338
|
readonly detail: Schema.optional<Schema.String>;
|
|
339
339
|
}>, Schema.Struct<{
|
|
340
340
|
readonly type: Schema.tag<"input_file">;
|
|
341
|
-
readonly filename: Schema.String
|
|
341
|
+
readonly filename: Schema.optional<Schema.String>;
|
|
342
342
|
readonly detail: Schema.optional<Schema.String>;
|
|
343
343
|
readonly file_data: Schema.optional<Schema.String>;
|
|
344
344
|
readonly file_url: Schema.optional<Schema.String>;
|
|
@@ -472,7 +472,7 @@ export declare const OpenResponsesBody: Schema.Struct<{
|
|
|
472
472
|
readonly detail: Schema.optional<Schema.String>;
|
|
473
473
|
}>, Schema.Struct<{
|
|
474
474
|
readonly type: Schema.tag<"input_file">;
|
|
475
|
-
readonly filename: Schema.String
|
|
475
|
+
readonly filename: Schema.optional<Schema.String>;
|
|
476
476
|
readonly detail: Schema.optional<Schema.String>;
|
|
477
477
|
readonly file_data: Schema.optional<Schema.String>;
|
|
478
478
|
readonly file_url: Schema.optional<Schema.String>;
|
|
@@ -519,7 +519,7 @@ export declare const OpenResponsesBody: Schema.Struct<{
|
|
|
519
519
|
readonly detail: Schema.optional<Schema.String>;
|
|
520
520
|
}>, Schema.Struct<{
|
|
521
521
|
readonly type: Schema.tag<"input_file">;
|
|
522
|
-
readonly filename: Schema.String
|
|
522
|
+
readonly filename: Schema.optional<Schema.String>;
|
|
523
523
|
readonly detail: Schema.optional<Schema.String>;
|
|
524
524
|
readonly file_data: Schema.optional<Schema.String>;
|
|
525
525
|
readonly file_url: Schema.optional<Schema.String>;
|
|
@@ -1023,7 +1023,7 @@ export declare const lowerConversation: (request: LLMRequest<import("../schema/o
|
|
|
1023
1023
|
readonly detail?: string | undefined;
|
|
1024
1024
|
} | {
|
|
1025
1025
|
readonly type: "input_file";
|
|
1026
|
-
readonly filename
|
|
1026
|
+
readonly filename?: string | undefined;
|
|
1027
1027
|
readonly detail?: string | undefined;
|
|
1028
1028
|
readonly file_data?: string | undefined;
|
|
1029
1029
|
readonly file_url?: string | undefined;
|
|
@@ -1055,7 +1055,7 @@ export declare const lowerConversation: (request: LLMRequest<import("../schema/o
|
|
|
1055
1055
|
readonly detail?: string | undefined;
|
|
1056
1056
|
} | {
|
|
1057
1057
|
readonly type: "input_file";
|
|
1058
|
-
readonly filename
|
|
1058
|
+
readonly filename?: string | undefined;
|
|
1059
1059
|
readonly detail?: string | undefined;
|
|
1060
1060
|
readonly file_data?: string | undefined;
|
|
1061
1061
|
readonly file_url?: string | undefined;
|
|
@@ -1200,7 +1200,7 @@ export declare const fromRequestWithAdapter: (request: LLMRequest<import("../sch
|
|
|
1200
1200
|
readonly detail?: string | undefined;
|
|
1201
1201
|
} | {
|
|
1202
1202
|
readonly type: "input_file";
|
|
1203
|
-
readonly filename
|
|
1203
|
+
readonly filename?: string | undefined;
|
|
1204
1204
|
readonly detail?: string | undefined;
|
|
1205
1205
|
readonly file_data?: string | undefined;
|
|
1206
1206
|
readonly file_url?: string | undefined;
|
|
@@ -1232,7 +1232,7 @@ export declare const fromRequestWithAdapter: (request: LLMRequest<import("../sch
|
|
|
1232
1232
|
readonly detail?: string | undefined;
|
|
1233
1233
|
} | {
|
|
1234
1234
|
readonly type: "input_file";
|
|
1235
|
-
readonly filename
|
|
1235
|
+
readonly filename?: string | undefined;
|
|
1236
1236
|
readonly detail?: string | undefined;
|
|
1237
1237
|
readonly file_data?: string | undefined;
|
|
1238
1238
|
readonly file_url?: string | undefined;
|
|
@@ -1398,7 +1398,7 @@ export declare const fromRequest: (request: LLMRequest) => Effect.Effect<{
|
|
|
1398
1398
|
readonly detail?: string | undefined;
|
|
1399
1399
|
} | {
|
|
1400
1400
|
readonly type: "input_file";
|
|
1401
|
-
readonly filename
|
|
1401
|
+
readonly filename?: string | undefined;
|
|
1402
1402
|
readonly detail?: string | undefined;
|
|
1403
1403
|
readonly file_data?: string | undefined;
|
|
1404
1404
|
readonly file_url?: string | undefined;
|
|
@@ -1430,7 +1430,7 @@ export declare const fromRequest: (request: LLMRequest) => Effect.Effect<{
|
|
|
1430
1430
|
readonly detail?: string | undefined;
|
|
1431
1431
|
} | {
|
|
1432
1432
|
readonly type: "input_file";
|
|
1433
|
-
readonly filename
|
|
1433
|
+
readonly filename?: string | undefined;
|
|
1434
1434
|
readonly detail?: string | undefined;
|
|
1435
1435
|
readonly file_data?: string | undefined;
|
|
1436
1436
|
readonly file_url?: string | undefined;
|
|
@@ -1834,7 +1834,7 @@ export declare const protocol: Protocol<{
|
|
|
1834
1834
|
readonly detail?: string | undefined;
|
|
1835
1835
|
} | {
|
|
1836
1836
|
readonly type: "input_file";
|
|
1837
|
-
readonly filename
|
|
1837
|
+
readonly filename?: string | undefined;
|
|
1838
1838
|
readonly detail?: string | undefined;
|
|
1839
1839
|
readonly file_data?: string | undefined;
|
|
1840
1840
|
readonly file_url?: string | undefined;
|
|
@@ -1866,7 +1866,7 @@ export declare const protocol: Protocol<{
|
|
|
1866
1866
|
readonly detail?: string | undefined;
|
|
1867
1867
|
} | {
|
|
1868
1868
|
readonly type: "input_file";
|
|
1869
|
-
readonly filename
|
|
1869
|
+
readonly filename?: string | undefined;
|
|
1870
1870
|
readonly detail?: string | undefined;
|
|
1871
1871
|
readonly file_data?: string | undefined;
|
|
1872
1872
|
readonly file_url?: string | undefined;
|
|
@@ -2090,7 +2090,7 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
2090
2090
|
readonly detail?: string | undefined;
|
|
2091
2091
|
} | {
|
|
2092
2092
|
readonly type: "input_file";
|
|
2093
|
-
readonly filename
|
|
2093
|
+
readonly filename?: string | undefined;
|
|
2094
2094
|
readonly detail?: string | undefined;
|
|
2095
2095
|
readonly file_data?: string | undefined;
|
|
2096
2096
|
readonly file_url?: string | undefined;
|
|
@@ -2122,7 +2122,7 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
2122
2122
|
readonly detail?: string | undefined;
|
|
2123
2123
|
} | {
|
|
2124
2124
|
readonly type: "input_file";
|
|
2125
|
-
readonly filename
|
|
2125
|
+
readonly filename?: string | undefined;
|
|
2126
2126
|
readonly detail?: string | undefined;
|
|
2127
2127
|
readonly file_data?: string | undefined;
|
|
2128
2128
|
readonly file_url?: string | undefined;
|
|
@@ -26,7 +26,7 @@ export const OpenResponsesInputImage = Schema.Struct({
|
|
|
26
26
|
});
|
|
27
27
|
export const OpenResponsesInputFile = Schema.Struct({
|
|
28
28
|
type: Schema.tag("input_file"),
|
|
29
|
-
filename: Schema.String,
|
|
29
|
+
filename: Schema.optional(Schema.String),
|
|
30
30
|
detail: Schema.optional(Schema.String),
|
|
31
31
|
file_data: Schema.optional(Schema.String),
|
|
32
32
|
file_url: Schema.optional(Schema.String),
|
|
@@ -405,11 +405,13 @@ const lowerMedia = Effect.fnUntraced(function* (part, request, adapter) {
|
|
|
405
405
|
if (part.media.kind !== "image") {
|
|
406
406
|
if (part.media.kind === "video")
|
|
407
407
|
return { type: "input_video", video_url: location };
|
|
408
|
+
if (url)
|
|
409
|
+
return { type: "input_file", file_url: url, detail };
|
|
408
410
|
return {
|
|
409
411
|
type: "input_file",
|
|
410
412
|
filename: part.filename ?? (mime === "application/pdf" ? "document.pdf" : "file"),
|
|
411
413
|
detail,
|
|
412
|
-
|
|
414
|
+
file_data: location,
|
|
413
415
|
};
|
|
414
416
|
}
|
|
415
417
|
return {
|
|
@@ -34,7 +34,7 @@ export declare const route: Route<{
|
|
|
34
34
|
readonly detail?: string | undefined;
|
|
35
35
|
} | {
|
|
36
36
|
readonly type: "input_file";
|
|
37
|
-
readonly filename
|
|
37
|
+
readonly filename?: string | undefined;
|
|
38
38
|
readonly detail?: string | undefined;
|
|
39
39
|
readonly file_data?: string | undefined;
|
|
40
40
|
readonly file_url?: string | undefined;
|
|
@@ -66,7 +66,7 @@ export declare const route: Route<{
|
|
|
66
66
|
readonly detail?: string | undefined;
|
|
67
67
|
} | {
|
|
68
68
|
readonly type: "input_file";
|
|
69
|
-
readonly filename
|
|
69
|
+
readonly filename?: string | undefined;
|
|
70
70
|
readonly detail?: string | undefined;
|
|
71
71
|
readonly file_data?: string | undefined;
|
|
72
72
|
readonly file_url?: string | undefined;
|
|
@@ -46,7 +46,7 @@ declare const OpenAIResponsesBody: Schema.Struct<{
|
|
|
46
46
|
readonly detail: Schema.optional<Schema.String>;
|
|
47
47
|
}>, Schema.Struct<{
|
|
48
48
|
readonly type: Schema.tag<"input_file">;
|
|
49
|
-
readonly filename: Schema.String
|
|
49
|
+
readonly filename: Schema.optional<Schema.String>;
|
|
50
50
|
readonly detail: Schema.optional<Schema.String>;
|
|
51
51
|
readonly file_data: Schema.optional<Schema.String>;
|
|
52
52
|
readonly file_url: Schema.optional<Schema.String>;
|
|
@@ -93,7 +93,7 @@ declare const OpenAIResponsesBody: Schema.Struct<{
|
|
|
93
93
|
readonly detail: Schema.optional<Schema.String>;
|
|
94
94
|
}>, Schema.Struct<{
|
|
95
95
|
readonly type: Schema.tag<"input_file">;
|
|
96
|
-
readonly filename: Schema.String
|
|
96
|
+
readonly filename: Schema.optional<Schema.String>;
|
|
97
97
|
readonly detail: Schema.optional<Schema.String>;
|
|
98
98
|
readonly file_data: Schema.optional<Schema.String>;
|
|
99
99
|
readonly file_url: Schema.optional<Schema.String>;
|
|
@@ -263,7 +263,7 @@ export declare const protocol: Protocol<{
|
|
|
263
263
|
readonly detail?: string | undefined;
|
|
264
264
|
} | {
|
|
265
265
|
readonly type: "input_file";
|
|
266
|
-
readonly filename
|
|
266
|
+
readonly filename?: string | undefined;
|
|
267
267
|
readonly detail?: string | undefined;
|
|
268
268
|
readonly file_data?: string | undefined;
|
|
269
269
|
readonly file_url?: string | undefined;
|
|
@@ -295,7 +295,7 @@ export declare const protocol: Protocol<{
|
|
|
295
295
|
readonly detail?: string | undefined;
|
|
296
296
|
} | {
|
|
297
297
|
readonly type: "input_file";
|
|
298
|
-
readonly filename
|
|
298
|
+
readonly filename?: string | undefined;
|
|
299
299
|
readonly detail?: string | undefined;
|
|
300
300
|
readonly file_data?: string | undefined;
|
|
301
301
|
readonly file_url?: string | undefined;
|
|
@@ -551,7 +551,7 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
551
551
|
readonly detail?: string | undefined;
|
|
552
552
|
} | {
|
|
553
553
|
readonly type: "input_file";
|
|
554
|
-
readonly filename
|
|
554
|
+
readonly filename?: string | undefined;
|
|
555
555
|
readonly detail?: string | undefined;
|
|
556
556
|
readonly file_data?: string | undefined;
|
|
557
557
|
readonly file_url?: string | undefined;
|
|
@@ -583,7 +583,7 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
583
583
|
readonly detail?: string | undefined;
|
|
584
584
|
} | {
|
|
585
585
|
readonly type: "input_file";
|
|
586
|
-
readonly filename
|
|
586
|
+
readonly filename?: string | undefined;
|
|
587
587
|
readonly detail?: string | undefined;
|
|
588
588
|
readonly file_data?: string | undefined;
|
|
589
589
|
readonly file_url?: string | undefined;
|
|
@@ -781,7 +781,7 @@ export declare const channelTransport: (options: import("./open-responses-channe
|
|
|
781
781
|
readonly detail?: string | undefined;
|
|
782
782
|
} | {
|
|
783
783
|
readonly type: "input_file";
|
|
784
|
-
readonly filename
|
|
784
|
+
readonly filename?: string | undefined;
|
|
785
785
|
readonly detail?: string | undefined;
|
|
786
786
|
readonly file_data?: string | undefined;
|
|
787
787
|
readonly file_url?: string | undefined;
|
|
@@ -813,7 +813,7 @@ export declare const channelTransport: (options: import("./open-responses-channe
|
|
|
813
813
|
readonly detail?: string | undefined;
|
|
814
814
|
} | {
|
|
815
815
|
readonly type: "input_file";
|
|
816
|
-
readonly filename
|
|
816
|
+
readonly filename?: string | undefined;
|
|
817
817
|
readonly detail?: string | undefined;
|
|
818
818
|
readonly file_data?: string | undefined;
|
|
819
819
|
readonly file_url?: string | undefined;
|
|
@@ -1011,7 +1011,7 @@ export declare const transport: import("../route/transport/index.js").Transport<
|
|
|
1011
1011
|
readonly detail?: string | undefined;
|
|
1012
1012
|
} | {
|
|
1013
1013
|
readonly type: "input_file";
|
|
1014
|
-
readonly filename
|
|
1014
|
+
readonly filename?: string | undefined;
|
|
1015
1015
|
readonly detail?: string | undefined;
|
|
1016
1016
|
readonly file_data?: string | undefined;
|
|
1017
1017
|
readonly file_url?: string | undefined;
|
|
@@ -1043,7 +1043,7 @@ export declare const transport: import("../route/transport/index.js").Transport<
|
|
|
1043
1043
|
readonly detail?: string | undefined;
|
|
1044
1044
|
} | {
|
|
1045
1045
|
readonly type: "input_file";
|
|
1046
|
-
readonly filename
|
|
1046
|
+
readonly filename?: string | undefined;
|
|
1047
1047
|
readonly detail?: string | undefined;
|
|
1048
1048
|
readonly file_data?: string | undefined;
|
|
1049
1049
|
readonly file_url?: string | undefined;
|
|
@@ -1241,7 +1241,7 @@ export declare const route: Route<{
|
|
|
1241
1241
|
readonly detail?: string | undefined;
|
|
1242
1242
|
} | {
|
|
1243
1243
|
readonly type: "input_file";
|
|
1244
|
-
readonly filename
|
|
1244
|
+
readonly filename?: string | undefined;
|
|
1245
1245
|
readonly detail?: string | undefined;
|
|
1246
1246
|
readonly file_data?: string | undefined;
|
|
1247
1247
|
readonly file_url?: string | undefined;
|
|
@@ -1273,7 +1273,7 @@ export declare const route: Route<{
|
|
|
1273
1273
|
readonly detail?: string | undefined;
|
|
1274
1274
|
} | {
|
|
1275
1275
|
readonly type: "input_file";
|
|
1276
|
-
readonly filename
|
|
1276
|
+
readonly filename?: string | undefined;
|
|
1277
1277
|
readonly detail?: string | undefined;
|
|
1278
1278
|
readonly file_data?: string | undefined;
|
|
1279
1279
|
readonly file_url?: string | undefined;
|
|
@@ -76,13 +76,13 @@ const decodeStart = route.decodeStarted(StartResponse, (value) => ({
|
|
|
76
76
|
const decodeTask = route.decodeJson(Task);
|
|
77
77
|
const decodeStatus = Effect.fn("RunwayVideo.decodeStatus")(function* (response, context) {
|
|
78
78
|
const output = yield* decodeTask(response);
|
|
79
|
-
const status =
|
|
79
|
+
const status = MediaProtocol.status(STATUS, output.value.status);
|
|
80
80
|
return { id: context.token.taskID, status, progress: output.value.progress ?? undefined };
|
|
81
81
|
});
|
|
82
82
|
const decodeResult = Effect.fn("RunwayVideo.decodeResult")(function* (response, context) {
|
|
83
83
|
const output = yield* decodeTask(response);
|
|
84
84
|
const task = output.value;
|
|
85
|
-
const status =
|
|
85
|
+
const status = MediaProtocol.status(STATUS, task.status);
|
|
86
86
|
if (status === "failed") {
|
|
87
87
|
const code = task.failureCode ?? undefined;
|
|
88
88
|
const message = `${route.name} task failed${code === undefined ? "" : ` (${code})`}${task.failure ? `: ${task.failure}` : ""}`;
|
|
@@ -35,7 +35,7 @@ export declare const protocol: Protocol<{
|
|
|
35
35
|
readonly detail?: string | undefined;
|
|
36
36
|
} | {
|
|
37
37
|
readonly type: "input_file";
|
|
38
|
-
readonly filename
|
|
38
|
+
readonly filename?: string | undefined;
|
|
39
39
|
readonly detail?: string | undefined;
|
|
40
40
|
readonly file_data?: string | undefined;
|
|
41
41
|
readonly file_url?: string | undefined;
|
|
@@ -67,7 +67,7 @@ export declare const protocol: Protocol<{
|
|
|
67
67
|
readonly detail?: string | undefined;
|
|
68
68
|
} | {
|
|
69
69
|
readonly type: "input_file";
|
|
70
|
-
readonly filename
|
|
70
|
+
readonly filename?: string | undefined;
|
|
71
71
|
readonly detail?: string | undefined;
|
|
72
72
|
readonly file_data?: string | undefined;
|
|
73
73
|
readonly file_url?: string | undefined;
|
|
@@ -82,13 +82,13 @@ const fraction = (progress) => progress !== undefined && progress !== null && pr
|
|
|
82
82
|
const decodeVideoStatus = route.decodeJson(VideoStatus);
|
|
83
83
|
const decodeStatus = Effect.fn("XAIVideo.decodeStatus")(function* (response, context) {
|
|
84
84
|
const output = yield* decodeVideoStatus(response);
|
|
85
|
-
const status =
|
|
85
|
+
const status = MediaProtocol.status(STATUS, output.value.status);
|
|
86
86
|
return { id: context.token.requestID, status, progress: fraction(output.value.progress) };
|
|
87
87
|
});
|
|
88
88
|
const decodeResult = Effect.fn("XAIVideo.decodeResult")(function* (response, context) {
|
|
89
89
|
const output = yield* decodeVideoStatus(response);
|
|
90
90
|
const decoded = output.value;
|
|
91
|
-
const status =
|
|
91
|
+
const status = MediaProtocol.status(STATUS, decoded.status);
|
|
92
92
|
if (status === "running")
|
|
93
93
|
return yield* output.pending(context.token.requestID);
|
|
94
94
|
if (status === "failed") {
|