@phnx-labs/agents-cli 1.23.10 → 1.23.12

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.
@@ -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
- if (uniqueAllow.length === 0 && uniqueDeny.length === 0)
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 convertCodexRulesToDeny(content) {
173
- const deny = [];
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] !== 'forbidden')
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
- deny.push(`Bash(${parts.join(' ')}:*)`);
217
+ rules.push(`Bash(${parts.join(' ')}:*)`);
215
218
  }
216
- return deny;
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 readCodexDenyRules(configPath) {
252
- const rulesPath = path.join(path.dirname(configPath), 'rules', CODEX_RULES_FILENAME);
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 convertCodexRulesToDeny(fs.readFileSync(rulesPath, 'utf-8'));
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)
@@ -1,6 +1,6 @@
1
1
  import type { AgentId, PermissionSet, InstalledPermission, ClaudePermissions, CursorPermissions, OpenCodePermissions, CodexPermissions } from './types.js';
2
- import { CODEX_RULES_FILENAME } from './permissions-registry.js';
3
- export { CODEX_RULES_FILENAME };
2
+ import { CODEX_ASK_RULES_FILENAME, CODEX_RULES_FILENAME } from './permissions-registry.js';
3
+ export { CODEX_ASK_RULES_FILENAME, CODEX_RULES_FILENAME };
4
4
  type ParsedRules = PermissionSet;
5
5
  export declare const COMPUTER_APP_GATED_VERBS: readonly ["screenshot", "describe", "get-text", "launch", "raise", "click", "right-click", "type", "type-text", "key", "drag", "scroll", "ax-action", "focus", "wait"];
6
6
  export declare function formatComputerPermissionGrantHint(bundleId?: string): string;
@@ -9,6 +9,7 @@ export declare function containsBroadGrants(rules: ParsedRules): {
9
9
  reason: string;
10
10
  } | null;
11
11
  export declare function convertDenyToCodexRules(deny: string[]): string | null;
12
+ export declare function convertAskToCodexRules(ask: string[]): string | null;
12
13
  export declare function parsePermissionSet(filePath: string): PermissionSet | null;
13
14
  export declare function discoverPermissionsFromRepo(repoPath: string): Array<{
14
15
  name: string;
@@ -59,9 +60,21 @@ interface CopilotPermissionsConfig {
59
60
  }>;
60
61
  }
61
62
  export declare function convertToCopilotFormat(set: PermissionSet, location: string): CopilotPermissionsConfig;
63
+ interface DroidAskRule {
64
+ id: string;
65
+ decision: 'ask';
66
+ match: {
67
+ prefix: string[];
68
+ };
69
+ tests: {
70
+ match: string[];
71
+ noMatch: string[];
72
+ };
73
+ }
62
74
  export declare function convertToDroidFormat(set: PermissionSet): {
63
75
  commandAllowlist: string[];
64
76
  commandDenylist: string[];
77
+ askRules?: DroidAskRule[];
65
78
  };
66
79
  export declare function convertToOpenClawFormat(set: PermissionSet): {
67
80
  alsoAllow: string[];
@@ -77,6 +90,7 @@ export declare function convertToAntigravityFormat(set: PermissionSet): {
77
90
  permissions: {
78
91
  allow: string[];
79
92
  deny?: string[];
93
+ ask?: string[];
80
94
  };
81
95
  };
82
96
  export declare function convertToGrokFormat(set: PermissionSet): {
@@ -85,12 +99,12 @@ export declare function convertToGrokFormat(set: PermissionSet): {
85
99
  };
86
100
  };
87
101
  type GrokRule = {
88
- action: 'allow' | 'deny';
102
+ action: 'allow' | 'deny' | 'ask';
89
103
  tool: string;
90
104
  pattern?: string;
91
105
  };
92
106
  type KimiRule = {
93
- decision: 'allow' | 'deny';
107
+ decision: 'allow' | 'deny' | 'ask';
94
108
  pattern: string;
95
109
  };
96
110
  export declare function convertToKimiFormat(set: PermissionSet): {
@@ -109,10 +123,12 @@ export declare function applyClaudePermissions(set: PermissionSet, scope?: 'user
109
123
  error?: string;
110
124
  };
111
125
  export declare function openCodeConfigPath(scope: 'user' | 'project', cwd?: string, home?: string): string;
112
- export declare function applyPermissionsToVersion(agentId: AgentId, set: PermissionSet, versionHome: string, merge?: boolean, cwd?: string): {
126
+ export type ApplyPermissionsResult = {
113
127
  success: boolean;
114
128
  error?: string;
129
+ skipped?: string[];
115
130
  };
131
+ export declare function applyPermissionsToVersion(agentId: AgentId, set: PermissionSet, versionHome: string, merge?: boolean, cwd?: string): ApplyPermissionsResult;
116
132
  export declare function claudeToCanonical(perms: ClaudePermissions): PermissionSet;
117
133
  export declare function openCodeToCanonical(perms: OpenCodePermissions): PermissionSet;
118
134
  export declare function codexToCanonical(perms: CodexPermissions): PermissionSet;
@@ -128,6 +144,10 @@ export declare function computePermissionsDiff(existing: PermissionSet, incoming
128
144
  added: string[];
129
145
  existing: string[];
130
146
  };
147
+ ask: {
148
+ added: string[];
149
+ existing: string[];
150
+ };
131
151
  };
132
152
  export declare function mergePermissionSets(existing: PermissionSet, incoming: PermissionSet): PermissionSet;
133
153
  export declare function saveDefaultPermissionSet(set: PermissionSet): {