unbound-cli 1.16.11 → 1.16.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.
package/README.md CHANGED
@@ -254,7 +254,7 @@ Alias: `unbound groups` works the same as `unbound user-groups`.
254
254
  | `unbound tools connect <type>` | Connect a tool |
255
255
  | `unbound tools approved` | List approved tool types |
256
256
 
257
- Supported tool types: `CLAUDE_CODE`, `UNBOUND_CLAUDE_CODE`, `CURSOR`, `COPILOT`, `AUGMENT_CODE`, `ROO_CODE`, `CLINE`, `GEMINI_CLI`, `CODEX`, `UNBOUND_CODEX`, `KILO_CODE`, `CUSTOM_ACCESS`
257
+ Supported tool types: `CLAUDE_CODE`, `CURSOR`, `COPILOT`, `AUGMENT_CODE`, `ROO_CODE`, `CLINE`, `GEMINI_CLI`, `CODEX`, `KILO_CODE`, `CUSTOM_ACCESS`
258
258
 
259
259
  ## Configuration
260
260
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unbound-cli",
3
- "version": "1.16.11",
3
+ "version": "1.16.12",
4
4
  "description": "CLI tool for Unbound - AI Gateway management",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -12,7 +12,6 @@ const SUPPORTED_TOOL_TYPES = [
12
12
  'CLINE',
13
13
  'GEMINI_CLI',
14
14
  'CODEX',
15
- 'UNBOUND_CODEX',
16
15
  'KILO_CODE',
17
16
  'CUSTOM_ACCESS',
18
17
  ];
@@ -181,4 +180,4 @@ Examples:
181
180
  });
182
181
  }
183
182
 
