@ai-sdk/rsc 2.0.0-beta.98 → 2.0.0

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,735 @@
1
1
  # @ai-sdk/rsc
2
2
 
3
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - dee8b05: ai SDK 6 beta
8
+
9
+ ### Minor Changes
10
+
11
+ - 78928cb: release: start 5.1 beta
12
+
13
+ ### Patch Changes
14
+
15
+ - 95f65c2: chore: use import \* from zod/v4
16
+ - 3bd2689: feat: extended token usage
17
+ - 8dac895: feat: `LanguageModelV3`
18
+ - af65ab6: drop react 19-rc support. Require minimal versions for RSC to address CVE-2025-55182
19
+ - 457318b: chore(provider,ai): switch to SharedV3Warning and unified warnings
20
+ - 4616b86: chore: update zod peer depenedency version
21
+ - cbf52cd: feat: expose raw finish reason
22
+ - fda12fa: chore(rsc): upgrade jsondiffpatch to 0.7.3
23
+ - Updated dependencies [0c3b58b]
24
+ - Updated dependencies [58920e0]
25
+ - Updated dependencies [a7da2b6]
26
+ - Updated dependencies [0adc679]
27
+ - Updated dependencies [50b70d6]
28
+ - Updated dependencies [d1bdadb]
29
+ - Updated dependencies [2d28066]
30
+ - Updated dependencies [fca786b]
31
+ - Updated dependencies [dee8b05]
32
+ - Updated dependencies [046aa3b]
33
+ - Updated dependencies [e1f6e8e]
34
+ - Updated dependencies [8d9e8ad]
35
+ - Updated dependencies [78928cb]
36
+ - Updated dependencies [b67d224]
37
+ - Updated dependencies [ab6f01a]
38
+ - Updated dependencies [9388ff1]
39
+ - Updated dependencies [dce03c4]
40
+ - Updated dependencies [2625a04]
41
+ - Updated dependencies [37c58a0]
42
+ - Updated dependencies [4e2b04d]
43
+ - Updated dependencies [ab1087b]
44
+ - Updated dependencies [3b1d015]
45
+ - Updated dependencies [2b0caef]
46
+ - Updated dependencies [bb10a89]
47
+ - Updated dependencies [457f1c6]
48
+ - Updated dependencies [95f65c2]
49
+ - Updated dependencies [754df61]
50
+ - Updated dependencies [016b111]
51
+ - Updated dependencies [58920e0]
52
+ - Updated dependencies [954c356]
53
+ - Updated dependencies [7fdd89d]
54
+ - Updated dependencies [eca63f3]
55
+ - Updated dependencies [90e5bdd]
56
+ - Updated dependencies [42cf7ed]
57
+ - Updated dependencies [544d4e8]
58
+ - Updated dependencies [4812235]
59
+ - Updated dependencies [7f2c9b6]
60
+ - Updated dependencies [614599a]
61
+ - Updated dependencies [0c4822d]
62
+ - Updated dependencies [e062079]
63
+ - Updated dependencies [2b49dae]
64
+ - Updated dependencies [ee651d7]
65
+ - Updated dependencies [5a4e732]
66
+ - Updated dependencies [f733285]
67
+ - Updated dependencies [9b83947]
68
+ - Updated dependencies [7eca093]
69
+ - Updated dependencies [077aea3]
70
+ - Updated dependencies [9f20c87]
71
+ - Updated dependencies [521c537]
72
+ - Updated dependencies [7169511]
73
+ - Updated dependencies [4c44a5b]
74
+ - Updated dependencies [e8109d3]
75
+ - Updated dependencies [03849b0]
76
+ - Updated dependencies [ed329cb]
77
+ - Updated dependencies [22ef5c6]
78
+ - Updated dependencies [9ba4324]
79
+ - Updated dependencies [e06565c]
80
+ - Updated dependencies [32d8dbb]
81
+ - Updated dependencies [53f3368]
82
+ - Updated dependencies [d116b4b]
83
+ - Updated dependencies [3bd2689]
84
+ - Updated dependencies [293a6b7]
85
+ - Updated dependencies [7c3c216]
86
+ - Updated dependencies [c62ecf0]
87
+ - Updated dependencies [d1bdadb]
88
+ - Updated dependencies [703459a]
89
+ - Updated dependencies [bb36798]
90
+ - Updated dependencies [3071620]
91
+ - Updated dependencies [7e4649f]
92
+ - Updated dependencies [48454ab]
93
+ - Updated dependencies [e06b663]
94
+ - Updated dependencies [83e5744]
95
+ - Updated dependencies [8c98371]
96
+ - Updated dependencies [7e32fea]
97
+ - Updated dependencies [b1405bf]
98
+ - Updated dependencies [a5e152d]
99
+ - Updated dependencies [aa0515c]
100
+ - Updated dependencies [f6f0c5a]
101
+ - Updated dependencies [3ed5519]
102
+ - Updated dependencies [eb8d1cb]
103
+ - Updated dependencies [e7d9b00]
104
+ - Updated dependencies [d5b25ee]
105
+ - Updated dependencies [d7bae86]
106
+ - Updated dependencies [8dac895]
107
+ - Updated dependencies [a755db5]
108
+ - Updated dependencies [1c2a4c1]
109
+ - Updated dependencies [686103c]
110
+ - Updated dependencies [a755db5]
111
+ - Updated dependencies [0d6c0d8]
112
+ - Updated dependencies [9b8d17e]
113
+ - Updated dependencies [79a8e7f]
114
+ - Updated dependencies [cbb1d35]
115
+ - Updated dependencies [d59ce25]
116
+ - Updated dependencies [475189e]
117
+ - Updated dependencies [3d83f38]
118
+ - Updated dependencies [457318b]
119
+ - Updated dependencies [b681d7d]
120
+ - Updated dependencies [c99da05]
121
+ - Updated dependencies [db913bd]
122
+ - Updated dependencies [9061dc0]
123
+ - Updated dependencies [8445d70]
124
+ - Updated dependencies [32223c8]
125
+ - Updated dependencies [8370068]
126
+ - Updated dependencies [5e313e3]
127
+ - Updated dependencies [db62f7d]
128
+ - Updated dependencies [a7f6f81]
129
+ - Updated dependencies [79ba99f]
130
+ - Updated dependencies [c98373a]
131
+ - Updated dependencies [c1efac4]
132
+ - Updated dependencies [846e80e]
133
+ - Updated dependencies [bbdcb81]
134
+ - Updated dependencies [366f50b]
135
+ - Updated dependencies [67a407c]
136
+ - Updated dependencies [9524761]
137
+ - Updated dependencies [ca13d26]
138
+ - Updated dependencies [4616b86]
139
+ - Updated dependencies [a322efa]
140
+ - Updated dependencies [2d166e4]
141
+ - Updated dependencies [384142c]
142
+ - Updated dependencies [36b175c]
143
+ - Updated dependencies [2b1bf9d]
144
+ - Updated dependencies [81d4308]
145
+ - Updated dependencies [e0d1ea9]
146
+ - Updated dependencies [9549c9e]
147
+ - Updated dependencies [2406576]
148
+ - Updated dependencies [b1aeea7]
149
+ - Updated dependencies [dce4e7b]
150
+ - Updated dependencies [af3780b]
151
+ - Updated dependencies [4f16c37]
152
+ - Updated dependencies [4ece5f9]
153
+ - Updated dependencies [81e29ab]
154
+ - Updated dependencies [a417a34]
155
+ - Updated dependencies [637eaa4]
156
+ - Updated dependencies [177b475]
157
+ - Updated dependencies [21e20c0]
158
+ - Updated dependencies [afe7093]
159
+ - Updated dependencies [61f7b0f]
160
+ - Updated dependencies [af9dab3]
161
+ - Updated dependencies [522f6b8]
162
+ - Updated dependencies [6306603]
163
+ - Updated dependencies [97b1d77]
164
+ - Updated dependencies [69768c2]
165
+ - Updated dependencies [27e8c3a]
166
+ - Updated dependencies [fca786b]
167
+ - Updated dependencies [81e29ab]
168
+ - Updated dependencies [7da02d2]
169
+ - Updated dependencies [763d04a]
170
+ - Updated dependencies [95b77e2]
171
+ - Updated dependencies [10d819b]
172
+ - Updated dependencies [3794514]
173
+ - Updated dependencies [cbf52cd]
174
+ - Updated dependencies [14ca35d]
175
+ - Updated dependencies [e9e157f]
176
+ - Updated dependencies [10c1322]
177
+ - Updated dependencies [dcdac8c]
178
+ - Updated dependencies [960ec8f]
179
+ - Updated dependencies [b59d924]
180
+ - Updated dependencies [1bd7d32]
181
+ - Updated dependencies [f0b2157]
182
+ - Updated dependencies [95f65c2]
183
+ - @ai-sdk/provider@3.0.0
184
+ - ai@6.0.0
185
+ - @ai-sdk/provider-utils@4.0.0
186
+
187
+ ## 2.0.0-beta.171
188
+
189
+ ### Patch Changes
190
+
191
+ - Updated dependencies [ee651d7]
192
+ - ai@6.0.0-beta.169
193
+
194
+ ## 2.0.0-beta.170
195
+
196
+ ### Patch Changes
197
+
198
+ - ai@6.0.0-beta.168
199
+
200
+ ## 2.0.0-beta.169
201
+
202
+ ### Patch Changes
203
+
204
+ - Updated dependencies [475189e]
205
+ - @ai-sdk/provider@3.0.0-beta.32
206
+ - ai@6.0.0-beta.167
207
+ - @ai-sdk/provider-utils@4.0.0-beta.59
208
+
209
+ ## 2.0.0-beta.168
210
+
211
+ ### Patch Changes
212
+
213
+ - Updated dependencies [9f20c87]
214
+ - ai@6.0.0-beta.166
215
+
216
+ ## 2.0.0-beta.167
217
+
218
+ ### Patch Changes
219
+
220
+ - Updated dependencies [2625a04]
221
+ - @ai-sdk/provider@3.0.0-beta.31
222
+ - ai@6.0.0-beta.165
223
+ - @ai-sdk/provider-utils@4.0.0-beta.58
224
+
225
+ ## 2.0.0-beta.166
226
+
227
+ ### Patch Changes
228
+
229
+ - cbf52cd: feat: expose raw finish reason
230
+ - Updated dependencies [cbf52cd]
231
+ - @ai-sdk/provider@3.0.0-beta.30
232
+ - ai@6.0.0-beta.164
233
+ - @ai-sdk/provider-utils@4.0.0-beta.57
234
+
235
+ ## 2.0.0-beta.165
236
+
237
+ ### Patch Changes
238
+
239
+ - Updated dependencies [9549c9e]
240
+ - @ai-sdk/provider@3.0.0-beta.29
241
+ - ai@6.0.0-beta.163
242
+ - @ai-sdk/provider-utils@4.0.0-beta.56
243
+
244
+ ## 2.0.0-beta.164
245
+
246
+ ### Patch Changes
247
+
248
+ - Updated dependencies [50b70d6]
249
+ - @ai-sdk/provider-utils@4.0.0-beta.55
250
+ - ai@6.0.0-beta.162
251
+
252
+ ## 2.0.0-beta.163
253
+
254
+ ### Patch Changes
255
+
256
+ - ai@6.0.0-beta.161
257
+
258
+ ## 2.0.0-beta.162
259
+
260
+ ### Patch Changes
261
+
262
+ - Updated dependencies [9061dc0]
263
+ - @ai-sdk/provider-utils@4.0.0-beta.54
264
+ - @ai-sdk/provider@3.0.0-beta.28
265
+ - ai@6.0.0-beta.160
266
+
267
+ ## 2.0.0-beta.161
268
+
269
+ ### Patch Changes
270
+
271
+ - Updated dependencies [3071620]
272
+ - ai@6.0.0-beta.159
273
+
274
+ ## 2.0.0-beta.160
275
+
276
+ ### Patch Changes
277
+
278
+ - Updated dependencies [366f50b]
279
+ - @ai-sdk/provider@3.0.0-beta.27
280
+ - ai@6.0.0-beta.158
281
+ - @ai-sdk/provider-utils@4.0.0-beta.53
282
+
283
+ ## 2.0.0-beta.159
284
+
285
+ ### Patch Changes
286
+
287
+ - Updated dependencies [763d04a]
288
+ - @ai-sdk/provider-utils@4.0.0-beta.52
289
+ - ai@6.0.0-beta.157
290
+
291
+ ## 2.0.0-beta.158
292
+
293
+ ### Patch Changes
294
+
295
+ - Updated dependencies [2406576]
296
+ - ai@6.0.0-beta.156
297
+
298
+ ## 2.0.0-beta.157
299
+
300
+ ### Patch Changes
301
+
302
+ - Updated dependencies [c1efac4]
303
+ - @ai-sdk/provider-utils@4.0.0-beta.51
304
+ - ai@6.0.0-beta.155
305
+
306
+ ## 2.0.0-beta.156
307
+
308
+ ### Patch Changes
309
+
310
+ - Updated dependencies [32223c8]
311
+ - @ai-sdk/provider-utils@4.0.0-beta.50
312
+ - ai@6.0.0-beta.154
313
+
314
+ ## 2.0.0-beta.155
315
+
316
+ ### Patch Changes
317
+
318
+ - Updated dependencies [83e5744]
319
+ - @ai-sdk/provider-utils@4.0.0-beta.49
320
+ - ai@6.0.0-beta.153
321
+
322
+ ## 2.0.0-beta.154
323
+
324
+ ### Patch Changes
325
+
326
+ - Updated dependencies [960ec8f]
327
+ - @ai-sdk/provider-utils@4.0.0-beta.48
328
+ - ai@6.0.0-beta.152
329
+
330
+ ## 2.0.0-beta.153
331
+
332
+ ### Patch Changes
333
+
334
+ - Updated dependencies [dcdac8c]
335
+ - ai@6.0.0-beta.151
336
+
337
+ ## 2.0.0-beta.152
338
+
339
+ ### Patch Changes
340
+
341
+ - Updated dependencies [db62f7d]
342
+ - ai@6.0.0-beta.150
343
+
344
+ ## 2.0.0-beta.151
345
+
346
+ ### Patch Changes
347
+
348
+ - Updated dependencies [4e2b04d]
349
+ - ai@6.0.0-beta.149
350
+
351
+ ## 2.0.0-beta.150
352
+
353
+ ### Patch Changes
354
+
355
+ - ai@6.0.0-beta.148
356
+
357
+ ## 2.0.0-beta.149
358
+
359
+ ### Patch Changes
360
+
361
+ - Updated dependencies [637eaa4]
362
+ - ai@6.0.0-beta.147
363
+
364
+ ## 2.0.0-beta.148
365
+
366
+ ### Patch Changes
367
+
368
+ - Updated dependencies [e9e157f]
369
+ - @ai-sdk/provider-utils@4.0.0-beta.47
370
+ - ai@6.0.0-beta.146
371
+
372
+ ## 2.0.0-beta.147
373
+
374
+ ### Patch Changes
375
+
376
+ - ai@6.0.0-beta.145
377
+
378
+ ## 2.0.0-beta.146
379
+
380
+ ### Patch Changes
381
+
382
+ - Updated dependencies [ab6f01a]
383
+ - ai@6.0.0-beta.144
384
+
385
+ ## 2.0.0-beta.145
386
+
387
+ ### Patch Changes
388
+
389
+ - Updated dependencies [81e29ab]
390
+ - Updated dependencies [81e29ab]
391
+ - @ai-sdk/provider-utils@4.0.0-beta.46
392
+ - ai@6.0.0-beta.143
393
+
394
+ ## 2.0.0-beta.144
395
+
396
+ ### Patch Changes
397
+
398
+ - Updated dependencies [7169511]
399
+ - Updated dependencies [bbdcb81]
400
+ - ai@6.0.0-beta.142
401
+
402
+ ## 2.0.0-beta.143
403
+
404
+ ### Patch Changes
405
+
406
+ - Updated dependencies [b1405bf]
407
+ - ai@6.0.0-beta.141
408
+
409
+ ## 2.0.0-beta.142
410
+
411
+ ### Patch Changes
412
+
413
+ - Updated dependencies [7fdd89d]
414
+ - ai@6.0.0-beta.140
415
+
416
+ ## 2.0.0-beta.141
417
+
418
+ ### Patch Changes
419
+
420
+ - 3bd2689: feat: extended token usage
421
+ - Updated dependencies [3bd2689]
422
+ - @ai-sdk/provider@3.0.0-beta.26
423
+ - ai@6.0.0-beta.139
424
+ - @ai-sdk/provider-utils@4.0.0-beta.45
425
+
426
+ ## 2.0.0-beta.140
427
+
428
+ ### Patch Changes
429
+
430
+ - Updated dependencies [53f3368]
431
+ - @ai-sdk/provider@3.0.0-beta.25
432
+ - ai@6.0.0-beta.138
433
+ - @ai-sdk/provider-utils@4.0.0-beta.44
434
+
435
+ ## 2.0.0-beta.139
436
+
437
+ ### Patch Changes
438
+
439
+ - Updated dependencies [9ba4324]
440
+ - ai@6.0.0-beta.137
441
+
442
+ ## 2.0.0-beta.138
443
+
444
+ ### Patch Changes
445
+
446
+ - Updated dependencies [3d83f38]
447
+ - ai@6.0.0-beta.136
448
+
449
+ ## 2.0.0-beta.137
450
+
451
+ ### Patch Changes
452
+
453
+ - Updated dependencies [afe7093]
454
+ - ai@6.0.0-beta.135
455
+
456
+ ## 2.0.0-beta.136
457
+
458
+ ### Patch Changes
459
+
460
+ - Updated dependencies [686103c]
461
+ - ai@6.0.0-beta.134
462
+
463
+ ## 2.0.0-beta.135
464
+
465
+ ### Patch Changes
466
+
467
+ - Updated dependencies [dce03c4]
468
+ - @ai-sdk/provider-utils@4.0.0-beta.43
469
+ - @ai-sdk/provider@3.0.0-beta.24
470
+ - ai@6.0.0-beta.133
471
+
472
+ ## 2.0.0-beta.134
473
+
474
+ ### Patch Changes
475
+
476
+ - Updated dependencies [af9dab3]
477
+ - ai@6.0.0-beta.132
478
+
479
+ ## 2.0.0-beta.133
480
+
481
+ ### Patch Changes
482
+
483
+ - Updated dependencies [3ed5519]
484
+ - @ai-sdk/provider-utils@4.0.0-beta.42
485
+ - ai@6.0.0-beta.131
486
+
487
+ ## 2.0.0-beta.132
488
+
489
+ ### Patch Changes
490
+
491
+ - af65ab6: drop react 19-rc support. Require minimal versions for RSC to address CVE-2025-55182
492
+
493
+ ## 2.0.0-beta.131
494
+
495
+ ### Patch Changes
496
+
497
+ - Updated dependencies [1bd7d32]
498
+ - @ai-sdk/provider-utils@4.0.0-beta.41
499
+ - @ai-sdk/provider@3.0.0-beta.23
500
+ - ai@6.0.0-beta.130
501
+
502
+ ## 2.0.0-beta.130
503
+
504
+ ### Patch Changes
505
+
506
+ - Updated dependencies [67a407c]
507
+ - ai@6.0.0-beta.129
508
+
509
+ ## 2.0.0-beta.129
510
+
511
+ ### Patch Changes
512
+
513
+ - ai@6.0.0-beta.128
514
+
515
+ ## 2.0.0-beta.128
516
+
517
+ ### Patch Changes
518
+
519
+ - Updated dependencies [614599a]
520
+ - ai@6.0.0-beta.127
521
+
522
+ ## 2.0.0-beta.127
523
+
524
+ ### Patch Changes
525
+
526
+ - Updated dependencies [b67d224]
527
+ - ai@6.0.0-beta.126
528
+
529
+ ## 2.0.0-beta.126
530
+
531
+ ### Patch Changes
532
+
533
+ - Updated dependencies [0d6c0d8]
534
+ - ai@6.0.0-beta.125
535
+
536
+ ## 2.0.0-beta.125
537
+
538
+ ### Patch Changes
539
+
540
+ - Updated dependencies [544d4e8]
541
+ - @ai-sdk/provider-utils@4.0.0-beta.40
542
+ - @ai-sdk/provider@3.0.0-beta.22
543
+ - ai@6.0.0-beta.124
544
+
545
+ ## 2.0.0-beta.124
546
+
547
+ ### Patch Changes
548
+
549
+ - Updated dependencies [954c356]
550
+ - @ai-sdk/provider-utils@4.0.0-beta.39
551
+ - @ai-sdk/provider@3.0.0-beta.21
552
+ - ai@6.0.0-beta.123
553
+
554
+ ## 2.0.0-beta.123
555
+
556
+ ### Patch Changes
557
+
558
+ - Updated dependencies [03849b0]
559
+ - @ai-sdk/provider-utils@4.0.0-beta.38
560
+ - ai@6.0.0-beta.122
561
+
562
+ ## 2.0.0-beta.122
563
+
564
+ ### Patch Changes
565
+
566
+ - ai@6.0.0-beta.121
567
+
568
+ ## 2.0.0-beta.121
569
+
570
+ ### Patch Changes
571
+
572
+ - 457318b: chore(provider,ai): switch to SharedV3Warning and unified warnings
573
+ - Updated dependencies [457318b]
574
+ - @ai-sdk/provider@3.0.0-beta.20
575
+ - ai@6.0.0-beta.120
576
+ - @ai-sdk/provider-utils@4.0.0-beta.37
577
+
578
+ ## 2.0.0-beta.120
579
+
580
+ ### Patch Changes
581
+
582
+ - Updated dependencies [b59d924]
583
+ - ai@6.0.0-beta.119
584
+
585
+ ## 2.0.0-beta.119
586
+
587
+ ### Patch Changes
588
+
589
+ - Updated dependencies [8d9e8ad]
590
+ - @ai-sdk/provider@3.0.0-beta.19
591
+ - ai@6.0.0-beta.118
592
+ - @ai-sdk/provider-utils@4.0.0-beta.36
593
+
594
+ ## 2.0.0-beta.118
595
+
596
+ ### Patch Changes
597
+
598
+ - Updated dependencies [10d819b]
599
+ - @ai-sdk/provider@3.0.0-beta.18
600
+ - ai@6.0.0-beta.117
601
+ - @ai-sdk/provider-utils@4.0.0-beta.35
602
+
603
+ ## 2.0.0-beta.117
604
+
605
+ ### Patch Changes
606
+
607
+ - Updated dependencies [4ece5f9]
608
+ - ai@6.0.0-beta.116
609
+
610
+ ## 2.0.0-beta.116
611
+
612
+ ### Patch Changes
613
+
614
+ - Updated dependencies [7da02d2]
615
+ - ai@6.0.0-beta.115
616
+
617
+ ## 2.0.0-beta.115
618
+
619
+ ### Patch Changes
620
+
621
+ - Updated dependencies [69768c2]
622
+ - ai@6.0.0-beta.114
623
+
624
+ ## 2.0.0-beta.114
625
+
626
+ ### Patch Changes
627
+
628
+ - Updated dependencies [79a8e7f]
629
+ - ai@6.0.0-beta.113
630
+
631
+ ## 2.0.0-beta.113
632
+
633
+ ### Patch Changes
634
+
635
+ - Updated dependencies [e06b663]
636
+ - ai@6.0.0-beta.112
637
+
638
+ ## 2.0.0-beta.112
639
+
640
+ ### Patch Changes
641
+
642
+ - ai@6.0.0-beta.111
643
+
644
+ ## 2.0.0-beta.111
645
+
646
+ ### Patch Changes
647
+
648
+ - Updated dependencies [db913bd]
649
+ - @ai-sdk/provider@3.0.0-beta.17
650
+ - ai@6.0.0-beta.110
651
+ - @ai-sdk/provider-utils@4.0.0-beta.34
652
+
653
+ ## 2.0.0-beta.110
654
+
655
+ ### Patch Changes
656
+
657
+ - Updated dependencies [79ba99f]
658
+ - ai@6.0.0-beta.109
659
+
660
+ ## 2.0.0-beta.109
661
+
662
+ ### Patch Changes
663
+
664
+ - ai@6.0.0-beta.108
665
+
666
+ ## 2.0.0-beta.108
667
+
668
+ ### Patch Changes
669
+
670
+ - Updated dependencies [8445d70]
671
+ - ai@6.0.0-beta.107
672
+
673
+ ## 2.0.0-beta.107
674
+
675
+ ### Patch Changes
676
+
677
+ - ai@6.0.0-beta.106
678
+
679
+ ## 2.0.0-beta.106
680
+
681
+ ### Patch Changes
682
+
683
+ - ai@6.0.0-beta.105
684
+
685
+ ## 2.0.0-beta.105
686
+
687
+ ### Patch Changes
688
+
689
+ - Updated dependencies [2d166e4]
690
+ - ai@6.0.0-beta.104
691
+
692
+ ## 2.0.0-beta.104
693
+
694
+ ### Patch Changes
695
+
696
+ - ai@6.0.0-beta.103
697
+
698
+ ## 2.0.0-beta.103
699
+
700
+ ### Patch Changes
701
+
702
+ - ai@6.0.0-beta.102
703
+
704
+ ## 2.0.0-beta.102
705
+
706
+ ### Patch Changes
707
+
708
+ - ai@6.0.0-beta.101
709
+
710
+ ## 2.0.0-beta.101
711
+
712
+ ### Patch Changes
713
+
714
+ - Updated dependencies [8370068]
715
+ - ai@6.0.0-beta.100
716
+
717
+ ## 2.0.0-beta.100
718
+
719
+ ### Patch Changes
720
+
721
+ - Updated dependencies [384142c]
722
+ - ai@6.0.0-beta.99
723
+
724
+ ## 2.0.0-beta.99
725
+
726
+ ### Patch Changes
727
+
728
+ - Updated dependencies [b681d7d]
729
+ - @ai-sdk/provider@3.0.0-beta.16
730
+ - ai@6.0.0-beta.98
731
+ - @ai-sdk/provider-utils@4.0.0-beta.33
732
+
3
733
  ## 2.0.0-beta.98
