@opencode/ai 0.0.0-dev-21922 → 0.0.0-dev-51

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 (128) hide show
  1. package/README.md +39 -17
  2. package/dist/ai-client.d.ts +2 -2
  3. package/dist/decision-client.d.ts +3 -3
  4. package/dist/decision.d.ts +4 -1
  5. package/dist/decision.js +3 -0
  6. package/dist/effect.d.ts +4 -5
  7. package/dist/effect.js +2 -3
  8. package/dist/experimental/realtime.d.ts +3 -2
  9. package/dist/image-client.d.ts +1 -1
  10. package/dist/image.js +1 -0
  11. package/dist/index.d.ts +6 -0
  12. package/dist/llm.d.ts +3 -0
  13. package/dist/media-client.d.ts +2 -1
  14. package/dist/media-model.d.ts +3 -0
  15. package/dist/media-model.js +4 -1
  16. package/dist/protocols/alibaba-responses.d.ts +3 -3
  17. package/dist/protocols/bedrock-converse.d.ts +98 -3
  18. package/dist/protocols/bedrock-converse.js +112 -15
  19. package/dist/protocols/bedrock-event-stream.js +1 -0
  20. package/dist/protocols/open-responses.d.ts +3 -0
  21. package/dist/protocols/openai-chat.d.ts +3 -0
  22. package/dist/protocols/openai-compatible-chat.d.ts +2 -2
  23. package/dist/protocols/openai-compatible-responses.d.ts +3 -3
  24. package/dist/protocols/utils/gemini-json-schema.d.ts +5 -0
  25. package/dist/protocols/utils/gemini-json-schema.js +3 -3
  26. package/dist/protocols/utils/tool-schema.js +15 -5
  27. package/dist/protocols/utils/tool-stream.d.ts +9 -0
  28. package/dist/providers/alibaba/images.d.ts +2 -0
  29. package/dist/providers/alibaba/images.js +1 -0
  30. package/dist/providers/alibaba.d.ts +3 -2
  31. package/dist/providers/alibaba.js +12 -8
  32. package/dist/providers/amazon-bedrock.d.ts +30 -10
  33. package/dist/providers/amazon-bedrock.js +11 -11
  34. package/dist/providers/azure/images.d.ts +2 -0
  35. package/dist/providers/azure/images.js +1 -0
  36. package/dist/providers/azure.d.ts +3 -1
  37. package/dist/providers/azure.js +19 -1
  38. package/dist/providers/baseten/decisions.d.ts +2 -0
  39. package/dist/providers/baseten/decisions.js +1 -0
  40. package/dist/providers/baseten.d.ts +5 -4
  41. package/dist/providers/baseten.js +15 -8
  42. package/dist/providers/cloudflare-ai-gateway/decisions.d.ts +2 -0
  43. package/dist/providers/cloudflare-ai-gateway/decisions.js +1 -0
  44. package/dist/providers/cloudflare-ai-gateway.d.ts +3 -2
  45. package/dist/providers/cloudflare-ai-gateway.js +11 -6
  46. package/dist/providers/cloudflare-workers-ai/decisions.d.ts +2 -0
  47. package/dist/providers/cloudflare-workers-ai/decisions.js +1 -0
  48. package/dist/providers/cloudflare-workers-ai/images.d.ts +2 -0
  49. package/dist/providers/cloudflare-workers-ai/images.js +1 -0
  50. package/dist/providers/cloudflare-workers-ai.d.ts +5 -3
  51. package/dist/providers/cloudflare-workers-ai.js +16 -7
  52. package/dist/providers/digitalocean/decisions.d.ts +2 -0
  53. package/dist/providers/digitalocean/decisions.js +1 -0
  54. package/dist/providers/digitalocean/images.d.ts +2 -0
  55. package/dist/providers/digitalocean/images.js +1 -0
  56. package/dist/providers/digitalocean.d.ts +9 -4
  57. package/dist/providers/digitalocean.js +25 -8
  58. package/dist/providers/google/images.d.ts +2 -0
  59. package/dist/providers/google/images.js +1 -0
  60. package/dist/providers/google-vertex/images.d.ts +2 -0
  61. package/dist/providers/google-vertex/images.js +1 -0
  62. package/dist/providers/google-vertex.d.ts +3 -1
  63. package/dist/providers/google-vertex.js +30 -13
  64. package/dist/providers/google.d.ts +5 -4
  65. package/dist/providers/google.js +15 -8
  66. package/dist/providers/openai/images.d.ts +2 -0
  67. package/dist/providers/openai/images.js +1 -0
  68. package/dist/providers/openai-compatible/images.d.ts +2 -0
  69. package/dist/providers/openai-compatible/images.js +1 -0
  70. package/dist/providers/openai-compatible.d.ts +3 -1
  71. package/dist/providers/openai-compatible.js +21 -9
  72. package/dist/providers/openai.d.ts +10 -8
  73. package/dist/providers/openai.js +10 -2
  74. package/dist/providers/opencode/decisions.d.ts +2 -0
  75. package/dist/providers/opencode/decisions.js +1 -0
  76. package/dist/providers/opencode.d.ts +9 -4
  77. package/dist/providers/opencode.js +2 -1
  78. package/dist/providers/openrouter/decisions.d.ts +2 -0
  79. package/dist/providers/openrouter/decisions.js +1 -0
  80. package/dist/providers/openrouter/images.d.ts +2 -0
  81. package/dist/providers/openrouter/images.js +1 -0
  82. package/dist/providers/openrouter.d.ts +9 -4
  83. package/dist/providers/openrouter.js +31 -9
  84. package/dist/providers/typesafe-ai/decisions.d.ts +2 -0
  85. package/dist/providers/typesafe-ai/decisions.js +1 -0
  86. package/dist/providers/typesafe-ai.d.ts +9 -4
  87. package/dist/providers/typesafe-ai.js +2 -1
  88. package/dist/providers/vercel-ai-gateway/decisions.d.ts +2 -0
  89. package/dist/providers/vercel-ai-gateway/decisions.js +1 -0
  90. package/dist/providers/vercel-ai-gateway/images.d.ts +2 -0
  91. package/dist/providers/vercel-ai-gateway/images.js +1 -0
  92. package/dist/providers/vercel-ai-gateway.d.ts +9 -7
  93. package/dist/providers/vercel-ai-gateway.js +18 -10
  94. package/dist/providers/xai/images.d.ts +2 -0
  95. package/dist/providers/xai/images.js +1 -0
  96. package/dist/providers/xai.d.ts +5 -4
  97. package/dist/providers/xai.js +15 -8
  98. package/dist/providers/zai/images.d.ts +2 -0
  99. package/dist/providers/zai/images.js +1 -0
  100. package/dist/providers/zai.d.ts +5 -4
  101. package/dist/providers/zai.js +15 -8
  102. package/dist/route/client.d.ts +2 -2
  103. package/dist/route/client.js +15 -4
  104. package/dist/route/decision.d.ts +2 -1
  105. package/dist/route/decision.js +1 -0
  106. package/dist/route/executor.d.ts +1 -1
  107. package/dist/route/framing.d.ts +2 -0
  108. package/dist/route/index.d.ts +3 -0
  109. package/dist/route/index.js +3 -0
  110. package/dist/route/media.d.ts +5 -1
  111. package/dist/route/media.js +6 -2
  112. package/dist/route/transport/http.js +1 -0
  113. package/dist/route/transport/index.d.ts +1 -0
  114. package/dist/schema/events.d.ts +135 -6
  115. package/dist/schema/events.js +10 -0
  116. package/dist/schema/messages.d.ts +4 -0
  117. package/dist/schema/messages.js +3 -0
  118. package/dist/speech-client.d.ts +1 -1
  119. package/dist/speech.js +2 -1
  120. package/dist/testing.d.ts +25 -24
  121. package/dist/testing.js +3 -21
  122. package/dist/transcription-client.d.ts +1 -1
  123. package/dist/transcription.js +1 -0
  124. package/dist/video-client.d.ts +1 -1
  125. package/dist/video.js +1 -0
  126. package/package.json +510 -8
  127. package/dist/provider.d.ts +0 -23
  128. package/dist/provider.js +0 -2
