groove-dev 0.27.41 → 0.27.42
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.
- package/CLAUDE.md +0 -7
- package/analyist/groove-security-audit.md +323 -0
- package/node_modules/@groove-dev/cli/package.json +1 -1
- package/node_modules/@groove-dev/daemon/package.json +1 -1
- package/node_modules/@groove-dev/daemon/src/api.js +11 -5
- package/node_modules/@groove-dev/daemon/src/lockmanager.js +22 -12
- package/node_modules/@groove-dev/daemon/src/process.js +3 -3
- package/node_modules/@groove-dev/daemon/src/teams.js +38 -9
- package/node_modules/@groove-dev/daemon/src/tool-executor.js +1 -1
- package/node_modules/@groove-dev/daemon/test/teams.test.js +13 -3
- package/node_modules/@groove-dev/gui/dist/assets/{index-zzVaD3-G.js → index-C1C2biHU.js} +250 -250
- package/node_modules/@groove-dev/gui/dist/index.html +1 -1
- package/node_modules/@groove-dev/gui/package.json +1 -1
- package/node_modules/@groove-dev/gui/src/components/ui/toast.jsx +1 -1
- package/node_modules/@groove-dev/gui/src/stores/groove.js +10 -5
- package/node_modules/@groove-dev/gui/src/views/agents.jsx +4 -8
- package/node_modules/@groove-dev/gui/src/views/settings.jsx +13 -0
- package/node_modules/@groove-dev/gui/vite.config.js +0 -3
- package/package.json +2 -3
- package/packages/cli/package.json +1 -1
- package/packages/daemon/package.json +1 -1
- package/packages/daemon/src/api.js +11 -5
- package/packages/daemon/src/lockmanager.js +22 -12
- package/packages/daemon/src/process.js +3 -3
- package/packages/daemon/src/teams.js +38 -9
- package/packages/daemon/src/tool-executor.js +1 -1
- package/packages/gui/dist/assets/{index-zzVaD3-G.js → index-C1C2biHU.js} +250 -250
- package/packages/gui/dist/index.html +1 -1
- package/packages/gui/package.json +1 -1
- package/packages/gui/src/components/ui/toast.jsx +1 -1
- package/packages/gui/src/stores/groove.js +10 -5
- package/packages/gui/src/views/agents.jsx +4 -8
- package/packages/gui/src/views/settings.jsx +13 -0
- package/packages/gui/vite.config.js +0 -3
- package/node_modules/@groove-dev/gui/src/lib/edition.js +0 -4
- package/packages/gui/src/lib/edition.js +0 -4
package/CLAUDE.md
CHANGED
|
@@ -263,10 +263,3 @@ Audit-driven release. Multi-agent orchestration system with 7 coordination layer
|
|
|
263
263
|
- Dashboard: routing donut, cache panel, context health gauges
|
|
264
264
|
- Monitor/QC agent mode (stay active, loop)
|
|
265
265
|
- Distribution: demo video, HN launch, Twitter content
|
|
266
|
-
|
|
267
|
-
<!-- GROOVE:START -->
|
|
268
|
-
## GROOVE Orchestration (auto-injected)
|
|
269
|
-
Active agents: 0
|
|
270
|
-
See AGENTS_REGISTRY.md for full agent state.
|
|
271
|
-
**Memory policy:** GROOVE manages project memory automatically. Do not read or write MEMORY.md or .groove/memory/ files directly.
|
|
272
|
-
<!-- GROOVE:END -->
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
GROOVE SECURITY AUDIT & ANALYSIS
|
|
2
|
+
=================================
|
|
3
|
+
|
|
4
|
+
Date: April 17, 2026
|
|
5
|
+
Auditor: GROOVE Security Agent (internal, automated)
|
|
6
|
+
Version: v0.27.41
|
|
7
|
+
Scope: Full daemon, GUI, CLI, and provider architecture review
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
EXECUTIVE SUMMARY
|
|
11
|
+
-----------------
|
|
12
|
+
|
|
13
|
+
Groove is a localhost-only process manager for AI coding agents. Its security model is
|
|
14
|
+
fundamentally different from tools that bind to open ports or proxy credentials through
|
|
15
|
+
a server. The daemon hard-blocks network exposure, encrypts stored credentials with
|
|
16
|
+
machine-bound keys, validates all inputs against strict schemas, and isolates agents
|
|
17
|
+
through scope-based file locks enforced at runtime.
|
|
18
|
+
|
|
19
|
+
This report covers 12 security areas across the full codebase.
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
================================================================================
|
|
23
|
+
1. NETWORK BINDING -- LOCALHOST ONLY (ENFORCED)
|
|
24
|
+
================================================================================
|
|
25
|
+
|
|
26
|
+
The daemon binds to 127.0.0.1:31415. This is not just a default -- it is a hard
|
|
27
|
+
security policy. If anyone attempts to bind to 0.0.0.0 or ::, the daemon prints an
|
|
28
|
+
error and exits immediately. The process refuses to start.
|
|
29
|
+
|
|
30
|
+
Remote access is only available through two channels, both encrypted and authenticated:
|
|
31
|
+
|
|
32
|
+
- SSH tunnel (groove connect)
|
|
33
|
+
- Tailscale private mesh network (--host tailscale)
|
|
34
|
+
|
|
35
|
+
There is no configuration path that exposes Groove to the open internet.
|
|
36
|
+
|
|
37
|
+
Result: PASS
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
================================================================================
|
|
41
|
+
2. CORS -- RESTRICTIVE ORIGIN VALIDATION
|
|
42
|
+
================================================================================
|
|
43
|
+
|
|
44
|
+
Every HTTP request is checked against a strict origin whitelist. Only requests from
|
|
45
|
+
localhost, 127.0.0.1, or the explicitly bound Tailscale interface are allowed. Any
|
|
46
|
+
other origin is silently rejected -- the browser never receives a permissive CORS
|
|
47
|
+
header, so cross-origin requests from external websites are blocked automatically.
|
|
48
|
+
|
|
49
|
+
Result: PASS
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
================================================================================
|
|
53
|
+
3. WEBSOCKET SECURITY -- ORIGIN VERIFICATION + FEDERATION SIGNING
|
|
54
|
+
================================================================================
|
|
55
|
+
|
|
56
|
+
WebSocket upgrade requests go through the same origin check as HTTP. Non-whitelisted
|
|
57
|
+
origins have their sockets destroyed immediately -- the connection is terminated before
|
|
58
|
+
any data is exchanged.
|
|
59
|
+
|
|
60
|
+
Federation connections (daemon-to-daemon) require signed headers with a daemon ID and
|
|
61
|
+
cryptographic signature. Missing or invalid headers result in immediate socket
|
|
62
|
+
destruction.
|
|
63
|
+
|
|
64
|
+
Result: PASS
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
================================================================================
|
|
68
|
+
4. INPUT VALIDATION -- STRICT SCHEMA ENFORCEMENT
|
|
69
|
+
================================================================================
|
|
70
|
+
|
|
71
|
+
All API inputs are validated against strict patterns and size limits before processing:
|
|
72
|
+
|
|
73
|
+
Role: Alphanumeric plus dash/underscore, max 50 characters
|
|
74
|
+
Name: Alphanumeric plus dash/underscore, max 64 characters
|
|
75
|
+
Scope patterns: Max 20 patterns, each max 200 characters
|
|
76
|
+
Scope paths: No ".." (path traversal), no "/" prefix (absolute paths), no null bytes
|
|
77
|
+
Prompt: Max 50,000 characters
|
|
78
|
+
Permission: Must be "auto" or "full" (whitelist)
|
|
79
|
+
Unknown fields: Silently stripped -- only safe fields are accepted
|
|
80
|
+
|
|
81
|
+
Path traversal, absolute path injection, and null byte injection are all explicitly
|
|
82
|
+
rejected at the validation layer.
|
|
83
|
+
|
|
84
|
+
Result: PASS
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
================================================================================
|
|
88
|
+
5. CREDENTIAL ENCRYPTION -- AES-256-GCM WITH MACHINE-BOUND KEYS
|
|
89
|
+
================================================================================
|
|
90
|
+
|
|
91
|
+
Stored API keys are encrypted using AES-256-GCM, which is authenticated encryption --
|
|
92
|
+
it provides both confidentiality (nobody can read the key) and integrity (nobody can
|
|
93
|
+
tamper with the ciphertext without detection).
|
|
94
|
+
|
|
95
|
+
The encryption key is derived via scrypt from a machine-specific seed that incorporates
|
|
96
|
+
the machine's hostname, home directory path, and a 256-bit random seed. Each encryption
|
|
97
|
+
operation uses a fresh random 128-bit initialization vector.
|
|
98
|
+
|
|
99
|
+
Key properties:
|
|
100
|
+
|
|
101
|
+
- Credentials copied to another machine are unrecoverable
|
|
102
|
+
- The GCM authentication tag detects any tampering
|
|
103
|
+
- All credential files are set to owner-only read/write permissions (0o600)
|
|
104
|
+
- The random seed file itself is also owner-only (0o600)
|
|
105
|
+
|
|
106
|
+
Result: PASS
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
================================================================================
|
|
110
|
+
6. PROCESS SPAWNING -- NO SHELL INJECTION
|
|
111
|
+
================================================================================
|
|
112
|
+
|
|
113
|
+
Agent processes are spawned using Node.js spawn() with an arguments array, never
|
|
114
|
+
through a shell. This is a critical distinction -- arguments are passed as discrete
|
|
115
|
+
values, not concatenated into a string that gets interpreted by bash or zsh.
|
|
116
|
+
|
|
117
|
+
User-controlled values like model names, prompts, and agent roles are passed as literal
|
|
118
|
+
arguments. The "shell: true" option is never set anywhere in the codebase. No string
|
|
119
|
+
interpolation occurs in command construction.
|
|
120
|
+
|
|
121
|
+
Result: PASS
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
================================================================================
|
|
125
|
+
7. SCOPE-BASED AGENT ISOLATION (KNOCK PROTOCOL)
|
|
126
|
+
================================================================================
|
|
127
|
+
|
|
128
|
+
Groove implements a scope-based file isolation system that operates at two stages:
|
|
129
|
+
|
|
130
|
+
Spawn-Time Collision Check:
|
|
131
|
+
When an agent is spawned, its declared file scope patterns are checked against all
|
|
132
|
+
running agents. If two agents' scopes overlap, the second spawn fails. Two agents
|
|
133
|
+
cannot be assigned to the same files simultaneously.
|
|
134
|
+
|
|
135
|
+
Runtime Knock Protocol:
|
|
136
|
+
Every file operation an agent attempts triggers a validation check before it executes.
|
|
137
|
+
The lock manager verifies the target file path against the agent's registered scope
|
|
138
|
+
patterns. If an agent tries to write outside its scope, the operation is denied and
|
|
139
|
+
the attempt is logged to the audit trail.
|
|
140
|
+
|
|
141
|
+
Working Directory Containment:
|
|
142
|
+
Agent working directories must reside within the project directory. Paths outside the
|
|
143
|
+
project boundary are rejected at spawn time.
|
|
144
|
+
|
|
145
|
+
Important caveat: This is orchestration-level isolation, not OS-level sandboxing. Agents
|
|
146
|
+
run as the same Unix user as the daemon. The knock protocol prevents agents from
|
|
147
|
+
conflicting with each other through the tool layer, but does not provide kernel-level
|
|
148
|
+
containment like containers or seccomp. The isolation is enforced at the coordination
|
|
149
|
+
layer, which is effective for its purpose but distinct from a full sandbox.
|
|
150
|
+
|
|
151
|
+
Result: PASS
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
================================================================================
|
|
155
|
+
8. PROTOTYPE POLLUTION PROTECTION
|
|
156
|
+
================================================================================
|
|
157
|
+
|
|
158
|
+
The agent registry only accepts updates to a defined whitelist of safe fields. Any
|
|
159
|
+
attempt to set unknown fields -- including __proto__ or constructor -- is silently
|
|
160
|
+
dropped.
|
|
161
|
+
|
|
162
|
+
WebSocket message parsing explicitly checks for and rejects messages containing
|
|
163
|
+
__proto__ or constructor keys. This prevents attackers from manipulating the JavaScript
|
|
164
|
+
prototype chain through crafted payloads.
|
|
165
|
+
|
|
166
|
+
Result: PASS
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
================================================================================
|
|
170
|
+
9. FILE PERMISSIONS -- OWNER-ONLY ACROSS ALL SENSITIVE FILES
|
|
171
|
+
================================================================================
|
|
172
|
+
|
|
173
|
+
All sensitive files are created with 0o600 permissions (owner read/write only, no
|
|
174
|
+
group or world access):
|
|
175
|
+
|
|
176
|
+
Agent logs
|
|
177
|
+
Credential seed file
|
|
178
|
+
Credential store
|
|
179
|
+
Audit log
|
|
180
|
+
Federation private keys
|
|
181
|
+
Integration credential files
|
|
182
|
+
|
|
183
|
+
The only exception is the federation public key, which is intentionally set to 0o644
|
|
184
|
+
(world-readable) since it is designed to be shared.
|
|
185
|
+
|
|
186
|
+
Result: PASS
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
================================================================================
|
|
190
|
+
10. WHAT GROOVE DOES NOT DO
|
|
191
|
+
================================================================================
|
|
192
|
+
|
|
193
|
+
This is architecturally significant and differentiates Groove from tools that proxy
|
|
194
|
+
credentials:
|
|
195
|
+
|
|
196
|
+
Proxy API calls to Claude/OpenAI/Gemini? No.
|
|
197
|
+
Touch OAuth tokens? No.
|
|
198
|
+
Impersonate AI providers? No.
|
|
199
|
+
Store user subscription credentials? No.
|
|
200
|
+
Forward agent credentials through the daemon? No.
|
|
201
|
+
|
|
202
|
+
Each agent process (Claude Code, Codex, Gemini CLI) runs as a standalone executable
|
|
203
|
+
with its own authentication. The daemon never relays API calls or handles provider
|
|
204
|
+
credentials on behalf of agents.
|
|
205
|
+
|
|
206
|
+
The one exception: Groove's journalist feature makes direct Anthropic API calls using
|
|
207
|
+
a locally-stored API key for internal project synthesis. This is the daemon's own
|
|
208
|
+
feature -- it does not proxy on behalf of any agent.
|
|
209
|
+
|
|
210
|
+
Result: PASS
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
================================================================================
|
|
214
|
+
11. AUDIT TRAIL
|
|
215
|
+
================================================================================
|
|
216
|
+
|
|
217
|
+
All state-changing operations are logged to an append-only audit file:
|
|
218
|
+
|
|
219
|
+
Knock protocol decisions (allowed and denied) with agent ID, tool, and targets
|
|
220
|
+
Agent lifecycle events (spawn, kill, rotate)
|
|
221
|
+
Configuration changes
|
|
222
|
+
Credential operations
|
|
223
|
+
|
|
224
|
+
Audit logs use owner-only permissions and are append-only -- no API endpoint can
|
|
225
|
+
truncate or delete the log.
|
|
226
|
+
|
|
227
|
+
Result: PASS
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
================================================================================
|
|
231
|
+
12. PORT EXPOSURE
|
|
232
|
+
================================================================================
|
|
233
|
+
|
|
234
|
+
Port 31415: Bound to 127.0.0.1. Not network-accessible.
|
|
235
|
+
Ports 31416-25: Fallback range if 31415 is in use. Also bound to 127.0.0.1.
|
|
236
|
+
|
|
237
|
+
No other ports are opened by the daemon. Remote access requires explicit SSH tunnel
|
|
238
|
+
or Tailscale configuration, both of which are encrypted and authenticated.
|
|
239
|
+
|
|
240
|
+
Result: PASS
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
================================================================================
|
|
244
|
+
GROOVE vs. TOOLS THAT LEAVE PORTS OPEN
|
|
245
|
+
================================================================================
|
|
246
|
+
|
|
247
|
+
Network binding:
|
|
248
|
+
Groove binds to 127.0.0.1 and enforces it -- you cannot override to 0.0.0.0.
|
|
249
|
+
Many open-source agent tools default to 0.0.0.0, making them accessible to any
|
|
250
|
+
device on the network.
|
|
251
|
+
|
|
252
|
+
Credential handling:
|
|
253
|
+
Groove uses machine-bound AES-256-GCM encryption and never proxies credentials.
|
|
254
|
+
Tools with open ports may proxy API keys through the server, exposing them to
|
|
255
|
+
network-level interception.
|
|
256
|
+
|
|
257
|
+
Agent isolation:
|
|
258
|
+
Groove enforces scope locks and a knock protocol on every file operation.
|
|
259
|
+
Most comparable tools have no agent-to-agent isolation at all.
|
|
260
|
+
|
|
261
|
+
Input validation:
|
|
262
|
+
Groove validates all inputs against strict schemas and blocks path traversal.
|
|
263
|
+
Input validation quality varies widely across open-source agent tools.
|
|
264
|
+
|
|
265
|
+
Remote access:
|
|
266
|
+
Groove requires SSH tunnel or Tailscale -- both encrypted and authenticated.
|
|
267
|
+
Tools with open ports allow direct, often unauthenticated network access.
|
|
268
|
+
|
|
269
|
+
CORS policy:
|
|
270
|
+
Groove validates origins and only allows localhost.
|
|
271
|
+
Many tools use permissive CORS (wildcard *) or skip CORS entirely.
|
|
272
|
+
|
|
273
|
+
Process spawning:
|
|
274
|
+
Groove uses argument arrays, never shell interpolation.
|
|
275
|
+
Some tools concatenate user input into shell commands.
|
|
276
|
+
|
|
277
|
+
Prototype pollution:
|
|
278
|
+
Groove explicitly whitelists fields and blocks __proto__/constructor.
|
|
279
|
+
This is rarely addressed in comparable tools.
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
================================================================================
|
|
283
|
+
SHOULD GROOVE BE INSTALLED ON A SEPARATE MACHINE?
|
|
284
|
+
================================================================================
|
|
285
|
+
|
|
286
|
+
For standard development use: No. A separate machine is not required.
|
|
287
|
+
|
|
288
|
+
The daemon is not network-accessible. No provider credentials are proxied or exposed.
|
|
289
|
+
Stored keys are encrypted and machine-bound. All sensitive files have restrictive
|
|
290
|
+
permissions. The architecture is designed for safe use on a daily development machine.
|
|
291
|
+
|
|
292
|
+
The residual risk is the AI agents themselves, not Groove's architecture. Claude Code,
|
|
293
|
+
Codex, and Gemini CLI run with your filesystem permissions. If an agent were to execute
|
|
294
|
+
a destructive command, that would be the agent's behavior within its own permission
|
|
295
|
+
model -- not a Groove vulnerability. Groove mitigates this through scope locks and the
|
|
296
|
+
knock protocol, but does not provide kernel-level containment.
|
|
297
|
+
|
|
298
|
+
For high-security environments where production credentials, banking sessions, or
|
|
299
|
+
sensitive SSH keys are present on the same machine, using a dedicated development
|
|
300
|
+
machine or VM is a reasonable precaution. However, this applies to any tool that gives
|
|
301
|
+
AI agents shell access, not to Groove specifically.
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
================================================================================
|
|
305
|
+
CONCLUSION
|
|
306
|
+
================================================================================
|
|
307
|
+
|
|
308
|
+
Groove's security architecture is defense-in-depth at the orchestration layer:
|
|
309
|
+
localhost binding (enforced, not just default), no credential proxying, authenticated
|
|
310
|
+
encryption, scope-based agent isolation, strict input validation, prototype pollution
|
|
311
|
+
protection, and a full audit trail.
|
|
312
|
+
|
|
313
|
+
It significantly reduces the attack surface compared to tools that bind to open ports
|
|
314
|
+
or tunnel credentials through a server. The architecture makes network exposure,
|
|
315
|
+
credential theft, command injection, and prototype pollution structurally impossible
|
|
316
|
+
through the daemon's interfaces.
|
|
317
|
+
|
|
318
|
+
The remaining attack surface -- AI agents acting within their own process permissions --
|
|
319
|
+
is an industry-wide challenge that no orchestration tool fully solves today. Groove
|
|
320
|
+
addresses it better than most through scope locks and the knock protocol, while being
|
|
321
|
+
transparent about the boundary of its guarantees.
|
|
322
|
+
|
|
323
|
+
All 12 areas audited: PASS.
|
|
@@ -15,13 +15,15 @@ import { ROLE_INTEGRATIONS } from './process.js';
|
|
|
15
15
|
|
|
16
16
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
17
17
|
const pkgVersion = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version;
|
|
18
|
-
const isPro = process.env.GROOVE_EDITION === 'pro';
|
|
19
18
|
|
|
20
19
|
let _daemon = null;
|
|
21
20
|
|
|
21
|
+
// Single source of truth for Pro features: the signed-in user's subscription
|
|
22
|
+
// status, populated by the daemon polling the backend with the stored JWT.
|
|
23
|
+
// There is no build-time "Pro edition" flag — one binary, account-gated.
|
|
22
24
|
function proOnly(req, res, next) {
|
|
23
25
|
const sub = _daemon?.subscriptionCache || {};
|
|
24
|
-
if (
|
|
26
|
+
if (sub.active) return next();
|
|
25
27
|
return res.status(403).json({
|
|
26
28
|
error: 'Pro subscription required',
|
|
27
29
|
edition: 'community',
|
|
@@ -129,6 +131,10 @@ export function createApi(app, daemon) {
|
|
|
129
131
|
const team = daemon.teams.get(config.teamId);
|
|
130
132
|
if (team?.workingDir) config.workingDir = team.workingDir;
|
|
131
133
|
}
|
|
134
|
+
// Inherit configured default model if the request didn't pick one
|
|
135
|
+
if (!config.model && daemon.config?.defaultModel) {
|
|
136
|
+
config.model = daemon.config.defaultModel;
|
|
137
|
+
}
|
|
132
138
|
const agent = await daemon.processes.spawn(config);
|
|
133
139
|
daemon.audit.log('agent.spawn', { id: agent.id, role: agent.role, provider: agent.provider });
|
|
134
140
|
res.status(201).json(agent);
|
|
@@ -295,7 +301,7 @@ export function createApi(app, daemon) {
|
|
|
295
301
|
// verify the path matches the scope or belongs to no one.
|
|
296
302
|
if (agent.scope && agent.scope.length > 0 && targets.length > 0) {
|
|
297
303
|
for (const target of targets) {
|
|
298
|
-
const conflict = daemon.locks.check(agentId, target);
|
|
304
|
+
const conflict = daemon.locks.check(agentId, target, agent.workingDir);
|
|
299
305
|
if (conflict.conflict) {
|
|
300
306
|
daemon.audit.log('knock.denied', { agentId, toolName, target, owner: conflict.owner, pattern: conflict.pattern });
|
|
301
307
|
daemon.broadcast({ type: 'knock:denied', agentId, agentName: agent.name, toolName, target, owner: conflict.owner, reason: 'scope_conflict' });
|
|
@@ -711,7 +717,7 @@ export function createApi(app, daemon) {
|
|
|
711
717
|
app.get('/api/edition', (req, res) => {
|
|
712
718
|
const sub = daemon.subscriptionCache || {};
|
|
713
719
|
res.json({
|
|
714
|
-
edition:
|
|
720
|
+
edition: sub.active ? 'pro' : 'community',
|
|
715
721
|
plan: sub.plan || 'community',
|
|
716
722
|
subscriptionActive: sub.active || false,
|
|
717
723
|
features: sub.features || [],
|
|
@@ -734,7 +740,7 @@ export function createApi(app, daemon) {
|
|
|
734
740
|
host: daemon.host,
|
|
735
741
|
port: daemon.port,
|
|
736
742
|
projectDir: daemon.projectDir,
|
|
737
|
-
edition:
|
|
743
|
+
edition: sub.active ? 'pro' : 'community',
|
|
738
744
|
});
|
|
739
745
|
});
|
|
740
746
|
|
|
@@ -18,7 +18,7 @@ const DEFAULT_OPERATION_TTL_MS = 10 * 60 * 1000; // 10 minutes
|
|
|
18
18
|
export class LockManager {
|
|
19
19
|
constructor(grooveDir) {
|
|
20
20
|
this.path = resolve(grooveDir, 'locks.json');
|
|
21
|
-
this.locks = new Map(); // agentId ->
|
|
21
|
+
this.locks = new Map(); // agentId -> { patterns, workingDir }
|
|
22
22
|
this._compiledPatterns = new Map(); // agentId -> RegExp[]
|
|
23
23
|
this.operations = new Map(); // agentId -> { name, resources, acquiredAt, expiresAt }
|
|
24
24
|
this.load();
|
|
@@ -28,9 +28,11 @@ export class LockManager {
|
|
|
28
28
|
if (existsSync(this.path)) {
|
|
29
29
|
try {
|
|
30
30
|
const data = JSON.parse(readFileSync(this.path, 'utf8'));
|
|
31
|
-
for (const [id,
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
for (const [id, val] of Object.entries(data)) {
|
|
32
|
+
// Backward compat: old format stored just patterns array
|
|
33
|
+
const entry = Array.isArray(val) ? { patterns: val, workingDir: null } : val;
|
|
34
|
+
this.locks.set(id, entry);
|
|
35
|
+
this._compilePatterns(id, entry.patterns);
|
|
34
36
|
}
|
|
35
37
|
} catch {
|
|
36
38
|
// Start fresh
|
|
@@ -51,8 +53,8 @@ export class LockManager {
|
|
|
51
53
|
this._compiledPatterns.set(agentId, compiled);
|
|
52
54
|
}
|
|
53
55
|
|
|
54
|
-
register(agentId, patterns) {
|
|
55
|
-
this.locks.set(agentId, patterns);
|
|
56
|
+
register(agentId, patterns, workingDir = null) {
|
|
57
|
+
this.locks.set(agentId, { patterns, workingDir: workingDir || null });
|
|
56
58
|
this._compilePatterns(agentId, patterns);
|
|
57
59
|
this.save();
|
|
58
60
|
}
|
|
@@ -64,9 +66,13 @@ export class LockManager {
|
|
|
64
66
|
this.save();
|
|
65
67
|
}
|
|
66
68
|
|
|
67
|
-
|
|
69
|
+
// Scopes are per-team — only conflict with owners in the same workingDir.
|
|
70
|
+
// Pass workingDir=null to skip the filter (legacy behavior).
|
|
71
|
+
check(agentId, filePath, workingDir = null) {
|
|
68
72
|
for (const [ownerId, compiled] of this._compiledPatterns) {
|
|
69
73
|
if (ownerId === agentId) continue;
|
|
74
|
+
const ownerEntry = this.locks.get(ownerId);
|
|
75
|
+
if (workingDir && ownerEntry?.workingDir && ownerEntry.workingDir !== workingDir) continue;
|
|
70
76
|
for (const { pattern, re } of compiled) {
|
|
71
77
|
if (re && re.test(filePath)) {
|
|
72
78
|
return { conflict: true, owner: ownerId, pattern };
|
|
@@ -111,11 +117,13 @@ export class LockManager {
|
|
|
111
117
|
/**
|
|
112
118
|
* Find any currently-locked agent whose scope overlaps with candidateScope.
|
|
113
119
|
* Returns { overlap: true, owner, ... } for the first conflict, else {overlap:false}.
|
|
120
|
+
* Pass workingDir to limit the search to the same team folder (scopes are per-team).
|
|
114
121
|
*/
|
|
115
|
-
findOverlappingOwner(candidateScope) {
|
|
116
|
-
for (const [ownerId,
|
|
117
|
-
|
|
118
|
-
|
|
122
|
+
findOverlappingOwner(candidateScope, workingDir = null) {
|
|
123
|
+
for (const [ownerId, entry] of this.locks) {
|
|
124
|
+
if (workingDir && entry.workingDir && entry.workingDir !== workingDir) continue;
|
|
125
|
+
const res = LockManager.scopesOverlap(candidateScope, entry.patterns);
|
|
126
|
+
if (res.overlap) return { overlap: true, owner: ownerId, ownerScope: entry.patterns, ...res };
|
|
119
127
|
}
|
|
120
128
|
return { overlap: false };
|
|
121
129
|
}
|
|
@@ -140,7 +148,9 @@ export class LockManager {
|
|
|
140
148
|
}
|
|
141
149
|
|
|
142
150
|
getAll() {
|
|
143
|
-
|
|
151
|
+
const obj = {};
|
|
152
|
+
for (const [id, entry] of this.locks) obj[id] = entry.patterns;
|
|
153
|
+
return obj;
|
|
144
154
|
}
|
|
145
155
|
|
|
146
156
|
// --- Operation locks (coordination protocol) ---
|
|
@@ -385,7 +385,7 @@ export class ProcessManager {
|
|
|
385
385
|
// bypass entirely since their job requires broad access.
|
|
386
386
|
const SCOPE_BYPASS_ROLES = new Set(['planner', 'fullstack', 'qc', 'pm', 'supervisor', 'security', 'ambassador']);
|
|
387
387
|
if (config.scope && config.scope.length > 0 && !SCOPE_BYPASS_ROLES.has(config.role) && !config.allowScopeOverlap) {
|
|
388
|
-
const conflict = locks.findOverlappingOwner(config.scope);
|
|
388
|
+
const conflict = locks.findOverlappingOwner(config.scope, config.workingDir);
|
|
389
389
|
if (conflict.overlap) {
|
|
390
390
|
const owner = registry.get(conflict.owner);
|
|
391
391
|
if (owner && owner.status === 'running' && owner.workingDir === config.workingDir) {
|
|
@@ -463,7 +463,7 @@ export class ProcessManager {
|
|
|
463
463
|
|
|
464
464
|
// Register file locks for the agent's scope
|
|
465
465
|
if (agent.scope && agent.scope.length > 0) {
|
|
466
|
-
locks.register(agent.id, agent.scope);
|
|
466
|
+
locks.register(agent.id, agent.scope, agent.workingDir);
|
|
467
467
|
}
|
|
468
468
|
|
|
469
469
|
// Register ambassador with federation system
|
|
@@ -1523,7 +1523,7 @@ For normal file edits within your scope, proceed without review.
|
|
|
1523
1523
|
|
|
1524
1524
|
// Re-register locks
|
|
1525
1525
|
if (newAgent.scope && newAgent.scope.length > 0) {
|
|
1526
|
-
locks.register(newAgent.id, newAgent.scope);
|
|
1526
|
+
locks.register(newAgent.id, newAgent.scope, newAgent.workingDir);
|
|
1527
1527
|
}
|
|
1528
1528
|
|
|
1529
1529
|
// Spawn the resumed process
|
|
@@ -34,14 +34,30 @@ export class Teams {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
_ensureDefault() {
|
|
37
|
-
const
|
|
38
|
-
|
|
37
|
+
const defaultDir = resolve(this.daemon.projectDir, 'default');
|
|
38
|
+
const existing = [...this.teams.values()].find((t) => t.isDefault);
|
|
39
|
+
|
|
40
|
+
if (!existing) {
|
|
41
|
+
try { mkdirSync(defaultDir, { recursive: true }); } catch { /* may exist */ }
|
|
39
42
|
const id = randomUUID().slice(0, 8);
|
|
40
|
-
const team = {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
const team = {
|
|
44
|
+
id,
|
|
45
|
+
name: 'Default',
|
|
46
|
+
isDefault: true,
|
|
47
|
+
workingDir: defaultDir,
|
|
48
|
+
createdAt: new Date().toISOString(),
|
|
49
|
+
};
|
|
43
50
|
this.teams.set(id, team);
|
|
44
51
|
this._save();
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Migrate legacy default teams that pointed at the project root — give them
|
|
56
|
+
// their own folder so generated files don't pile up alongside source code.
|
|
57
|
+
if (!existing.workingDir || existing.workingDir === this.daemon.projectDir) {
|
|
58
|
+
try { mkdirSync(defaultDir, { recursive: true }); } catch { /* may exist */ }
|
|
59
|
+
existing.workingDir = defaultDir;
|
|
60
|
+
this._save();
|
|
45
61
|
}
|
|
46
62
|
}
|
|
47
63
|
|
|
@@ -125,12 +141,13 @@ export class Teams {
|
|
|
125
141
|
}
|
|
126
142
|
|
|
127
143
|
/**
|
|
128
|
-
* Delete a team —
|
|
144
|
+
* Delete a team — kills its agents, removes its directory, drops it from the
|
|
145
|
+
* registry. Deleting the default team regenerates a fresh empty one so users
|
|
146
|
+
* can wipe accumulated state and keep working without restarting the daemon.
|
|
129
147
|
*/
|
|
130
148
|
delete(id) {
|
|
131
149
|
const team = this.teams.get(id);
|
|
132
150
|
if (!team) throw new Error('Team not found');
|
|
133
|
-
if (team.isDefault) throw new Error('Cannot delete the default team');
|
|
134
151
|
|
|
135
152
|
// Kill any running agents in this team
|
|
136
153
|
const agents = this.daemon.registry.getAll().filter((a) => a.teamId === id);
|
|
@@ -145,8 +162,13 @@ export class Teams {
|
|
|
145
162
|
this.daemon.registry.remove(agent.id);
|
|
146
163
|
}
|
|
147
164
|
|
|
148
|
-
// Remove the working directory
|
|
149
|
-
|
|
165
|
+
// Remove the team's working directory — refuse to nuke the project root
|
|
166
|
+
// (legacy default teams that were never migrated point there).
|
|
167
|
+
if (
|
|
168
|
+
team.workingDir &&
|
|
169
|
+
team.workingDir !== this.daemon.projectDir &&
|
|
170
|
+
existsSync(team.workingDir)
|
|
171
|
+
) {
|
|
150
172
|
try {
|
|
151
173
|
rmSync(team.workingDir, { recursive: true, force: true });
|
|
152
174
|
} catch (err) {
|
|
@@ -158,6 +180,13 @@ export class Teams {
|
|
|
158
180
|
this._save();
|
|
159
181
|
this.daemon.broadcast({ type: 'team:deleted', teamId: id });
|
|
160
182
|
|
|
183
|
+
// Always keep a default team available — regenerate one with a clean folder
|
|
184
|
+
if (team.isDefault) {
|
|
185
|
+
this._ensureDefault();
|
|
186
|
+
const fresh = this.getDefault();
|
|
187
|
+
if (fresh) this.daemon.broadcast({ type: 'team:created', team: fresh });
|
|
188
|
+
}
|
|
189
|
+
|
|
161
190
|
// Clean up orphaned logs immediately — don't wait for the 24h GC cycle
|
|
162
191
|
try { this.daemon._gc(); } catch { /* gc should never block deletion */ }
|
|
163
192
|
|
|
@@ -158,7 +158,7 @@ export class ToolExecutor {
|
|
|
158
158
|
_checkWriteScope(resolvedPath) {
|
|
159
159
|
if (!this.daemon?.locks) return;
|
|
160
160
|
const rel = relative(this.workingDir, resolvedPath);
|
|
161
|
-
const result = this.daemon.locks.check(this.agentId, rel);
|
|
161
|
+
const result = this.daemon.locks.check(this.agentId, rel, this.workingDir);
|
|
162
162
|
if (result.conflict) {
|
|
163
163
|
// Record conflict for supervisor + token savings
|
|
164
164
|
if (this.daemon.supervisor) {
|
|
@@ -135,9 +135,19 @@ describe('Teams', () => {
|
|
|
135
135
|
assert.equal(msg.teamId, team.id);
|
|
136
136
|
});
|
|
137
137
|
|
|
138
|
-
it('should
|
|
139
|
-
const
|
|
140
|
-
|
|
138
|
+
it('should regenerate a fresh default team when the default is deleted', () => {
|
|
139
|
+
const original = teams.getDefault();
|
|
140
|
+
broadcasts.length = 0;
|
|
141
|
+
|
|
142
|
+
teams.delete(original.id);
|
|
143
|
+
|
|
144
|
+
const fresh = teams.getDefault();
|
|
145
|
+
assert.ok(fresh, 'a new default team should be created');
|
|
146
|
+
assert.notEqual(fresh.id, original.id);
|
|
147
|
+
assert.equal(fresh.isDefault, true);
|
|
148
|
+
assert.equal(teams.list().length, 1);
|
|
149
|
+
assert.ok(broadcasts.find((b) => b.type === 'team:deleted' && b.teamId === original.id));
|
|
150
|
+
assert.ok(broadcasts.find((b) => b.type === 'team:created' && b.team?.id === fresh.id));
|
|
141
151
|
});
|
|
142
152
|
|
|
143
153
|
it('should throw when deleting nonexistent team', () => {
|