fleetdeck 0.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fleetdeck/__init__.py +3 -0
- fleetdeck/__main__.py +232 -0
- fleetdeck/accounts.py +115 -0
- fleetdeck/adapters/__init__.py +0 -0
- fleetdeck/adapters/base.py +71 -0
- fleetdeck/adapters/claude_cli.py +187 -0
- fleetdeck/adapters/codex_cli.py +362 -0
- fleetdeck/adapters/demo.py +331 -0
- fleetdeck/config.py +323 -0
- fleetdeck/db.py +511 -0
- fleetdeck/gitinfo.py +169 -0
- fleetdeck/models.py +178 -0
- fleetdeck/paths.py +64 -0
- fleetdeck/proc.py +92 -0
- fleetdeck/redact.py +51 -0
- fleetdeck/services/__init__.py +0 -0
- fleetdeck/services/dispatcher.py +382 -0
- fleetdeck/services/fleet.py +65 -0
- fleetdeck/services/monitor.py +253 -0
- fleetdeck/services/notifier.py +71 -0
- fleetdeck/status.py +97 -0
- fleetdeck/terminal.py +235 -0
- fleetdeck/termrender.py +129 -0
- fleetdeck/ui/__init__.py +0 -0
- fleetdeck/ui/app.py +1295 -0
- fleetdeck/ui/app.tcss +263 -0
- fleetdeck/ui/commands.py +63 -0
- fleetdeck/ui/screens/__init__.py +0 -0
- fleetdeck/ui/screens/modals.py +623 -0
- fleetdeck/ui/style.py +150 -0
- fleetdeck/ui/views.py +230 -0
- fleetdeck/ui/widgets/__init__.py +0 -0
- fleetdeck/ui/widgets/agent_table.py +185 -0
- fleetdeck/ui/widgets/bottom.py +27 -0
- fleetdeck/ui/widgets/details.py +295 -0
- fleetdeck/ui/widgets/header.py +87 -0
- fleetdeck/ui/widgets/sidebar.py +227 -0
- fleetdeck/ui/widgets/splitter.py +66 -0
- fleetdeck/ui/widgets/terminal.py +119 -0
- fleetdeck-0.3.0.dist-info/METADATA +245 -0
- fleetdeck-0.3.0.dist-info/RECORD +44 -0
- fleetdeck-0.3.0.dist-info/WHEEL +4 -0
- fleetdeck-0.3.0.dist-info/entry_points.txt +2 -0
- fleetdeck-0.3.0.dist-info/licenses/LICENSE +21 -0
fleetdeck/models.py
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"""Domain models shared by the adapters, services and UI."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import time
|
|
6
|
+
from dataclasses import dataclass, field
|
|
7
|
+
from enum import Enum
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class AgentStatus(str, Enum):
|
|
11
|
+
"""Dashboard status. Only derived from fields Claude Code actually reports."""
|
|
12
|
+
|
|
13
|
+
RUNNING = "running"
|
|
14
|
+
WAITING = "waiting"
|
|
15
|
+
PERMISSION = "permission"
|
|
16
|
+
PLANNING = "planning"
|
|
17
|
+
COMPLETED = "completed"
|
|
18
|
+
FAILED = "failed"
|
|
19
|
+
IDLE = "idle"
|
|
20
|
+
STOPPED = "stopped"
|
|
21
|
+
UNKNOWN = "unknown"
|
|
22
|
+
|
|
23
|
+
@property
|
|
24
|
+
def label(self) -> str:
|
|
25
|
+
return {
|
|
26
|
+
AgentStatus.RUNNING: "Running",
|
|
27
|
+
AgentStatus.WAITING: "Waiting for input",
|
|
28
|
+
AgentStatus.PERMISSION: "Permission required",
|
|
29
|
+
AgentStatus.PLANNING: "Planning",
|
|
30
|
+
AgentStatus.COMPLETED: "Completed",
|
|
31
|
+
AgentStatus.FAILED: "Failed",
|
|
32
|
+
AgentStatus.IDLE: "Idle",
|
|
33
|
+
AgentStatus.STOPPED: "Stopped",
|
|
34
|
+
AgentStatus.UNKNOWN: "Unknown",
|
|
35
|
+
}[self]
|
|
36
|
+
|
|
37
|
+
@property
|
|
38
|
+
def is_active(self) -> bool:
|
|
39
|
+
"""Occupies a concurrency slot (process doing or about to do work)."""
|
|
40
|
+
return self in (
|
|
41
|
+
AgentStatus.RUNNING,
|
|
42
|
+
AgentStatus.PLANNING,
|
|
43
|
+
AgentStatus.WAITING,
|
|
44
|
+
AgentStatus.PERMISSION,
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
@property
|
|
48
|
+
def needs_attention(self) -> bool:
|
|
49
|
+
return self in (AgentStatus.WAITING, AgentStatus.PERMISSION, AgentStatus.FAILED)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class TaskStatus(str, Enum):
|
|
53
|
+
QUEUED = "queued"
|
|
54
|
+
DISPATCHING = "dispatching"
|
|
55
|
+
RUNNING = "running"
|
|
56
|
+
BLOCKED = "blocked"
|
|
57
|
+
COMPLETED = "completed"
|
|
58
|
+
FAILED = "failed"
|
|
59
|
+
CANCELLED = "cancelled"
|
|
60
|
+
|
|
61
|
+
@property
|
|
62
|
+
def is_terminal(self) -> bool:
|
|
63
|
+
return self in (TaskStatus.COMPLETED, TaskStatus.FAILED, TaskStatus.CANCELLED)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
PROJECT_GROUPS = ("office", "personal")
|
|
67
|
+
|
|
68
|
+
# Permission modes the command center will pass to `claude`. bypassPermissions
|
|
69
|
+
# and dontAsk are deliberately absent: the dashboard must never weaken
|
|
70
|
+
# Claude Code's native approval flow.
|
|
71
|
+
SAFE_PERMISSION_MODES = ("default", "plan", "acceptEdits", "auto")
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
@dataclass(slots=True)
|
|
75
|
+
class Agent:
|
|
76
|
+
"""A Claude Code session as reported by `claude agents --json --all`."""
|
|
77
|
+
|
|
78
|
+
key: str # stable identity: short id for background, sessionId/pid for interactive
|
|
79
|
+
kind: str # "interactive" | "background"
|
|
80
|
+
cwd: str
|
|
81
|
+
started_at: float # unix seconds
|
|
82
|
+
status: AgentStatus
|
|
83
|
+
id: str | None = None # short id (background sessions only)
|
|
84
|
+
name: str | None = None
|
|
85
|
+
session_id: str | None = None
|
|
86
|
+
pid: int | None = None
|
|
87
|
+
raw_state: str | None = None
|
|
88
|
+
raw_status: str | None = None
|
|
89
|
+
waiting_for: str | None = None
|
|
90
|
+
# enrichment (never fabricated: None means "not known")
|
|
91
|
+
project_id: int | None = None
|
|
92
|
+
project_name: str | None = None
|
|
93
|
+
branch: str | None = None
|
|
94
|
+
model: str | None = None
|
|
95
|
+
task_title: str | None = None
|
|
96
|
+
task_id: int | None = None
|
|
97
|
+
permission_mode: str | None = None
|
|
98
|
+
last_activity: float | None = None
|
|
99
|
+
account: str | None = None # account name the session belongs to
|
|
100
|
+
provider: str = "claude" # claude | codex
|
|
101
|
+
usage: dict | None = None # token usage, only when the CLI reports it (Codex)
|
|
102
|
+
|
|
103
|
+
@property
|
|
104
|
+
def display_name(self) -> str:
|
|
105
|
+
return self.name or self.id or (self.session_id or "")[:8] or f"pid {self.pid}"
|
|
106
|
+
|
|
107
|
+
@property
|
|
108
|
+
def controllable(self) -> bool:
|
|
109
|
+
"""Only background sessions can be attached/logged/stopped by id."""
|
|
110
|
+
return self.kind == "background" and bool(self.id)
|
|
111
|
+
|
|
112
|
+
@property
|
|
113
|
+
def pending_approvals(self) -> int:
|
|
114
|
+
return 1 if self.status is AgentStatus.PERMISSION else 0
|
|
115
|
+
|
|
116
|
+
def elapsed(self, now: float | None = None) -> float:
|
|
117
|
+
return max(0.0, (now or time.time()) - self.started_at)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
@dataclass(slots=True)
|
|
121
|
+
class Project:
|
|
122
|
+
id: int
|
|
123
|
+
name: str
|
|
124
|
+
path: str
|
|
125
|
+
group: str = "personal"
|
|
126
|
+
pinned: bool = False
|
|
127
|
+
environment: str = "default"
|
|
128
|
+
instructions: str = ""
|
|
129
|
+
always_worktree: bool = False
|
|
130
|
+
test_command: str = ""
|
|
131
|
+
env: dict[str, str] = field(default_factory=dict)
|
|
132
|
+
created_at: float = 0.0
|
|
133
|
+
account: str | None = None # default account for agents launched here
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
@dataclass(slots=True)
|
|
137
|
+
class Task:
|
|
138
|
+
id: int
|
|
139
|
+
project_id: int
|
|
140
|
+
title: str
|
|
141
|
+
prompt: str
|
|
142
|
+
priority: int = 2 # 1 = urgent … 4 = low
|
|
143
|
+
status: TaskStatus = TaskStatus.QUEUED
|
|
144
|
+
agent_id: str | None = None
|
|
145
|
+
agent_name: str | None = None
|
|
146
|
+
model: str | None = None
|
|
147
|
+
permission_mode: str | None = None
|
|
148
|
+
use_worktree: bool = False
|
|
149
|
+
attempts: int = 0
|
|
150
|
+
error: str | None = None
|
|
151
|
+
created_at: float = 0.0
|
|
152
|
+
started_at: float | None = None
|
|
153
|
+
finished_at: float | None = None
|
|
154
|
+
depends_on: int | None = None # run only after this task completes
|
|
155
|
+
resume_session: str | None = None # follow-up: continue this session (full UUID)
|
|
156
|
+
resume_agent: str | None = None # follow-up: short id of that session
|
|
157
|
+
account: str | None = None # which account runs it (None = project/active default)
|
|
158
|
+
|
|
159
|
+
@property
|
|
160
|
+
def is_follow_up(self) -> bool:
|
|
161
|
+
return bool(self.resume_session)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
@dataclass(slots=True)
|
|
165
|
+
class Template:
|
|
166
|
+
id: int
|
|
167
|
+
name: str
|
|
168
|
+
body: str
|
|
169
|
+
created_at: float = 0.0
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
@dataclass(slots=True)
|
|
173
|
+
class Activity:
|
|
174
|
+
id: int
|
|
175
|
+
ts: float
|
|
176
|
+
level: str # info | success | warning | error
|
|
177
|
+
message: str
|
|
178
|
+
project_id: int | None = None
|
fleetdeck/paths.py
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"""Filesystem locations. Override everything with FLEETDECK_HOME."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
import shutil
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
# Before the rename the app was "claude-command-center" (command claude-center).
|
|
10
|
+
LEGACY_ENV = "CLAUDE_CENTER_HOME"
|
|
11
|
+
LEGACY_DIRNAME = "claude-center"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _config_base() -> Path:
|
|
15
|
+
xdg = os.environ.get("XDG_CONFIG_HOME")
|
|
16
|
+
return Path(xdg).expanduser() if xdg else Path.home() / ".config"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def home_dir() -> Path:
|
|
20
|
+
override = os.environ.get("FLEETDECK_HOME") or os.environ.get(LEGACY_ENV)
|
|
21
|
+
if override:
|
|
22
|
+
return Path(override).expanduser()
|
|
23
|
+
return _config_base() / "fleetdeck"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def legacy_home() -> Path:
|
|
27
|
+
return _config_base() / LEGACY_DIRNAME
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def migrate_legacy_home() -> Path | None:
|
|
31
|
+
"""Copy ~/.config/claude-center to ~/.config/fleetdeck once.
|
|
32
|
+
|
|
33
|
+
Copies (never moves), so the old folder stays as a backup. Returns the
|
|
34
|
+
source path if a migration happened.
|
|
35
|
+
"""
|
|
36
|
+
if os.environ.get("FLEETDECK_HOME") or os.environ.get(LEGACY_ENV):
|
|
37
|
+
return None # explicit location: nothing to migrate
|
|
38
|
+
new, old = home_dir(), legacy_home()
|
|
39
|
+
if new.exists() or not old.is_dir():
|
|
40
|
+
return None
|
|
41
|
+
shutil.copytree(old, new, ignore=shutil.ignore_patterns("demo.db*", "demo-workspace"))
|
|
42
|
+
try:
|
|
43
|
+
new.chmod(0o700)
|
|
44
|
+
except OSError:
|
|
45
|
+
pass
|
|
46
|
+
return old
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def config_path() -> Path:
|
|
50
|
+
return home_dir() / "config.yaml"
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def db_path(demo: bool = False) -> Path:
|
|
54
|
+
return home_dir() / ("demo.db" if demo else "center.db")
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def ensure_private_dir(path: Path) -> Path:
|
|
58
|
+
"""Create ``path`` (0700) so config, history and logs stay user-private."""
|
|
59
|
+
path.mkdir(parents=True, exist_ok=True)
|
|
60
|
+
try:
|
|
61
|
+
path.chmod(0o700)
|
|
62
|
+
except OSError:
|
|
63
|
+
pass
|
|
64
|
+
return path
|
fleetdeck/proc.py
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"""Subprocess helper: async, bounded, killable, never inherits the TTY."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
import os
|
|
7
|
+
import signal
|
|
8
|
+
from typing import Mapping, Sequence
|
|
9
|
+
|
|
10
|
+
_LIVE: set[asyncio.subprocess.Process] = set()
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class CommandNotFound(RuntimeError):
|
|
14
|
+
pass
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
async def run(
|
|
18
|
+
argv: Sequence[str],
|
|
19
|
+
*,
|
|
20
|
+
cwd: str | None = None,
|
|
21
|
+
env: Mapping[str, str] | None = None,
|
|
22
|
+
timeout: float = 15.0,
|
|
23
|
+
stdin_data: bytes | None = None,
|
|
24
|
+
track: bool = True,
|
|
25
|
+
) -> tuple[int, str, str]:
|
|
26
|
+
"""Run ``argv`` and return (returncode, stdout, stderr).
|
|
27
|
+
|
|
28
|
+
Returns code 124 on timeout (the process group is killed). Raises
|
|
29
|
+
CommandNotFound if the executable does not exist. ``track=False`` keeps the
|
|
30
|
+
process out of kill_all(), for commands that must not die with the UI
|
|
31
|
+
(e.g. `claude --bg`, which may still be handing off its session).
|
|
32
|
+
"""
|
|
33
|
+
full_env = dict(os.environ)
|
|
34
|
+
if env:
|
|
35
|
+
full_env.update(env)
|
|
36
|
+
try:
|
|
37
|
+
proc = await asyncio.create_subprocess_exec(
|
|
38
|
+
*argv,
|
|
39
|
+
cwd=cwd,
|
|
40
|
+
env=full_env,
|
|
41
|
+
stdin=asyncio.subprocess.PIPE if stdin_data is not None else asyncio.subprocess.DEVNULL,
|
|
42
|
+
stdout=asyncio.subprocess.PIPE,
|
|
43
|
+
stderr=asyncio.subprocess.PIPE,
|
|
44
|
+
start_new_session=True, # own process group: clean kill, no TTY signals
|
|
45
|
+
)
|
|
46
|
+
except FileNotFoundError as exc:
|
|
47
|
+
raise CommandNotFound(argv[0]) from exc
|
|
48
|
+
if track:
|
|
49
|
+
_LIVE.add(proc)
|
|
50
|
+
try:
|
|
51
|
+
out, err = await asyncio.wait_for(proc.communicate(stdin_data), timeout=timeout)
|
|
52
|
+
except asyncio.TimeoutError:
|
|
53
|
+
if track:
|
|
54
|
+
_kill(proc)
|
|
55
|
+
await proc.wait()
|
|
56
|
+
# untracked (e.g. `claude --bg`): stop waiting but let it finish its
|
|
57
|
+
# hand-off; killing its process group could take the session with it.
|
|
58
|
+
return 124, "", f"timed out after {timeout:.0f}s: {' '.join(argv[:3])}"
|
|
59
|
+
except asyncio.CancelledError:
|
|
60
|
+
if track:
|
|
61
|
+
_kill(proc)
|
|
62
|
+
raise
|
|
63
|
+
finally:
|
|
64
|
+
_LIVE.discard(proc)
|
|
65
|
+
return (
|
|
66
|
+
proc.returncode if proc.returncode is not None else -1,
|
|
67
|
+
out.decode("utf-8", "replace"),
|
|
68
|
+
err.decode("utf-8", "replace"),
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def _kill(proc: asyncio.subprocess.Process) -> None:
|
|
73
|
+
if proc.returncode is not None:
|
|
74
|
+
return
|
|
75
|
+
try:
|
|
76
|
+
os.killpg(proc.pid, signal.SIGTERM)
|
|
77
|
+
except (ProcessLookupError, PermissionError):
|
|
78
|
+
try:
|
|
79
|
+
proc.kill()
|
|
80
|
+
except ProcessLookupError:
|
|
81
|
+
pass
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def kill_all() -> None:
|
|
85
|
+
"""Terminate helper subprocesses still running (used on shutdown).
|
|
86
|
+
|
|
87
|
+
This only affects short-lived helper commands spawned by the dashboard;
|
|
88
|
+
Claude background sessions are owned by Claude Code's supervisor and keep
|
|
89
|
+
running after the dashboard exits.
|
|
90
|
+
"""
|
|
91
|
+
for proc in list(_LIVE):
|
|
92
|
+
_kill(proc)
|
fleetdeck/redact.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""Best-effort secret redaction for anything rendered in the dashboard."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import re
|
|
6
|
+
|
|
7
|
+
MASK = "‹redacted›"
|
|
8
|
+
|
|
9
|
+
_PATTERNS: list[tuple[re.Pattern[str], str]] = [
|
|
10
|
+
# PEM private keys (multi-line)
|
|
11
|
+
(
|
|
12
|
+
re.compile(
|
|
13
|
+
r"-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----.*?-----END [A-Z0-9 ]*PRIVATE KEY-----",
|
|
14
|
+
re.DOTALL,
|
|
15
|
+
),
|
|
16
|
+
MASK,
|
|
17
|
+
),
|
|
18
|
+
# Provider-specific tokens
|
|
19
|
+
(re.compile(r"sk-ant-[A-Za-z0-9_\-]{10,}"), MASK),
|
|
20
|
+
(re.compile(r"\bsk-(?:proj-)?[A-Za-z0-9_\-]{20,}"), MASK),
|
|
21
|
+
(re.compile(r"\bgh[pousr]_[A-Za-z0-9]{20,}"), MASK),
|
|
22
|
+
(re.compile(r"\bgithub_pat_[A-Za-z0-9_]{20,}"), MASK),
|
|
23
|
+
(re.compile(r"\bxox[abprs]-[A-Za-z0-9\-]{10,}"), MASK),
|
|
24
|
+
(re.compile(r"\b(?:AKIA|ASIA)[0-9A-Z]{16}\b"), MASK),
|
|
25
|
+
(re.compile(r"\bAIza[0-9A-Za-z_\-]{35}\b"), MASK),
|
|
26
|
+
(re.compile(r"\bglpat-[A-Za-z0-9_\-]{20,}"), MASK),
|
|
27
|
+
# JWTs
|
|
28
|
+
(re.compile(r"\beyJ[A-Za-z0-9_\-]{8,}\.[A-Za-z0-9_\-]{8,}\.[A-Za-z0-9_\-]{8,}"), MASK),
|
|
29
|
+
# Authorization headers
|
|
30
|
+
(re.compile(r"(?i)(authorization\s*[:=]\s*(?:bearer|basic|token)\s+)[^\s'\"]+"), r"\1" + MASK),
|
|
31
|
+
(re.compile(r"(?i)\b(bearer\s+)[A-Za-z0-9._~+/\-]{16,}=*"), r"\1" + MASK),
|
|
32
|
+
# URLs with embedded credentials
|
|
33
|
+
(re.compile(r"(?i)\b([a-z][a-z0-9+.\-]*://[^\s:/@]+:)[^\s@/]+@"), r"\1" + MASK + "@"),
|
|
34
|
+
# key=value / key: value for secret-looking keys
|
|
35
|
+
(
|
|
36
|
+
re.compile(
|
|
37
|
+
r"(?i)\b([A-Z0-9_]*(?:PASSWORD|PASSWD|SECRET|TOKEN|API[_-]?KEY|ACCESS[_-]?KEY|PRIVATE[_-]?KEY|CLIENT[_-]?SECRET)[A-Z0-9_]*"
|
|
38
|
+
r"[\"']?\s*[:=]\s*[\"']?)([^\s\"',;]{4,})"
|
|
39
|
+
),
|
|
40
|
+
r"\1" + MASK,
|
|
41
|
+
),
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def redact(text: str) -> str:
|
|
46
|
+
"""Return ``text`` with credential-shaped substrings masked."""
|
|
47
|
+
if not text:
|
|
48
|
+
return text
|
|
49
|
+
for pattern, repl in _PATTERNS:
|
|
50
|
+
text = pattern.sub(repl, text)
|
|
51
|
+
return text
|
|
File without changes
|