@@ -193,7 +193,7 @@ export declare function make<Body, Prepared, Frame, Event, State>(input: MakeTra
193
193
  * the public surface preemptively.
194
194
  */
195
195
  export declare function make<Body, Frame, Event, State>(input: MakeInput<Body, Frame, Event, State>): Route<Body, HttpTransport.HttpPrepared<Frame>>;
196
- /** @internal Test-only projection of the execution compiler; not exported from package barrels. */
196
+ /** Test-only projection of the execution compiler; exported from `@opencode/ai/testing`. */
197
197
  export declare const compileRequest: (request: LLMRequest<LanguageModel<{
198
198
  readonly [x: string]: unknown;
199
199
  }, CompactionOperations | undefined>>) => Effect.Effect<{
@@ -220,7 +220,7 @@ export declare const LLMClient: {
220
220
  readonly canCompact: typeof canCompact;
221
221
  readonly compact: typeof compact;
222
222
  readonly Service: typeof LLMClientService;
223
- readonly layer: Layer.Layer<LLMClientService, never, import("./executor-service.js").RequestExecutorService>;
223
+ readonly layer: Layer.Layer<LLMClientService, never, RequestExecutor.RequestExecutorService>;
224
224
  readonly stream: typeof stream;
225
225
  readonly generate: typeof generate;
226
226
  };
@@ -1,4 +1,4 @@
1
- import { Cause, Context, Effect, Layer, Schema, Stream } from "effect";
1
+ import { Cause, Context, Effect, Layer, Option, Schema, Stream } from "effect";
2
2
  import { Auth } from "./auth.js";
3
3
  import { Endpoint } from "./endpoint.js";
4
4
  import { RequestExecutor } from "./executor.js";
@@ -91,13 +91,22 @@ const incompleteStreamError = (route) => new AIError({
91
91
  const requireTerminalEvent = (route) => (events) => Stream.suspend(() => {
92
92
  let terminal = false;
93
93
  return events.pipe(Stream.mapEffect((event) => {
94
- if (terminal)
94
+ // Raw events carry provider frames that may trail the terminal event.
95
+ if (terminal && !LLMEvent.is.raw(event))
95
96
  return Effect.fail(ProviderShared.eventError(route, `Provider emitted ${event.type} after the terminal event`));
96
97
  if (LLMEvent.is.finish(event) || LLMEvent.is.providerError(event))
97
98
  terminal = true;
98
99
  return Effect.succeed(event);
99
100
  }), Stream.onEnd(Effect.suspend(() => (terminal ? Effect.void : Effect.fail(incompleteStreamError(route))))));
100
101
  });
102
+ const decodeJsonOption = Schema.decodeUnknownOption(ProviderShared.Json);
103
+ // JSON text frames are parsed; non-JSON sentinels such as `[DONE]` stay strings.
104
+ const rawFrame = (frame) => typeof frame === "string" ? Option.getOrElse(decodeJsonOption(frame), () => frame) : frame;
105
+ // Transports may interleave their own marker objects with provider frames, e.g. Gemini's continuation boundary.
106
+ const isProviderFrame = (frame) => typeof frame !== "object" ||
107
+ frame === null ||
108
+ Array.isArray(frame) ||
109
+ Object.getPrototypeOf(frame) === Object.prototype;
101
110
  function makeFromTransport(input) {
102
111
  const protocol = input.protocol;
103
112
  const decodeEventEffect = Schema.decodeUnknownEffect(protocol.stream.event);
@@ -165,7 +174,9 @@ function makeFromTransport(input) {
165
174
  let state = protocol.stream.initial(request);
166
175
  const parsed = events.pipe(Stream.mapEffect(({ event, frame }) => protocol.stream.step(state, event).pipe(Effect.catchCause((cause) => Effect.fail(streamError(route, `Failed to parse ${route} event`, cause))), Effect.map(([next, output]) => {
167
176
  state = next;
168
- return output;
177
+ return request.includeRaw && isProviderFrame(frame)
178
+ ? [LLMEvent.raw({ data: execution.raw?.(frame) ?? rawFrame(frame) }), ...output]
179
+ : output;
169
180
  }), Effect.mapError(frameError(frame, event)))), Stream.flatMap(Stream.fromIterable));
170
181
  const onHalt = protocol.stream.onHalt;
171
182
  return onHalt
@@ -238,7 +249,7 @@ const compile = Effect.fn("LLM.compile")(function* (request, options) {
238
249
  prepared,
239
250
  };
240
251
  });
241
- /** @internal Test-only projection of the execution compiler; not exported from package barrels. */
252
+ /** Test-only projection of the execution compiler; exported from `@opencode/ai/testing`. */
242
253
  export const compileRequest = Effect.fn("LLM.compileRequest")(function* (request) {
243
254
  const compiled = yield* compile(request);
244
255
  return {
@@ -1,7 +1,7 @@
1
1
  import { Effect } from "effect";
2
2
  import type { HttpClientResponse } from "effect/http";
3
3
  import { DecisionModel, DecisionModelCompatibility, type DecisionOptions, type DecisionRequestFor, type DecisionResponse } from "../decision.js";
4
- import { HttpOptions, ProviderID, type AIError } from "../schema/index.js";
4
+ import { HttpOptions, ProviderID, type AIError, type ProviderOptions } from "../schema/index.js";
5
5
  import { Auth } from "./auth.js";
6
6
  import { Endpoint } from "./endpoint.js";
7
7
  import { MediaProtocol } from "./media-protocol.js";
@@ -45,6 +45,7 @@ export interface Route {
45
45
  readonly model: <Options extends DecisionOptions = DecisionOptions>(input: {
46
46
  readonly id: string;
47
47
  readonly compatibility?: DecisionModelCompatibility.Input;
48
+ readonly providerOptions?: ProviderOptions;
48
49
  }) => DecisionModel<Options>;
49
50
  }
50
51
  export interface MakeInput extends Omit<Patch, "endpoint"> {
@@ -36,6 +36,7 @@ export const make = (input) => {
36
36
  id: model.id,
37
37
  provider,
38
38
  http: route.http,
39
+ providerOptions: model.providerOptions,
39
40
  compatibility: model.compatibility === undefined ? undefined : DecisionModelCompatibility.make(model.compatibility),
40
41
  route: { id: route.id, generate: send },
41
42
  });
@@ -3,7 +3,7 @@ import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http";
3
3
  import { AIError } from "../schema/index.js";
4
4
  import { Service, type HttpMiddleware, type Interface } from "./executor-service.js";
5
5
  export { responseHttp, Service } from "./executor-service.js";
6
- export type { HttpHandler, HttpMiddleware, Interface } from "./executor-service.js";
6
+ export type { HttpHandler, HttpMiddleware, Interface, RequestExecutorService } from "./executor-service.js";
7
7
  /** Preserve HTTP diagnostics for executor and externally captured failures alike. */
8
8
  export declare const httpFailure: (input: {
9
9
  readonly message: string;
@@ -21,6 +21,8 @@ export interface Definition<Frame> {
21
21
  readonly frame: (bytes: Stream.Stream<Uint8Array, AIError>) => Stream.Stream<Frame, AIError>;
22
22
  /** Original wire representation when framing transforms the provider payload. */
23
23
  readonly body?: (frame: Frame) => string | undefined;
24
+ /** Provider value exposed as a `raw` event when framing adds fields of its own. Defaults to the frame. */
25
+ readonly raw?: (frame: Frame) => unknown;
24
26
  }
25
27
  /**
26
28
  * `framing` step for Server-Sent Events. Decodes UTF-8, runs the SSE channel
@@ -10,6 +10,9 @@ export { Framing } from "./framing.js";
10
10
  export { Protocol } from "./protocol.js";
11
11
  export { HttpTransport, WebSocketTransport } from "./transport/index.js";
12
12
  export * as Transport from "./transport/index.js";
13
+ export { ProviderShared } from "../protocols/shared.js";
14
+ export { classifyProviderFailure } from "../provider-error.js";
15
+ export { mergeHttpOptions } from "../schema/index.js";
13
16
  export type { Definition as AuthShape, AuthInput, Credential, CredentialError } from "./auth.js";
14
17
  export type { ApiKeyMode, AuthOverride, ProviderAuthOption } from "./auth-options.js";
15
18
  export type { Definition as EndpointFn, EndpointInput } from "./endpoint.js";
@@ -9,3 +9,6 @@ export { Framing } from "./framing.js";
9
9
  export { Protocol } from "./protocol.js";
10
10
  export { HttpTransport, WebSocketTransport } from "./transport/index.js";
11
11
  export * as Transport from "./transport/index.js";
12
+ export { ProviderShared } from "../protocols/shared.js";
13
+ export { classifyProviderFailure } from "../provider-error.js";
14
+ export { mergeHttpOptions } from "../schema/index.js";
@@ -4,7 +4,7 @@ import { Endpoint } from "./endpoint.js";
4
4
  import { type Interface } from "./executor-service.js";
5
5
  import { MediaProtocol } from "./media-protocol.js";
6
6
  import { Generation } from "../generation.js";
7
- import { AIError, HttpOptions, ProviderID } from "../schema/index.js";
7
+ import { AIError, HttpOptions, ProviderID, type ProviderOptions } from "../schema/index.js";
8
8
  export type Execute = Interface["execute"];
9
9
  /** The minimum a media request must carry for the route to build a transport request. */
10
10
  export interface MediaRequest {
@@ -12,7 +12,9 @@ export interface MediaRequest {
12
12
  readonly id: string;
13
13
  readonly provider: ProviderID;
14
14
  readonly http?: HttpOptions;
15
+ readonly providerOptions?: ProviderOptions;
15
16
  };
17
+ readonly providerOptions?: ProviderOptions;
16
18
  readonly http?: HttpOptions;
17
19
  }
18
20
  /** Deployment inputs every media model factory accepts; provider facades fill these from `configure(...)`. */
@@ -22,6 +24,8 @@ export interface ModelInput {
22
24
  readonly baseURL?: string;
23
25
  readonly headers?: Record<string, string>;
24
26
  readonly http?: HttpOptions;
27
+ /** Defaults under each request's `providerOptions`. */
28
+ readonly providerOptions?: ProviderOptions;
25
29
  }
26
30
  /** A provider facade's `configure(...)` input as the `ModelInput` every media selector shares, minus the model id. */
27
31
  export declare const deployment: (input: {
@@ -7,7 +7,7 @@ import { RequestExecutor } from "./executor.js";
7
7
  import { MediaProtocol } from "./media-protocol.js";
8
8
  import { Generation, isTerminal } from "../generation.js";
9
9
  import { isRetryable } from "../provider-error.js";
10
- import { AIError, AIErrorReason, HttpOptions, InvalidRequestError, ProviderID, UnsupportedOperationError, mergeHttpOptions, } from "../schema/index.js";
10
+ import { AIError, AIErrorReason, HttpOptions, InvalidRequestError, ProviderID, UnsupportedOperationError, mergeHttpOptions, mergeProviderOptions, } from "../schema/index.js";
11
11
  import { encodeJson } from "../utils/json.js";
12
12
  import { sanitizeSurrogates } from "../utils/sanitize.js";
13
13
  /** A provider facade's `configure(...)` input as the `ModelInput` every media selector shares, minus the model id. */
@@ -161,12 +161,16 @@ const makeTransport = (input) => {
161
161
  submit: Effect.fn("MediaRoute.submit")(function* (request, protocol, execute) {
162
162
  yield* rejectUnsupported(input.protocol.id, input.protocol.provider, request, protocol.unsupported);
163
163
  const http = mergeHttpOptions(routeHttp, request.model.http, request.http);
164
+ const providerOptions = mergeProviderOptions(request.model.providerOptions, request.providerOptions);
164
165
  const headers = Headers.fromInput(http?.headers);
165
166
  const prepared = protocol.prepare === undefined
166
167
  ? request
167
168
  : yield* protocol.prepare(request, (path, body) => send({ method: "POST", url: baseURL(path), headers, request, body }, execute).pipe(Effect.map((sent) => sent.response)));
168
169
  // Sanitize after merging so model-level overlays are covered; the model value is restored, not sanitized.
169
- const resolved = { ...sanitizeSurrogates({ ...prepared, http }), model: request.model };
170
+ const resolved = {
171
+ ...sanitizeSurrogates({ ...prepared, http, providerOptions }),
172
+ model: request.model,
173
+ };
170
174
  const body = yield* protocol.from(resolved);
171
175
  const url = withQuery(withQuery(Endpoint.render(input.endpoint, { request: resolved, body }), body.type === "multipart" ? undefined : body.query), http?.query);
172
176
  const sent = yield* send({ method: "POST", url, headers, request: resolved, body }, execute);
@@ -78,6 +78,7 @@ export const httpJson = (input) => ({
78
78
  }), Stream.interruptWhen(Effect.sleep(remaining).pipe(Effect.andThen(Effect.fail(timeout("read", "Timed out waiting for the response to complete", http))))))),
79
79
  http,
80
80
  body: prepared.framing.body,
81
+ raw: prepared.framing.raw,
81
82
  };
82
83
  }),
83
84
  });
@@ -11,6 +11,7 @@ export interface TransportExecution<Frame> {
11
11
  readonly frames: Stream.Stream<Frame, AIError>;
12
12
  readonly http?: HttpContext;
13
13
  body?(frame: Frame): string | undefined;
14
+ raw?(frame: Frame): unknown;
14
15
  /** Optional successful-consumption acknowledgement. HTTP leaves this absent. */
15
16
  readonly complete?: Effect.Effect<void>;
16
17
  }
@@ -410,6 +410,12 @@ export declare const ProviderErrorEvent: Schema.Struct<{
410
410
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
411
411
  }>;
412
412
  export type ProviderErrorEvent = Schema.Schema.Type<typeof ProviderErrorEvent>;
413
+ /** One provider frame as received, emitted before the events parsed from it when the request sets `includeRaw`. */
414
+ export declare const RawEvent: Schema.Struct<{
415
+ readonly type: Schema.tag<"raw">;
416
+ readonly data: Schema.Unknown;
417
+ }>;
418
+ export type RawEvent = Schema.Schema.Type<typeof RawEvent>;
413
419
  declare const llmEventTagged: Schema.toTaggedUnion<"type", readonly [Schema.refine<{
414
420
  readonly type: "compaction";
415
421
  readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
@@ -643,6 +649,9 @@ declare const llmEventTagged: Schema.toTaggedUnion<"type", readonly [Schema.refi
643
649
  readonly message: Schema.String;
644
650
  readonly classification: Schema.optional<Schema.Literals<readonly ["context-overflow", "payload-too-large"]>>;
645
651
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
652
+ }>, Schema.Struct<{
653
+ readonly type: Schema.tag<"raw">;
654
+ readonly data: Schema.Unknown;
646
655
  }>]>;
647
656
  type WithID<Event extends {
648
657
  readonly id: unknown;
@@ -892,8 +901,11 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
892
901
  readonly message: Schema.String;
893
902
  readonly classification: Schema.optional<Schema.Literals<readonly ["context-overflow", "payload-too-large"]>>;
894
903
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
904
+ }>, Schema.Struct<{
905
+ readonly type: Schema.tag<"raw">;
906
+ readonly data: Schema.Unknown;
895
907
  }>]> & {
896
- readonly discriminants: readonly ["compaction", "step-start", "text-start", "text-delta", "text-end", "reasoning-start", "reasoning-delta", "reasoning-end", "tool-input-start", "tool-input-delta", "tool-input-end", "tool-input-error", "tool-call", "tool-result", "tool-error", "media", "step-finish", "finish", "provider-error"];
908
+ readonly discriminants: readonly ["compaction", "step-start", "text-start", "text-delta", "text-end", "reasoning-start", "reasoning-delta", "reasoning-end", "tool-input-start", "tool-input-delta", "tool-input-end", "tool-input-error", "tool-call", "tool-result", "tool-error", "media", "step-finish", "finish", "provider-error", "raw"];
897
909
  readonly cases: {
898
910
  compaction: Schema.refine<{
899
911
  readonly type: "compaction";
@@ -976,6 +988,10 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
976
988
  readonly classification: Schema.optional<Schema.Literals<readonly ["context-overflow", "payload-too-large"]>>;
977
989
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
978
990
  }>;
991
+ raw: Schema.Struct<{
992
+ readonly type: Schema.tag<"raw">;
993
+ readonly data: Schema.Unknown;
994
+ }>;
979
995
  "reasoning-delta": Schema.Struct<{
980
996
  readonly type: Schema.tag<"reasoning-delta">;
981
997
  readonly id: Schema.String;
@@ -1151,6 +1167,9 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
1151
1167
  readonly isAnyOf: <const Keys>(keys: readonly Keys[]) => (value: {
1152
1168
  readonly type: "step-start";
1153
1169
  readonly index: number;
1170
+ } | {
1171
+ readonly type: "raw";
1172
+ readonly data: unknown;
1154
1173
  } | {
1155
1174
  readonly type: "text-start";
1156
1175
  readonly id: string;
@@ -1368,6 +1387,11 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
1368
1387
  readonly index: number;
1369
1388
  }, {
1370
1389
  readonly type: Keys;
1390
+ }> | Extract<{
1391
+ readonly type: "raw";
1392
+ readonly data: unknown;
1393
+ }, {
1394
+ readonly type: Keys;
1371
1395
  }> | Extract<{
1372
1396
  readonly type: "text-start";
1373
1397
  readonly id: string;
@@ -1673,6 +1697,10 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
1673
1697
  };
1674
1698
  } | undefined;
1675
1699
  };
1700
+ raw: (u: unknown) => u is {
1701
+ readonly type: "raw";
1702
+ readonly data: unknown;
1703
+ };
1676
1704
  "reasoning-delta": (u: unknown) => u is {
1677
1705
  readonly type: "reasoning-delta";
1678
1706
  readonly id: string;
@@ -2069,6 +2097,9 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
2069
2097
  readonly message: Schema.String;
2070
2098
  readonly classification: Schema.optional<Schema.Literals<readonly ["context-overflow", "payload-too-large"]>>;
2071
2099
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
2100
+ }> | Schema.Struct<{
2101
+ readonly type: Schema.tag<"raw">;
2102
+ readonly data: Schema.Unknown;
2072
2103
  }> | (Schema.refine<{
2073
2104
  readonly type: "compaction";
2074
2105
  readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
@@ -2098,6 +2129,9 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
2098
2129
  }) as M["Type"]["type"]]: (value: M["Type"]) => any; }>(value: {
2099
2130
  readonly type: "step-start";
2100
2131
  readonly index: number;
2132
+ } | {
2133
+ readonly type: "raw";
2134
+ readonly data: unknown;
2101
2135
  } | {
2102
2136
  readonly type: "text-start";
2103
2137
  readonly id: string;
@@ -2518,6 +2552,9 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
2518
2552
  readonly message: Schema.String;
2519
2553
  readonly classification: Schema.optional<Schema.Literals<readonly ["context-overflow", "payload-too-large"]>>;
2520
2554
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
2555
+ }> | Schema.Struct<{
2556
+ readonly type: Schema.tag<"raw">;
2557
+ readonly data: Schema.Unknown;
2521
2558
  }> | (Schema.refine<{
2522
2559
  readonly type: "compaction";
2523
2560
  readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
@@ -2547,6 +2584,9 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
2547
2584
  }) as M["Type"]["type"]]: (value: M["Type"]) => any; }>(cases: Cases): (value: {
2548
2585
  readonly type: "step-start";
2549
2586
  readonly index: number;
2587
+ } | {
2588
+ readonly type: "raw";
2589
+ readonly data: unknown;
2550
2590
  } | {
2551
2591
  readonly type: "text-start";
2552
2592
  readonly id: string;
@@ -2969,6 +3009,9 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
2969
3009
  readonly message: Schema.String;
2970
3010
  readonly classification: Schema.optional<Schema.Literals<readonly ["context-overflow", "payload-too-large"]>>;
2971
3011
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
3012
+ }> | Schema.Struct<{
3013
+ readonly type: Schema.tag<"raw">;
3014
+ readonly data: Schema.Unknown;
2972
3015
  }> | (Schema.refine<{
2973
3016
  readonly type: "compaction";
2974
3017
  readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
@@ -2995,9 +3038,12 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
2995
3038
  readonly text: string | null;
2996
3039
  readonly encrypted?: never;
2997
3040
  })) => CompactionPart;
2998
- }) as M["Type"]["type"]]+?: (value: M["Type"]) => any; } & { [K in Exclude<keyof Cases, "compaction" | "finish" | "media" | "provider-error" | "reasoning-delta" | "reasoning-end" | "reasoning-start" | "step-finish" | "step-start" | "text-delta" | "text-end" | "text-start" | "tool-call" | "tool-error" | "tool-input-delta" | "tool-input-end" | "tool-input-error" | "tool-input-start" | "tool-result">]: never; }, OrElse extends (value: Exclude<{
3041
+ }) as M["Type"]["type"]]+?: (value: M["Type"]) => any; } & { [K in Exclude<keyof Cases, "compaction" | "finish" | "media" | "provider-error" | "raw" | "reasoning-delta" | "reasoning-end" | "reasoning-start" | "step-finish" | "step-start" | "text-delta" | "text-end" | "text-start" | "tool-call" | "tool-error" | "tool-input-delta" | "tool-input-end" | "tool-input-error" | "tool-input-start" | "tool-result">]: never; }, OrElse extends (value: Exclude<{
2999
3042
  readonly type: "step-start";
3000
3043
  readonly index: number;
3044
+ } | {
3045
+ readonly type: "raw";
3046
+ readonly data: unknown;
3001
3047
  } | {
3002
3048
  readonly type: "text-start";
3003
3049
  readonly id: string;
@@ -3213,6 +3259,9 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
3213
3259
  })), { readonly [K in "type"]: keyof Cases; }>) => any>(value: {
3214
3260
  readonly type: "step-start";
3215
3261
  readonly index: number;
3262
+ } | {
3263
+ readonly type: "raw";
3264
+ readonly data: unknown;
3216
3265
  } | {
3217
3266
  readonly type: "text-start";
3218
3267
  readonly id: string;
@@ -3633,6 +3682,9 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
3633
3682
  readonly message: Schema.String;
3634
3683
  readonly classification: Schema.optional<Schema.Literals<readonly ["context-overflow", "payload-too-large"]>>;
3635
3684
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
3685
+ }> | Schema.Struct<{
3686
+ readonly type: Schema.tag<"raw">;
3687
+ readonly data: Schema.Unknown;
3636
3688
  }> | (Schema.refine<{
3637
3689
  readonly type: "compaction";
3638
3690
  readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
@@ -3659,9 +3711,12 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
3659
3711
  readonly text: string | null;
3660
3712
  readonly encrypted?: never;
3661
3713
  })) => CompactionPart;