184
- module.exports = { register };
183
+ module.exports = { register, SUPPORTED_TOOL_TYPES };
@@ -0,0 +1,55 @@
1
+ const { test } = require('node:test');
2
+ const assert = require('node:assert/strict');
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const { SUPPORTED_TOOL_TYPES } = require('../src/commands/tools');
6
+
7
+ // Cross-repo contract: every tool type the CLI offers must be one the backend's
8
+ // agents API accepts, or `tools connect` sends a request the backend answers
9
+ // with 400. Rather than mirror the backend list by hand (which silently drifts),
10
+ // this reads the REAL allowlist from ai-gateway-data at
11
+ // webapp/api/v1/agent_handlers.py::SUPPORTED_AGENT_TOOL_TYPES.
12
+ //
13
+ // The backend repo isn't a dependency of the CLI, so when it isn't checked out
14
+ // beside this one the test skips rather than failing — it runs wherever the
15
+ // fleet is present (a dev machine, the cross-repo CI stage) and is a no-op
16
+ // elsewhere. Point it explicitly with AI_GATEWAY_DATA_DIR.
17
+
18
+ const HANDLERS_REL = 'webapp/api/v1/agent_handlers.py';
19
+
20
+ function findBackendFile() {
21
+ const candidates = [];
22
+ if (process.env.AI_GATEWAY_DATA_DIR) {
23
+ candidates.push(path.join(process.env.AI_GATEWAY_DATA_DIR, HANDLERS_REL));
24
+ }
25
+ // Common layouts: a sibling checkout next to unbound-cli.
26
+ const repoRoot = path.join(__dirname, '..');
27
+ candidates.push(path.join(repoRoot, '..', 'ai-gateway-data', HANDLERS_REL));
28
+ candidates.push(path.join(repoRoot, '..', '..', 'ai-gateway-data', HANDLERS_REL));
29
+ return candidates.find((p) => { try { return fs.existsSync(p); } catch { return false; } });
30
+ }
31
+
32
+ function parseBackendAllowlist(file) {
33
+ const src = fs.readFileSync(file, 'utf8');
34
+ const m = src.match(/SUPPORTED_AGENT_TOOL_TYPES\s*=\s*\[([\s\S]*?)\]/);
35
+ assert.ok(m, 'could not locate SUPPORTED_AGENT_TOOL_TYPES in agent_handlers.py');
36
+ const types = [...m[1].matchAll(/['"]([A-Z_]+)['"]/g)].map((x) => x[1]);
37
+ assert.ok(types.length > 0, 'parsed an empty backend allowlist');
38
+ return new Set(types);
39
+ }
40
+
41
+ const backendFile = findBackendFile();
42
+
43
+ test('every CLI-offered tool type is in the REAL backend agent_handlers allowlist',
44
+ { skip: backendFile ? false : 'ai-gateway-data not checked out (set AI_GATEWAY_DATA_DIR)' },
45
+ () => {
46
+ const accepted = parseBackendAllowlist(backendFile);
47
+ for (const type of SUPPORTED_TOOL_TYPES) {
48
+ assert.ok(accepted.has(type),
49
+ `CLI offers ${type} but the backend allowlist does not accept it (would 400)`);
50
+ }
51
+ // Guard the specific regression: the removed type must be absent from the CLI
52
+ // list precisely because the backend rejects it.
53
+ assert.ok(!SUPPORTED_TOOL_TYPES.includes('UNBOUND_CODEX') || accepted.has('UNBOUND_CODEX'),
54
+ 'UNBOUND_CODEX may only be offered if the backend accepts it');
55
+ });
@@ -0,0 +1,85 @@
1
+ const { test } = require('node:test');
2
+ const assert = require('node:assert/strict');
3
+ const { Command } = require('commander');
4
+
5
+ const config = require('../src/config');
6
+ const api = require('../src/api');
7
+ const output = require('../src/output');
8
+ const { register, SUPPORTED_TOOL_TYPES } = require('../src/commands/tools');
9
+
10
+ // Mirror of ai-gateway-data webapp/api/v1/agent_handlers.py SUPPORTED_AGENT_TOOL_TYPES.
11
+ // `tools connect` must only offer types this backend accepts; anything else gets a 400.
12
+ const BACKEND_ACCEPTED = new Set([
13
+ 'CLAUDE_CODE', 'UNBOUND_CLAUDE_CODE', 'CURSOR', 'COPILOT',
14
+ 'ROO_CODE', 'CLINE', 'GEMINI_CLI', 'CODEX', 'KILO_CODE', 'OPENCLAW',
15
+ 'CUSTOM_ACCESS', 'AUGMENT_CODE',
16
+ ]);
17
+
18
+ // Drive the real `tools connect` action with login + api stubbed. Returns
19
+ // { reachedApi, sentType, errored } so a test can tell a type accepted by the
20
+ // CLI (reaches the connect call) from one the CLI rejects before any request.
21
+ async function connect(toolType) {
22
+ const orig = {
23
+ isLoggedIn: config.isLoggedIn,
24
+ post: api.post,
25
+ error: output.error,
26
+ success: output.success,
27
+ keyValue: output.keyValue,
28
+ json: output.json,
29
+ exitCode: process.exitCode,
30
+ };
31
+ let reachedApi = false;
32
+ let sentType = null;
33
+ let errored = false;
34
+ let errorMsg = '';
35
+ config.isLoggedIn = () => true;
36
+ api.post = async (_path, { body }) => { reachedApi = true; sentType = body.tool_type; return { tool_type: body.tool_type, status: 'connected' }; };
37
+ output.error = (m) => { errored = true; errorMsg = String(m ?? ''); };
38
+ output.success = () => {};
39
+ output.keyValue = () => {};
40
+ output.json = () => {};
41
+ try {
42
+ const program = new Command();
43
+ register(program);
44
+ await program.parseAsync(['node', 'x', 'tools', 'connect', toolType]);
45
+ return { reachedApi, sentType, errored, errorMsg, exitCode: process.exitCode };
46
+ } finally {
47
+ config.isLoggedIn = orig.isLoggedIn;
48
+ api.post = orig.post;
49
+ output.error = orig.error;
50
+ output.success = orig.success;
51
+ output.keyValue = orig.keyValue;
52
+ output.json = orig.json;
53
+ process.exitCode = orig.exitCode;
54
+ }
55
+ }
56
+
57
+ // The backend rejects UNBOUND_CODEX with a 400, so the CLI must not offer it.
58
+ test('tools connect UNBOUND_CODEX is rejected before any backend call', async () => {
59
+ const r = await connect('UNBOUND_CODEX');
60
+ assert.equal(r.reachedApi, false, 'must not send an UNBOUND_CODEX connect request');
61
+ assert.equal(r.errored, true, 'must report an unsupported-type error');
62
+ assert.equal(r.exitCode, 1, 'must exit non-zero so scripts see the rejection');
63
+ // The error points the user at the real types: it names the supported set,
64
+ // including the correct CODEX to reach for instead.
65
+ assert.match(r.errorMsg, /Supported types:/);
66
+ assert.match(r.errorMsg, /\bCODEX\b/);
67
+ });
68
+
69
+ // A representative valid type still connects.
70
+ test('tools connect CODEX reaches the backend with tool_type CODEX', async () => {
71
+ const r = await connect('CODEX');
72
+ assert.equal(r.reachedApi, true);
73
+ assert.equal(r.sentType, 'CODEX');
74
+ });
75
+
76
+ // Drive the actual production allowlist: every type the CLI offers must reach the
77
+ // backend and be one the backend accepts. Adding a backend-rejected type to
78
+ // SUPPORTED_TOOL_TYPES would fail here rather than recur as a runtime 400.
79
+ test('every CLI-offered tool type is accepted by the backend', async () => {
80
+ for (const type of SUPPORTED_TOOL_TYPES) {
81
+ const r = await connect(type);
82
+ assert.equal(r.reachedApi, true, `CLI should offer ${type}`);
83
+ assert.ok(BACKEND_ACCEPTED.has(r.sentType), `CLI offers ${r.sentType} which the backend rejects`);
84
+ }
85
+ });