@opencode/ai 2.2.7 → 2.3.1

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.
Files changed (158) hide show
  1. package/README.md +164 -99
  2. package/dist/cache-policy.js +4 -2
  3. package/dist/effect.d.ts +11 -8
  4. package/dist/effect.js +2 -1
  5. package/dist/experimental.d.ts +0 -4
  6. package/dist/experimental.js +0 -3
  7. package/dist/generation.d.ts +10 -10
  8. package/dist/generation.js +8 -14
  9. package/dist/image-client.d.ts +56 -59
  10. package/dist/image-client.js +47 -12
  11. package/dist/image.d.ts +36 -95
  12. package/dist/image.js +11 -14
  13. package/dist/index.d.ts +31 -68
  14. package/dist/index.js +54 -30
  15. package/dist/llm.d.ts +4 -1
  16. package/dist/llm.js +10 -1
  17. package/dist/media-client.d.ts +18 -6
  18. package/dist/media-client.js +42 -37
  19. package/dist/media-model.d.ts +2 -0
  20. package/dist/media-model.js +3 -1
  21. package/dist/media.d.ts +26 -4
  22. package/dist/media.js +52 -11
  23. package/dist/protocols/alibaba-messages.d.ts +24 -2
  24. package/dist/protocols/alibaba-responses.d.ts +26 -0
  25. package/dist/protocols/anthropic-messages.d.ts +70 -6
  26. package/dist/protocols/anthropic-messages.js +74 -9
  27. package/dist/protocols/assemblyai-transcription.js +7 -6
  28. package/dist/protocols/cartesia-speech.d.ts +0 -8
  29. package/dist/protocols/deepgram-speech.d.ts +0 -8
  30. package/dist/protocols/elevenlabs-speech.d.ts +0 -8
  31. package/dist/protocols/google-decisions.d.ts +13 -0
  32. package/dist/protocols/google-decisions.js +133 -0
  33. package/dist/protocols/google-interactions-video.d.ts +38 -0
  34. package/dist/protocols/google-interactions-video.js +185 -0
  35. package/dist/protocols/google-interactions.d.ts +14 -1
  36. package/dist/protocols/google-interactions.js +1 -1
  37. package/dist/protocols/google-speech.d.ts +0 -8
  38. package/dist/protocols/google-transcription.d.ts +0 -8
  39. package/dist/protocols/index.d.ts +1 -0
  40. package/dist/protocols/index.js +1 -0
  41. package/dist/protocols/meta-messages.d.ts +24 -2
  42. package/dist/protocols/meta-responses.d.ts +52 -0
  43. package/dist/protocols/minimax-video.d.ts +45 -0
  44. package/dist/protocols/minimax-video.js +290 -0
  45. package/dist/protocols/open-responses.d.ts +250 -24
  46. package/dist/protocols/open-responses.js +40 -24
  47. package/dist/protocols/openai-chat.js +7 -3
  48. package/dist/protocols/openai-compatible-responses.d.ts +26 -0
  49. package/dist/protocols/openai-freeform.d.ts +1 -1
  50. package/dist/protocols/openai-freeform.js +9 -5
  51. package/dist/protocols/openai-images.d.ts +0 -8
  52. package/dist/protocols/openai-responses.d.ts +153 -0
  53. package/dist/protocols/openai-responses.js +68 -7
  54. package/dist/protocols/openai-speech.d.ts +0 -8
  55. package/dist/protocols/openai-transcription.d.ts +0 -8
  56. package/dist/protocols/openrouter-video.d.ts +36 -0
  57. package/dist/protocols/openrouter-video.js +139 -0
  58. package/dist/protocols/seedance-video.d.ts +45 -0
  59. package/dist/protocols/seedance-video.js +217 -0
  60. package/dist/protocols/system-one.d.ts +45 -1
  61. package/dist/protocols/system-one.js +42 -7
  62. package/dist/protocols/utils/gateway-protocol.js +1 -0
  63. package/dist/protocols/utils/responses-compaction.js +8 -4
  64. package/dist/protocols/xai-responses.d.ts +26 -0
  65. package/dist/protocols/xai-video.d.ts +12 -11
  66. package/dist/protocols/xai-video.js +33 -24
  67. package/dist/protocols/zai-messages.d.ts +24 -2
  68. package/dist/provider-error.js +7 -1
  69. package/dist/providers/alibaba.d.ts +50 -2
  70. package/dist/providers/amazon-bedrock-mantle.d.ts +50 -2
  71. package/dist/providers/anthropic-compatible.d.ts +24 -2
  72. package/dist/providers/anthropic.d.ts +24 -2
  73. package/dist/providers/azure.d.ts +76 -2
  74. package/dist/providers/byteplus/videos.d.ts +2 -0
  75. package/dist/providers/byteplus/videos.js +1 -0
  76. package/dist/providers/byteplus.d.ts +26 -0
  77. package/dist/providers/byteplus.js +21 -0
  78. package/dist/providers/cloudflare-ai-gateway.d.ts +100 -4
  79. package/dist/providers/digitalocean.d.ts +26 -0
  80. package/dist/providers/google/decisions.d.ts +2 -0
  81. package/dist/providers/google/decisions.js +1 -0
  82. package/dist/providers/google/videos.d.ts +2 -0
  83. package/dist/providers/google/videos.js +1 -0
  84. package/dist/providers/google-vertex-messages.d.ts +24 -2
  85. package/dist/providers/google-vertex-messages.js +1 -0
  86. package/dist/providers/google-vertex-responses.d.ts +26 -0
  87. package/dist/providers/google.d.ts +11 -4
  88. package/dist/providers/google.js +16 -3
  89. package/dist/providers/index.d.ts +2 -1
  90. package/dist/providers/index.js +2 -1
  91. package/dist/providers/meta.d.ts +50 -2
  92. package/dist/providers/minimax/videos.d.ts +3 -0
  93. package/dist/providers/minimax/videos.js +1 -0
  94. package/dist/providers/minimax.d.ts +56 -3
  95. package/dist/providers/minimax.js +10 -1
  96. package/dist/providers/moonshot.d.ts +50 -2
  97. package/dist/providers/openai-compatible/decisions.d.ts +2 -0
  98. package/dist/providers/openai-compatible/decisions.js +1 -0
  99. package/dist/providers/openai-compatible-responses.d.ts +26 -0
  100. package/dist/providers/openai-compatible.d.ts +2 -0
  101. package/dist/providers/openai-compatible.js +14 -0
  102. package/dist/providers/openai.d.ts +26 -0
  103. package/dist/providers/openrouter/videos.d.ts +2 -0
  104. package/dist/providers/openrouter/videos.js +1 -0
  105. package/dist/providers/openrouter.d.ts +31 -0
  106. package/dist/providers/openrouter.js +8 -0
  107. package/dist/providers/venice.d.ts +26 -0
  108. package/dist/providers/volcengine/videos.d.ts +2 -0
  109. package/dist/providers/volcengine/videos.js +1 -0
  110. package/dist/providers/volcengine.d.ts +26 -0
  111. package/dist/providers/volcengine.js +21 -0
  112. package/dist/providers/xai/videos.d.ts +2 -0
  113. package/dist/providers/xai/videos.js +1 -0
  114. package/dist/providers/xai.d.ts +4 -3
  115. package/dist/providers/xai.js +5 -1
  116. package/dist/providers/zai-coding-plan.d.ts +50 -2
  117. package/dist/public.d.ts +7 -4
  118. package/dist/public.js +2 -1
  119. package/dist/route/client.d.ts +2 -0
  120. package/dist/route/client.js +5 -1
  121. package/dist/route/executor-service.d.ts +20 -1
  122. package/dist/route/executor-service.js +35 -1
  123. package/dist/route/executor.d.ts +11 -2
  124. package/dist/route/executor.js +25 -5
  125. package/dist/route/media-protocol.d.ts +21 -15
  126. package/dist/route/media-protocol.js +11 -4
  127. package/dist/route/media.d.ts +2 -0
  128. package/dist/route/media.js +40 -22
  129. package/dist/route/protocol.d.ts +3 -0
  130. package/dist/route/transport/http.js +1 -1
  131. package/dist/schema/events.d.ts +5 -0
  132. package/dist/schema/messages.d.ts +25 -2
  133. package/dist/schema/messages.js +27 -7
  134. package/dist/schema/options.d.ts +18 -2
  135. package/dist/schema/options.js +1 -0
  136. package/dist/speech-client.d.ts +6 -6
  137. package/dist/speech-client.js +4 -4
  138. package/dist/speech.d.ts +7 -88
  139. package/dist/speech.js +1 -3
  140. package/dist/tool-updates.d.ts +34 -0
  141. package/dist/tool-updates.js +93 -0
  142. package/dist/tool.d.ts +6 -1
  143. package/dist/tool.js +1 -1
  144. package/dist/transcription-client.d.ts +6 -6
  145. package/dist/transcription-client.js +1 -2
  146. package/dist/transcription.d.ts +7 -88
  147. package/dist/transcription.js +1 -3
  148. package/dist/video-client.d.ts +16 -84
  149. package/dist/video-client.js +30 -13
  150. package/dist/video.d.ts +54 -1126
  151. package/dist/video.js +29 -65
  152. package/package.json +59 -7
  153. package/dist/protocols/google-video.d.ts +0 -26
  154. package/dist/protocols/google-video.js +0 -146
  155. package/dist/protocols/runway-video.d.ts +0 -38
  156. package/dist/protocols/runway-video.js +0 -141
  157. package/dist/providers/runway.d.ts +0 -20
  158. package/dist/providers/runway.js +0 -17
