@infosupport/huddle-cli 0.0.0-experiment-98.52.1 → 0.0.0-experiment-109.53.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/dist/index.js CHANGED
@@ -4,25 +4,29 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.parseArgs = parseArgs;
7
8
  const fs_1 = __importDefault(require("fs"));
8
9
  const path_1 = __importDefault(require("path"));
9
10
  const api_1 = require("./api");
10
11
  const start_1 = require("./start");
11
12
  const firewall_1 = require("./firewall");
12
13
  const init_1 = require("./init");
14
+ const node_1 = require("./node");
13
15
  const migrate_1 = require("./migrate");
14
- const indexfolder_1 = require("./indexfolder");
16
+ const logs_1 = require("./logs");
17
+ const sbx_1 = require("./sbx");
15
18
  const images_1 = require("./images");
16
19
  const self_update_1 = require("./self-update");
17
20
  const utils_1 = require("./utils");
18
21
  const experiment_1 = require("./experiment");
19
- const VALUE_FLAGS = new Set(['url', 'ide', 'name', 'image', 'workspace', 'container', 'status', 'runtime', 'experiment', 'path', 'ca-path', 'output', 'out', 'workspace-root', 'depth']);
20
- const BOOLEAN_FLAGS = new Set(['help', 'h', 'empty', 'i', 'interactive', 'version', 'v', 'deny', 'docker-socket', 'force', 'replace', 'all', 'list', 'clear']);
21
- const COMMANDS = new Set(['start', 'firewall', 'fw', 'init', 'restart', 'experiment', 'migrate', 'indexfolder', 'indexfolders', 'help', 'version']);
22
+ const VALUE_FLAGS = new Set(['url', 'ide', 'name', 'image', 'workspace', 'container', 'status', 'runtime', 'experiment', 'path', 'ca-path', 'output', 'out', 'workspace-root', 'agent', 'entry', 'port', 'data-dir', 'lines', 'n']);
23
+ const BOOLEAN_FLAGS = new Set(['help', 'h', 'empty', 'i', 'interactive', 'version', 'v', 'deny', 'docker-socket', 'force', 'replace', 'dry-run', 'follow', 'f', 'node', 'gateway']);
24
+ const COMMANDS = new Set(['start', 'firewall', 'fw', 'init', 'restart', 'experiment', 'migrate', 'sbx', 'node', 'logs', 'log', 'help', 'version']);
22
25
  function parseArgs(argv) {
23
26
  const positional = [];
24
27
  const flags = {};
25
28
  const mounts = [];
29
+ const folders = [];
26
30
  for (let i = 0; i < argv.length; i++) {
27
31
  const arg = argv[i];
28
32
  if (arg === '--') {
@@ -35,8 +39,10 @@ function parseArgs(argv) {
35
39
  const name = eq >= 0 ? raw.slice(0, eq) : raw;
36
40
  if (!name)
37
41
  throw new Error(`Invalid option: ${arg}`);
38
- // Repeatable, unlike every other value flag (one `--mount host=container` per folder).
39
- if (name === 'mount') {
42
+ // Repeatable, unlike every other value flag (one `--mount host=container` or
43
+ // one `--folder <host path>` per folder).
44
+ if (name === 'mount' || name === 'folder') {
45
+ const expects = name === 'mount' ? 'host=container' : 'a host path';
40
46
  let value;
41
47
  if (eq >= 0) {
42
48
  value = raw.slice(eq + 1);
@@ -44,12 +50,12 @@ function parseArgs(argv) {
44
50
  else {
45
51
  const next = argv[i + 1];
46
52
  if (next === undefined || next.startsWith('-')) {
47
- throw new Error('Option --mount expects a value (host=container)');
53
+ throw new Error(`Option --${name} expects a value (${expects})`);
48
54
  }
49
55
  value = next;
50
56
  i++;
51
57
  }
52
- mounts.push(value);
58
+ (name === 'mount' ? mounts : folders).push(value);
53
59
  continue;
54
60
  }
55
61
  if (eq >= 0) {
@@ -89,7 +95,7 @@ function parseArgs(argv) {
89
95
  }
90
96
  positional.push(arg);
91
97
  }
92
- return { positional, flags, mounts };
98
+ return { positional, flags, mounts, folders };
93
99
  }
94
100
  function parseMountFlag(raw) {
95
101
  const eq = raw.indexOf('=');
@@ -119,14 +125,10 @@ Usage:
119
125
  huddle start [options] [folder] Explicitly start a devcontainer
120
126
  huddle init [options] Pull the Huddle + devcontainer base images and
121
127
  start them via Docker or Podman
122
- huddle restart Recreate the gateway (e.g. to mount a changed
123
- team firewall-rules folder)
128
+ huddle restart Recreate the gateway (e.g. after changing the
129
+ team extensions folder, which loads at boot)
124
130
  huddle migrate [folder] Wire an existing docker-compose devcontainer
125
131
  behind Huddle by generating an override file
126
- huddle indexfolder [folder] Index the folders under this one so the portal
127
- can offer them where a host path is needed
128
- (the portal runs in a container and cannot
129
- browse your host)
130
132
  huddle firewall list [options] Show firewall requests
131
133
  huddle fw list [options] Alias for firewall list
132
134
  huddle firewall add <domain> Add a custom firewall rule (wildcards
@@ -139,14 +141,51 @@ Usage:
139
141
  huddle firewall group export <name> Export a group as JSON (--out <file>)
140
142
  huddle firewall group import <file> Import a group (--replace to mirror)
141
143
  huddle firewall group apply <name> Apply a group (--container <id> or global)
144
+ huddle sbx status Show Docker Sandboxes (sbx) mode status:
145
+ host-agent pipe, upstream proxy, sbx version
146
+ huddle sbx list List sandboxes the host sbx daemon knows
147
+ huddle sbx start [name] [options] Start a microVM sandbox with Huddle as its
148
+ upstream proxy (--agent <name> --workspace <path>)
149
+ --folder <host path>[:ro] adds another folder
150
+ (repeatable); Huddle's folder mappings are
151
+ mounted automatically
152
+ huddle sbx rm <name> [--force] Remove a sandbox
153
+ huddle sbx reconcile [--dry-run] Set every Huddle sandbox to allow-all in sbx
154
+ (Huddle's proxy enforces the rules)
155
+ huddle sbx trust-ca <name> Install Huddle's CA in a sandbox so HTTPS
156
+ works (needed for VS Code / JetBrains backends)
157
+ huddle sbx trust-host Trust Huddle's CA on the HOST, where the sbx
158
+ daemon runs — sbx terminates TLS itself for
159
+ some hosts (platform.claude.com) and then
160
+ validates Huddle against the host store; without
161
+ this those calls fail with "Empty reply from
162
+ server". Run by 'huddle init'; idempotent.
163
+ huddle sbx ssh-setup Enable the SSH bridge (<name>.sbx) for
164
+ VS Code / JetBrains remote development
142
165
  huddle firewall folder set <path> Set the team-managed rules folder
143
166
  huddle firewall folder reload Re-read the team-managed rules folder
144
167
  huddle firewall folder sync Write the portal's groups back to the folder
168
+ huddle logs [options] Show both halves' output: Huddle Node's log
169
+ file on this host and the gateway container
170
+ (-n <lines>, -f to follow, --node/--gateway
171
+ for one half)
172
+ huddle node [options] Run Huddle Node (portal + API + orchestration)
173
+ directly on this host instead of in the
174
+ gateway container. The firewall stays in
175
+ huddle-gateway. Foreground; Ctrl-C to stop.
145
176
  huddle experiment use <nr> Activate the experimental build of issue/PR <nr>
146
177
  and run init
147
178
  huddle experiment reset Back to the stable release
148
179
  huddle experiment status Show the active channel and CLI version
149
180
 
181
+ Node options:
182
+ --entry <path> Path to the built Huddle Node entrypoint
183
+ (default: the gateway build in this checkout;
184
+ also via HUDDLE_NODE_ENTRY)
185
+ --port <port> Portal + API port (default: 24842)
186
+ --data-dir <path> Database, CA and config location
187
+ (default: ~/.huddle)
188
+
150
189
  Init options:
151
190
  --runtime <docker|podman> Container runtime (default: auto-detected;
152
191
  also via the HUDDLE_RUNTIME env var)
@@ -174,16 +213,6 @@ Migrate options:
174
213
  (default: docker-compose.huddle.yml next to the source)
175
214
  --force Overwrite an existing override file
176
215
 
177
- Indexfolder options:
178
- --depth <n> How deep to walk (default: 2, max 8)
179
- --all Also index build folders (node_modules, dist,
180
- target, ...); hidden folders stay skipped
181
- --replace Drop the earlier entries under this folder
182
- first, instead of merging
183
- --list Show the current index and exit
184
- --clear Empty the index (or, with a folder, only the
185
- entries under it)
186
-
187
216
  Firewall options:
188
217
  -i, --interactive Interactively approve/deny (list)
189
218
  --container <name> Filter by (list) / scope to (add) a container
@@ -203,7 +232,7 @@ Firewall export/import options:
203
232
  scope first (default: merge/upsert)
204
233
 
205
234
  Global options:
206
- --url <url> Huddle URL (default: http://localhost:3000)
235
+ --url <url> Huddle URL (default: http://localhost:24842)
207
236
  Or via the HUDDLE_URL env var
208
237
  --help, -h Show help
209
238
  --version, -v Show version (as published to
@@ -230,8 +259,16 @@ async function main() {
230
259
  printHelp();
231
260
  return;
232
261
  }
233
- const url = flagString(flags, 'url') ?? process.env.HUDDLE_URL ?? 'http://localhost:3000';
234
- (0, api_1.setBaseUrl)(url);
262
+ // Only when the operator named an address. The fallback used to be nodeUrl(),
263
+ // which is the URL for a HUMAN — `http://localhost:…` — and that is the one
264
+ // spelling the CLI must not use: Node binds a single literal, `localhost` is
265
+ // two, and on Windows it resolves to ::1 first. A browser papers over that,
266
+ // fetch() does not, so every command failed with "Huddle does not appear to be
267
+ // running" against a healthy process the portal was talking to happily.
268
+ // Leaving this unset lets api.ts try the loopback literals instead.
269
+ const url = flagString(flags, 'url') ?? process.env.HUDDLE_URL;
270
+ if (url)
271
+ (0, api_1.setBaseUrl)(url);
235
272
  const startsWithExistingPath = cmd !== undefined && !COMMANDS.has(cmd) && fs_1.default.existsSync(path_1.default.resolve(cmd));
236
273
  if (!cmd || cmd === 'start' || startsWithExistingPath) {
237
274
  const startArgs = cmd === 'start' ? positional.slice(1) : startsWithExistingPath ? positional : [];
@@ -249,6 +286,17 @@ async function main() {
249
286
  });
250
287
  return;
251
288
  }
289
+ if (cmd === 'node') {
290
+ // Runs Huddle Node in the FOREGROUND on this host — the shape you want
291
+ // while working on Huddle itself. `huddle init` starts the same process
292
+ // detached, alongside the gateway container.
293
+ await (0, node_1.runNode)({
294
+ entry: flagString(flags, 'entry'),
295
+ port: flagString(flags, 'port'),
296
+ dataDir: flagString(flags, 'data-dir'),
297
+ });
298
+ return;
299
+ }
252
300
  if (cmd === 'init') {
253
301
  // Shows the exact CLI build, so with experiments it's immediately visible
254
302
  // which version is running.
@@ -352,17 +400,59 @@ async function main() {
352
400
  }
353
401
  return;
354
402
  }
355
- if (cmd === 'indexfolder' || cmd === 'indexfolders') {
356
- await (0, indexfolder_1.runIndexFolder)({
357
- path: positional[1],
358
- depth: flagString(flags, 'depth'),
359
- all: flagBool(flags, 'all'),
360
- replace: flagBool(flags, 'replace'),
361
- clear: flagBool(flags, 'clear'),
362
- list: flagBool(flags, 'list'),
403
+ if (cmd === 'logs' || cmd === 'log') {
404
+ await (0, logs_1.runLogs)({
405
+ lines: flagString(flags, 'lines', 'n'),
406
+ follow: flagBool(flags, 'follow', 'f'),
407
+ node: flagBool(flags, 'node'),
408
+ gateway: flagBool(flags, 'gateway'),
363
409
  });
364
410
  return;
365
411
  }
412
+ if (cmd === 'sbx') {
413
+ const subCmd = sub ?? 'status';
414
+ if (subCmd === 'status') {
415
+ await (0, sbx_1.runSbxStatus)();
416
+ }
417
+ else if (subCmd === 'list' || subCmd === 'ls') {
418
+ await (0, sbx_1.runSbxList)();
419
+ }
420
+ else if (subCmd === 'start' || subCmd === 'create') {
421
+ await (0, sbx_1.runSbxStart)({
422
+ name: positional[2] ?? flagString(flags, 'name'),
423
+ agent: flagString(flags, 'agent'),
424
+ workspace: flagString(flags, 'workspace'),
425
+ folders: parsed.folders,
426
+ });
427
+ }
428
+ else if (subCmd === 'rm' || subCmd === 'remove' || subCmd === 'delete') {
429
+ await (0, sbx_1.runSbxRemove)({ name: positional[2] ?? flagString(flags, 'name'), force: flagBool(flags, 'force') });
430
+ }
431
+ else if (subCmd === 'reconcile' || subCmd === 'sync') {
432
+ await (0, sbx_1.runSbxReconcile)({ dryRun: flagBool(flags, 'dry-run') });
433
+ }
434
+ else if (subCmd === 'trust-ca' || subCmd === 'ca') {
435
+ await (0, sbx_1.runSbxTrustCa)({ name: positional[2] ?? flagString(flags, 'name') });
436
+ }
437
+ else if (subCmd === 'trust-host' || subCmd === 'host-ca') {
438
+ await (0, sbx_1.runSbxTrustHost)({ runtime: flagString(flags, 'runtime') });
439
+ }
440
+ else if (subCmd === 'log') {
441
+ await (0, sbx_1.runSbxLog)({ name: positional[2] ?? flagString(flags, 'name') });
442
+ }
443
+ else if (subCmd === 'ingest') {
444
+ await (0, sbx_1.runSbxIngest)();
445
+ }
446
+ else if (subCmd === 'ssh-setup' || subCmd === 'ssh') {
447
+ await (0, sbx_1.runSbxSshSetup)();
448
+ }
449
+ else {
450
+ console.error(`Unknown sbx subcommand: ${subCmd}`);
451
+ console.error('Usage: huddle sbx <status|list|start|rm|reconcile|trust-ca|trust-host|ssh-setup|log|ingest>');
452
+ process.exit(1);
453
+ }
454
+ return;
455
+ }
366
456
  if (cmd === 'migrate') {
367
457
  await (0, migrate_1.runMigrate)({
368
458
  path: positional[1],
@@ -389,10 +479,13 @@ function flagString(flags, ...names) {
389
479
  function flagBool(flags, ...names) {
390
480
  return names.some((name) => flags[name] === true);
391
481
  }
392
- main().catch((err) => {
393
- console.error(`Error: ${err.message ?? err}`);
394
- if (err instanceof api_1.ApiError && err.message.includes('Cannot reach Huddle API')) {
395
- console.error('\nHuddle does not appear to be running. Start it with:\n huddle init');
396
- }
397
- process.exit(1);
398
- });
482
+ // Guarded so the arg parser above can be imported by tests without the CLI
483
+ // running itself as a side effect of the import.
484
+ if (require.main === module)
485
+ main().catch((err) => {
486
+ console.error(`Error: ${err.message ?? err}`);
487
+ if (err instanceof api_1.ApiError && err.message.includes('Cannot reach Huddle API')) {
488
+ console.error('\nHuddle does not appear to be running. Start it with:\n huddle init');
489
+ }
490
+ process.exit(1);
491
+ });