( context: ToolUseContext, )
| 1641 | * haven't been retrieved yet. |
| 1642 | */ |
| 1643 | export async function createAsyncAgentAttachmentsIfNeeded( |
| 1644 | context: ToolUseContext, |
| 1645 | ): Promise<AttachmentMessage[]> { |
| 1646 | const appState = context.getAppState() |
| 1647 | const asyncAgents = Object.values(appState.tasks).filter( |
| 1648 | (task): task is LocalAgentTaskState => task.type === 'local_agent', |
| 1649 | ) |
| 1650 | |
| 1651 | return asyncAgents.flatMap(agent => { |
| 1652 | if ( |
| 1653 | agent.retrieved || |
| 1654 | agent.status === 'pending' || |
| 1655 | agent.agentId === context.agentId |
| 1656 | ) { |
| 1657 | return [] |
| 1658 | } |
| 1659 | return [ |
| 1660 | createAttachmentMessage({ |
| 1661 | type: 'task_status', |
| 1662 | taskId: agent.agentId, |
| 1663 | taskType: 'local_agent', |
| 1664 | description: agent.description, |
| 1665 | status: agent.status, |
| 1666 | deltaSummary: |
| 1667 | agent.status === 'running' |
| 1668 | ? (agent.progress?.summary ?? null) |
| 1669 | : (agent.error ?? null), |
| 1670 | outputFilePath: getTaskOutputPath(agent.agentId), |
| 1671 | }), |
| 1672 | ] |
| 1673 | }) |
| 1674 | } |
| 1675 | |
| 1676 | /** |
| 1677 | * Scan messages for Read tool_use blocks and collect their file_path inputs |
no test coverage detected