4
734
 
5
735
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { LanguageModelV3 } from '@ai-sdk/provider';
1
+ import { LanguageModelV3, LanguageModelV3StreamResult } from '@ai-sdk/provider';
2
2
  import { ProviderOptions, InferSchema } from '@ai-sdk/provider-utils';
3
+ import { Schema, CallSettings, Prompt, ToolChoice, FinishReason, LanguageModelUsage, CallWarning } from 'ai';
3
4
  import { ReactNode } from 'react';
4
5
  import * as z3 from 'zod/v3';
5
6
  import * as z4 from 'zod/v4';
6
- import { Schema, CallSettings, Prompt, ToolChoice, FinishReason, LanguageModelUsage, CallWarning } from 'ai';
7
7
 
8
8
  type JSONValue = string | number | boolean | JSONObject | JSONArray;
9
9
  interface JSONObject {
@@ -153,7 +153,7 @@ type RenderText = Renderer<[
153
153
  ]>;
154
154
  type RenderResult = {
155
155
  value: ReactNode;
156
- } & Awaited<ReturnType<LanguageModelV3['doStream']>>;
156
+ } & LanguageModelV3StreamResult;
157
157
  /**
158
158
  * `streamUI` is a helper function to create a streamable UI from LLMs.
159
159
  */
