@infosupport/huddle-cli 0.0.0-experiment-137.151.1 → 0.0.0-experiment-160.152.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/README.md CHANGED
@@ -45,43 +45,25 @@ huddle --ide vscode \
45
45
 
46
46
  Default API URL: `http://localhost:3000`. Override it with `--url` or `HUDDLE_URL`.
47
47
 
48
- ## Making host folders selectable in the portal
48
+ ## Browsing host folders from the portal
49
49
 
50
- Huddle's portal runs inside a container, so it cannot open a folder dialog on your
51
- host: every host path had to be typed from memory. `huddle indexfolder` scans your
52
- host once and stores what it finds, and every host-path field in the portal grows a
53
- **Browse** button that opens those folders as a tree — starting a devcontainer, the
54
- folder mappings, and the team-managed folders. Starting a devcontainer, Ctrl-click picks
55
- several folders at once and each becomes its own worktree. Typing a path by hand keeps working:
56
- the index is a snapshot, so a folder created after the last scan must not be
57
- unreachable.
50
+ Huddle's portal runs inside a container, so it cannot see your host by itself. `huddle init`
51
+ (and `huddle restart`) therefore also start the **host pipe** in the background: a small agent,
52
+ part of this CLI, that answers the gateway through files in `~/.huddle/pipe`. Through it every
53
+ host-path field in the portal gets a **Browse** button with a live folder tree of your host —
54
+ starting a devcontainer, the folder mappings, and the team-managed folders — and the portal can
55
+ drive allowlisted host tools such as Docker Sandboxes (`sbx`, argv only, never a shell). Starting a
56
+ devcontainer, Ctrl-click picks several folders at once and each becomes its own worktree.
58
57
 
59
58
  ```bash
60
- cd T:/projects
61
- huddle indexfolder # this folder + 2 levels below it
62
- huddle indexfolder T:/projects --depth 3
63
- huddle indexfolder --all # also index node_modules, dist, target, ...
64
- huddle indexfolder --replace # re-scan: drop the earlier entries under this folder first
65
- huddle indexfolder --list # show what is indexed
66
- huddle indexfolder --clear # empty the index (with a folder: only that subtree)
59
+ huddle pipe status # online/offline, pid, CLI version, available tools
60
+ huddle pipe start # start in the background (replaces a running one)
61
+ huddle pipe stop
62
+ huddle pipe serve # run in the foreground, for debugging
67
63
  ```
68
64
 
69
- Hidden (dot) folders and the usual build folders (`node_modules`, `dist`, `target`,
70
- `obj`, …) are skipped, which is what keeps a scan of a projects folder in the
71
- hundreds instead of the tens of thousands; `--all` turns that off. The scan stops
72
- at 1500 folders and the index holds at most 2000 — index a more specific folder if
73
- you hit that.
74
-
75
- The index is a **snapshot**, not a live view: the gateway cannot read your host, so
76
- re-run the command after adding projects. Every input keeps accepting a typed path,
77
- so a folder you created a minute ago works without re-indexing first. Windows paths
78
- may be typed either way (`T:\projects\app` or `T:/projects/app`) — they are stored
79
- in one canonical form, and the two spellings are the same entry.
80
-
81
- Individual folders can also be added or removed under **Settings > Indexed
82
- folders** in the portal. The index lives in Huddle's database, not in
83
- `~/.huddle/config.json`: it describes this machine, so unlike the team-managed
84
- settings it is not something to share in version control.
65
+ The agent logs to `~/.huddle/pipe/host.log`. Typing a path by hand keeps working when the pipe
66
+ is offline. The protocol is described in [docs/host-pipe.md](../docs/host-pipe.md).
85
67
 
86
68
  ## Experiments
87
69
 
package/dist/api.js CHANGED
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.del = exports.put = exports.post = exports.get = exports.ApiError = void 0;
4
4
  exports.setBaseUrl = setBaseUrl;
5
5
  exports.apiCall = apiCall;
6
+ exports.uploadFile = uploadFile;
6
7
  const config_1 = require("./config");
7
8
  let baseUrl = normalizeBaseUrl(process.env.HUDDLE_URL ?? 'http://localhost:3000');
