diff --git a/apps/backend/internal/agent/agents/kiro_acp.go b/apps/backend/internal/agent/agents/kiro_acp.go index b372631696..7d57f7307d 100644 --- a/apps/backend/internal/agent/agents/kiro_acp.go +++ b/apps/backend/internal/agent/agents/kiro_acp.go @@ -89,12 +89,14 @@ func (a *KiroACP) Runtime() *RuntimeConfig { Protocol: agent.ProtocolACP, UserSkillDir: ".kiro/skills", SessionConfig: SessionConfig{ - // TODO: set SessionDirTemplate once the Kiro session dir is - // confirmed (likely "{home}/.kiro"). Without it, the Docker - // runtime skips mounting the session dir, so NativeSessionResume - // has no persistence across container restarts. ACP-native - // session/load still works in standalone mode where the host - // home dir is the working filesystem. + // Verified against Kiro CLI 2.15.0 by driving `kiro-cli-chat acp` + // through session/new: each ACP session is persisted as + // ~/.kiro/sessions/cli/.{json,jsonl}. KIRO_HOME + // relocates the directory. Note ~/.kiro carries config + sessions + // only — the login token lives in the separate + // ~/.local/share/kiro-cli/data.sqlite3 (auth_kv table), so this + // mount persists resumable sessions but not authentication. + SessionDirTemplate: "{home}/.kiro", NativeSessionResume: true, CanRecover: &canRecover, }, diff --git a/apps/backend/internal/agent/agents/new_acp_agents_test.go b/apps/backend/internal/agent/agents/new_acp_agents_test.go index f22f806b18..76b9477661 100644 --- a/apps/backend/internal/agent/agents/new_acp_agents_test.go +++ b/apps/backend/internal/agent/agents/new_acp_agents_test.go @@ -30,6 +30,13 @@ type acpAgentSpec struct { installViaNpm bool // InstallScript starts with "npm install -g" installScript string // expected InstallScript() value (empty = unchecked) stripEnv []string // expected Runtime().StripEnv (nil = unchecked) + // sessionDirTemplate is the agent's on-disk session root. Pinned per + // agent because it is derived from what the CLI actually writes (see the + // evidence comment on each Runtime()), not from a naming convention — + // Trae and Devin both diverge from the "{home}/." shape, and a + // wrong value silently bind-mounts the wrong directory into the + // container. + sessionDirTemplate string } var newACPAgentSpecs = []struct { @@ -38,38 +45,43 @@ var newACPAgentSpecs = []struct { }{ {func() Agent { return NewQwenACP() }, acpAgentSpec{ id: "qwen-acp", displayName: "Qwen", detectBinaries: []string{"qwen"}, - expectedArgv: []string{"npx", "-y", "@qwen-code/qwen-code", "--acp"}, - inferenceArgv: []string{"npx", "-y", "@qwen-code/qwen-code", "--acp"}, - passthroughArgv: []string{"npx", "-y", "@qwen-code/qwen-code"}, - installViaNpm: true, + expectedArgv: []string{"npx", "-y", "@qwen-code/qwen-code", "--acp"}, + inferenceArgv: []string{"npx", "-y", "@qwen-code/qwen-code", "--acp"}, + passthroughArgv: []string{"npx", "-y", "@qwen-code/qwen-code"}, + installViaNpm: true, + sessionDirTemplate: "{home}/.qwen", }}, {func() Agent { return NewIFlowACP() }, acpAgentSpec{ id: "iflow-acp", displayName: "iFlow (beta)", detectBinaries: []string{"iflow"}, - expectedArgv: []string{"npx", "-y", "@iflow-ai/iflow-cli", "--experimental-acp"}, - inferenceArgv: []string{"npx", "-y", "@iflow-ai/iflow-cli", "--experimental-acp"}, - passthroughArgv: []string{"npx", "-y", "@iflow-ai/iflow-cli"}, - installViaNpm: true, + expectedArgv: []string{"npx", "-y", "@iflow-ai/iflow-cli", "--experimental-acp"}, + inferenceArgv: []string{"npx", "-y", "@iflow-ai/iflow-cli", "--experimental-acp"}, + passthroughArgv: []string{"npx", "-y", "@iflow-ai/iflow-cli"}, + installViaNpm: true, + sessionDirTemplate: "{home}/.iflow", }}, {func() Agent { return NewDroidACP() }, acpAgentSpec{ id: "droid-acp", displayName: "Droid", detectBinaries: []string{"droid"}, - expectedArgv: []string{"npx", "-y", "droid", "exec", "--output-format", "acp"}, - inferenceArgv: []string{"npx", "-y", "droid", "exec", "--output-format", "acp"}, - passthroughArgv: []string{"npx", "-y", "droid"}, - installViaNpm: true, + expectedArgv: []string{"npx", "-y", "droid", "exec", "--output-format", "acp"}, + inferenceArgv: []string{"npx", "-y", "droid", "exec", "--output-format", "acp"}, + passthroughArgv: []string{"npx", "-y", "droid"}, + installViaNpm: true, + sessionDirTemplate: "{home}/.factory", }}, {func() Agent { return NewKilocodeACP() }, acpAgentSpec{ id: "kilocode-acp", displayName: "Kilocode", detectBinaries: []string{"kilo", "kilocode"}, - expectedArgv: []string{"npx", "-y", "@kilocode/cli", "acp"}, - inferenceArgv: []string{"npx", "-y", "@kilocode/cli", "acp"}, - passthroughArgv: []string{"npx", "-y", "@kilocode/cli"}, - installViaNpm: true, + expectedArgv: []string{"npx", "-y", "@kilocode/cli", "acp"}, + inferenceArgv: []string{"npx", "-y", "@kilocode/cli", "acp"}, + passthroughArgv: []string{"npx", "-y", "@kilocode/cli"}, + installViaNpm: true, + sessionDirTemplate: "{home}/.kilocode", }}, {func() Agent { return NewPiACP() }, acpAgentSpec{ id: "pi-acp", displayName: "Pi", detectBinaries: []string{"pi-acp", "pi"}, - expectedArgv: []string{"npx", "-y", "pi-acp"}, - inferenceArgv: []string{"npx", "-y", "pi-acp"}, - passthroughArgv: []string{"npx", "-y", "pi-acp"}, - installViaNpm: true, + expectedArgv: []string{"npx", "-y", "pi-acp"}, + inferenceArgv: []string{"npx", "-y", "pi-acp"}, + passthroughArgv: []string{"npx", "-y", "pi-acp"}, + installViaNpm: true, + sessionDirTemplate: "{home}/.pi", }}, {func() Agent { return NewCursorACP() }, acpAgentSpec{ id: "cursor-acp", displayName: "Cursor", detectBinaries: []string{"cursor-agent"}, @@ -87,49 +99,56 @@ bash "$tmp" rm -f "$tmp" export PATH="$HOME/.local/bin:$PATH" grep -qxF 'export PATH="$HOME/.local/bin:$PATH"' "$HOME/.bashrc" 2>/dev/null || echo 'export PATH="$HOME/.local/bin:$PATH"' >> "$HOME/.bashrc"`, + sessionDirTemplate: "{home}/.cursor", }}, {func() Agent { return NewKimiACP() }, acpAgentSpec{ id: "kimi-acp", displayName: "Kimi", detectBinaries: []string{"kimi"}, - expectedArgv: []string{"kimi", "acp"}, - inferenceArgv: []string{"kimi", "acp"}, - passthroughArgv: []string{"kimi"}, - installViaNpm: false, + expectedArgv: []string{"kimi", "acp"}, + inferenceArgv: []string{"kimi", "acp"}, + passthroughArgv: []string{"kimi"}, + installViaNpm: false, + sessionDirTemplate: "{home}/.kimi", }}, {func() Agent { return NewKiroACP() }, acpAgentSpec{ id: "kiro-acp", displayName: "Kiro", detectBinaries: []string{"kiro-cli-chat"}, - expectedArgv: []string{"kiro-cli-chat", "acp"}, - inferenceArgv: []string{"kiro-cli-chat", "acp"}, - passthroughArgv: []string{"kiro-cli-chat"}, - installViaNpm: false, + expectedArgv: []string{"kiro-cli-chat", "acp"}, + inferenceArgv: []string{"kiro-cli-chat", "acp"}, + passthroughArgv: []string{"kiro-cli-chat"}, + installViaNpm: false, + sessionDirTemplate: "{home}/.kiro", }}, {func() Agent { return NewQoderACP() }, acpAgentSpec{ id: "qoder-acp", displayName: "Qoder", detectBinaries: []string{"qodercli"}, - expectedArgv: []string{"qodercli", "--acp"}, - inferenceArgv: []string{"qodercli", "--acp"}, - passthroughArgv: []string{"qodercli"}, - installViaNpm: false, + expectedArgv: []string{"qodercli", "--acp"}, + inferenceArgv: []string{"qodercli", "--acp"}, + passthroughArgv: []string{"qodercli"}, + installViaNpm: false, + sessionDirTemplate: "{home}/.qoder", }}, {func() Agent { return NewTraeACP() }, acpAgentSpec{ id: "trae-acp", displayName: "Trae", detectBinaries: []string{"traecli"}, - expectedArgv: []string{"traecli", "acp", "serve"}, - inferenceArgv: []string{"traecli", "acp", "serve"}, - passthroughArgv: []string{"traecli"}, - installViaNpm: false, + expectedArgv: []string{"traecli", "acp", "serve"}, + inferenceArgv: []string{"traecli", "acp", "serve"}, + passthroughArgv: []string{"traecli"}, + installViaNpm: false, + sessionDirTemplate: "{home}/.cache/trae-cli", }}, {func() Agent { return NewOmpACP() }, acpAgentSpec{ id: "omp-acp", displayName: "omp", detectBinaries: []string{"omp"}, - expectedArgv: []string{"omp", "acp"}, - inferenceArgv: []string{"omp", "acp"}, - passthroughArgv: []string{"omp"}, - installViaNpm: false, + expectedArgv: []string{"omp", "acp"}, + inferenceArgv: []string{"omp", "acp"}, + passthroughArgv: []string{"omp"}, + installViaNpm: false, + sessionDirTemplate: "{home}/.omp", }}, {func() Agent { return NewDevinACP() }, acpAgentSpec{ id: "devin-acp", displayName: "Devin", detectBinaries: []string{"devin"}, - expectedArgv: []string{"devin", "acp"}, - inferenceArgv: []string{"devin", "acp"}, - passthroughArgv: []string{"devin"}, - installViaNpm: false, - stripEnv: []string{"ACP_BACKEND"}, + expectedArgv: []string{"devin", "acp"}, + inferenceArgv: []string{"devin", "acp"}, + passthroughArgv: []string{"devin"}, + installViaNpm: false, + stripEnv: []string{"ACP_BACKEND"}, + sessionDirTemplate: "{home}/.local/share/devin", }}, } @@ -196,6 +215,30 @@ func TestNewACPAgents_AllCommandSurfaces(t *testing.T) { } } +// TestNewACPAgents_SessionDirTemplate pins the session root each agent +// declares. The lifecycle manager turns SessionDirTemplate into the +// bind-mount source under /agent-sessions//, so an +// unset value means an agent's own session state is quietly lost on every +// container restart, and a wrong value mounts a directory the CLI never +// reads. +func TestNewACPAgents_SessionDirTemplate(t *testing.T) { + for _, tc := range newACPAgentSpecs { + t.Run(tc.spec.id, func(t *testing.T) { + rt := tc.new().Runtime() + if rt == nil { + t.Fatalf("Runtime() returned nil") + } + if got := rt.SessionConfig.SessionDirTemplate; got != tc.spec.sessionDirTemplate { + t.Errorf("SessionDirTemplate = %q, want %q", got, tc.spec.sessionDirTemplate) + } + if !strings.HasPrefix(tc.spec.sessionDirTemplate, "{home}/") { + t.Errorf("SessionDirTemplate %q must be {home}-relative; SessionDirHostPath only trims that prefix", + tc.spec.sessionDirTemplate) + } + }) + } +} + func TestNewACPAgents_InstallScript(t *testing.T) { for _, tc := range newACPAgentSpecs { t.Run(tc.spec.id, func(t *testing.T) { diff --git a/apps/backend/internal/agent/agents/pi_acp.go b/apps/backend/internal/agent/agents/pi_acp.go index 03d3958db1..ae3bdf4679 100644 --- a/apps/backend/internal/agent/agents/pi_acp.go +++ b/apps/backend/internal/agent/agents/pi_acp.go @@ -96,10 +96,12 @@ func (a *PiACP) Runtime() *RuntimeConfig { UserSkillDir: ".pi/agent/skills", ProjectMCPStrategy: mcpconfig.PiStrategy{}, SessionConfig: SessionConfig{ - // TODO: set SessionDirTemplate once the Pi session dir is - // confirmed. Without it, the Docker runtime skips mounting the - // session dir, so NativeSessionResume has no persistence across - // container restarts. + // Verified against pi-acp@0.0.32: the adapter keeps the ACP↔pi + // session map in ~/.pi/pi-acp/session-map.json and reads pi's own + // transcripts from ~/.pi/agent/sessions (relocatable via + // PI_CODING_AGENT_DIR or a sessionDir in ~/.pi/agent/settings.json). + // Both halves of session/load live under ~/.pi. + SessionDirTemplate: "{home}/.pi", NativeSessionResume: true, CanRecover: &canRecover, }, diff --git a/apps/backend/internal/agent/agents/qoder_acp.go b/apps/backend/internal/agent/agents/qoder_acp.go index 263ef8d842..cc704619f0 100644 --- a/apps/backend/internal/agent/agents/qoder_acp.go +++ b/apps/backend/internal/agent/agents/qoder_acp.go @@ -87,10 +87,11 @@ func (a *QoderACP) Runtime() *RuntimeConfig { ResourceLimits: ResourceLimits{MemoryMB: 4096, CPUCores: 2.0, Timeout: time.Hour}, Protocol: agent.ProtocolACP, SessionConfig: SessionConfig{ - // TODO: set SessionDirTemplate once the Qoder session dir is - // confirmed. Without it, the Docker runtime skips mounting the - // session dir, so NativeSessionResume has no persistence across - // container restarts. + // Verified against qodercli 1.1.7: every user-level artifact + // (settings.json, .auth/, logs/sessions/) is written + // under ~/.qoder, and the --config-dir flag relocates that single + // root wholesale — running with it leaves nothing else in $HOME. + SessionDirTemplate: "{home}/.qoder", NativeSessionResume: true, CanRecover: &canRecover, }, diff --git a/apps/backend/internal/agent/agents/trae_acp.go b/apps/backend/internal/agent/agents/trae_acp.go index 0887263751..8366dd4eb4 100644 --- a/apps/backend/internal/agent/agents/trae_acp.go +++ b/apps/backend/internal/agent/agents/trae_acp.go @@ -86,10 +86,16 @@ func (a *TraeACP) Runtime() *RuntimeConfig { ResourceLimits: ResourceLimits{MemoryMB: 4096, CPUCores: 2.0, Timeout: time.Hour}, Protocol: agent.ProtocolACP, SessionConfig: SessionConfig{ - // TODO: set SessionDirTemplate once the Trae session dir is - // confirmed. Without it, the Docker runtime skips mounting the - // session dir, so NativeSessionResume has no persistence across - // container restarts. + // Verified against Trae CLI 0.120.48 by driving `traecli acp + // serve` through session/new + session/prompt: the ACP session ID + // appears as ~/.cache/trae-cli/sessions//, which is + // where the CLI persists conversation history and metadata. + // ~/.trae holds config only (traecli.yaml, skills, agents, + // commands) and the login token lives in the OS keyring, not a + // file, so neither belongs here. The published manual still + // documents the older ~/.cache/coco/ cache root; the shipped + // binary uses ~/.cache/trae-cli, so re-check this on upgrades. + SessionDirTemplate: "{home}/.cache/trae-cli", NativeSessionResume: true, CanRecover: &canRecover, },