unbound-cli 0.5.0 → 0.5.1
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/LOCAL_DEV.md +41 -0
- package/package.json +1 -1
- package/src/commands/onboard.js +6 -3
- package/src/commands/setup.js +38 -20
package/LOCAL_DEV.md
CHANGED
|
@@ -43,6 +43,47 @@ node src/index.js config reset-url
|
|
|
43
43
|
node src/index.js config reset-frontend-url
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
+
## Point setup scripts to a local backend / frontend
|
|
47
|
+
|
|
48
|
+
The `setup`, `setup mdm`, `onboard`, and `onboard-mdm` commands invoke Python setup scripts from the `setup` repo. Those scripts:
|
|
49
|
+
|
|
50
|
+
- Ping `https://backend.getunbound.ai/api/v1/setup/complete/` when a tool is configured (override with `--backend-url`).
|
|
51
|
+
- Use the frontend URL for the browser-auth callback if `--api-key` is not already stored (override with `--frontend-url`, passed through to the scripts as `--domain`).
|
|
52
|
+
|
|
53
|
+
Both flags are hidden from `--help` (dev-only) and work on every setup-invoking command:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
# Single tool — override backend only, or both
|
|
57
|
+
node src/index.js setup cursor --backend-url http://localhost:8000
|
|
58
|
+
node src/index.js setup cursor --backend-url http://localhost:8000 --frontend-url http://localhost:3000
|
|
59
|
+
node src/index.js setup claude-code --gateway --backend-url http://localhost:8000 --frontend-url http://localhost:3000
|
|
60
|
+
|
|
61
|
+
# Default bundle
|
|
62
|
+
node src/index.js setup --all --backend-url http://localhost:8000 --frontend-url http://localhost:3000
|
|
63
|
+
|
|
64
|
+
# Multiple explicit tools
|
|
65
|
+
node src/index.js setup cursor claude-code-gateway --backend-url http://localhost:8000 --frontend-url http://localhost:3000
|
|
66
|
+
|
|
67
|
+
# Interactive mode (select tools, then apply overrides to all selected)
|
|
68
|
+
node src/index.js setup --backend-url http://localhost:8000 --frontend-url http://localhost:3000
|
|
69
|
+
|
|
70
|
+
# MDM (requires sudo; MDM scripts ignore --frontend-url since they don't use browser auth)
|
|
71
|
+
sudo node src/index.js setup mdm --admin-api-key <ADMIN_KEY> --all --backend-url http://localhost:8000
|
|
72
|
+
|
|
73
|
+
# Onboarding (combined setup + discover)
|
|
74
|
+
node src/index.js onboard --api-key <USER_KEY> --discovery-key <DISCOVERY_KEY> \
|
|
75
|
+
--backend-url http://localhost:8000 --frontend-url http://localhost:3000
|
|
76
|
+
sudo node src/index.js onboard-mdm --admin-api-key <ADMIN_KEY> --discovery-key <DISCOVERY_KEY> \
|
|
77
|
+
--backend-url http://localhost:8000
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
When omitted, scripts default to `https://backend.getunbound.ai` and the stored frontend URL (or `https://gateway.getunbound.ai`).
|
|
81
|
+
|
|
82
|
+
Notes:
|
|
83
|
+
- `--backend-url` / `--frontend-url` only affect the setup scripts. They do not change the CLI's own API calls (use `config set-url` / `UNBOUND_API_URL` / `config set-frontend-url` / `UNBOUND_FRONTEND_URL` for that).
|
|
84
|
+
- `onboard` and `onboard-mdm` also take a visible `--domain <url>` flag — that one is for the **discovery** backend (a separate repo), not the setup scripts' frontend. The two flags don't conflict.
|
|
85
|
+
- MDM setup scripts (`setup mdm`, `onboard-mdm`) don't do browser auth, so `--frontend-url` is a no-op there; only `--backend-url` is meaningful.
|
|
86
|
+
|
|
46
87
|
## Verify config
|
|
47
88
|
|
|
48
89
|
```bash
|
package/package.json
CHANGED
package/src/commands/onboard.js
CHANGED
|
@@ -27,6 +27,8 @@ function register(program) {
|
|
|
27
27
|
.requiredOption('--api-key <key>', 'User API key (for tool setup and login)')
|
|
28
28
|
.requiredOption('--discovery-key <key>', 'Discovery API key (for device scan)')
|
|
29
29
|
.option('--domain <url>', 'Backend URL for discovery', DEFAULT_DOMAIN)
|
|
30
|
+
.addOption(new Option('--backend-url <url>', 'Override backend URL for setup scripts (dev only)').hideHelp())
|
|
31
|
+
.addOption(new Option('--frontend-url <url>', 'Override frontend URL for setup scripts (dev only)').hideHelp())
|
|
30
32
|
.addHelpText('after', `
|
|
31
33
|
Runs the full onboarding flow for an end user:
|
|
32
34
|
1. Logs in with --api-key and stores credentials.
|
|
@@ -54,7 +56,7 @@ Examples:
|
|
|
54
56
|
|
|
55
57
|
console.log('');
|
|
56
58
|
output.info('Step 1/2: Installing tool bundle');
|
|
57
|
-
const ok = await runSetupAllBundle(apiKey);
|
|
59
|
+
const ok = await runSetupAllBundle(apiKey, { backendUrl: opts.backendUrl, frontendUrl: opts.frontendUrl });
|
|
58
60
|
if (!ok) return;
|
|
59
61
|
setupSucceeded = true;
|
|
60
62
|
|
|
@@ -87,7 +89,8 @@ Examples:
|
|
|
87
89
|
.requiredOption('--admin-api-key <key>', 'Admin API key for MDM enrollment')
|
|
88
90
|
.requiredOption('--discovery-key <key>', 'Discovery API key (for device scan)')
|
|
89
91
|
.option('--domain <url>', 'Backend URL for discovery', DEFAULT_DOMAIN)
|
|
90
|
-
.addOption(new Option('--url <url>', 'Override backend URL for setup scripts').hideHelp())
|
|
92
|
+
.addOption(new Option('--backend-url <url>', 'Override backend URL for setup scripts (dev only)').hideHelp())
|
|
93
|
+
.addOption(new Option('--frontend-url <url>', 'Override frontend URL for setup scripts (dev only)').hideHelp())
|
|
91
94
|
.addHelpText('after', `
|
|
92
95
|
Runs the full MDM onboarding flow for device enrollment:
|
|
93
96
|
1. Installs the MDM tool bundle: ${MDM_ALL_TOOLS.join(', ')}.
|
|
@@ -108,7 +111,7 @@ Examples:
|
|
|
108
111
|
|
|
109
112
|
console.log('');
|
|
110
113
|
output.info('Step 1/2: Installing MDM tool bundle');
|
|
111
|
-
const ok = await runMdmSetupAllBundle(opts.adminApiKey, {
|
|
114
|
+
const ok = await runMdmSetupAllBundle(opts.adminApiKey, { backendUrl: opts.backendUrl, frontendUrl: opts.frontendUrl });
|
|
112
115
|
if (!ok) return;
|
|
113
116
|
setupSucceeded = true;
|
|
114
117
|
|
package/src/commands/setup.js
CHANGED
|
@@ -90,8 +90,11 @@ function buildSetupCommand(scriptPath, args) {
|
|
|
90
90
|
/**
|
|
91
91
|
* Runs a Python setup script from the setup repo with inherited stdio (live output).
|
|
92
92
|
*/
|
|
93
|
-
function runSetupScript(scriptPath, apiKey, { clear = false } = {}) {
|
|
94
|
-
|
|
93
|
+
function runSetupScript(scriptPath, apiKey, { clear = false, backendUrl, frontendUrl } = {}) {
|
|
94
|
+
let args = `--api-key ${shellEscape(apiKey)}`;
|
|
95
|
+
if (backendUrl) args += ` --backend-url ${shellEscape(backendUrl)}`;
|
|
96
|
+
if (frontendUrl) args += ` --domain ${shellEscape(frontendUrl)}`;
|
|
97
|
+
if (clear) args += ' --clear';
|
|
95
98
|
console.log('');
|
|
96
99
|
try {
|
|
97
100
|
execSync(buildSetupCommand(scriptPath, args), { stdio: 'inherit' });
|
|
@@ -177,6 +180,8 @@ function register(program) {
|
|
|
177
180
|
.option('--subscription', 'Use subscription mode for Claude Code / Codex (hooks only)')
|
|
178
181
|
.option('--gateway', 'Use gateway mode for Claude Code / Codex (Unbound as AI provider)')
|
|
179
182
|
.option('--all', 'Set up the default bundle: Cursor, Claude Code (hooks), Codex (hooks)')
|
|
183
|
+
.addOption(new Option('--backend-url <url>', 'Override backend URL for setup scripts (dev only)').hideHelp())
|
|
184
|
+
.addOption(new Option('--frontend-url <url>', 'Override frontend URL for setup scripts (dev only)').hideHelp())
|
|
180
185
|
.addHelpText('after', `
|
|
181
186
|
Available tools:
|
|
182
187
|
cursor Cursor IDE
|
|
@@ -252,8 +257,11 @@ automatically to authenticate before proceeding.
|
|
|
252
257
|
const selectedTools = SETUP_TOOLS.filter(t => selected.includes(t.value));
|
|
253
258
|
console.log('');
|
|
254
259
|
|
|
260
|
+
let interactiveArgs = `--api-key ${shellEscape(apiKey)}`;
|
|
261
|
+
if (opts.backendUrl) interactiveArgs += ` --backend-url ${shellEscape(opts.backendUrl)}`;
|
|
262
|
+
if (opts.frontendUrl) interactiveArgs += ` --domain ${shellEscape(opts.frontendUrl)}`;
|
|
255
263
|
const ok = await runBatch(selectedTools, (tool) =>
|
|
256
|
-
runScriptPiped(tool.script,
|
|
264
|
+
runScriptPiped(tool.script, interactiveArgs)
|
|
257
265
|
);
|
|
258
266
|
if (!ok) return;
|
|
259
267
|
|
|
@@ -318,13 +326,13 @@ automatically to authenticate before proceeding.
|
|
|
318
326
|
const toolName = tools[0];
|
|
319
327
|
|
|
320
328
|
if (SETUP_TOOL_MAP[toolName]) {
|
|
321
|
-
runSetupScript(SETUP_TOOL_MAP[toolName].script, apiKey, { clear: opts.clear });
|
|
329
|
+
runSetupScript(SETUP_TOOL_MAP[toolName].script, apiKey, { clear: opts.clear, backendUrl: opts.backendUrl, frontendUrl: opts.frontendUrl });
|
|
322
330
|
} else if (MODE_TOOLS[toolName]) {
|
|
323
331
|
const mode = MODE_TOOLS[toolName];
|
|
324
332
|
if (opts.clear) {
|
|
325
333
|
// Clear both modes
|
|
326
|
-
runSetupScript(SETUP_TOOL_MAP[mode.subscription].script, apiKey, { clear: true });
|
|
327
|
-
runSetupScript(SETUP_TOOL_MAP[mode.gateway].script, apiKey, { clear: true });
|
|
334
|
+
runSetupScript(SETUP_TOOL_MAP[mode.subscription].script, apiKey, { clear: true, backendUrl: opts.backendUrl, frontendUrl: opts.frontendUrl });
|
|
335
|
+
runSetupScript(SETUP_TOOL_MAP[mode.gateway].script, apiKey, { clear: true, backendUrl: opts.backendUrl, frontendUrl: opts.frontendUrl });
|
|
328
336
|
} else {
|
|
329
337
|
let useSubscription = opts.subscription;
|
|
330
338
|
if (!opts.subscription && !opts.gateway) {
|
|
@@ -332,7 +340,7 @@ automatically to authenticate before proceeding.
|
|
|
332
340
|
useSubscription = choice === 'subscription';
|
|
333
341
|
}
|
|
334
342
|
const resolved = useSubscription ? mode.subscription : mode.gateway;
|
|
335
|
-
runSetupScript(SETUP_TOOL_MAP[resolved].script, apiKey, {});
|
|
343
|
+
runSetupScript(SETUP_TOOL_MAP[resolved].script, apiKey, { backendUrl: opts.backendUrl, frontendUrl: opts.frontendUrl });
|
|
336
344
|
}
|
|
337
345
|
} else if (INSTRUCTION_TOOLS[toolName]) {
|
|
338
346
|
output.keyValue(INSTRUCTION_TOOLS[toolName].values(apiKey, frontendUrl));
|
|
@@ -370,7 +378,10 @@ automatically to authenticate before proceeding.
|
|
|
370
378
|
// Run automated tools with spinners
|
|
371
379
|
if (resolvedScripts.length > 0) {
|
|
372
380
|
console.log('');
|
|
373
|
-
|
|
381
|
+
let args = `--api-key ${shellEscape(apiKey)}`;
|
|
382
|
+
if (opts.backendUrl) args += ` --backend-url ${shellEscape(opts.backendUrl)}`;
|
|
383
|
+
if (opts.frontendUrl) args += ` --domain ${shellEscape(opts.frontendUrl)}`;
|
|
384
|
+
if (opts.clear) args += ' --clear';
|
|
374
385
|
const ok = await runBatch(resolvedScripts, (tool) =>
|
|
375
386
|
runScriptPiped(tool.script, args)
|
|
376
387
|
, { clear: opts.clear });
|
|
@@ -409,7 +420,6 @@ automatically to authenticate before proceeding.
|
|
|
409
420
|
.requiredOption('--admin-api-key <key>', 'Admin API key for MDM enrollment')
|
|
410
421
|
.option('--clear', 'Remove Unbound configuration for the specified tools')
|
|
411
422
|
.option('--all', 'Set up all available tools')
|
|
412
|
-
.addOption(new Option('--url <url>', 'Override backend URL').hideHelp())
|
|
413
423
|
.addHelpText('after', `
|
|
414
424
|
Available tools:
|
|
415
425
|
cursor Cursor IDE
|
|
@@ -429,18 +439,22 @@ Examples:
|
|
|
429
439
|
$ sudo unbound setup mdm --admin-api-key KEY --all
|
|
430
440
|
$ sudo unbound setup mdm --admin-api-key KEY --clear cursor codex-subscription
|
|
431
441
|
`)
|
|
432
|
-
.action(async (tools, opts) => {
|
|
442
|
+
.action(async (tools, opts, command) => {
|
|
433
443
|
try {
|
|
434
444
|
checkRoot();
|
|
445
|
+
// --all and --clear are defined on both this command and the parent `setup` command;
|
|
446
|
+
// --backend-url and --frontend-url are defined only on the parent `setup` command.
|
|
447
|
+
// Use optsWithGlobals() so all four work regardless of position relative to `mdm`.
|
|
448
|
+
const globalOpts = command.optsWithGlobals();
|
|
435
449
|
|
|
436
|
-
if (
|
|
450
|
+
if (globalOpts.all && tools.length > 0) {
|
|
437
451
|
output.error('Cannot combine --all with specific tool names. Use one or the other.');
|
|
438
452
|
process.exitCode = 1;
|
|
439
453
|
return;
|
|
440
454
|
}
|
|
441
455
|
|
|
442
456
|
let toolNames;
|
|
443
|
-
if (
|
|
457
|
+
if (globalOpts.all) {
|
|
444
458
|
toolNames = MDM_ALL_TOOLS;
|
|
445
459
|
} else if (tools.length > 0) {
|
|
446
460
|
toolNames = tools;
|
|
@@ -476,20 +490,21 @@ Examples:
|
|
|
476
490
|
|
|
477
491
|
const mdmArgs = (tool) => {
|
|
478
492
|
let args = `--api-key ${shellEscape(opts.adminApiKey)}`;
|
|
479
|
-
if (
|
|
480
|
-
if (
|
|
493
|
+
if (globalOpts.backendUrl) args += ` --backend-url ${shellEscape(globalOpts.backendUrl)}`;
|
|
494
|
+
if (globalOpts.frontendUrl) args += ` --domain ${shellEscape(globalOpts.frontendUrl)}`;
|
|
495
|
+
if (globalOpts.clear) args += ' --clear';
|
|
481
496
|
return args;
|
|
482
497
|
};
|
|
483
498
|
|
|
484
499
|
const ok = await runBatch(
|
|
485
500
|
resolvedTools,
|
|
486
501
|
(tool) => runScriptPiped(tool.script, mdmArgs(tool)),
|
|
487
|
-
{ clear:
|
|
502
|
+
{ clear: globalOpts.clear }
|
|
488
503
|
);
|
|
489
504
|
if (!ok) return;
|
|
490
505
|
|
|
491
506
|
console.log('');
|
|
492
|
-
output.success(
|
|
507
|
+
output.success(globalOpts.clear ? 'All tools cleared' : 'All tools configured');
|
|
493
508
|
} catch (err) {
|
|
494
509
|
output.error(err.message);
|
|
495
510
|
process.exitCode = 1;
|
|
@@ -502,9 +517,11 @@ Examples:
|
|
|
502
517
|
* Assumes the caller has already ensured the user is logged in.
|
|
503
518
|
* Returns true on success, false on failure.
|
|
504
519
|
*/
|
|
505
|
-
async function runSetupAllBundle(apiKey) {
|
|
520
|
+
async function runSetupAllBundle(apiKey, { backendUrl, frontendUrl } = {}) {
|
|
506
521
|
const resolvedTools = ALL_TOOLS.map(name => ({ name, ...SETUP_TOOL_MAP[name] }));
|
|
507
|
-
|
|
522
|
+
let args = `--api-key ${shellEscape(apiKey)}`;
|
|
523
|
+
if (backendUrl) args += ` --backend-url ${shellEscape(backendUrl)}`;
|
|
524
|
+
if (frontendUrl) args += ` --domain ${shellEscape(frontendUrl)}`;
|
|
508
525
|
return runBatch(resolvedTools, (tool) => runScriptPiped(tool.script, args));
|
|
509
526
|
}
|
|
510
527
|
|
|
@@ -513,10 +530,11 @@ async function runSetupAllBundle(apiKey) {
|
|
|
513
530
|
* Caller must ensure the process is running as root.
|
|
514
531
|
* Returns true on success, false on failure.
|
|
515
532
|
*/
|
|
516
|
-
async function runMdmSetupAllBundle(adminApiKey, {
|
|
533
|
+
async function runMdmSetupAllBundle(adminApiKey, { backendUrl, frontendUrl } = {}) {
|
|
517
534
|
const resolvedTools = MDM_ALL_TOOLS.map(name => ({ name, ...MDM_TOOLS[name] }));
|
|
518
535
|
let args = `--api-key ${shellEscape(adminApiKey)}`;
|
|
519
|
-
if (
|
|
536
|
+
if (backendUrl) args += ` --backend-url ${shellEscape(backendUrl)}`;
|
|
537
|
+
if (frontendUrl) args += ` --domain ${shellEscape(frontendUrl)}`;
|
|
520
538
|
return runBatch(resolvedTools, (tool) => runScriptPiped(tool.script, args));
|
|
521
539
|
}
|
|
522
540
|
|