3662
- }) as M["Type"]["type"]]+?: (value: M["Type"]) => any; } & { [K in Exclude<keyof Cases, "compaction" | "finish" | "media" | "provider-error" | "reasoning-delta" | "reasoning-end" | "reasoning-start" | "step-finish" | "step-start" | "text-delta" | "text-end" | "text-start" | "tool-call" | "tool-error" | "tool-input-delta" | "tool-input-end" | "tool-input-error" | "tool-input-start" | "tool-result">]: never; }, OrElse extends (value: Exclude<{
3714
+ }) as M["Type"]["type"]]+?: (value: M["Type"]) => any; } & { [K in Exclude<keyof Cases, "compaction" | "finish" | "media" | "provider-error" | "raw" | "reasoning-delta" | "reasoning-end" | "reasoning-start" | "step-finish" | "step-start" | "text-delta" | "text-end" | "text-start" | "tool-call" | "tool-error" | "tool-input-delta" | "tool-input-end" | "tool-input-error" | "tool-input-start" | "tool-result">]: never; }, OrElse extends (value: Exclude<{
3663
3715
  readonly type: "step-start";
3664
3716
  readonly index: number;
3717
+ } | {
3718
+ readonly type: "raw";
3719
+ readonly data: unknown;
3665
3720
  } | {
3666
3721
  readonly type: "text-start";
3667
3722
  readonly id: string;
@@ -3877,6 +3932,9 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
3877
3932
  })), { readonly [K in "type"]: keyof Cases; }>) => any>(cases: Cases, orElse: OrElse): (value: {
3878
3933
  readonly type: "step-start";
3879
3934
  readonly index: number;
3935
+ } | {
3936
+ readonly type: "raw";
3937
+ readonly data: unknown;
3880
3938
  } | {
3881
3939
  readonly type: "text-start";
3882
3940
  readonly id: string;
@@ -4358,6 +4416,13 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
4358
4416
  };
4359
4417
  } | undefined;
