fix: restart backend under systemd and use .sproutclaw agent dir

Restart via systemctl when running as a service, set SPROUTCLAW_CODING_AGENT_DIR
for the RPC subprocess, and add a frontend poll timeout for failed restarts.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-24 10:29:28 +08:00
parent 767a776a3e
commit bd2251e89a
7 changed files with 123 additions and 32 deletions

View File

@@ -32,8 +32,8 @@ type Config struct {
func New() *Config {
port := flag.Int("port", 19133, "HTTP port")
agentDir := flag.String("agent-dir", "", "pi agent directory (e.g. /path/to/.pi/agent)")
repoRoot := flag.String("repo-root", "", "pi repo root (pi CLI cwd); defaults to two levels above agent-dir")
agentDir := flag.String("agent-dir", "", "SproutClaw agent directory (e.g. /path/to/.sproutclaw/agent)")
repoRoot := flag.String("repo-root", "", "SproutClaw repo root (CLI cwd); defaults to two levels above agent-dir")
dataDir := flag.String("data-dir", "", "sproutclaw-web data dir for SQLite (defaults to ./data)")
piCmd := flag.String("pi-cmd", "", "pi CLI command (may include args, e.g. \"node /path/tsx.mjs /path/cli.ts\")")
frontendDist := flag.String("frontend-dist", "", "path to frontend/dist (defaults to ../frontend/dist relative to binary)")
@@ -41,7 +41,7 @@ func New() *Config {
if *agentDir == "" {
cwd, _ := os.Getwd()
*agentDir = filepath.Join(cwd, ".pi", "agent")
*agentDir = filepath.Join(cwd, ".sproutclaw", "agent")
}
cfg := &Config{
@@ -50,7 +50,7 @@ func New() *Config {
RepoRoot: *repoRoot,
DataDir: *dataDir,
}
// repoRoot defaults to the directory two levels above agentDir (.pi/agent -> repo root)
// repoRoot defaults to the directory two levels above agentDir (.sproutclaw/agent -> repo root)
if cfg.RepoRoot == "" {
cfg.RepoRoot = filepath.Dir(filepath.Dir(*agentDir))
}