@ai-sdk/rsc 2.0.0-beta.99 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,732 @@
1
1
  # @ai-sdk/rsc
2
2
 
3
+ ## 2.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - ai@6.0.1
8
+
9
+ ## 2.0.0
10
+
11
+ ### Major Changes
12
+
13
+ - dee8b05: ai SDK 6 beta
14
+
15
+ ### Minor Changes
16
+
17
+ - 78928cb: release: start 5.1 beta
18
+
19
+ ### Patch Changes
20
+
21
+ - 95f65c2: chore: use import \* from zod/v4
22
+ - 3bd2689: feat: extended token usage
23
+ - 8dac895: feat: `LanguageModelV3`
24
+ - af65ab6: drop react 19-rc support. Require minimal versions for RSC to address CVE-2025-55182
25
+ - 457318b: chore(provider,ai): switch to SharedV3Warning and unified warnings
26
+ - 4616b86: chore: update zod peer depenedency version
27
+ - cbf52cd: feat: expose raw finish reason
28
+ - fda12fa: chore(rsc): upgrade jsondiffpatch to 0.7.3
29
+ - Updated dependencies [0c3b58b]
30
+ - Updated dependencies [58920e0]
31
+ - Updated dependencies [a7da2b6]
32
+ - Updated dependencies [0adc679]
33
+ - Updated dependencies [50b70d6]
34
+ - Updated dependencies [d1bdadb]
35
+ - Updated dependencies [2d28066]
36
+ - Updated dependencies [fca786b]
37
+ - Updated dependencies [dee8b05]
38
+ - Updated dependencies [046aa3b]
39
+ - Updated dependencies [e1f6e8e]
40
+ - Updated dependencies [8d9e8ad]
41
+ - Updated dependencies [78928cb]
42
+ - Updated dependencies [b67d224]
43
+ - Updated dependencies [ab6f01a]
44
+ - Updated dependencies [9388ff1]
45
+ - Updated dependencies [dce03c4]
46
+ - Updated dependencies [2625a04]
47
+ - Updated dependencies [37c58a0]
48
+ - Updated dependencies [4e2b04d]
49
+ - Updated dependencies [ab1087b]
50
+ - Updated dependencies [3b1d015]
51
+ - Updated dependencies [2b0caef]
52
+ - Updated dependencies [bb10a89]
53
+ - Updated dependencies [457f1c6]
54
+ - Updated dependencies [95f65c2]
55
+ - Updated dependencies [754df61]
56
+ - Updated dependencies [016b111]
57
+ - Updated dependencies [58920e0]
58
+ - Updated dependencies [954c356]
59
+ - Updated dependencies [7fdd89d]
60
+ - Updated dependencies [eca63f3]
61
+ - Updated dependencies [90e5bdd]
62
+ - Updated dependencies [42cf7ed]
63
+ - Updated dependencies [544d4e8]
64
+ - Updated dependencies [4812235]
65
+ - Updated dependencies [7f2c9b6]
66
+ - Updated dependencies [614599a]
67
+ - Updated dependencies [0c4822d]
68
+ - Updated dependencies [e062079]
69
+ - Updated dependencies [2b49dae]
70
+ - Updated dependencies [ee651d7]
71
+ - Updated dependencies [5a4e732]
72
+ - Updated dependencies [f733285]
73
+ - Updated dependencies [9b83947]
74
+ - Updated dependencies [7eca093]
75
+ - Updated dependencies [077aea3]
76
+ - Updated dependencies [9f20c87]
77
+ - Updated dependencies [521c537]
78
+ - Updated dependencies [7169511]
79
+ - Updated dependencies [4c44a5b]
80
+ - Updated dependencies [e8109d3]
81
+ - Updated dependencies [03849b0]
82
+ - Updated dependencies [ed329cb]
83
+ - Updated dependencies [22ef5c6]
84
+ - Updated dependencies [9ba4324]
85
+ - Updated dependencies [e06565c]
86
+ - Updated dependencies [32d8dbb]
87
+ - Updated dependencies [53f3368]
88
+ - Updated dependencies [d116b4b]
89
+ - Updated dependencies [3bd2689]
90
+ - Updated dependencies [293a6b7]
91
+ - Updated dependencies [7c3c216]
92
+ - Updated dependencies [c62ecf0]
93
+ - Updated dependencies [d1bdadb]
94
+ - Updated dependencies [703459a]
95
+ - Updated dependencies [bb36798]
96
+ - Updated dependencies [3071620]
97
+ - Updated dependencies [7e4649f]
98
+ - Updated dependencies [48454ab]
99
+ - Updated dependencies [e06b663]
100
+ - Updated dependencies [83e5744]
101
+ - Updated dependencies [8c98371]
102
+ - Updated dependencies [7e32fea]
103
+ - Updated dependencies [b1405bf]
104
+ - Updated dependencies [a5e152d]
105
+ - Updated dependencies [aa0515c]
106
+ - Updated dependencies [f6f0c5a]
107
+ - Updated dependencies [3ed5519]
108
+ - Updated dependencies [eb8d1cb]
109
+ - Updated dependencies [e7d9b00]
110
+ - Updated dependencies [d5b25ee]
111
+ - Updated dependencies [d7bae86]
112
+ - Updated dependencies [8dac895]
113
+ - Updated dependencies [a755db5]
114
+ - Updated dependencies [1c2a4c1]
115
+ - Updated dependencies [686103c]
116
+ - Updated dependencies [a755db5]
117
+ - Updated dependencies [0d6c0d8]
118
+ - Updated dependencies [9b8d17e]
119
+ - Updated dependencies [79a8e7f]
120
+ - Updated dependencies [cbb1d35]
121
+ - Updated dependencies [d59ce25]
122
+ - Updated dependencies [475189e]
123
+ - Updated dependencies [3d83f38]
124
+ - Updated dependencies [457318b]
125
+ - Updated dependencies [b681d7d]
126
+ - Updated dependencies [c99da05]
127
+ - Updated dependencies [db913bd]
128
+ - Updated dependencies [9061dc0]
129
+ - Updated dependencies [8445d70]
130
+ - Updated dependencies [32223c8]
131
+ - Updated dependencies [8370068]
132
+ - Updated dependencies [5e313e3]
133
+ - Updated dependencies [db62f7d]
134
+ - Updated dependencies [a7f6f81]
135
+ - Updated dependencies [79ba99f]
136
+ - Updated dependencies [c98373a]
137
+ - Updated dependencies [c1efac4]
138
+ - Updated dependencies [846e80e]
139
+ - Updated dependencies [bbdcb81]
140
+ - Updated dependencies [366f50b]
141
+ - Updated dependencies [67a407c]
142
+ - Updated dependencies [9524761]
143
+ - Updated dependencies [ca13d26]
144
+ - Updated dependencies [4616b86]
145
+ - Updated dependencies [a322efa]
146
+ - Updated dependencies [2d166e4]
147
+ - Updated dependencies [384142c]
148
+ - Updated dependencies [36b175c]
149
+ - Updated dependencies [2b1bf9d]
150
+ - Updated dependencies [81d4308]
151
+ - Updated dependencies [e0d1ea9]
152
+ - Updated dependencies [9549c9e]
153
+ - Updated dependencies [2406576]
154
+ - Updated dependencies [b1aeea7]
155
+ - Updated dependencies [dce4e7b]
156
+ - Updated dependencies [af3780b]
157
+ - Updated dependencies [4f16c37]
158
+ - Updated dependencies [4ece5f9]
159
+ - Updated dependencies [81e29ab]
160
+ - Updated dependencies [a417a34]
161
+ - Updated dependencies [637eaa4]
162
+ - Updated dependencies [177b475]
163
+ - Updated dependencies [21e20c0]
164
+ - Updated dependencies [afe7093]
165
+ - Updated dependencies [61f7b0f]
166
+ - Updated dependencies [af9dab3]
167
+ - Updated dependencies [522f6b8]
168
+ - Updated dependencies [6306603]
169
+ - Updated dependencies [97b1d77]
170
+ - Updated dependencies [69768c2]
171
+ - Updated dependencies [27e8c3a]
172
+ - Updated dependencies [fca786b]
173
+ - Updated dependencies [81e29ab]
174
+ - Updated dependencies [7da02d2]
175
+ - Updated dependencies [763d04a]
176
+ - Updated dependencies [95b77e2]
177
+ - Updated dependencies [10d819b]
178
+ - Updated dependencies [3794514]
179
+ - Updated dependencies [cbf52cd]
180
+ - Updated dependencies [14ca35d]
181
+ - Updated dependencies [e9e157f]
182
+ - Updated dependencies [10c1322]
183
+ - Updated dependencies [dcdac8c]
184
+ - Updated dependencies [960ec8f]
185
+ - Updated dependencies [b59d924]
186
+ - Updated dependencies [1bd7d32]
187
+ - Updated dependencies [f0b2157]
188
+ - Updated dependencies [95f65c2]
189
+ - @ai-sdk/provider@3.0.0
190
+ - ai@6.0.0
191
+ - @ai-sdk/provider-utils@4.0.0
192
+
193
+ ## 2.0.0-beta.171
194
+
195
+ ### Patch Changes
196
+
197
+ - Updated dependencies [ee651d7]
198
+ - ai@6.0.0-beta.169
199
+
200
+ ## 2.0.0-beta.170
201
+
202
+ ### Patch Changes
203
+
204
+ - ai@6.0.0-beta.168
205
+
206
+ ## 2.0.0-beta.169
207
+
208
+ ### Patch Changes
209
+
210
+ - Updated dependencies [475189e]
211
+ - @ai-sdk/provider@3.0.0-beta.32
212
+ - ai@6.0.0-beta.167
213
+ - @ai-sdk/provider-utils@4.0.0-beta.59
214
+
215
+ ## 2.0.0-beta.168
216
+
217
+ ### Patch Changes
218
+
219
+ - Updated dependencies [9f20c87]
220
+ - ai@6.0.0-beta.166
221
+
222
+ ## 2.0.0-beta.167
223
+
224
+ ### Patch Changes
225
+
226
+ - Updated dependencies [2625a04]
227
+ - @ai-sdk/provider@3.0.0-beta.31
228
+ - ai@6.0.0-beta.165
229
+ - @ai-sdk/provider-utils@4.0.0-beta.58
230
+
231
+ ## 2.0.0-beta.166
232
+
233
+ ### Patch Changes
234
+
235
+ - cbf52cd: feat: expose raw finish reason
236
+ - Updated dependencies [cbf52cd]
237
+ - @ai-sdk/provider@3.0.0-beta.30
238
+ - ai@6.0.0-beta.164
239
+ - @ai-sdk/provider-utils@4.0.0-beta.57
240
+
241
+ ## 2.0.0-beta.165
242
+
243
+ ### Patch Changes
244
+
245
+ - Updated dependencies [9549c9e]
246
+ - @ai-sdk/provider@3.0.0-beta.29
247
+ - ai@6.0.0-beta.163
248
+ - @ai-sdk/provider-utils@4.0.0-beta.56
249
+
250
+ ## 2.0.0-beta.164
251
+
252
+ ### Patch Changes
253
+
254
+ - Updated dependencies [50b70d6]
255
+ - @ai-sdk/provider-utils@4.0.0-beta.55
256
+ - ai@6.0.0-beta.162
257
+
258
+ ## 2.0.0-beta.163
259
+
260
+ ### Patch Changes
261
+
262
+ - ai@6.0.0-beta.161
263
+
264
+ ## 2.0.0-beta.162
265
+
266
+ ### Patch Changes
267
+
268
+ - Updated dependencies [9061dc0]
269
+ - @ai-sdk/provider-utils@4.0.0-beta.54
270
+ - @ai-sdk/provider@3.0.0-beta.28
271
+ - ai@6.0.0-beta.160
272
+
273
+ ## 2.0.0-beta.161
274
+
275
+ ### Patch Changes
276
+
277
+ - Updated dependencies [3071620]
278
+ - ai@6.0.0-beta.159
279
+
280
+ ## 2.0.0-beta.160
281
+
282
+ ### Patch Changes
283
+
284
+ - Updated dependencies [366f50b]
285
+ - @ai-sdk/provider@3.0.0-beta.27
286
+ - ai@6.0.0-beta.158
287
+ - @ai-sdk/provider-utils@4.0.0-beta.53
288
+
289
+ ## 2.0.0-beta.159
290
+
291
+ ### Patch Changes
292
+
293
+ - Updated dependencies [763d04a]
294
+ - @ai-sdk/provider-utils@4.0.0-beta.52
295
+ - ai@6.0.0-beta.157
296
+
297
+ ## 2.0.0-beta.158
298
+
299
+ ### Patch Changes
300
+
301
+ - Updated dependencies [2406576]
302
+ - ai@6.0.0-beta.156
303
+
304
+ ## 2.0.0-beta.157
305
+
306
+ ### Patch Changes
307
+
308
+ - Updated dependencies [c1efac4]
309
+ - @ai-sdk/provider-utils@4.0.0-beta.51
310
+ - ai@6.0.0-beta.155
311
+
312
+ ## 2.0.0-beta.156
313
+
314
+ ### Patch Changes
315
+
316
+ - Updated dependencies [32223c8]
317
+ - @ai-sdk/provider-utils@4.0.0-beta.50
318
+ - ai@6.0.0-beta.154
319
+
320
+ ## 2.0.0-beta.155
321
+
322
+ ### Patch Changes
323
+
324
+ - Updated dependencies [83e5744]
325
+ - @ai-sdk/provider-utils@4.0.0-beta.49
326
+ - ai@6.0.0-beta.153
327
+
328
+ ## 2.0.0-beta.154
329
+
330
+ ### Patch Changes
331
+
332
+ - Updated dependencies [960ec8f]
333
+ - @ai-sdk/provider-utils@4.0.0-beta.48
334
+ - ai@6.0.0-beta.152
335
+
336
+ ## 2.0.0-beta.153
337
+
338
+ ### Patch Changes
339
+
340
+ - Updated dependencies [dcdac8c]
341
+ - ai@6.0.0-beta.151
342
+
343
+ ## 2.0.0-beta.152
344
+
345
+ ### Patch Changes
346
+
347
+ - Updated dependencies [db62f7d]
348
+ - ai@6.0.0-beta.150
349
+
350
+ ## 2.0.0-beta.151
351
+
352
+ ### Patch Changes
353
+
354
+ - Updated dependencies [4e2b04d]
355
+ - ai@6.0.0-beta.149
356
+
357
+ ## 2.0.0-beta.150
358
+
359
+ ### Patch Changes
360
+
361
+ - ai@6.0.0-beta.148
362
+
363
+ ## 2.0.0-beta.149
364
+
365
+ ### Patch Changes
366
+
367
+ - Updated dependencies [637eaa4]
368
+ - ai@6.0.0-beta.147
369
+
370
+ ## 2.0.0-beta.148
371
+
372
+ ### Patch Changes
373
+
374
+ - Updated dependencies [e9e157f]
375
+ - @ai-sdk/provider-utils@4.0.0-beta.47
376
+ - ai@6.0.0-beta.146
377
+
378
+ ## 2.0.0-beta.147
379
+
380
+ ### Patch Changes
381
+
382
+ - ai@6.0.0-beta.145
383
+
384
+ ## 2.0.0-beta.146
385
+
386
+ ### Patch Changes
387
+
388
+ - Updated dependencies [ab6f01a]
389
+ - ai@6.0.0-beta.144
390
+
391
+ ## 2.0.0-beta.145
392
+
393
+ ### Patch Changes
394
+
395
+ - Updated dependencies [81e29ab]
396
+ - Updated dependencies [81e29ab]
397
+ - @ai-sdk/provider-utils@4.0.0-beta.46
398
+ - ai@6.0.0-beta.143
399
+
400
+ ## 2.0.0-beta.144
401
+
402
+ ### Patch Changes
403
+
404
+ - Updated dependencies [7169511]
405
+ - Updated dependencies [bbdcb81]
406
+ - ai@6.0.0-beta.142
407
+
408
+ ## 2.0.0-beta.143
409
+
410
+ ### Patch Changes
411
+
412
+ - Updated dependencies [b1405bf]
413
+ - ai@6.0.0-beta.141
414
+
415
+ ## 2.0.0-beta.142
416
+
417
+ ### Patch Changes
418
+
419
+ - Updated dependencies [7fdd89d]
420
+ - ai@6.0.0-beta.140
421
+
422
+ ## 2.0.0-beta.141
423
+
424
+ ### Patch Changes
425
+
426
+ - 3bd2689: feat: extended token usage
427
+ - Updated dependencies [3bd2689]
428
+ - @ai-sdk/provider@3.0.0-beta.26
429
+ - ai@6.0.0-beta.139
430
+ - @ai-sdk/provider-utils@4.0.0-beta.45
431
+
432
+ ## 2.0.0-beta.140
433
+
434
+ ### Patch Changes
435
+
436
+ - Updated dependencies [53f3368]
437
+ - @ai-sdk/provider@3.0.0-beta.25
438
+ - ai@6.0.0-beta.138
439
+ - @ai-sdk/provider-utils@4.0.0-beta.44
440
+
441
+ ## 2.0.0-beta.139
442
+
443
+ ### Patch Changes
444
+
445
+ - Updated dependencies [9ba4324]
446
+ - ai@6.0.0-beta.137
447
+
448
+ ## 2.0.0-beta.138
449
+
450
+ ### Patch Changes
451
+
452
+ - Updated dependencies [3d83f38]
453
+ - ai@6.0.0-beta.136
454
+
455
+ ## 2.0.0-beta.137
456
+
457
+ ### Patch Changes
458
+
459
+ - Updated dependencies [afe7093]
460
+ - ai@6.0.0-beta.135
461
+
462
+ ## 2.0.0-beta.136
463
+
464
+ ### Patch Changes
465
+
466
+ - Updated dependencies [686103c]
467
+ - ai@6.0.0-beta.134
468
+
469
+ ## 2.0.0-beta.135
470
+
471
+ ### Patch Changes
472
+
473
+ - Updated dependencies [dce03c4]
474
+ - @ai-sdk/provider-utils@4.0.0-beta.43
475
+ - @ai-sdk/provider@3.0.0-beta.24
476
+ - ai@6.0.0-beta.133
477
+
478
+ ## 2.0.0-beta.134
479
+
480
+ ### Patch Changes
481
+
482
+ - Updated dependencies [af9dab3]
483
+ - ai@6.0.0-beta.132
484
+
485
+ ## 2.0.0-beta.133
486
+
487
+ ### Patch Changes
488
+
489
+ - Updated dependencies [3ed5519]
490
+ - @ai-sdk/provider-utils@4.0.0-beta.42
491
+ - ai@6.0.0-beta.131
492
+
493
+ ## 2.0.0-beta.132
494
+
495
+ ### Patch Changes
496
+
497
+ - af65ab6: drop react 19-rc support. Require minimal versions for RSC to address CVE-2025-55182
498
+
499
+ ## 2.0.0-beta.131
500
+
501
+ ### Patch Changes
502
+
503
+ - Updated dependencies [1bd7d32]
504
+ - @ai-sdk/provider-utils@4.0.0-beta.41
505
+ - @ai-sdk/provider@3.0.0-beta.23
506
+ - ai@6.0.0-beta.130
507
+
508
+ ## 2.0.0-beta.130
509
+
510
+ ### Patch Changes
511
+
512
+ - Updated dependencies [67a407c]
513
+ - ai@6.0.0-beta.129
514
+
515
+ ## 2.0.0-beta.129
516
+
517
+ ### Patch Changes
518
+
519
+ - ai@6.0.0-beta.128
520
+
521
+ ## 2.0.0-beta.128
522
+
523
+ ### Patch Changes
524
+
525
+ - Updated dependencies [614599a]
526
+ - ai@6.0.0-beta.127
527
+
528
+ ## 2.0.0-beta.127
529
+
530
+ ### Patch Changes
531
+
532
+ - Updated dependencies [b67d224]
533
+ - ai@6.0.0-beta.126
534
+
535
+ ## 2.0.0-beta.126
536
+
537
+ ### Patch Changes
538
+
539
+ - Updated dependencies [0d6c0d8]
540
+ - ai@6.0.0-beta.125
541
+
542
+ ## 2.0.0-beta.125
543
+
544
+ ### Patch Changes
545
+
546
+ - Updated dependencies [544d4e8]
547
+ - @ai-sdk/provider-utils@4.0.0-beta.40
548
+ - @ai-sdk/provider@3.0.0-beta.22
549
+ - ai@6.0.0-beta.124
550
+
551
+ ## 2.0.0-beta.124
552
+
553
+ ### Patch Changes
554
+
555
+ - Updated dependencies [954c356]
556
+ - @ai-sdk/provider-utils@4.0.0-beta.39
557
+ - @ai-sdk/provider@3.0.0-beta.21
558
+ - ai@6.0.0-beta.123
559
+
560
+ ## 2.0.0-beta.123
561
+
562
+ ### Patch Changes
563
+
564
+ - Updated dependencies [03849b0]
565
+ - @ai-sdk/provider-utils@4.0.0-beta.38
566
+ - ai@6.0.0-beta.122
567
+
568
+ ## 2.0.0-beta.122
569
+
570
+ ### Patch Changes
571
+
572
+ - ai@6.0.0-beta.121
573
+
574
+ ## 2.0.0-beta.121
575
+
576
+ ### Patch Changes
577
+
578
+ - 457318b: chore(provider,ai): switch to SharedV3Warning and unified warnings
579
+ - Updated dependencies [457318b]
580
+ - @ai-sdk/provider@3.0.0-beta.20
581
+ - ai@6.0.0-beta.120
582
+ - @ai-sdk/provider-utils@4.0.0-beta.37
583
+
584
+ ## 2.0.0-beta.120
585
+
586
+ ### Patch Changes
587
+
588
+ - Updated dependencies [b59d924]
589
+ - ai@6.0.0-beta.119
590
+
591
+ ## 2.0.0-beta.119
592
+
593
+ ### Patch Changes
594
+
595
+ - Updated dependencies [8d9e8ad]
596
+ - @ai-sdk/provider@3.0.0-beta.19
597
+ - ai@6.0.0-beta.118
598
+ - @ai-sdk/provider-utils@4.0.0-beta.36
599
+
600
+ ## 2.0.0-beta.118
601
+
602
+ ### Patch Changes
603
+
604
+ - Updated dependencies [10d819b]
605
+ - @ai-sdk/provider@3.0.0-beta.18
606
+ - ai@6.0.0-beta.117
607
+ - @ai-sdk/provider-utils@4.0.0-beta.35
608
+
609
+ ## 2.0.0-beta.117
610
+
611
+ ### Patch Changes
612
+
613
+ - Updated dependencies [4ece5f9]
614
+ - ai@6.0.0-beta.116
615
+
616
+ ## 2.0.0-beta.116
617
+
618
+ ### Patch Changes
619
+
620
+ - Updated dependencies [7da02d2]
621
+ - ai@6.0.0-beta.115
622
+
623
+ ## 2.0.0-beta.115
624
+
625
+ ### Patch Changes
626
+
627
+ - Updated dependencies [69768c2]
628
+ - ai@6.0.0-beta.114
629
+
630
+ ## 2.0.0-beta.114
631
+
632
+ ### Patch Changes
633
+
634
+ - Updated dependencies [79a8e7f]
635
+ - ai@6.0.0-beta.113
636
+
637
+ ## 2.0.0-beta.113
638
+
639
+ ### Patch Changes
640
+
641
+ - Updated dependencies [e06b663]
642
+ - ai@6.0.0-beta.112
643
+
644
+ ## 2.0.0-beta.112
645
+
646
+ ### Patch Changes
647
+
648
+ - ai@6.0.0-beta.111
649
+
650
+ ## 2.0.0-beta.111
651
+
652
+ ### Patch Changes
653
+
654
+ - Updated dependencies [db913bd]
655
+ - @ai-sdk/provider@3.0.0-beta.17
656
+ - ai@6.0.0-beta.110
657
+ - @ai-sdk/provider-utils@4.0.0-beta.34
658
+
659
+ ## 2.0.0-beta.110
660
+
661
+ ### Patch Changes
662
+
663
+ - Updated dependencies [79ba99f]
664
+ - ai@6.0.0-beta.109
665
+
666
+ ## 2.0.0-beta.109
667
+
668
+ ### Patch Changes
669
+
670
+ - ai@6.0.0-beta.108
671
+
672
+ ## 2.0.0-beta.108
673
+
674
+ ### Patch Changes
675
+
676
+ - Updated dependencies [8445d70]
677
+ - ai@6.0.0-beta.107
678
+
679
+ ## 2.0.0-beta.107
680
+
681
+ ### Patch Changes
682
+
683
+ - ai@6.0.0-beta.106
684
+
685
+ ## 2.0.0-beta.106
686
+
687
+ ### Patch Changes
688
+
689
+ - ai@6.0.0-beta.105
690
+
691
+ ## 2.0.0-beta.105
692
+
693
+ ### Patch Changes
694
+
695
+ - Updated dependencies [2d166e4]
696
+ - ai@6.0.0-beta.104
697
+
698
+ ## 2.0.0-beta.104
699
+
700
+ ### Patch Changes
701
+
702
+ - ai@6.0.0-beta.103
703
+
704
+ ## 2.0.0-beta.103
705
+
706
+ ### Patch Changes
707
+
708
+ - ai@6.0.0-beta.102
709
+
710
+ ## 2.0.0-beta.102
711
+
712
+ ### Patch Changes
713
+
714
+ - ai@6.0.0-beta.101
715
+
716
+ ## 2.0.0-beta.101
717
+
718
+ ### Patch Changes
719
+
720
+ - Updated dependencies [8370068]
721
+ - ai@6.0.0-beta.100
722
+
723
+ ## 2.0.0-beta.100
724
+
725
+ ### Patch Changes
726
+
727
+ - Updated dependencies [384142c]
728
+ - ai@6.0.0-beta.99
729
+
3
730
  ## 2.0.0-beta.99