4360
4418
  };
4419
+ raw: (input: {
4420
+ readonly type?: "raw" | undefined;
4421
+ readonly data: unknown;
4422
+ }, options?: Schema.MakeOptions) => {
4423
+ readonly type: "raw";
4424
+ readonly data: unknown;
4425
+ };
4361
4426
  is: {
4362
4427
  compaction: (u: unknown) => u is {
4363
4428
  readonly type: "compaction";
@@ -4593,6 +4658,10 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
4593
4658
  };
4594
4659
  } | undefined;
4595
4660
  };
4661
+ raw: (u: unknown) => u is {
4662
+ readonly type: "raw";
4663
+ readonly data: unknown;
4664
+ };
4596
4665
  };
4597
4666
  };
4598
4667
  export type LLMEvent = Schema.Schema.Type<typeof llmEventTagged>;
@@ -4853,8 +4922,11 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
4853
4922
  readonly message: Schema.String;
4854
4923
  readonly classification: Schema.optional<Schema.Literals<readonly ["context-overflow", "payload-too-large"]>>;
4855
4924
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
4925
+ }>, Schema.Struct<{
4926
+ readonly type: Schema.tag<"raw">;
4927
+ readonly data: Schema.Unknown;
4856
4928
  }>]> & {
4857
- readonly discriminants: readonly ["compaction", "step-start", "text-start", "text-delta", "text-end", "reasoning-start", "reasoning-delta", "reasoning-end", "tool-input-start", "tool-input-delta", "tool-input-end", "tool-input-error", "tool-call", "tool-result", "tool-error", "media", "step-finish", "finish", "provider-error"];
4929
+ readonly discriminants: readonly ["compaction", "step-start", "text-start", "text-delta", "text-end", "reasoning-start", "reasoning-delta", "reasoning-end", "tool-input-start", "tool-input-delta", "tool-input-end", "tool-input-error", "tool-call", "tool-result", "tool-error", "media", "step-finish", "finish", "provider-error", "raw"];
4858
4930
  readonly cases: {
4859
4931
  compaction: Schema.refine<{
4860
4932
  readonly type: "compaction";
@@ -4937,6 +5009,10 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
4937
5009
  readonly classification: Schema.optional<Schema.Literals<readonly ["context-overflow", "payload-too-large"]>>;
4938
5010
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
4939
5011
  }>;
5012
+ raw: Schema.Struct<{
5013
+ readonly type: Schema.tag<"raw">;
5014
+ readonly data: Schema.Unknown;
5015
+ }>;
4940
5016
  "reasoning-delta": Schema.Struct<{
4941
5017
  readonly type: Schema.tag<"reasoning-delta">;
4942
5018
  readonly id: Schema.String;
@@ -5112,6 +5188,9 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
5112
5188
  readonly isAnyOf: <const Keys>(keys: readonly Keys[]) => (value: {
5113
5189
  readonly type: "step-start";
5114
5190
  readonly index: number;
5191
+ } | {
5192
+ readonly type: "raw";
5193
+ readonly data: unknown;
5115
5194
  } | {
5116
5195
  readonly type: "text-start";
5117
5196
  readonly id: string;
@@ -5329,6 +5408,11 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
5329
5408
  readonly index: number;
5330
5409
  }, {
5331
5410
  readonly type: Keys;
5411
+ }> | Extract<{
5412
+ readonly type: "raw";
5413
+ readonly data: unknown;
5414
+ }, {
5415
+ readonly type: Keys;
5332
5416
  }> | Extract<{
5333
5417
  readonly type: "text-start";
5334
5418
  readonly id: string;
@@ -5634,6 +5718,10 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
5634
5718
  };
5635
5719
  } | undefined;
5636
5720
  };
5721
+ raw: (u: unknown) => u is {
5722
+ readonly type: "raw";
5723
+ readonly data: unknown;
5724
+ };
5637
5725
  "reasoning-delta": (u: unknown) => u is {
5638
5726
  readonly type: "reasoning-delta";
5639
5727
  readonly id: string;
@@ -6030,6 +6118,9 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
6030
6118
  readonly message: Schema.String;
6031
6119
  readonly classification: Schema.optional<Schema.Literals<readonly ["context-overflow", "payload-too-large"]>>;
6032
6120
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
6121
+ }> | Schema.Struct<{
6122
+ readonly type: Schema.tag<"raw">;
6123
+ readonly data: Schema.Unknown;
6033
6124
  }> | (Schema.refine<{
6034
6125
  readonly type: "compaction";
6035
6126
  readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
@@ -6059,6 +6150,9 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
6059
6150
  }) as M["Type"]["type"]]: (value: M["Type"]) => any; }>(value: {
6060
6151
  readonly type: "step-start";
6061
6152
  readonly index: number;
6153
+ } | {
6154
+ readonly type: "raw";
6155
+ readonly data: unknown;
6062
6156
  } | {
6063
6157
  readonly type: "text-start";
6064
6158
  readonly id: string;
@@ -6479,6 +6573,9 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
6479
6573
  readonly message: Schema.String;
6480
6574
  readonly classification: Schema.optional<Schema.Literals<readonly ["context-overflow", "payload-too-large"]>>;
6481
6575
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
6576
+ }> | Schema.Struct<{
6577
+ readonly type: Schema.tag<"raw">;
6578
+ readonly data: Schema.Unknown;
6482
6579
  }> | (Schema.refine<{
6483
6580
  readonly type: "compaction";
6484
6581
  readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
@@ -6508,6 +6605,9 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
6508
6605
  }) as M["Type"]["type"]]: (value: M["Type"]) => any; }>(cases: Cases): (value: {
6509
6606
  readonly type: "step-start";
6510
6607
  readonly index: number;
6608
+ } | {
6609
+ readonly type: "raw";
6610
+ readonly data: unknown;
6511
6611
  } | {
6512
6612
  readonly type: "text-start";
6513
6613
  readonly id: string;
@@ -6930,6 +7030,9 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
6930
7030
  readonly message: Schema.String;
6931
7031
  readonly classification: Schema.optional<Schema.Literals<readonly ["context-overflow", "payload-too-large"]>>;
6932
7032
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
7033
+ }> | Schema.Struct<{
7034
+ readonly type: Schema.tag<"raw">;
7035
+ readonly data: Schema.Unknown;
6933
7036
  }> | (Schema.refine<{
6934
7037
  readonly type: "compaction";
6935
7038
  readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
@@ -6956,9 +7059,12 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
6956
7059
  readonly text: string | null;
6957
7060
  readonly encrypted?: never;
6958
7061
  })) => CompactionPart;