@@ -1,9 +1,9 @@
1
- import { LanguageModelV3 } from '@ai-sdk/provider';
1
+ import { LanguageModelV3, LanguageModelV3StreamResult } from '@ai-sdk/provider';
2
2
  import { ProviderOptions, InferSchema } from '@ai-sdk/provider-utils';
3
+ import { Schema, CallSettings, Prompt, ToolChoice, FinishReason, LanguageModelUsage, CallWarning } from 'ai';
3
4
  import { ReactNode } from 'react';
4
5
  import * as z3 from 'zod/v3';
5
6
  import * as z4 from 'zod/v4';
6
- import { Schema, CallSettings, Prompt, ToolChoice, FinishReason, LanguageModelUsage, CallWarning } from 'ai';
7
7
 
8
8
  type AIAction<T = any, R = any> = (...args: T[]) => Promise<R>;
9
9
  type AIActions<T = any, R = any> = Record<string, AIAction<T, R>>;
@@ -132,7 +132,7 @@ type RenderText = Renderer<[
132
132
  ]>;
133
133
  type RenderResult = {
134
134
  value: ReactNode;
135
- } & Awaited<ReturnType<LanguageModelV3['doStream']>>;
135
+ } & LanguageModelV3StreamResult;
136
136
  /**
137
137
  * `streamUI` is a helper function to create a streamable UI from LLMs.
138
138
  */
@@ -219,23 +219,14 @@ import {
219
219
  NoSuchToolError
220
220
  } from "ai";
221
221
  import {
222
- standardizePrompt,
223
- prepareToolsAndToolChoice,
224
- prepareRetries,
222
+ asLanguageModelUsage,
223
+ convertToLanguageModelPrompt,
225
224
  prepareCallSettings,
226
- convertToLanguageModelPrompt
225
+ prepareRetries,
226
+ prepareToolsAndToolChoice,
227
+ standardizePrompt
227
228
  } from "ai/internal";
228
229
 
229
- // src/util/is-async-generator.ts
230
- function isAsyncGenerator(value) {
231
- return value != null && typeof value === "object" && Symbol.asyncIterator in value;
232
- }
233
-
234
- // src/util/is-generator.ts
235
- function isGenerator(value) {
236
- return value != null && typeof value === "object" && Symbol.iterator in value;
237
- }
238
-
239
230
  // src/util/constants.ts
240
231
  var HANGING_STREAM_WARNING_TIME_MS = 15 * 1e3;
241
232
 
@@ -345,6 +336,16 @@ function createStreamableUI(initialValue) {
345
336
  return streamable;
346
337
  }
347
338
 
339
+ // src/util/is-async-generator.ts
340
+ function isAsyncGenerator(value) {
341
+ return value != null && typeof value === "object" && Symbol.asyncIterator in value;
342
+ }
343
+
344
+ // src/util/is-generator.ts
345
+ function isGenerator(value) {
346
+ return value != null && typeof value === "object" && Symbol.iterator in value;
347
+ }
348
+
348
349
  // src/stream-ui/stream-ui.tsx
349
350
  var defaultTextRenderer = ({ content }) => content;
