@phnx-labs/agents-cli 1.23.11 → 1.23.13
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/CHANGELOG.md +10 -0
- package/dist/commands/permissions.js +36 -6
- package/dist/commands/setup.js +1 -1
- package/dist/lib/agent-spec/agents.js +15 -9
- package/dist/lib/installations/active-check.d.ts +1 -0
- package/dist/lib/installations/active-check.js +37 -4
- package/dist/lib/installations/versions.js +1 -2
- package/dist/lib/permissions-registry.d.ts +4 -0
- package/dist/lib/permissions-registry.js +70 -18
- package/dist/lib/permissions.d.ts +25 -5
- package/dist/lib/permissions.js +239 -53
- package/dist/lib/staleness/detectors/permissions.js +16 -8
- package/dist/lib/staleness/writers/permissions.js +6 -1
- package/dist/lib/types.d.ts +4 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.23.13
|
|
4
|
+
|
|
5
|
+
- **`agents setup` without a terminal exits 0 when setup worked (PHNX-4227).** Outside a TTY it printed the onboarding checklist and exited 1 if any capability was unconfigured: browser, fleet, watchdog, preferences and so on. Every headless install, such as a Rush pod image build, has those unset by design, so the build had to tolerate a failing `agents setup`. It now exits 1 only when core setup (the system repo) is missing. `agents setup status` still exits 1 for any missing capability. Source: `cli/src/commands/setup.ts`.
|
|
6
|
+
|
|
7
|
+
## 1.23.12
|
|
8
|
+
|
|
9
|
+
- **`agents add` works in containers without `ps` (PHNX-4227).** Before replacing an install, the CLI checks whether any process runs from it. On Linux it listed processes with `ps`, which `node:*-slim` images (every Rush pod) lack, and a failed scan counts as "in use", so `agents add` refused with "account home main is in use" on an idle install. On Linux it now reads `/proc/<pid>/cmdline`; macOS keeps `ps`, Windows keeps its CIM query, and an unreadable process table still refuses. Source: `cli/src/lib/installations/active-check.ts`.
|
|
10
|
+
|
|
11
|
+
- **A permission preset that names a missing group fails, and `ask:` rules sync into harnesses that can prompt on a rule (PHNX-4227).** `buildPermissionsFromGroups` used to skip a group whose file was not there, and preset sync dropped missing includes before that function ran, so a dangling name such as `16-mcp` disappeared. A named group with no `permissions/groups/<name>.yaml` now throws, and the error names the active preset and the group. `00-local` stays the one optional per-machine group and is skipped when its file is absent. An `ask:` section is kept beside allow and deny. It is written to the native prompt list where one exists: Claude `permissions.ask`, OpenCode `permission.bash` value `ask`, Codex `agents-ask.rules` (`decision = "prompt"`), Grok `action = "ask"`, Kimi `decision = "ask"`, Droid `permissionRules` decision `ask` (not `commandDenylist`), and Antigravity `permissions.ask`. Cursor, Copilot, OpenClaw, and Hermes have no per-rule ask list. Allow and deny still sync, and the ask rules are skipped with the reason recorded on `PERMISSION_TARGETS`. Source: `cli/src/lib/permissions.ts`, `cli/src/lib/permissions-registry.ts`, `cli/src/lib/installations/versions.ts`.
|
|
12
|
+
|
|
3
13
|
## 1.23.11
|
|
4
14
|
|
|
5
15
|
- **The daemon no longer restarts when a service tick runs slow (PHNX-4225).** A
|
|
@@ -65,6 +65,13 @@ When to use:
|
|
|
65
65
|
console.log(` ${chalk.yellow(p)}`);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
+
const claudeAsk = claudePerms.permissions.ask ?? [];
|
|
69
|
+
if (claudeAsk.length > 0) {
|
|
70
|
+
console.log(chalk.yellow(' Ask:'));
|
|
71
|
+
for (const p of claudeAsk) {
|
|
72
|
+
console.log(` ${chalk.yellow(p)}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
68
75
|
}
|
|
69
76
|
else if (agentId === 'opencode') {
|
|
70
77
|
const ocPerms = perms;
|
|
@@ -107,6 +114,11 @@ When to use:
|
|
|
107
114
|
for (const p of set.deny)
|
|
108
115
|
console.log(` ${chalk.yellow(p)}`);
|
|
109
116
|
}
|
|
117
|
+
if (set.ask?.length) {
|
|
118
|
+
console.log(chalk.yellow(' Ask:'));
|
|
119
|
+
for (const p of set.ask)
|
|
120
|
+
console.log(` ${chalk.yellow(p)}`);
|
|
121
|
+
}
|
|
110
122
|
}
|
|
111
123
|
console.log();
|
|
112
124
|
};
|
|
@@ -196,7 +208,7 @@ When to use:
|
|
|
196
208
|
? ` - ${chalk.gray(truncateToWidth(perm.set.description, budget))}`
|
|
197
209
|
: '';
|
|
198
210
|
console.log(`${prefix}${desc}`);
|
|
199
|
-
console.log(` ${chalk.gray(`${perm.set.allow.length} allow, ${perm.set.deny?.length || 0} deny rules`)}`);
|
|
211
|
+
console.log(` ${chalk.gray(`${perm.set.allow.length} allow, ${perm.set.deny?.length || 0} deny${perm.set.ask?.length ? `, ${perm.set.ask.length} ask` : ''} rules`)}`);
|
|
200
212
|
}
|
|
201
213
|
}
|
|
202
214
|
});
|
|
@@ -261,7 +273,7 @@ Examples:
|
|
|
261
273
|
value: installed.name,
|
|
262
274
|
name: installed.set.description
|
|
263
275
|
? `${installed.name} ${chalk.gray(installed.set.description.slice(0, 40))}`
|
|
264
|
-
: `${installed.name} ${chalk.gray(`${installed.set.allow.length} allow, ${installed.set.deny?.length || 0} deny`)}`,
|
|
276
|
+
: `${installed.name} ${chalk.gray(`${installed.set.allow.length} allow, ${installed.set.deny?.length || 0} deny${installed.set.ask?.length ? `, ${installed.set.ask.length} ask` : ''}`)}`,
|
|
265
277
|
}));
|
|
266
278
|
const selected = await checkbox({
|
|
267
279
|
message: 'Select permission sets to apply',
|
|
@@ -322,6 +334,8 @@ Examples:
|
|
|
322
334
|
const applyResult = applyPermissionsToVersion(agentId, installed.set, versionHome, !options.replace);
|
|
323
335
|
if (applyResult.success) {
|
|
324
336
|
console.log(chalk.green(` Applied ${setName} to ${agentLabel(agentId)}@${version}`));
|
|
337
|
+
for (const line of applyResult.skipped ?? [])
|
|
338
|
+
console.log(chalk.yellow(` ${line}`));
|
|
325
339
|
recordVersionResources(agentId, version, 'permissions', [setName]);
|
|
326
340
|
applied++;
|
|
327
341
|
}
|
|
@@ -357,14 +371,14 @@ Examples:
|
|
|
357
371
|
const isAgentConfig = detectPermissionAgentFromPath(localPath) !== null;
|
|
358
372
|
if (isAgentConfig) {
|
|
359
373
|
const incoming = exportPermissionsFromPath(localPath);
|
|
360
|
-
if (!incoming || (incoming.allow.length === 0 && (!incoming.deny || incoming.deny.length === 0))) {
|
|
374
|
+
if (!incoming || (incoming.allow.length === 0 && (!incoming.deny || incoming.deny.length === 0) && (!incoming.ask || incoming.ask.length === 0))) {
|
|
361
375
|
console.log(chalk.yellow(`\nNo permissions found in ${localPath}`));
|
|
362
376
|
return;
|
|
363
377
|
}
|
|
364
378
|
const existing = getDefaultPermissionSet();
|
|
365
379
|
const diff = computePermissionsDiff(existing, incoming);
|
|
366
|
-
const totalNew = diff.allow.added.length + diff.deny.added.length;
|
|
367
|
-
const totalExisting = diff.allow.existing.length + diff.deny.existing.length;
|
|
380
|
+
const totalNew = diff.allow.added.length + diff.deny.added.length + diff.ask.added.length;
|
|
381
|
+
const totalExisting = diff.allow.existing.length + diff.deny.existing.length + diff.ask.existing.length;
|
|
368
382
|
if (totalNew === 0) {
|
|
369
383
|
console.log(chalk.gray('\nAll permissions already exist in central storage.'));
|
|
370
384
|
return;
|
|
@@ -385,6 +399,12 @@ Examples:
|
|
|
385
399
|
console.log(chalk.red(` + ${rule}`));
|
|
386
400
|
}
|
|
387
401
|
}
|
|
402
|
+
if (diff.ask.added.length > 0) {
|
|
403
|
+
console.log(chalk.yellow('\n New ask rules:'));
|
|
404
|
+
for (const rule of diff.ask.added) {
|
|
405
|
+
console.log(chalk.yellow(` + ${rule}`));
|
|
406
|
+
}
|
|
407
|
+
}
|
|
388
408
|
if (totalExisting > 0) {
|
|
389
409
|
console.log(chalk.gray(`\n (${totalExisting} rules already exist, will be skipped)`));
|
|
390
410
|
}
|
|
@@ -457,6 +477,8 @@ Examples:
|
|
|
457
477
|
const applyResult = applyPermissionsToVersion(agentId, merged, versionHome, !options.replace);
|
|
458
478
|
if (applyResult.success) {
|
|
459
479
|
console.log(chalk.green(` Applied to ${agentLabel(agentId)}@${version}`));
|
|
480
|
+
for (const line of applyResult.skipped ?? [])
|
|
481
|
+
console.log(chalk.yellow(` ${line}`));
|
|
460
482
|
recordVersionResources(agentId, version, 'permissions', [merged.name || 'default']);
|
|
461
483
|
applied++;
|
|
462
484
|
}
|
|
@@ -492,7 +514,7 @@ Examples:
|
|
|
492
514
|
for (const perm of permissions) {
|
|
493
515
|
const desc = perm.set.description ? ` - ${perm.set.description}` : '';
|
|
494
516
|
console.log(` ${chalk.cyan(perm.name)}${desc}`);
|
|
495
|
-
console.log(` ${chalk.gray(`${perm.set.allow.length} allow, ${perm.set.deny?.length || 0} deny rules`)}`);
|
|
517
|
+
console.log(` ${chalk.gray(`${perm.set.allow.length} allow, ${perm.set.deny?.length || 0} deny${perm.set.ask?.length ? `, ${perm.set.ask.length} ask` : ''} rules`)}`);
|
|
496
518
|
}
|
|
497
519
|
const broadGrants = permissions
|
|
498
520
|
.map((perm) => ({ name: perm.name, grants: containsBroadGrants(perm.set) }))
|
|
@@ -585,6 +607,8 @@ Examples:
|
|
|
585
607
|
const applyResult = applyPermissionsToVersion(agentId, perm.set, versionHome, !options.replace);
|
|
586
608
|
if (applyResult.success) {
|
|
587
609
|
console.log(chalk.green(` Applied ${perm.name} to ${agentLabel(agentId)}@${version}`));
|
|
610
|
+
for (const line of applyResult.skipped ?? [])
|
|
611
|
+
console.log(chalk.yellow(` ${line}`));
|
|
588
612
|
recordVersionResources(agentId, version, 'permissions', [perm.name]);
|
|
589
613
|
applied++;
|
|
590
614
|
}
|
|
@@ -733,6 +757,12 @@ Examples:
|
|
|
733
757
|
lines.push(` ${chalk.yellow(rule)}`);
|
|
734
758
|
}
|
|
735
759
|
}
|
|
760
|
+
if (perm.set.ask && perm.set.ask.length > 0) {
|
|
761
|
+
lines.push(chalk.yellow('\n Ask rules:'));
|
|
762
|
+
for (const rule of perm.set.ask) {
|
|
763
|
+
lines.push(` ${chalk.yellow(rule)}`);
|
|
764
|
+
}
|
|
765
|
+
}
|
|
736
766
|
lines.push('');
|
|
737
767
|
const output = lines.join('\n');
|
|
738
768
|
printWithPager(output, lines.length);
|
package/dist/commands/setup.js
CHANGED
|
@@ -280,7 +280,7 @@ export async function runSetupHub(deps = {}) {
|
|
|
280
280
|
if (!interactive) {
|
|
281
281
|
const rows = await getSetupStatus();
|
|
282
282
|
renderSetupStatus(rows);
|
|
283
|
-
if (rows.some((row) => row.state === 'missing'))
|
|
283
|
+
if (rows.some((row) => row.phase === 'core' && row.state === 'missing'))
|
|
284
284
|
process.exitCode = 1;
|
|
285
285
|
return;
|
|
286
286
|
}
|
|
@@ -231,7 +231,7 @@ export const AGENTS = {
|
|
|
231
231
|
// Harness-owned skill directories survive orphan cleanup.
|
|
232
232
|
ownedSkillDirs: ['synced'],
|
|
233
233
|
cloudProvider: 'rush',
|
|
234
|
-
capabilities: { hooks: true, mcp: true, mcpHttp: true, mcpHeaders: true, allowlist: true, skills: true, commands: true, plugins: true, subagents: true, rules: { file: 'CLAUDE.md' }, workflows: true, memory: true, modes: ['plan', 'edit', 'auto', 'skip'], rulesImports: true, interactiveRepl: true },
|
|
234
|
+
capabilities: { hooks: true, mcp: true, mcpHttp: true, mcpHeaders: true, allowlist: true, ask: true, skills: true, commands: true, plugins: true, subagents: true, rules: { file: 'CLAUDE.md' }, workflows: true, memory: true, modes: ['plan', 'edit', 'auto', 'skip'], rulesImports: true, interactiveRepl: true },
|
|
235
235
|
},
|
|
236
236
|
codex: {
|
|
237
237
|
id: 'codex',
|
|
@@ -258,7 +258,7 @@ export const AGENTS = {
|
|
|
258
258
|
variableSyntax: '$ARGUMENTS',
|
|
259
259
|
supportsHooks: true,
|
|
260
260
|
cloudProvider: 'codex',
|
|
261
|
-
capabilities: { hooks: { since: '0.116.0' }, mcp: true, mcpHttp: true, mcpHeaders: false, allowlist: { since: '0.138.0' }, skills: true, commands: { until: '0.117.0' }, plugins: { since: '0.128.0' }, subagents: { since: '0.117.0' }, rules: { file: 'AGENTS.md' }, workflows: false, memory: true, modes: ['plan', 'edit', 'auto', 'skip'], interactiveRepl: true },
|
|
261
|
+
capabilities: { hooks: { since: '0.116.0' }, mcp: true, mcpHttp: true, mcpHeaders: false, allowlist: { since: '0.138.0' }, ask: { since: '0.138.0' }, skills: true, commands: { until: '0.117.0' }, plugins: { since: '0.128.0' }, subagents: { since: '0.117.0' }, rules: { file: 'AGENTS.md' }, workflows: false, memory: true, modes: ['plan', 'edit', 'auto', 'skip'], interactiveRepl: true },
|
|
262
262
|
},
|
|
263
263
|
cursor: {
|
|
264
264
|
id: 'cursor',
|
|
@@ -286,7 +286,7 @@ export const AGENTS = {
|
|
|
286
286
|
format: 'markdown',
|
|
287
287
|
variableSyntax: '$ARGUMENTS',
|
|
288
288
|
supportsHooks: true,
|
|
289
|
-
capabilities: { hooks: true, mcp: true, mcpHttp: false, mcpHeaders: false, allowlist: true, skills: true, commands: true, plugins: true, subagents: { since: '2026.1.22' }, rules: { file: '.cursorrules' }, workflows: false, memory: false, modes: ['plan', 'edit', 'skip'], interactiveRepl: true },
|
|
289
|
+
capabilities: { hooks: true, mcp: true, mcpHttp: false, mcpHeaders: false, allowlist: true, ask: false, skills: true, commands: true, plugins: true, subagents: { since: '2026.1.22' }, rules: { file: '.cursorrules' }, workflows: false, memory: false, modes: ['plan', 'edit', 'skip'], interactiveRepl: true },
|
|
290
290
|
},
|
|
291
291
|
opencode: {
|
|
292
292
|
id: 'opencode',
|
|
@@ -311,7 +311,7 @@ export const AGENTS = {
|
|
|
311
311
|
format: 'markdown',
|
|
312
312
|
variableSyntax: '$ARGUMENTS',
|
|
313
313
|
supportsHooks: true,
|
|
314
|
-
capabilities: { hooks: { since: '0.3.130' }, mcp: true, mcpHttp: false, mcpHeaders: false, allowlist: { since: '1.1.1' }, skills: true, commands: true, plugins: true, subagents: true, rules: { file: 'AGENTS.md' }, workflows: false, memory: false, modes: ['plan', 'edit'], interactiveRepl: true },
|
|
314
|
+
capabilities: { hooks: { since: '0.3.130' }, mcp: true, mcpHttp: false, mcpHeaders: false, allowlist: { since: '1.1.1' }, ask: { since: '1.1.1' }, skills: true, commands: true, plugins: true, subagents: true, rules: { file: 'AGENTS.md' }, workflows: false, memory: false, modes: ['plan', 'edit'], interactiveRepl: true },
|
|
315
315
|
},
|
|
316
316
|
openclaw: {
|
|
317
317
|
id: 'openclaw',
|
|
@@ -337,7 +337,7 @@ export const AGENTS = {
|
|
|
337
337
|
format: 'markdown',
|
|
338
338
|
variableSyntax: '{{ARGUMENTS}}',
|
|
339
339
|
supportsHooks: false,
|
|
340
|
-
capabilities: { hooks: false, mcp: true, mcpHttp: false, mcpHeaders: false, allowlist: true, skills: true, commands: false, plugins: true, subagents: true, rules: { file: 'workspace/AGENTS.md' }, workflows: true, memory: true, modes: ['plan', 'edit', 'skip'], interactiveRepl: true },
|
|
340
|
+
capabilities: { hooks: false, mcp: true, mcpHttp: false, mcpHeaders: false, allowlist: true, ask: false, skills: true, commands: false, plugins: true, subagents: true, rules: { file: 'workspace/AGENTS.md' }, workflows: true, memory: true, modes: ['plan', 'edit', 'skip'], interactiveRepl: true },
|
|
341
341
|
},
|
|
342
342
|
copilot: {
|
|
343
343
|
id: 'copilot',
|
|
@@ -363,7 +363,7 @@ export const AGENTS = {
|
|
|
363
363
|
format: 'markdown',
|
|
364
364
|
variableSyntax: '$ARGUMENTS',
|
|
365
365
|
supportsHooks: true,
|
|
366
|
-
capabilities: { hooks: true, mcp: true, mcpHttp: false, mcpHeaders: false, allowlist: true, skills: true, commands: true, plugins: true, subagents: { since: '0.0.353' }, rules: { file: 'AGENTS.md' }, workflows: false, memory: false, modes: ['plan', 'edit', 'auto', 'skip'], interactiveRepl: false },
|
|
366
|
+
capabilities: { hooks: true, mcp: true, mcpHttp: false, mcpHeaders: false, allowlist: true, ask: false, skills: true, commands: true, plugins: true, subagents: { since: '0.0.353' }, rules: { file: 'AGENTS.md' }, workflows: false, memory: false, modes: ['plan', 'edit', 'auto', 'skip'], interactiveRepl: false },
|
|
367
367
|
},
|
|
368
368
|
amp: {
|
|
369
369
|
id: 'amp',
|
|
@@ -388,7 +388,7 @@ export const AGENTS = {
|
|
|
388
388
|
format: 'markdown',
|
|
389
389
|
variableSyntax: '$ARGUMENTS',
|
|
390
390
|
supportsHooks: false,
|
|
391
|
-
capabilities: { hooks: false, mcp: true, mcpHttp: false, mcpHeaders: false, allowlist: false, skills: true, commands: true, plugins: false, subagents: false, rules: { file: 'AGENTS.md' }, workflows: false, memory: false, modes: ['plan', 'edit'], interactiveRepl: false },
|
|
391
|
+
capabilities: { hooks: false, mcp: true, mcpHttp: false, mcpHeaders: false, allowlist: false, ask: false, skills: true, commands: true, plugins: false, subagents: false, rules: { file: 'AGENTS.md' }, workflows: false, memory: false, modes: ['plan', 'edit'], interactiveRepl: false },
|
|
392
392
|
},
|
|
393
393
|
goose: {
|
|
394
394
|
id: 'goose',
|
|
@@ -415,7 +415,7 @@ export const AGENTS = {
|
|
|
415
415
|
format: 'markdown',
|
|
416
416
|
variableSyntax: '$ARGUMENTS',
|
|
417
417
|
supportsHooks: true,
|
|
418
|
-
capabilities: { hooks: { since: '1.34.0' }, mcp: true, mcpHttp: false, mcpHeaders: false, allowlist: false, skills: { since: '1.25.0' }, commands: true, plugins: true, subagents: true, rules: { file: 'AGENTS.md' }, workflows: true, memory: false, modes: ['edit'], interactiveRepl: true },
|
|
418
|
+
capabilities: { hooks: { since: '1.34.0' }, mcp: true, mcpHttp: false, mcpHeaders: false, allowlist: false, ask: false, skills: { since: '1.25.0' }, commands: true, plugins: true, subagents: true, rules: { file: 'AGENTS.md' }, workflows: true, memory: false, modes: ['edit'], interactiveRepl: true },
|
|
419
419
|
},
|
|
420
420
|
antigravity: {
|
|
421
421
|
id: 'antigravity',
|
|
@@ -443,7 +443,7 @@ export const AGENTS = {
|
|
|
443
443
|
variableSyntax: '{{args}}',
|
|
444
444
|
supportsHooks: true,
|
|
445
445
|
cloudProvider: 'antigravity',
|
|
446
|
-
capabilities: { hooks: true, mcp: true, mcpHttp: false, mcpHeaders: false, allowlist: true, skills: true, commands: true, plugins: true, subagents: { since: '1.0.16' }, rules: { file: 'AGENTS.md' }, workflows: { since: '1.0.6' }, memory: false, modes: ['edit', 'skip'], rulesImports: false, interactiveRepl: true },
|
|
446
|
+
capabilities: { hooks: true, mcp: true, mcpHttp: false, mcpHeaders: false, allowlist: true, ask: true, skills: true, commands: true, plugins: true, subagents: { since: '1.0.16' }, rules: { file: 'AGENTS.md' }, workflows: { since: '1.0.6' }, memory: false, modes: ['edit', 'skip'], rulesImports: false, interactiveRepl: true },
|
|
447
447
|
},
|
|
448
448
|
grok: {
|
|
449
449
|
id: 'grok',
|
|
@@ -475,6 +475,7 @@ export const AGENTS = {
|
|
|
475
475
|
mcpHttp: false,
|
|
476
476
|
mcpHeaders: false,
|
|
477
477
|
allowlist: true,
|
|
478
|
+
ask: true,
|
|
478
479
|
skills: true,
|
|
479
480
|
commands: true,
|
|
480
481
|
plugins: true,
|
|
@@ -519,6 +520,7 @@ export const AGENTS = {
|
|
|
519
520
|
mcpHttp: false,
|
|
520
521
|
mcpHeaders: false,
|
|
521
522
|
allowlist: true,
|
|
523
|
+
ask: true,
|
|
522
524
|
skills: true,
|
|
523
525
|
commands: false,
|
|
524
526
|
plugins: true,
|
|
@@ -565,6 +567,7 @@ export const AGENTS = {
|
|
|
565
567
|
mcpHttp: false,
|
|
566
568
|
mcpHeaders: false,
|
|
567
569
|
allowlist: { since: '0.57.5' },
|
|
570
|
+
ask: { since: '0.57.5' },
|
|
568
571
|
skills: { since: '0.26.0' },
|
|
569
572
|
commands: true,
|
|
570
573
|
plugins: true,
|
|
@@ -607,6 +610,7 @@ export const AGENTS = {
|
|
|
607
610
|
mcpHttp: true,
|
|
608
611
|
mcpHeaders: false,
|
|
609
612
|
allowlist: true,
|
|
613
|
+
ask: false,
|
|
610
614
|
skills: true,
|
|
611
615
|
commands: false,
|
|
612
616
|
plugins: true,
|
|
@@ -651,6 +655,7 @@ export const AGENTS = {
|
|
|
651
655
|
mcpHttp: true,
|
|
652
656
|
mcpHeaders: true,
|
|
653
657
|
allowlist: false,
|
|
658
|
+
ask: false,
|
|
654
659
|
skills: true,
|
|
655
660
|
commands: false,
|
|
656
661
|
plugins: true,
|
|
@@ -693,6 +698,7 @@ export const AGENTS = {
|
|
|
693
698
|
mcpHttp: true,
|
|
694
699
|
mcpHeaders: true,
|
|
695
700
|
allowlist: false,
|
|
701
|
+
ask: false,
|
|
696
702
|
skills: true,
|
|
697
703
|
commands: false,
|
|
698
704
|
plugins: false,
|
|
@@ -9,6 +9,7 @@ export interface ProcessRow {
|
|
|
9
9
|
tty?: string;
|
|
10
10
|
args: string;
|
|
11
11
|
}
|
|
12
|
+
export declare function listProcessRowsFromProc(procRoot?: string): ProcessRow[];
|
|
12
13
|
export declare const realProcessSnapshot: ProcessSnapshot;
|
|
13
14
|
export declare function installationLooksActive(installation: Pick<Installation, 'agent' | 'label'>, commandLines: string[]): boolean;
|
|
14
15
|
export declare function isInstallationLikelyActive(installation: Pick<Installation, 'agent' | 'label'>, snapshot?: ProcessSnapshot): Promise<boolean>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { execFile } from 'child_process';
|
|
2
|
+
import * as fs from 'fs';
|
|
2
3
|
import { promisify } from 'util';
|
|
3
4
|
import { getVersionDir } from './store.js';
|
|
4
5
|
import { hasLiveLaunchLease } from './shims.js';
|
|
@@ -25,6 +26,28 @@ async function listCommandLinesPosix() {
|
|
|
25
26
|
throw new Error('could not read the process table (ps failed)');
|
|
26
27
|
}
|
|
27
28
|
}
|
|
29
|
+
export function listProcessRowsFromProc(procRoot = '/proc') {
|
|
30
|
+
let entries;
|
|
31
|
+
try {
|
|
32
|
+
entries = fs.readdirSync(procRoot);
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
throw new Error(`could not read the process table (${procRoot}: ${err.message})`);
|
|
36
|
+
}
|
|
37
|
+
return entries.flatMap((name) => {
|
|
38
|
+
if (!/^\d+$/.test(name))
|
|
39
|
+
return [];
|
|
40
|
+
let raw;
|
|
41
|
+
try {
|
|
42
|
+
raw = fs.readFileSync(`${procRoot}/${name}/cmdline`, 'utf8');
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
const args = raw.replace(/\0+$/, '').split('\0').join(' ');
|
|
48
|
+
return args ? [{ pid: Number(name), args }] : [];
|
|
49
|
+
});
|
|
50
|
+
}
|
|
28
51
|
async function listCommandLinesWindows() {
|
|
29
52
|
try {
|
|
30
53
|
const { stdout } = await execFileAsync('powershell.exe', ['-NoLogo', '-NoProfile', '-NonInteractive', '-Command',
|
|
@@ -36,10 +59,20 @@ async function listCommandLinesWindows() {
|
|
|
36
59
|
}
|
|
37
60
|
}
|
|
38
61
|
export const realProcessSnapshot = {
|
|
39
|
-
listCommandLines: () =>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
62
|
+
listCommandLines: async () => {
|
|
63
|
+
if (process.platform === 'win32')
|
|
64
|
+
return listCommandLinesWindows();
|
|
65
|
+
if (process.platform === 'linux')
|
|
66
|
+
return listProcessRowsFromProc().map((row) => row.args);
|
|
67
|
+
return listCommandLinesPosix();
|
|
68
|
+
},
|
|
69
|
+
listProcessRows: async () => {
|
|
70
|
+
if (process.platform === 'win32')
|
|
71
|
+
return (await listCommandLinesWindows()).map((args) => ({ args }));
|
|
72
|
+
if (process.platform === 'linux')
|
|
73
|
+
return listProcessRowsFromProc();
|
|
74
|
+
return listProcessRowsPosix();
|
|
75
|
+
},
|
|
43
76
|
};
|
|
44
77
|
export function installationLooksActive(installation, commandLines) {
|
|
45
78
|
const versionDir = getVersionDir(installation.agent, installation.label);
|
|
@@ -1917,8 +1917,7 @@ export function syncResourcesToVersion(agent, version, selection, options = {})
|
|
|
1917
1917
|
if (activePresetName) {
|
|
1918
1918
|
const recipe = readPermissionPresetRecipe(activePresetName);
|
|
1919
1919
|
if (recipe) {
|
|
1920
|
-
|
|
1921
|
-
presetFilteredGroups = recipe.includes.filter(g => available.has(g));
|
|
1920
|
+
presetFilteredGroups = recipe.includes;
|
|
1922
1921
|
}
|
|
1923
1922
|
else {
|
|
1924
1923
|
console.warn(`${PERMISSION_PRESET_ENV_VAR}=${activePresetName} but no recipe at ~/.agents/permissions/presets/${activePresetName}.yaml — falling back to all groups`);
|
|
@@ -3,6 +3,7 @@ export declare const GROK_TOOL_BY_CANONICAL: Record<string, string | undefined>;
|
|
|
3
3
|
export declare const CANONICAL_TO_OPENCLAW_TOOL: Record<string, string>;
|
|
4
4
|
export declare const ANTIGRAVITY_ACTION_BY_TOOL: Record<string, string | undefined>;
|
|
5
5
|
export declare const CODEX_RULES_FILENAME = "agents-deny.rules";
|
|
6
|
+
export declare const CODEX_ASK_RULES_FILENAME = "agents-ask.rules";
|
|
6
7
|
export declare function stripJsonComments(content: string): string;
|
|
7
8
|
interface PermissionTarget {
|
|
8
9
|
home(home: string): string;
|
|
@@ -10,6 +11,9 @@ interface PermissionTarget {
|
|
|
10
11
|
toCanonical(configPath: string): PermissionSet | null;
|
|
11
12
|
lossyBecause: string;
|
|
12
13
|
altSuffixes?: string[];
|
|
14
|
+
ask: true | {
|
|
15
|
+
reason: string;
|
|
16
|
+
};
|
|
13
17
|
}
|
|
14
18
|
export declare const PERMISSION_TARGETS: Partial<Record<AgentId, PermissionTarget>>;
|
|
15
19
|
export declare function readCanonicalPermissions(agent: AgentId, scope?: 'user' | 'project', cwd?: string, home?: string): PermissionSet | null;
|
|
@@ -38,6 +38,7 @@ const CANONICAL_BY_GROK_TOOL = invertFirstWins(GROK_TOOL_BY_CANONICAL);
|
|
|
38
38
|
const CANONICAL_BY_OPENCLAW_TOOL = invertFirstWins(CANONICAL_TO_OPENCLAW_TOOL);
|
|
39
39
|
const CANONICAL_BY_ANTIGRAVITY_ACTION = invertFirstWins(ANTIGRAVITY_ACTION_BY_TOOL);
|
|
40
40
|
export const CODEX_RULES_FILENAME = 'agents-deny.rules';
|
|
41
|
+
export const CODEX_ASK_RULES_FILENAME = 'agents-ask.rules';
|
|
41
42
|
const CANONICAL_TOOL_CASE = {
|
|
42
43
|
bash: 'Bash',
|
|
43
44
|
read: 'Read',
|
|
@@ -68,15 +69,17 @@ function canonicalRule(lowerTool, pattern) {
|
|
|
68
69
|
return lowerTool === 'bash' ? 'Bash(*)' : `${tool}(**)`;
|
|
69
70
|
return `${tool}(${pattern})`;
|
|
70
71
|
}
|
|
71
|
-
function permissionSet(allow, deny) {
|
|
72
|
+
function permissionSet(allow, deny, ask = []) {
|
|
72
73
|
const uniqueAllow = [...new Set(allow)];
|
|
73
74
|
const uniqueDeny = [...new Set(deny)];
|
|
74
|
-
|
|
75
|
+
const uniqueAsk = [...new Set(ask)];
|
|
76
|
+
if (uniqueAllow.length === 0 && uniqueDeny.length === 0 && uniqueAsk.length === 0)
|
|
75
77
|
return null;
|
|
76
78
|
return {
|
|
77
79
|
name: 'exported',
|
|
78
80
|
allow: uniqueAllow,
|
|
79
81
|
...(uniqueDeny.length ? { deny: uniqueDeny } : {}),
|
|
82
|
+
...(uniqueAsk.length ? { ask: uniqueAsk } : {}),
|
|
80
83
|
};
|
|
81
84
|
}
|
|
82
85
|
export function stripJsonComments(content) {
|
|
@@ -169,8 +172,8 @@ function existingOr(preferred, alternate) {
|
|
|
169
172
|
function stringList(value) {
|
|
170
173
|
return Array.isArray(value) ? value.filter((v) => typeof v === 'string') : [];
|
|
171
174
|
}
|
|
172
|
-
function
|
|
173
|
-
const
|
|
175
|
+
function convertCodexRulesByDecision(content, wanted) {
|
|
176
|
+
const rules = [];
|
|
174
177
|
const marker = 'prefix_rule';
|
|
175
178
|
let searchFrom = 0;
|
|
176
179
|
while (searchFrom < content.length) {
|
|
@@ -188,7 +191,7 @@ function convertCodexRulesToDeny(content) {
|
|
|
188
191
|
const body = content.slice(open + 1, bodyEnd);
|
|
189
192
|
searchFrom = bodyEnd + 1;
|
|
190
193
|
const decision = body.match(/decision\s*=\s*"((?:\\.|[^"\\])*)"/);
|
|
191
|
-
if (!decision || decision[1] !==
|
|
194
|
+
if (!decision || decision[1] !== wanted)
|
|
192
195
|
continue;
|
|
193
196
|
const patternKw = body.search(/pattern\s*=/);
|
|
194
197
|
if (patternKw < 0)
|
|
@@ -211,9 +214,9 @@ function convertCodexRulesToDeny(content) {
|
|
|
211
214
|
const parts = parsed.filter((p) => typeof p === 'string' && p.length > 0);
|
|
212
215
|
if (parts.length === 0)
|
|
213
216
|
continue;
|
|
214
|
-
|
|
217
|
+
rules.push(`Bash(${parts.join(' ')}:*)`);
|
|
215
218
|
}
|
|
216
|
-
return
|
|
219
|
+
return rules;
|
|
217
220
|
}
|
|
218
221
|
function findMatchingCloser(source, openIdx, open, close) {
|
|
219
222
|
let depth = 0;
|
|
@@ -248,29 +251,59 @@ function findMatchingCloser(source, openIdx, open, close) {
|
|
|
248
251
|
}
|
|
249
252
|
return -1;
|
|
250
253
|
}
|
|
251
|
-
function
|
|
252
|
-
const rulesPath = path.join(path.dirname(configPath), 'rules',
|
|
254
|
+
function readCodexRulesFile(configPath, filename, decision) {
|
|
255
|
+
const rulesPath = path.join(path.dirname(configPath), 'rules', filename);
|
|
253
256
|
if (!fs.existsSync(rulesPath))
|
|
254
257
|
return [];
|
|
255
258
|
try {
|
|
256
|
-
return
|
|
259
|
+
return convertCodexRulesByDecision(fs.readFileSync(rulesPath, 'utf-8'), decision);
|
|
257
260
|
}
|
|
258
261
|
catch {
|
|
259
262
|
return [];
|
|
260
263
|
}
|
|
261
264
|
}
|
|
265
|
+
function readCodexDenyRules(configPath) {
|
|
266
|
+
return readCodexRulesFile(configPath, CODEX_RULES_FILENAME, 'forbidden');
|
|
267
|
+
}
|
|
268
|
+
function readCodexAskRules(configPath) {
|
|
269
|
+
return readCodexRulesFile(configPath, CODEX_ASK_RULES_FILENAME, 'prompt');
|
|
270
|
+
}
|
|
271
|
+
function droidAskRules(config) {
|
|
272
|
+
const block = config.permissionRules;
|
|
273
|
+
if (!block || typeof block !== 'object' || Array.isArray(block))
|
|
274
|
+
return [];
|
|
275
|
+
const rules = block.rules;
|
|
276
|
+
if (!Array.isArray(rules))
|
|
277
|
+
return [];
|
|
278
|
+
const ask = [];
|
|
279
|
+
for (const rule of rules) {
|
|
280
|
+
if (!rule || typeof rule !== 'object' || Array.isArray(rule))
|
|
281
|
+
continue;
|
|
282
|
+
const r = rule;
|
|
283
|
+
if (r.decision !== 'ask')
|
|
284
|
+
continue;
|
|
285
|
+
const prefix = r.match?.prefix;
|
|
286
|
+
if (!Array.isArray(prefix) || prefix.length === 0)
|
|
287
|
+
continue;
|
|
288
|
+
if (!prefix.every((part) => typeof part === 'string' && part.length > 0))
|
|
289
|
+
continue;
|
|
290
|
+
ask.push(`Bash(${prefix.join(' ')}:*)`);
|
|
291
|
+
}
|
|
292
|
+
return ask;
|
|
293
|
+
}
|
|
262
294
|
export const PERMISSION_TARGETS = {
|
|
263
295
|
claude: {
|
|
264
296
|
home: (h) => path.join(h, '.claude', 'settings.json'),
|
|
265
297
|
project: (cwd) => path.join(cwd, '.claude', 'settings.json'),
|
|
266
298
|
lossyBecause: 'canonical Write(...) is written as Edit(...), so it reads back as Edit',
|
|
299
|
+
ask: true,
|
|
267
300
|
toCanonical(configPath) {
|
|
268
301
|
const config = readJson(configPath);
|
|
269
302
|
const perms = config?.permissions;
|
|
270
303
|
if (!perms || typeof perms !== 'object' || Array.isArray(perms))
|
|
271
304
|
return null;
|
|
272
305
|
const p = perms;
|
|
273
|
-
const set = permissionSet(stringList(p.allow), stringList(p.deny));
|
|
306
|
+
const set = permissionSet(stringList(p.allow), stringList(p.deny), stringList(p.ask));
|
|
274
307
|
const dirs = stringList(p.additionalDirectories);
|
|
275
308
|
if (set && dirs.length)
|
|
276
309
|
set.additionalDirectories = dirs;
|
|
@@ -287,6 +320,7 @@ export const PERMISSION_TARGETS = {
|
|
|
287
320
|
'opencode.json',
|
|
288
321
|
],
|
|
289
322
|
lossyBecause: 'OpenCode gates Bash only, so non-Bash rules were never written',
|
|
323
|
+
ask: true,
|
|
290
324
|
toCanonical(configPath) {
|
|
291
325
|
const config = readJson(configPath);
|
|
292
326
|
const permission = config?.permission;
|
|
@@ -297,19 +331,23 @@ export const PERMISSION_TARGETS = {
|
|
|
297
331
|
return null;
|
|
298
332
|
const allow = [];
|
|
299
333
|
const deny = [];
|
|
334
|
+
const ask = [];
|
|
300
335
|
for (const [pattern, action] of Object.entries(bash)) {
|
|
301
336
|
if (action === 'allow')
|
|
302
337
|
allow.push(`Bash(${pattern})`);
|
|
303
338
|
else if (action === 'deny')
|
|
304
339
|
deny.push(`Bash(${pattern})`);
|
|
340
|
+
else if (action === 'ask')
|
|
341
|
+
ask.push(`Bash(${pattern})`);
|
|
305
342
|
}
|
|
306
|
-
return permissionSet(allow, deny);
|
|
343
|
+
return permissionSet(allow, deny, ask);
|
|
307
344
|
},
|
|
308
345
|
},
|
|
309
346
|
codex: {
|
|
310
347
|
home: (h) => path.join(h, '.codex', 'config.toml'),
|
|
311
348
|
project: (cwd) => path.join(cwd, '.codex', 'config.toml'),
|
|
312
|
-
lossyBecause: 'sandbox mode widens into representative blanket grants; deny round-trips from agents-deny.rules as Bash(prefix:*)',
|
|
349
|
+
lossyBecause: 'sandbox mode widens into representative blanket grants; deny round-trips from agents-deny.rules and ask from agents-ask.rules, both as Bash(prefix:*)',
|
|
350
|
+
ask: true,
|
|
313
351
|
toCanonical(configPath) {
|
|
314
352
|
const config = readToml(configPath);
|
|
315
353
|
const allow = [];
|
|
@@ -326,12 +364,13 @@ export const PERMISSION_TARGETS = {
|
|
|
326
364
|
allow.push('WebSearch(*)', 'WebFetch(*)');
|
|
327
365
|
}
|
|
328
366
|
}
|
|
329
|
-
return permissionSet(allow, readCodexDenyRules(configPath));
|
|
367
|
+
return permissionSet(allow, readCodexDenyRules(configPath), readCodexAskRules(configPath));
|
|
330
368
|
},
|
|
331
369
|
},
|
|
332
370
|
cursor: {
|
|
333
371
|
home: (h) => path.join(h, '.cursor', 'cli-config.json'),
|
|
334
372
|
lossyBecause: 'canonical Bash reads back from Shell(...) and Edit was written as Write(...)',
|
|
373
|
+
ask: { reason: 'Cursor permissions are allow and deny lists; cli-config.json has no ask list' },
|
|
335
374
|
toCanonical(configPath) {
|
|
336
375
|
const config = readJson(configPath);
|
|
337
376
|
const perms = config?.permissions;
|
|
@@ -345,6 +384,7 @@ export const PERMISSION_TARGETS = {
|
|
|
345
384
|
antigravity: {
|
|
346
385
|
home: (h) => path.join(h, '.gemini', 'antigravity-cli', 'settings.json'),
|
|
347
386
|
lossyBecause: 'only command/read_file/write_file/read_url map, so other canonical tools were never written',
|
|
387
|
+
ask: true,
|
|
348
388
|
toCanonical(configPath) {
|
|
349
389
|
const config = readJson(configPath);
|
|
350
390
|
const perms = config?.permissions;
|
|
@@ -365,12 +405,13 @@ export const PERMISSION_TARGETS = {
|
|
|
365
405
|
}
|
|
366
406
|
return out;
|
|
367
407
|
};
|
|
368
|
-
return permissionSet(back(stringList(p.allow)), back(stringList(p.deny)));
|
|
408
|
+
return permissionSet(back(stringList(p.allow)), back(stringList(p.deny)), back(stringList(p.ask)));
|
|
369
409
|
},
|
|
370
410
|
},
|
|
371
411
|
grok: {
|
|
372
412
|
home: (h) => path.join(h, '.grok', 'config.toml'),
|
|
373
413
|
lossyBecause: 'canonical Write is written as Grok `edit`, so it reads back as Edit',
|
|
414
|
+
ask: true,
|
|
374
415
|
toCanonical(configPath) {
|
|
375
416
|
const config = readToml(configPath);
|
|
376
417
|
const permission = config?.permission;
|
|
@@ -381,6 +422,7 @@ export const PERMISSION_TARGETS = {
|
|
|
381
422
|
return null;
|
|
382
423
|
const allow = [];
|
|
383
424
|
const deny = [];
|
|
425
|
+
const ask = [];
|
|
384
426
|
for (const rule of rules) {
|
|
385
427
|
if (!rule || typeof rule !== 'object' || Array.isArray(rule))
|
|
386
428
|
continue;
|
|
@@ -395,15 +437,18 @@ export const PERMISSION_TARGETS = {
|
|
|
395
437
|
const canonical = canonicalRule(lowerTool, pattern);
|
|
396
438
|
if (r.action === 'deny')
|
|
397
439
|
deny.push(canonical);
|
|
440
|
+
else if (r.action === 'ask')
|
|
441
|
+
ask.push(canonical);
|
|
398
442
|
else if (r.action === 'allow')
|
|
399
443
|
allow.push(canonical);
|
|
400
444
|
}
|
|
401
|
-
return permissionSet(allow, deny);
|
|
445
|
+
return permissionSet(allow, deny, ask);
|
|
402
446
|
},
|
|
403
447
|
},
|
|
404
448
|
kimi: {
|
|
405
449
|
home: (h) => path.join(h, '.kimi-code', 'config.toml'),
|
|
406
450
|
lossyBecause: 'each Bash arg-glob was written as two picomatch patterns, which collapse back to one rule',
|
|
451
|
+
ask: true,
|
|
407
452
|
toCanonical(configPath) {
|
|
408
453
|
const config = readToml(configPath);
|
|
409
454
|
const permission = config?.permission;
|
|
@@ -414,6 +459,7 @@ export const PERMISSION_TARGETS = {
|
|
|
414
459
|
return null;
|
|
415
460
|
const allow = [];
|
|
416
461
|
const deny = [];
|
|
462
|
+
const ask = [];
|
|
417
463
|
for (const rule of rules) {
|
|
418
464
|
if (!rule || typeof rule !== 'object' || Array.isArray(rule))
|
|
419
465
|
continue;
|
|
@@ -425,26 +471,30 @@ export const PERMISSION_TARGETS = {
|
|
|
425
471
|
continue;
|
|
426
472
|
if (r.decision === 'deny')
|
|
427
473
|
deny.push(canonical);
|
|
474
|
+
else if (r.decision === 'ask')
|
|
475
|
+
ask.push(canonical);
|
|
428
476
|
else if (r.decision === 'allow')
|
|
429
477
|
allow.push(canonical);
|
|
430
478
|
}
|
|
431
|
-
return permissionSet(allow, deny);
|
|
479
|
+
return permissionSet(allow, deny, ask);
|
|
432
480
|
},
|
|
433
481
|
},
|
|
434
482
|
droid: {
|
|
435
483
|
home: (h) => path.join(h, '.factory', 'settings.json'),
|
|
436
484
|
lossyBecause: 'Droid gates shell commands only, so non-Bash rules were never written',
|
|
485
|
+
ask: true,
|
|
437
486
|
toCanonical(configPath) {
|
|
438
487
|
const config = readJson(configPath);
|
|
439
488
|
if (!config)
|
|
440
489
|
return null;
|
|
441
490
|
const back = (commands) => commands.map((c) => (c === '*' ? 'Bash(*)' : `Bash(${denormalizeBashPattern(c)})`));
|
|
442
|
-
return permissionSet(back(stringList(config.commandAllowlist)), back(stringList(config.commandDenylist)));
|
|
491
|
+
return permissionSet(back(stringList(config.commandAllowlist)), back(stringList(config.commandDenylist)), droidAskRules(config));
|
|
443
492
|
},
|
|
444
493
|
},
|
|
445
494
|
copilot: {
|
|
446
495
|
home: (h) => path.join(h, '.copilot', 'permissions-config.json'),
|
|
447
496
|
lossyBecause: 'approvals are per working directory and read/write are whole-tool kinds with no path',
|
|
497
|
+
ask: { reason: 'Copilot stores pre-approved tool_approvals only; there is no per-rule ask list' },
|
|
448
498
|
toCanonical(configPath) {
|
|
449
499
|
const config = readJson(configPath);
|
|
450
500
|
const locations = config?.locations;
|
|
@@ -482,6 +532,7 @@ export const PERMISSION_TARGETS = {
|
|
|
482
532
|
openclaw: {
|
|
483
533
|
home: (h) => path.join(h, '.openclaw', 'openclaw.json'),
|
|
484
534
|
lossyBecause: 'OpenClaw gates whole tools, so only blanket rules were written and all read back as blanket',
|
|
535
|
+
ask: { reason: 'OpenClaw ask is an exec mode (allowlist on miss), not a per-command ask rule' },
|
|
485
536
|
toCanonical(configPath) {
|
|
486
537
|
const config = readJson(configPath);
|
|
487
538
|
const tools = config?.tools;
|
|
@@ -498,6 +549,7 @@ export const PERMISSION_TARGETS = {
|
|
|
498
549
|
hermes: {
|
|
499
550
|
home: (h) => path.join(h, '.hermes', 'config.yaml'),
|
|
500
551
|
lossyBecause: 'Hermes gates shell commands only, so non-Bash rules were never written',
|
|
552
|
+
ask: { reason: 'Hermes has a global approvals mode plus allow and deny lists, not a per-command ask list' },
|
|
501
553
|
toCanonical(configPath) {
|
|
502
554
|
const config = readYaml(configPath);
|
|
503
555
|
if (!config)
|