fix: resolve errand worktree path for sendMessage instead of using agent-workdirs

Errand agents are spawned in the errand's git worktree (managed by
SimpleGitWorktreeManager), not in agent-workdirs/<alias>/.
sendUserMessage was deriving the cwd from worktreeId which pointed to
the non-existent agent-workdirs path. Now the errand.sendMessage
procedure resolves the actual worktree path and passes it through.
This commit is contained in:
Lukas May
2026-03-06 23:11:55 +01:00
parent bc61e658dc
commit b17c0a2b4f
4 changed files with 21 additions and 5 deletions

View File

@@ -667,7 +667,7 @@ export class MultiProviderAgentManager implements AgentManager {
* Does not use the conversations table — the message is injected directly
* as the next resume prompt for the agent's Claude Code session.
*/
async sendUserMessage(agentId: string, message: string): Promise<void> {
async sendUserMessage(agentId: string, message: string, cwd?: string): Promise<void> {
const agent = await this.repository.findById(agentId);
if (!agent) throw new Error(`Agent not found: ${agentId}`);
@@ -682,7 +682,7 @@ export class MultiProviderAgentManager implements AgentManager {
const provider = getProvider(agent.provider);
if (!provider) throw new Error(`Unknown provider: ${agent.provider}`);
const agentCwd = this.processManager.getAgentWorkdir(agent.worktreeId);
const agentCwd = cwd ?? this.processManager.getAgentWorkdir(agent.worktreeId);
// Clear previous signal.json
const signalPath = join(agentCwd, '.cw/output/signal.json');