ai 3.0.10 → 3.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -499,6 +499,43 @@ function experimental_AssistantResponse({ threadId, messageId }, process2) {
499
499
  textEncoder.encode(formatStreamPart("error", errorMessage))
500
500
  );
501
501
  };
502
+ const forwardStream = async (stream2) => {
503
+ var _a2, _b;
504
+ let result = void 0;
505
+ for await (const value of stream2) {
506
+ switch (value.event) {
507
+ case "thread.message.created": {
508
+ controller.enqueue(
509
+ textEncoder.encode(
510
+ formatStreamPart("assistant_message", {
511
+ id: value.data.id,
512
+ role: "assistant",
513
+ content: [{ type: "text", text: { value: "" } }]
514
+ })
515
+ )
516
+ );
517
+ break;
518
+ }
519
+ case "thread.message.delta": {
520
+ const content = (_a2 = value.data.delta.content) == null ? void 0 : _a2[0];
521
+ if ((content == null ? void 0 : content.type) === "text" && ((_b = content.text) == null ? void 0 : _b.value) != null) {
522
+ controller.enqueue(
523
+ textEncoder.encode(
524
+ formatStreamPart("text", content.text.value)
525
+ )
526
+ );
527
+ }
528
+ break;
529
+ }
530
+ case "thread.run.completed":
531
+ case "thread.run.requires_action": {
532
+ result = value.data;
533
+ break;
534
+ }
535
+ }
536
+ }
537
+ return result;
538
+ };
502
539
  controller.enqueue(
503
540
  textEncoder.encode(
504
541
  formatStreamPart("assistant_control_data", {
@@ -512,7 +549,8 @@ function experimental_AssistantResponse({ threadId, messageId }, process2) {
512
549
  threadId,
513
550
  messageId,
514
551
  sendMessage,
515
- sendDataMessage
552
+ sendDataMessage,
553
+ forwardStream
516
554
  });
517
555
  } catch (error) {
518
556
  sendError((_a = error.message) != null ? _a : `${error}`);