8
9
  class ApiError extends Error {
@@ -21,6 +22,15 @@ async function apiCall(method, path, body) {
21
22
  const headers = {};
22
23
  if (body !== undefined)
23
24
  headers['content-type'] = 'application/json';
25
+ return send(method, path, body !== undefined ? JSON.stringify(body) : undefined, headers);
26
+ }
27
+ /** POSTs one file as multipart/form-data (field `file`), e.g. an extension zip. */
28
+ async function uploadFile(path, fileName, data) {
29
+ const form = new FormData();
30
+ form.append('file', new Blob([new Uint8Array(data)]), fileName);
31
+ return send('POST', path, form, {});
32
+ }
33
+ async function send(method, path, body, headers) {
24
34
  // Operator-auth: stuur het token als Bearer mee zodat de CLI de control-plane
25
35
  // -auth passeert. Zonder token krijgen we een 401 met een duidelijke hint.
26
36
  const token = (0, config_1.operatorToken)();
@@ -28,11 +38,7 @@ async function apiCall(method, path, body) {
28
38
  headers['authorization'] = `Bearer ${token}`;
29
39
  let res;
30
40
  try {
31
- res = await fetch(`${baseUrl}${path}`, {
32
- method,
33
- headers,
34
- body: body !== undefined ? JSON.stringify(body) : undefined,
35
- });
41
+ res = await fetch(`${baseUrl}${path}`, { method, headers, body });
36
42
  }
37
43
  catch (err) {
38
44
  const detail = err instanceof Error ? err.message : String(err);
package/dist/config.js CHANGED
@@ -139,7 +139,10 @@ let tmpSeq = 0;
139
139
  * config.
140
140
  */
141
141
  function updateConfig(patch) {
142
- fs_1.default.mkdirSync(exports.CONFIG_DIR, { recursive: true });
142
+ // The config holds the operator token: owner-only. chmod as well, because
143
+ // mkdir's mode does not tighten a directory created by an older version.
144
+ fs_1.default.mkdirSync(exports.CONFIG_DIR, { recursive: true, mode: 0o700 });
145
+ fs_1.default.chmodSync(exports.CONFIG_DIR, 0o700);
143
146
  const token = acquireLock();
144
147
  if (token === null) {
145
148
  throw new Error(`Could not lock ${CONFIG_PATH} within ${LOCK_WAIT_MS}ms — another Huddle process ` +
@@ -153,7 +156,7 @@ function updateConfig(patch) {
153
156
  if (v === undefined)
154
157
  delete next[k];
155
158
  }
156
- fs_1.default.writeFileSync(tmp, `${JSON.stringify(next, null, 2)}\n`);
159
+ fs_1.default.writeFileSync(tmp, `${JSON.stringify(next, null, 2)}\n`, { mode: 0o600 });
157
160
  fs_1.default.renameSync(tmp, CONFIG_PATH);
158
161
  return next;
159
162
  }
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.isExtensionId = exports.MAX_FOLDER_DEPTH = void 0;
7
+ exports.insideFolder = insideFolder;
8
+ exports.collectExtensionFiles = collectExtensionFiles;
9
+ exports.planInstall = planInstall;
10
+ exports.asExtensionList = asExtensionList;
11
+ exports.runExtensionList = runExtensionList;
12
+ exports.restartRuntime = restartRuntime;
13
+ exports.runExtensionInstall = runExtensionInstall;
14
+ exports.runExtensionRemove = runExtensionRemove;
15
+ const fs_1 = __importDefault(require("fs"));
16
+ const path_1 = __importDefault(require("path"));
17
+ const child_process_1 = require("child_process");
18
+ const api_1 = require("./api");
19
+ const zip_1 = require("./zip");
20
+ const init_1 = require("./init");
21
+ const runtime_1 = require("./runtime");
22
+ const utils_1 = require("./utils");
23
+ const SKIPPED = new Set(['node_modules']);
24
+ exports.MAX_FOLDER_DEPTH = 32;
25
+ /** The gateway's own id rule: one lowercase path component, so it can never point outside the extensions folder. */
26
+ const isExtensionId = (id) => typeof id === 'string' && /^[a-z0-9-]+$/.test(id);
27
+ exports.isExtensionId = isExtensionId;
28
+ /** Resolves `rel` within `root` and refuses anything that lands outside it (`..`, absolute paths). */
29
+ function insideFolder(root, rel) {
30
+ const base = path_1.default.resolve(root);
31
+ const abs = path_1.default.resolve(base, rel);
32
+ if (abs !== base && !abs.startsWith(base + path_1.default.sep))
33
+ throw new Error(`${rel} is outside the extension folder`);
34
+ return abs;
35
+ }
36
+ /**
37
+ * Reads a regular file of the folder; a symlink is refused, so the zip can never carry a file from outside it.
38
+ * @param root the resolved extension folder @param rel a path relative to it, from readdir
39
+ */
40
+ function readPlainFile(root, rel) {
41
+ const abs = insideFolder(root, rel);
42
+ const stat = fs_1.default.lstatSync(abs);
43
+ if (stat.isSymbolicLink())
44
+ throw new Error(`${rel} is a symlink; extensions are packaged without symlinks`);
45
+ if (!stat.isFile())
46
+ throw new Error(`${rel} is not a regular file`);
47
+ return fs_1.default.readFileSync(abs);
48
+ }
49
+ /** Reads an extension folder into zip entries; the manifest must pass the gateway's own id rule. */
50
+ function collectExtensionFiles(dir) {
51
+ const root = path_1.default.resolve(dir);
52
+ for (const required of ['manifest.json', 'index.js']) {
53
+ if (!fs_1.default.lstatSync(insideFolder(root, required), { throwIfNoEntry: false }))
54
+ throw new Error(`${required} missing in ${root}`);
55
+ }
56
+ const manifest = JSON.parse(readPlainFile(root, 'manifest.json').toString('utf8'));
57
+ if (!(0, exports.isExtensionId)(manifest.id)) {
58
+ throw new Error(`manifest id ${JSON.stringify(manifest.id)} must be lowercase letters, digits and -`);
59
+ }
60
+ if (typeof manifest.name !== 'string' || !manifest.name)
61
+ throw new Error('manifest name is required');
62
+ readPlainFile(root, 'index.js');
63
+ const entries = [];
64
+ const walk = (rel, depth) => {
65
+ if (depth > exports.MAX_FOLDER_DEPTH)
66
+ throw new Error(`${rel} is nested deeper than ${exports.MAX_FOLDER_DEPTH} folders`);
67
+ for (const item of fs_1.default.readdirSync(insideFolder(root, rel), { withFileTypes: true })) {
68
+ if (item.name.startsWith('.') || SKIPPED.has(item.name))
69
+ continue;
70
+ const childRel = rel ? `${rel}/${item.name}` : item.name;
71
+ if (item.isSymbolicLink())
72
+ throw new Error(`${childRel} is a symlink; extensions are packaged without symlinks`);
73
+ if (item.isDirectory())
74
+ walk(childRel, depth + 1);
75
+ else if (item.isFile())
76
+ entries.push({ name: childRel, data: readPlainFile(root, childRel) });
77
+ }
78
+ };
79
+ walk('', 0);
80
+ return { manifest, entries };
81
+ }
82
+ /** An id already taken by an extension with another name is someone else's; only --force replaces it. */
83
+ function planInstall(incoming, installed, force) {
84
+ const existing = installed.find((e) => e.id === incoming.id);
85
+ if (!existing)
86
+ return { action: 'install' };
87
+ const from = existing.version ?? 'unknown';
88
+ if (existing.name !== incoming.name && !force) {
89
+ return {
90
+ action: 'refuse',
91
+ reason: `id '${incoming.id}' belongs to "${existing.name}" (v${from}), not "${incoming.name}". Use --force to replace it.`,
92
+ };
93
+ }
94
+ return { action: 'update', from };
95
+ }
96
+ /** The answer of /api/extensions, or an error when another service holds Huddle's address. */
97
+ function asExtensionList(value) {
98
+ if (!Array.isArray(value))
99
+ throw new Error('could not reach Huddle: the address answered, but not with its extensions. Check HUDDLE_URL.');
100
+ return value;
101
+ }
102
+ async function runExtensionList() {
103
+ const installed = asExtensionList(await (0, api_1.get)('/api/extensions'));
104
+ if (!installed.length) {
105
+ console.log('No extensions installed.');
106
+ return;
107
+ }
108
+ (0, utils_1.printTable)(['ID', 'NAME', 'VERSION', 'ENABLED'], installed.map((e) => [e.id, e.name, e.version ?? '-', e.enabled === false ? 'no' : 'yes']));
109
+ }
110
+ function hasHuddleContainer(rt) {
111
+ try {
112
+ (0, child_process_1.execFileSync)(rt, ['container', 'inspect', init_1.CONTAINER], { stdio: 'ignore' });
113
+ return true;
114
+ }
115
+ catch {
116
+ return false;
117
+ }
118
+ }
119
+ /**
120
+ * The engine whose huddle container gets restarted after an install. An explicit
121
+ * --runtime / HUDDLE_RUNTIME wins; otherwise the engine that actually runs the
122
+ * container. Plain auto-detection prefers Docker, so with Podman owning Huddle
123
+ * it would restart an unrelated `huddle` container (or none) and leave the new
124
+ * extension inactive.
125
+ */
126
+ function restartRuntime(explicit, hasContainer = hasHuddleContainer, detect = () => (0, runtime_1.resolveRuntime)().name) {
127
+ const requested = explicit ?? process.env.HUDDLE_RUNTIME;
128
+ if (requested !== undefined) {
129
+ // An empty value is a typo, not a request to auto-detect: probing could pick another engine's container.
130
+ if (!requested)
131
+ throw new Error('--runtime must not be empty; choose docker or podman.');
132
+ return (0, runtime_1.resolveRuntime)(requested).name;
133
+ }
134
+ const owners = ['docker', 'podman'].filter((rt) => hasContainer(rt));
135
+ if (owners.length === 1)
136
+ return owners[0];
137
+ if (owners.length === 0) {
138
+ throw new Error(`No ${init_1.CONTAINER} container found under docker or podman. Run huddle init first.`);
139
+ }
140
+ // Both commands see a huddle container: either `docker` is a Podman shim
141
+ // (one engine, detection reports podman) or two engines each run one.
142
+ if (detect() === 'podman')
143
+ return 'podman';
144
+ throw new Error(`Both docker and podman run a ${init_1.CONTAINER} container; pick one with --runtime <docker|podman>.`);
145
+ }
146
+ async function runExtensionInstall(dir, opts) {
147
+ const { manifest, entries } = collectExtensionFiles(dir);
148
+ const plan = planInstall(manifest, asExtensionList(await (0, api_1.get)('/api/extensions')), opts.force);
149
+ if (plan.action === 'refuse')
150
+ throw new Error(plan.reason);
151
+ const result = await (0, api_1.uploadFile)('/api/extensions/upload', `${manifest.id}.zip`, (0, zip_1.createZip)(entries));
152
+ const verb = plan.action === 'update' ? `Updated ${manifest.id} v${plan.from} → v${manifest.version ?? '?'}` : `Installed ${manifest.id} v${manifest.version ?? '?'}`;
153
+ console.log((0, utils_1.green)(`[OK] ${verb}`));
154
+ if (!result.restartRequired)
155
+ return;
156
+ if (!opts.restart) {
157
+ console.log((0, utils_1.yellow)('The gateway keeps running the old code until it restarts. Re-run with --restart, or restart the huddle container.'));
158
+ return;
159
+ }
160
+ const rt = restartRuntime(opts.runtime);
161
+ console.log((0, utils_1.dim)(`Restarting the gateway process (${rt} restart ${init_1.CONTAINER}); the container itself is kept.`));
162
+ (0, child_process_1.execFileSync)(rt, ['restart', init_1.CONTAINER], { stdio: 'ignore' });
163
+ console.log((0, utils_1.green)('[OK] Gateway restarted with the new extension code.'));
164
+ }
165
+ async function runExtensionRemove(id) {
166
+ if (!(0, exports.isExtensionId)(id))
167
+ throw new Error(`invalid extension id: ${id}`);
168
+ await (0, api_1.del)(`/api/extensions/${id}`);
169
+ console.log((0, utils_1.green)(`[OK] Removed ${id}`));
170
+ }
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.HOST_CODEX_INDEX_MOUNT = exports.HOST_CODEX_LOGS_MOUNT = exports.HOST_AGENT_LOGS_MOUNT = void 0;
7
+ exports.hostAgentLogsMountArgs = hostAgentLogsMountArgs;
8
+ exports.hostCodexLogsMountArgs = hostCodexLogsMountArgs;
9
+ exports.hostCodexIndexMountArgs = hostCodexIndexMountArgs;
10
+ const fs_1 = __importDefault(require("fs"));
11
+ const path_1 = __importDefault(require("path"));
12
+ /** Must match HOST_AGENT_LOGS_MOUNT in gateway/src/host-config.ts. */
13
+ exports.HOST_AGENT_LOGS_MOUNT = '/host-logs/claude/projects';
14
+ /** Must match HOST_CODEX_LOGS_MOUNT in gateway/src/host-config.ts. */
15
+ exports.HOST_CODEX_LOGS_MOUNT = '/host-logs/codex/sessions';
16
+ /** Extensions read the Codex index here; the gateway itself never opens it. */
17
+ exports.HOST_CODEX_INDEX_MOUNT = '/host-logs/codex/session_index.jsonl';
18
+ /** A real directory only: Docker follows a symlinked source, which could point the mount at ~/.claude itself. */
19
+ const isPlainDir = (p) => {
20
+ try {
21
+ return fs_1.default.lstatSync(p).isDirectory();
22
+ }
23
+ catch {
24
+ return false;
25
+ }
26
+ };
27
+ /**
28
+ * `docker run` args that expose the host's Claude session logs to extensions:
29
+ * only ~/.claude/projects, read-only — never ~/.claude itself, which holds credentials.
30
+ */
31
+ function hostAgentLogsMountArgs(cfg, homeDir, exists = isPlainDir) {
32
+ if (cfg.hostAgentLogs !== true)
33
+ return [];
34
+ const projects = path_1.default.join(homeDir, '.claude', 'projects');
35
+ return exists(projects) ? ['-v', `${projects}:${exports.HOST_AGENT_LOGS_MOUNT}:ro`] : [];
36
+ }
37
+ /** The same for Codex: only ~/.codex/sessions, read-only — never ~/.codex itself, which holds auth.json. */
38
+ function hostCodexLogsMountArgs(cfg, homeDir, exists = isPlainDir) {
39
+ if (cfg.hostAgentLogs !== true)
40
+ return [];
41
+ const sessions = path_1.default.join(homeDir, '.codex', 'sessions');
42
+ return exists(sessions) ? ['-v', `${sessions}:${exports.HOST_CODEX_LOGS_MOUNT}:ro`] : [];
43
+ }
44
+ /** A plain file only: a symlink or hard link here could point the mount at auth.json. */
45
+ const isPlainFile = (p) => {
46
+ try {
47
+ const stat = fs_1.default.lstatSync(p);
48
+ return stat.isFile() && stat.nlink === 1;
49
+ }
50
+ catch {
51
+ return false;
52
+ }
53
+ };
54
+ /** Codex keeps thread names in ~/.codex/session_index.jsonl; only that file is mounted, read-only. */
55
+ function hostCodexIndexMountArgs(cfg, homeDir, exists = isPlainFile) {
56
+ if (cfg.hostAgentLogs !== true)
57
+ return [];
58
+ const index = path_1.default.join(homeDir, '.codex', 'session_index.jsonl');
59
+ return exists(index) ? ['-v', `${index}:${exports.HOST_CODEX_INDEX_MOUNT}:ro`] : [];
60
+ }
package/dist/index.js CHANGED
@@ -8,12 +8,13 @@ const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const api_1 = require("./api");
10
10
  const start_1 = require("./start");
11
+ const extension_1 = require("./extension");
11
12
  const firewall_1 = require("./firewall");
12
13
  const init_1 = require("./init");
13
14
  const migrate_1 = require("./migrate");
14
- const indexfolder_1 = require("./indexfolder");
15
15
  const triage_agent_1 = require("./triage-agent");
16
16
  const update_agent_1 = require("./update-agent");
17
+ const command_1 = require("./pipe/command");
17
18
  const images_1 = require("./images");
18
19
  const base_images_1 = require("./base-images");
19
20
  const config_1 = require("./config");
@@ -21,9 +22,9 @@ const runtime_1 = require("./runtime");
21
22
  const self_update_1 = require("./self-update");
22
23
  const utils_1 = require("./utils");
23
24
  const experiment_1 = require("./experiment");
24
- const VALUE_FLAGS = new Set(['url', 'ide', 'name', 'image', 'workspace', 'container', 'status', 'runtime', 'experiment', 'path', 'ca-path', 'output', 'out', 'workspace-root', 'depth']);
25
- const BOOLEAN_FLAGS = new Set(['help', 'h', 'empty', 'i', 'interactive', 'version', 'v', 'deny', 'docker-socket', 'force', 'replace', 'all', 'list', 'clear', 'no-vscode-config']);
26
- const COMMANDS = new Set(['start', 'firewall', 'fw', 'init', 'restart', 'experiment', 'migrate', 'indexfolder', 'indexfolders', 'update-agent', 'triage-agent', 'images', 'help', 'version']);
25
+ const VALUE_FLAGS = new Set(['url', 'ide', 'name', 'image', 'workspace', 'container', 'status', 'runtime', 'experiment', 'path', 'ca-path', 'output', 'out', 'workspace-root']);
26
+ const BOOLEAN_FLAGS = new Set(['help', 'h', 'empty', 'i', 'interactive', 'version', 'v', 'deny', 'docker-socket', 'force', 'replace', 'no-vscode-config']);
27
+ const COMMANDS = new Set(['start', 'firewall', 'fw', 'extension', 'ext', 'init', 'restart', 'experiment', 'migrate', 'pipe', 'update-agent', 'triage-agent', 'images', 'help', 'version']);
27
28
  function parseArgs(argv) {
28
29
  const positional = [];
29
30
  const flags = {};
@@ -128,10 +129,11 @@ Usage:
128
129
  team firewall-rules folder)
129
130
  huddle migrate [folder] Wire an existing docker-compose devcontainer
130
131
  behind Huddle by generating an override file
131
- huddle indexfolder [folder] Index the folders under this one so the portal
132
- can offer them where a host path is needed
133
- (the portal runs in a container and cannot
134
- browse your host)
132
+ huddle pipe status Show whether the host pipe is online (lets the
133
+ portal browse host folders and run sbx)
134
+ huddle pipe start|stop Start (or replace) / stop the host pipe in the
135
+ background (huddle init starts it for you)
136
+ huddle pipe serve Run the host pipe in the foreground (debugging)
135
137
  huddle firewall list [options] Show firewall requests
136
138
  huddle fw list [options] Alias for firewall list
137
139
  huddle firewall add <domain> Add a custom firewall rule (wildcards
@@ -153,6 +155,13 @@ Usage:
153
155
  huddle triage-agent [PR] Let Claude analyse open PRs labelled security
154
156
  and comment its impact analysis, inside an
155
157
  airlocked devcontainer (same requirements)
158
+ huddle extension list List installed gateway extensions
159
+ huddle ext list Alias for extension list
160
+ huddle extension install <dir> Install or update the extension in a folder
161
+ (--force replaces another extension with the
162
+ same id, --restart reloads the gateway process
163
+ on the engine that runs Huddle, or --runtime)
164
+ huddle extension remove <id> Remove an installed extension
156
165
  huddle experiment use <nr> Activate the experimental build of issue/PR <nr>
157
166
  and run init
158
167
  huddle experiment reset Back to the stable release
@@ -177,7 +186,8 @@ Start options:
177
186
  --workspace-root <path> Container path the IDE opens as project root when using
178
187
  --mount (default: common parent of the mount targets)
179
188
  --name <name> Container name (default: devcontainer-<foldername>)
180
- --image <image> Use a specific image
189
+ --image <image> Use a specific image. Any Debian/Ubuntu/Alpine image works:
190
+ Huddle builds it once with its own layer on top
181
191
  --empty Empty container without a workspace
182
192
  --no-vscode-config Do not write the per-container attach config
183
193
  that makes VS Code open the workspace folder
@@ -208,16 +218,6 @@ Migrate options:
208
218
  (default: docker-compose.huddle.yml next to the source)
209
219
  --force Overwrite an existing override file
210
220
 
211
- Indexfolder options:
212
- --depth <n> How deep to walk (default: 2, max 8)
213
- --all Also index build folders (node_modules, dist,
214
- target, ...); hidden folders stay skipped
215
- --replace Drop the earlier entries under this folder
216
- first, instead of merging
217
- --list Show the current index and exit
218
- --clear Empty the index (or, with a folder, only the
219
- entries under it)
220
-
221
221
  Firewall options:
222
222
  -i, --interactive Interactively approve/deny (list)
223
223
  --container <name> Filter by (list) / scope to (add) a container
@@ -412,15 +412,40 @@ async function main() {
412
412
  }
413
413
  return;
414
414
  }
415
- if (cmd === 'indexfolder' || cmd === 'indexfolders') {
416
- await (0, indexfolder_1.runIndexFolder)({
417
- path: positional[1],
418
- depth: flagString(flags, 'depth'),
419
- all: flagBool(flags, 'all'),
420
- replace: flagBool(flags, 'replace'),
421
- clear: flagBool(flags, 'clear'),
422
- list: flagBool(flags, 'list'),
423
- });
415
+ if (cmd === 'extension' || cmd === 'ext') {
416
+ const subCmd = sub ?? 'list';
417
+ if (subCmd === 'list') {
418
+ await (0, extension_1.runExtensionList)();
419
+ }
420
+ else if (subCmd === 'install') {
421
+ const dir = positional[2];
422
+ if (!dir) {
423
+ console.error('Usage: huddle extension install <dir> [--force] [--restart] [--runtime <docker|podman>]');
424
+ process.exit(1);
425
+ }
426
+ await (0, extension_1.runExtensionInstall)(dir, {
427
+ force: flagBool(flags, 'force'),
428
+ restart: flagBool(flags, 'restart'),
429
+ runtime: flagString(flags, 'runtime'),
430
+ });
431
+ }
432
+ else if (subCmd === 'remove' || subCmd === 'rm') {
433
+ const id = positional[2];
434
+ if (!id) {
435
+ console.error('Usage: huddle extension remove <id>');
436
+ process.exit(1);
437
+ }
438
+ await (0, extension_1.runExtensionRemove)(id);
439
+ }
440
+ else {
441
+ console.error(`Unknown extension subcommand: ${subCmd}`);
442
+ console.error('Usage: huddle extension <list|install <dir>|remove <id>>');
443
+ process.exit(1);
444
+ }
445
+ return;
446
+ }
447
+ if (cmd === 'pipe') {
448
+ await (0, command_1.runPipe)({ action: sub });
424
449
  return;
425
450
  }
426
451
  if (cmd === 'update-agent') {
package/dist/init.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.HOST_SOCKET_DIR = exports.INTERNAL_NET = void 0;
6
+ exports.SSH_RELAY_PORTS = exports.HOST_SOCKET_DIR = exports.INTERNAL_NET = exports.CONTAINER = void 0;
7
7
  exports.runInit = runInit;
8
8
  const child_process_1 = require("child_process");
9
9
  const crypto_1 = __importDefault(require("crypto"));
@@ -12,8 +12,12 @@ const runtime_1 = require("./runtime");
12
12
  const images_1 = require("./images");
13
13
  const config_1 = require("./config");
14
14
  const base_images_1 = require("./base-images");
15
+ const os_1 = __importDefault(require("os"));
16
+ const host_logs_1 = require("./host-logs");
17
+ const protocol_1 = require("./pipe/protocol");
18
+ const command_1 = require("./pipe/command");
15
19
  const fs_1 = __importDefault(require("fs"));
16
- const CONTAINER = 'huddle';
20
+ exports.CONTAINER = 'huddle';
17
21
  const VOLUME = 'huddle-data';
18
22
  /**
19
23
  * The shared, internal network that `huddle init` creates (`--internal`, so it
@@ -30,6 +34,15 @@ exports.INTERNAL_NET = 'devcontainer-net';
30
34
  */
31
35
  exports.HOST_SOCKET_DIR = '/tmp/dc-sockets';
32
36
  const HOST_PORT = process.env.HUDDLE_PORT ?? '3000';
37
+ /**
38
+ * Ports of the per-devcontainer SSH relays (JetBrains Gateway over SSH), bound to
39
+ * the host's loopback only. Kept in sync with SSH_RELAY_PORT_MIN/MAX in
40
+ * gateway/src/ssh-access.ts.
41
+ */
42
+ exports.SSH_RELAY_PORTS = '2200-2219';
43
+ // Host port of the gateway's sbx egress proxy (docs/host-pipe.md). Published on
44
+ // loopback only: the sbx daemon runs on this machine, nothing else needs it.
45
+ const SBX_PROXY_HOST_PORT = process.env.HUDDLE_SBX_PROXY_PORT ?? '32768';
33
46
  // Run a binary with an argv array — NO shell. Values that originate from config
34
47
  // (team-folder paths, which are writable via `huddle firewall folder set` and the
35
48
  // authenticated settings API) must never be interpolated into a shell string, or
@@ -72,7 +85,7 @@ async function runInit(opts, images) {
72
85
  console.log((0, utils_1.dim)(`Network: ${exports.INTERNAL_NET}`));
73
86
  runArgsSilent(rt, ['network', 'inspect', exports.INTERNAL_NET]) || runArgs(rt, ['network', 'create', '--internal', exports.INTERNAL_NET]);
74
87
  console.log((0, utils_1.dim)(`Removing old container if it exists`));
75
- runArgsSilent(rt, ['rm', '-f', CONTAINER]);
88
+ runArgsSilent(rt, ['rm', '-f', exports.CONTAINER]);
76
89
  console.log((0, utils_1.dim)(`Socket directory: /tmp/dc-sockets`));
77
90
  // The mount SOURCE must be the path on the Docker ENGINE host (on Windows:
78
91
  // the WSL2/Linux VM), even when the CLI itself runs on Windows. The gateway
@@ -138,23 +151,45 @@ async function runInit(opts, images) {
138
151
  console.log((0, utils_1.dim)(` Mounting firewall-rules folder: ${fwFolder} -> /firewall-rules`));
139
152
  if (extFolder)
140
153
  console.log((0, utils_1.dim)(` Mounting extensions folder: ${extFolder} -> /extensions`));
154
+ // The host pipe lives inside the ~/.huddle mount; create it now so the
155
+ // gateway sees the folder from its first start, before the agent runs.
156
+ try {
157
+ (0, protocol_1.ensurePrivateDir)(protocol_1.PIPE_DIR);
158
+ }
159
+ catch (err) {
160
+ console.log((0, utils_1.yellow)(` Host pipe folder not usable: ${err instanceof Error ? err.message : err}`));
161
+ }
141
162
  // Build the container command as an argv array (runArgs → execFileSync, no
142
163
  // shell). The folder paths below come from config and are operator-writable via
143
164
  // the settings API, so they must never reach a shell as a string.
144
- const dockerArgs = ['run', '-d', '--name', CONTAINER, '--network', runtime.defaultNetwork];
165
+ const dockerArgs = ['run', '-d', '--name', exports.CONTAINER, '--network', runtime.defaultNetwork];
145
166
  for (const opt of runtime.securityOpts)
146
167
  dockerArgs.push('--security-opt', opt);
147
168
  dockerArgs.push('-e', `HUDDLE_RUNTIME=${runtime.name}`);
148
169
  dockerArgs.push('-e', `HUDDLE_OPERATOR_TOKEN=${operatorToken}`);
149
170
  dockerArgs.push('-p', `${HOST_PORT}:3000`);
171
+ dockerArgs.push('-p', `127.0.0.1:${exports.SSH_RELAY_PORTS}:${exports.SSH_RELAY_PORTS}`);
172
+ dockerArgs.push('-p', `127.0.0.1:${SBX_PROXY_HOST_PORT}:3128`, '-e', `HUDDLE_SBX_PROXY_HOST_PORT=${SBX_PROXY_HOST_PORT}`);
150
173
  dockerArgs.push('-v', `${VOLUME}:/data`);
151
174
  dockerArgs.push('-v', `${runtime.socketPath}:/var/run/docker.sock`);
152
175
  dockerArgs.push('-v', `${hostTmpSockets}:/tmp/dc-sockets`);
153
176
  dockerArgs.push('-v', `${config_1.CONFIG_DIR}:/huddle-home:rw`, '-e', 'HUDDLE_HOME_DIR=/huddle-home');
177
+ // Its host path, so the gateway can refuse mounts that would expose it (the
178
+ // operator token in config.json, the host pipe) to a devcontainer or sandbox.
179
+ dockerArgs.push('-e', `HUDDLE_HOST_HOME_DIR=${config_1.CONFIG_DIR}`);
154
180
  if (fwFolder)
155
181
  dockerArgs.push('-v', `${fwFolder}:/firewall-rules:rw`);
156
182
  if (extFolder)
157
183
  dockerArgs.push('-v', `${extFolder}:/extensions:ro`);
184
+ const hostLogs = (0, host_logs_1.hostAgentLogsMountArgs)(cfg, os_1.default.homedir());
185
+ if (hostLogs.length)
186
+ console.log((0, utils_1.dim)(' Mounting host Claude logs (read-only) for extensions'));
187
+ dockerArgs.push(...hostLogs);
188
+ const hostCodexLogs = (0, host_logs_1.hostCodexLogsMountArgs)(cfg, os_1.default.homedir());
189
+ if (hostCodexLogs.length)
190
+ console.log((0, utils_1.dim)(' Mounting host Codex logs (read-only) for extensions'));
191
+ dockerArgs.push(...hostCodexLogs);
192
+ dockerArgs.push(...(0, host_logs_1.hostCodexIndexMountArgs)(cfg, os_1.default.homedir()));
158
193
  dockerArgs.push(...(0, images_1.gatewayEnvArgs)(images));
159
194
  dockerArgs.push(IMAGE);
160
195
  runArgs(rt, dockerArgs);
@@ -176,7 +211,17 @@ async function runInit(opts, images) {
176
211
  // resolv.conf on Podman with that network's internal aardvark-DNS; the
177
212
  // gateway cleans that up itself (see dns-egress.ts / the startup sanitize in
178
213
  // index.ts).
179
- runArgsSilent(rt, ['network', 'connect', exports.INTERNAL_NET, CONTAINER]);
214
+ runArgsSilent(rt, ['network', 'connect', exports.INTERNAL_NET, exports.CONTAINER]);
215
+ // The host pipe lets the portal browse host folders and drive host tools
216
+ // (docs/host-pipe.md). Restarting it here means it always runs the CLI that
217
+ // was just installed. It is an extra, so a failure only warns.
218
+ const pipe = await (0, command_1.startPipeAgent)();
219
+ if (pipe.ok) {
220
+ console.log((0, utils_1.dim)(`Host pipe: running (pid ${pipe.pid})`));
221
+ }
222
+ else {
223
+ console.log((0, utils_1.yellow)(`[!] Host pipe did not start: ${pipe.error}. Run: huddle pipe start`));
224
+ }
180
225
  console.log();
181
226
  console.log((0, utils_1.green)(`[OK] Huddle is running at http://localhost:${HOST_PORT}`));
182
227
  console.log();