6959
- }) as M["Type"]["type"]]+?: (value: M["Type"]) => any; } & { [K in Exclude<keyof Cases, "compaction" | "finish" | "media" | "provider-error" | "reasoning-delta" | "reasoning-end" | "reasoning-start" | "step-finish" | "step-start" | "text-delta" | "text-end" | "text-start" | "tool-call" | "tool-error" | "tool-input-delta" | "tool-input-end" | "tool-input-error" | "tool-input-start" | "tool-result">]: never; }, OrElse extends (value: Exclude<{
7062
+ }) as M["Type"]["type"]]+?: (value: M["Type"]) => any; } & { [K in Exclude<keyof Cases, "compaction" | "finish" | "media" | "provider-error" | "raw" | "reasoning-delta" | "reasoning-end" | "reasoning-start" | "step-finish" | "step-start" | "text-delta" | "text-end" | "text-start" | "tool-call" | "tool-error" | "tool-input-delta" | "tool-input-end" | "tool-input-error" | "tool-input-start" | "tool-result">]: never; }, OrElse extends (value: Exclude<{
6960
7063
  readonly type: "step-start";
6961
7064
  readonly index: number;
7065
+ } | {
7066
+ readonly type: "raw";
7067
+ readonly data: unknown;
6962
7068
  } | {
6963
7069
  readonly type: "text-start";
6964
7070
  readonly id: string;
@@ -7174,6 +7280,9 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
7174
7280
  })), { readonly [K in "type"]: keyof Cases; }>) => any>(value: {
7175
7281
  readonly type: "step-start";
7176
7282
  readonly index: number;
7283
+ } | {
7284
+ readonly type: "raw";
7285
+ readonly data: unknown;
7177
7286
  } | {
7178
7287
  readonly type: "text-start";
7179
7288
  readonly id: string;
@@ -7594,6 +7703,9 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
7594
7703
  readonly message: Schema.String;
7595
7704
  readonly classification: Schema.optional<Schema.Literals<readonly ["context-overflow", "payload-too-large"]>>;
7596
7705
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
7706
+ }> | Schema.Struct<{
7707
+ readonly type: Schema.tag<"raw">;
7708
+ readonly data: Schema.Unknown;
7597
7709
  }> | (Schema.refine<{
7598
7710
  readonly type: "compaction";
7599
7711
  readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
@@ -7620,9 +7732,12 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
7620
7732
  readonly text: string | null;
7621
7733
  readonly encrypted?: never;
7622
7734
  })) => CompactionPart;
