@opencode/ai 0.0.0-dev-537 → 0.0.0-dev-549

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
@@ -11,4 +11,4 @@ export { HttpTransport, WebSocketTransport } from "./transport/index.js";
11
11
  export * as Transport from "./transport/index.js";
12
12
  export { ProviderShared } from "../protocols/shared.js";
13
13
  export { classifyProviderFailure } from "../provider-error.js";
14
- export { mergeHttpOptions } from "../schema/index.js";
14
+ export { mergeTransport } from "../schema/index.js";
@@ -4,19 +4,15 @@ 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, type ProviderOptions } from "../schema/index.js";
7
+ import { AIError, ProviderID, type BaseRequest, type HttpOptions, 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
- export interface MediaRequest {
11
- readonly model: {
12
- readonly id: string;
13
- readonly provider: ProviderID;
14
- readonly http?: HttpOptions;
15
- readonly providerOptions?: ProviderOptions;
16
- };
17
- readonly providerOptions?: ProviderOptions;
10
+ export type MediaRequest = BaseRequest<{
11
+ readonly id: string;
12
+ readonly provider: ProviderID;
18
13
  readonly http?: HttpOptions;
19
- }
14
+ readonly providerOptions?: ProviderOptions;
15
+ }>;
20
16
  /** Deployment inputs every media model factory accepts; provider facades fill these from `configure(...)`. */
21
17
  export interface ModelInput {
22
18
  readonly id: string;
@@ -31,7 +27,7 @@ export interface ModelInput {
31
27
  export declare const deployment: (input: {
32
28
  readonly baseURL?: string;
33
29
  readonly headers?: Record<string, string>;
34
- readonly http?: HttpOptions.Input;
30
+ readonly http?: HttpOptions;
35
31
  }, auth: Auth.Definition) => Omit<ModelInput, "id">;
36
32
  /** One request, one response. */
37
33
  export interface InlineRoute<Request extends MediaRequest, Response> {
@@ -6,16 +6,11 @@ import { RequestExecutor } from "./executor.js";
6
6
  import { MediaProtocol } from "./media-protocol.js";
7
7
  import { Generation, isTerminal } from "../generation.js";
8
8
  import { isRetryable } from "../provider-error.js";
9
- import { AIError, AIErrorReason, HttpOptions, InvalidRequestError, ProviderID, UnsupportedOperationError, mergeHttpOptions, mergeProviderOptions, } from "../schema/index.js";
9
+ import { AIError, AIErrorReason, InvalidRequestError, ProviderID, UnsupportedOperationError, mergeProviderOptions, mergeTransport, } from "../schema/index.js";
10
10
  import { encodeJson } from "../utils/json.js";
11
11
  import { sanitizeSurrogates } from "../utils/sanitize.js";
12
12
  /** A provider facade's `configure(...)` input as the `ModelInput` every media selector shares, minus the model id. */
13
- export const deployment = (input, auth) => ({
14
- auth,
15
- baseURL: input.baseURL,
16
- headers: input.headers,
17
- http: HttpOptions.make(input.http),
18
- });
13
+ export const deployment = (input, auth) => ({ auth, baseURL: input.baseURL, headers: input.headers, http: input.http });
19
14
  /**
20
15
  * Compose an inline media protocol with an endpoint and auth into a runnable route. The route owns the transport
21
16
  * plumbing every media protocol would otherwise duplicate: option merging, surrogate sanitizing, unsupported-field
@@ -59,15 +54,15 @@ export const queued = (input) => {
59
54
  const decodeToken = Schema.decodeUnknownEffect(protocol.token);
60
55
  // A protocol producing a token its own codec rejects is a programmer defect, not a provider error.
61
56
  const encodeToken = Schema.encodeSync(protocol.token);
62
- const generationRoute = (token, http, execute) => {
57
+ const generationRoute = (token, exchange, execute) => {
63
58
  // Only the GET exchange retries: a decoded terminal failure (`output.ended`) can be a `ProviderInternal` too, and
64
59
  // re-reading it would spin until the caller's deadline.
65
- const poll = (operation) => transport.call("GET", operation.path(token), http, execute).pipe(Effect.retry({ schedule: READ_RETRY, while: isRetryable }), Effect.flatMap((sent) => operation.decode(sent.response, { token, auth: sent.auth })));
60
+ const poll = (operation) => transport.call("GET", operation.path(token), exchange, execute).pipe(Effect.retry({ schedule: READ_RETRY, while: isRetryable }), Effect.flatMap((sent) => operation.decode(sent.response, { token, auth: sent.auth })));
66
61
  const status = poll(protocol.status);
67
62
  const cancel = protocol.cancel;
68
63
  const send = cancel === undefined
69
64
  ? undefined
70
- : transport.call(cancel.method, cancel.path(token), http, execute).pipe(Effect.asVoid);
65
+ : transport.call(cancel.method, cancel.path(token), exchange, execute).pipe(Effect.asVoid);
71
66
  return {
72
67
  status,
73
68
  result: poll(protocol.result),
@@ -79,7 +74,7 @@ export const queued = (input) => {
79
74
  const start = Effect.fn("MediaRoute.start")(function* (request, execute) {
80
75
  const submitted = yield* transport.submit(request, { unsupported: protocol.unsupported, prepare: protocol.start.prepare, from: protocol.start.body.from }, execute);
81
76
  const started = yield* protocol.start.decode(submitted.response, submitted.context);
82
- const route = generationRoute(started.token, submitted.context.request.http, execute);
77
+ const route = generationRoute(started.token, submitted.exchange, execute);
83
78
  return new Generation(route, encodeToken(started.token), started.snapshot);
84
79
  });
85
80
  const resume = Effect.fn("MediaRoute.resume")(function* (model, raw, execute) {
@@ -89,7 +84,7 @@ export const queued = (input) => {
89
84
  cause,
90
85
  }),
91
86
  })));
92
- const route = generationRoute(token, transport.http(model), execute);
87
+ const route = generationRoute(token, transport.exchange(model), execute);
93
88
  return new Generation(route, encodeToken(token), yield* route.status);
94
89
  });
95
90
  return { kind: "queued", id: protocol.id, provider: protocol.provider, protocol: protocol.id, start, resume };
@@ -132,11 +127,10 @@ export const stream = (input) => {
132
127
  // Transport plumbing shared by every kind
133
128
  // ---------------------------------------------------------------------------
134
129
  const makeTransport = (input) => {
135
- const routeHttp = input.headers === undefined ? undefined : new HttpOptions({ headers: input.headers });
136
130
  const authorize = Auth.toEffect(input.auth);
137
131
  const baseURL = (path) => new URL(`${Endpoint.trimBaseUrl(input.endpoint.baseURL ?? "")}${path}`);
138
132
  /** `auth` is only what `Auth` added or changed, never untouched deployment headers. */
139
- const send = Effect.fn("MediaRoute.send")(function* (call, execute) {
133
+ const send = Effect.fn("MediaRoute.send")(function* (call, fetch, execute) {
140
134
  const encoded = encode(call.body, call.headers);
141
135
  const url = call.url.toString();
142
136
  const headers = yield* authorize({
@@ -146,41 +140,43 @@ const makeTransport = (input) => {
146
140
  body: encoded.text,
147
141
  headers: encoded.headers,
148
142
  });
149
- const response = yield* execute(encoded.apply(HttpClientRequest.make(call.method)(url).pipe(HttpClientRequest.setHeaders(headers))));
143
+ const response = yield* execute(encoded.apply(HttpClientRequest.make(call.method)(url).pipe(HttpClientRequest.setHeaders(headers))), RequestExecutor.withFetch(fetch));
150
144
  return {
151
145
  response,
152
146
  auth: Object.fromEntries(Object.entries(headers).filter(([key, value]) => encoded.headers[key] !== value)),
153
147
  };
154
148
  });
155
149
  return {
156
- /** Route and model overlays; `start` additionally merges the request's own `http`. */
157
- http: (model) => mergeHttpOptions(routeHttp, model.http),
150
+ /** Route and model overlays; `start` additionally merges the request's own. */
151
+ exchange: (model) => mergeTransport({ headers: input.headers, http: model.http }),
158
152
  /** POST the protocol body to the route endpoint. */
159
153
  submit: Effect.fn("MediaRoute.submit")(function* (request, protocol, execute) {
160
154
  yield* rejectUnsupported(input.protocol.id, input.protocol.provider, request, protocol.unsupported);
161
- const http = mergeHttpOptions(routeHttp, request.model.http, request.http);
155
+ const { headers: merged, http } = mergeTransport({ headers: input.headers, http: request.model.http }, request);
156
+ const exchange = { headers: merged, http, fetch: request.fetch };
162
157
  const providerOptions = mergeProviderOptions(request.model.providerOptions, request.providerOptions);
163
- const headers = Headers.fromInput(http?.headers);
158
+ const headers = Headers.fromInput(merged);
164
159
  const prepared = protocol.prepare === undefined
165
160
  ? request
166
- : yield* protocol.prepare(request, (path, body) => send({ method: "POST", url: baseURL(path), headers, request, body }, execute).pipe(Effect.map((sent) => sent.response)));
161
+ : yield* protocol.prepare(request, (path, body) => send({ method: "POST", url: baseURL(path), headers, request, body }, request.fetch, execute).pipe(Effect.map((sent) => sent.response)));
167
162
  // Sanitize after merging so model-level overlays are covered; the model value is restored, not sanitized.
168
163
  const resolved = {
169
- ...sanitizeSurrogates({ ...prepared, http, providerOptions }),
164
+ ...sanitizeSurrogates({ ...prepared, headers: merged, http, providerOptions }),
170
165
  model: request.model,
171
166
  };
172
167
  const body = yield* protocol.from(resolved);
173
168
  const url = withQuery(withQuery(Endpoint.render(input.endpoint, { request: resolved, body }), body.type === "multipart" ? undefined : body.query), http?.query);
174
- const sent = yield* send({ method: "POST", url, headers, request: resolved, body }, execute);
175
- return { response: sent.response, context: { request: resolved, body } };
169
+ const sent = yield* send({ method: "POST", url, headers, request: resolved, body }, request.fetch, execute);
170
+ return { response: sent.response, context: { request: resolved, body }, exchange };
176
171
  }),
177
172
  /** Bodiless follow-up call (status, result, cancel) with the same auth and headers as `submit`. */
178
- call: (method, path, http, execute) => {
173
+ call: (method, path, exchange, execute) => {
179
174
  // Provider-issued absolute URLs are used as-is; everything else resolves against the base.
180
- const url = withQuery(/^https?:\/\//.test(path) ? new URL(path) : baseURL(path), http?.query);
175
+ const url = withQuery(/^https?:\/\//.test(path) ? new URL(path) : baseURL(path), exchange.http?.query);
181
176
  for (const [key, value] of Object.entries(input.endpoint.query ?? {}))
182
177
  url.searchParams.set(key, value);
183
- return send({ method, url, headers: Headers.fromInput(http?.headers), request: { http } }, execute);
178
+ const headers = Headers.fromInput(exchange.headers);
179
+ return send({ method, url, headers, request: { http: exchange.http } }, exchange.fetch, execute);
184
180
  },
185
181
  };
186
182
  };
@@ -4,7 +4,7 @@ import { Auth } from "../auth.js";
4
4
  import { render as renderEndpoint } from "../endpoint.js";
5
5
  import { Framing } from "../framing.js";
6
6
  import * as ProviderShared from "../../protocols/shared.js";
7
- import { AIError, DEFAULT_CHUNK_TIMEOUT_MS, DEFAULT_HTTP_TIMEOUT_MS, mergeJsonRecords, TransportError, } from "../../schema/index.js";
7
+ import { AIError, DEFAULT_CHUNK_TIMEOUT_MS, DEFAULT_HTTP_TIMEOUT_MS, mergeJsonRecords, timeoutConfig, TransportError, } from "../../schema/index.js";
8
8
  import { RequestExecutor } from "../executor.js";
9
9
  const bodyWithOverlay = (body, request, encodeBody) => Effect.gen(function* () {
10
10
  if (request.http?.body === undefined)
@@ -29,7 +29,7 @@ export const jsonRequestParts = (input) => Effect.gen(function* () {
29
29
  body: body.bodyText,
30
30
  headers: Headers.fromInput({
31
31
  ...input.headers?.({ request: input.request }),
32
- ...input.request.http?.headers,
32
+ ...input.request.headers,
33
33
  }),
34
34
  });
35
35
  return { url, jsonBody: body.jsonBody, bodyText: body.bodyText, headers };
@@ -63,17 +63,18 @@ export const httpJson = (input) => ({
63
63
  }),
64
64
  });
65
65
  const started = yield* Clock.currentTimeMillis;
66
+ const limits = timeoutConfig(request.timeout);
66
67
  // Unlike the header and chunk limits, the whole-request budget has no default.
67
- const total = request.http?.timeout ? Duration.millis(request.http.timeout) : Duration.infinity;
68
+ const total = limits.total ? Duration.millis(limits.total) : Duration.infinity;
68
69
  const response = yield* runtime.http.execute(prepared.request, prepared.middleware).pipe(Effect.timeoutOrElse({
69
- duration: Duration.min(timeoutDuration(request.http?.headerTimeout), total),
70
+ duration: Duration.min(timeoutDuration(limits.headers), total),
70
71
  orElse: () => timeout("request", "Timed out waiting for response headers"),
71
72
  }));
72
73
  const http = RequestExecutor.responseHttp(response);
73
74
  const remaining = Duration.subtract(total, Duration.millis((yield* Clock.currentTimeMillis) - started));
74
75
  return {
75
76
  frames: prepared.framing.frame(RequestExecutor.responseStream(response).pipe(Stream.timeoutOrElse({
76
- duration: timeoutDuration(request.http?.chunkTimeout, DEFAULT_CHUNK_TIMEOUT_MS),
77
+ duration: timeoutDuration(limits.chunk, DEFAULT_CHUNK_TIMEOUT_MS),
77
78
  orElse: () => Stream.fail(timeout("read", "Timed out waiting for response data", http)),
78
79
  }), Stream.interruptWhen(Effect.sleep(remaining).pipe(Effect.andThen(Effect.fail(timeout("read", "Timed out waiting for the response to complete", http))))))),
79
80
  http,
@@ -1,6 +1,6 @@
1
1
  import { Schema } from "effect";
2
2
  import { ContentBlockID, ToolCallID } from "./ids.js";
3
- import { Message, CompactionPart, ToolOutput, ToolResultValue } from "./messages.js";
3
+ import { AssistantMessage, Message, CompactionPart, ToolOutput, ToolResultPart, ToolResultValue } from "./messages.js";
4
4
  import { ProviderMetadata } from "./options.js";
5
5
  import { Media } from "../media.js";
6
6
  export declare const FinishReason: Schema.Literals<readonly ["stop", "length", "tool-calls", "content-filter", "error", "unknown"]>;
@@ -111,7 +111,30 @@ export declare const tokenUsage: (counts: {
111
111
  readonly details?: Record<string, unknown>;
112
112
  }) => MediaUsage | undefined;
113
113
  declare const CompactionResponse_base: Schema.Class<CompactionResponse, Schema.Struct<{
114
- readonly replacement: Schema.$Array<typeof Message>;
114
+ readonly replacement: Schema.$Array<Schema.Union<readonly [typeof import("./messages.js").SystemMessage, typeof import("./messages.js").UserMessage, typeof AssistantMessage, typeof import("./messages.js").ToolMessage]> & {
115
+ text: (value: string) => import("./messages.js").TextPart;
116
+ media: (media: import("./messages.js").MediaPartInput["media"], options?: Omit<import("./messages.js").MediaPartInput, "type" | "media">) => import("./messages.js").MediaPart;
117
+ content: {
118
+ (input: Message.UserContentInput): import("./messages.js").UserMessage["content"];
119
+ (input: Message.AssistantContentInput): AssistantMessage["content"];
120
+ (input: Message.ContentInput): ReadonlyArray<import("./messages.js").ContentPart>;
121
+ };
122
+ make: {
123
+ (input: import("./messages.js").SystemMessage | Message.SystemInput): import("./messages.js").SystemMessage;
124
+ (input: import("./messages.js").UserMessage | Message.UserInput): import("./messages.js").UserMessage;
125
+ (input: AssistantMessage | Message.AssistantInput): AssistantMessage;
126
+ (input: import("./messages.js").ToolMessage | Message.ToolInput): import("./messages.js").ToolMessage;
127
+ (input: Message | Message.Input): Message;
128
+ };
129
+ user: (input: Message.UserContentInput) => import("./messages.js").UserMessage;
130
+ assistant: (input: Message.AssistantContentInput) => AssistantMessage;
131
+ system: (input: Message.SystemContentInput) => import("./messages.js").SystemMessage;
132
+ effort: (input: {
133
+ readonly effort?: import("./options.js").ReasoningEffort;
134
+ readonly previous?: import("./options.js").ReasoningEffort;
135
+ }) => import("./messages.js").SystemMessage;
136
+ tool: (result: ToolResultPart | Parameters<typeof ToolResultPart.make>[0]) => import("./messages.js").ToolMessage;
137
+ }>;
115
138
  readonly usage: Schema.optional<typeof Usage>;
116
139
  }>, {}>;
117
140
  /** A replacement context window, not an assistant message to append to prior history. */
@@ -361,7 +384,7 @@ export declare const Finish: Schema.Struct<{
361
384
  }>;
362
385
  readonly usage: Schema.optional<typeof Usage>;
363
386
  /** The final assistant message, set by `ai.stream` and `ai.loop`. */
364
- readonly message: Schema.optional<typeof Message>;
387
+ readonly message: Schema.optional<typeof AssistantMessage>;
365
388
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
366
389
  }>;
367
390
  export type Finish = Schema.Schema.Type<typeof Finish>;
@@ -628,7 +651,7 @@ declare const llmEventTagged: Schema.toTaggedUnion<"type", readonly [Schema.refi
628
651
  }>;
629
652
  readonly usage: Schema.optional<typeof Usage>;
630
653
  /** The final assistant message, set by `ai.stream` and `ai.loop`. */
631
- readonly message: Schema.optional<typeof Message>;
654
+ readonly message: Schema.optional<typeof AssistantMessage>;
632
655
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
633
656
  }>, Schema.Struct<{
634
657
  readonly type: Schema.tag<"raw">;
@@ -869,7 +892,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
869
892
  }>;
870
893
  readonly usage: Schema.optional<typeof Usage>;
871
894
  /** The final assistant message, set by `ai.stream` and `ai.loop`. */
872
- readonly message: Schema.optional<typeof Message>;
895
+ readonly message: Schema.optional<typeof AssistantMessage>;
873
896
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
874
897
  }>, Schema.Struct<{
875
898
  readonly type: Schema.tag<"raw">;
@@ -917,7 +940,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
917
940
  }>;
918
941
  readonly usage: Schema.optional<typeof Usage>;
919
942
  /** The final assistant message, set by `ai.stream` and `ai.loop`. */
920
- readonly message: Schema.optional<typeof Message>;
943
+ readonly message: Schema.optional<typeof AssistantMessage>;
921
944
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
922
945
  }>;
923
946
  media: Schema.Struct<{
@@ -1294,7 +1317,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
1294
1317
  readonly explanation?: string | undefined;
1295
1318
  };
1296
1319
  readonly usage?: Usage | undefined;
1297
- readonly message?: Message | undefined;
1320
+ readonly message?: AssistantMessage | undefined;
1298
1321
  readonly providerMetadata?: {
1299
1322
  readonly [x: string]: {
1300
1323
  readonly [x: string]: unknown;
@@ -1522,7 +1545,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
1522
1545
  readonly explanation?: string | undefined;
1523
1546
  };
1524
1547
  readonly usage?: Usage | undefined;
1525
- readonly message?: Message | undefined;
1548
+ readonly message?: AssistantMessage | undefined;
1526
1549
  readonly providerMetadata?: {
1527
1550
  readonly [x: string]: {
1528
1551
  readonly [x: string]: unknown;
@@ -1586,7 +1609,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
1586
1609
  readonly explanation?: string | undefined;
1587
1610
  };
1588
1611
  readonly usage?: Usage | undefined;
1589
- readonly message?: Message | undefined;
1612
+ readonly message?: AssistantMessage | undefined;
1590
1613
  readonly providerMetadata?: {
1591
1614
  readonly [x: string]: {
1592
1615
  readonly [x: string]: unknown;
@@ -1822,7 +1845,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
1822
1845
  }>;
1823
1846
  readonly usage: Schema.optional<typeof Usage>;
1824
1847
  /** The final assistant message, set by `ai.stream` and `ai.loop`. */
1825
- readonly message: Schema.optional<typeof Message>;
1848
+ readonly message: Schema.optional<typeof AssistantMessage>;
1826
1849
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
1827
1850
  }>;
1828
1851
  readonly media: Schema.Struct<{
@@ -2198,7 +2221,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
2198
2221
  readonly explanation?: string | undefined;
2199
2222
  };
2200
2223
  readonly usage?: Usage | undefined;
2201
- readonly message?: Message | undefined;
2224
+ readonly message?: AssistantMessage | undefined;
2202
2225
  readonly providerMetadata?: {
2203
2226
  readonly [x: string]: {
2204
2227
  readonly [x: string]: unknown;
@@ -2265,7 +2288,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
2265
2288
  }>;
2266
2289
  readonly usage: Schema.optional<typeof Usage>;
2267
2290
  /** The final assistant message, set by `ai.stream` and `ai.loop`. */
2268
- readonly message: Schema.optional<typeof Message>;
2291
+ readonly message: Schema.optional<typeof AssistantMessage>;
2269
2292
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
2270
2293
  }>;
2271
2294
  readonly media: Schema.Struct<{
@@ -2641,7 +2664,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
2641
2664
  readonly explanation?: string | undefined;
2642
2665
  };
2643
2666
  readonly usage?: Usage | undefined;
2644
- readonly message?: Message | undefined;
2667
+ readonly message?: AssistantMessage | undefined;
2645
2668
  readonly providerMetadata?: {
2646
2669
  readonly [x: string]: {
2647
2670
  readonly [x: string]: unknown;
@@ -2842,7 +2865,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
2842
2865
  readonly explanation?: string | undefined;
2843
2866
  };
2844
2867
  readonly usage?: Usage | undefined;
2845
- readonly message?: Message | undefined;
2868
+ readonly message?: AssistantMessage | undefined;
2846
2869
  readonly providerMetadata?: {
2847
2870
  readonly [x: string]: {
2848
2871
  readonly [x: string]: unknown;
@@ -2891,7 +2914,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
2891
2914
  readonly explanation?: string | undefined;
2892
2915
  };
2893
2916
  readonly usage?: Usage | undefined;
2894
- readonly message?: Message | undefined;
2917
+ readonly message?: AssistantMessage | undefined;
2895
2918
  readonly providerMetadata?: {
2896
2919
  readonly [x: string]: {
2897
2920
  readonly [x: string]: unknown;
@@ -3287,7 +3310,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
3287
3310
  readonly explanation?: string | undefined;
3288
3311
  };
3289
3312
  readonly usage?: Usage | undefined;
3290
- readonly message?: Message | undefined;
3313
+ readonly message?: AssistantMessage | undefined;
3291
3314
  readonly providerMetadata?: {
3292
3315
  readonly [x: string]: {
3293
3316
  readonly [x: string]: unknown;
@@ -3351,7 +3374,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
3351
3374
  readonly explanation?: string | undefined;
3352
3375
  };
3353
3376
  readonly usage?: Usage | undefined;
3354
- readonly message?: Message | undefined;
3377
+ readonly message?: AssistantMessage | undefined;
3355
3378
  readonly providerMetadata?: {
3356
3379
  readonly [x: string]: {
3357
3380
  readonly [x: string]: unknown;
@@ -3747,7 +3770,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
3747
3770
  readonly explanation?: string | undefined;
3748
3771
  };
3749
3772
  readonly usage?: Usage | undefined;
3750
- readonly message?: Message | undefined;
3773
+ readonly message?: AssistantMessage | undefined;
3751
3774
  readonly providerMetadata?: {
3752
3775
  readonly [x: string]: {
3753
3776
  readonly [x: string]: unknown;
@@ -3959,7 +3982,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
3959
3982
  readonly explanation?: string | undefined;
3960
3983
  };
3961
3984
  readonly usage?: Usage | undefined;
3962
- readonly message?: Message | undefined;
3985
+ readonly message?: AssistantMessage | undefined;
3963
3986
  readonly providerMetadata?: {
3964
3987
  readonly [x: string]: {
3965
3988
  readonly [x: string]: unknown;
@@ -4216,7 +4239,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
4216
4239
  readonly explanation?: string | undefined;
4217
4240
  };
4218
4241
  readonly usage?: Usage | undefined;
4219
- readonly message?: Message | undefined;
4242
+ readonly message?: AssistantMessage | undefined;
4220
4243
  readonly providerMetadata?: {
4221
4244
  readonly [x: string]: {
4222
4245
  readonly [x: string]: unknown;
@@ -4436,7 +4459,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
4436
4459
  readonly explanation?: string | undefined;
4437
4460
  };
4438
4461
  readonly usage?: Usage | undefined;
4439
- readonly message?: Message | undefined;
4462
+ readonly message?: AssistantMessage | undefined;
4440
4463
  readonly providerMetadata?: {
4441
4464
  readonly [x: string]: {
4442
4465
  readonly [x: string]: unknown;
@@ -4463,7 +4486,7 @@ interface ToolInputAssembly {
4463
4486
  }
4464
4487
  interface ResponseState {
4465
4488
  readonly events: LLMEvent[];
4466
- readonly message: Message;
4489
+ readonly message: AssistantMessage;
4467
4490
  readonly usage?: Usage;
4468
4491
  readonly finishReason?: FinishReasonDetails;
4469
4492
  readonly textParts: Readonly<Record<string, ContentAssembly>>;
@@ -4473,7 +4496,7 @@ interface ResponseState {
4473
4496
  declare const emptyResponseState: () => ResponseState;
4474
4497
  declare const reduceResponseState: (state: ResponseState, event: LLMEvent) => ResponseState;
4475
4498
  declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
4476
- readonly message: typeof Message;
4499
+ readonly message: typeof AssistantMessage;
4477
4500
  readonly events: Schema.$Array<Schema.Union<readonly [Schema.refine<{
4478
4501
  readonly type: "compaction";
4479
4502
  readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
@@ -4694,7 +4717,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
4694
4717
  }>;
4695
4718
  readonly usage: Schema.optional<typeof Usage>;
4696
4719
  /** The final assistant message, set by `ai.stream` and `ai.loop`. */
4697
- readonly message: Schema.optional<typeof Message>;
4720
+ readonly message: Schema.optional<typeof AssistantMessage>;
4698
4721
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
4699
4722
  }>, Schema.Struct<{
4700
4723
  readonly type: Schema.tag<"raw">;
@@ -4742,7 +4765,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
4742
4765
  }>;
4743
4766
  readonly usage: Schema.optional<typeof Usage>;
4744
4767
  /** The final assistant message, set by `ai.stream` and `ai.loop`. */
4745
- readonly message: Schema.optional<typeof Message>;
4768
+ readonly message: Schema.optional<typeof AssistantMessage>;
4746
4769
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
4747
4770
  }>;
4748
4771
  media: Schema.Struct<{
@@ -5119,7 +5142,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
5119
5142
  readonly explanation?: string | undefined;
5120
5143
  };
5121
5144
  readonly usage?: Usage | undefined;
5122
- readonly message?: Message | undefined;
5145
+ readonly message?: AssistantMessage | undefined;
5123
5146
  readonly providerMetadata?: {
5124
5147
  readonly [x: string]: {
5125
5148
  readonly [x: string]: unknown;
@@ -5347,7 +5370,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
5347
5370
  readonly explanation?: string | undefined;
5348
5371
  };
5349
5372
  readonly usage?: Usage | undefined;
5350
- readonly message?: Message | undefined;
5373
+ readonly message?: AssistantMessage | undefined;
5351
5374
  readonly providerMetadata?: {
5352
5375
  readonly [x: string]: {
5353
5376
  readonly [x: string]: unknown;
@@ -5411,7 +5434,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
5411
5434
  readonly explanation?: string | undefined;
5412
5435
  };
5413
5436
  readonly usage?: Usage | undefined;
5414
- readonly message?: Message | undefined;
5437
+ readonly message?: AssistantMessage | undefined;
5415
5438
  readonly providerMetadata?: {
5416
5439
  readonly [x: string]: {
5417
5440
  readonly [x: string]: unknown;
@@ -5647,7 +5670,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
5647
5670
  }>;
5648
5671
  readonly usage: Schema.optional<typeof Usage>;
5649
5672
  /** The final assistant message, set by `ai.stream` and `ai.loop`. */
5650
- readonly message: Schema.optional<typeof Message>;
5673
+ readonly message: Schema.optional<typeof AssistantMessage>;
5651
5674
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
5652
5675
  }>;
5653
5676
  readonly media: Schema.Struct<{
@@ -6023,7 +6046,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
6023
6046
  readonly explanation?: string | undefined;
6024
6047
  };
6025
6048
  readonly usage?: Usage | undefined;
6026
- readonly message?: Message | undefined;
6049
+ readonly message?: AssistantMessage | undefined;
6027
6050
  readonly providerMetadata?: {
6028
6051
  readonly [x: string]: {
6029
6052
  readonly [x: string]: unknown;
@@ -6090,7 +6113,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
6090
6113
  }>;
6091
6114
  readonly usage: Schema.optional<typeof Usage>;
6092
6115
  /** The final assistant message, set by `ai.stream` and `ai.loop`. */
6093
- readonly message: Schema.optional<typeof Message>;
6116
+ readonly message: Schema.optional<typeof AssistantMessage>;
6094
6117
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
6095
6118
  }>;
6096
6119
  readonly media: Schema.Struct<{
@@ -6466,7 +6489,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
6466
6489
  readonly explanation?: string | undefined;
6467
6490
  };
6468
6491
  readonly usage?: Usage | undefined;
6469
- readonly message?: Message | undefined;
6492
+ readonly message?: AssistantMessage | undefined;
6470
6493
  readonly providerMetadata?: {
6471
6494
  readonly [x: string]: {
6472
6495
  readonly [x: string]: unknown;
@@ -6667,7 +6690,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
6667
6690
  readonly explanation?: string | undefined;
6668
6691
  };
6669
6692
  readonly usage?: Usage | undefined;
6670
- readonly message?: Message | undefined;
6693
+ readonly message?: AssistantMessage | undefined;
6671
6694
  readonly providerMetadata?: {
6672
6695
  readonly [x: string]: {
6673
6696
  readonly [x: string]: unknown;
@@ -6716,7 +6739,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
6716
6739
  readonly explanation?: string | undefined;
6717
6740
  };
6718
6741
  readonly usage?: Usage | undefined;
6719
- readonly message?: Message | undefined;
6742
+ readonly message?: AssistantMessage | undefined;
6720
6743
  readonly providerMetadata?: {
6721
6744
  readonly [x: string]: {
6722
6745
  readonly [x: string]: unknown;
@@ -7112,7 +7135,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
7112
7135
  readonly explanation?: string | undefined;
7113
7136
  };
7114
7137
  readonly usage?: Usage | undefined;
7115
- readonly message?: Message | undefined;
7138
+ readonly message?: AssistantMessage | undefined;
7116
7139
  readonly providerMetadata?: {
7117
7140
  readonly [x: string]: {
7118
7141
  readonly [x: string]: unknown;
@@ -7176,7 +7199,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
7176
7199
  readonly explanation?: string | undefined;
7177
7200
  };
7178
7201
  readonly usage?: Usage | undefined;
7179
- readonly message?: Message | undefined;
7202
+ readonly message?: AssistantMessage | undefined;
7180
7203
  readonly providerMetadata?: {
7181
7204
  readonly [x: string]: {
7182
7205
  readonly [x: string]: unknown;
@@ -7572,7 +7595,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
7572
7595
  readonly explanation?: string | undefined;
7573
7596
  };
7574
7597
  readonly usage?: Usage | undefined;
7575
- readonly message?: Message | undefined;
7598
+ readonly message?: AssistantMessage | undefined;
7576
7599
  readonly providerMetadata?: {
7577
7600
  readonly [x: string]: {
7578
7601
  readonly [x: string]: unknown;
@@ -7784,7 +7807,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
7784
7807
  readonly explanation?: string | undefined;
7785
7808
  };
7786
7809
  readonly usage?: Usage | undefined;
7787
- readonly message?: Message | undefined;
7810
+ readonly message?: AssistantMessage | undefined;
7788
7811
  readonly providerMetadata?: {
7789
7812
  readonly [x: string]: {
7790
7813
  readonly [x: string]: unknown;
@@ -8041,7 +8064,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
8041
8064
  readonly explanation?: string | undefined;
8042
8065
  };
8043
8066
  readonly usage?: Usage | undefined;
8044
- readonly message?: Message | undefined;
8067
+ readonly message?: AssistantMessage | undefined;
8045
8068
  readonly providerMetadata?: {
8046
8069
  readonly [x: string]: {
8047
8070
  readonly [x: string]: unknown;
@@ -8261,7 +8284,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
8261
8284
  readonly explanation?: string | undefined;
8262
8285
  };
8263
8286
  readonly usage?: Usage | undefined;
8264
- readonly message?: Message | undefined;
8287
+ readonly message?: AssistantMessage | undefined;
8265
8288
  readonly providerMetadata?: {
8266
8289
  readonly [x: string]: {
8267
8290
  readonly [x: string]: unknown;
@@ -1,7 +1,7 @@
1
1
  import { Schema } from "effect";
2
2
  import { LLM } from "@opencode/schema/llm";
3
3
  import { ContentBlockID, ToolCallID } from "./ids.js";
4
- import { Message, CompactionPart, ToolCallPart, ToolOutput, ToolResultPart, ToolResultValue, } from "./messages.js";
4
+ import { AssistantMessage, Message, CompactionPart, ToolCallPart, ToolOutput, ToolResultPart, ToolResultValue, } from "./messages.js";
5
5
  import { ProviderMetadata } from "./options.js";
6
6
  import { Media } from "../media.js";
7
7
  export const FinishReason = LLM.FinishReason;
@@ -228,7 +228,7 @@ export const Finish = Schema.Struct({
228
228
  reason: FinishReasonDetails,
229
229
  usage: Schema.optional(Usage),
230
230
  /** The final assistant message, set by `ai.stream` and `ai.loop`. */
231
- message: Schema.optional(Message),
231
+ message: Schema.optional(AssistantMessage),
232
232
  providerMetadata: Schema.optional(ProviderMetadata),
233
233
  }).annotate({ identifier: "LLM.Event.Finish" });
234
234
  /** A generated media asset (image, audio, …) emitted by the model as first-class output rather than a tool result. */
@@ -500,7 +500,7 @@ const reduceResponseState = (state, event) => {
500
500
  }
501
501
  };
502
502
  export class LLMResponse extends Schema.Class("LLM.Response")({
503
- message: Message,
503
+ message: AssistantMessage,
504
504
  events: Schema.Array(LLMEvent),
505
505
  usage: Schema.optional(Usage),
506
506
  finishReason: FinishReasonDetails,