4
731
 
5
732
  ### 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,IAAM,sBAAsB,IAAI,kBAO7B;AAEH,SAAS,uBAAuB,SAAiB;AAC/C,QAAM,QAAQ,oBAAoB,SAAS;AAC3C,MAAI,C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AgB;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,SAAS,qBAAqB;AACnC,QAAM,QAAQ,uBAAuB,0BAA0B;AAC/D,QAAM,SAAS;AACjB;AAgBA,SAAS,cACJ,MACH;AACA,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,aAAO;AAAA,IACT;AAAA,IACA,OAAO,OAAU;AACf,mBAAa,WAAW;AAExB,UACE,OAAO,iBAAiB,YACxB,OAAO,iBAAiB,aACxB;AACA,cAAM,IAAI;AAAA,UACR,2DAA2D,OAAO,YAAY;AAAA,QAChF;AAAA,MACF;AACA,UAAI,OAAO,UAAU,UAAU;AAC7B,cAAM,IAAI;AAAA,UACR,mDAAmD,OAAO,KAAK;AAAA,QACjE;AAAA,MACF;AAEA,YAAM,kBAAkB,WAAW;AACnC,mBAAa,wBAAwB;AAErC,UAAI,OAAO,iBAAiB,UAAU;AACpC,4BAAoB,CAAC,GAAG,KAAK;AAC7B,QAAC,eAA0B,eAAe;AAAA,MAC5C,OAAO;AACL,4BAAoB;AACpB,uBAAe;AAAA,MACjB;AAEA,uBAAiB,WAAW;AAC5B,sBAAgB,cAAc,CAAC;AAE/B,yBAAmB;AAEnB,aAAO;AAAA,IACT;AAAA,IACA,MAAM,OAAY;AAChB,mBAAa,UAAU;AAEvB,UAAI,gBAAgB;AAClB,qBAAa,cAAc;AAAA,MAC7B;AACA,eAAS;AACT,qBAAe;AACf,uBAAiB;AAEjB,iBAAW,QAAQ,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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/rsc",
3
- "version": "2.0.0-beta.99",
3
+ "version": "2.0.1",
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.98",
26
- "@ai-sdk/provider": "3.0.0-beta.16",
27
- "@ai-sdk/provider-utils": "4.0.0-beta.33"
25
+ "ai": "6.0.1",
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",
@@ -43,11 +43,11 @@
43
43
  "tsup": "^7.2.0",
44
44
  "typescript": "5.8.3",
45
45
  "zod": "3.25.76",
46
- "eslint-config-vercel-ai": "0.0.0",
47
- "@vercel/ai-tsconfig": "0.0.0"
46
+ "@vercel/ai-tsconfig": "0.0.0",
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": {