7623
- }) as M["Type"]["type"]]+?: (value: M["Type"]) => any; } & { [K in Exclude<keyof Cases, "compaction" | "finish" | "media" | "provider-error" | "reasoning-delta" | "reasoning-end" | "reasoning-start" | "step-finish" | "step-start" | "text-delta" | "text-end" | "text-start" | "tool-call" | "tool-error" | "tool-input-delta" | "tool-input-end" | "tool-input-error" | "tool-input-start" | "tool-result">]: never; }, OrElse extends (value: Exclude<{
7735
+ }) as M["Type"]["type"]]+?: (value: M["Type"]) => any; } & { [K in Exclude<keyof Cases, "compaction" | "finish" | "media" | "provider-error" | "raw" | "reasoning-delta" | "reasoning-end" | "reasoning-start" | "step-finish" | "step-start" | "text-delta" | "text-end" | "text-start" | "tool-call" | "tool-error" | "tool-input-delta" | "tool-input-end" | "tool-input-error" | "tool-input-start" | "tool-result">]: never; }, OrElse extends (value: Exclude<{
7624
7736
  readonly type: "step-start";
7625
7737
  readonly index: number;
7738
+ } | {
7739
+ readonly type: "raw";
7740
+ readonly data: unknown;
7626
7741
  } | {
7627
7742
  readonly type: "text-start";
7628
7743
  readonly id: string;
@@ -7838,6 +7953,9 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
7838
7953
  })), { readonly [K in "type"]: keyof Cases; }>) => any>(cases: Cases, orElse: OrElse): (value: {
7839
7954
  readonly type: "step-start";
7840
7955
  readonly index: number;
7956
+ } | {
7957
+ readonly type: "raw";
7958
+ readonly data: unknown;
7841
7959
  } | {
7842
7960
  readonly type: "text-start";
7843
7961
  readonly id: string;
@@ -8319,6 +8437,13 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
8319
8437
  };
8320
8438
  } | undefined;
8321
8439
  };
8440
+ raw: (input: {
8441
+ readonly type?: "raw" | undefined;
8442
+ readonly data: unknown;
8443
+ }, options?: Schema.MakeOptions) => {
8444
+ readonly type: "raw";
8445
+ readonly data: unknown;
8446
+ };
8322
8447
  is: {
8323
8448
  compaction: (u: unknown) => u is {
8324
8449
  readonly type: "compaction";
@@ -8554,6 +8679,10 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
8554
8679
  };
8555
8680
  } | undefined;
8556
8681
  };
8682
+ raw: (u: unknown) => u is {
8683
+ readonly type: "raw";
8684
+ readonly data: unknown;
8685
+ };
8557
8686
  };
8558
8687
  }>;
8559
8688
  readonly usage: Schema.optional<typeof Usage>;