@opencode/ai 0.0.0-dev-466 → 0.0.0-dev-468

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 (87) hide show
  1. package/README.md +27 -16
  2. package/dist/cache-policy.d.ts +1 -1
  3. package/dist/cache-policy.js +2 -2
  4. package/dist/decision-client.d.ts +3 -3
  5. package/dist/decision.d.ts +13 -120
  6. package/dist/decision.js +17 -13
  7. package/dist/effect.d.ts +8 -6
  8. package/dist/effect.js +4 -3
  9. package/dist/effort-updates.d.ts +1 -1
  10. package/dist/effort-updates.js +2 -2
  11. package/dist/experimental/cloudflare-run-extraction.d.ts +7 -3
  12. package/dist/experimental/cloudflare-run-extraction.js +4 -1
  13. package/dist/experimental/extraction.d.ts +12 -38
  14. package/dist/experimental/extraction.js +13 -11
  15. package/dist/experimental.d.ts +8 -8
  16. package/dist/experimental.js +4 -4
  17. package/dist/image-client.d.ts +11 -5
  18. package/dist/image-client.js +1 -1
  19. package/dist/image.d.ts +21 -62
  20. package/dist/image.js +16 -13
  21. package/dist/index.d.ts +20 -14
  22. package/dist/index.js +6 -3
  23. package/dist/llm.d.ts +60 -25
  24. package/dist/llm.js +126 -38
  25. package/dist/protocols/alibaba-images.d.ts +2 -2
  26. package/dist/protocols/alibaba-messages.js +3 -3
  27. package/dist/protocols/anthropic-messages.d.ts +1 -1
  28. package/dist/protocols/anthropic-messages.js +4 -3
  29. package/dist/protocols/assemblyai-transcription.d.ts +2 -2
  30. package/dist/protocols/cartesia-speech.d.ts +2 -2
  31. package/dist/protocols/cloudflare-workers-ai-images.d.ts +2 -2
  32. package/dist/protocols/deepgram-speech.d.ts +2 -2
  33. package/dist/protocols/deepgram-transcription.d.ts +2 -2
  34. package/dist/protocols/elevenlabs-speech.d.ts +2 -2
  35. package/dist/protocols/elevenlabs-transcription.d.ts +2 -2
  36. package/dist/protocols/gemini.js +2 -8
  37. package/dist/protocols/google-images.d.ts +2 -2
  38. package/dist/protocols/google-speech.d.ts +2 -2
  39. package/dist/protocols/google-transcription.d.ts +2 -2
  40. package/dist/protocols/google-video.d.ts +2 -2
  41. package/dist/protocols/meta-images.d.ts +2 -2
  42. package/dist/protocols/meta-responses.js +4 -3
  43. package/dist/protocols/minimax-images.d.ts +2 -2
  44. package/dist/protocols/open-responses.d.ts +1 -21
  45. package/dist/protocols/openai-chat.d.ts +1 -21
  46. package/dist/protocols/openai-chat.js +7 -9
  47. package/dist/protocols/openai-decisions.js +1 -1
  48. package/dist/protocols/openai-images.d.ts +2 -2
  49. package/dist/protocols/openai-responses.js +0 -1
  50. package/dist/protocols/openai-speech.d.ts +2 -2
  51. package/dist/protocols/openai-transcription.d.ts +2 -2
  52. package/dist/protocols/runway-video.d.ts +2 -2
  53. package/dist/protocols/shared.d.ts +1 -1
  54. package/dist/protocols/shared.js +2 -2
  55. package/dist/protocols/system-one.d.ts +4 -4
  56. package/dist/protocols/utils/responses-checkpoint.js +1 -1
  57. package/dist/protocols/utils/responses-compaction.d.ts +1 -1
  58. package/dist/protocols/utils/responses-compaction.js +4 -3
  59. package/dist/protocols/utils/tool-stream.d.ts +3 -63
  60. package/dist/protocols/xai-images.d.ts +2 -2
  61. package/dist/protocols/xai-video.d.ts +2 -2
  62. package/dist/protocols/zai-images.d.ts +2 -2
  63. package/dist/protocols/zai-messages.js +3 -3
  64. package/dist/provider-error.js +4 -4
  65. package/dist/providers/vercel-ai-gateway.js +4 -3
  66. package/dist/route/client.d.ts +43 -19
  67. package/dist/route/client.js +30 -18
  68. package/dist/route/decision.d.ts +6 -6
  69. package/dist/schema/errors.d.ts +1 -2
  70. package/dist/schema/errors.js +1 -2
  71. package/dist/schema/events.d.ts +61 -769
  72. package/dist/schema/events.js +3 -30
  73. package/dist/schema/messages.d.ts +20 -92
  74. package/dist/schema/messages.js +1 -52
  75. package/dist/speech-client.d.ts +5 -5
  76. package/dist/speech.d.ts +17 -19
  77. package/dist/speech.js +16 -12
  78. package/dist/testing.d.ts +8 -168
  79. package/dist/tool-runtime.js +12 -30
  80. package/dist/transcription-client.d.ts +5 -5
  81. package/dist/transcription.d.ts +17 -19
  82. package/dist/transcription.js +16 -12
  83. package/dist/video-client.d.ts +5 -5
  84. package/dist/video-client.js +1 -1
  85. package/dist/video.d.ts +18 -20
  86. package/dist/video.js +16 -12
  87. package/package.json +3 -3
