@opencode/ai 0.0.0-dev-536 → 0.0.0-dev-544

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 (67) hide show
  1. package/README.md +16 -2
  2. package/dist/cache-policy.js +15 -3
  3. package/dist/decision.d.ts +12 -10
  4. package/dist/decision.js +10 -4
  5. package/dist/experimental/extraction.d.ts +3 -7
  6. package/dist/experimental/extraction.js +2 -3
  7. package/dist/image.d.ts +5 -7
  8. package/dist/image.js +2 -3
  9. package/dist/llm.d.ts +3 -6
  10. package/dist/llm.js +5 -2
  11. package/dist/loop.js +5 -4
  12. package/dist/media-model.d.ts +1 -1
  13. package/dist/media-model.js +1 -1
  14. package/dist/media.d.ts +9 -0
  15. package/dist/media.js +37 -2
  16. package/dist/protocols/anthropic-messages.js +3 -12
  17. package/dist/protocols/bedrock-converse.js +0 -4
  18. package/dist/protocols/gemini.js +0 -4
  19. package/dist/protocols/meta-responses.js +22 -20
  20. package/dist/protocols/mistral-chat.js +0 -3
  21. package/dist/protocols/open-responses.d.ts +1 -1
  22. package/dist/protocols/open-responses.js +4 -6
  23. package/dist/protocols/openai-chat.d.ts +3 -3
  24. package/dist/protocols/openai-chat.js +7 -25
  25. package/dist/protocols/shared.js +11 -9
  26. package/dist/protocols/utils/responses-compaction.js +3 -3
  27. package/dist/protocols/utils/tool-stream.d.ts +2 -2
  28. package/dist/providers/assemblyai.d.ts +1 -1
  29. package/dist/providers/azure.js +2 -2
  30. package/dist/providers/cartesia.d.ts +1 -1
  31. package/dist/providers/deepgram.d.ts +1 -1
  32. package/dist/providers/elevenlabs.d.ts +1 -1
  33. package/dist/providers/openai.js +2 -2
  34. package/dist/providers/opencode.d.ts +2 -2
  35. package/dist/providers/opencode.js +1 -1
  36. package/dist/providers/runway.d.ts +1 -1
  37. package/dist/providers/typesafe-ai.d.ts +2 -2
  38. package/dist/providers/typesafe-ai.js +1 -1
  39. package/dist/public.d.ts +3 -3
  40. package/dist/public.js +1 -1
  41. package/dist/route/client.d.ts +3 -7
  42. package/dist/route/client.js +11 -24
  43. package/dist/route/decision.d.ts +2 -2
  44. package/dist/route/decision.js +3 -3
  45. package/dist/route/executor.d.ts +5 -0
  46. package/dist/route/executor.js +10 -0
  47. package/dist/route/index.d.ts +1 -1
  48. package/dist/route/index.js +1 -1
  49. package/dist/route/media.d.ts +7 -11
  50. package/dist/route/media.js +22 -26
  51. package/dist/route/transport/http.js +6 -5
  52. package/dist/schema/events.d.ts +63 -40
  53. package/dist/schema/events.js +3 -3
  54. package/dist/schema/messages.d.ts +181 -32
  55. package/dist/schema/messages.js +65 -23
  56. package/dist/schema/options.d.ts +42 -30
  57. package/dist/schema/options.js +27 -56
  58. package/dist/speech.d.ts +3 -7
  59. package/dist/speech.js +1 -3
  60. package/dist/testing.d.ts +8 -8
  61. package/dist/tool-history.d.ts +1 -1
  62. package/dist/tool-history.js +3 -9
  63. package/dist/transcription.d.ts +3 -8
  64. package/dist/transcription.js +1 -3
  65. package/dist/video.d.ts +3 -7
  66. package/dist/video.js +1 -3
  67. package/package.json +3 -3
package/dist/speech.js CHANGED
@@ -3,7 +3,7 @@ import { ProgressEvent, QueuedEvent } from "./generation.js";
3
3
  import { Media } from "./media.js";
4
4
  import { MediaModel, composeRoute, tryRequest } from "./media-model.js";
5
5
  import { MediaRoute } from "./route/media.js";
