@opencode/ai 2.2.1 → 2.2.3
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 +92 -76
- package/dist/decision.d.ts +0 -1
- package/dist/effect.d.ts +2 -14
- package/dist/effect.js +1 -10
- package/dist/experimental/testing.d.ts +3 -0
- package/dist/experimental/testing.js +3 -0
- package/dist/experimental.d.ts +12 -0
- package/dist/experimental.js +9 -0
- package/dist/image.d.ts +1 -0
- package/dist/index.d.ts +340 -336
- package/dist/index.js +43 -41
- package/dist/llm.d.ts +2 -2
- package/dist/llm.js +19 -29
- 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/client.d.ts +3 -0
- package/dist/route/client.js +5 -4
- package/dist/route/media-protocol.d.ts +2 -3
- package/dist/route/media-protocol.js +2 -6
- package/dist/schema/errors.d.ts +6 -0
- package/dist/schema/errors.js +8 -0
- package/dist/schema/events.d.ts +4 -0
- package/dist/schema/events.js +4 -0
- package/dist/speech.d.ts +1 -0
- package/dist/testing.d.ts +1 -4
- package/dist/testing.js +4 -12
- package/dist/tool.d.ts +40 -73
- package/dist/tool.js +27 -18
- package/dist/transcription.d.ts +1 -0
- package/dist/video.d.ts +1 -0
- package/package.json +9 -5
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.
|
|
@@ -42,9 +42,11 @@ export const make = (options = {}) => {
|
|
|
42
42
|
}
|
|
43
43
|
const handle = (generation) => ({
|
|
44
44
|
...generation.snapshot,
|
|
45
|
+
snapshot: generation.snapshot,
|
|
46
|
+
terminal: generation.terminal,
|
|
45
47
|
token: generation.token,
|
|
46
|
-
await: (options) => run(generation.await(
|
|
47
|
-
events: (options) => iterate(generation.events(
|
|
48
|
+
await: (options) => run(generation.await(options), options),
|
|
49
|
+
events: (options) => iterate(generation.events(options), options),
|
|
48
50
|
result: (options) => run(generation.result(), options),
|
|
49
51
|
refresh: (options) => run(generation.refresh(), options).then(handle),
|
|
50
52
|
cancel: (options) => run(generation.cancel(), options),
|
|
@@ -77,63 +79,63 @@ export const make = (options = {}) => {
|
|
|
77
79
|
},
|
|
78
80
|
llm: {
|
|
79
81
|
request: LLM.request,
|
|
80
|
-
generate: (input, options) => run(LLM.generate(input), options),
|
|
81
|
-
stream: (input, options) => iterate(LLM.stream(input), options),
|
|
82
|
+
generate: (input, options) => run(LLM.generate(input, options), options),
|
|
83
|
+
stream: (input, options) => iterate(LLM.stream(input, options), options),
|
|
82
84
|
/** Stream model calls, running their tool calls, until the model stops calling tools or `until` is true. */
|
|
83
|
-
loop: (input, options) => iterate(LLM.loop(input), options),
|
|
85
|
+
loop: (input, options) => iterate(LLM.loop(input, options), options),
|
|
84
86
|
/** Decode the model's output against `schema` (or `jsonSchema`, unvalidated) like `LLM.generateObject`. */
|
|
85
87
|
generateObject,
|
|
86
88
|
/** Compact a Responses request like `LLMClient.compact`: a replacement window, or a checkpoint with `mechanism: "trigger"`. */
|
|
87
89
|
compact,
|
|
90
|
+
canCompact: LLMClient.canCompact,
|
|
88
91
|
},
|
|
89
92
|
image: {
|
|
90
93
|
request: Image.request,
|
|
91
|
-
generate: (input, options) => run(Image.generate(input,
|
|
92
|
-
stream: (input, options) => iterate(Image.stream(input,
|
|
94
|
+
generate: (input, options) => run(Image.generate(input, options), options),
|
|
95
|
+
stream: (input, options) => iterate(Image.stream(input, options), options),
|
|
93
96
|
start: (input, options) => run(Image.start(input), options).then(handle),
|
|
94
97
|
resume: (model, token, options) => run(Image.resume(model, token), options).then(handle),
|
|
95
98
|
},
|
|
96
|
-
video: {
|
|
97
|
-
request: Video.request,
|
|
98
|
-
start: (input, options) => run(Video.start(input), options).then(handle),
|
|
99
|
-
generate: (input, options) => run(Video.generate(input, { poll: options?.poll }), options),
|
|
100
|
-
resume: (model, token, options) => run(Video.resume(model, token), options).then(handle),
|
|
101
|
-
stream: (input, options) => iterate(Video.stream(input, { poll: options?.poll }), options),
|
|
102
|
-
},
|
|
103
|
-
speech: {
|
|
104
|
-
request: Speech.request,
|
|
105
|
-
generate: (input, options) => run(Speech.generate(input), options),
|
|
106
|
-
stream: (input, options) => iterate(Speech.stream(input), options),
|
|
107
|
-
},
|
|
108
|
-
transcription: {
|
|
109
|
-
request: Transcription.request,
|
|
110
|
-
generate: (input, options) => run(Transcription.generate(input, { poll: options?.poll }), options),
|
|
111
|
-
stream: (input, options) => iterate(Transcription.stream(input, { poll: options?.poll }), options),
|
|
112
|
-
start: (input, options) => run(Transcription.start(input), options).then(handle),
|
|
113
|
-
resume: (model, token, options) => run(Transcription.resume(model, token), options).then(handle),
|
|
114
|
-
},
|
|
115
99
|
decision: {
|
|
116
100
|
request: Decision.request,
|
|
117
101
|
generate: (input, options) => run(Decision.generate(input), options),
|
|
118
102
|
},
|
|
103
|
+
/** Experimental: may change without compatibility guarantees. */
|
|
104
|
+
experimental: {
|
|
105
|
+
speech: {
|
|
106
|
+
request: Speech.request,
|
|
107
|
+
generate: (input, options) => run(Speech.generate(input), options),
|
|
108
|
+
stream: (input, options) => iterate(Speech.stream(input), options),
|
|
109
|
+
},
|
|
110
|
+
transcription: {
|
|
111
|
+
request: Transcription.request,
|
|
112
|
+
generate: (input, options) => run(Transcription.generate(input, { poll: options?.poll }), options),
|
|
113
|
+
stream: (input, options) => iterate(Transcription.stream(input, { poll: options?.poll }), options),
|
|
114
|
+
start: (input, options) => run(Transcription.start(input), options).then(handle),
|
|
115
|
+
resume: (model, token, options) => run(Transcription.resume(model, token), options).then(handle),
|
|
116
|
+
},
|
|
117
|
+
video: {
|
|
118
|
+
request: Video.request,
|
|
119
|
+
start: (input, options) => run(Video.start(input), options).then(handle),
|
|
120
|
+
generate: (input, options) => run(Video.generate(input, { poll: options?.poll }), options),
|
|
121
|
+
resume: (model, token, options) => run(Video.resume(model, token), options).then(handle),
|
|
122
|
+
stream: (input, options) => iterate(Video.stream(input, { poll: options?.poll }), options),
|
|
123
|
+
},
|
|
124
|
+
},
|
|
119
125
|
dispose: () => runtime.dispose(),
|
|
120
126
|
};
|
|
121
127
|
};
|
|
122
128
|
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
|
-
});
|
|
129
|
+
/** `tool` from `@opencode/ai/effect`, with an `execute` that returns a value or a Promise and throws to fail. */
|
|
130
|
+
export const tool = (config) => {
|
|
131
|
+
const execute = config.execute;
|
|
132
|
+
return build(config, execute &&
|
|
133
|
+
((params, context) => Effect.tryPromise({
|
|
134
|
+
try: async (signal) => execute(params, { ...context, signal }),
|
|
135
|
+
catch: (error) => new ToolFailure({ message: error instanceof Error ? error.message : String(error), error }),
|
|
136
|
+
})));
|
|
137
|
+
};
|
|
137
138
|
/** Default client over `RequestExecutor.fetchLayer` for scripts; the runtime builds its layer on first use. */
|
|
138
139
|
export const ai = make();
|
|
140
|
+
export { AIError } from "./schema/index.js";
|
|
139
141
|
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
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
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
|
-
import { GenerationOptions, HttpOptions, InvalidProviderOutputError, AIError, LLMEvent, LLMRequest, LLMResponse, Message, LanguageModel, SystemPart, ToolChoice, ToolEntry, } from "./schema/index.js";
|
|
5
|
-
import {
|
|
4
|
+
import { GenerationOptions, HttpOptions, InvalidProviderOutputError, AIError, LLMEvent, LLMRequest, LLMResponse, Message, LanguageModel, SystemPart, ToolChoice, ToolEntry, withPartial, } from "./schema/index.js";
|
|
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)));
|
|
@@ -13,11 +13,11 @@ export function stream(input, options) {
|
|
|
13
13
|
export function loop(input, options) {
|
|
14
14
|
const { tools, until, ...rest } = input;
|
|
15
15
|
const step = (request, steps) => Stream.suspend(() => {
|
|
16
|
-
|
|
17
|
-
return LLMClient.stream(request, options).pipe(Stream.map((event) => event.type === "step-start" || event.type === "step-finish" ? { ...event, index: steps.length } : event), Stream.tap((event) => Effect.sync(() =>
|
|
18
|
-
const response = LLMResponse.
|
|
16
|
+
let state = LLMResponse.empty();
|
|
17
|
+
return LLMClient.stream(request, options).pipe(Stream.map((event) => event.type === "step-start" || event.type === "step-finish" ? { ...event, index: steps.length } : event), Stream.tap((event) => Effect.sync(() => (state = LLMResponse.reduce(state, event)))), Stream.mapError((error) => withPartial(error, LLMResponse.partial(state))), Stream.concat(Stream.unwrap(Effect.gen(function* () {
|
|
18
|
+
const response = LLMResponse.complete(state);
|
|
19
19
|
const calls = response?.toolCalls.filter((call) => call.providerExecuted !== true) ?? [];
|
|
20
|
-
if (!response || calls.length === 0 || events.some(LLMEvent.is.providerError))
|
|
20
|
+
if (!response || calls.length === 0 || state.events.some(LLMEvent.is.providerError))
|
|
21
21
|
return Stream.empty;
|
|
22
22
|
const done = [...steps, response];
|
|
23
23
|
if (until?.({ steps: done }))
|
|
@@ -81,34 +81,24 @@ const runGenerateObject = Effect.fn("LLM.generateObject")(function* (options, to
|
|
|
81
81
|
});
|
|
82
82
|
const response = yield* LLMClient.generate(generateRequest);
|
|
83
83
|
const call = response.toolCalls.find((event) => event.name === GENERATE_OBJECT_TOOL_NAME);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
})));
|
|
84
|
+
const invalidOutput = (reason) => new AIError({ reason, partial: response });
|
|
85
|
+
if (!call) {
|
|
86
|
+
const message = response.finishReason.normalized === "length"
|
|
87
|
+
? "generateObject: output hit the token limit before the forced tool call completed"
|
|
88
|
+
: `generateObject: model did not call the forced \`${GENERATE_OBJECT_TOOL_NAME}\` tool`;
|
|
89
|
+
return yield* invalidOutput(new InvalidProviderOutputError({ message }));
|
|
90
|
+
}
|
|
91
|
+
const object = yield* tool._decode(call.input).pipe(Effect.mapError((error) => invalidOutput(new InvalidProviderOutputError({
|
|
92
|
+
message: `generateObject: tool input failed schema decode: ${error.message}`,
|
|
93
|
+
cause: error,
|
|
94
|
+
}))));
|
|
96
95
|
return new GenerateObjectResponse(object, response);
|
|
97
96
|
});
|
|
98
97
|
export function generateObject(options) {
|
|
99
98
|
if ("schema" in options) {
|
|
100
99
|
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
|
-
}));
|
|
100
|
+
return runGenerateObject(rest, tool({ description: GENERATE_OBJECT_TOOL_DESCRIPTION, parameters: schema }));
|
|
107
101
|
}
|
|
108
102
|
const { jsonSchema, ...rest } = options;
|
|
109
|
-
return runGenerateObject(rest,
|
|
110
|
-
description: GENERATE_OBJECT_TOOL_DESCRIPTION,
|
|
111
|
-
jsonSchema,
|
|
112
|
-
execute: () => Effect.void,
|
|
113
|
-
}));
|
|
103
|
+
return runGenerateObject(rest, tool({ description: GENERATE_OBJECT_TOOL_DESCRIPTION, jsonSchema }));
|
|
114
104
|
}
|
|
@@ -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;
|