(event: WorkflowRunAttachedEvent)
| 691 | } |
| 692 | |
| 693 | async attachWorkflowRunToToolCall(event: WorkflowRunAttachedEvent): Promise<boolean> { |
| 694 | const workspaceId = event.workspaceId as WorkspaceId; |
| 695 | const streamInfo = this.workspaceStreams.get(workspaceId); |
| 696 | if ( |
| 697 | streamInfo == null || |
| 698 | (event.messageId != null && streamInfo.messageId !== event.messageId) |
| 699 | ) { |
| 700 | return false; |
| 701 | } |
| 702 | |
| 703 | const attachment = this.getWorkflowRunAttachment(event); |
| 704 | const partIndex = streamInfo.parts.findIndex( |
| 705 | (part) => part.type === "dynamic-tool" && part.toolCallId === event.toolCallId |
| 706 | ); |
| 707 | if (partIndex === -1) { |
| 708 | (streamInfo.pendingWorkflowRunAttachments ??= new Map()).set(event.toolCallId, attachment); |
| 709 | return true; |
| 710 | } |
| 711 | |
| 712 | const part = streamInfo.parts[partIndex]; |
| 713 | if (part.type !== "dynamic-tool") { |
| 714 | return false; |
| 715 | } |
| 716 | |
| 717 | streamInfo.pendingWorkflowRunAttachments?.delete(event.toolCallId); |
| 718 | streamInfo.parts[partIndex] = { |
| 719 | ...part, |
| 720 | workflowRun: attachment, |
| 721 | }; |
| 722 | |
| 723 | await this.flushPartialWrite(workspaceId, streamInfo); |
| 724 | return true; |
| 725 | } |
| 726 | |
| 727 | /** |
| 728 | * Write the current partial message to disk (throttled by mtime) |
no test coverage detected