unbound-cli 1.23.0 → 1.25.0

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.
@@ -131,6 +131,12 @@ function formatToolTypes(types) {
131
131
  return types.join(', ');
132
132
  }
133
133
 
134
+ /** --tools value as the body's scope_tool_types: "all" clears the targets; ids are checked by the server. */
135
+ function parseToolIds(value) {
136
+ if (String(value).trim().toLowerCase() === 'all') return [];
137
+ return parseCommaSeparated(value).map((t) => t.toUpperCase());
138
+ }
139
+
134
140
  function displayPolicy(policy) {
135
141
  if (!policy) {
136
142
  output.warn('No policy data to display.');
@@ -194,6 +200,7 @@ function displayToolPolicy(policy) {
194
200
  ['Status', policy.status || '-'],
195
201
  ['Custom Message', policy.custom_message || '-'],
196
202
  ['Scope Groups', formatScope(policy.scope_user_groups)],
203
+ ['AI Tools', formatToolTypes(policy.scope_tool_types)],
197
204
  ];
198
205
  if (policy.policy_type === 'TERMINAL_COMMAND') {
199
206
  rows.push(['Command Family', policy.command_family || '-']);
@@ -1410,6 +1417,7 @@ Subcommands:
1410
1417
  { key: 'action', header: 'Action' },
1411
1418
  { key: 'enabled', header: 'Enabled', format: (v) => (v ? 'yes' : 'no') },
1412
1419
  { key: 'scope_user_groups', header: 'Scope', format: (v) => formatScope(v) },
1420
+ { key: 'scope_tool_types', header: 'AI Tools', format: (v) => formatToolTypes(v) },
1413
1421
  ]);
1414
1422
 
1415
1423
  if (!opts.all && meta.total_pages && meta.total_pages > 1) {
@@ -1475,6 +1483,7 @@ Subcommands:
1475
1483
  .option('--description <text>', 'Human-readable description')
1476
1484
  .option('--custom-message <text>', 'Message shown to the user when the policy fires. Required when --action is BLOCK or WARN.')
1477
1485
  .option('--group <names|ids>', 'Comma-separated user group names or IDs to scope this policy to')
1486
+ .option('--tools <ids>', 'Comma-separated AI tool ids this policy applies to (e.g. CURSOR,CODEX); default all tools')
1478
1487
  .option('--disabled', 'Create the policy in disabled state')
1479
1488
  .option('--config <json>', 'Advanced: raw config JSON (skips --field builder)')
1480
1489
  .option('--yes', 'Skip the confirmation prompt for --prompt flows (preview is still printed)')
@@ -1563,6 +1572,7 @@ Learn more: ${DOCS_TOOL}
1563
1572
  return;
1564
1573
  }
1565
1574
  const body = result.body;
1575
+ if (opts.tools !== undefined) body.scope_tool_types = parseToolIds(opts.tools);
1566
1576
  let data;
1567
1577
  try {
1568
1578
  data = await api.post('/api/v1/command-policies/', { body });
@@ -1636,6 +1646,7 @@ Learn more: ${DOCS_TOOL}
1636
1646
  const formData = await loadFormData();
1637
1647
  body.scope_user_group_ids = resolveByName(formData.user_groups || [], opts.group, { kind: 'user group' });
1638
1648
  }
1649
+ if (opts.tools !== undefined) body.scope_tool_types = parseToolIds(opts.tools);
1639
1650
 
1640
1651
  const data = await api.post('/api/v1/command-policies/', { body });
1641
1652
  if (opts.json) {
@@ -1663,6 +1674,7 @@ Learn more: ${DOCS_TOOL}
1663
1674
  .option('--description <text>', 'Human-readable description. Override AI suggestion when used with --prompt.')
1664
1675
  .option('--custom-message <text>', 'Message shown to the user when the policy fires. Required when --action is BLOCK or WARN. Override AI suggestion when used with --prompt.')
1665
1676
  .option('--group <names|ids>', 'Comma-separated user group names or IDs to scope this policy to')
1677
+ .option('--tools <ids>', 'Comma-separated AI tool ids this policy applies to (e.g. CURSOR,CODEX); default all tools')
1666
1678
  .option('--disabled', 'Create the policy in disabled state')
1667
1679
  .option('--config <json>', 'Advanced: raw config JSON')
1668
1680
  .option('--yes', 'Skip the confirmation prompt for --prompt flows (preview is still printed)')
@@ -1741,6 +1753,7 @@ Learn more: ${DOCS_TOOL}
1741
1753
  return;
1742
1754
  }
1743
1755
  const body = result.body;
1756
+ if (opts.tools !== undefined) body.scope_tool_types = parseToolIds(opts.tools);
1744
1757
  let data;
1745
1758
  try {
1746
1759
  data = await api.post('/api/v1/command-policies/', { body });
@@ -1811,6 +1824,7 @@ Learn more: ${DOCS_TOOL}
1811
1824
  const formData = await loadFormData();
1812
1825
  body.scope_user_group_ids = resolveByName(formData.user_groups || [], opts.group, { kind: 'user group' });
1813
1826
  }
1827
+ if (opts.tools !== undefined) body.scope_tool_types = parseToolIds(opts.tools);
1814
1828
 
1815
1829
  const data = await api.post('/api/v1/command-policies/', { body });
1816
1830
  if (opts.json) {
@@ -1833,6 +1847,7 @@ Learn more: ${DOCS_TOOL}
1833
1847
  .option('--action <action>', `New action: ${TOOL_ACTIONS.join(' | ')}`)
1834
1848
  .option('--custom-message <text>', 'New custom message')
1835
1849
  .option('--group <names|ids>', 'Replace scope')
1850
+ .option('--tools <ids>', 'Replace the AI tools this policy applies to (comma-separated ids, or "all")')
1836
1851
  .option('--enabled', 'Enable the policy')
1837
1852
  .option('--disabled', 'Disable the policy')
1838
1853
  .option('--command-family <family>', '(TERMINAL only) new command family')
@@ -1884,6 +1899,7 @@ Learn more: ${DOCS_TOOL}
1884
1899
  const formData = await loadFormData();
1885
1900
  body.scope_user_group_ids = resolveByName(formData.user_groups || [], opts.group, { kind: 'user group' });
1886
1901
  }
1902
+ if (opts.tools !== undefined) body.scope_tool_types = parseToolIds(opts.tools);
1887
1903
 
1888
1904
  if ((body.action === 'BLOCK' || body.action === 'WARN') && !body.custom_message && opts.customMessage === undefined) {
1889
1905
  output.warn('Action changed to BLOCK/WARN without --custom-message. The existing custom_message will remain; pass --custom-message to replace it.');
package/src/index.js CHANGED
@@ -183,6 +183,15 @@ FLAGS AND FALSE POSITIVES (Admin/Analytics Viewer/Manager; mark-fp is Admin only
183
183
  Mark a detection as a false positive
184
184
  $ unbound trace <trace-id> Log, terminal runs and data security for one trace ID
185
185
 
186
+ DELIVERY (Admin/Analytics Viewer, whole organization)
187
+ $ unbound delivery summary Branches, PRs opened and merged, spend, cost per PR
188
+ $ unbound delivery branches AI branches with PR, ticket, work group and cost
189
+ $ unbound delivery branch <id> One branch with its timeline and sessions
190
+ $ unbound delivery users | teams Spend, PRs and merges per person or department
191
+ $ unbound delivery spend --by outcome|work-group
192
+ AI spend by PR outcome or work group
193
+ $ unbound delivery repos Repositories to pass to --repo
194
+
186
195
  FALSE POSITIVES ON YOUR OWN REQUESTS (any user)
187
196
  $ unbound false-positive list <trace-id> Your findings on a blocked request
188
197
  $ unbound false-positive mark <trace-id> Mark one as a false positive
@@ -232,6 +241,7 @@ require('./commands/user-groups').register(program);
232
241
  require('./commands/tools').register(program);
233
242
  require('./commands/analytics').register(program);
234
243
  require('./commands/flags').register(program);
244
+ require('./commands/delivery').register(program);
235
245
  require('./commands/trace').register(program);
236
246
  require('./commands/false-positive').register(program);
237
247
  require('./commands/download').register(program);
@@ -40,8 +40,12 @@ function toolRowToPolicy(row) {
40
40
  p.mcp = mcp;
41
41
  if (row.config && Object.keys(row.config).length) p.config = row.config;
42
42
  }
43
+ const scope = {};
43
44
  const groups = groupNames(row);
44
- if (groups.length) p.scope = { userGroups: groups };
45
+ if (groups.length) scope.userGroups = groups;
46
+ // An empty list is exported too: a tool pack that omits toolTypes leaves the live targets alone.
47
+ if (Array.isArray(row.scope_tool_types)) scope.toolTypes = [...row.scope_tool_types];
48
+ if (Object.keys(scope).length) p.scope = scope;
45
49
  return p;
46
50
  }
47
51
 
@@ -181,6 +181,9 @@ function expandActionType(ref, server, actionType) {
181
181
  return [...tools].sort();
182
182
  }
183
183
 
184
+ // The server stores these legacy ids under their current names, so plans compare the current name.
185
+ const LEGACY_TOOL_IDS = { UNBOUND_CLAUDE_CODE: 'CLAUDE_CODE', UNBOUND_CODEX: 'CODEX' };
186
+
184
187
  function toolDesired(policy, ref, where) {
185
188
  const scopeIds = resolveIds(ref.userGroups, policy.scope && policy.scope.userGroups, 'user group', { where });
186
189
  const body = {
@@ -202,6 +205,11 @@ function toolDesired(policy, ref, where) {
202
205
  enabled: body.enabled,
203
206
  scope_user_group_ids: scopeIds,
204
207
  };
208
+ // Tool targets are managed only when the pack lists them, so packs without the field plan no change.
209
+ if (policy.scope && policy.scope.toolTypes !== undefined) {
210
+ body.scope_tool_types = [...new Set(policy.scope.toolTypes.map((t) => LEGACY_TOOL_IDS[t] || t))].sort();
211
+ proj.scope_tool_types = body.scope_tool_types;
212
+ }
205
213
  let mcp = null;
206
214
  if (policy.type === 'TERMINAL_COMMAND') {
207
215
  body.command_family = policy.commandFamily;
@@ -319,6 +327,7 @@ function liveProjection(row, table) {
319
327
  description: row.description || '',
320
328
  enabled: row.enabled !== undefined ? !!row.enabled : row.status === 'ACTIVE',
321
329
  scope_user_group_ids: scopeIds,
330
+ scope_tool_types: [...new Set(row.scope_tool_types || [])].sort(),
322
331
  };
323
332
  if (row.policy_type === 'TERMINAL_COMMAND') {
324
333
  proj.command_family = row.command_family;
@@ -358,6 +367,7 @@ const PROJ_TO_BODY = {
358
367
  description: (d) => ({ description: d.body.description }),
359
368
  enabled: (d) => ({ enabled: d.body.enabled }),
360
369
  scope_user_group_ids: (d) => ({ scope_user_group_ids: d.body.scope_user_group_ids }),
370
+ scope_tool_types: (d) => ({ scope_tool_types: d.body.scope_tool_types }),
361
371
  command_family: (d) => ({ command_family: d.body.command_family, config: d.body.config }),
362
372
  config: (d) => (d.body.policy_type === 'TERMINAL_COMMAND'
363
373
  ? { command_family: d.body.command_family, config: d.body.config }
@@ -404,6 +414,12 @@ function findBySlug(rows, slug) {
404
414
  * live: { tool: [rows], generic: [rows] } — only rows under this pack's prefix
405
415
  * options.prune: delete managed rows absent from the pack
406
416
  */
417
+ // A pack without toolTypes leaves targets unmanaged, so a replacement keeps the live row's.
418
+ function replaceBody(d, row) {
419
+ if (d.proj.scope_tool_types !== undefined || !Array.isArray(row.scope_tool_types) || !row.scope_tool_types.length) return d.body;
420
+ return { ...d.body, scope_tool_types: [...row.scope_tool_types] };
421
+ }
422
+
407
423
  function buildPlan(desired, live, { prune = false } = {}) {
408
424
  const ops = [];
409
425
  const matchedTool = new Set();
@@ -465,7 +481,7 @@ function buildPlan(desired, live, { prune = false } = {}) {
465
481
  const liveProj = liveProjection(row, d.table);
466
482
  if (d.table === 'tool' && (row.policy_type !== d.body.policy_type || (d.proj.mcp_server && liveProj.mcp_server !== d.proj.mcp_server))) {
467
483
  const what = row.policy_type !== d.body.policy_type ? `type ${row.policy_type} -> ${d.body.policy_type}` : `MCP server ${liveProj.mcp_server} -> ${d.proj.mcp_server}`;
468
- ops.push({ ...base, op: 'replace', row, body: d.body, changes: [{ field: 'identity', from: row.policy_type, to: d.body.policy_type }], reason: what });
484
+ ops.push({ ...base, op: 'replace', row, body: replaceBody(d, row), changes: [{ field: 'identity', from: row.policy_type, to: d.body.policy_type }], reason: what });
469
485
  continue;
470
486
  }
471
487
 
@@ -485,7 +501,7 @@ function buildPlan(desired, live, { prune = false } = {}) {
485
501
  Object.assign(body, patch);
486
502
  }
487
503
  if (unpatchable) {
488
- ops.push({ ...base, op: 'replace', row, body: d.body, changes, reason: `${unpatchable} cannot be patched in place` });
504
+ ops.push({ ...base, op: 'replace', row, body: replaceBody(d, row), changes, reason: `${unpatchable} cannot be patched in place` });
489
505
  } else {
490
506
  ops.push({ ...base, op: 'update', row, body, changes });
491
507
  }
@@ -89,16 +89,15 @@ function rejectUnknownKeys(obj, allowed, where, file) {
89
89
  }
90
90
  }
91
91
 
92
- function validateScope(scope, where, file, { allowToolTypes }) {
92
+ function validateScope(scope, where, file) {
93
93
  if (scope === undefined) return undefined;
94
94
  if (!isPlainObject(scope)) throw new PackError(`${where}.scope must be an object`, { file });
95
95
  rejectUnknownKeys(scope, SCOPE_KEYS, `${where}.scope`, file);
96
96
  if (scope.userGroups !== undefined && !isStringArray(scope.userGroups)) {
97
97
  throw new PackError(`${where}.scope.userGroups must be a list of user group names`, { file });
98
98
  }
99
- if (scope.toolTypes !== undefined) {
100
- if (!allowToolTypes) throw new PackError(`${where}.scope.toolTypes applies to security, model and cost policies only`, { file });
101
- if (!isStringArray(scope.toolTypes)) throw new PackError(`${where}.scope.toolTypes must be a list of tool type names`, { file });
99
+ if (scope.toolTypes !== undefined && !isStringArray(scope.toolTypes)) {
100
+ throw new PackError(`${where}.scope.toolTypes must be a list of tool type names`, { file });
102
101
  }
103
102
  return scope;
104
103
  }
@@ -129,7 +128,7 @@ function validateDefaults(defaults, file) {
129
128
  rejectUnknownKeys(defaults, DEFAULTS_KEYS, 'defaults', file);
130
129
  if (defaults.enabled !== undefined && typeof defaults.enabled !== 'boolean') throw new PackError('defaults.enabled must be true or false', { file });
131
130
  if (defaults.labels !== undefined && !isStringArray(defaults.labels)) throw new PackError('defaults.labels must be a list of label names', { file });
132
- validateScope(defaults.scope, 'defaults', file, { allowToolTypes: true });
131
+ validateScope(defaults.scope, 'defaults', file);
133
132
  return defaults;
134
133
  }
135
134
 
@@ -296,7 +295,7 @@ function validatePack(doc, file) {
296
295
  const label = `${where} (${raw.id})`;
297
296
  if (raw.kind === 'tool') validateToolPolicy(raw, label, file);
298
297
  else validateGenericPolicy(raw, label, file);
299
- validateScope(raw.scope, label, file, { allowToolTypes: raw.kind !== 'tool' });
298
+ validateScope(raw.scope, label, file);
300
299
 
301
300
  const merged = mergeDefaults(raw, defaults);
302
301
  return {