@opencode-ai/ai 0.0.0-dev-18544 → 0.0.0-dev-18548

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.
package/dist/llm.d.ts CHANGED
@@ -45,6 +45,7 @@ export declare class GenerateObjectResponse<T> {
45
45
  } | {
46
46
  readonly id: string;
47
47
  readonly type: "text-end";
48
+ readonly text?: string | undefined;
48
49
  readonly providerMetadata?: {
49
50
  readonly [x: string]: {
50
51
  readonly [x: string]: unknown;
@@ -70,6 +71,7 @@ export declare class GenerateObjectResponse<T> {
70
71
  } | {
71
72
  readonly id: string;
72
73
  readonly type: "reasoning-end";
74
+ readonly text?: string | undefined;
73
75
  readonly providerMetadata?: {
74
76
  readonly [x: string]: {
75
77
  readonly [x: string]: unknown;
@@ -829,6 +829,7 @@ export declare const step: (state: ParserState, input: Event) => AIError | Effec
829
829
  } | {
830
830
  readonly id: string;
831
831
  readonly type: "text-end";
832
+ readonly text?: string | undefined;
832
833
  readonly providerMetadata?: {
833
834
  readonly [x: string]: {
834
835
  readonly [x: string]: unknown;
@@ -854,6 +855,7 @@ export declare const step: (state: ParserState, input: Event) => AIError | Effec
854
855
  } | {
855
856
  readonly id: string;
856
857
  readonly type: "reasoning-end";
858
+ readonly text?: string | undefined;
857
859
  readonly providerMetadata?: {
858
860
  readonly [x: string]: {
859
861
  readonly [x: string]: unknown;
@@ -10,8 +10,12 @@ export declare const textStart: (state: State, events: LLMEvent[], id: string, p
10
10
  export declare const textDelta: (state: State, events: LLMEvent[], id: string, text: string, providerMetadata?: ProviderMetadata) => State;
11
11
  export declare const reasoningStart: (state: State, events: LLMEvent[], id: string, providerMetadata?: ProviderMetadata) => State;
12
12
  export declare const reasoningDelta: (state: State, events: LLMEvent[], id: string, text: string, providerMetadata?: ProviderMetadata) => State;
13
- export declare const reasoningEnd: (state: State, events: LLMEvent[], id: string, providerMetadata?: ProviderMetadata) => State;
14
- export declare const textEnd: (state: State, events: LLMEvent[], id: string, providerMetadata?: ProviderMetadata) => State;
13
+ export declare const reasoningEnd: (state: State, events: LLMEvent[], id: string, providerMetadata?: ProviderMetadata,
14
+ /** Authoritative complete value; replaces accumulated deltas when present. */
15
+ text?: string) => State;
16
+ export declare const textEnd: (state: State, events: LLMEvent[], id: string, providerMetadata?: ProviderMetadata,
17
+ /** Authoritative complete value; replaces accumulated deltas when present. */
18
+ text?: string) => State;
15
19
  export declare const finish: (state: State, events: LLMEvent[], input: {
16
20
  readonly reason: FinishReasonDetails;
17
21
  readonly usage?: Usage;
@@ -30,23 +30,27 @@ export const reasoningDelta = (state, events, id, text, providerMetadata) => {
30
30
  events.push(LLMEvent.reasoningDelta({ id, text, providerMetadata }));
31
31
  return started;
32
32
  };
33
- export const reasoningEnd = (state, events, id, providerMetadata) => {
33
+ export const reasoningEnd = (state, events, id, providerMetadata,
34
+ /** Authoritative complete value; replaces accumulated deltas when present. */
35
+ text) => {
34
36
  if (!state.reasoning.has(id))
35
37
  return state;
36
38
  const stepped = stepStart(state, events);
37
- events.push(LLMEvent.reasoningEnd({ id, providerMetadata }));
39
+ events.push(LLMEvent.reasoningEnd({ id, text, providerMetadata }));
38
40
  const reasoning = new Set(stepped.reasoning);
39
41
  reasoning.delete(id);
40
42
  return { ...stepped, reasoning };
41
43
  };
42
- export const textEnd = (state, events, id, providerMetadata) => {
44
+ export const textEnd = (state, events, id, providerMetadata,
45
+ /** Authoritative complete value; replaces accumulated deltas when present. */
46
+ text) => {
43
47
  if (!state.text.has(id))
44
48
  return state;
45
49
  const stepped = stepStart(state, events);
46
- events.push(LLMEvent.textEnd({ id, providerMetadata }));
47
- const text = new Set(stepped.text);
48
- text.delete(id);
49
- return { ...stepped, text };
50
+ events.push(LLMEvent.textEnd({ id, text, providerMetadata }));
51
+ const open = new Set(stepped.text);
52
+ open.delete(id);
53
+ return { ...stepped, text: open };
50
54
  };
51
55
  const closeOpenBlocks = (state, events) => {
52
56
  for (const id of state.reasoning)
@@ -93,6 +93,7 @@ export declare const finish: <K extends StreamKey>(route: string, tools: State<K
93
93
  } | {
94
94
  readonly id: string;
95
95
  readonly type: "text-end";
96
+ readonly text?: string | undefined;
96
97
  readonly providerMetadata?: {
97
98
  readonly [x: string]: {
98
99
  readonly [x: string]: unknown;
@@ -118,6 +119,7 @@ export declare const finish: <K extends StreamKey>(route: string, tools: State<K
118
119
  } | {
119
120
  readonly id: string;
120
121
  readonly type: "reasoning-end";
122
+ readonly text?: string | undefined;
121
123
  readonly providerMetadata?: {
122
124
  readonly [x: string]: {
123
125
  readonly [x: string]: unknown;
@@ -287,6 +289,7 @@ export declare const finishWithInput: <K extends StreamKey>(route: string, tools
287
289
  } | {
288
290
  readonly id: string;
289
291
  readonly type: "text-end";
292
+ readonly text?: string | undefined;
290
293
  readonly providerMetadata?: {
291
294
  readonly [x: string]: {
292
295
  readonly [x: string]: unknown;
@@ -312,6 +315,7 @@ export declare const finishWithInput: <K extends StreamKey>(route: string, tools
312
315
  } | {
313
316
  readonly id: string;
314
317
  readonly type: "reasoning-end";
318
+ readonly text?: string | undefined;
315
319
  readonly providerMetadata?: {
316
320
  readonly [x: string]: {
317
321
  readonly [x: string]: unknown;
@@ -478,6 +482,7 @@ export declare const finishAll: <K extends StreamKey>(route: string, tools: Stat
478
482
  } | {
479
483
  readonly id: string;
480
484
  readonly type: "text-end";
485
+ readonly text?: string | undefined;
481
486
  readonly providerMetadata?: {
482
487
  readonly [x: string]: {
483
488
  readonly [x: string]: unknown;
@@ -503,6 +508,7 @@ export declare const finishAll: <K extends StreamKey>(route: string, tools: Stat
503
508
  } | {
504
509
  readonly id: string;
505
510
  readonly type: "reasoning-end";
511
+ readonly text?: string | undefined;
506
512
  readonly providerMetadata?: {
507
513
  readonly [x: string]: {
508
514
  readonly [x: string]: unknown;
@@ -24,6 +24,7 @@ const patterns = [
24
24
  /too large for model with \d+ maximum context length/i,
25
25
  /prompt has [\d,]+ tokens?, but the configured context size is [\d,]+ tokens?/i,
26
26
  /model_context_window_exceeded/i,
27
+ /range of input length should be/i,
27
28
  /too many tokens/i,
28
29
  /token limit exceeded/i,
29
30
  /request_too_large/i,
@@ -38,6 +39,7 @@ export const isContextOverflowFailure = (failure) => failure instanceof AIError
38
39
  : Schema.is(ProviderErrorEvent)(failure) && failure.classification === "context-overflow";
39
40
  const decodeJson = Schema.decodeUnknownOption(Schema.fromJsonString(Schema.Unknown));
40
41
  const QUOTA_CODES = new Set(["insufficient_quota", "usage_not_included", "billing_error"]);
42
+ const AUTH_CODES = new Set(["authentication_error", "permission_error"]);
41
43
  const SERVER_CODES = new Set([
42
44
  "api_error",
43
45
  "internal_error",
@@ -53,9 +55,12 @@ const INVALID_REQUEST_CODES = new Set(["invalid_prompt", "invalid_request_error"
53
55
  const RATE_LIMIT_TEXT = /rate increased too quickly|rate[-_\s]?limit|too[_\s]?many[_\s]?requests/i;
54
56
  const QUOTA_TEXT = /insufficient[-_\s]?quota|quota[-_\s]?exceeded/i;
55
57
  const CONTENT_POLICY_TEXT = /content[-_\s]?policy|content_filter|safety/i;
56
- const NETWORK_ERROR_TEXT = /network[-_\s]error/i;
57
- // Keep HTTP failures and provider-reported stream failures on one typed path so
58
- // session retry policy never needs provider-specific string matching.
58
+ // Classification records affirmative evidence about a failure. Deterministic
59
+ // failures need positive identification (a 4xx status, quota/auth/policy
60
+ // signals); anything unrecognized stays UnknownProvider, which the session
61
+ // retry policy treats as retry-eligible because transient failures arrive in
62
+ // unpredictable shapes while deterministic rejections almost always carry a
63
+ // status or known code.
59
64
  export function classifyProviderFailure(input) {
60
65
  const details = { message: input.message, body: input.rawBody, http: input.http, cause: input.cause };
61
66
  const body = input.rawBody ?? "";
@@ -76,48 +81,28 @@ export function classifyProviderFailure(input) {
76
81
  return new ContentPolicyError(details);
77
82
  if (codes.some((code) => QUOTA_CODES.has(code)) || (input.status === 429 && QUOTA_TEXT.test(text)))
78
83
  return new QuotaExceededError(details);
79
- if (input.status === 401)
80
- return new AuthenticationError({ ...details, kind: "invalid" });
81
- if (input.status === 403)
82
- return new AuthenticationError({ ...details, kind: "insufficient-permissions" });
83
- if (codes.includes("authentication_error"))
84
- return new AuthenticationError({ ...details, kind: "invalid" });
85
- if (codes.includes("permission_error"))
86
- return new AuthenticationError({ ...details, kind: "insufficient-permissions" });
87
- if (codes.some((code) => code.includes("rate_limit") || code === "too_many_requests" || code === "throttlingexception"))
84
+ if (input.status === 401 || input.status === 403 || codes.some((code) => AUTH_CODES.has(code)))
85
+ return new AuthenticationError(details);
86
+ if (input.status === 429 ||
87
+ codes.some((code) => code.includes("rate_limit") || code === "too_many_requests" || code === "throttlingexception") ||
88
+ RATE_LIMIT_TEXT.test(text))
88
89
  return new RateLimitError({
89
90
  ...details,
90
91
  retryAfterMs: input.retryAfterMs,
91
92
  rateLimit: input.rateLimit,
92
93
  });
93
- if (RATE_LIMIT_TEXT.test(text))
94
- return new RateLimitError({
95
- ...details,
96
- retryAfterMs: input.retryAfterMs,
97
- rateLimit: input.rateLimit,
98
- });
99
- if (NETWORK_ERROR_TEXT.test(text))
100
- return new ProviderInternalError(details);
101
- if (codes.some((code) => SERVER_CODES.has(code) || code.includes("exhausted") || code.includes("unavailable")))
102
- return new ProviderInternalError({
103
- ...details,
104
- retryAfterMs: input.retryAfterMs,
105
- });
106
- if (input.status === 429) {
107
- return new RateLimitError({
108
- ...details,
109
- retryAfterMs: input.retryAfterMs,
110
- rateLimit: input.rateLimit,
111
- });
112
- }
113
- if (input.status === 408 || input.status === 409 || (input.status !== undefined && input.status >= 500))
94
+ if (input.status === 408 ||
95
+ input.status === 409 ||
96
+ (input.status !== undefined && input.status >= 500) ||
97
+ codes.some((code) => SERVER_CODES.has(code) || code.includes("exhausted") || code.includes("unavailable")))
114
98
  return new ProviderInternalError({
115
99
  ...details,
116
100
  retryAfterMs: input.retryAfterMs,
117
101
  });
118
102
  if (codes.some((code) => INVALID_REQUEST_CODES.has(code)))
119
103
  return new InvalidRequestError(details);
120
- if (input.status === 400 || input.status === 404 || input.status === 413 || input.status === 422)
104
+ // Any remaining 4xx is a deterministic rejection of this request.
105
+ if (input.status !== undefined && input.status >= 400 && input.status < 500)
121
106
  return new InvalidRequestError(details);
122
107
  return new UnknownProviderError(details);
123
108
  }
@@ -77,7 +77,7 @@ const toAIError = (error) => {
77
77
  if (error instanceof MissingCredentialError || error instanceof Config.ConfigError) {
78
78
  return new AIError({
79
79
  reason: error instanceof MissingCredentialError
80
- ? new AuthenticationError({ message: error.message, cause: error, kind: "missing" })
80
+ ? new AuthenticationError({ message: error.message, cause: error })
81
81
  : new InvalidRequestError({ message: `Failed to resolve auth config: ${error.message}`, cause: error }),
82
82
  });
83
83
  }
@@ -173,6 +173,7 @@ export declare const streamRequest: (request: LLMRequest, options?: StreamOption
173
173
  } | {
174
174
  readonly id: string;
175
175
  readonly type: "text-end";
176
+ readonly text?: string | undefined;
176
177
  readonly providerMetadata?: {
177
178
  readonly [x: string]: {
178
179
  readonly [x: string]: unknown;
@@ -198,6 +199,7 @@ export declare const streamRequest: (request: LLMRequest, options?: StreamOption
198
199
  } | {
199
200
  readonly id: string;
200
201
  readonly type: "reasoning-end";
202
+ readonly text?: string | undefined;
201
203
  readonly providerMetadata?: {
202
204
  readonly [x: string]: {
203
205
  readonly [x: string]: unknown;
@@ -39,11 +39,10 @@ declare const NoRouteError_base: Schema.Class<NoRouteError, Schema.TaggedStruct<
39
39
  export declare class NoRouteError extends NoRouteError_base {
40
40
  }
41
41
  declare const AuthenticationError_base: Schema.Class<AuthenticationError, Schema.TaggedStruct<"Authentication", {
42
- readonly kind: Schema.Literals<readonly ["missing", "invalid", "expired", "insufficient-permissions", "unknown"]>;
43
- readonly message: Schema.String;
44
- readonly body: Schema.optional<Schema.String>;
45
- readonly http: Schema.optional<typeof HttpContext>;
46
- readonly cause: Schema.optional<Schema.Defect>;
42
+ message: Schema.String;
43
+ body: Schema.optional<Schema.String>;
44
+ http: Schema.optional<typeof HttpContext>;
45
+ cause: Schema.optional<Schema.Defect>;
47
46
  }>, import("effect/Cause").YieldableError>;
48
47
  export declare class AuthenticationError extends AuthenticationError_base {
49
48
  }
@@ -35,10 +35,7 @@ export class NoRouteError extends Schema.TaggedError("AI.Error.NoRoute")("NoRout
35
35
  model: ModelID,
36
36
  }) {
37
37
  }
38
- export class AuthenticationError extends Schema.TaggedError("AI.Error.Authentication")("Authentication", {
39
- ...ReasonFields,
40
- kind: Schema.Literals(["missing", "invalid", "expired", "insufficient-permissions", "unknown"]),
41
- }) {
38
+ export class AuthenticationError extends Schema.TaggedError("AI.Error.Authentication")("Authentication", ReasonFields) {
42
39
  }
43
40
  export class RateLimitError extends Schema.TaggedError("AI.Error.RateLimit")("RateLimit", {
44
41
  ...ReasonFields,
@@ -91,6 +91,8 @@ export type TextDelta = Schema.Schema.Type<typeof TextDelta>;
91
91
  export declare const TextEnd: Schema.Struct<{
92
92
  readonly type: Schema.tag<"text-end">;
93
93
  readonly id: Schema.String;
94
+ /** Authoritative complete value; replaces accumulated deltas when present. */
95
+ readonly text: Schema.optional<Schema.String>;
94
96
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
95
97
  }>;
96
98
  export type TextEnd = Schema.Schema.Type<typeof TextEnd>;
@@ -110,6 +112,8 @@ export type ReasoningDelta = Schema.Schema.Type<typeof ReasoningDelta>;
110
112
  export declare const ReasoningEnd: Schema.Struct<{
111
113
  readonly type: Schema.tag<"reasoning-end">;
112
114
  readonly id: Schema.String;
115
+ /** Authoritative complete value; replaces accumulated deltas when present. */
116
+ readonly text: Schema.optional<Schema.String>;
113
117
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
114
118
  }>;
115
119
  export type ReasoningEnd = Schema.Schema.Type<typeof ReasoningEnd>;
@@ -259,6 +263,8 @@ declare const llmEventTagged: Schema.toTaggedUnion<"type", readonly [Schema.Stru
259
263
  }>, Schema.Struct<{
260
264
  readonly type: Schema.tag<"text-end">;
261
265
  readonly id: Schema.String;
266
+ /** Authoritative complete value; replaces accumulated deltas when present. */
267
+ readonly text: Schema.optional<Schema.String>;
262
268
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
263
269
  }>, Schema.Struct<{
264
270
  readonly type: Schema.tag<"reasoning-start">;
@@ -272,6 +278,8 @@ declare const llmEventTagged: Schema.toTaggedUnion<"type", readonly [Schema.Stru
272
278
  }>, Schema.Struct<{
273
279
  readonly type: Schema.tag<"reasoning-end">;
274
280
  readonly id: Schema.String;
281
+ /** Authoritative complete value; replaces accumulated deltas when present. */
282
+ readonly text: Schema.optional<Schema.String>;
275
283
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
276
284
  }>, Schema.Struct<{
277
285
  readonly type: Schema.tag<"tool-input-start">;
@@ -409,6 +417,8 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.Struct<{
409
417
  }>, Schema.Struct<{
410
418
  readonly type: Schema.tag<"text-end">;
411
419
  readonly id: Schema.String;
420
+ /** Authoritative complete value; replaces accumulated deltas when present. */
421
+ readonly text: Schema.optional<Schema.String>;
412
422
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
413
423
  }>, Schema.Struct<{
414
424
  readonly type: Schema.tag<"reasoning-start">;
@@ -422,6 +432,8 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.Struct<{
422
432
  }>, Schema.Struct<{
423
433
  readonly type: Schema.tag<"reasoning-end">;
424
434
  readonly id: Schema.String;
435
+ /** Authoritative complete value; replaces accumulated deltas when present. */
436
+ readonly text: Schema.optional<Schema.String>;
425
437
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
426
438
  }>, Schema.Struct<{
427
439
  readonly type: Schema.tag<"tool-input-start">;
@@ -549,6 +561,8 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.Struct<{
549
561
  "text-end": Schema.Struct<{
550
562
  readonly type: Schema.tag<"text-end">;
551
563
  readonly id: Schema.String;
564
+ /** Authoritative complete value; replaces accumulated deltas when present. */
565
+ readonly text: Schema.optional<Schema.String>;
552
566
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
553
567
  }>;
554
568
  "reasoning-start": Schema.Struct<{
@@ -565,6 +579,8 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.Struct<{
565
579
  "reasoning-end": Schema.Struct<{
566
580
  readonly type: Schema.tag<"reasoning-end">;
567
581
  readonly id: Schema.String;
582
+ /** Authoritative complete value; replaces accumulated deltas when present. */
583
+ readonly text: Schema.optional<Schema.String>;
568
584
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
569
585
  }>;
570
586
  "tool-input-start": Schema.Struct<{
@@ -706,6 +722,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.Struct<{
706
722
  } | {
707
723
  readonly id: string;
708
724
  readonly type: "text-end";
725
+ readonly text?: string | undefined;
709
726
  readonly providerMetadata?: {
710
727
  readonly [x: string]: {
711
728
  readonly [x: string]: unknown;
@@ -731,6 +748,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.Struct<{
731
748
  } | {
732
749
  readonly id: string;
733
750
  readonly type: "reasoning-end";
751
+ readonly text?: string | undefined;
734
752
  readonly providerMetadata?: {
735
753
  readonly [x: string]: {
736
754
  readonly [x: string]: unknown;
@@ -894,6 +912,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.Struct<{
894
912
  }> | Extract<{
895
913
  readonly id: string;
896
914
  readonly type: "text-end";
915
+ readonly text?: string | undefined;
897
916
  readonly providerMetadata?: {
898
917
  readonly [x: string]: {
899
918
  readonly [x: string]: unknown;
@@ -925,6 +944,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.Struct<{
925
944
  }> | Extract<{
926
945
  readonly id: string;
927
946
  readonly type: "reasoning-end";
947
+ readonly text?: string | undefined;
928
948
  readonly providerMetadata?: {
929
949
  readonly [x: string]: {
930
950
  readonly [x: string]: unknown;
@@ -1109,6 +1129,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.Struct<{
1109
1129
  "text-end": (u: unknown) => u is {
1110
1130
  readonly id: string;
1111
1131
  readonly type: "text-end";
1132
+ readonly text?: string | undefined;
1112
1133
  readonly providerMetadata?: {
1113
1134
  readonly [x: string]: {
1114
1135
  readonly [x: string]: unknown;
@@ -1137,6 +1158,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.Struct<{
1137
1158
  "reasoning-end": (u: unknown) => u is {
1138
1159
  readonly id: string;
1139
1160
  readonly type: "reasoning-end";
1161
+ readonly text?: string | undefined;
1140
1162
  readonly providerMetadata?: {
1141
1163
  readonly [x: string]: {
1142
1164
  readonly [x: string]: unknown;
@@ -1311,6 +1333,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.Struct<{
1311
1333
  "text-end": (value: {
1312
1334
  readonly id: string;
1313
1335
  readonly type: "text-end";
1336
+ readonly text?: string | undefined;
1314
1337
  readonly providerMetadata?: {
1315
1338
  readonly [x: string]: {
1316
1339
  readonly [x: string]: unknown;
@@ -1339,6 +1362,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.Struct<{
1339
1362
  "reasoning-end": (value: {
1340
1363
  readonly id: string;
1341
1364
  readonly type: "reasoning-end";
1365
+ readonly text?: string | undefined;
1342
1366
  readonly providerMetadata?: {
1343
1367
  readonly [x: string]: {
1344
1368
  readonly [x: string]: unknown;
@@ -1507,6 +1531,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.Struct<{
1507
1531
  } | {
1508
1532
  readonly id: string;
1509
1533
  readonly type: "text-end";
1534
+ readonly text?: string | undefined;
1510
1535
  readonly providerMetadata?: {
1511
1536
  readonly [x: string]: {
1512
1537
  readonly [x: string]: unknown;
@@ -1532,6 +1557,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.Struct<{
1532
1557
  } | {
1533
1558
  readonly id: string;
1534
1559
  readonly type: "reasoning-end";
1560
+ readonly text?: string | undefined;
1535
1561
  readonly providerMetadata?: {
1536
1562
  readonly [x: string]: {
1537
1563
  readonly [x: string]: unknown;
@@ -1694,6 +1720,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.Struct<{
1694
1720
  "text-end": (value: {
1695
1721
  readonly id: string;
1696
1722
  readonly type: "text-end";
1723
+ readonly text?: string | undefined;
1697
1724
  readonly providerMetadata?: {
1698
1725
  readonly [x: string]: {
1699
1726
  readonly [x: string]: unknown;
@@ -1722,6 +1749,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.Struct<{
1722
1749
  "reasoning-end": (value: {
1723
1750
  readonly id: string;
1724
1751
  readonly type: "reasoning-end";
1752
+ readonly text?: string | undefined;
1725
1753
  readonly providerMetadata?: {
1726
1754
  readonly [x: string]: {
1727
1755
  readonly [x: string]: unknown;
@@ -1890,6 +1918,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.Struct<{
1890
1918
  } | {
1891
1919
  readonly id: string;
1892
1920
  readonly type: "text-end";
1921
+ readonly text?: string | undefined;
1893
1922
  readonly providerMetadata?: {
1894
1923
  readonly [x: string]: {
1895
1924
  readonly [x: string]: unknown;
@@ -1915,6 +1944,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.Struct<{
1915
1944
  } | {
1916
1945
  readonly id: string;
1917
1946
  readonly type: "reasoning-end";
1947
+ readonly text?: string | undefined;
1918
1948
  readonly providerMetadata?: {
1919
1949
  readonly [x: string]: {
1920
1950
  readonly [x: string]: unknown;
@@ -2079,6 +2109,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.Struct<{
2079
2109
  "text-end"?: ((value: {
2080
2110
  readonly id: string;
2081
2111
  readonly type: "text-end";
2112
+ readonly text?: string | undefined;
2082
2113
  readonly providerMetadata?: {
2083
2114
  readonly [x: string]: {
2084
2115
  readonly [x: string]: unknown;
@@ -2107,6 +2138,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.Struct<{
2107
2138
  "reasoning-end"?: ((value: {
2108
2139
  readonly id: string;
2109
2140
  readonly type: "reasoning-end";
2141
+ readonly text?: string | undefined;
2110
2142
  readonly providerMetadata?: {
2111
2143
  readonly [x: string]: {
2112
2144
  readonly [x: string]: unknown;
@@ -2281,6 +2313,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.Struct<{
2281
2313
  }> | Exclude<{
2282
2314
  readonly id: string;
2283
2315
  readonly type: "text-end";
2316
+ readonly text?: string | undefined;
2284
2317
  readonly providerMetadata?: {
2285
2318
  readonly [x: string]: {
2286
2319
  readonly [x: string]: unknown;
@@ -2312,6 +2345,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.Struct<{
2312
2345
  }> | Exclude<{
2313
2346
  readonly id: string;
2314
2347
  readonly type: "reasoning-end";
2348
+ readonly text?: string | undefined;
2315
2349
  readonly providerMetadata?: {
2316
2350
  readonly [x: string]: {
2317
2351
  readonly [x: string]: unknown;
@@ -2491,6 +2525,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.Struct<{
2491
2525
  } | {
2492
2526
  readonly id: string;
2493
2527
  readonly type: "text-end";
2528
+ readonly text?: string | undefined;
2494
2529
  readonly providerMetadata?: {
2495
2530
  readonly [x: string]: {
2496
2531
  readonly [x: string]: unknown;
@@ -2516,6 +2551,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.Struct<{
2516
2551
  } | {
2517
2552
  readonly id: string;
2518
2553
  readonly type: "reasoning-end";
2554
+ readonly text?: string | undefined;
2519
2555
  readonly providerMetadata?: {
2520
2556
  readonly [x: string]: {
2521
2557
  readonly [x: string]: unknown;
@@ -2678,6 +2714,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.Struct<{
2678
2714
  "text-end"?: ((value: {
2679
2715
  readonly id: string;
2680
2716
  readonly type: "text-end";
2717
+ readonly text?: string | undefined;
2681
2718
  readonly providerMetadata?: {
2682
2719
  readonly [x: string]: {
2683
2720
  readonly [x: string]: unknown;
@@ -2706,6 +2743,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.Struct<{
2706
2743
  "reasoning-end"?: ((value: {
2707
2744
  readonly id: string;
2708
2745
  readonly type: "reasoning-end";
2746
+ readonly text?: string | undefined;
2709
2747
  readonly providerMetadata?: {
2710
2748
  readonly [x: string]: {
2711
2749
  readonly [x: string]: unknown;
@@ -2880,6 +2918,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.Struct<{
2880
2918
  }> | Exclude<{
2881
2919
  readonly id: string;
2882
2920
  readonly type: "text-end";
2921
+ readonly text?: string | undefined;
2883
2922
  readonly providerMetadata?: {
2884
2923
  readonly [x: string]: {
2885
2924
  readonly [x: string]: unknown;
@@ -2911,6 +2950,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.Struct<{
2911
2950
  }> | Exclude<{
2912
2951
  readonly id: string;
2913
2952
  readonly type: "reasoning-end";
2953
+ readonly text?: string | undefined;
2914
2954
  readonly providerMetadata?: {
2915
2955
  readonly [x: string]: {
2916
2956
  readonly [x: string]: unknown;
@@ -3090,6 +3130,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.Struct<{
3090
3130
  } | {
3091
3131
  readonly id: string;
3092
3132
  readonly type: "text-end";
3133
+ readonly text?: string | undefined;
3093
3134
  readonly providerMetadata?: {
3094
3135
  readonly [x: string]: {
3095
3136
  readonly [x: string]: unknown;
@@ -3115,6 +3156,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.Struct<{
3115
3156
  } | {
3116
3157
  readonly id: string;
3117
3158
  readonly type: "reasoning-end";
3159
+ readonly text?: string | undefined;
3118
3160
  readonly providerMetadata?: {
3119
3161
  readonly [x: string]: {
3120
3162
  readonly [x: string]: unknown;
@@ -3281,6 +3323,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.Struct<{
3281
3323
  textEnd: (input: WithID<TextEnd, ContentBlockID>) => {
3282
3324
  readonly id: string;
3283
3325
  readonly type: "text-end";
3326
+ readonly text?: string | undefined;
3284
3327
  readonly providerMetadata?: {
3285
3328
  readonly [x: string]: {
3286
3329
  readonly [x: string]: unknown;
@@ -3309,6 +3352,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.Struct<{
3309
3352
  reasoningEnd: (input: WithID<ReasoningEnd, ContentBlockID>) => {
3310
3353
  readonly id: string;
3311
3354
  readonly type: "reasoning-end";
3355
+ readonly text?: string | undefined;
3312
3356
  readonly providerMetadata?: {
3313
3357
  readonly [x: string]: {
3314
3358
  readonly [x: string]: unknown;
@@ -3490,6 +3534,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.Struct<{
3490
3534
  textEnd: (u: unknown) => u is {
3491
3535
  readonly id: string;
3492
3536
  readonly type: "text-end";
3537
+ readonly text?: string | undefined;
3493
3538
  readonly providerMetadata?: {
3494
3539
  readonly [x: string]: {
3495
3540
  readonly [x: string]: unknown;
@@ -3518,6 +3563,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.Struct<{
3518
3563
  reasoningEnd: (u: unknown) => u is {
3519
3564
  readonly id: string;
3520
3565
  readonly type: "reasoning-end";
3566
+ readonly text?: string | undefined;
3521
3567
  readonly providerMetadata?: {
3522
3568
  readonly [x: string]: {
3523
3569
  readonly [x: string]: unknown;
@@ -3702,6 +3748,8 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
3702
3748
  }>, Schema.Struct<{
3703
3749
  readonly type: Schema.tag<"text-end">;
3704
3750
  readonly id: Schema.String;
3751
+ /** Authoritative complete value; replaces accumulated deltas when present. */
3752
+ readonly text: Schema.optional<Schema.String>;
3705
3753
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
3706
3754
  }>, Schema.Struct<{
3707
3755
  readonly type: Schema.tag<"reasoning-start">;
@@ -3715,6 +3763,8 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
3715
3763
  }>, Schema.Struct<{
3716
3764
  readonly type: Schema.tag<"reasoning-end">;
3717
3765
  readonly id: Schema.String;
3766
+ /** Authoritative complete value; replaces accumulated deltas when present. */
3767
+ readonly text: Schema.optional<Schema.String>;
3718
3768
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
3719
3769
  }>, Schema.Struct<{
3720
3770
  readonly type: Schema.tag<"tool-input-start">;
@@ -3842,6 +3892,8 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
3842
3892
  "text-end": Schema.Struct<{
3843
3893
  readonly type: Schema.tag<"text-end">;
3844
3894
  readonly id: Schema.String;
3895
+ /** Authoritative complete value; replaces accumulated deltas when present. */
3896
+ readonly text: Schema.optional<Schema.String>;
3845
3897
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
3846
3898
  }>;
3847
3899
  "reasoning-start": Schema.Struct<{
@@ -3858,6 +3910,8 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
3858
3910
  "reasoning-end": Schema.Struct<{
3859
3911
  readonly type: Schema.tag<"reasoning-end">;
3860
3912
  readonly id: Schema.String;
3913
+ /** Authoritative complete value; replaces accumulated deltas when present. */
3914
+ readonly text: Schema.optional<Schema.String>;
3861
3915
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
3862
3916
  }>;
3863
3917
  "tool-input-start": Schema.Struct<{
@@ -3999,6 +4053,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
3999
4053
  } | {
4000
4054
  readonly id: string;
4001
4055
  readonly type: "text-end";
4056
+ readonly text?: string | undefined;
4002
4057
  readonly providerMetadata?: {
4003
4058
  readonly [x: string]: {
4004
4059
  readonly [x: string]: unknown;
@@ -4024,6 +4079,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
4024
4079
  } | {
4025
4080
  readonly id: string;
4026
4081
  readonly type: "reasoning-end";
4082
+ readonly text?: string | undefined;
4027
4083
  readonly providerMetadata?: {
4028
4084
  readonly [x: string]: {
4029
4085
  readonly [x: string]: unknown;
@@ -4187,6 +4243,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
4187
4243
  }> | Extract<{
4188
4244
  readonly id: string;
4189
4245
  readonly type: "text-end";
4246
+ readonly text?: string | undefined;
4190
4247
  readonly providerMetadata?: {
4191
4248
  readonly [x: string]: {
4192
4249
  readonly [x: string]: unknown;
@@ -4218,6 +4275,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
4218
4275
  }> | Extract<{
4219
4276
  readonly id: string;
4220
4277
  readonly type: "reasoning-end";
4278
+ readonly text?: string | undefined;
4221
4279
  readonly providerMetadata?: {
4222
4280
  readonly [x: string]: {
4223
4281
  readonly [x: string]: unknown;
@@ -4402,6 +4460,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
4402
4460
  "text-end": (u: unknown) => u is {
4403
4461
  readonly id: string;
4404
4462
  readonly type: "text-end";
4463
+ readonly text?: string | undefined;
4405
4464
  readonly providerMetadata?: {
4406
4465
  readonly [x: string]: {
4407
4466
  readonly [x: string]: unknown;
@@ -4430,6 +4489,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
4430
4489
  "reasoning-end": (u: unknown) => u is {
4431
4490
  readonly id: string;
4432
4491
  readonly type: "reasoning-end";
4492
+ readonly text?: string | undefined;
4433
4493
  readonly providerMetadata?: {
4434
4494
  readonly [x: string]: {
4435
4495
  readonly [x: string]: unknown;
@@ -4604,6 +4664,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
4604
4664
  "text-end": (value: {
4605
4665
  readonly id: string;
4606
4666
  readonly type: "text-end";
4667
+ readonly text?: string | undefined;
4607
4668
  readonly providerMetadata?: {
4608
4669
  readonly [x: string]: {
4609
4670
  readonly [x: string]: unknown;
@@ -4632,6 +4693,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
4632
4693
  "reasoning-end": (value: {
4633
4694
  readonly id: string;
4634
4695
  readonly type: "reasoning-end";
4696
+ readonly text?: string | undefined;
4635
4697
  readonly providerMetadata?: {
4636
4698
  readonly [x: string]: {
4637
4699
  readonly [x: string]: unknown;
@@ -4800,6 +4862,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
4800
4862
  } | {
4801
4863
  readonly id: string;
4802
4864
  readonly type: "text-end";
4865
+ readonly text?: string | undefined;
4803
4866
  readonly providerMetadata?: {
4804
4867
  readonly [x: string]: {
4805
4868
  readonly [x: string]: unknown;
@@ -4825,6 +4888,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
4825
4888
  } | {
4826
4889
  readonly id: string;
4827
4890
  readonly type: "reasoning-end";
4891
+ readonly text?: string | undefined;
4828
4892
  readonly providerMetadata?: {
4829
4893
  readonly [x: string]: {
4830
4894
  readonly [x: string]: unknown;
@@ -4987,6 +5051,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
4987
5051
  "text-end": (value: {
4988
5052
  readonly id: string;
4989
5053
  readonly type: "text-end";
5054
+ readonly text?: string | undefined;
4990
5055
  readonly providerMetadata?: {
4991
5056
  readonly [x: string]: {
4992
5057
  readonly [x: string]: unknown;
@@ -5015,6 +5080,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
5015
5080
  "reasoning-end": (value: {
5016
5081
  readonly id: string;
5017
5082
  readonly type: "reasoning-end";
5083
+ readonly text?: string | undefined;
5018
5084
  readonly providerMetadata?: {
5019
5085
  readonly [x: string]: {
5020
5086
  readonly [x: string]: unknown;
@@ -5183,6 +5249,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
5183
5249
  } | {
5184
5250
  readonly id: string;
5185
5251
  readonly type: "text-end";
5252
+ readonly text?: string | undefined;
5186
5253
  readonly providerMetadata?: {
5187
5254
  readonly [x: string]: {
5188
5255
  readonly [x: string]: unknown;
@@ -5208,6 +5275,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
5208
5275
  } | {
5209
5276
  readonly id: string;
5210
5277
  readonly type: "reasoning-end";
5278
+ readonly text?: string | undefined;
5211
5279
  readonly providerMetadata?: {
5212
5280
  readonly [x: string]: {
5213
5281
  readonly [x: string]: unknown;
@@ -5372,6 +5440,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
5372
5440
  "text-end"?: ((value: {
5373
5441
  readonly id: string;
5374
5442
  readonly type: "text-end";
5443
+ readonly text?: string | undefined;
5375
5444
  readonly providerMetadata?: {
5376
5445
  readonly [x: string]: {
5377
5446
  readonly [x: string]: unknown;
@@ -5400,6 +5469,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
5400
5469
  "reasoning-end"?: ((value: {
5401
5470
  readonly id: string;
5402
5471
  readonly type: "reasoning-end";
5472
+ readonly text?: string | undefined;
5403
5473
  readonly providerMetadata?: {
5404
5474
  readonly [x: string]: {
5405
5475
  readonly [x: string]: unknown;
@@ -5574,6 +5644,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
5574
5644
  }> | Exclude<{
5575
5645
  readonly id: string;
5576
5646
  readonly type: "text-end";
5647
+ readonly text?: string | undefined;
5577
5648
  readonly providerMetadata?: {
5578
5649
  readonly [x: string]: {
5579
5650
  readonly [x: string]: unknown;
@@ -5605,6 +5676,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
5605
5676
  }> | Exclude<{
5606
5677
  readonly id: string;
5607
5678
  readonly type: "reasoning-end";
5679
+ readonly text?: string | undefined;
5608
5680
  readonly providerMetadata?: {
5609
5681
  readonly [x: string]: {
5610
5682
  readonly [x: string]: unknown;
@@ -5784,6 +5856,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
5784
5856
  } | {
5785
5857
  readonly id: string;
5786
5858
  readonly type: "text-end";
5859
+ readonly text?: string | undefined;
5787
5860
  readonly providerMetadata?: {
5788
5861
  readonly [x: string]: {
5789
5862
  readonly [x: string]: unknown;
@@ -5809,6 +5882,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
5809
5882
  } | {
5810
5883
  readonly id: string;
5811
5884
  readonly type: "reasoning-end";
5885
+ readonly text?: string | undefined;
5812
5886
  readonly providerMetadata?: {
5813
5887
  readonly [x: string]: {
5814
5888
  readonly [x: string]: unknown;
@@ -5971,6 +6045,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
5971
6045
  "text-end"?: ((value: {
5972
6046
  readonly id: string;
5973
6047
  readonly type: "text-end";
6048
+ readonly text?: string | undefined;
5974
6049
  readonly providerMetadata?: {
5975
6050
  readonly [x: string]: {
5976
6051
  readonly [x: string]: unknown;
@@ -5999,6 +6074,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
5999
6074
  "reasoning-end"?: ((value: {
6000
6075
  readonly id: string;
6001
6076
  readonly type: "reasoning-end";
6077
+ readonly text?: string | undefined;
6002
6078
  readonly providerMetadata?: {
6003
6079
  readonly [x: string]: {
6004
6080
  readonly [x: string]: unknown;
@@ -6173,6 +6249,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
6173
6249
  }> | Exclude<{
6174
6250
  readonly id: string;
6175
6251
  readonly type: "text-end";
6252
+ readonly text?: string | undefined;
6176
6253
  readonly providerMetadata?: {
6177
6254
  readonly [x: string]: {
6178
6255
  readonly [x: string]: unknown;
@@ -6204,6 +6281,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
6204
6281
  }> | Exclude<{
6205
6282
  readonly id: string;
6206
6283
  readonly type: "reasoning-end";
6284
+ readonly text?: string | undefined;
6207
6285
  readonly providerMetadata?: {
6208
6286
  readonly [x: string]: {
6209
6287
  readonly [x: string]: unknown;
@@ -6383,6 +6461,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
6383
6461
  } | {
6384
6462
  readonly id: string;
6385
6463
  readonly type: "text-end";
6464
+ readonly text?: string | undefined;
6386
6465
  readonly providerMetadata?: {
6387
6466
  readonly [x: string]: {
6388
6467
  readonly [x: string]: unknown;
@@ -6408,6 +6487,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
6408
6487
  } | {
6409
6488
  readonly id: string;
6410
6489
  readonly type: "reasoning-end";
6490
+ readonly text?: string | undefined;
6411
6491
  readonly providerMetadata?: {
6412
6492
  readonly [x: string]: {
6413
6493
  readonly [x: string]: unknown;
@@ -6574,6 +6654,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
6574
6654
  textEnd: (input: WithID<TextEnd, ContentBlockID>) => {
6575
6655
  readonly id: string;
6576
6656
  readonly type: "text-end";
6657
+ readonly text?: string | undefined;
6577
6658
  readonly providerMetadata?: {
6578
6659
  readonly [x: string]: {
6579
6660
  readonly [x: string]: unknown;
@@ -6602,6 +6683,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
6602
6683
  reasoningEnd: (input: WithID<ReasoningEnd, ContentBlockID>) => {
6603
6684
  readonly id: string;
6604
6685
  readonly type: "reasoning-end";
6686
+ readonly text?: string | undefined;
6605
6687
  readonly providerMetadata?: {
6606
6688
  readonly [x: string]: {
6607
6689
  readonly [x: string]: unknown;
@@ -6783,6 +6865,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
6783
6865
  textEnd: (u: unknown) => u is {
6784
6866
  readonly id: string;
6785
6867
  readonly type: "text-end";
6868
+ readonly text?: string | undefined;
6786
6869
  readonly providerMetadata?: {
6787
6870
  readonly [x: string]: {
6788
6871
  readonly [x: string]: unknown;
@@ -6811,6 +6894,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
6811
6894
  reasoningEnd: (u: unknown) => u is {
6812
6895
  readonly id: string;
6813
6896
  readonly type: "reasoning-end";
6897
+ readonly text?: string | undefined;
6814
6898
  readonly providerMetadata?: {
6815
6899
  readonly [x: string]: {
6816
6900
  readonly [x: string]: unknown;
@@ -6965,9 +7049,9 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
6965
7049
  }>;
6966
7050
  }>, {}>;
6967
7051
  export declare class LLMResponse extends LLMResponse_base {
6968
- /** Concatenated assistant text assembled from streamed `text-delta` events. */
7052
+ /** Concatenated assistant text; each fragment's `text-end` value replaces its accumulated deltas when present. */
6969
7053
  get text(): string;
6970
- /** Concatenated reasoning text assembled from streamed `reasoning-delta` events. */
7054
+ /** Concatenated reasoning text; each fragment's `reasoning-end` value replaces its accumulated deltas when present. */
6971
7055
  get reasoning(): string;
6972
7056
  /** Completed tool calls emitted by the provider. */
6973
7057
  get toolCalls(): {
@@ -91,6 +91,8 @@ export const TextDelta = Schema.Struct({
91
91
  export const TextEnd = Schema.Struct({
92
92
  type: Schema.tag("text-end"),
93
93
  id: ContentBlockID,
94
+ /** Authoritative complete value; replaces accumulated deltas when present. */
95
+ text: Schema.optional(Schema.String),
94
96
  providerMetadata: Schema.optional(ProviderMetadata),
95
97
  }).annotate({ identifier: "LLM.Event.TextEnd" });
96
98
  export const ReasoningStart = Schema.Struct({
@@ -107,6 +109,8 @@ export const ReasoningDelta = Schema.Struct({
107
109
  export const ReasoningEnd = Schema.Struct({
108
110
  type: Schema.tag("reasoning-end"),
109
111
  id: ContentBlockID,
112
+ /** Authoritative complete value; replaces accumulated deltas when present. */
113
+ text: Schema.optional(Schema.String),
110
114
  providerMetadata: Schema.optional(ProviderMetadata),
111
115
  }).annotate({ identifier: "LLM.Event.ReasoningEnd" });
112
116
  export const ToolInputStart = Schema.Struct({
@@ -259,14 +263,26 @@ export const LLMEvent = Object.assign(llmEventTagged, {
259
263
  providerError: llmEventTagged.guards["provider-error"],
260
264
  },
261
265
  });
262
- const responseText = (events) => events
263
- .filter(LLMEvent.is.textDelta)
264
- .map((event) => event.text)
265
- .join("");
266
- const responseReasoning = (events) => events
267
- .filter(LLMEvent.is.reasoningDelta)
268
- .map((event) => event.text)
269
- .join("");
266
+ /** Joins deltas per fragment, letting an authoritative end value replace that fragment's accumulated deltas. */
267
+ const joinFragments = (events, isDelta, isEnd) => {
268
+ const order = [];
269
+ const parts = new Map();
270
+ for (const event of events) {
271
+ if (isDelta(event)) {
272
+ if (!parts.has(event.id))
273
+ order.push(event.id);
274
+ parts.set(event.id, (parts.get(event.id) ?? "") + event.text);
275
+ }
276
+ if (isEnd(event) && event.text !== undefined) {
277
+ if (!parts.has(event.id))
278
+ order.push(event.id);
279
+ parts.set(event.id, event.text);
280
+ }
281
+ }
282
+ return order.map((id) => parts.get(id)).join("");
283
+ };
284
+ const responseText = (events) => joinFragments(events, LLMEvent.is.textDelta, LLMEvent.is.textEnd);
285
+ const responseReasoning = (events) => joinFragments(events, LLMEvent.is.reasoningDelta, LLMEvent.is.reasoningEnd);
270
286
  const responseUsage = (events) => events.reduce((usage, event) => ("usage" in event && event.usage !== undefined ? event.usage : usage), undefined);
271
287
  const emptyResponseState = () => ({
272
288
  events: [],
@@ -333,10 +349,11 @@ const reduceTextEnd = (state, event) => {
333
349
  const current = state.textParts[event.id];
334
350
  if (!current)
335
351
  return state;
352
+ const text = event.text ?? current.text;
336
353
  const providerMetadata = event.providerMetadata ?? current.providerMetadata;
337
354
  return {
338
- ...replaceContent(state, current.contentIndex, textContent(current.text, providerMetadata)),
339
- textParts: { ...state.textParts, [event.id]: { ...current, providerMetadata } },
355
+ ...replaceContent(state, current.contentIndex, textContent(text, providerMetadata)),
356
+ textParts: { ...state.textParts, [event.id]: { ...current, text, providerMetadata } },
340
357
  };
341
358
  };
342
359
  const ensureReasoning = (state, id, providerMetadata) => {
@@ -366,10 +383,11 @@ const reduceReasoningEnd = (state, event) => {
366
383
  const current = state.reasoningParts[event.id];
367
384
  if (!current)
368
385
  return state;
386
+ const text = event.text ?? current.text;
369
387
  const providerMetadata = event.providerMetadata ?? current.providerMetadata;
370
388
  return {
371
- ...replaceContent(state, current.contentIndex, reasoningContent(current.text, providerMetadata)),
372
- reasoningParts: { ...state.reasoningParts, [event.id]: { ...current, providerMetadata } },
389
+ ...replaceContent(state, current.contentIndex, reasoningContent(text, providerMetadata)),
390
+ reasoningParts: { ...state.reasoningParts, [event.id]: { ...current, text, providerMetadata } },
373
391
  };
374
392
  };
375
393
  const reduceToolInputStart = (state, event) => ({
@@ -457,11 +475,11 @@ export class LLMResponse extends Schema.Class("LLM.Response")({
457
475
  usage: Schema.optional(Usage),
458
476
  finishReason: FinishReasonDetails,
459
477
  }) {
460
- /** Concatenated assistant text assembled from streamed `text-delta` events. */
478
+ /** Concatenated assistant text; each fragment's `text-end` value replaces its accumulated deltas when present. */
461
479
  get text() {
462
480
  return responseText(this.events);
463
481
  }
464
- /** Concatenated reasoning text assembled from streamed `reasoning-delta` events. */
482
+ /** Concatenated reasoning text; each fragment's `reasoning-end` value replaces its accumulated deltas when present. */
465
483
  get reasoning() {
466
484
  return responseReasoning(this.events);
467
485
  }
package/dist/testing.d.ts CHANGED
@@ -50,6 +50,7 @@ export declare const complete: (options: {
50
50
  } | {
51
51
  readonly id: string;
52
52
  readonly type: "text-end";
53
+ readonly text?: string | undefined;
53
54
  readonly providerMetadata?: {
54
55
  readonly [x: string]: {
55
56
  readonly [x: string]: unknown;
@@ -75,6 +76,7 @@ export declare const complete: (options: {
75
76
  } | {
76
77
  readonly id: string;
77
78
  readonly type: "reasoning-end";
79
+ readonly text?: string | undefined;
78
80
  readonly providerMetadata?: {
79
81
  readonly [x: string]: {
80
82
  readonly [x: string]: unknown;
@@ -233,6 +235,7 @@ export declare const stop: (...events: readonly LLMEvent[]) => ({
233
235
  } | {
234
236
  readonly id: string;
235
237
  readonly type: "text-end";
238
+ readonly text?: string | undefined;
236
239
  readonly providerMetadata?: {
237
240
  readonly [x: string]: {
238
241
  readonly [x: string]: unknown;
@@ -258,6 +261,7 @@ export declare const stop: (...events: readonly LLMEvent[]) => ({
258
261
  } | {
259
262
  readonly id: string;
260
263
  readonly type: "reasoning-end";
264
+ readonly text?: string | undefined;
261
265
  readonly providerMetadata?: {
262
266
  readonly [x: string]: {
263
267
  readonly [x: string]: unknown;
@@ -416,6 +420,7 @@ export declare const toolCalls: (...events: readonly LLMEvent[]) => ({
416
420
  } | {
417
421
  readonly id: string;
418
422
  readonly type: "text-end";
423
+ readonly text?: string | undefined;
419
424
  readonly providerMetadata?: {
420
425
  readonly [x: string]: {
421
426
  readonly [x: string]: unknown;
@@ -441,6 +446,7 @@ export declare const toolCalls: (...events: readonly LLMEvent[]) => ({
441
446
  } | {
442
447
  readonly id: string;
443
448
  readonly type: "reasoning-end";
449
+ readonly text?: string | undefined;
444
450
  readonly providerMetadata?: {
445
451
  readonly [x: string]: {
446
452
  readonly [x: string]: unknown;
@@ -599,6 +605,7 @@ export declare const text: (value: string, id: string) => ({
599
605
  } | {
600
606
  readonly id: string;
601
607
  readonly type: "text-end";
608
+ readonly text?: string | undefined;
602
609
  readonly providerMetadata?: {
603
610
  readonly [x: string]: {
604
611
  readonly [x: string]: unknown;
@@ -624,6 +631,7 @@ export declare const text: (value: string, id: string) => ({
624
631
  } | {
625
632
  readonly id: string;
626
633
  readonly type: "reasoning-end";
634
+ readonly text?: string | undefined;
627
635
  readonly providerMetadata?: {
628
636
  readonly [x: string]: {
629
637
  readonly [x: string]: unknown;
@@ -782,6 +790,7 @@ export declare const textWithUsage: (value: string, id: string, inputTokens: num
782
790
  } | {
783
791
  readonly id: string;
784
792
  readonly type: "text-end";
793
+ readonly text?: string | undefined;
785
794
  readonly providerMetadata?: {
786
795
  readonly [x: string]: {
787
796
  readonly [x: string]: unknown;
@@ -807,6 +816,7 @@ export declare const textWithUsage: (value: string, id: string, inputTokens: num
807
816
  } | {
808
817
  readonly id: string;
809
818
  readonly type: "reasoning-end";
819
+ readonly text?: string | undefined;
810
820
  readonly providerMetadata?: {
811
821
  readonly [x: string]: {
812
822
  readonly [x: string]: unknown;
@@ -965,6 +975,7 @@ export declare const tool: (id: string, name: string, input: unknown) => ({
965
975
  } | {
966
976
  readonly id: string;
967
977
  readonly type: "text-end";
978
+ readonly text?: string | undefined;
968
979
  readonly providerMetadata?: {
969
980
  readonly [x: string]: {
970
981
  readonly [x: string]: unknown;
@@ -990,6 +1001,7 @@ export declare const tool: (id: string, name: string, input: unknown) => ({
990
1001
  } | {
991
1002
  readonly id: string;
992
1003
  readonly type: "reasoning-end";
1004
+ readonly text?: string | undefined;
993
1005
  readonly providerMetadata?: {
994
1006
  readonly [x: string]: {
995
1007
  readonly [x: string]: unknown;
@@ -1148,6 +1160,7 @@ export declare const failAfter: (error: AIError, ...events: readonly LLMEvent[])
1148
1160
  } | {
1149
1161
  readonly id: string;
1150
1162
  readonly type: "text-end";
1163
+ readonly text?: string | undefined;
1151
1164
  readonly providerMetadata?: {
1152
1165
  readonly [x: string]: {
1153
1166
  readonly [x: string]: unknown;
@@ -1173,6 +1186,7 @@ export declare const failAfter: (error: AIError, ...events: readonly LLMEvent[])
1173
1186
  } | {
1174
1187
  readonly id: string;
1175
1188
  readonly type: "reasoning-end";
1189
+ readonly text?: string | undefined;
1176
1190
  readonly providerMetadata?: {
1177
1191
  readonly [x: string]: {
1178
1192
  readonly [x: string]: unknown;
@@ -1331,6 +1345,7 @@ export declare const hangAfter: (...events: readonly LLMEvent[]) => Stream.Strea
1331
1345
  } | {
1332
1346
  readonly id: string;
1333
1347
  readonly type: "text-end";
1348
+ readonly text?: string | undefined;
1334
1349
  readonly providerMetadata?: {
1335
1350
  readonly [x: string]: {
1336
1351
  readonly [x: string]: unknown;
@@ -1356,6 +1371,7 @@ export declare const hangAfter: (...events: readonly LLMEvent[]) => Stream.Strea
1356
1371
  } | {
1357
1372
  readonly id: string;
1358
1373
  readonly type: "reasoning-end";
1374
+ readonly text?: string | undefined;
1359
1375
  readonly providerMetadata?: {
1360
1376
  readonly [x: string]: {
1361
1377
  readonly [x: string]: unknown;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "0.0.0-dev-18544",
3
+ "version": "0.0.0-dev-18548",
4
4
  "name": "@opencode-ai/ai",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -30,7 +30,7 @@
30
30
  "devDependencies": {
31
31
  "@clack/prompts": "1.0.0-alpha.1",
32
32
  "@effect/platform-node": "4.0.0-rc.112",
33
- "@opencode-ai/http-recorder": "0.0.0-dev-18544",
33
+ "@opencode-ai/http-recorder": "0.0.0-dev-18548",
34
34
  "@tsconfig/bun": "1.0.9",
35
35
  "@types/bun": "1.3.13",
36
36
  "@typescript/native-preview": "7.0.0-dev.20251207.1",
@@ -39,7 +39,7 @@
39
39
  "dependencies": {
40
40
  "@smithy/eventstream-codec": "4.2.14",
41
41
  "@smithy/util-utf8": "4.2.2",
42
- "@opencode-ai/schema": "0.0.0-dev-18544",
42
+ "@opencode-ai/schema": "0.0.0-dev-18548",
43
43
  "aws4fetch": "1.0.20",
44
44
  "effect": "4.0.0-rc.112",
45
45
  "google-auth-library": "10.5.0"