MCPcopy Index your code
hub / github.com/coder/mux / attachWorkflowRunToToolCall

Method attachWorkflowRunToToolCall

src/node/services/streamManager.ts:693–725  ·  view source on GitHub ↗
(event: WorkflowRunAttachedEvent)

Source from the content-addressed store, hash-verified

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)

Callers 2

streamMessageMethod · 0.80

Calls 5

flushPartialWriteMethod · 0.95
setMethod · 0.80
getMethod · 0.65
deleteMethod · 0.45

Tested by

no test coverage detected