@@ -1,141 +0,0 @@
1
- import { Duration, Effect, Schema } from "effect";
2
- import { Media } from "../media.js";
3
- import { MediaProtocol } from "../route/media-protocol.js";
4
- import { MediaRoute } from "../route/media.js";
5
- import { mergeJsonRecords } from "../schema/index.js";
6
- import { VideoModel, VideoResponse } from "../video.js";
7
- import { ProviderShared, optionalArray, optionalNull } from "./shared.js";
8
- const route = MediaProtocol.identity({ id: "runway-video", name: "Runway", provider: "runway" });
9
- export const DEFAULT_BASE_URL = "https://api.dev.runwayml.com/v1";
10
- /** Every Runway request must pin the API version. */
11
- export const API_VERSION = "2024-11-06";
12
- export const TEXT_TO_VIDEO_PATH = "/text_to_video";
13
- export const IMAGE_TO_VIDEO_PATH = "/image_to_video";
14
- export const VIDEO_TO_VIDEO_PATH = "/video_to_video";
15
- export const TASKS_PATH = "/tasks";
16
- /** Output URLs are valid for 24–48 hours; the asset carries the conservative bound. */
17
- const OUTPUT_RETENTION = Duration.hours(24);
18
- // ---------------------------------------------------------------------------
19
- // 2. Token and response schemas
20
- // ---------------------------------------------------------------------------
21
- export const Token = Schema.Struct({ taskID: Schema.String });
22
- const Cost = Schema.Struct({ credits: Schema.Number });
23
- const StartResponse = Schema.Struct({ id: Schema.String });
24
- const Task = Schema.Struct({
25
- status: Schema.String,
26
- progress: optionalNull(Schema.Number),
27
- output: optionalArray(Schema.String),
28
- failure: optionalNull(Schema.String),
29
- failureCode: optionalNull(Schema.String),
30
- cost: Schema.optional(Cost),
31
- estimatedCost: Schema.optional(Cost),
32
- });
33
- const STATUS = {
34
- PENDING: "queued",
35
- THROTTLED: "queued",
36
- RUNNING: "running",
37
- SUCCEEDED: "completed",
38
- FAILED: "failed",
39
- CANCELLED: "cancelled",
40
- };
41
- // ---------------------------------------------------------------------------
42
- // 5. Request body construction
43
- // ---------------------------------------------------------------------------
44
- // Runway accepts HTTPS URLs, `runway://` upload URIs, and data URIs, all as one string.
45
- const mediaUri = (asset) => ProviderShared.mediaReference(asset, route.provider, route.name).pipe(Effect.map((reference) => reference.value));
46
- const fromRequest = Effect.fn("RunwayVideo.fromRequest")(function* (request) {
47
- const first = request.frames?.first === undefined ? undefined : yield* mediaUri(request.frames.first);
48
- const last = request.frames?.last === undefined ? undefined : yield* mediaUri(request.frames.last);
49
- const promptImage = [
50
- ...(first === undefined ? [] : [{ uri: first, position: "first" }]),
51
- ...(last === undefined ? [] : [{ uri: last, position: "last" }]),
52
- ];
53
- const videoUri = request.video === undefined ? undefined : yield* mediaUri(request.video);
54
- const references = yield* Effect.forEach(request.references ?? [], (asset) => mediaUri(asset).pipe(Effect.map((uri) => ({ uri }))));
55
- return MediaProtocol.json(mergeJsonRecords({
56
- model: request.model.id,
57
- promptText: request.prompt,
58
- promptImage: promptImage.length === 0 ? undefined : promptImage,
59
- videoUri,
60
- references: references.length === 0 ? undefined : references,
61
- ratio: request.aspect,
62
- duration: request.durationSeconds,
63
- resolution: request.resolution,
64
- audio: request.audio,
65
- negativePrompt: request.negativePrompt,
66
- seed: request.seed,
67
- }, request.providerOptions, request.http?.body) ?? {});
68
- });
69
- // ---------------------------------------------------------------------------
70
- // 6. Response decoding
71
- // ---------------------------------------------------------------------------
72
- const decodeStart = route.decodeStarted(StartResponse, (value) => ({
73
- token: { taskID: value.id },
74
- snapshot: { id: value.id, status: "queued" },
75
- }));
76
- const decodeTask = route.decodeJson(Task);
77
- const decodeStatus = Effect.fn("RunwayVideo.decodeStatus")(function* (response, context) {
78
- const output = yield* decodeTask(response);
79
- const status = MediaProtocol.status(STATUS, output.value.status);
80
- return { id: context.token.taskID, status, progress: output.value.progress ?? undefined };
81
- });
82
- const decodeResult = Effect.fn("RunwayVideo.decodeResult")(function* (response, context) {
83
- const output = yield* decodeTask(response);
84
- const task = output.value;
85
- const status = MediaProtocol.status(STATUS, task.status);
86
- if (status === "failed") {
87
- const code = task.failureCode ?? undefined;
88
- const message = `${route.name} task failed${code === undefined ? "" : ` (${code})`}${task.failure ? `: ${task.failure}` : ""}`;
89
- // Runway failure codes are dotted paths; every moderation outcome carries a SAFETY segment.
90
- if (code !== undefined && /(^|\.)SAFETY(\.|$)/.test(code))
91
- return yield* output.contentPolicy(message);
92
- // ASSET.INVALID rejects the caller's input media; Runway documents it as not retryable.
93
- return yield* output.ended("failed", message, code !== undefined && /^ASSET\.INVALID(\.|$)/.test(code) ? "InvalidRequest" : "ProviderInternal");
94
- }
95
- if (status === "cancelled")
96
- return yield* output.ended("cancelled", `${route.name} task ${context.token.taskID} was cancelled`);
97
- if (status !== "completed")
98
- return yield* output.pending(context.token.taskID);
99
- const urls = task.output ?? [];
100
- if (urls.length === 0)
101
- return yield* output.invalid(`${route.name} task succeeded without any output`);
102
- return new VideoResponse({
103
- videos: yield* Effect.forEach(urls, (url) => MediaProtocol.expiringUrl(url, OUTPUT_RETENTION, { mediaType: "video/mp4" })),
104
- usage: task.cost === undefined ? undefined : { type: "credits", credits: task.cost.credits },
105
- providerMetadata: {
106
- runway: {
107
- taskId: context.token.taskID,
108
- estimatedCredits: task.estimatedCost?.credits,
109
- },
110
- },
111
- });
112
- });
113
- // ---------------------------------------------------------------------------
114
- // 7. Protocol and route
115
- // ---------------------------------------------------------------------------
116
- const taskPath = (token) => `${TASKS_PATH}/${token.taskID}`;
117
- export const protocol = MediaProtocol.queued(route, {
118
- token: Token,
119
- unsupported: ["n"],
120
- start: { body: { from: fromRequest }, decode: decodeStart },
121
- status: { path: taskPath, decode: decodeStatus },
122
- result: { path: taskPath, decode: decodeResult },
123
- cancel: { method: "DELETE", path: taskPath, activeOnly: true },
124
- });
125
- const startPath = (request) => {
126
- if (request.video !== undefined)
127
- return VIDEO_TO_VIDEO_PATH;
128
- if (request.frames?.first !== undefined || request.frames?.last !== undefined)
129
- return IMAGE_TO_VIDEO_PATH;
130
- return TEXT_TO_VIDEO_PATH;
131
- };
132
- export const model = (input) => VideoModel.fromRoute({
133
- protocol,
134
- baseURL: DEFAULT_BASE_URL,
135
- headers: { "X-Runway-Version": API_VERSION },
136
- path: ({ request }) => startPath(request),
137
- }, input);
138
- export const RunwayVideo = {
139
- protocol,
140
- model,
141
- };
@@ -1,20 +0,0 @@
1
- import { type ProviderAuthOption } from "../route/auth-options.js";
2
- import { type HttpOptions, type ModelID } from "../schema/index.js";
3
- export type { RunwayVideoOptions } from "../protocols/runway-video.js";
4
- export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
5
- export type Config = ProviderAuthOption<"optional"> & {
6
- readonly baseURL?: string;
7
- readonly headers?: Record<string, string>;
8
- readonly http?: HttpOptions;
9
- };
10
- export declare const configure: (input?: Config) => {
11
- id: string & import("effect/Brand").Brand<"AI.ProviderID">;
12
- video: (modelID: string | ModelID) => import("../video.js").VideoModel<import("../protocols/runway-video.js").RunwayVideoOptions>;
13
- configure: typeof configure;
14
- };
15
- export declare const provider: {
16
- id: string & import("effect/Brand").Brand<"AI.ProviderID">;
17
- video: (modelID: string | ModelID) => import("../video.js").VideoModel<import("../protocols/runway-video.js").RunwayVideoOptions>;
18
- configure: typeof configure;
19
- };
20
- export declare const video: (modelID: string | ModelID) => import("../video.js").VideoModel<import("../protocols/runway-video.js").RunwayVideoOptions>;
@@ -1,17 +0,0 @@
1
- import { AuthOptions } from "../route/auth-options.js";
2
- import { MediaRoute } from "../route/media.js";
3
- import { ProviderID } from "../schema/index.js";
4
- import { RunwayVideo } from "../protocols/runway-video.js";
5
- export const id = ProviderID.make("runway");
6
- const auth = (options) => AuthOptions.bearer(options, "RUNWAYML_API_SECRET");
7
- export const configure = (input = {}) => {
8
- const media = MediaRoute.deployment(input, auth(input));
9
- const video = (modelID) => RunwayVideo.model({ ...media, id: modelID });
10
- return {
11
- id,
12
- video,
13
- configure,
14
- };
15
- };
16
- export const provider = configure();
17
- export const video = provider.video;