350
351
  async function streamUI({
@@ -451,6 +452,7 @@ async function streamUI({
451
452
  );
452
453
  const [stream, forkedStream] = result.stream.tee();
453
454
  (async () => {
455
+ var _a;
454
456
  try {
455
457
  let content = "";
456
458
  let hasToolCall = false;
@@ -522,7 +524,7 @@ async function streamUI({
522
524
  }
523
525
  case "finish": {
524
526
  finishEvent = {
525
- finishReason: value.finishReason,
527
+ finishReason: (_a = value.finishReason) == null ? void 0 : _a.unified,
526
528
  usage: value.usage,
527
529
  warnings,
528
530
  response: result.response
@@ -543,6 +545,7 @@ async function streamUI({
543
545
  if (finishEvent && onFinish) {
544
546
  await onFinish({
545
547
  ...finishEvent,
548
+ usage: asLanguageModelUsage(finishEvent.usage),
546
549
  value: ui.value
547
550
  });
548
551
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/ai-state.tsx","../src/util/create-resolvable-promise.ts","../src/util/is-function.ts","../src/provider.tsx","../src/stream-ui/stream-ui.tsx","../src/util/is-async-generator.ts","../src/util/is-generator.ts","../src/util/constants.ts","../src/streamable-ui/create-suspended-chunk.tsx","../src/streamable-ui/create-streamable-ui.tsx","../src/streamable-value/streamable-value.ts","../src/streamable-value/create-streamable-value.ts"],"sourcesContent":["import * as jsondiffpatch from 'jsondiffpatch';\nimport { AsyncLocalStorage } from 'node:async_hooks';\nimport { createResolvablePromise } from './util/create-resolvable-promise';\nimport { isFunction } from './util/is-function';\nimport type {\n AIProvider,\n InferAIState,\n InternalAIStateStorageOptions,\n MutableAIState,\n ValueOrUpdater,\n} from './types';\n\n// It is possible that multiple AI requests get in concurrently, for different\n// AI instances. So ALS is necessary here for a simpler API.\nconst asyncAIStateStorage = new AsyncLocalStorage<{\n currentState: any;\n originalState: any;\n sealed: boolean;\n options: InternalAIStateStorageOptions;\n mutationDeltaPromise?: Promise<any>;\n mutationDeltaResolve?: (v: any) => void;\n}>();\n\nfunction getAIStateStoreOrThrow(message: string) {\n const store = asyncAIStateStorage.getStore();\n if (!store) {\n throw new Error(message);\n }\n return store;\n}\n\nexport function withAIState<S, T>(\n { state, options }: { state: S; options: InternalAIStateStorageOptions },\n fn: () => T,\n): T {\n return asyncAIStateStorage.run(\n {\n currentState: JSON.parse(JSON.stringify(state)), // deep clone object\n originalState: state,\n sealed: false,\n options,\n },\n fn,\n );\n}\n\nexport function getAIStateDeltaPromise() {\n const store = getAIStateStoreOrThrow('Internal error occurred.');\n return store.mutationDeltaPromise;\n}\n\n// Internal method. This will be called after the AI Action has been returned\n// and you can no longer call `getMutableAIState()` inside any async callbacks\n// created by that Action.\nexport function sealMutableAIState() {\n const store = getAIStateStoreOrThrow('Internal error occurred.');\n store.sealed = true;\n}\n\n/**\n * Get the current AI state.\n * If `key` is provided, it will return the value of the specified key in the\n * AI state, if it's an object. If it's not an object, it will throw an error.\n *\n * @example const state = getAIState() // Get the entire AI state\n * @example const field = getAIState('key') // Get the value of the key\n */\nfunction getAIState<AI extends AIProvider = any>(): Readonly<\n InferAIState<AI, any>\n>;\nfunction getAIState<AI extends AIProvider = any>(\n key: keyof InferAIState<AI, any>,\n): Readonly<InferAIState<AI, any>[typeof key]>;\nfunction getAIState<AI extends AIProvider = any>(\n ...args: [] | [key: keyof InferAIState<AI, any>]\n) {\n const store = getAIStateStoreOrThrow(\n '`getAIState` must be called within an AI Action.',\n );\n\n if (args.length > 0) {\n const key = args[0];\n if (typeof store.currentState !== 'object') {\n throw new Error(\n `You can't get the \"${String(\n key,\n )}\" field from the AI state because it's not an object.`,\n );\n }\n return store.currentState[key as keyof typeof store.currentState];\n }\n\n return store.currentState;\n}\n\n/**\n * Get the mutable AI state. Note that you must call `.done()` when finishing\n * updating the AI state.\n *\n * @example\n * ```tsx\n * const state = getMutableAIState()\n * state.update({ ...state.get(), key: 'value' })\n * state.update((currentState) => ({ ...currentState, key: 'value' }))\n * state.done()\n * ```\n *\n * @example\n * ```tsx\n * const state = getMutableAIState()\n * state.done({ ...state.get(), key: 'value' }) // Done with a new state\n * ```\n */\nfunction getMutableAIState<AI extends AIProvider = any>(): MutableAIState<\n InferAIState<AI, any>\n>;\nfunction getMutableAIState<AI extends AIProvider = any>(\n key: keyof InferAIState<AI, any>,\n): MutableAIState<InferAIState<AI, any>[typeof key]>;\nfunction getMutableAIState<AI extends AIProvider = any>(\n ...args: [] | [key: keyof InferAIState<AI, any>]\n) {\n type AIState = InferAIState<AI, any>;\n type AIStateWithKey = typeof args extends [key: keyof AIState]\n ? AIState[(typeof args)[0]]\n : AIState;\n type NewStateOrUpdater = ValueOrUpdater<AIStateWithKey>;\n\n const store = getAIStateStoreOrThrow(\n '`getMutableAIState` must be called within an AI Action.',\n );\n\n if (store.sealed) {\n throw new Error(\n \"`getMutableAIState` must be called before returning from an AI Action. Please move it to the top level of the Action's function body.\",\n );\n }\n\n if (!store.mutationDeltaPromise) {\n const { promise, resolve } = createResolvablePromise();\n store.mutationDeltaPromise = promise;\n store.mutationDeltaResolve = resolve;\n }\n\n function doUpdate(newState: NewStateOrUpdater, done: boolean) {\n if (args.length > 0) {\n if (typeof store.currentState !== 'object') {\n const key = args[0];\n throw new Error(\n `You can't modify the \"${String(\n key,\n )}\" field of the AI state because it's not an object.`,\n );\n }\n }\n\n if (isFunction(newState)) {\n if (args.length > 0) {\n store.currentState[args[0]] = newState(store.currentState[args[0]]);\n } else {\n store.currentState = newState(store.currentState);\n }\n } else {\n if (args.length > 0) {\n store.currentState[args[0]] = newState;\n } else {\n store.currentState = newState;\n }\n }\n\n store.options.onSetAIState?.({\n key: args.length > 0 ? args[0] : undefined,\n state: store.currentState,\n done,\n });\n }\n\n const mutableState = {\n get: () => {\n if (args.length > 0) {\n const key = args[0];\n if (typeof store.currentState !== 'object') {\n throw new Error(\n `You can't get the \"${String(\n key,\n )}\" field from the AI state because it's not an object.`,\n );\n }\n return store.currentState[key] as Readonly<AIStateWithKey>;\n }\n\n return store.currentState as Readonly<AIState>;\n },\n update: function update(newAIState: NewStateOrUpdater) {\n doUpdate(newAIState, false);\n },\n done: function done(...doneArgs: [] | [NewStateOrUpdater]) {\n if (doneArgs.length > 0) {\n doUpdate(doneArgs[0] as NewStateOrUpdater, true);\n }\n\n const delta = jsondiffpatch.diff(store.originalState, store.currentState);\n store.mutationDeltaResolve!(delta);\n },\n };\n\n return mutableState;\n}\n\nexport { getAIState, getMutableAIState };\n","/**\n * Creates a Promise with externally accessible resolve and reject functions.\n *\n * @template T - The type of the value that the Promise will resolve to.\n * @returns An object containing:\n * - promise: A Promise that can be resolved or rejected externally.\n * - resolve: A function to resolve the Promise with a value of type T.\n * - reject: A function to reject the Promise with an error.\n */\nexport function createResolvablePromise<T = any>(): {\n promise: Promise<T>;\n resolve: (value: T) => void;\n reject: (error: unknown) => void;\n} {\n let resolve: (value: T) => void;\n let reject: (error: unknown) => void;\n\n const promise = new Promise<T>((res, rej) => {\n resolve = res;\n reject = rej;\n });\n\n return {\n promise,\n resolve: resolve!,\n reject: reject!,\n };\n}\n","/**\n * Checks if the given value is a function.\n *\n * @param {unknown} value - The value to check.\n * @returns {boolean} True if the value is a function, false otherwise.\n */\nexport const isFunction = (value: unknown): value is Function =>\n typeof value === 'function';\n","// This file provides the AI context to all AI Actions via AsyncLocalStorage.\n\nimport * as React from 'react';\nimport { InternalAIProvider } from './rsc-shared.mjs';\nimport {\n withAIState,\n getAIStateDeltaPromise,\n sealMutableAIState,\n} from './ai-state';\nimport type {\n ServerWrappedActions,\n AIAction,\n AIActions,\n AIProvider,\n InternalAIStateStorageOptions,\n OnSetAIState,\n OnGetUIState,\n} from './types';\n\nasync function innerAction<T>(\n {\n action,\n options,\n }: { action: AIAction; options: InternalAIStateStorageOptions },\n state: T,\n ...args: unknown[]\n) {\n 'use server';\n return await withAIState(\n {\n state,\n options,\n },\n async () => {\n const result = await action(...args);\n sealMutableAIState();\n return [getAIStateDeltaPromise() as Promise<T>, result];\n },\n );\n}\n\nfunction wrapAction<T = unknown>(\n action: AIAction,\n options: InternalAIStateStorageOptions,\n) {\n return innerAction.bind(null, { action, options }) as AIAction<T>;\n}\n\nexport function createAI<\n AIState = any,\n UIState = any,\n Actions extends AIActions = {},\n>({\n actions,\n initialAIState,\n initialUIState,\n\n onSetAIState,\n onGetUIState,\n}: {\n actions: Actions;\n initialAIState?: AIState;\n initialUIState?: UIState;\n\n /**\n * This function is called whenever the AI state is updated by an Action.\n * You can use this to persist the AI state to a database, or to send it to a\n * logging service.\n */\n onSetAIState?: OnSetAIState<AIState>;\n\n /**\n * This function is used to retrieve the UI state based on the AI state.\n * For example, to render the initial UI state based on a given AI state, or\n * to sync the UI state when the application is already loaded.\n *\n * If returning `undefined`, the client side UI state will not be updated.\n *\n * This function must be annotated with the `\"use server\"` directive.\n *\n * @example\n * ```tsx\n * onGetUIState: async () => {\n * 'use server';\n *\n * const currentAIState = getAIState();\n * const externalAIState = await loadAIStateFromDatabase();\n *\n * if (currentAIState === externalAIState) return undefined;\n *\n * // Update current AI state and return the new UI state\n * const state = getMutableAIState()\n * state.done(externalAIState)\n *\n * return <div>...</div>;\n * }\n * ```\n */\n onGetUIState?: OnGetUIState<UIState>;\n}) {\n // Wrap all actions with our HoC.\n const wrappedActions: ServerWrappedActions = {};\n for (const name in actions) {\n wrappedActions[name] = wrapAction(actions[name], {\n onSetAIState,\n });\n }\n\n const wrappedSyncUIState = onGetUIState\n ? wrapAction(onGetUIState, {})\n : undefined;\n\n const AI: AIProvider<AIState, UIState, Actions> = async props => {\n if ('useState' in React) {\n // This file must be running on the React Server layer.\n // Ideally we should be using `import \"server-only\"` here but we can have a\n // more customized error message with this implementation.\n throw new Error(\n 'This component can only be used inside Server Components.',\n );\n }\n\n let uiState = props.initialUIState ?? initialUIState;\n let aiState = props.initialAIState ?? initialAIState;\n let aiStateDelta = undefined;\n\n if (wrappedSyncUIState) {\n const [newAIStateDelta, newUIState] = await wrappedSyncUIState(aiState);\n if (newUIState !== undefined) {\n aiStateDelta = newAIStateDelta;\n uiState = newUIState;\n }\n }\n\n return (\n <InternalAIProvider\n wrappedActions={wrappedActions}\n wrappedSyncUIState={wrappedSyncUIState}\n initialUIState={uiState}\n initialAIState={aiState}\n initialAIStatePatch={aiStateDelta}\n >\n {props.children}\n </InternalAIProvider>\n );\n };\n\n return AI;\n}\n","import { LanguageModelV3, LanguageModelV3CallWarning } from '@ai-sdk/provider';\nimport {\n InferSchema,\n ProviderOptions,\n safeParseJSON,\n} from '@ai-sdk/provider-utils';\nimport { ReactNode } from 'react';\nimport * as z3 from 'zod/v3';\nimport * as z4 from 'zod/v4';\nimport {\n CallWarning,\n FinishReason,\n LanguageModelUsage,\n ToolChoice,\n Prompt,\n CallSettings,\n InvalidToolInputError,\n NoSuchToolError,\n Schema,\n} from 'ai';\nimport {\n standardizePrompt,\n prepareToolsAndToolChoice,\n prepareRetries,\n prepareCallSettings,\n convertToLanguageModelPrompt,\n} from 'ai/internal';\nimport { createResolvablePromise } from '../util/create-resolvable-promise';\nimport { isAsyncGenerator } from '../util/is-async-generator';\nimport { isGenerator } from '../util/is-generator';\nimport { createStreamableUI } from '../streamable-ui/create-streamable-ui';\n\ntype Streamable = ReactNode | Promise<ReactNode>;\n\ntype Renderer<T extends Array<any>> = (\n ...args: T\n) =>\n | Streamable\n | Generator<Streamable, Streamable, void>\n | AsyncGenerator<Streamable, Streamable, void>;\n\ntype RenderTool<\n INPUT_SCHEMA extends z4.core.$ZodType | z3.Schema | Schema = any,\n> = {\n description?: string;\n inputSchema: INPUT_SCHEMA;\n generate?: Renderer<\n [\n InferSchema<INPUT_SCHEMA>,\n {\n toolName: string;\n toolCallId: string;\n },\n ]\n >;\n};\n\ntype RenderText = Renderer<\n [\n {\n /**\n * The full text content from the model so far.\n */\n content: string;\n\n /**\n * The new appended text content from the model since the last `text` call.\n */\n delta: string;\n\n /**\n * Whether the model is done generating text.\n * If `true`, the `content` will be the final output and this call will be the last.\n */\n done: boolean;\n },\n ]\n>;\n\ntype RenderResult = {\n value: ReactNode;\n} & Awaited<ReturnType<LanguageModelV3['doStream']>>;\n\nconst defaultTextRenderer: RenderText = ({ content }: { content: string }) =>\n content;\n\n/**\n * `streamUI` is a helper function to create a streamable UI from LLMs.\n */\nexport async function streamUI<\n TOOLS extends { [name: string]: z4.core.$ZodType | z3.Schema | Schema } = {},\n>({\n model,\n tools,\n toolChoice,\n system,\n prompt,\n messages,\n maxRetries,\n abortSignal,\n headers,\n initial,\n text,\n providerOptions,\n onFinish,\n ...settings\n}: CallSettings &\n Prompt & {\n /**\n * The language model to use.\n */\n model: LanguageModelV3;\n\n /**\n * The tools that the model can call. The model needs to support calling tools.\n */\n tools?: {\n [name in keyof TOOLS]: RenderTool<TOOLS[name]>;\n };\n\n /**\n * The tool choice strategy. Default: 'auto'.\n */\n toolChoice?: ToolChoice<TOOLS>;\n\n text?: RenderText;\n initial?: ReactNode;\n\n /**\nAdditional provider-specific options. They are passed through\nto the provider from the AI SDK and enable provider-specific\nfunctionality that can be fully encapsulated in the provider.\n */\n providerOptions?: ProviderOptions;\n\n /**\n * Callback that is called when the LLM response and the final object validation are finished.\n */\n onFinish?: (event: {\n /**\n * The reason why the generation finished.\n */\n finishReason: FinishReason;\n /**\n * The token usage of the generated response.\n */\n usage: LanguageModelUsage;\n /**\n * The final ui node that was generated.\n */\n value: ReactNode;\n /**\n * Warnings from the model provider (e.g. unsupported settings)\n */\n warnings?: CallWarning[];\n /**\n * Optional response data.\n */\n response?: {\n /**\n * Response headers.\n */\n headers?: Record<string, string>;\n };\n }) => Promise<void> | void;\n }): Promise<RenderResult> {\n // TODO: Remove these errors after the experimental phase.\n if (typeof model === 'string') {\n throw new Error(\n '`model` cannot be a string in `streamUI`. Use the actual model instance instead.',\n );\n }\n if ('functions' in settings) {\n throw new Error(\n '`functions` is not supported in `streamUI`, use `tools` instead.',\n );\n }\n if ('provider' in settings) {\n throw new Error(\n '`provider` is no longer needed in `streamUI`. Use `model` instead.',\n );\n }\n if (tools) {\n for (const [name, tool] of Object.entries(tools)) {\n if ('render' in tool) {\n throw new Error(\n 'Tool definition in `streamUI` should not have `render` property. Use `generate` instead. Found in tool: ' +\n name,\n );\n }\n }\n }\n\n const ui = createStreamableUI(initial);\n\n // The default text renderer just returns the content as string.\n const textRender = text || defaultTextRenderer;\n\n let finished: Promise<void> | undefined;\n\n let finishEvent: {\n finishReason: FinishReason;\n usage: LanguageModelUsage;\n warnings?: CallWarning[];\n response?: {\n headers?: Record<string, string>;\n };\n } | null = null;\n\n async function render({\n args,\n renderer,\n streamableUI,\n isLastCall = false,\n }: {\n renderer: undefined | Renderer<any>;\n args: [payload: any] | [payload: any, options: any];\n streamableUI: ReturnType<typeof createStreamableUI>;\n isLastCall?: boolean;\n }) {\n if (!renderer) return;\n\n // create a promise that will be resolved when the render call is finished.\n // it is appended to the `finished` promise chain to ensure the render call\n // is finished before the next render call starts.\n const renderFinished = createResolvablePromise<void>();\n finished = finished\n ? finished.then(() => renderFinished.promise)\n : renderFinished.promise;\n\n const rendererResult = renderer(...args);\n\n if (isAsyncGenerator(rendererResult) || isGenerator(rendererResult)) {\n while (true) {\n const { done, value } = await rendererResult.next();\n const node = await value;\n\n if (isLastCall && done) {\n streamableUI.done(node);\n } else {\n streamableUI.update(node);\n }\n\n if (done) break;\n }\n } else {\n const node = await rendererResult;\n\n if (isLastCall) {\n streamableUI.done(node);\n } else {\n streamableUI.update(node);\n }\n }\n\n // resolve the promise to signal that the render call is finished\n renderFinished.resolve(undefined);\n }\n\n const { retry } = prepareRetries({ maxRetries, abortSignal });\n\n const validatedPrompt = await standardizePrompt({\n system,\n prompt,\n messages,\n } as Prompt);\n const result = await retry(async () =>\n model.doStream({\n ...prepareCallSettings(settings),\n ...prepareToolsAndToolChoice({\n tools: tools as any,\n toolChoice,\n activeTools: undefined,\n }),\n prompt: await convertToLanguageModelPrompt({\n prompt: validatedPrompt,\n supportedUrls: await model.supportedUrls,\n download: undefined,\n }),\n providerOptions,\n abortSignal,\n headers,\n includeRawChunks: false,\n }),\n );\n\n // For the stream and consume it asynchronously:\n const [stream, forkedStream] = result.stream.tee();\n (async () => {\n try {\n let content = '';\n let hasToolCall = false;\n let warnings: LanguageModelV3CallWarning[] | undefined;\n\n const reader = forkedStream.getReader();\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n\n switch (value.type) {\n case 'stream-start': {\n warnings = value.warnings;\n break;\n }\n\n case 'text-delta': {\n content += value.delta;\n render({\n renderer: textRender,\n args: [{ content, done: false, delta: value.delta }],\n streamableUI: ui,\n });\n break;\n }\n\n case 'tool-input-start':\n case 'tool-input-delta': {\n hasToolCall = true;\n break;\n }\n\n case 'tool-call': {\n const toolName = value.toolName as keyof TOOLS & string;\n\n if (!tools) {\n throw new NoSuchToolError({ toolName });\n }\n\n const tool = tools[toolName];\n if (!tool) {\n throw new NoSuchToolError({\n toolName,\n availableTools: Object.keys(tools),\n });\n }\n\n hasToolCall = true;\n const parseResult = await safeParseJSON({\n text: value.input,\n schema: tool.inputSchema,\n });\n\n if (parseResult.success === false) {\n throw new InvalidToolInputError({\n toolName,\n toolInput: value.input,\n cause: parseResult.error,\n });\n }\n\n render({\n renderer: tool.generate,\n args: [\n parseResult.value,\n {\n toolName,\n toolCallId: value.toolCallId,\n },\n ],\n streamableUI: ui,\n isLastCall: true,\n });\n\n break;\n }\n\n case 'error': {\n throw value.error;\n }\n\n case 'finish': {\n finishEvent = {\n finishReason: value.finishReason,\n usage: value.usage,\n warnings,\n response: result.response,\n };\n break;\n }\n }\n }\n\n if (!hasToolCall) {\n render({\n renderer: textRender,\n args: [{ content, done: true }],\n streamableUI: ui,\n isLastCall: true,\n });\n }\n\n await finished;\n\n if (finishEvent && onFinish) {\n await onFinish({\n ...finishEvent,\n value: ui.value,\n });\n }\n } catch (error) {\n // During the stream rendering, we don't want to throw the error to the\n // parent scope but only let the React's error boundary to catch it.\n ui.error(error);\n }\n })();\n\n return {\n ...result,\n stream,\n value: ui.value,\n };\n}\n","export function isAsyncGenerator<T, TReturn, TNext>(\n value: unknown,\n): value is AsyncGenerator<T, TReturn, TNext> {\n return (\n value != null && typeof value === 'object' && Symbol.asyncIterator in value\n );\n}\n","export function isGenerator<T, TReturn, TNext>(\n value: unknown,\n): value is Generator<T, TReturn, TNext> {\n return value != null && typeof value === 'object' && Symbol.iterator in value;\n}\n","/**\n * Warning time for notifying developers that a stream is hanging in dev mode\n * using a console.warn.\n */\nexport const HANGING_STREAM_WARNING_TIME_MS = 15 * 1000;\n","import React, { Suspense } from 'react';\nimport { createResolvablePromise } from '../util/create-resolvable-promise';\n\n// Recursive type for the chunk.\ntype ChunkType =\n | {\n done: false;\n value: React.ReactNode;\n next: Promise<ChunkType>;\n append?: boolean;\n }\n | {\n done: true;\n value: React.ReactNode;\n };\n\n// Use single letter names for the variables to reduce the size of the RSC payload.\n// `R` for `Row`, `c` for `current`, `n` for `next`.\n// Note: Array construction is needed to access the name R.\nconst R = [\n (async ({\n c: current,\n n: next,\n }: {\n c: React.ReactNode;\n n: Promise<ChunkType>;\n }) => {\n const chunk = await next;\n\n if (chunk.done) {\n return chunk.value;\n }\n\n if (chunk.append) {\n return (\n <>\n {current}\n <Suspense fallback={chunk.value}>\n <R c={chunk.value} n={chunk.next} />\n </Suspense>\n </>\n );\n }\n\n return (\n <Suspense fallback={chunk.value}>\n <R c={chunk.value} n={chunk.next} />\n </Suspense>\n );\n }) as unknown as React.FC<{\n c: React.ReactNode;\n n: Promise<ChunkType>;\n }>,\n][0];\n\n/**\n * Creates a suspended chunk for React Server Components.\n *\n * This function generates a suspenseful React component that can be dynamically updated.\n * It's useful for streaming updates to the client in a React Server Components context.\n *\n * @param {React.ReactNode} initialValue - The initial value to render while the promise is pending.\n * @returns {Object} An object containing:\n * - row: A React node that renders the suspenseful content.\n * - resolve: A function to resolve the promise with a new value.\n * - reject: A function to reject the promise with an error.\n */\nexport function createSuspendedChunk(initialValue: React.ReactNode): {\n row: React.ReactNode;\n resolve: (value: ChunkType) => void;\n reject: (error: unknown) => void;\n} {\n const { promise, resolve, reject } = createResolvablePromise<ChunkType>();\n\n return {\n row: (\n <Suspense fallback={initialValue}>\n <R c={initialValue} n={promise} />\n </Suspense>\n ),\n resolve,\n reject,\n };\n}\n","import { HANGING_STREAM_WARNING_TIME_MS } from '../util/constants';\nimport { createResolvablePromise } from '../util/create-resolvable-promise';\nimport { createSuspendedChunk } from './create-suspended-chunk';\n\n// It's necessary to define the type manually here, otherwise TypeScript compiler\n// will not be able to infer the correct return type as it's circular.\ntype StreamableUIWrapper = {\n /**\n * The value of the streamable UI. This can be returned from a Server Action and received by the client.\n */\n readonly value: React.ReactNode;\n\n /**\n * This method updates the current UI node. It takes a new UI node and replaces the old one.\n */\n update(value: React.ReactNode): StreamableUIWrapper;\n\n /**\n * This method is used to append a new UI node to the end of the old one.\n * Once appended a new UI node, the previous UI node cannot be updated anymore.\n *\n * @example\n * ```jsx\n * const ui = createStreamableUI(<div>hello</div>)\n * ui.append(<div>world</div>)\n *\n * // The UI node will be:\n * // <>\n * // <div>hello</div>\n * // <div>world</div>\n * // </>\n * ```\n */\n append(value: React.ReactNode): StreamableUIWrapper;\n\n /**\n * This method is used to signal that there is an error in the UI stream.\n * It will be thrown on the client side and caught by the nearest error boundary component.\n */\n error(error: any): StreamableUIWrapper;\n\n /**\n * This method marks the UI node as finalized. You can either call it without any parameters or with a new UI node as the final state.\n * Once called, the UI node cannot be updated or appended anymore.\n *\n * This method is always **required** to be called, otherwise the response will be stuck in a loading state.\n */\n done(...args: [React.ReactNode] | []): StreamableUIWrapper;\n};\n\n/**\n * Create a piece of changeable UI that can be streamed to the client.\n * On the client side, it can be rendered as a normal React node.\n */\nfunction createStreamableUI(initialValue?: React.ReactNode) {\n let currentValue = initialValue;\n let closed = false;\n let { row, resolve, reject } = createSuspendedChunk(initialValue);\n\n function assertStream(method: string) {\n if (closed) {\n throw new Error(method + ': UI stream is already closed.');\n }\n }\n\n let warningTimeout: NodeJS.Timeout | undefined;\n function warnUnclosedStream() {\n if (process.env.NODE_ENV === 'development') {\n if (warningTimeout) {\n clearTimeout(warningTimeout);\n }\n warningTimeout = setTimeout(() => {\n console.warn(\n 'The streamable UI has been slow to update. This may be a bug or a performance issue or you forgot to call `.done()`.',\n );\n }, HANGING_STREAM_WARNING_TIME_MS);\n }\n }\n warnUnclosedStream();\n\n const streamable: StreamableUIWrapper = {\n value: row,\n update(value: React.ReactNode) {\n assertStream('.update()');\n\n // There is no need to update the value if it's referentially equal.\n if (value === currentValue) {\n warnUnclosedStream();\n return streamable;\n }\n\n const resolvable = createResolvablePromise();\n currentValue = value;\n\n resolve({ value: currentValue, done: false, next: resolvable.promise });\n resolve = resolvable.resolve;\n reject = resolvable.reject;\n\n warnUnclosedStream();\n\n return streamable;\n },\n append(value: React.ReactNode) {\n assertStream('.append()');\n\n const resolvable = createResolvablePromise();\n currentValue = value;\n\n resolve({ value, done: false, append: true, next: resolvable.promise });\n resolve = resolvable.resolve;\n reject = resolvable.reject;\n\n warnUnclosedStream();\n\n return streamable;\n },\n error(error: any) {\n assertStream('.error()');\n\n if (warningTimeout) {\n clearTimeout(warningTimeout);\n }\n closed = true;\n reject(error);\n\n return streamable;\n },\n done(...args: [] | [React.ReactNode]) {\n assertStream('.done()');\n\n if (warningTimeout) {\n clearTimeout(warningTimeout);\n }\n closed = true;\n if (args.length) {\n resolve({ value: args[0], done: true });\n return streamable;\n }\n resolve({ value: currentValue, done: true });\n\n return streamable;\n },\n };\n\n return streamable;\n}\n\nexport { createStreamableUI };\n","export const STREAMABLE_VALUE_TYPE = Symbol.for('ui.streamable.value');\n\nexport type StreamablePatch = undefined | [0, string]; // Append string.\n\ndeclare const __internal_curr: unique symbol;\ndeclare const __internal_error: unique symbol;\n\n/**\n * StreamableValue is a value that can be streamed over the network via AI Actions.\n * To read the streamed values, use the `readStreamableValue` or `useStreamableValue` APIs.\n */\nexport type StreamableValue<T = any, E = any> = {\n /**\n * @internal Use `readStreamableValue` to read the values.\n */\n type?: typeof STREAMABLE_VALUE_TYPE;\n /**\n * @internal Use `readStreamableValue` to read the values.\n */\n curr?: T;\n /**\n * @internal Use `readStreamableValue` to read the values.\n */\n error?: E;\n /**\n * @internal Use `readStreamableValue` to read the values.\n */\n diff?: StreamablePatch;\n /**\n * @internal Use `readStreamableValue` to read the values.\n */\n next?: Promise<StreamableValue<T, E>>;\n\n // branded types to maintain type signature after internal properties are stripped.\n [__internal_curr]?: T;\n [__internal_error]?: E;\n};\n","import { HANGING_STREAM_WARNING_TIME_MS } from '../util/constants';\nimport { createResolvablePromise } from '../util/create-resolvable-promise';\nimport {\n STREAMABLE_VALUE_TYPE,\n StreamablePatch,\n StreamableValue,\n} from './streamable-value';\n\nconst STREAMABLE_VALUE_INTERNAL_LOCK = Symbol('streamable.value.lock');\n\n/**\n * Create a wrapped, changeable value that can be streamed to the client.\n * On the client side, the value can be accessed via the readStreamableValue() API.\n */\nfunction createStreamableValue<T = any, E = any>(\n initialValue?: T | ReadableStream<T>,\n) {\n const isReadableStream =\n initialValue instanceof ReadableStream ||\n (typeof initialValue === 'object' &&\n initialValue !== null &&\n 'getReader' in initialValue &&\n typeof initialValue.getReader === 'function' &&\n 'locked' in initialValue &&\n typeof initialValue.locked === 'boolean');\n\n if (!isReadableStream) {\n return createStreamableValueImpl<T, E>(initialValue);\n }\n\n const streamableValue = createStreamableValueImpl<T, E>();\n\n // Since the streamable value will be from a readable stream, it's not allowed\n // to update the value manually as that introduces race conditions and\n // unexpected behavior.\n // We lock the value to prevent any updates from the user.\n streamableValue[STREAMABLE_VALUE_INTERNAL_LOCK] = true;\n\n (async () => {\n try {\n // Consume the readable stream and update the value.\n const reader = initialValue.getReader();\n\n while (true) {\n const { value, done } = await reader.read();\n if (done) {\n break;\n }\n\n // Unlock the value to allow updates.\n streamableValue[STREAMABLE_VALUE_INTERNAL_LOCK] = false;\n if (typeof value === 'string') {\n streamableValue.append(value);\n } else {\n streamableValue.update(value);\n }\n // Lock the value again.\n streamableValue[STREAMABLE_VALUE_INTERNAL_LOCK] = true;\n }\n\n streamableValue[STREAMABLE_VALUE_INTERNAL_LOCK] = false;\n streamableValue.done();\n } catch (e) {\n streamableValue[STREAMABLE_VALUE_INTERNAL_LOCK] = false;\n streamableValue.error(e);\n }\n })();\n\n return streamableValue;\n}\n\n// It's necessary to define the type manually here, otherwise TypeScript compiler\n// will not be able to infer the correct return type as it's circular.\ntype StreamableValueWrapper<T, E> = {\n /**\n * The value of the streamable. This can be returned from a Server Action and\n * received by the client. To read the streamed values, use the\n * `readStreamableValue` or `useStreamableValue` APIs.\n */\n readonly value: StreamableValue<T, E>;\n\n /**\n * This method updates the current value with a new one.\n */\n update(value: T): StreamableValueWrapper<T, E>;\n\n /**\n * This method is used to append a delta string to the current value. It\n * requires the current value of the streamable to be a string.\n *\n * @example\n * ```jsx\n * const streamable = createStreamableValue('hello');\n * streamable.append(' world');\n *\n * // The value will be 'hello world'\n * ```\n */\n append(value: T): StreamableValueWrapper<T, E>;\n\n /**\n * This method is used to signal that there is an error in the value stream.\n * It will be thrown on the client side when consumed via\n * `readStreamableValue` or `useStreamableValue`.\n */\n error(error: any): StreamableValueWrapper<T, E>;\n\n /**\n * This method marks the value as finalized. You can either call it without\n * any parameters or with a new value as the final state.\n * Once called, the value cannot be updated or appended anymore.\n *\n * This method is always **required** to be called, otherwise the response\n * will be stuck in a loading state.\n */\n done(...args: [T] | []): StreamableValueWrapper<T, E>;\n\n /**\n * @internal This is an internal lock to prevent the value from being\n * updated by the user.\n */\n [STREAMABLE_VALUE_INTERNAL_LOCK]: boolean;\n};\n\nfunction createStreamableValueImpl<T = any, E = any>(initialValue?: T) {\n let closed = false;\n let locked = false;\n let resolvable = createResolvablePromise<StreamableValue<T, E>>();\n\n let currentValue = initialValue;\n let currentError: E | undefined;\n let currentPromise: typeof resolvable.promise | undefined =\n resolvable.promise;\n let currentPatchValue: StreamablePatch;\n\n function assertStream(method: string) {\n if (closed) {\n throw new Error(method + ': Value stream is already closed.');\n }\n if (locked) {\n throw new Error(\n method + ': Value stream is locked and cannot be updated.',\n );\n }\n }\n\n let warningTimeout: NodeJS.Timeout | undefined;\n function warnUnclosedStream() {\n if (process.env.NODE_ENV === 'development') {\n if (warningTimeout) {\n clearTimeout(warningTimeout);\n }\n warningTimeout = setTimeout(() => {\n console.warn(\n 'The streamable value has been slow to update. This may be a bug or a performance issue or you forgot to call `.done()`.',\n );\n }, HANGING_STREAM_WARNING_TIME_MS);\n }\n }\n warnUnclosedStream();\n\n function createWrapped(initialChunk?: boolean): StreamableValue<T, E> {\n // This makes the payload much smaller if there're mutative updates before the first read.\n let init: Partial<StreamableValue<T, E>>;\n\n if (currentError !== undefined) {\n init = { error: currentError };\n } else {\n if (currentPatchValue && !initialChunk) {\n init = { diff: currentPatchValue };\n } else {\n init = { curr: currentValue };\n }\n }\n\n if (currentPromise) {\n init.next = currentPromise;\n }\n\n if (initialChunk) {\n init.type = STREAMABLE_VALUE_TYPE;\n }\n\n return init;\n }\n\n // Update the internal `currentValue` and `currentPatchValue` if needed.\n function updateValueStates(value: T) {\n // If we can only send a patch over the wire, it's better to do so.\n currentPatchValue = undefined;\n if (typeof value === 'string') {\n if (typeof currentValue === 'string') {\n if (value.startsWith(currentValue)) {\n currentPatchValue = [0, value.slice(currentValue.length)];\n }\n }\n }\n\n currentValue = value;\n }\n\n const streamable: StreamableValueWrapper<T, E> = {\n set [STREAMABLE_VALUE_INTERNAL_LOCK](state: boolean) {\n locked = state;\n },\n get value() {\n return createWrapped(true);\n },\n update(value: T) {\n assertStream('.update()');\n\n const resolvePrevious = resolvable.resolve;\n resolvable = createResolvablePromise();\n\n updateValueStates(value);\n currentPromise = resolvable.promise;\n resolvePrevious(createWrapped());\n\n warnUnclosedStream();\n\n return streamable;\n },\n append(value: T) {\n assertStream('.append()');\n\n if (\n typeof currentValue !== 'string' &&\n typeof currentValue !== 'undefined'\n ) {\n throw new Error(\n `.append(): The current value is not a string. Received: ${typeof currentValue}`,\n );\n }\n if (typeof value !== 'string') {\n throw new Error(\n `.append(): The value is not a string. Received: ${typeof value}`,\n );\n }\n\n const resolvePrevious = resolvable.resolve;\n resolvable = createResolvablePromise();\n\n if (typeof currentValue === 'string') {\n currentPatchValue = [0, value];\n (currentValue as string) = currentValue + value;\n } else {\n currentPatchValue = undefined;\n currentValue = value;\n }\n\n currentPromise = resolvable.promise;\n resolvePrevious(createWrapped());\n\n warnUnclosedStream();\n\n return streamable;\n },\n error(error: any) {\n assertStream('.error()');\n\n if (warningTimeout) {\n clearTimeout(warningTimeout);\n }\n closed = true;\n currentError = error;\n currentPromise = undefined;\n\n resolvable.resolve({ error });\n\n return streamable;\n },\n done(...args: [] | [T]) {\n assertStream('.done()');\n\n if (warningTimeout) {\n clearTimeout(warningTimeout);\n }\n closed = true;\n currentPromise = undefined;\n\n if (args.length) {\n updateValueStates(args[0]);\n resolvable.resolve(createWrapped());\n return streamable;\n }\n\n resolvable.resolve({});\n\n return streamable;\n },\n };\n\n return streamable;\n}\n\nexport { createStreamableValue };\n"],"mappings":";AAAA,YAAY,mBAAmB;AAC/B,SAAS,yBAAyB;;;ACQ3B,SAAS,0BAId;AACA,MAAI;AACJ,MAAI;AAEJ,QAAM,UAAU,IAAI,QAAW,CAAC,KAAK,QAAQ;AAC3C,cAAU;AACV,aAAS;AAAA,EACX,CAAC;AAED,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;;;ACrBO,IAAM,aAAa,CAAC,UACzB,OAAO,UAAU;;;AFOnB,I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,EAAE,MAAM,CAAC;AAE5B,aAAO;AAAA,IACT;AAAA,IACA,QAAQ,MAAgB;AACtB,mBAAa,SAAS;AAEtB,UAAI,gBAAgB;AAClB,qBAAa,cAAc;AAAA,MAC7B;AACA,eAAS;AACT,uBAAiB;AAEjB,UAAI,KAAK,QAAQ;AACf,0BAAkB,KAAK,CAAC,CAAC;AACzB,mBAAW,QAAQ,cAAc,CAAC;AAClC,eAAO;AAAA,MACT;AAEA,iBAAW,QAAQ,CAAC,CAAC;AAErB,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;","names":["jsx"]}
1
+ {"version":3,"sources":["../src/ai-state.tsx","../src/util/create-resolvable-promise.ts","../src/util/is-function.ts","../src/provider.tsx","../src/stream-ui/stream-ui.tsx","../src/util/constants.ts","../src/streamable-ui/create-suspended-chunk.tsx","../src/streamable-ui/create-streamable-ui.tsx","../src/util/is-async-generator.ts","../src/util/is-generator.ts","../src/streamable-value/streamable-value.ts","../src/streamable-value/create-streamable-value.ts"],"sourcesContent":["import * as jsondiffpatch from 'jsondiffpatch';\nimport { AsyncLocalStorage } from 'node:async_hooks';\nimport { createResolvablePromise } from './util/create-resolvable-promise';\nimport { isFunction } from './util/is-function';\nimport type {\n AIProvider,\n InferAIState,\n InternalAIStateStorageOptions,\n MutableAIState,\n ValueOrUpdater,\n} from './types';\n\n// It is possible that multiple AI requests get in concurrently, for different\n// AI instances. So ALS is necessary here for a simpler API.\nconst asyncAIStateStorage = new AsyncLocalStorage<{\n currentState: any;\n originalState: any;\n sealed: boolean;\n options: InternalAIStateStorageOptions;\n mutationDeltaPromise?: Promise<any>;\n mutationDeltaResolve?: (v: any) => void;\n}>();\n\nfunction getAIStateStoreOrThrow(message: string) {\n const store = asyncAIStateStorage.getStore();\n if (!store) {\n throw new Error(message);\n }\n return store;\n}\n\nexport function withAIState<S, T>(\n { state, options }: { state: S; options: InternalAIStateStorageOptions },\n fn: () => T,\n): T {\n return asyncAIStateStorage.run(\n {\n currentState: JSON.parse(JSON.stringify(state)), // deep clone object\n originalState: state,\n sealed: false,\n options,\n },\n fn,\n );\n}\n\nexport function getAIStateDeltaPromise() {\n const store = getAIStateStoreOrThrow('Internal error occurred.');\n return store.mutationDeltaPromise;\n}\n\n// Internal method. This will be called after the AI Action has been returned\n// and you can no longer call `getMutableAIState()` inside any async callbacks\n// created by that Action.\nexport function sealMutableAIState() {\n const store = getAIStateStoreOrThrow('Internal error occurred.');\n store.sealed = true;\n}\n\n/**\n * Get the current AI state.\n * If `key` is provided, it will return the value of the specified key in the\n * AI state, if it's an object. If it's not an object, it will throw an error.\n *\n * @example const state = getAIState() // Get the entire AI state\n * @example const field = getAIState('key') // Get the value of the key\n */\nfunction getAIState<AI extends AIProvider = any>(): Readonly<\n InferAIState<AI, any>\n>;\nfunction getAIState<AI extends AIProvider = any>(\n key: keyof InferAIState<AI, any>,\n): Readonly<InferAIState<AI, any>[typeof key]>;\nfunction getAIState<AI extends AIProvider = any>(\n ...args: [] | [key: keyof InferAIState<AI, any>]\n) {\n const store = getAIStateStoreOrThrow(\n '`getAIState` must be called within an AI Action.',\n );\n\n if (args.length > 0) {\n const key = args[0];\n if (typeof store.currentState !== 'object') {\n throw new Error(\n `You can't get the \"${String(\n key,\n )}\" field from the AI state because it's not an object.`,\n );\n }\n return store.currentState[key as keyof typeof store.currentState];\n }\n\n return store.currentState;\n}\n\n/**\n * Get the mutable AI state. Note that you must call `.done()` when finishing\n * updating the AI state.\n *\n * @example\n * ```tsx\n * const state = getMutableAIState()\n * state.update({ ...state.get(), key: 'value' })\n * state.update((currentState) => ({ ...currentState, key: 'value' }))\n * state.done()\n * ```\n *\n * @example\n * ```tsx\n * const state = getMutableAIState()\n * state.done({ ...state.get(), key: 'value' }) // Done with a new state\n * ```\n */\nfunction getMutableAIState<AI extends AIProvider = any>(): MutableAIState<\n InferAIState<AI, any>\n>;\nfunction getMutableAIState<AI extends AIProvider = any>(\n key: keyof InferAIState<AI, any>,\n): MutableAIState<InferAIState<AI, any>[typeof key]>;\nfunction getMutableAIState<AI extends AIProvider = any>(\n ...args: [] | [key: keyof InferAIState<AI, any>]\n) {\n type AIState = InferAIState<AI, any>;\n type AIStateWithKey = typeof args extends [key: keyof AIState]\n ? AIState[(typeof args)[0]]\n : AIState;\n type NewStateOrUpdater = ValueOrUpdater<AIStateWithKey>;\n\n const store = getAIStateStoreOrThrow(\n '`getMutableAIState` must be called within an AI Action.',\n );\n\n if (store.sealed) {\n throw new Error(\n \"`getMutableAIState` must be called before returning from an AI Action. Please move it to the top level of the Action's function body.\",\n );\n }\n\n if (!store.mutationDeltaPromise) {\n const { promise, resolve } = createResolvablePromise();\n store.mutationDeltaPromise = promise;\n store.mutationDeltaResolve = resolve;\n }\n\n function doUpdate(newState: NewStateOrUpdater, done: boolean) {\n if (args.length > 0) {\n if (typeof store.currentState !== 'object') {\n const key = args[0];\n throw new Error(\n `You can't modify the \"${String(\n key,\n )}\" field of the AI state because it's not an object.`,\n );\n }\n }\n\n if (isFunction(newState)) {\n if (args.length > 0) {\n store.currentState[args[0]] = newState(store.currentState[args[0]]);\n } else {\n store.currentState = newState(store.currentState);\n }\n } else {\n if (args.length > 0) {\n store.currentState[args[0]] = newState;\n } else {\n store.currentState = newState;\n }\n }\n\n store.options.onSetAIState?.({\n key: args.length > 0 ? args[0] : undefined,\n state: store.currentState,\n done,\n });\n }\n\n const mutableState = {\n get: () => {\n if (args.length > 0) {\n const key = args[0];\n if (typeof store.currentState !== 'object') {\n throw new Error(\n `You can't get the \"${String(\n key,\n )}\" field from the AI state because it's not an object.`,\n );\n }\n return store.currentState[key] as Readonly<AIStateWithKey>;\n }\n\n return store.currentState as Readonly<AIState>;\n },\n update: function update(newAIState: NewStateOrUpdater) {\n doUpdate(newAIState, false);\n },\n done: function done(...doneArgs: [] | [NewStateOrUpdater]) {\n if (doneArgs.length > 0) {\n doUpdate(doneArgs[0] as NewStateOrUpdater, true);\n }\n\n const delta = jsondiffpatch.diff(store.originalState, store.currentState);\n store.mutationDeltaResolve!(delta);\n },\n };\n\n return mutableState;\n}\n\nexport { getAIState, getMutableAIState };\n","/**\n * Creates a Promise with externally accessible resolve and reject functions.\n *\n * @template T - The type of the value that the Promise will resolve to.\n * @returns An object containing:\n * - promise: A Promise that can be resolved or rejected externally.\n * - resolve: A function to resolve the Promise with a value of type T.\n * - reject: A function to reject the Promise with an error.\n */\nexport function createResolvablePromise<T = any>(): {\n promise: Promise<T>;\n resolve: (value: T) => void;\n reject: (error: unknown) => void;\n} {\n let resolve: (value: T) => void;\n let reject: (error: unknown) => void;\n\n const promise = new Promise<T>((res, rej) => {\n resolve = res;\n reject = rej;\n });\n\n return {\n promise,\n resolve: resolve!,\n reject: reject!,\n };\n}\n","/**\n * Checks if the given value is a function.\n *\n * @param {unknown} value - The value to check.\n * @returns {boolean} True if the value is a function, false otherwise.\n */\nexport const isFunction = (value: unknown): value is Function =>\n typeof value === 'function';\n","// This file provides the AI context to all AI Actions via AsyncLocalStorage.\n\nimport * as React from 'react';\nimport { InternalAIProvider } from './rsc-shared.mjs';\nimport {\n withAIState,\n getAIStateDeltaPromise,\n sealMutableAIState,\n} from './ai-state';\nimport type {\n ServerWrappedActions,\n AIAction,\n AIActions,\n AIProvider,\n InternalAIStateStorageOptions,\n OnSetAIState,\n OnGetUIState,\n} from './types';\n\nasync function innerAction<T>(\n {\n action,\n options,\n }: { action: AIAction; options: InternalAIStateStorageOptions },\n state: T,\n ...args: unknown[]\n) {\n 'use server';\n return await withAIState(\n {\n state,\n options,\n },\n async () => {\n const result = await action(...args);\n sealMutableAIState();\n return [getAIStateDeltaPromise() as Promise<T>, result];\n },\n );\n}\n\nfunction wrapAction<T = unknown>(\n action: AIAction,\n options: InternalAIStateStorageOptions,\n) {\n return innerAction.bind(null, { action, options }) as AIAction<T>;\n}\n\nexport function createAI<\n AIState = any,\n UIState = any,\n Actions extends AIActions = {},\n>({\n actions,\n initialAIState,\n initialUIState,\n\n onSetAIState,\n onGetUIState,\n}: {\n actions: Actions;\n initialAIState?: AIState;\n initialUIState?: UIState;\n\n /**\n * This function is called whenever the AI state is updated by an Action.\n * You can use this to persist the AI state to a database, or to send it to a\n * logging service.\n */\n onSetAIState?: OnSetAIState<AIState>;\n\n /**\n * This function is used to retrieve the UI state based on the AI state.\n * For example, to render the initial UI state based on a given AI state, or\n * to sync the UI state when the application is already loaded.\n *\n * If returning `undefined`, the client side UI state will not be updated.\n *\n * This function must be annotated with the `\"use server\"` directive.\n *\n * @example\n * ```tsx\n * onGetUIState: async () => {\n * 'use server';\n *\n * const currentAIState = getAIState();\n * const externalAIState = await loadAIStateFromDatabase();\n *\n * if (currentAIState === externalAIState) return undefined;\n *\n * // Update current AI state and return the new UI state\n * const state = getMutableAIState()\n * state.done(externalAIState)\n *\n * return <div>...</div>;\n * }\n * ```\n */\n onGetUIState?: OnGetUIState<UIState>;\n}) {\n // Wrap all actions with our HoC.\n const wrappedActions: ServerWrappedActions = {};\n for (const name in actions) {\n wrappedActions[name] = wrapAction(actions[name], {\n onSetAIState,\n });\n }\n\n const wrappedSyncUIState = onGetUIState\n ? wrapAction(onGetUIState, {})\n : undefined;\n\n const AI: AIProvider<AIState, UIState, Actions> = async props => {\n if ('useState' in React) {\n // This file must be running on the React Server layer.\n // Ideally we should be using `import \"server-only\"` here but we can have a\n // more customized error message with this implementation.\n throw new Error(\n 'This component can only be used inside Server Components.',\n );\n }\n\n let uiState = props.initialUIState ?? initialUIState;\n let aiState = props.initialAIState ?? initialAIState;\n let aiStateDelta = undefined;\n\n if (wrappedSyncUIState) {\n const [newAIStateDelta, newUIState] = await wrappedSyncUIState(aiState);\n if (newUIState !== undefined) {\n aiStateDelta = newAIStateDelta;\n uiState = newUIState;\n }\n }\n\n return (\n <InternalAIProvider\n wrappedActions={wrappedActions}\n wrappedSyncUIState={wrappedSyncUIState}\n initialUIState={uiState}\n initialAIState={aiState}\n initialAIStatePatch={aiStateDelta}\n >\n {props.children}\n </InternalAIProvider>\n );\n };\n\n return AI;\n}\n","import {\n LanguageModelV3,\n LanguageModelV3StreamResult,\n LanguageModelV3Usage,\n SharedV3Warning,\n} from '@ai-sdk/provider';\nimport {\n InferSchema,\n ProviderOptions,\n safeParseJSON,\n} from '@ai-sdk/provider-utils';\nimport {\n CallSettings,\n CallWarning,\n FinishReason,\n InvalidToolInputError,\n LanguageModelUsage,\n NoSuchToolError,\n Prompt,\n Schema,\n ToolChoice,\n} from 'ai';\nimport {\n asLanguageModelUsage,\n convertToLanguageModelPrompt,\n prepareCallSettings,\n prepareRetries,\n prepareToolsAndToolChoice,\n standardizePrompt,\n} from 'ai/internal';\nimport { ReactNode } from 'react';\nimport * as z3 from 'zod/v3';\nimport * as z4 from 'zod/v4';\nimport { createStreamableUI } from '../streamable-ui/create-streamable-ui';\nimport { createResolvablePromise } from '../util/create-resolvable-promise';\nimport { isAsyncGenerator } from '../util/is-async-generator';\nimport { isGenerator } from '../util/is-generator';\n\ntype Streamable = ReactNode | Promise<ReactNode>;\n\ntype Renderer<T extends Array<any>> = (\n ...args: T\n) =>\n | Streamable\n | Generator<Streamable, Streamable, void>\n | AsyncGenerator<Streamable, Streamable, void>;\n\ntype RenderTool<\n INPUT_SCHEMA extends z4.core.$ZodType | z3.Schema | Schema = any,\n> = {\n description?: string;\n inputSchema: INPUT_SCHEMA;\n generate?: Renderer<\n [\n InferSchema<INPUT_SCHEMA>,\n {\n toolName: string;\n toolCallId: string;\n },\n ]\n >;\n};\n\ntype RenderText = Renderer<\n [\n {\n /**\n * The full text content from the model so far.\n */\n content: string;\n\n /**\n * The new appended text content from the model since the last `text` call.\n */\n delta: string;\n\n /**\n * Whether the model is done generating text.\n * If `true`, the `content` will be the final output and this call will be the last.\n */\n done: boolean;\n },\n ]\n>;\n\ntype RenderResult = {\n value: ReactNode;\n} & LanguageModelV3StreamResult;\n\nconst defaultTextRenderer: RenderText = ({ content }: { content: string }) =>\n content;\n\n/**\n * `streamUI` is a helper function to create a streamable UI from LLMs.\n */\nexport async function streamUI<\n TOOLS extends { [name: string]: z4.core.$ZodType | z3.Schema | Schema } = {},\n>({\n model,\n tools,\n toolChoice,\n system,\n prompt,\n messages,\n maxRetries,\n abortSignal,\n headers,\n initial,\n text,\n providerOptions,\n onFinish,\n ...settings\n}: CallSettings &\n Prompt & {\n /**\n * The language model to use.\n */\n model: LanguageModelV3;\n\n /**\n * The tools that the model can call. The model needs to support calling tools.\n */\n tools?: {\n [name in keyof TOOLS]: RenderTool<TOOLS[name]>;\n };\n\n /**\n * The tool choice strategy. Default: 'auto'.\n */\n toolChoice?: ToolChoice<TOOLS>;\n\n text?: RenderText;\n initial?: ReactNode;\n\n /**\nAdditional provider-specific options. They are passed through\nto the provider from the AI SDK and enable provider-specific\nfunctionality that can be fully encapsulated in the provider.\n */\n providerOptions?: ProviderOptions;\n\n /**\n * Callback that is called when the LLM response and the final object validation are finished.\n */\n onFinish?: (event: {\n /**\n * The reason why the generation finished.\n */\n finishReason: FinishReason;\n /**\n * The token usage of the generated response.\n */\n usage: LanguageModelUsage;\n /**\n * The final ui node that was generated.\n */\n value: ReactNode;\n /**\n * Warnings from the model provider (e.g. unsupported settings)\n */\n warnings?: CallWarning[];\n /**\n * Optional response data.\n */\n response?: {\n /**\n * Response headers.\n */\n headers?: Record<string, string>;\n };\n }) => Promise<void> | void;\n }): Promise<RenderResult> {\n // TODO: Remove these errors after the experimental phase.\n if (typeof model === 'string') {\n throw new Error(\n '`model` cannot be a string in `streamUI`. Use the actual model instance instead.',\n );\n }\n if ('functions' in settings) {\n throw new Error(\n '`functions` is not supported in `streamUI`, use `tools` instead.',\n );\n }\n if ('provider' in settings) {\n throw new Error(\n '`provider` is no longer needed in `streamUI`. Use `model` instead.',\n );\n }\n if (tools) {\n for (const [name, tool] of Object.entries(tools)) {\n if ('render' in tool) {\n throw new Error(\n 'Tool definition in `streamUI` should not have `render` property. Use `generate` instead. Found in tool: ' +\n name,\n );\n }\n }\n }\n\n const ui = createStreamableUI(initial);\n\n // The default text renderer just returns the content as string.\n const textRender = text || defaultTextRenderer;\n\n let finished: Promise<void> | undefined;\n\n let finishEvent: {\n finishReason: FinishReason;\n usage: LanguageModelV3Usage;\n warnings?: CallWarning[];\n response?: {\n headers?: Record<string, string>;\n };\n } | null = null;\n\n async function render({\n args,\n renderer,\n streamableUI,\n isLastCall = false,\n }: {\n renderer: undefined | Renderer<any>;\n args: [payload: any] | [payload: any, options: any];\n streamableUI: ReturnType<typeof createStreamableUI>;\n isLastCall?: boolean;\n }) {\n if (!renderer) return;\n\n // create a promise that will be resolved when the render call is finished.\n // it is appended to the `finished` promise chain to ensure the render call\n // is finished before the next render call starts.\n const renderFinished = createResolvablePromise<void>();\n finished = finished\n ? finished.then(() => renderFinished.promise)\n : renderFinished.promise;\n\n const rendererResult = renderer(...args);\n\n if (isAsyncGenerator(rendererResult) || isGenerator(rendererResult)) {\n while (true) {\n const { done, value } = await rendererResult.next();\n const node = await value;\n\n if (isLastCall && done) {\n streamableUI.done(node);\n } else {\n streamableUI.update(node);\n }\n\n if (done) break;\n }\n } else {\n const node = await rendererResult;\n\n if (isLastCall) {\n streamableUI.done(node);\n } else {\n streamableUI.update(node);\n }\n }\n\n // resolve the promise to signal that the render call is finished\n renderFinished.resolve(undefined);\n }\n\n const { retry } = prepareRetries({ maxRetries, abortSignal });\n\n const validatedPrompt = await standardizePrompt({\n system,\n prompt,\n messages,\n } as Prompt);\n const result = await retry(async () =>\n model.doStream({\n ...prepareCallSettings(settings),\n ...prepareToolsAndToolChoice({\n tools: tools as any,\n toolChoice,\n activeTools: undefined,\n }),\n prompt: await convertToLanguageModelPrompt({\n prompt: validatedPrompt,\n supportedUrls: await model.supportedUrls,\n download: undefined,\n }),\n providerOptions,\n abortSignal,\n headers,\n includeRawChunks: false,\n }),\n );\n\n // For the stream and consume it asynchronously:\n const [stream, forkedStream] = result.stream.tee();\n (async () => {\n try {\n let content = '';\n let hasToolCall = false;\n let warnings: SharedV3Warning[] | undefined;\n\n const reader = forkedStream.getReader();\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n\n switch (value.type) {\n case 'stream-start': {\n warnings = value.warnings;\n break;\n }\n\n case 'text-delta': {\n content += value.delta;\n render({\n renderer: textRender,\n args: [{ content, done: false, delta: value.delta }],\n streamableUI: ui,\n });\n break;\n }\n\n case 'tool-input-start':\n case 'tool-input-delta': {\n hasToolCall = true;\n break;\n }\n\n case 'tool-call': {\n const toolName = value.toolName as keyof TOOLS & string;\n\n if (!tools) {\n throw new NoSuchToolError({ toolName });\n }\n\n const tool = tools[toolName];\n if (!tool) {\n throw new NoSuchToolError({\n toolName,\n availableTools: Object.keys(tools),\n });\n }\n\n hasToolCall = true;\n const parseResult = await safeParseJSON({\n text: value.input,\n schema: tool.inputSchema,\n });\n\n if (parseResult.success === false) {\n throw new InvalidToolInputError({\n toolName,\n toolInput: value.input,\n cause: parseResult.error,\n });\n }\n\n render({\n renderer: tool.generate,\n args: [\n parseResult.value,\n {\n toolName,\n toolCallId: value.toolCallId,\n },\n ],\n streamableUI: ui,\n isLastCall: true,\n });\n\n break;\n }\n\n case 'error': {\n throw value.error;\n }\n\n case 'finish': {\n finishEvent = {\n finishReason: value.finishReason?.unified,\n usage: value.usage,\n warnings,\n response: result.response,\n };\n break;\n }\n }\n }\n\n if (!hasToolCall) {\n render({\n renderer: textRender,\n args: [{ content, done: true }],\n streamableUI: ui,\n isLastCall: true,\n });\n }\n\n await finished;\n\n if (finishEvent && onFinish) {\n await onFinish({\n ...finishEvent,\n usage: asLanguageModelUsage(finishEvent.usage),\n value: ui.value,\n });\n }\n } catch (error) {\n // During the stream rendering, we don't want to throw the error to the\n // parent scope but only let the React's error boundary to catch it.\n ui.error(error);\n }\n })();\n\n return {\n ...result,\n stream,\n value: ui.value,\n };\n}\n","/**\n * Warning time for notifying developers that a stream is hanging in dev mode\n * using a console.warn.\n */\nexport const HANGING_STREAM_WARNING_TIME_MS = 15 * 1000;\n","import React, { Suspense } from 'react';\nimport { createResolvablePromise } from '../util/create-resolvable-promise';\n\n// Recursive type for the chunk.\ntype ChunkType =\n | {\n done: false;\n value: React.ReactNode;\n next: Promise<ChunkType>;\n append?: boolean;\n }\n | {\n done: true;\n value: React.ReactNode;\n };\n\n// Use single letter names for the variables to reduce the size of the RSC payload.\n// `R` for `Row`, `c` for `current`, `n` for `next`.\n// Note: Array construction is needed to access the name R.\nconst R = [\n (async ({\n c: current,\n n: next,\n }: {\n c: React.ReactNode;\n n: Promise<ChunkType>;\n }) => {\n const chunk = await next;\n\n if (chunk.done) {\n return chunk.value;\n }\n\n if (chunk.append) {\n return (\n <>\n {current}\n <Suspense fallback={chunk.value}>\n <R c={chunk.value} n={chunk.next} />\n </Suspense>\n </>\n );\n }\n\n return (\n <Suspense fallback={chunk.value}>\n <R c={chunk.value} n={chunk.next} />\n </Suspense>\n );\n }) as unknown as React.FC<{\n c: React.ReactNode;\n n: Promise<ChunkType>;\n }>,\n][0];\n\n/**\n * Creates a suspended chunk for React Server Components.\n *\n * This function generates a suspenseful React component that can be dynamically updated.\n * It's useful for streaming updates to the client in a React Server Components context.\n *\n * @param {React.ReactNode} initialValue - The initial value to render while the promise is pending.\n * @returns {Object} An object containing:\n * - row: A React node that renders the suspenseful content.\n * - resolve: A function to resolve the promise with a new value.\n * - reject: A function to reject the promise with an error.\n */\nexport function createSuspendedChunk(initialValue: React.ReactNode): {\n row: React.ReactNode;\n resolve: (value: ChunkType) => void;\n reject: (error: unknown) => void;\n} {\n const { promise, resolve, reject } = createResolvablePromise<ChunkType>();\n\n return {\n row: (\n <Suspense fallback={initialValue}>\n <R c={initialValue} n={promise} />\n </Suspense>\n ),\n resolve,\n reject,\n };\n}\n","import { HANGING_STREAM_WARNING_TIME_MS } from '../util/constants';\nimport { createResolvablePromise } from '../util/create-resolvable-promise';\nimport { createSuspendedChunk } from './create-suspended-chunk';\n\n// It's necessary to define the type manually here, otherwise TypeScript compiler\n// will not be able to infer the correct return type as it's circular.\ntype StreamableUIWrapper = {\n /**\n * The value of the streamable UI. This can be returned from a Server Action and received by the client.\n */\n readonly value: React.ReactNode;\n\n /**\n * This method updates the current UI node. It takes a new UI node and replaces the old one.\n */\n update(value: React.ReactNode): StreamableUIWrapper;\n\n /**\n * This method is used to append a new UI node to the end of the old one.\n * Once appended a new UI node, the previous UI node cannot be updated anymore.\n *\n * @example\n * ```jsx\n * const ui = createStreamableUI(<div>hello</div>)\n * ui.append(<div>world</div>)\n *\n * // The UI node will be:\n * // <>\n * // <div>hello</div>\n * // <div>world</div>\n * // </>\n * ```\n */\n append(value: React.ReactNode): StreamableUIWrapper;\n\n /**\n * This method is used to signal that there is an error in the UI stream.\n * It will be thrown on the client side and caught by the nearest error boundary component.\n */\n error(error: any): StreamableUIWrapper;\n\n /**\n * This method marks the UI node as finalized. You can either call it without any parameters or with a new UI node as the final state.\n * Once called, the UI node cannot be updated or appended anymore.\n *\n * This method is always **required** to be called, otherwise the response will be stuck in a loading state.\n */\n done(...args: [React.ReactNode] | []): StreamableUIWrapper;\n};\n\n/**\n * Create a piece of changeable UI that can be streamed to the client.\n * On the client side, it can be rendered as a normal React node.\n */\nfunction createStreamableUI(initialValue?: React.ReactNode) {\n let currentValue = initialValue;\n let closed = false;\n let { row, resolve, reject } = createSuspendedChunk(initialValue);\n\n function assertStream(method: string) {\n if (closed) {\n throw new Error(method + ': UI stream is already closed.');\n }\n }\n\n let warningTimeout: NodeJS.Timeout | undefined;\n function warnUnclosedStream() {\n if (process.env.NODE_ENV === 'development') {\n if (warningTimeout) {\n clearTimeout(warningTimeout);\n }\n warningTimeout = setTimeout(() => {\n console.warn(\n 'The streamable UI has been slow to update. This may be a bug or a performance issue or you forgot to call `.done()`.',\n );\n }, HANGING_STREAM_WARNING_TIME_MS);\n }\n }\n warnUnclosedStream();\n\n const streamable: StreamableUIWrapper = {\n value: row,\n update(value: React.ReactNode) {\n assertStream('.update()');\n\n // There is no need to update the value if it's referentially equal.\n if (value === currentValue) {\n warnUnclosedStream();\n return streamable;\n }\n\n const resolvable = createResolvablePromise();\n currentValue = value;\n\n resolve({ value: currentValue, done: false, next: resolvable.promise });\n resolve = resolvable.resolve;\n reject = resolvable.reject;\n\n warnUnclosedStream();\n\n return streamable;\n },\n append(value: React.ReactNode) {\n assertStream('.append()');\n\n const resolvable = createResolvablePromise();\n currentValue = value;\n\n resolve({ value, done: false, append: true, next: resolvable.promise });\n resolve = resolvable.resolve;\n reject = resolvable.reject;\n\n warnUnclosedStream();\n\n return streamable;\n },\n error(error: any) {\n assertStream('.error()');\n\n if (warningTimeout) {\n clearTimeout(warningTimeout);\n }\n closed = true;\n reject(error);\n\n return streamable;\n },\n done(...args: [] | [React.ReactNode]) {\n assertStream('.done()');\n\n if (warningTimeout) {\n clearTimeout(warningTimeout);\n }\n closed = true;\n if (args.length) {\n resolve({ value: args[0], done: true });\n return streamable;\n }\n resolve({ value: currentValue, done: true });\n\n return streamable;\n },\n };\n\n return streamable;\n}\n\nexport { createStreamableUI };\n","export function isAsyncGenerator<T, TReturn, TNext>(\n value: unknown,\n): value is AsyncGenerator<T, TReturn, TNext> {\n return (\n value != null && typeof value === 'object' && Symbol.asyncIterator in value\n );\n}\n","export function isGenerator<T, TReturn, TNext>(\n value: unknown,\n): value is Generator<T, TReturn, TNext> {\n return value != null && typeof value === 'object' && Symbol.iterator in value;\n}\n","export const STREAMABLE_VALUE_TYPE = Symbol.for('ui.streamable.value');\n\nexport type StreamablePatch = undefined | [0, string]; // Append string.\n\ndeclare const __internal_curr: unique symbol;\ndeclare const __internal_error: unique symbol;\n\n/**\n * StreamableValue is a value that can be streamed over the network via AI Actions.\n * To read the streamed values, use the `readStreamableValue` or `useStreamableValue` APIs.\n */\nexport type StreamableValue<T = any, E = any> = {\n /**\n * @internal Use `readStreamableValue` to read the values.\n */\n type?: typeof STREAMABLE_VALUE_TYPE;\n /**\n * @internal Use `readStreamableValue` to read the values.\n */\n curr?: T;\n /**\n * @internal Use `readStreamableValue` to read the values.\n */\n error?: E;\n /**\n * @internal Use `readStreamableValue` to read the values.\n */\n diff?: StreamablePatch;\n /**\n * @internal Use `readStreamableValue` to read the values.\n */\n next?: Promise<StreamableValue<T, E>>;\n\n // branded types to maintain type signature after internal properties are stripped.\n [__internal_curr]?: T;\n [__internal_error]?: E;\n};\n","import { HANGING_STREAM_WARNING_TIME_MS } from '../util/constants';\nimport { createResolvablePromise } from '../util/create-resolvable-promise';\nimport {\n STREAMABLE_VALUE_TYPE,\n StreamablePatch,\n StreamableValue,\n} from './streamable-value';\n\nconst STREAMABLE_VALUE_INTERNAL_LOCK = Symbol('streamable.value.lock');\n\n/**\n * Create a wrapped, changeable value that can be streamed to the client.\n * On the client side, the value can be accessed via the readStreamableValue() API.\n */\nfunction createStreamableValue<T = any, E = any>(\n initialValue?: T | ReadableStream<T>,\n) {\n const isReadableStream =\n initialValue instanceof ReadableStream ||\n (typeof initialValue === 'object' &&\n initialValue !== null &&\n 'getReader' in initialValue &&\n typeof initialValue.getReader === 'function' &&\n 'locked' in initialValue &&\n typeof initialValue.locked === 'boolean');\n\n if (!isReadableStream) {\n return createStreamableValueImpl<T, E>(initialValue);\n }\n\n const streamableValue = createStreamableValueImpl<T, E>();\n\n // Since the streamable value will be from a readable stream, it's not allowed\n // to update the value manually as that introduces race conditions and\n // unexpected behavior.\n // We lock the value to prevent any updates from the user.\n streamableValue[STREAMABLE_VALUE_INTERNAL_LOCK] = true;\n\n (async () => {\n try {\n // Consume the readable stream and update the value.\n const reader = initialValue.getReader();\n\n while (true) {\n const { value, done } = await reader.read();\n if (done) {\n break;\n }\n\n // Unlock the value to allow updates.\n streamableValue[STREAMABLE_VALUE_INTERNAL_LOCK] = false;\n if (typeof value === 'string') {\n streamableValue.append(value);\n } else {\n streamableValue.update(value);\n }\n // Lock the value again.\n streamableValue[STREAMABLE_VALUE_INTERNAL_LOCK] = true;\n }\n\n streamableValue[STREAMABLE_VALUE_INTERNAL_LOCK] = false;\n streamableValue.done();\n } catch (e) {\n streamableValue[STREAMABLE_VALUE_INTERNAL_LOCK] = false;\n streamableValue.error(e);\n }\n })();\n\n return streamableValue;\n}\n\n// It's necessary to define the type manually here, otherwise TypeScript compiler\n// will not be able to infer the correct return type as it's circular.\ntype StreamableValueWrapper<T, E> = {\n /**\n * The value of the streamable. This can be returned from a Server Action and\n * received by the client. To read the streamed values, use the\n * `readStreamableValue` or `useStreamableValue` APIs.\n */\n readonly value: StreamableValue<T, E>;\n\n /**\n * This method updates the current value with a new one.\n */\n update(value: T): StreamableValueWrapper<T, E>;\n\n /**\n * This method is used to append a delta string to the current value. It\n * requires the current value of the streamable to be a string.\n *\n * @example\n * ```jsx\n * const streamable = createStreamableValue('hello');\n * streamable.append(' world');\n *\n * // The value will be 'hello world'\n * ```\n */\n append(value: T): StreamableValueWrapper<T, E>;\n\n /**\n * This method is used to signal that there is an error in the value stream.\n * It will be thrown on the client side when consumed via\n * `readStreamableValue` or `useStreamableValue`.\n */\n error(error: any): StreamableValueWrapper<T, E>;\n\n /**\n * This method marks the value as finalized. You can either call it without\n * any parameters or with a new value as the final state.\n * Once called, the value cannot be updated or appended anymore.\n *\n * This method is always **required** to be called, otherwise the response\n * will be stuck in a loading state.\n */\n done(...args: [T] | []): StreamableValueWrapper<T, E>;\n\n /**\n * @internal This is an internal lock to prevent the value from being\n * updated by the user.\n */\n [STREAMABLE_VALUE_INTERNAL_LOCK]: boolean;\n};\n\nfunction createStreamableValueImpl<T = any, E = any>(initialValue?: T) {\n let closed = false;\n let locked = false;\n let resolvable = createResolvablePromise<StreamableValue<T, E>>();\n\n let currentValue = initialValue;\n let currentError: E | undefined;\n let currentPromise: typeof resolvable.promise | undefined =\n resolvable.promise;\n let currentPatchValue: StreamablePatch;\n\n function assertStream(method: string) {\n if (closed) {\n throw new Error(method + ': Value stream is already closed.');\n }\n if (locked) {\n throw new Error(\n method + ': Value stream is locked and cannot be updated.',\n );\n }\n }\n\n let warningTimeout: NodeJS.Timeout | undefined;\n function warnUnclosedStream() {\n if (process.env.NODE_ENV === 'development') {\n if (warningTimeout) {\n clearTimeout(warningTimeout);\n }\n warningTimeout = setTimeout(() => {\n console.warn(\n 'The streamable value has been slow to update. This may be a bug or a performance issue or you forgot to call `.done()`.',\n );\n }, HANGING_STREAM_WARNING_TIME_MS);\n }\n }\n warnUnclosedStream();\n\n function createWrapped(initialChunk?: boolean): StreamableValue<T, E> {\n // This makes the payload much smaller if there're mutative updates before the first read.\n let init: Partial<StreamableValue<T, E>>;\n\n if (currentError !== undefined) {\n init = { error: currentError };\n } else {\n if (currentPatchValue && !initialChunk) {\n init = { diff: currentPatchValue };\n } else {\n init = { curr: currentValue };\n }\n }\n\n if (currentPromise) {\n init.next = currentPromise;\n }\n\n if (initialChunk) {\n init.type = STREAMABLE_VALUE_TYPE;\n }\n\n return init;\n }\n\n // Update the internal `currentValue` and `currentPatchValue` if needed.\n function updateValueStates(value: T) {\n // If we can only send a patch over the wire, it's better to do so.\n currentPatchValue = undefined;\n if (typeof value === 'string') {\n if (typeof currentValue === 'string') {\n if (value.startsWith(currentValue)) {\n currentPatchValue = [0, value.slice(currentValue.length)];\n }\n }\n }\n\n currentValue = value;\n }\n\n const streamable: StreamableValueWrapper<T, E> = {\n set [STREAMABLE_VALUE_INTERNAL_LOCK](state: boolean) {\n locked = state;\n },\n get value() {\n return createWrapped(true);\n },\n update(value: T) {\n assertStream('.update()');\n\n const resolvePrevious = resolvable.resolve;\n resolvable = createResolvablePromise();\n\n updateValueStates(value);\n currentPromise = resolvable.promise;\n resolvePrevious(createWrapped());\n\n warnUnclosedStream();\n\n return streamable;\n },\n append(value: T) {\n assertStream('.append()');\n\n if (\n typeof currentValue !== 'string' &&\n typeof currentValue !== 'undefined'\n ) {\n throw new Error(\n `.append(): The current value is not a string. Received: ${typeof currentValue}`,\n );\n }\n if (typeof value !== 'string') {\n throw new Error(\n `.append(): The value is not a string. Received: ${typeof value}`,\n );\n }\n\n const resolvePrevious = resolvable.resolve;\n resolvable = createResolvablePromise();\n\n if (typeof currentValue === 'string') {\n currentPatchValue = [0, value];\n (currentValue as string) = currentValue + value;\n } else {\n currentPatchValue = undefined;\n currentValue = value;\n }\n\n currentPromise = resolvable.promise;\n resolvePrevious(createWrapped());\n\n warnUnclosedStream();\n\n return streamable;\n },\n error(error: any) {\n assertStream('.error()');\n\n if (warningTimeout) {\n clearTimeout(warningTimeout);\n }\n closed = true;\n currentError = error;\n currentPromise = undefined;\n\n resolvable.resolve({ error });\n\n return streamable;\n },\n done(...args: [] | [T]) {\n assertStream('.done()');\n\n if (warningTimeout) {\n clearTimeout(warningTimeout);\n }\n closed = true;\n currentPromise = undefined;\n\n if (args.length) {\n updateValueStates(args[0]);\n resolvable.resolve(createWrapped());\n return streamable;\n }\n\n resolvable.resolve({});\n\n return streamable;\n },\n };\n\n return streamable;\n}\n\nexport { createStreamableValue };\n"],"mappings":";AAAA,YAAY,mBAAmB;AAC/B,SAAS,yBAAyB;;;ACQ3B,SAAS,0BAId;AACA,MAAI;AACJ,MAAI;AAEJ,QAAM,UAAU,IAAI,QAAW,CAAC,KAAK,QAAQ;AAC3C,cAAU;AACV,aAAS;AAAA,EACX,CAAC;AAED,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;;;ACrBO,IAAM,aAAa,CAAC,UACzB,OAAO,UAAU;;;AFOnB,IAAM,sBAAsB,IAAI,kBAO7B;AAEH,SAAS,uBAAuB,SAAiB;AAC/C,QAAM,QAAQ,oBAAoB,SAAS;AAC3C,MAAI,CAAC,OAAO;AACV,UAAM,IAAI,MAAM,OAAO;AAAA,EACzB;AACA,SAAO;AACT;AAEO,SAAS,YACd,EAAE,OAAO,QAAQ,GACjB,IACG;AACH,SAAO,oBAAoB;AAAA,IACzB;AAAA,MACE,cAAc,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC;AAAA;AAAA,MAC9C,eAAe;AAAA,MACf,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,yBAAyB;AACvC,QAAM,QAAQ,uBAAuB,0BAA0B;AAC/D,SAAO,MAAM;AACf;AAKO,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@
1
1
  {
2
2
  "name": "@ai-sdk/rsc",
3
- "version": "2.0.0-beta.98",
3
+ "version": "2.0.0",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/rsc-client.mjs",
@@ -22,9 +22,9 @@
22
22
  ],
23
23
  "dependencies": {
24
24
  "jsondiffpatch": "0.7.3",
25
- "ai": "6.0.0-beta.97",
26
- "@ai-sdk/provider-utils": "4.0.0-beta.32",
27
- "@ai-sdk/provider": "3.0.0-beta.15"
25
+ "ai": "6.0.0",
26
+ "@ai-sdk/provider": "3.0.0",
27
+ "@ai-sdk/provider-utils": "4.0.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@testing-library/jest-dom": "^6.6.3",
@@ -47,7 +47,7 @@
47
47
  "eslint-config-vercel-ai": "0.0.0"
48
48
  },
49
49
  "peerDependencies": {
50
- "react": "^18 || ^19 || ^19.0.0-rc",
50
+ "react": "^18 || ~19.0.1 || ~19.1.2 || ^19.2.1",
51
51
  "zod": "^3.25.76 || ^4.1.8"
52
52
  },
53
53
  "peerDependenciesMeta": {