(
parent: SessionHeader,
definition: AgentDefinition,
requestFingerprint: string,
)
| 989 | } |
| 990 | |
| 991 | private async provisionChildWorkspace( |
| 992 | parent: SessionHeader, |
| 993 | definition: AgentDefinition, |
| 994 | requestFingerprint: string, |
| 995 | ): Promise<SubagentWorkspaceBinding | undefined> { |
| 996 | if (definition.contract.workspace !== AGENT_WORKSPACE_WORKTREE) return undefined; |
| 997 | const executor = this.deps.worktreeChildExecutor; |
| 998 | if (!executor) { |
| 999 | throw new Error( |
| 1000 | `Agent "${definition.id}" is unavailable: "worktree" workspace isolation requires a worktree child executor.`, |
| 1001 | ); |
| 1002 | } |
| 1003 | const fingerprint = requestFingerprint.startsWith('sha256:') |
| 1004 | ? requestFingerprint.slice('sha256:'.length) |
| 1005 | : requestFingerprint; |
| 1006 | if (!/^[a-f0-9]{64}$/.test(fingerprint)) { |
| 1007 | throw new Error('Child workspace request fingerprint must be SHA-256'); |
| 1008 | } |
| 1009 | return executor.provision({ |
| 1010 | leaseId: `subagent_worktree_${fingerprint.slice(0, 32)}`, |
| 1011 | sourceSessionId: parent.id, |
| 1012 | sourceCwd: parent.cwd, |
| 1013 | ...(parent.projectId !== undefined ? { sourceProjectId: parent.projectId } : {}), |
| 1014 | }); |
| 1015 | } |
| 1016 | |
| 1017 | private async ensureChildWorkspace(header: SessionHeader): Promise<void> { |
| 1018 | const binding = header.subagentWorkspace; |
no test coverage detected