@mastra/ai-sdk 1.4.1-alpha.1 → 1.4.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @mastra/ai-sdk
2
2
 
3
+ ## 1.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixed workflow streaming in @mastra/ai-sdk so intermediate `data-workflow` parts stop repeating every completed step output. Added `data-workflow-step` parts with the full payload for the step that just changed, which reduces stream size for long-running workflows while preserving final workflow outputs. ([#15218](https://github.com/mastra-ai/mastra/pull/15218))
8
+
9
+ If your UI reads live step outputs during workflow execution, it should now consume `data-workflow-step` parts in addition to `data-workflow`. Final workflow snapshots still include the full step outputs.
10
+
11
+ - Fix AI SDK v6 approval replay so ordinary user follow-up turns do not resume stale approval responses. ([#15480](https://github.com/mastra-ai/mastra/pull/15480))
12
+
13
+ - Fixed tool call approvals in AI SDK v6: `handleChatStream` now automatically routes to `resumeStream` when the AI SDK v6 native approval flow is used on the client (no extra server-side wiring required). The v6 stream now emits native `tool-approval-request` parts so `useChat` can surface approval UI and call `addToolApprovalResponse()`, while also emitting the existing `data-tool-call-approval` chunk for backwards compatibility. ([#15345](https://github.com/mastra-ai/mastra/pull/15345))
14
+
15
+ - Fixed AI SDK v6 tool approval streams so requireApproval works with handleChatStream and AssistantChatTransport. ([#15345](https://github.com/mastra-ai/mastra/pull/15345))
16
+
17
+ - Updated dependencies [[`20f59b8`](https://github.com/mastra-ai/mastra/commit/20f59b876cf91199efbc49a0e36b391240708f08), [`aba393e`](https://github.com/mastra-ai/mastra/commit/aba393e2da7390c69b80e516a4f153cda6f09376), [`3d83d06`](https://github.com/mastra-ai/mastra/commit/3d83d06f776f00fb5f4163dddd32a030c5c20844), [`e2687a7`](https://github.com/mastra-ai/mastra/commit/e2687a7408790c384563816a9a28ed06735684c9), [`fdd54cf`](https://github.com/mastra-ai/mastra/commit/fdd54cf612a9af876e9fdd85e534454f6e7dd518), [`6315317`](https://github.com/mastra-ai/mastra/commit/63153175fe9a7b224e5be7c209bbebc01dd9b0d5), [`a371ac5`](https://github.com/mastra-ai/mastra/commit/a371ac534aa1bb368a1acf9d8b313378dfdc787e), [`0474c2b`](https://github.com/mastra-ai/mastra/commit/0474c2b2e7c7e1ad8691dca031284841391ff1ef), [`0a5fa1d`](https://github.com/mastra-ai/mastra/commit/0a5fa1d3cb0583889d06687155f26fd7d2edc76c), [`7e0e63e`](https://github.com/mastra-ai/mastra/commit/7e0e63e2e485e84442351f4c7a79a424c83539dc), [`ea43e64`](https://github.com/mastra-ai/mastra/commit/ea43e646dd95d507694b6112b0bf1df22ad552b2), [`f607106`](https://github.com/mastra-ai/mastra/commit/f607106854c6416c4a07d4082604b9f66d047221), [`30456b6`](https://github.com/mastra-ai/mastra/commit/30456b6b08c8fd17e109dd093b73d93b65e83bc5), [`9d11a8c`](https://github.com/mastra-ai/mastra/commit/9d11a8c1c8924eb975a245a5884d40ca1b7e0491), [`9d3b24b`](https://github.com/mastra-ai/mastra/commit/9d3b24b19407ae9c09586cf7766d38dc4dff4a69), [`00d1b16`](https://github.com/mastra-ai/mastra/commit/00d1b16b401199cb294fa23f43336547db4dca9b), [`47cee3e`](https://github.com/mastra-ai/mastra/commit/47cee3e137fe39109cf7fffd2a8cf47b76dc702e), [`62919a6`](https://github.com/mastra-ai/mastra/commit/62919a6ee0fbf3779ad21a97b1ec6696515d5104), [`d246696`](https://github.com/mastra-ai/mastra/commit/d246696139a3144a5b21b042d41c532688e957e1), [`354f9ce`](https://github.com/mastra-ai/mastra/commit/354f9ce1ca6af2074b6a196a23f8ec30012dccca), [`16e34ca`](https://github.com/mastra-ai/mastra/commit/16e34caa98b9a114b17a6125e4e3fd87f169d0d0), [`7020c06`](https://github.com/mastra-ai/mastra/commit/7020c0690b199d9da337f0e805f16948e557922e), [`8786a61`](https://github.com/mastra-ai/mastra/commit/8786a61fa54ba265f85eeff9985ca39863d18bb6), [`9467ea8`](https://github.com/mastra-ai/mastra/commit/9467ea87695749a53dfc041576410ebf9ee7bb67), [`7338d94`](https://github.com/mastra-ai/mastra/commit/7338d949380cf68b095342e8e42610dc51d557c1), [`c80dc16`](https://github.com/mastra-ai/mastra/commit/c80dc16e113e6cc159f510ffde501ad4711b2189), [`af8a57e`](https://github.com/mastra-ai/mastra/commit/af8a57ed9ba9685ad8601d5b71ae3706da6222f9), [`d63ffdb`](https://github.com/mastra-ai/mastra/commit/d63ffdbb2c11e76fe5ea45faab44bc15460f010c), [`47cee3e`](https://github.com/mastra-ai/mastra/commit/47cee3e137fe39109cf7fffd2a8cf47b76dc702e), [`1bd5104`](https://github.com/mastra-ai/mastra/commit/1bd51048b6da93507276d6623e3fd96a9e1a8944), [`e9837b5`](https://github.com/mastra-ai/mastra/commit/e9837b53699e18711b09e0ca010a4106376f2653), [`8f1b280`](https://github.com/mastra-ai/mastra/commit/8f1b280b7fe6999ec654f160cb69c1a8719e7a57), [`92dcf02`](https://github.com/mastra-ai/mastra/commit/92dcf029294210ac91b090900c1a0555a425c57a), [`0fd90a2`](https://github.com/mastra-ai/mastra/commit/0fd90a215caf5fca8099c15a67ca03e4427747a3), [`8fb2405`](https://github.com/mastra-ai/mastra/commit/8fb2405138f2d208b7962ad03f121ca25bcc28c5), [`12df98c`](https://github.com/mastra-ai/mastra/commit/12df98c4904643d9481f5c78f3bed443725b4c96)]:
18
+ - @mastra/core@1.26.0
19
+
20
+ ## 1.4.1-alpha.2
21
+
22
+ ### Patch Changes
23
+
24
+ - Fix AI SDK v6 approval replay so ordinary user follow-up turns do not resume stale approval responses. ([#15480](https://github.com/mastra-ai/mastra/pull/15480))
25
+
26
+ - Updated dependencies [[`20f59b8`](https://github.com/mastra-ai/mastra/commit/20f59b876cf91199efbc49a0e36b391240708f08), [`e2687a7`](https://github.com/mastra-ai/mastra/commit/e2687a7408790c384563816a9a28ed06735684c9), [`8f1b280`](https://github.com/mastra-ai/mastra/commit/8f1b280b7fe6999ec654f160cb69c1a8719e7a57), [`12df98c`](https://github.com/mastra-ai/mastra/commit/12df98c4904643d9481f5c78f3bed443725b4c96)]:
27
+ - @mastra/core@1.26.0-alpha.11
28
+
3
29
  ## 1.4.1-alpha.1
4
30
 
5
31
  ### Patch Changes
@@ -435,6 +435,8 @@ export declare type AsyncIterableStream<T> = AsyncIterable<T> & ReadableStream<T
435
435
  * Attributes is a map from string to attribute values.
436
436
  *
437
437
  * Note: only the own enumerable keys are counted as valid attribute keys.
438
+ *
439
+ * @since 1.3.0
438
440
  */
439
441
  declare interface Attributes {
440
442
  [attributeKey: string]: AttributeValue | undefined;
@@ -444,6 +446,8 @@ declare interface Attributes {
444
446
  * Attribute values may be any non-nullish primitive value except an object.
445
447
  *
446
448
  * null or undefined attribute values are invalid and will result in undefined behavior.
449
+ *
450
+ * @since 1.3.0
447
451
  */
448
452
  declare type AttributeValue = string | number | boolean | Array<null | undefined | string> | Array<null | undefined | number> | Array<null | undefined | boolean>;
449
453
 
@@ -778,6 +782,9 @@ export declare type ContentPart<TOOLS extends ToolSet> = {
778
782
  providerMetadata?: ProviderMetadata;
779
783
  });
780
784
 
785
+ /**
786
+ * @since 1.0.0
787
+ */
781
788
  declare interface Context {
782
789
  /**
783
790
  * Get a value from the context.
@@ -1705,6 +1712,8 @@ declare class EventSourceParserStream extends TransformStream<string, EventSourc
1705
1712
  * Defines Exception.
1706
1713
  *
1707
1714
  * string or an object with one of (message or name or code) and optional stack
1715
+ *
1716
+ * @since 1.0.0
1708
1717
  */
1709
1718
  declare type Exception = ExceptionWithCode | ExceptionWithMessage | ExceptionWithName | string;
1710
1719
 
@@ -2973,6 +2982,8 @@ export declare function hasToolCall(toolName: string): StopCondition<any>;
2973
2982
  * The second number is calculated by converting the digits after the decimal point of the subtraction, (1609504210150 / 1000) - HrTime[0], to nanoseconds:
2974
2983
  * HrTime[1] = Number((1609504210.150 - HrTime[0]).toFixed(9)) * 1e9 = 150000000.
2975
2984
  * This is represented in HrTime format as [1609504210, 150000000].
2985
+ *
2986
+ * @since 1.0.0
2976
2987
  */
2977
2988
  declare type HrTime = [number, number];
2978
2989
 
@@ -5546,6 +5557,8 @@ declare function lazyValidator<OBJECT>(createValidator: () => Validator<OBJECT>)
5546
5557
  * However, it is desirable to associate incoming SpanContext to new trace
5547
5558
  * initiated on service provider side so two traces (from Client and from
5548
5559
  * Service Provider) can be correlated.
5560
+ *
5561
+ * @since 1.0.0
5549
5562
  */
5550
5563
  declare interface Link {
5551
5564
  /** The {@link SpanContext} of a linked span. */
@@ -7019,6 +7032,8 @@ export declare type SourceUrlUIPart = {
7019
7032
  * may have children.
7020
7033
  *
7021
7034
  * Spans are created by the {@link Tracer.startSpan} method.
7035
+ *
7036
+ * @since 1.0.0
7022
7037
  */
7023
7038
  declare interface Span {
7024
7039
  /**
@@ -7078,11 +7093,21 @@ declare interface Span {
7078
7093
  */
7079
7094
  addLinks(links: Link[]): this;
7080
7095
  /**
7081
- * Sets a status to the span. If used, this will override the default Span
7082
- * status. Default is {@link SpanStatusCode.UNSET}. SetStatus overrides the value
7083
- * of previous calls to SetStatus on the Span.
7096
+ * Sets the status of the span.
7097
+ *
7098
+ * By default, a span has status {@link SpanStatusCode.UNSET}.
7099
+ * Calling this method overrides that default.
7100
+ *
7101
+ * The status codes have a total order: `OK > ERROR > UNSET`.
7102
+ *
7103
+ * - Once {@link SpanStatusCode.OK} is set, any further attempts to change
7104
+ * the status are ignored.
7105
+ * - Any attempt to set {@link SpanStatusCode.UNSET} is always ignored.
7106
+ *
7107
+ * The `message` field is only used when {@link SpanStatusCode.ERROR} is set.
7108
+ * For all other status codes, `message` is ignored.
7084
7109
  *
7085
- * @param status the SpanStatus to set.
7110
+ * @param status The {@link SpanStatus} to set.
7086
7111
  */
7087
7112
  setStatus(status: SpanStatus): this;
7088
7113
  /**
@@ -7127,17 +7152,21 @@ declare interface Span {
7127
7152
 
7128
7153
  /**
7129
7154
  * @deprecated please use {@link Attributes}
7155
+ * @since 1.0.0
7130
7156
  */
7131
7157
  declare type SpanAttributes = Attributes;
7132
7158
 
7133
7159
  /**
7134
7160
  * @deprecated please use {@link AttributeValue}
7161
+ * @since 1.0.0
7135
7162
  */
7136
7163
  declare type SpanAttributeValue = AttributeValue;
7137
7164
 
7138
7165
  /**
7139
7166
  * A SpanContext represents the portion of a {@link Span} which must be
7140
7167
  * serialized and propagated along side of a {@link Baggage}.
7168
+ *
7169
+ * @since 1.0.0
7141
7170
  */
7142
7171
  declare interface SpanContext {
7143
7172
  /**
@@ -7187,6 +7216,9 @@ declare interface SpanContext {
7187
7216
  traceState?: TraceState;
7188
7217
  }
7189
7218
 
7219
+ /**
7220
+ * @since 1.0.0
7221
+ */
7190
7222
  declare enum SpanKind {
7191
7223
  /** Default value. Indicates that the span is used internally. */
7192
7224
  INTERNAL = 0,
@@ -7216,6 +7248,8 @@ declare enum SpanKind {
7216
7248
 
7217
7249
  /**
7218
7250
  * Options needed for span creation
7251
+ *
7252
+ * @since 1.0.0
7219
7253
  */
7220
7254
  declare interface SpanOptions {
7221
7255
  /**
@@ -7224,7 +7258,7 @@ declare interface SpanOptions {
7224
7258
  */
7225
7259
  kind?: SpanKind;
7226
7260
  /** A span's attributes */
7227
- attributes?: SpanAttributes;
7261
+ attributes?: Attributes;
7228
7262
  /** {@link Link}s span to other spans */
7229
7263
  links?: Link[];
7230
7264
  /** A manually specified start time for the created `Span` object. */
@@ -7233,6 +7267,9 @@ declare interface SpanOptions {
7233
7267
  root?: boolean;
7234
7268
  }
7235
7269
 
7270
+ /**
7271
+ * @since 1.0.0
7272
+ */
7236
7273
  declare interface SpanStatus {
7237
7274
  /** The status code of this message. */
7238
7275
  code: SpanStatusCode;
@@ -7242,6 +7279,8 @@ declare interface SpanStatus {
7242
7279
 
7243
7280
  /**
7244
7281
  * An enumeration of status codes.
7282
+ *
7283
+ * @since 1.0.0
7245
7284
  */
7246
7285
  declare enum SpanStatusCode {
7247
7286
  /**
@@ -8798,6 +8837,8 @@ export declare type TextUIPart = {
8798
8837
  * Defines TimeInput.
8799
8838
  *
8800
8839
  * hrtime, epoch milliseconds, performance.now() or Date
8840
+ *
8841
+ * @since 1.0.0
8801
8842
  */
8802
8843
  declare type TimeInput = HrTime | number | Date;
8803
8844
 
@@ -9142,6 +9183,8 @@ export declare class TooManyEmbeddingValuesForCallError extends AISDKError {
9142
9183
 
9143
9184
  /**
9144
9185
  * Tracer provides an interface for creating {@link Span}s.
9186
+ *
9187
+ * @since 1.0.0
9145
9188
  */
9146
9189
  declare interface Tracer {
9147
9190
  /**
@@ -9208,6 +9251,9 @@ declare interface Tracer {
9208
9251
  startActiveSpan<F extends (span: Span) => unknown>(name: string, options: SpanOptions, context: Context, fn: F): ReturnType<F>;
9209
9252
  }
9210
9253
 
9254
+ /**
9255
+ * @since 1.0.0
9256
+ */
9211
9257
  declare interface TraceState {
9212
9258
  /**
9213
9259
  * Create a new TraceState which inherits from this TraceState and has the
@@ -732,6 +732,8 @@ export declare type AsyncIterableStream<T> = AsyncIterable<T> & ReadableStream<T
732
732
  * Attributes is a map from string to attribute values.
733
733
  *
734
734
  * Note: only the own enumerable keys are counted as valid attribute keys.
735
+ *
736
+ * @since 1.3.0
735
737
  */
736
738
  declare interface Attributes {
737
739
  [attributeKey: string]: AttributeValue | undefined;
@@ -741,6 +743,8 @@ declare interface Attributes {
741
743
  * Attribute values may be any non-nullish primitive value except an object.
742
744
  *
743
745
  * null or undefined attribute values are invalid and will result in undefined behavior.
746
+ *
747
+ * @since 1.3.0
744
748
  */
745
749
  declare type AttributeValue = string | number | boolean | Array<null | undefined | string> | Array<null | undefined | number> | Array<null | undefined | boolean>;
746
750
 
@@ -1125,6 +1129,9 @@ export declare type ContentPart<TOOLS extends ToolSet> = {
1125
1129
  providerMetadata?: ProviderMetadata;
1126
1130
  }) | ToolApprovalRequestOutput<TOOLS>;
1127
1131
 
1132
+ /**
1133
+ * @since 1.0.0
1134
+ */
1128
1135
  declare interface Context {
1129
1136
  /**
1130
1137
  * Get a value from the context.
@@ -2680,6 +2687,8 @@ declare class EventSourceParserStream extends TransformStream<string, EventSourc
2680
2687
  * Defines Exception.
2681
2688
  *
2682
2689
  * string or an object with one of (message or name or code) and optional stack
2690
+ *
2691
+ * @since 1.0.0
2683
2692
  */
2684
2693
  declare type Exception = ExceptionWithCode | ExceptionWithMessage | ExceptionWithName | string;
2685
2694
 
@@ -4237,6 +4246,8 @@ export declare function hasToolCall(toolName: string): StopCondition<any>;
4237
4246
  * The second number is calculated by converting the digits after the decimal point of the subtraction, (1609504210150 / 1000) - HrTime[0], to nanoseconds:
4238
4247
  * HrTime[1] = Number((1609504210.150 - HrTime[0]).toFixed(9)) * 1e9 = 150000000.
4239
4248
  * This is represented in HrTime format as [1609504210, 150000000].
4249
+ *
4250
+ * @since 1.0.0
4240
4251
  */
4241
4252
  declare type HrTime = [number, number];
4242
4253
 
@@ -7445,6 +7456,8 @@ declare function lazySchema_2<SCHEMA>(createSchema: () => Schema<SCHEMA>): LazyS
7445
7456
  * However, it is desirable to associate incoming SpanContext to new trace
7446
7457
  * initiated on service provider side so two traces (from Client and from
7447
7458
  * Service Provider) can be correlated.
7459
+ *
7460
+ * @since 1.0.0
7448
7461
  */
7449
7462
  declare interface Link {
7450
7463
  /** The {@link SpanContext} of a linked span. */
@@ -10006,6 +10019,8 @@ export declare type SourceUrlUIPart = {
10006
10019
  * may have children.
10007
10020
  *
10008
10021
  * Spans are created by the {@link Tracer.startSpan} method.
10022
+ *
10023
+ * @since 1.0.0
10009
10024
  */
10010
10025
  declare interface Span {
10011
10026
  /**
@@ -10065,11 +10080,21 @@ declare interface Span {
10065
10080
  */
10066
10081
  addLinks(links: Link[]): this;
10067
10082
  /**
10068
- * Sets a status to the span. If used, this will override the default Span
10069
- * status. Default is {@link SpanStatusCode.UNSET}. SetStatus overrides the value
10070
- * of previous calls to SetStatus on the Span.
10083
+ * Sets the status of the span.
10084
+ *
10085
+ * By default, a span has status {@link SpanStatusCode.UNSET}.
10086
+ * Calling this method overrides that default.
10087
+ *
10088
+ * The status codes have a total order: `OK > ERROR > UNSET`.
10089
+ *
10090
+ * - Once {@link SpanStatusCode.OK} is set, any further attempts to change
10091
+ * the status are ignored.
10092
+ * - Any attempt to set {@link SpanStatusCode.UNSET} is always ignored.
10093
+ *
10094
+ * The `message` field is only used when {@link SpanStatusCode.ERROR} is set.
10095
+ * For all other status codes, `message` is ignored.
10071
10096
  *
10072
- * @param status the SpanStatus to set.
10097
+ * @param status The {@link SpanStatus} to set.
10073
10098
  */
10074
10099
  setStatus(status: SpanStatus): this;
10075
10100
  /**
@@ -10114,17 +10139,21 @@ declare interface Span {
10114
10139
 
10115
10140
  /**
10116
10141
  * @deprecated please use {@link Attributes}
10142
+ * @since 1.0.0
10117
10143
  */
10118
10144
  declare type SpanAttributes = Attributes;
10119
10145
 
10120
10146
  /**
10121
10147
  * @deprecated please use {@link AttributeValue}
10148
+ * @since 1.0.0
10122
10149
  */
10123
10150
  declare type SpanAttributeValue = AttributeValue;
10124
10151
 
10125
10152
  /**
10126
10153
  * A SpanContext represents the portion of a {@link Span} which must be
10127
10154
  * serialized and propagated along side of a {@link Baggage}.
10155
+ *
10156
+ * @since 1.0.0
10128
10157
  */
10129
10158
  declare interface SpanContext {
10130
10159
  /**
@@ -10174,6 +10203,9 @@ declare interface SpanContext {
10174
10203
  traceState?: TraceState;
10175
10204
  }
10176
10205
 
10206
+ /**
10207
+ * @since 1.0.0
10208
+ */
10177
10209
  declare enum SpanKind {
10178
10210
  /** Default value. Indicates that the span is used internally. */
10179
10211
  INTERNAL = 0,
@@ -10203,6 +10235,8 @@ declare enum SpanKind {
10203
10235
 
10204
10236
  /**
10205
10237
  * Options needed for span creation
10238
+ *
10239
+ * @since 1.0.0
10206
10240
  */
10207
10241
  declare interface SpanOptions {
10208
10242
  /**
@@ -10211,7 +10245,7 @@ declare interface SpanOptions {
10211
10245
  */
10212
10246
  kind?: SpanKind;
10213
10247
  /** A span's attributes */
10214
- attributes?: SpanAttributes;
10248
+ attributes?: Attributes;
10215
10249
  /** {@link Link}s span to other spans */
10216
10250
  links?: Link[];
10217
10251
  /** A manually specified start time for the created `Span` object. */
@@ -10220,6 +10254,9 @@ declare interface SpanOptions {
10220
10254
  root?: boolean;
10221
10255
  }
10222
10256
 
10257
+ /**
10258
+ * @since 1.0.0
10259
+ */
10223
10260
  declare interface SpanStatus {
10224
10261
  /** The status code of this message. */
10225
10262
  code: SpanStatusCode;
@@ -10229,6 +10266,8 @@ declare interface SpanStatus {
10229
10266
 
10230
10267
  /**
10231
10268
  * An enumeration of status codes.
10269
+ *
10270
+ * @since 1.0.0
10232
10271
  */
10233
10272
  declare enum SpanStatusCode {
10234
10273
  /**
@@ -11981,6 +12020,8 @@ export declare type TextUIPart = {
11981
12020
  * Defines TimeInput.
11982
12021
  *
11983
12022
  * hrtime, epoch milliseconds, performance.now() or Date
12023
+ *
12024
+ * @since 1.0.0
11984
12025
  */
11985
12026
  declare type TimeInput = HrTime | number | Date;
11986
12027
 
@@ -13421,6 +13462,8 @@ export declare class TooManyEmbeddingValuesForCallError extends AISDKError {
13421
13462
 
13422
13463
  /**
13423
13464
  * Tracer provides an interface for creating {@link Span}s.
13465
+ *
13466
+ * @since 1.0.0
13424
13467
  */
13425
13468
  declare interface Tracer {
13426
13469
  /**
@@ -13487,6 +13530,9 @@ declare interface Tracer {
13487
13530
  startActiveSpan<F extends (span: Span) => unknown>(name: string, options: SpanOptions, context: Context, fn: F): ReturnType<F>;
13488
13531
  }
13489
13532
 
13533
+ /**
13534
+ * @since 1.0.0
13535
+ */
13490
13536
  declare interface TraceState {
13491
13537
  /**
13492
13538
  * Create a new TraceState which inherits from this TraceState and has the
@@ -1 +1 @@
1
- {"version":3,"file":"chat-route.d.ts","sourceRoot":"","sources":["../src/chat-route.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,IAAI,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAM9F,OAAO,KAAK,EAAE,sBAAsB,IAAI,wBAAwB,EAAE,MA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AO,gBAAgB,CAAC,CAkNhE"}
package/dist/index.cjs CHANGED
@@ -13298,15 +13298,8 @@ function toAISdkStream(stream, options = {
13298
13298
 
13299
13299
  // src/chat-route.ts
13300
13300
  function extractV6NativeApproval(messages) {
13301
- let lastAssistantMsg;
13302
- for (let i = messages.length - 1; i >= 0; i--) {
13303
- const message = messages[i];
13304
- if (message.role === "assistant") {
13305
- lastAssistantMsg = message;
13306
- break;
13307
- }
13308
- }
13309
- if (!lastAssistantMsg) return null;
13301
+ const lastAssistantMsg = messages.at(-1);
13302
+ if (!lastAssistantMsg || lastAssistantMsg.role !== "assistant") return null;
13310
13303
  for (const part of lastAssistantMsg.parts ?? []) {
13311
13304
  if (!isToolUIPart2(part) || part.state !== "approval-responded") continue;
13312
13305
  const lastSep = part.approval.id.lastIndexOf(APPROVAL_ID_SEPARATOR);