package/dist/testing.d.ts CHANGED
@@ -184,18 +184,6 @@ export declare const complete: (options: {
184
184
  readonly [x: string]: unknown;
185
185
  };
186
186
  } | undefined;
187
- } | {
188
- readonly type: "tool-error";
189
- readonly id: string;
190
- readonly name: string;
191
- readonly namespace?: string | undefined;
192
- readonly message: string;
193
- readonly error?: unknown;
194
- readonly providerMetadata?: {
195
- readonly [x: string]: {
196
- readonly [x: string]: unknown;
197
- };
198
- } | undefined;
199
187
  } | {
200
188
  readonly type: "step-finish";
201
189
  readonly index: number;
@@ -220,6 +208,7 @@ export declare const complete: (options: {
220
208
  readonly explanation?: string | undefined;
221
209
  };
222
210
  readonly usage?: import("./schema/events.js").Usage | undefined;
211
+ readonly message?: import("./schema/messages.js").Message | undefined;
223
212
  readonly providerMetadata?: {
224
213
  readonly [x: string]: {
225
214
  readonly [x: string]: unknown;
@@ -233,15 +222,6 @@ export declare const complete: (options: {
233
222
  readonly [x: string]: unknown;
234
223
  };
235
224
  } | undefined;
236
- } | {
237
- readonly type: "provider-error";
238
- readonly message: string;
239
- readonly classification?: "context-overflow" | "payload-too-large" | undefined;
240
- readonly providerMetadata?: {
241
- readonly [x: string]: {
242
- readonly [x: string]: unknown;
243
- };
244
- } | undefined;
245
225
  } | ({
246
226
  readonly type: "compaction";
247
227
  readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
@@ -403,18 +383,6 @@ export declare const stop: (...events: readonly LLMEvent[]) => ({
403
383
  readonly [x: string]: unknown;
404
384
  };
405
385
  } | undefined;
406
- } | {
407
- readonly type: "tool-error";
408
- readonly id: string;
409
- readonly name: string;
410
- readonly namespace?: string | undefined;
411
- readonly message: string;
412
- readonly error?: unknown;
413
- readonly providerMetadata?: {
414
- readonly [x: string]: {
415
- readonly [x: string]: unknown;
416
- };
417
- } | undefined;
418
386
  } | {
419
387
  readonly type: "step-finish";
420
388
  readonly index: number;
@@ -439,6 +407,7 @@ export declare const stop: (...events: readonly LLMEvent[]) => ({
439
407
  readonly explanation?: string | undefined;
440
408
  };
441
409
  readonly usage?: import("./schema/events.js").Usage | undefined;
410
+ readonly message?: import("./schema/messages.js").Message | undefined;
442
411
  readonly providerMetadata?: {
443
412
  readonly [x: string]: {
444
413
  readonly [x: string]: unknown;
@@ -452,15 +421,6 @@ export declare const stop: (...events: readonly LLMEvent[]) => ({
452
421
  readonly [x: string]: unknown;
453
422
  };
454
423
  } | undefined;
455
- } | {
456
- readonly type: "provider-error";
457
- readonly message: string;
458
- readonly classification?: "context-overflow" | "payload-too-large" | undefined;
459
- readonly providerMetadata?: {
460
- readonly [x: string]: {
461
- readonly [x: string]: unknown;
462
- };
463
- } | undefined;
464
424
  } | ({
465
425
  readonly type: "compaction";
466
426
  readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
@@ -622,18 +582,6 @@ export declare const toolCalls: (...events: readonly LLMEvent[]) => ({
622
582
  readonly [x: string]: unknown;
623
583
  };
624
584
  } | undefined;
625
- } | {
626
- readonly type: "tool-error";
627
- readonly id: string;
628
- readonly name: string;
629
- readonly namespace?: string | undefined;
630
- readonly message: string;
631
- readonly error?: unknown;
632
- readonly providerMetadata?: {
633
- readonly [x: string]: {
634
- readonly [x: string]: unknown;
635
- };
636
- } | undefined;
637
585
  } | {
638
586
  readonly type: "step-finish";
639
587
  readonly index: number;
@@ -658,6 +606,7 @@ export declare const toolCalls: (...events: readonly LLMEvent[]) => ({
658
606
  readonly explanation?: string | undefined;
659
607
  };
660
608
  readonly usage?: import("./schema/events.js").Usage | undefined;
609
+ readonly message?: import("./schema/messages.js").Message | undefined;
661
610
  readonly providerMetadata?: {
662
611
  readonly [x: string]: {
663
612
  readonly [x: string]: unknown;
@@ -671,15 +620,6 @@ export declare const toolCalls: (...events: readonly LLMEvent[]) => ({
671
620
  readonly [x: string]: unknown;
672
621
  };
673
622
  } | undefined;
674
- } | {
675
- readonly type: "provider-error";
676
- readonly message: string;
677
- readonly classification?: "context-overflow" | "payload-too-large" | undefined;
678
- readonly providerMetadata?: {
679
- readonly [x: string]: {
680
- readonly [x: string]: unknown;
681
- };
682
- } | undefined;
683
623
  } | ({
684
624
  readonly type: "compaction";
685
625
  readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
@@ -841,18 +781,6 @@ export declare const text: (value: string, id: string) => ({
841
781
  readonly [x: string]: unknown;
842
782
  };
843
783
  } | undefined;
844
- } | {
845
- readonly type: "tool-error";
846
- readonly id: string;
847
- readonly name: string;
848
- readonly namespace?: string | undefined;
849
- readonly message: string;
850
- readonly error?: unknown;
851
- readonly providerMetadata?: {
852
- readonly [x: string]: {
853
- readonly [x: string]: unknown;
854
- };
855
- } | undefined;
856
784
  } | {
857
785
  readonly type: "step-finish";
858
786
  readonly index: number;
@@ -877,6 +805,7 @@ export declare const text: (value: string, id: string) => ({
877
805
  readonly explanation?: string | undefined;
878
806
  };
879
807
  readonly usage?: import("./schema/events.js").Usage | undefined;
808
+ readonly message?: import("./schema/messages.js").Message | undefined;
880
809
  readonly providerMetadata?: {
881
810
  readonly [x: string]: {
882
811
  readonly [x: string]: unknown;
@@ -890,15 +819,6 @@ export declare const text: (value: string, id: string) => ({
890
819
  readonly [x: string]: unknown;
891
820
  };
892
821
  } | undefined;
893
- } | {
894
- readonly type: "provider-error";
895
- readonly message: string;
896
- readonly classification?: "context-overflow" | "payload-too-large" | undefined;
897
- readonly providerMetadata?: {
898
- readonly [x: string]: {
899
- readonly [x: string]: unknown;
900
- };
901
- } | undefined;
902
822
  } | ({
903
823
  readonly type: "compaction";
904
824
  readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
@@ -1060,18 +980,6 @@ export declare const textWithUsage: (value: string, id: string, inputTokens: num
1060
980
  readonly [x: string]: unknown;
1061
981
  };
1062
982
  } | undefined;
1063
- } | {
1064
- readonly type: "tool-error";
1065
- readonly id: string;
1066
- readonly name: string;
1067
- readonly namespace?: string | undefined;
1068
- readonly message: string;
1069
- readonly error?: unknown;
1070
- readonly providerMetadata?: {
1071
- readonly [x: string]: {
1072
- readonly [x: string]: unknown;
1073
- };
1074
- } | undefined;
1075
983
  } | {
1076
984
  readonly type: "step-finish";
1077
985
  readonly index: number;
@@ -1096,6 +1004,7 @@ export declare const textWithUsage: (value: string, id: string, inputTokens: num
1096
1004
  readonly explanation?: string | undefined;
1097
1005
  };
1098
1006
  readonly usage?: import("./schema/events.js").Usage | undefined;
1007
+ readonly message?: import("./schema/messages.js").Message | undefined;
1099
1008
  readonly providerMetadata?: {
1100
1009
  readonly [x: string]: {
1101
1010
  readonly [x: string]: unknown;
@@ -1109,15 +1018,6 @@ export declare const textWithUsage: (value: string, id: string, inputTokens: num
1109
1018
  readonly [x: string]: unknown;
1110
1019
  };
1111
1020
  } | undefined;
1112
- } | {
1113
- readonly type: "provider-error";
1114
- readonly message: string;
1115
- readonly classification?: "context-overflow" | "payload-too-large" | undefined;
1116
- readonly providerMetadata?: {
1117
- readonly [x: string]: {
1118
- readonly [x: string]: unknown;
1119
- };
1120
- } | undefined;
1121
1021
  } | ({
1122
1022
  readonly type: "compaction";
1123
1023
  readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
@@ -1279,18 +1179,6 @@ export declare const toolCall: (id: string, name: string, input: unknown) => ({
1279
1179
  readonly [x: string]: unknown;
1280
1180
  };
1281
1181
  } | undefined;
1282
- } | {
1283
- readonly type: "tool-error";
1284
- readonly id: string;
1285
- readonly name: string;
1286
- readonly namespace?: string | undefined;
1287
- readonly message: string;
1288
- readonly error?: unknown;
1289
- readonly providerMetadata?: {
1290
- readonly [x: string]: {
1291
- readonly [x: string]: unknown;
1292
- };
1293
- } | undefined;
1294
1182
  } | {
1295
1183
  readonly type: "step-finish";
1296
1184
  readonly index: number;
@@ -1315,6 +1203,7 @@ export declare const toolCall: (id: string, name: string, input: unknown) => ({
1315
1203
  readonly explanation?: string | undefined;
1316
1204
  };
1317
1205
  readonly usage?: import("./schema/events.js").Usage | undefined;
1206
+ readonly message?: import("./schema/messages.js").Message | undefined;
1318
1207
  readonly providerMetadata?: {
1319
1208
  readonly [x: string]: {
1320
1209
  readonly [x: string]: unknown;
@@ -1328,15 +1217,6 @@ export declare const toolCall: (id: string, name: string, input: unknown) => ({
1328
1217
  readonly [x: string]: unknown;
1329
1218
  };
1330
1219
  } | undefined;
1331
- } | {
1332
- readonly type: "provider-error";
1333
- readonly message: string;
1334
- readonly classification?: "context-overflow" | "payload-too-large" | undefined;
1335
- readonly providerMetadata?: {
1336
- readonly [x: string]: {
1337
- readonly [x: string]: unknown;
1338
- };
1339
- } | undefined;
1340
1220
  } | ({
1341
1221
  readonly type: "compaction";
1342
1222
  readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
@@ -1498,18 +1378,6 @@ export declare const failAfter: (error: AIError, ...events: readonly LLMEvent[])
1498
1378
  readonly [x: string]: unknown;
1499
1379
  };
1500
1380
  } | undefined;
1501
- } | {
1502
- readonly type: "tool-error";
1503
- readonly id: string;
1504
- readonly name: string;
1505
- readonly namespace?: string | undefined;
1506
- readonly message: string;
1507
- readonly error?: unknown;
1508
- readonly providerMetadata?: {
1509
- readonly [x: string]: {
1510
- readonly [x: string]: unknown;
1511
- };
1512
- } | undefined;
1513
1381
  } | {
1514
1382
  readonly type: "step-finish";
1515
1383
  readonly index: number;
@@ -1534,6 +1402,7 @@ export declare const failAfter: (error: AIError, ...events: readonly LLMEvent[])
1534
1402
  readonly explanation?: string | undefined;
1535
1403
  };
1536
1404
  readonly usage?: import("./schema/events.js").Usage | undefined;
1405
+ readonly message?: import("./schema/messages.js").Message | undefined;
1537
1406
  readonly providerMetadata?: {
1538
1407
  readonly [x: string]: {
1539
1408
  readonly [x: string]: unknown;
@@ -1547,15 +1416,6 @@ export declare const failAfter: (error: AIError, ...events: readonly LLMEvent[])
1547
1416
  readonly [x: string]: unknown;
1548
1417
  };
1549
1418
  } | undefined;
1550
- } | {
1551
- readonly type: "provider-error";
1552
- readonly message: string;
1553
- readonly classification?: "context-overflow" | "payload-too-large" | undefined;
1554
- readonly providerMetadata?: {
1555
- readonly [x: string]: {
1556
- readonly [x: string]: unknown;
1557
- };
1558
- } | undefined;
1559
1419
  } | ({
1560
1420
  readonly type: "compaction";
1561
1421
  readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
@@ -1717,18 +1577,6 @@ export declare const hangAfter: (...events: readonly LLMEvent[]) => Stream.Strea
1717
1577
  readonly [x: string]: unknown;
1718
1578
  };
1719
1579
  } | undefined;
1720
- } | {
1721
- readonly type: "tool-error";
1722
- readonly id: string;
1723
- readonly name: string;
1724
- readonly namespace?: string | undefined;
1725
- readonly message: string;
1726
- readonly error?: unknown;
1727
- readonly providerMetadata?: {
1728
- readonly [x: string]: {
1729
- readonly [x: string]: unknown;
1730
- };
1731
- } | undefined;
1732
1580
  } | {
1733
1581
  readonly type: "step-finish";
1734
1582
  readonly index: number;
@@ -1753,6 +1601,7 @@ export declare const hangAfter: (...events: readonly LLMEvent[]) => Stream.Strea
1753
1601
  readonly explanation?: string | undefined;
1754
1602
  };
1755
1603
  readonly usage?: import("./schema/events.js").Usage | undefined;
1604
+ readonly message?: import("./schema/messages.js").Message | undefined;
1756
1605
  readonly providerMetadata?: {
1757
1606
  readonly [x: string]: {
1758
1607
  readonly [x: string]: unknown;
@@ -1766,15 +1615,6 @@ export declare const hangAfter: (...events: readonly LLMEvent[]) => Stream.Strea
1766
1615
  readonly [x: string]: unknown;
1767
1616
  };
1768
1617
  } | undefined;
1769
- } | {
1770
- readonly type: "provider-error";
1771
- readonly message: string;
1772
- readonly classification?: "context-overflow" | "payload-too-large" | undefined;
1773
- readonly providerMetadata?: {
1774
- readonly [x: string]: {
1775
- readonly [x: string]: unknown;
1776
- };
1777
- } | undefined;
1778
1618
  } | ({
1779
1619
  readonly type: "compaction";
1780
1620
  readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
@@ -12,7 +12,7 @@ export const dispatch = (tools, call) => {
12
12
  }));
13
13
  if (!tool.execute)
14
14
  return Effect.succeed(result(call, { type: "error", value: `Tool has no execute handler: ${name}` }));
15
- return decodeAndExecute(tool, call).pipe(Effect.map((value) => result(call, value)), Effect.catchTag("Tool.Error", (failure) => Effect.succeed(result(call, { type: "error", value: failure.message }, failure.error))));
15
+ return decodeAndExecute(tool, call).pipe(Effect.map((value) => result(call, value)), Effect.catchTag("Tool.Error", (failure) => Effect.succeed(result(call, { type: "error", value: failure.message }))));
16
16
  };
17
17
  const decodeAndExecute = (tool, call) => tool._decode(call.input).pipe(Effect.mapError((error) => new ToolFailure({ message: `Invalid tool input: ${error.message}` })), Effect.flatMap((decoded) => tool.execute(decoded, {
18
18
  id: call.id,
@@ -27,39 +27,21 @@ const decodeAndExecute = (tool, call) => tool._decode(call.input).pipe(Effect.ma
27
27
  const result = ToolOutput.toResultValue(output);
28
28
  return result.type === "error" ? { result } : { result, output };
29
29
  }))));
30
- const result = (call, value, error) => {
30
+ const result = (call, value) => {
31
31
  const settlement = ToolResultValue.is(value) ? { result: value } : value;
32
32
  return {
33
33
  result: settlement.result,
34
34
  output: settlement.output,
35
- events: settlement.result.type === "error"
36
- ? [
37
- LLMEvent.toolError({
38
- id: call.id,
39
- name: call.name,
40
- namespace: call.namespace,
41
- message: String(settlement.result.value),
42
- error,
43
- providerMetadata: call.providerMetadata,
44
- }),
45
- LLMEvent.toolResult({
46
- id: call.id,
47
- name: call.name,
48
- namespace: call.namespace,
49
- result: settlement.result,
50
- providerMetadata: call.providerMetadata,
51
- }),
52
- ]
53
- : [
54
- LLMEvent.toolResult({
55
- id: call.id,
56
- name: call.name,
57
- namespace: call.namespace,
58
- result: settlement.result,
59
- output: settlement.output,
60
- providerMetadata: call.providerMetadata,
61
- }),
62
- ],
35
+ events: [
36
+ LLMEvent.toolResult({
37
+ id: call.id,
38
+ name: call.name,
39
+ namespace: call.namespace,
40
+ result: settlement.result,
41
+ output: settlement.output,
42
+ providerMetadata: call.providerMetadata,
43
+ }),
44
+ ],
63
45
  };
64
46
  };
65
47
  export const ToolRuntime = { dispatch };
@@ -1,7 +1,7 @@
1
1
  import { Context } from "effect";
2
2
  import { MediaClient } from "./media-client.js";
3
- import { type TranscriptionEvent, type TranscriptionRequestFor, type TranscriptionResponse } from "./transcription.js";
4
- export type Interface = MediaClient.Interface<TranscriptionRequestFor, TranscriptionEvent, TranscriptionResponse>;
3
+ import { type TranscriptionEvent, type TranscriptionRequest, type TranscriptionResponse } from "./transcription.js";
4
+ export type Interface = MediaClient.Interface<TranscriptionRequest, TranscriptionEvent, TranscriptionResponse>;
5
5
  declare const TranscriptionClientService_base: Context.ServiceClass<TranscriptionClientService, "@opencode/TranscriptionClient", Interface>;
6
6
  export declare class TranscriptionClientService extends TranscriptionClientService_base {
7
7
  }
@@ -73,8 +73,8 @@ export declare const TranscriptionClient: {
73
73
  readonly type: "finish";
74
74
  })[];
75
75
  readonly layer: import("effect/Layer").Layer<TranscriptionClientService, never, import("./route.js").RequestExecutorService>;
76
- readonly generate: (request: TranscriptionRequestFor, options?: import("./generation.js").AwaitOptions) => import("effect/Effect").Effect<TranscriptionResponse, import("./effect.js").AIError, TranscriptionClientService>;
77
- readonly stream: (request: TranscriptionRequestFor, options?: import("./generation.js").AwaitOptions) => import("effect/Stream").Stream<{
76
+ readonly generate: (request: TranscriptionRequest, options?: import("./generation.js").AwaitOptions) => import("effect/Effect").Effect<TranscriptionResponse, import("./effect.js").AIError, TranscriptionClientService>;
77
+ readonly stream: (request: TranscriptionRequest, options?: import("./generation.js").AwaitOptions) => import("effect/Stream").Stream<{
78
78
  readonly type: "text-delta";
79
79
  readonly delta: string;
80
80
  } | {
@@ -130,7 +130,7 @@ export declare const TranscriptionClient: {
130
130
  } | undefined;
131
131
  readonly type: "finish";
132
132
  } | import("./generation.js").Observation, import("./effect.js").AIError, TranscriptionClientService>;
133
- readonly start: (request: TranscriptionRequestFor) => import("effect/Effect").Effect<import("./generation.js").Generation<TranscriptionResponse>, import("./effect.js").AIError, TranscriptionClientService>;
133
+ readonly start: (request: TranscriptionRequest) => import("effect/Effect").Effect<import("./generation.js").Generation<TranscriptionResponse>, import("./effect.js").AIError, TranscriptionClientService>;
134
134
  readonly resume: (model: import("./transcription.js").TranscriptionModel<{
135
135
  readonly [x: string]: unknown;
136
136
  }>, token: unknown) => import("effect/Effect").Effect<import("./generation.js").Generation<TranscriptionResponse>, import("./effect.js").AIError, TranscriptionClientService>;
@@ -6,13 +6,13 @@ import { MediaRoute } from "./route/media.js";
6
6
  import { AIError, HttpOptions } from "./schema/index.js";
7
7
  import { Service } from "./transcription-client.js";
8
8
  export type TranscriptionOptions = MediaModel.Options;
9
- export type TranscriptionRoute = MediaRoute.AnyRoute<TranscriptionRequestFor, TranscriptionEvent, TranscriptionResponse>;
9
+ export type TranscriptionRoute = MediaRoute.AnyRoute<TranscriptionRequest, TranscriptionEvent, TranscriptionResponse>;
10
10
  export declare class TranscriptionModel<Options extends TranscriptionOptions = TranscriptionOptions> extends MediaModel<TranscriptionRoute, Options> {
11
11
  protected readonly _TranscriptionModel: void;
12
12
  /** The number of type arguments selects the kind: `<Options>`, `<Options, Frame, State>`, or `<Options, Token>`. */
13
- static fromRoute<Options extends TranscriptionOptions>(route: MediaModel.InlineRouteInput<TranscriptionRequestFor<Options>, TranscriptionResponse>, input: MediaRoute.ModelInput): TranscriptionModel<Options>;
14
- static fromRoute<Options extends TranscriptionOptions, Frame, State>(route: MediaModel.StreamRouteInput<TranscriptionRequestFor<Options>, TranscriptionEvent, Frame, State>, input: MediaRoute.ModelInput): TranscriptionModel<Options>;
15
- static fromRoute<Options extends TranscriptionOptions, Token>(route: MediaModel.QueuedRouteInput<TranscriptionRequestFor<Options>, TranscriptionResponse, Token>, input: MediaRoute.ModelInput): TranscriptionModel<Options>;
13
+ static fromRoute<Options extends TranscriptionOptions>(route: MediaModel.InlineRouteInput<TranscriptionRequest<TranscriptionModel<Options>>, TranscriptionResponse>, input: MediaRoute.ModelInput): TranscriptionModel<Options>;
14
+ static fromRoute<Options extends TranscriptionOptions, Frame, State>(route: MediaModel.StreamRouteInput<TranscriptionRequest<TranscriptionModel<Options>>, TranscriptionEvent, Frame, State>, input: MediaRoute.ModelInput): TranscriptionModel<Options>;
15
+ static fromRoute<Options extends TranscriptionOptions, Token>(route: MediaModel.QueuedRouteInput<TranscriptionRequest<TranscriptionModel<Options>>, TranscriptionResponse, Token>, input: MediaRoute.ModelInput): TranscriptionModel<Options>;
16
16
  }
17
17
  export declare const TranscriptionModelSchema: Schema.declare<TranscriptionModel<{
18
18
  readonly [x: string]: unknown;
@@ -21,7 +21,7 @@ export declare const TranscriptionModelSchema: Schema.declare<TranscriptionModel
21
21
  }>>;
22
22
  export declare const TranscriptionTimestamps: Schema.Literals<readonly ["none", "segment", "word"]>;
23
23
  export type TranscriptionTimestamps = Schema.Schema.Type<typeof TranscriptionTimestamps>;
24
- declare const TranscriptionRequest_base: Schema.Class<TranscriptionRequest, Schema.Struct<{
24
+ declare const TranscriptionRequestSchema: Schema.Struct<{
25
25
  readonly model: Schema.declare<TranscriptionModel<{
26
26
  readonly [x: string]: unknown;
27
27
  }>, TranscriptionModel<{
@@ -66,17 +66,15 @@ declare const TranscriptionRequest_base: Schema.Class<TranscriptionRequest, Sche
66
66
  readonly speakers: Schema.optional<Schema.Int>;
67
67
  readonly providerOptions: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
68
68
  readonly http: Schema.optional<typeof HttpOptions>;
69
- }>, {}>;
70
- export declare class TranscriptionRequest extends TranscriptionRequest_base {
71
- protected readonly _TranscriptionRequest: void;
72
- }
73
- export type TranscriptionRequestFor<Options extends TranscriptionOptions = TranscriptionOptions> = Omit<TranscriptionRequest, "model" | "providerOptions"> & {
74
- readonly model: TranscriptionModel<Options>;
75
- readonly providerOptions?: Options;
69
+ }>;
70
+ /** 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>;
76
74
  };
77
75
  export type TranscriptionModelOptions<Model> = Model extends TranscriptionModel<infer Options> ? Options : never;
78
- export type TranscriptionRequestInput<Model extends TranscriptionModel = TranscriptionModel> = Omit<ConstructorParameters<typeof TranscriptionRequest>[0], "model" | "providerOptions" | "http"> & {
79
- readonly model: Model;
76
+ /** 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"> & {
80
78
  readonly providerOptions?: NoInfer<TranscriptionModelOptions<Model>>;
81
79
  readonly http?: HttpOptions.Input;
82
80
  };
@@ -1321,12 +1319,12 @@ export declare const TranscriptionEvent: Schema.Union<readonly [Schema.Struct<{
1321
1319
  };
1322
1320
  };
1323
1321
  export type TranscriptionEvent = Schema.Schema.Type<typeof transcriptionEventTagged>;
1324
- export declare function request<const Model extends TranscriptionModel>(input: TranscriptionRequestInput<Model>): TranscriptionRequestFor<TranscriptionModelOptions<Model>>;
1325
- export declare function request(input: TranscriptionRequest): TranscriptionRequest;
1326
- export declare function generate<const Model extends TranscriptionModel>(input: TranscriptionRequest | TranscriptionRequestInput<Model>, options?: AwaitOptions): Effect.Effect<TranscriptionResponse, AIError, Service>;
1327
- export declare function stream<const Model extends TranscriptionModel>(input: TranscriptionRequest | TranscriptionRequestInput<Model>, options?: AwaitOptions): Stream.Stream<TranscriptionEvent, AIError, Service>;
1322
+ /** Normalize transcription request input into a plain `TranscriptionRequest`. */
1323
+ export declare const request: <const Model extends TranscriptionModel>(input: TranscriptionRequestInput<Model>) => TranscriptionRequest<Model>;
1324
+ export declare function generate<const Model extends TranscriptionModel>(input: TranscriptionRequestInput<Model>, options?: AwaitOptions): Effect.Effect<TranscriptionResponse, AIError, Service>;
1325
+ export declare function stream<const Model extends TranscriptionModel>(input: TranscriptionRequestInput<Model>, options?: AwaitOptions): Stream.Stream<TranscriptionEvent, AIError, Service>;
1328
1326
  /** Inline and streaming routes fail with `UnsupportedOperation`. */
1329
- export declare function start<const Model extends TranscriptionModel>(input: TranscriptionRequest | TranscriptionRequestInput<Model>): Effect.Effect<Generation<TranscriptionResponse>, AIError, Service>;
1327
+ export declare function start<const Model extends TranscriptionModel>(input: TranscriptionRequestInput<Model>): Effect.Effect<Generation<TranscriptionResponse>, AIError, Service>;
1330
1328
  export declare const resume: (model: TranscriptionModel, token: unknown) => Effect.Effect<Generation<TranscriptionResponse>, AIError, Service>;
1331
1329
  export declare const Transcription: {
1332
1330
  readonly request: typeof request;
@@ -21,7 +21,7 @@ export const TranscriptionModelSchema = Schema.declare((value) => value instance
21
21
  // Request
22
22
  // ---------------------------------------------------------------------------
23
23
  export const TranscriptionTimestamps = Schema.Literals(["none", "segment", "word"]);
24
- export class TranscriptionRequest extends Schema.Class("Transcription.Request")({
24
+ const TranscriptionRequestSchema = Schema.Struct({
25
25
  model: TranscriptionModelSchema,
26
26
  audio: Media.AssetSchema,
27
27
  language: Schema.optional(Schema.String),
@@ -32,8 +32,7 @@ export class TranscriptionRequest extends Schema.Class("Transcription.Request")(
32
32
  speakers: Schema.optional(Schema.Int),
33
33
  providerOptions: Schema.optional(ProviderOptions),
34
34
  http: Schema.optional(HttpOptions),
35
- }) {
36
- }
35
+ });
37
36
  // ---------------------------------------------------------------------------
38
37
  // Response and events
39
38
  // ---------------------------------------------------------------------------
@@ -99,15 +98,20 @@ const collectResponse = (events) => {
99
98
  const { type: _type, ...transcript } = finish;
100
99
  return Effect.succeed(new TranscriptionResponse(transcript));
101
100
  };
102
- export function request(input) {
103
- if (input instanceof TranscriptionRequest)
104
- return input;
105
- return new TranscriptionRequest({
106
- ...input,
107
- http: HttpOptions.make(input.http),
108
- });
109
- }
110
- const requestEffect = (input) => tryRequest(() => request(input));
101
+ // ---------------------------------------------------------------------------
102
+ // Request-shaped call API
103
+ // ---------------------------------------------------------------------------
104
+ /** Normalize transcription request input into a plain `TranscriptionRequest`. */
105
+ export const request = (input) => ({
106
+ ...input,
107
+ http: HttpOptions.make(input.http),
108
+ });
109
+ const validate = Schema.decodeUnknownSync(TranscriptionRequestSchema);
110
+ const requestEffect = (input) => tryRequest(() => {
111
+ const normalized = request(input);
112
+ validate(normalized);
113
+ return normalized;
114
+ });
111
115
  export function generate(input, options) {
112
116
  return requestEffect(input).pipe(Effect.flatMap((request) => TranscriptionClient.generate(request, options)));
113
117
  }
@@ -1,7 +1,7 @@
1
1
  import { Context } from "effect";
2
2
  import { MediaClient } from "./media-client.js";
3
- import { type VideoEvent, type VideoRequestFor, type VideoResponse } from "./video.js";
4
- export type Interface = MediaClient.Interface<VideoRequestFor, VideoEvent, VideoResponse>;
3
+ import { type VideoEvent, type VideoRequest, type VideoResponse } from "./video.js";
4
+ export type Interface = MediaClient.Interface<VideoRequest, VideoEvent, VideoResponse>;
5
5
  declare const VideoClientService_base: Context.ServiceClass<VideoClientService, "@opencode/VideoClient", Interface>;
6
6
  export declare class VideoClientService extends VideoClientService_base {
7
7
  }
@@ -50,8 +50,8 @@ export declare const VideoClient: {
50
50
  } | undefined;
51
51
  })[];
52
52
  readonly layer: import("effect/Layer").Layer<VideoClientService, never, import("./route.js").RequestExecutorService>;
53
- readonly generate: (request: VideoRequestFor, options?: import("./generation.js").AwaitOptions) => import("effect/Effect").Effect<VideoResponse, import("./effect.js").AIError, VideoClientService>;
54
- readonly stream: (request: VideoRequestFor, options?: import("./generation.js").AwaitOptions) => import("effect/Stream").Stream<{
53
+ readonly generate: (request: VideoRequest, options?: import("./generation.js").AwaitOptions) => import("effect/Effect").Effect<VideoResponse, import("./effect.js").AIError, VideoClientService>;
54
+ readonly stream: (request: VideoRequest, options?: import("./generation.js").AwaitOptions) => import("effect/Stream").Stream<{
55
55
  readonly type: "video";
56
56
  readonly index: number;
57
57
  readonly video: import("./media.js").Asset;
@@ -84,7 +84,7 @@ export declare const VideoClient: {
84
84
  };
85
85
  } | undefined;
86
86
  } | import("./generation.js").Observation, import("./effect.js").AIError, VideoClientService>;
87
- readonly start: (request: VideoRequestFor) => import("effect/Effect").Effect<import("./generation.js").Generation<VideoResponse>, import("./effect.js").AIError, VideoClientService>;
87
+ readonly start: (request: VideoRequest) => import("effect/Effect").Effect<import("./generation.js").Generation<VideoResponse>, import("./effect.js").AIError, VideoClientService>;
88
88
  readonly resume: (model: import("./video.js").VideoModel<{
89
89
  readonly [x: string]: unknown;
90
90
  }>, token: unknown) => import("effect/Effect").Effect<import("./generation.js").Generation<VideoResponse>, import("./effect.js").AIError, VideoClientService>;
@@ -1,6 +1,6 @@
1
1
  import { Context } from "effect";
2
2
  import { MediaClient } from "./media-client.js";
3
- import { VideoOutputEvent, VideoFinishEvent, } from "./video.js";
3
+ import { VideoOutputEvent, VideoFinishEvent } from "./video.js";
4
4
  export class VideoClientService extends Context.Service()("@opencode/VideoClient") {
5
5
  }
6
6
  export const Service = VideoClientService;