6
- import { AIError, HttpOptions, MediaUsage, ProviderMetadata, ProviderOptions } from "./schema/index.js";
6
+ import { AIError, MediaUsage, ProviderMetadata, ProviderOptions, } from "./schema/index.js";
7
7
  import { SpeechClient, Service } from "./speech-client.js";
8
8
  export class SpeechModel extends MediaModel {
9
9
  static fromRoute(route, input) {
@@ -42,7 +42,6 @@ const SpeechRequestSchema = Schema.Struct({
42
42
  instructions: Schema.optional(Schema.String),
43
43
  timestamps: Schema.optional(Schema.Boolean),
44
44
  providerOptions: Schema.optional(ProviderOptions),
45
- http: Schema.optional(HttpOptions),
46
45
  });
47
46
  // ---------------------------------------------------------------------------
48
47
  // Response and events
@@ -105,7 +104,6 @@ const collectResponse = (events) => {
105
104
  /** Normalize speech request input into a plain `SpeechRequest`. */
106
105
  export const request = (input) => ({
107
106
  ...input,
108
- http: HttpOptions.make(input.http),
109
107
  });
110
108
  const validate = Schema.decodeUnknownSync(SpeechRequestSchema);
111
109
  const requestEffect = (input) => tryRequest(() => {
package/dist/testing.d.ts CHANGED
@@ -208,7 +208,7 @@ export declare const complete: (options: {
208
208
  readonly explanation?: string | undefined;
209
209
  };
210
210
  readonly usage?: import("./schema/events.js").Usage | undefined;
211
- readonly message?: import("./schema/messages.js").Message | undefined;
211
+ readonly message?: import("./schema/messages.js").AssistantMessage | undefined;
212
212
  readonly providerMetadata?: {
213
213
  readonly [x: string]: {
214
214
  readonly [x: string]: unknown;
@@ -407,7 +407,7 @@ export declare const stop: (...events: readonly LLMEvent[]) => ({
407
407
  readonly explanation?: string | undefined;
408
408
  };
409
409
  readonly usage?: import("./schema/events.js").Usage | undefined;
410
- readonly message?: import("./schema/messages.js").Message | undefined;
410
+ readonly message?: import("./schema/messages.js").AssistantMessage | undefined;
411
411
  readonly providerMetadata?: {
412
412
  readonly [x: string]: {
413
413
  readonly [x: string]: unknown;
@@ -606,7 +606,7 @@ export declare const toolCalls: (...events: readonly LLMEvent[]) => ({
606
606
  readonly explanation?: string | undefined;
607
607
  };
608
608
  readonly usage?: import("./schema/events.js").Usage | undefined;
609
- readonly message?: import("./schema/messages.js").Message | undefined;
609
+ readonly message?: import("./schema/messages.js").AssistantMessage | undefined;
610
610
  readonly providerMetadata?: {
611
611
  readonly [x: string]: {
612
612
  readonly [x: string]: unknown;
@@ -805,7 +805,7 @@ export declare const text: (value: string, id: string) => ({
805
805
  readonly explanation?: string | undefined;
806
806
  };
807
807
  readonly usage?: import("./schema/events.js").Usage | undefined;
808
- readonly message?: import("./schema/messages.js").Message | undefined;
808
+ readonly message?: import("./schema/messages.js").AssistantMessage | undefined;
809
809
  readonly providerMetadata?: {
810
810
  readonly [x: string]: {
811
811
  readonly [x: string]: unknown;
@@ -1004,7 +1004,7 @@ export declare const textWithUsage: (value: string, id: string, inputTokens: num
1004
1004
  readonly explanation?: string | undefined;
1005
1005
  };
1006
1006
  readonly usage?: import("./schema/events.js").Usage | undefined;
1007
- readonly message?: import("./schema/messages.js").Message | undefined;
1007
+ readonly message?: import("./schema/messages.js").AssistantMessage | undefined;
1008
1008
  readonly providerMetadata?: {
1009
1009
  readonly [x: string]: {
1010
1010
  readonly [x: string]: unknown;
@@ -1203,7 +1203,7 @@ export declare const toolCall: (id: string, name: string, input: unknown) => ({
1203
1203
  readonly explanation?: string | undefined;
1204
1204
  };
1205
1205
  readonly usage?: import("./schema/events.js").Usage | undefined;
1206
- readonly message?: import("./schema/messages.js").Message | undefined;
1206
+ readonly message?: import("./schema/messages.js").AssistantMessage | undefined;
1207
1207
  readonly providerMetadata?: {
1208
1208
  readonly [x: string]: {
1209
1209
  readonly [x: string]: unknown;
@@ -1402,7 +1402,7 @@ export declare const failAfter: (error: AIError, ...events: readonly LLMEvent[])
1402
1402
  readonly explanation?: string | undefined;
1403
1403
  };
1404
1404
  readonly usage?: import("./schema/events.js").Usage | undefined;
1405
- readonly message?: import("./schema/messages.js").Message | undefined;
1405
+ readonly message?: import("./schema/messages.js").AssistantMessage | undefined;
1406
1406
  readonly providerMetadata?: {
1407
1407
  readonly [x: string]: {
1408
1408
  readonly [x: string]: unknown;
@@ -1601,7 +1601,7 @@ export declare const hangAfter: (...events: readonly LLMEvent[]) => Stream.Strea
1601
1601
  readonly explanation?: string | undefined;
1602
1602
  };
1603
1603
  readonly usage?: import("./schema/events.js").Usage | undefined;
1604
- readonly message?: import("./schema/messages.js").Message | undefined;
1604
+ readonly message?: import("./schema/messages.js").AssistantMessage | undefined;
1605
1605
  readonly providerMetadata?: {
1606
1606
  readonly [x: string]: {
1607
1607
  readonly [x: string]: unknown;
@@ -1,2 +1,2 @@
1
- import { Message } from "./schema/messages.js";
1
+ import { type Message } from "./schema/messages.js";
2
2
  export declare function normalizeToolHistory(messages: ReadonlyArray<Message>): readonly Message[];
@@ -1,4 +1,4 @@
1
- import { Message, ToolResultPart } from "./schema/messages.js";
1
+ import { ToolMessage, ToolResultPart } from "./schema/messages.js";
2
2
  const EMPTY_TOOL_OUTPUT = "(no tool output)";
3
3
  const MISSING_TOOL_RESULT = "Tool result missing";
4
4
  export function normalizeToolHistory(messages) {
@@ -46,7 +46,7 @@ export function normalizeToolHistory(messages) {
46
46
  : normalized;
47
47
  }
48
48
  function missingToolResults(calls) {
49
- return new Message({
49
+ return new ToolMessage({
50
50
  role: "tool",
51
51
  content: [...calls].map((call) => ToolResultPart.make({
52
52
  id: call.id,
@@ -70,13 +70,7 @@ function normalizeToolMessage(message, pending) {
70
70
  return undefined;
71
71
  if (content.every((part, index) => part === message.content[index]))
72
72
  return message;
73
- return new Message({
74
- id: message.id,
75
- role: message.role,
76
- content,
77
- providerMetadata: message.providerMetadata,
78
- native: message.native,
79
- });
73
+ return new ToolMessage({ ...message, content });
80
74
  }
81
75
  function normalizeToolResult(part, call) {
82
76
  const named = call === undefined || (part.name === call.name && part.namespace === call.namespace)
@@ -3,7 +3,7 @@ import { Generation, type AwaitOptions } from "./generation.js";
3
3
  import { Media } from "./media.js";
4
4
  import { MediaModel } from "./media-model.js";
5
5
  import { MediaRoute } from "./route/media.js";
6
- import { AIError, HttpOptions } from "./schema/index.js";
6
+ import { AIError, type BaseRequest } from "./schema/index.js";
7
7
  import { Service } from "./transcription-client.js";
8
8
  export type TranscriptionOptions = MediaModel.Options;
9
9
  export type TranscriptionRoute = MediaRoute.AnyRoute<TranscriptionRequest, TranscriptionEvent, TranscriptionResponse>;
@@ -65,18 +65,13 @@ declare const TranscriptionRequestSchema: Schema.Struct<{
65
65
  readonly diarize: Schema.optional<Schema.Boolean>;
66
66
  readonly speakers: Schema.optional<Schema.Int>;
67
67
  readonly providerOptions: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
68
- readonly http: Schema.optional<typeof HttpOptions>;
69
68
  }>;
70
69
  /** A normalized transcription request, the plain object `Transcription.request(...)` returns. */
71
- export type TranscriptionRequest<Model extends TranscriptionModel = TranscriptionModel> = Omit<typeof TranscriptionRequestSchema.Type, "model" | "providerOptions"> & {
72
- readonly model: Model;
73
- readonly providerOptions?: TranscriptionModelOptions<Model>;
74
- };
70
+ export type TranscriptionRequest<Model extends TranscriptionModel = TranscriptionModel> = Omit<typeof TranscriptionRequestSchema.Type, "model" | "providerOptions"> & BaseRequest<Model, TranscriptionModelOptions<Model>>;
75
71
  export type TranscriptionModelOptions<Model> = Model extends TranscriptionModel<infer Options> ? Options : never;
76
72
  /** Input accepted by `Transcription.request` and the calls; a `TranscriptionRequest` is also a valid input. */
77
- export type TranscriptionRequestInput<Model extends TranscriptionModel = TranscriptionModel> = Omit<TranscriptionRequest<Model>, "providerOptions" | "http"> & {
73
+ export type TranscriptionRequestInput<Model extends TranscriptionModel = TranscriptionModel> = Omit<TranscriptionRequest<Model>, "providerOptions"> & {
78
74
  readonly providerOptions?: NoInfer<TranscriptionModelOptions<Model>>;
79
- readonly http?: HttpOptions.Input;
80
75
  };
81
76
  /** Speaker labels are provider-native (`A`, `0`, `spk:0`, `speaker_0`, or a known speaker name). */
82
77
  export declare const TranscriptionSegment: Schema.Struct<{
@@ -3,7 +3,7 @@ import { Generation, ProgressEvent, QueuedEvent } from "./generation.js";
3
3
  import { Media } from "./media.js";
4
4
  import { MediaModel, composeRoute, tryRequest } from "./media-model.js";
5
5
  import { MediaRoute } from "./route/media.js";
6
- import { AIError, HttpOptions, MediaUsage, ProviderMetadata, ProviderOptions } from "./schema/index.js";
6
+ import { AIError, MediaUsage, ProviderMetadata, ProviderOptions } from "./schema/index.js";
7
7
  import { TranscriptionClient, Service } from "./transcription-client.js";
8
8
  export class TranscriptionModel extends MediaModel {
9
9
  static fromRoute(route, input) {
@@ -31,7 +31,6 @@ const TranscriptionRequestSchema = Schema.Struct({
31
31
  diarize: Schema.optional(Schema.Boolean),
32
32
  speakers: Schema.optional(Schema.Int),
33
33
  providerOptions: Schema.optional(ProviderOptions),
34
- http: Schema.optional(HttpOptions),
35
34
  });
36
35
  // ---------------------------------------------------------------------------
37
36
  // Response and events
@@ -104,7 +103,6 @@ const collectResponse = (events) => {
104
103
  /** Normalize transcription request input into a plain `TranscriptionRequest`. */
105
104
  export const request = (input) => ({
106
105
  ...input,
107
- http: HttpOptions.make(input.http),
108
106
  });
109
107
  const validate = Schema.decodeUnknownSync(TranscriptionRequestSchema);
110
108
  const requestEffect = (input) => tryRequest(() => {
package/dist/video.d.ts CHANGED
@@ -3,7 +3,7 @@ import { Generation, type AwaitOptions } from "./generation.js";
3
3
  import { Media } from "./media.js";
4
4
  import { MediaModel } from "./media-model.js";
5
5
  import { MediaRoute } from "./route/media.js";
6
- import { AIError, HttpOptions, type OpenString } from "./schema/index.js";
6
+ import { AIError, type OpenString, type BaseRequest } from "./schema/index.js";
7
7
  import { Service } from "./video-client.js";
8
8
  export type VideoOptions = MediaModel.Options;
9
9
  export type VideoRoute = MediaRoute.AnyRoute<VideoRequest, VideoEvent, VideoResponse>;
@@ -232,19 +232,15 @@ declare const VideoRequestSchema: Schema.Struct<{
232
232
  readonly seed: Schema.optional<Schema.Number>;
233
233
  readonly negativePrompt: Schema.optional<Schema.String>;
234
234
  readonly providerOptions: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
235
- readonly http: Schema.optional<typeof HttpOptions>;
236
235
  }>;
237
236
  /** A normalized video request, the plain object `Video.request(...)` returns. */
238
- export type VideoRequest<Model extends VideoModel = VideoModel> = Omit<typeof VideoRequestSchema.Type, "model" | "providerOptions" | "resolution"> & {
239
- readonly model: Model;
237
+ export type VideoRequest<Model extends VideoModel = VideoModel> = Omit<typeof VideoRequestSchema.Type, "model" | "providerOptions" | "resolution"> & BaseRequest<Model, VideoModelOptions<Model>> & {
240
238
  readonly resolution?: VideoResolution;
241
- readonly providerOptions?: VideoModelOptions<Model>;
242
239
  };
243
240
  export type VideoModelOptions<Model> = Model extends VideoModel<infer Options> ? Options : never;
244
241
  /** Input accepted by `Video.request` and the calls; a `VideoRequest` is also a valid input. */
245
- export type VideoRequestInput<Model extends VideoModel = VideoModel> = Omit<VideoRequest<Model>, "providerOptions" | "http"> & {
242
+ export type VideoRequestInput<Model extends VideoModel = VideoModel> = Omit<VideoRequest<Model>, "providerOptions"> & {
246
243
  readonly providerOptions?: NoInfer<VideoModelOptions<Model>>;
247
- readonly http?: HttpOptions.Input;
248
244
  };
249
245
  declare const VideoResponse_base: Schema.Class<VideoResponse, Schema.Struct<{
250
246
  readonly videos: Schema.$Array<Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
package/dist/video.js CHANGED
@@ -3,7 +3,7 @@ import { Generation, ProgressEvent, QueuedEvent } from "./generation.js";
3
3
  import { Media } from "./media.js";
4
4
  import { MediaModel, composeRoute, tryRequest } from "./media-model.js";
5
5
  import { MediaRoute } from "./route/media.js";
6
- import { AIError, HttpOptions, MediaUsage, ProviderMetadata, ProviderOptions } from "./schema/index.js";
6
+ import { AIError, MediaUsage, ProviderMetadata, ProviderOptions, } from "./schema/index.js";
7
7
  import { VideoClient, Service } from "./video-client.js";
8
8
  export class VideoModel extends MediaModel {
9
9
  static fromRoute(route, input) {
@@ -42,7 +42,6 @@ const VideoRequestSchema = Schema.Struct({
42
42
  seed: Schema.optional(Schema.Number),
43
43
  negativePrompt: Schema.optional(Schema.String),
44
44
  providerOptions: Schema.optional(ProviderOptions),
45
- http: Schema.optional(HttpOptions),
46
45
  });
47
46
  // ---------------------------------------------------------------------------
48
47
  // Response and events
@@ -92,7 +91,6 @@ const collectResponse = (events) => {
92
91
  /** Normalize video request input into a plain `VideoRequest`. */
93
92
  export const request = (input) => ({
94
93
  ...input,
95
- http: HttpOptions.make(input.http),
96
94
  });
97
95
  const validate = Schema.decodeUnknownSync(VideoRequestSchema);
98
96
  const requestEffect = (input) => tryRequest(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "0.0.0-dev-536",
3
+ "version": "0.0.0-dev-544",
4
4
  "name": "@opencode/ai",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -520,7 +520,7 @@
520
520
  "devDependencies": {
521
521
  "@clack/prompts": "1.0.0-alpha.1",
522
522
  "@effect/platform-node": "4.1.0",
523
- "@opencode/http-recorder": "0.0.0-dev-536",
523
+ "@opencode/http-recorder": "0.0.0-dev-544",
524
524
  "@tsconfig/bun": "1.0.9",
525
525
  "@types/bun": "1.4.3",
526
526
  "@typescript/native": "npm:typescript@7.1.0-beta",
@@ -530,7 +530,7 @@
530
530
  "@aws-sdk/credential-providers": "3.1057.0",
531
531
  "@smithy/eventstream-codec": "4.2.14",
532
532
  "@smithy/util-utf8": "4.2.2",
533
- "@opencode/schema": "0.0.0-dev-536",
533
+ "@opencode/schema": "0.0.0-dev-544",
534
534
  "aws4fetch": "1.0.20",
535
535
  "effect": "4.1.0",
536
536
  "google-auth-library": "10.5.0"