@openchamber/web 1.13.3 → 1.13.4

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.
Files changed (125) hide show
  1. package/bin/cli-output.js +0 -7
  2. package/bin/cli.js +132 -5548
  3. package/bin/cli.test.js +674 -0
  4. package/bin/lib/DOCUMENTATION.md +121 -0
  5. package/bin/lib/cli-args.js +726 -0
  6. package/bin/lib/cli-errors.js +18 -0
  7. package/bin/lib/cli-executables.js +54 -0
  8. package/bin/lib/cli-http.js +215 -0
  9. package/bin/lib/cli-lifecycle.js +421 -0
  10. package/bin/lib/cli-log-files.js +93 -0
  11. package/bin/lib/cli-network.js +153 -0
  12. package/bin/lib/cli-paths.js +111 -0
  13. package/bin/lib/cli-ports.js +51 -0
  14. package/bin/lib/cli-process.js +292 -0
  15. package/bin/lib/cli-startup.js +370 -0
  16. package/bin/lib/cli-tunnel-capabilities.js +9 -0
  17. package/bin/lib/cli-tunnel-profiles.js +366 -0
  18. package/bin/lib/cli-tunnel-utils.js +300 -0
  19. package/bin/lib/commands-connect-url.js +173 -0
  20. package/bin/lib/commands-lifecycle.js +396 -0
  21. package/bin/lib/commands-logs.js +110 -0
  22. package/bin/lib/commands-serve.js +396 -0
  23. package/bin/lib/commands-startup.js +64 -0
  24. package/bin/lib/commands-status.js +114 -0
  25. package/bin/lib/commands-tunnel.js +1757 -0
  26. package/bin/lib/commands-update.js +141 -0
  27. package/dist/assets/{DiagramView-BmHROYsX.js → DiagramView-BAoYIAGR.js} +1 -1
  28. package/dist/assets/{MarkdownRendererImpl-DiJE-v5Q.js → MarkdownRendererImpl-B0NE4mIY.js} +3 -3
  29. package/dist/assets/MultiRunWindow-BT4kt6aB.js +1 -0
  30. package/dist/assets/NewWorktreeDialog-Bx-zQyBp.js +167 -0
  31. package/dist/assets/{OnboardingScreen-DpBF8dKJ.js → OnboardingScreen-CbJOPUxm.js} +1 -1
  32. package/dist/assets/{SessionSwitcherDropdown-1xaHUxPK.js → SessionSwitcherDropdown-BbUzUNEi.js} +1 -1
  33. package/dist/assets/{SettingsWindow-ChwLyQAe.js → SettingsWindow-CSb8eo8p.js} +1 -1
  34. package/dist/assets/{TerminalView-DGEBNuAp.js → TerminalView-ME5MOz7S.js} +1 -1
  35. package/dist/assets/es-Bk-yR0w-.js +15 -0
  36. package/dist/assets/fr-f1ibV7QU.js +13 -0
  37. package/dist/assets/index-B82A6jBD.css +1 -0
  38. package/dist/assets/index-BsXkdBYx.js +3 -0
  39. package/dist/assets/ja-D9mS3zWP.js +15 -0
  40. package/dist/assets/ko-Cpl1IA3D.js +15 -0
  41. package/dist/assets/{main-fm_8J7Lk.js → main-D6eC2bnV.js} +2 -2
  42. package/dist/assets/main-fsOGbLGZ.js +214 -0
  43. package/dist/assets/miniChat-DKGU29GZ.js +2 -0
  44. package/dist/assets/mobile-YHQHMYWC.js +2 -0
  45. package/dist/assets/pl-CYke_fxL.js +15 -0
  46. package/dist/assets/pt-BR-Clb6Z8up.js +15 -0
  47. package/dist/assets/renderElectronMiniChatApp-3vxeddJO.js +2 -0
  48. package/dist/assets/{renderMobileApp-6s0G1iIJ.js → renderMobileApp-BrvLHYCY.js} +5 -5
  49. package/dist/assets/uk-CXn8cxXa.js +15 -0
  50. package/dist/assets/{useAppFontEffects-CV5C5O0r.js → useAppFontEffects-b7bqtGFf.js} +124 -119
  51. package/dist/assets/{vendor-.bun-CC_Xso_s.js → vendor-.bun-By2L9XvG.js} +1 -1
  52. package/dist/assets/zh-CN-BRwwlEdG.js +15 -0
  53. package/dist/assets/zh-TW-D5pg5Z8l.js +15 -0
  54. package/dist/index.html +4 -4
  55. package/dist/mini-chat.html +4 -4
  56. package/dist/mobile.html +4 -4
  57. package/package.json +1 -1
  58. package/server/lib/cloudflare-tunnel.js +2 -2
  59. package/server/lib/event-stream/global-hub.js +1 -1
  60. package/server/lib/event-stream/index.js +0 -12
  61. package/server/lib/event-stream/runtime.js +1 -1
  62. package/server/lib/git/service.js +18 -0
  63. package/server/lib/git/service.test.js +48 -0
  64. package/server/lib/notifications/index.js +1 -4
  65. package/server/lib/opencode/agents.js +0 -6
  66. package/server/lib/opencode/commands.js +0 -5
  67. package/server/lib/opencode/config-entity-routes.js +39 -21
  68. package/server/lib/opencode/feature-routes-runtime.js +27 -62
  69. package/server/lib/opencode/lifecycle.js +13 -1
  70. package/server/lib/opencode/npm-registry.js +3 -3
  71. package/server/lib/opencode/proxy.js +3 -3
  72. package/server/lib/opencode/shared.js +0 -6
  73. package/server/lib/opencode/skills.js +0 -2
  74. package/server/lib/opencode/snippets.js +0 -2
  75. package/server/lib/package-manager.js +5 -5
  76. package/server/lib/projects/project-config.js +0 -8
  77. package/server/lib/quota/DOCUMENTATION.md +3 -1
  78. package/server/lib/quota/providers/claude.js +1 -1
  79. package/server/lib/quota/providers/codex.js +1 -1
  80. package/server/lib/quota/providers/copilot.js +1 -1
  81. package/server/lib/quota/providers/cursor.js +1 -1
  82. package/server/lib/quota/providers/google/auth.js +2 -2
  83. package/server/lib/quota/providers/google/index.js +0 -27
  84. package/server/lib/quota/providers/google/transforms.js +1 -1
  85. package/server/lib/quota/providers/index.js +1 -1
  86. package/server/lib/quota/providers/kimi.js +1 -1
  87. package/server/lib/quota/providers/minimax-cn-coding-plan.js +1 -1
  88. package/server/lib/quota/providers/minimax-coding-plan.js +1 -1
  89. package/server/lib/quota/providers/nanogpt.js +1 -1
  90. package/server/lib/quota/providers/ollama-cloud.js +1 -1
  91. package/server/lib/quota/providers/openai.js +4 -4
  92. package/server/lib/quota/providers/openrouter.js +1 -1
  93. package/server/lib/quota/providers/wafer.js +1 -1
  94. package/server/lib/quota/providers/zai.js +1 -1
  95. package/server/lib/quota/providers/zhipuai-coding-plan.js +1 -1
  96. package/server/lib/skills-catalog/cache.js +0 -4
  97. package/server/lib/skills-catalog/clawdhub/api.js +0 -32
  98. package/server/lib/skills-catalog/clawdhub/scan.js +0 -52
  99. package/server/lib/skills-catalog/curated-sources.js +1 -1
  100. package/server/lib/skills-catalog/source.js +5 -0
  101. package/server/lib/terminal/runtime.js +11 -9
  102. package/server/lib/text/summarization.js +1 -1
  103. package/server/lib/tunnels/providers/ngrok.js +1 -1
  104. package/server/lib/tunnels/types.js +2 -2
  105. package/dist/assets/MultiRunWindow-yZoCT7F7.js +0 -1
  106. package/dist/assets/NewWorktreeDialog-CTMiE7Xd.js +0 -167
  107. package/dist/assets/es-CTE-E8we.js +0 -15
  108. package/dist/assets/fr-TVkZpyEo.js +0 -13
  109. package/dist/assets/index-B4pCDMbq.css +0 -1
  110. package/dist/assets/index-D9uMvTQF.js +0 -3
  111. package/dist/assets/ko-D_UCJIIL.js +0 -15
  112. package/dist/assets/main-eAd3a6tx.js +0 -214
  113. package/dist/assets/miniChat-Bbjg31IC.js +0 -2
  114. package/dist/assets/mobile-B3_j_DsB.js +0 -2
  115. package/dist/assets/pl-nDEkk-GZ.js +0 -15
  116. package/dist/assets/pt-BR-B_g2RcgU.js +0 -15
  117. package/dist/assets/renderElectronMiniChatApp-CB13zs6N.js +0 -2
  118. package/dist/assets/uk-CWLhnPGW.js +0 -15
  119. package/dist/assets/zh-CN-BFxe1b5m.js +0 -15
  120. package/dist/assets/zh-TW-n-d-xbGV.js +0 -15
  121. package/server/lib/opencode/index.js +0 -95
  122. package/server/lib/quota/providers/interface.js +0 -55
  123. package/server/lib/skills-catalog/clawdhub/index.js +0 -30
  124. package/server/lib/skills-catalog/index.js +0 -42
  125. package/server/lib/terminal/index.js +0 -31
@@ -0,0 +1,726 @@
1
+ import { TunnelCliError, EXIT_CODE } from './cli-errors.js';
2
+
3
+ const DEFAULT_PORT = 3000;
4
+ const DEFAULT_TAIL_LINES = 200;
5
+
6
+ function levenshteinDistance(a, b) {
7
+ const m = a.length;
8
+ const n = b.length;
9
+ const dp = Array.from({ length: m + 1 }, () => new Array(n + 1).fill(0));
10
+ for (let i = 0; i <= m; i++) dp[i][0] = i;
11
+ for (let j = 0; j <= n; j++) dp[0][j] = j;
12
+ for (let i = 1; i <= m; i++) {
13
+ for (let j = 1; j <= n; j++) {
14
+ dp[i][j] = a[i - 1] === b[j - 1]
15
+ ? dp[i - 1][j - 1]
16
+ : 1 + Math.min(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1]);
17
+ }
18
+ }
19
+ return dp[m][n];
20
+ }
21
+
22
+ function findClosestMatch(input, candidates, maxDistance = 3) {
23
+ if (typeof input !== 'string' || input.length === 0 || !Array.isArray(candidates)) {
24
+ return null;
25
+ }
26
+ const normalized = input.toLowerCase();
27
+ let bestCandidate = null;
28
+ let bestDistance = maxDistance + 1;
29
+ for (const candidate of candidates) {
30
+ const distance = levenshteinDistance(normalized, candidate.toLowerCase());
31
+ if (distance < bestDistance) {
32
+ bestDistance = distance;
33
+ bestCandidate = candidate;
34
+ }
35
+ }
36
+ return bestDistance <= maxDistance ? bestCandidate : null;
37
+ }
38
+
39
+ function splitOptionToken(arg) {
40
+ if (!arg.startsWith('-')) return null;
41
+ if (arg.startsWith('--')) {
42
+ const eqIndex = arg.indexOf('=');
43
+ return {
44
+ name: eqIndex >= 0 ? arg.slice(2, eqIndex) : arg.slice(2),
45
+ inlineValue: eqIndex >= 0 ? arg.slice(eqIndex + 1) : undefined,
46
+ long: true,
47
+ };
48
+ }
49
+ return {
50
+ name: arg.slice(1),
51
+ inlineValue: undefined,
52
+ long: false,
53
+ };
54
+ }
55
+
56
+ function parseArgs(argv = process.argv.slice(2)) {
57
+ const args = Array.isArray(argv) ? [...argv] : [];
58
+ const options = {
59
+ port: DEFAULT_PORT,
60
+ host: undefined,
61
+ uiPassword: process.env.OPENCHAMBER_UI_PASSWORD || undefined,
62
+ json: false,
63
+ all: false,
64
+ follow: true,
65
+ lines: DEFAULT_TAIL_LINES,
66
+ provider: undefined,
67
+ mode: undefined,
68
+ profile: undefined,
69
+ name: undefined,
70
+ configPath: undefined,
71
+ token: undefined,
72
+ tokenFile: undefined,
73
+ tokenStdin: false,
74
+ hostname: undefined,
75
+ server: undefined,
76
+ connectTtl: undefined,
77
+ sessionTtl: undefined,
78
+ qr: false,
79
+ explicitQr: false,
80
+ force: false,
81
+ showSecrets: false,
82
+ dryRun: false,
83
+ plain: false,
84
+ quiet: false,
85
+ explicitPort: false,
86
+ explicitUiPassword: false,
87
+ envSnapshot: true,
88
+ foreground: false,
89
+ lan: false,
90
+ apiOnly: false,
91
+ };
92
+
93
+ const removedFlagErrors = [];
94
+ const positional = [];
95
+ let helpRequested = false;
96
+ let versionRequested = false;
97
+
98
+ const consumeValue = (index, inlineValue) => {
99
+ if (typeof inlineValue === 'string' && inlineValue.length > 0) {
100
+ return { value: inlineValue, nextIndex: index };
101
+ }
102
+ const candidate = args[index + 1];
103
+ if (typeof candidate === 'string' && !candidate.startsWith('-')) {
104
+ return { value: candidate, nextIndex: index + 1 };
105
+ }
106
+ return { value: undefined, nextIndex: index };
107
+ };
108
+
109
+ for (let i = 0; i < args.length; i++) {
110
+ const arg = args[i];
111
+ const parsedToken = splitOptionToken(arg);
112
+ if (!parsedToken) {
113
+ positional.push(arg);
114
+ continue;
115
+ }
116
+
117
+ const { name, inlineValue, long } = parsedToken;
118
+ switch (name) {
119
+ case 'port':
120
+ case 'p': {
121
+ const { value: consumedValue, nextIndex: consumedIndex } = consumeValue(i, inlineValue);
122
+ let value = consumedValue;
123
+ let nextIndex = consumedIndex;
124
+
125
+ // Support explicit negative numeric values like `-p -1` so we can report
126
+ // a clear range validation error instead of "Unknown option".
127
+ if (value === undefined && typeof inlineValue !== 'string') {
128
+ const candidate = args[i + 1];
129
+ if (typeof candidate === 'string' && /^-\d+$/.test(candidate)) {
130
+ value = candidate;
131
+ nextIndex = i + 1;
132
+ }
133
+ }
134
+
135
+ i = nextIndex;
136
+
137
+ if (typeof value !== 'string' || value.trim().length === 0) {
138
+ throw new TunnelCliError('Missing value for --port.', EXIT_CODE.USAGE_ERROR);
139
+ }
140
+
141
+ if (!/^-?\d+$/.test(value.trim())) {
142
+ throw new TunnelCliError(`Invalid port value: ${value}`, EXIT_CODE.USAGE_ERROR);
143
+ }
144
+
145
+ const parsed = parseInt(value, 10);
146
+ if (parsed < 1 || parsed > 65535) {
147
+ throw new TunnelCliError(`Invalid port value: ${parsed}`, EXIT_CODE.USAGE_ERROR);
148
+ }
149
+
150
+ options.port = parsed;
151
+ options.explicitPort = true;
152
+ break;
153
+ }
154
+ case 'host': {
155
+ const { value, nextIndex } = consumeValue(i, inlineValue);
156
+ i = nextIndex;
157
+ if (typeof value !== 'string' || value.trim().length === 0) {
158
+ throw new TunnelCliError('Missing value for --host.', EXIT_CODE.USAGE_ERROR);
159
+ }
160
+ options.host = value.trim();
161
+ break;
162
+ }
163
+ case 'lan':
164
+ options.lan = true;
165
+ break;
166
+ case 'ui-password': {
167
+ const { value, nextIndex } = consumeValue(i, inlineValue);
168
+ i = nextIndex;
169
+ options.uiPassword = typeof value === 'string' ? value : '';
170
+ options.explicitUiPassword = true;
171
+ break;
172
+ }
173
+ case 'provider': {
174
+ const { value, nextIndex } = consumeValue(i, inlineValue);
175
+ i = nextIndex;
176
+ options.provider = typeof value === 'string' ? value : options.provider;
177
+ break;
178
+ }
179
+ case 'mode': {
180
+ const { value, nextIndex } = consumeValue(i, inlineValue);
181
+ i = nextIndex;
182
+ options.mode = typeof value === 'string' ? value : options.mode;
183
+ break;
184
+ }
185
+ case 'profile': {
186
+ const { value, nextIndex } = consumeValue(i, inlineValue);
187
+ i = nextIndex;
188
+ options.profile = typeof value === 'string' ? value : options.profile;
189
+ break;
190
+ }
191
+ case 'name': {
192
+ const { value, nextIndex } = consumeValue(i, inlineValue);
193
+ i = nextIndex;
194
+ options.name = typeof value === 'string' ? value : options.name;
195
+ break;
196
+ }
197
+ case 'config': {
198
+ const { value, nextIndex } = consumeValue(i, inlineValue);
199
+ i = nextIndex;
200
+ options.configPath = typeof value === 'string' ? value : null;
201
+ break;
202
+ }
203
+ case 'token': {
204
+ const { value, nextIndex } = consumeValue(i, inlineValue);
205
+ i = nextIndex;
206
+ options.token = typeof value === 'string' ? value : options.token;
207
+ break;
208
+ }
209
+ case 'token-file': {
210
+ const { value, nextIndex } = consumeValue(i, inlineValue);
211
+ i = nextIndex;
212
+ options.tokenFile = typeof value === 'string' ? value : options.tokenFile;
213
+ break;
214
+ }
215
+ case 'token-stdin':
216
+ options.tokenStdin = true;
217
+ break;
218
+ case 'hostname': {
219
+ const { value, nextIndex } = consumeValue(i, inlineValue);
220
+ i = nextIndex;
221
+ options.hostname = typeof value === 'string' ? value : options.hostname;
222
+ break;
223
+ }
224
+ case 'server':
225
+ case 'server-url': {
226
+ const { value, nextIndex } = consumeValue(i, inlineValue);
227
+ i = nextIndex;
228
+ if (typeof value !== 'string' || value.trim().length === 0) {
229
+ throw new TunnelCliError('Missing value for --server.', EXIT_CODE.USAGE_ERROR);
230
+ }
231
+ options.server = value.trim();
232
+ break;
233
+ }
234
+ case 'connect-ttl': {
235
+ const { value, nextIndex } = consumeValue(i, inlineValue);
236
+ i = nextIndex;
237
+ options.connectTtl = typeof value === 'string' ? value : options.connectTtl;
238
+ break;
239
+ }
240
+ case 'session-ttl': {
241
+ const { value, nextIndex } = consumeValue(i, inlineValue);
242
+ i = nextIndex;
243
+ options.sessionTtl = typeof value === 'string' ? value : options.sessionTtl;
244
+ break;
245
+ }
246
+ case 'json':
247
+ options.json = true;
248
+ break;
249
+ case 'all':
250
+ options.all = true;
251
+ break;
252
+ case 'no-follow':
253
+ options.follow = false;
254
+ break;
255
+ case 'no-env-snapshot':
256
+ options.envSnapshot = false;
257
+ break;
258
+ case 'lines': {
259
+ const { value, nextIndex } = consumeValue(i, inlineValue);
260
+ i = nextIndex;
261
+ const parsed = parseInt(value ?? '', 10);
262
+ if (Number.isFinite(parsed) && parsed > 0) {
263
+ options.lines = parsed;
264
+ }
265
+ break;
266
+ }
267
+ case 'qr':
268
+ options.qr = true;
269
+ options.explicitQr = true;
270
+ break;
271
+ case 'no-qr':
272
+ options.qr = false;
273
+ options.explicitQr = true;
274
+ break;
275
+ case 'force':
276
+ options.force = true;
277
+ break;
278
+ case 'show-secrets':
279
+ options.showSecrets = true;
280
+ break;
281
+ case 'dry-run':
282
+ options.dryRun = true;
283
+ break;
284
+ case 'plain':
285
+ options.plain = true;
286
+ break;
287
+ case 'quiet':
288
+ case 'q':
289
+ options.quiet = true;
290
+ break;
291
+ case 'help':
292
+ case 'h':
293
+ helpRequested = true;
294
+ break;
295
+ case 'version':
296
+ case 'v':
297
+ versionRequested = true;
298
+ break;
299
+ case 'foreground':
300
+ case 'no-daemon':
301
+ options.foreground = true;
302
+ break;
303
+ case 'api-only':
304
+ options.apiOnly = true;
305
+ break;
306
+ case 'daemon':
307
+ case 'd':
308
+ // Legacy no-op: daemon mode is already the default, but older clients
309
+ // may still pass this when starting a remote server.
310
+ break;
311
+ case 'try-cf-tunnel':
312
+ removedFlagErrors.push('`--try-cf-tunnel` was removed. Use: openchamber tunnel start --provider cloudflare --mode quick');
313
+ break;
314
+ case 'tunnel-qr':
315
+ removedFlagErrors.push('`--tunnel-qr` was removed. Use: openchamber tunnel start ... --qr');
316
+ break;
317
+ case 'tunnel-password-url':
318
+ removedFlagErrors.push('`--tunnel-password-url` was removed. Use UI password auth directly after tunnel start.');
319
+ break;
320
+ case 'tunnel-provider':
321
+ case 'tunnel-mode':
322
+ case 'tunnel-config':
323
+ case 'tunnel-token':
324
+ case 'tunnel-hostname':
325
+ case 'tunnel':
326
+ removedFlagErrors.push(`\`--${name}\` was removed from top-level serve flow. Use: openchamber tunnel start ...`);
327
+ break;
328
+ default:
329
+ if (!long && name.length === 1) {
330
+ removedFlagErrors.push(`Unknown option: -${name}`);
331
+ } else {
332
+ removedFlagErrors.push(`Unknown option: --${name}`);
333
+ }
334
+ break;
335
+ }
336
+ }
337
+
338
+ const command = positional[0] || 'serve';
339
+ const subcommand = command === 'tunnel' ? (positional[1] || 'help') : null;
340
+ const tunnelAction = command === 'tunnel' ? (positional[2] || null) : null;
341
+ const startupAction = command === 'startup' ? (positional[1] || 'status') : null;
342
+
343
+ if (options.lan && typeof options.host !== 'string') {
344
+ options.host = '0.0.0.0';
345
+ }
346
+
347
+ if (command !== 'tunnel' && typeof options.hostname === 'string' && typeof options.host !== 'string') {
348
+ options.host = options.hostname;
349
+ }
350
+
351
+ return {
352
+ command,
353
+ subcommand,
354
+ tunnelAction,
355
+ startupAction,
356
+ options,
357
+ removedFlagErrors,
358
+ helpRequested,
359
+ versionRequested,
360
+ };
361
+ }
362
+
363
+ function showHelp() {
364
+ console.log(`
365
+ OpenChamber - Web interface for the OpenCode AI coding agent
366
+
367
+ USAGE:
368
+ openchamber [COMMAND] [OPTIONS]
369
+
370
+ COMMANDS:
371
+ serve Start the web server (daemon default)
372
+ stop Stop running instance(s)
373
+ restart Stop and start the server
374
+ status Show server status
375
+ tunnel Tunnel lifecycle commands
376
+ startup Manage launch at system startup
377
+ logs Tail OpenChamber logs
378
+ connect-url Generate URL/QR for connecting another client
379
+ update Check for and install updates
380
+
381
+ OPTIONS:
382
+ -p, --port Web server port (default: ${DEFAULT_PORT})
383
+ --host Bind address (default: 127.0.0.1)
384
+ --hostname Alias for --host outside tunnel commands
385
+ --lan Bind to 0.0.0.0 for LAN access
386
+ --server <url> Public/server URL for connect-url links
387
+ --ui-password Protect browser UI with single password
388
+ --api-only Start API routes only, without serving browser UI assets
389
+ --foreground Run server in foreground (use with systemd/process managers)
390
+ --no-daemon Alias for --foreground
391
+ -h, --help Show help
392
+ -v, --version Show version
393
+
394
+ ENVIRONMENT:
395
+ OPENCHAMBER_HOST Bind address (e.g. 0.0.0.0 for all interfaces)
396
+ OPENCHAMBER_UI_PASSWORD Alternative to --ui-password flag
397
+ OPENCHAMBER_API_ONLY Set to true/1 to start API routes only
398
+ OPENCHAMBER_DATA_DIR Override OpenChamber data directory
399
+ OPENCODE_HOST External OpenCode server base URL, e.g. http://hostname:4096
400
+ OPENCODE_PORT Port of external OpenCode server to connect to
401
+ OPENCODE_SKIP_START Skip starting OpenCode, use external server
402
+ OPENCHAMBER_OPENCODE_HOSTNAME Bind hostname for managed OpenCode server (default: 127.0.0.1)
403
+
404
+ EXAMPLES:
405
+ openchamber # Start in daemon mode on default port 3000 (or free port)
406
+ openchamber --port 8080 # Start on port 8080 (daemon)
407
+ openchamber --lan --port 3002 # Start on LAN at 0.0.0.0:3002
408
+ openchamber serve --foreground # Start in foreground (for systemd Type=simple)
409
+ openchamber connect-url --port 3000 --qr
410
+ openchamber connect-url --server https://openchamber.example.com
411
+ openchamber startup enable # Start OpenChamber at user login
412
+ openchamber tunnel help # Show tunnel lifecycle help
413
+ openchamber logs # Follow logs for latest running instance
414
+ `);
415
+ }
416
+
417
+ function showStartupHelp() {
418
+ console.log(`
419
+ OpenChamber Startup Commands
420
+
421
+ USAGE:
422
+ openchamber startup <SUBCOMMAND> [OPTIONS]
423
+
424
+ SUBCOMMANDS:
425
+ status Show startup integration status
426
+ enable Install and start native user startup integration
427
+ disable Stop and remove native user startup integration
428
+
429
+ OPTIONS:
430
+ -p, --port Web server port used by startup service
431
+ --host Bind address used by startup service
432
+ --ui-password Protect browser UI with single password
433
+ --api-only Start API routes only, without serving browser UI assets
434
+ --no-env-snapshot Do not save current environment for startup service
435
+ --json Output machine-readable JSON
436
+ -q, --quiet Suppress non-essential output
437
+
438
+ EXAMPLES:
439
+ openchamber startup enable
440
+ openchamber startup enable --port 3000
441
+ openchamber startup enable --port 3000 --api-only --host 0.0.0.0
442
+ openchamber startup status --json
443
+ `);
444
+ }
445
+
446
+ function showConnectUrlHelp() {
447
+ console.log(`
448
+ OpenChamber Connect URL
449
+
450
+ USAGE:
451
+ openchamber connect-url [OPTIONS]
452
+
453
+ DESCRIPTION:
454
+ Generate an openchamber:// connection link for adding this server to another
455
+ OpenChamber app. If no server is running on the selected port, it starts one.
456
+
457
+ OPTIONS:
458
+ -p, --port <port> Server port to use or start (default: ${DEFAULT_PORT})
459
+ --host <address> Bind address when starting the server
460
+ --hostname <address> Alias for --host
461
+ --lan Bind to 0.0.0.0 for LAN access when starting
462
+ --server <url> Public URL saved into the connection link
463
+ --server-url <url> Alias for --server
464
+ --name <label> Label saved with the remote client token
465
+ --ui-password <value> Protect browser access when UI routes are enabled
466
+ --api-only Start in headless/API-only mode when starting
467
+ --qr Print a QR code for the connection link
468
+ --json Output machine-readable JSON
469
+ -q, --quiet Print only the connection link
470
+ -h, --help Show this help
471
+
472
+ EXAMPLES:
473
+ openchamber connect-url --port 3000 --qr
474
+ openchamber connect-url --port 3000 --api-only --lan --server http://workstation.local:3000 --qr
475
+ openchamber connect-url --server https://openchamber.example.com --name Workstation
476
+ `);
477
+ }
478
+
479
+ function showTunnelHelp() {
480
+ console.log(`
481
+ Tunnel Lifecycle Commands
482
+
483
+ USAGE:
484
+ openchamber tunnel <SUBCOMMAND> [OPTIONS]
485
+
486
+ SUBCOMMANDS:
487
+ help Show this tunnel help
488
+ providers Show available tunnel providers and capabilities
489
+ ready Check tunnel readiness for a provider
490
+ doctor Run deep tunnel diagnostics
491
+ status Show tunnel status
492
+ start Start a tunnel
493
+ stop Stop active tunnel (keep server running)
494
+ profile Manage saved managed-remote profiles
495
+
496
+ COMMON OPTIONS:
497
+ -p, --port Target OpenChamber instance port
498
+ --host Bind address when auto-starting an instance
499
+ --lan Bind to 0.0.0.0 when auto-starting an instance
500
+ --ui-password Protect browser UI when auto-starting an instance
501
+ --api-only Start API routes only when auto-starting an instance
502
+ --json Output machine-readable JSON
503
+ --all Apply to all running instances (doctor default, stop)
504
+
505
+ START OPTIONS:
506
+ --provider <id> Tunnel provider id (default: cloudflare)
507
+ --mode <id> Tunnel mode (default: quick)
508
+ --profile <name> Start tunnel from saved profile name
509
+ --config [path] Managed-local config path (optional)
510
+ --token <token> Managed-remote token (visible in process list)
511
+ --token-file <path> Read token from file (recommended)
512
+ --token-stdin Read token from stdin
513
+ --hostname <hostname> Managed-remote hostname
514
+ --connect-ttl <value> Connect-link TTL (e.g. 30m, 24h, 1d)
515
+ --session-ttl <value> Session TTL (e.g. 8h, 24h, 1d)
516
+ --qr Print QR code for resulting tunnel URL
517
+ --no-qr Disable QR output
518
+ --dry-run Validate inputs without applying changes
519
+
520
+ OUTPUT OPTIONS:
521
+ --show-secrets Show full tokens in output (default: redacted)
522
+ --plain Disable colors and decorations
523
+ -q, --quiet Suppress non-essential output
524
+ --json Output machine-readable JSON
525
+
526
+ BEHAVIOR NOTES:
527
+ - One active tunnel per OpenChamber instance.
528
+ - Starting a different mode/provider replaces the current tunnel and revokes old connect links/sessions.
529
+ - Connect links are one-time; generating a new link revokes the previous unused link.
530
+
531
+ PROFILE USAGE:
532
+ openchamber tunnel profile list [--provider <id>] [--json]
533
+ openchamber tunnel profile show --name <name> [--provider <id>] [--json]
534
+ openchamber tunnel profile add --provider <id> --mode managed-remote --name <name> --hostname <host> --token <token> [--force] [--json]
535
+ openchamber tunnel profile add --provider <id> --mode managed-remote --name <name> --hostname <host> --token-file <path> [--force] [--json]
536
+ openchamber tunnel profile remove --name <name> [--provider <id>] [--json]
537
+
538
+ SHELL COMPLETION:
539
+ openchamber tunnel completion bash Generate Bash completion script
540
+ openchamber tunnel completion zsh Generate Zsh completion script
541
+ openchamber tunnel completion fish Generate Fish completion script
542
+
543
+ EXAMPLES:
544
+ openchamber tunnel providers
545
+ openchamber tunnel ready --provider cloudflare
546
+ openchamber tunnel doctor --provider cloudflare
547
+ openchamber tunnel status
548
+ openchamber tunnel start --qr
549
+ openchamber tunnel start --profile prod-main
550
+ openchamber tunnel start --provider cloudflare --mode managed-remote --token-file ~/.secrets/cf-token --hostname app.example.com
551
+ openchamber tunnel start --provider cloudflare --mode managed-local --config ~/.cloudflared/config.yml
552
+ openchamber tunnel start --dry-run --provider cloudflare --mode managed-remote --token-file ~/.secrets/cf-token --hostname app.example.com
553
+ echo "$TOKEN" | openchamber tunnel profile add --provider cloudflare --mode managed-remote --name prod-main --hostname app.example.com --token-stdin
554
+ openchamber tunnel profile list --provider cloudflare
555
+ openchamber tunnel profile list --json --show-secrets
556
+ openchamber tunnel stop --port 3000
557
+ `);
558
+ }
559
+
560
+ function generateCompletionScript(shell) {
561
+ const normalized = typeof shell === 'string' ? shell.trim().toLowerCase() : '';
562
+
563
+ if (normalized === 'bash') {
564
+ return `# Bash completion for openchamber tunnel
565
+ # Add to ~/.bashrc: eval "$(openchamber tunnel completion bash)"
566
+ _openchamber_tunnel() {
567
+ local cur prev commands tunnel_commands profile_commands common_flags start_flags
568
+ COMPREPLY=()
569
+ cur="\${COMP_WORDS[COMP_CWORD]}"
570
+ prev="\${COMP_WORDS[COMP_CWORD-1]}"
571
+
572
+ commands="serve stop restart status tunnel logs update"
573
+ tunnel_commands="help providers ready doctor status start stop profile completion"
574
+ profile_commands="list show add remove"
575
+ common_flags="--port --foreground --no-daemon --json --all --help --version --plain --quiet"
576
+ start_flags="--provider --mode --profile --config --token --token-file --token-stdin --hostname --connect-ttl --session-ttl --qr --no-qr --dry-run --show-secrets"
577
+
578
+ if [[ \${COMP_CWORD} -eq 1 ]]; then
579
+ COMPREPLY=( $(compgen -W "\${commands}" -- "\${cur}") )
580
+ return 0
581
+ fi
582
+
583
+ if [[ "\${COMP_WORDS[1]}" == "tunnel" ]]; then
584
+ if [[ \${COMP_CWORD} -eq 2 ]]; then
585
+ COMPREPLY=( $(compgen -W "\${tunnel_commands}" -- "\${cur}") )
586
+ return 0
587
+ fi
588
+ if [[ "\${COMP_WORDS[2]}" == "profile" && \${COMP_CWORD} -eq 3 ]]; then
589
+ COMPREPLY=( $(compgen -W "\${profile_commands}" -- "\${cur}") )
590
+ return 0
591
+ fi
592
+ if [[ "\${COMP_WORDS[2]}" == "completion" && \${COMP_CWORD} -eq 3 ]]; then
593
+ COMPREPLY=( $(compgen -W "bash zsh fish" -- "\${cur}") )
594
+ return 0
595
+ fi
596
+ if [[ "\${COMP_WORDS[2]}" == "start" ]]; then
597
+ COMPREPLY=( $(compgen -W "\${start_flags} \${common_flags}" -- "\${cur}") )
598
+ return 0
599
+ fi
600
+ COMPREPLY=( $(compgen -W "\${common_flags}" -- "\${cur}") )
601
+ return 0
602
+ fi
603
+
604
+ COMPREPLY=( $(compgen -W "\${common_flags}" -- "\${cur}") )
605
+ return 0
606
+ }
607
+ complete -F _openchamber_tunnel openchamber
608
+ `;
609
+ }
610
+
611
+ if (normalized === 'zsh') {
612
+ return `#compdef openchamber
613
+ # Zsh completion for openchamber tunnel
614
+ # Add to ~/.zshrc: eval "$(openchamber tunnel completion zsh)"
615
+
616
+ _openchamber() {
617
+ local -a commands tunnel_commands profile_commands
618
+
619
+ commands=(
620
+ 'serve:Start the web server'
621
+ 'stop:Stop running instance(s)'
622
+ 'restart:Stop and start the server'
623
+ 'status:Show server status'
624
+ 'tunnel:Tunnel lifecycle commands'
625
+ 'logs:Tail OpenChamber logs'
626
+ 'update:Check for and install updates'
627
+ )
628
+
629
+ tunnel_commands=(
630
+ 'help:Show tunnel help'
631
+ 'providers:Show available providers'
632
+ 'ready:Check tunnel readiness'
633
+ 'doctor:Run tunnel diagnostics'
634
+ 'status:Show tunnel status'
635
+ 'start:Start a tunnel'
636
+ 'stop:Stop active tunnel'
637
+ 'profile:Manage saved profiles'
638
+ 'completion:Generate shell completion'
639
+ )
640
+
641
+ profile_commands=(
642
+ 'list:List profiles'
643
+ 'show:Show profile details'
644
+ 'add:Add a profile'
645
+ 'remove:Remove a profile'
646
+ )
647
+
648
+ _arguments -C \\
649
+ '1:command:->command' \\
650
+ '*::arg:->args'
651
+
652
+ case \$state in
653
+ command)
654
+ _describe 'command' commands
655
+ ;;
656
+ args)
657
+ case \$words[1] in
658
+ tunnel)
659
+ if (( CURRENT == 2 )); then
660
+ _describe 'tunnel command' tunnel_commands
661
+ elif [[ \$words[2] == "profile" ]] && (( CURRENT == 3 )); then
662
+ _describe 'profile action' profile_commands
663
+ elif [[ \$words[2] == "completion" ]] && (( CURRENT == 3 )); then
664
+ _values 'shell' bash zsh fish
665
+ fi
666
+ ;;
667
+ esac
668
+ ;;
669
+ esac
670
+ }
671
+
672
+ compdef _openchamber openchamber
673
+ `;
674
+ }
675
+
676
+ if (normalized === 'fish') {
677
+ return `# Fish completion for openchamber tunnel
678
+ # Save to ~/.config/fish/completions/openchamber.fish
679
+
680
+ complete -c openchamber -n '__fish_use_subcommand' -a 'serve' -d 'Start the web server'
681
+ complete -c openchamber -n '__fish_seen_subcommand_from serve' -l foreground -d 'Run in foreground (for systemd/process managers)'
682
+ complete -c openchamber -n '__fish_seen_subcommand_from serve' -l no-daemon -d 'Run in foreground (alias for --foreground)'
683
+ complete -c openchamber -n '__fish_use_subcommand' -a 'stop' -d 'Stop running instance(s)'
684
+ complete -c openchamber -n '__fish_use_subcommand' -a 'restart' -d 'Stop and start the server'
685
+ complete -c openchamber -n '__fish_use_subcommand' -a 'status' -d 'Show server status'
686
+ complete -c openchamber -n '__fish_use_subcommand' -a 'tunnel' -d 'Tunnel lifecycle commands'
687
+ complete -c openchamber -n '__fish_use_subcommand' -a 'logs' -d 'Tail logs'
688
+ complete -c openchamber -n '__fish_use_subcommand' -a 'update' -d 'Check for updates'
689
+
690
+ complete -c openchamber -n '__fish_seen_subcommand_from tunnel; and not __fish_seen_subcommand_from help providers ready doctor status start stop profile completion' -a 'help' -d 'Show tunnel help'
691
+ complete -c openchamber -n '__fish_seen_subcommand_from tunnel; and not __fish_seen_subcommand_from help providers ready doctor status start stop profile completion' -a 'providers' -d 'Show providers'
692
+ complete -c openchamber -n '__fish_seen_subcommand_from tunnel; and not __fish_seen_subcommand_from help providers ready doctor status start stop profile completion' -a 'ready' -d 'Check readiness'
693
+ complete -c openchamber -n '__fish_seen_subcommand_from tunnel; and not __fish_seen_subcommand_from help providers ready doctor status start stop profile completion' -a 'doctor' -d 'Run diagnostics'
694
+ complete -c openchamber -n '__fish_seen_subcommand_from tunnel; and not __fish_seen_subcommand_from help providers ready doctor status start stop profile completion' -a 'status' -d 'Show tunnel status'
695
+ complete -c openchamber -n '__fish_seen_subcommand_from tunnel; and not __fish_seen_subcommand_from help providers ready doctor status start stop profile completion' -a 'start' -d 'Start a tunnel'
696
+ complete -c openchamber -n '__fish_seen_subcommand_from tunnel; and not __fish_seen_subcommand_from help providers ready doctor status start stop profile completion' -a 'stop' -d 'Stop tunnel'
697
+ complete -c openchamber -n '__fish_seen_subcommand_from tunnel; and not __fish_seen_subcommand_from help providers ready doctor status start stop profile completion' -a 'profile' -d 'Manage profiles'
698
+ complete -c openchamber -n '__fish_seen_subcommand_from tunnel; and not __fish_seen_subcommand_from help providers ready doctor status start stop profile completion' -a 'completion' -d 'Generate completions'
699
+
700
+ complete -c openchamber -n '__fish_seen_subcommand_from tunnel; and __fish_seen_subcommand_from start' -l provider -d 'Provider id'
701
+ complete -c openchamber -n '__fish_seen_subcommand_from tunnel; and __fish_seen_subcommand_from start' -l mode -d 'Tunnel mode'
702
+ complete -c openchamber -n '__fish_seen_subcommand_from tunnel; and __fish_seen_subcommand_from start' -l profile -d 'Profile name'
703
+ complete -c openchamber -n '__fish_seen_subcommand_from tunnel; and __fish_seen_subcommand_from start' -l config -d 'Config path'
704
+ complete -c openchamber -n '__fish_seen_subcommand_from tunnel; and __fish_seen_subcommand_from start' -l token -d 'Token'
705
+ complete -c openchamber -n '__fish_seen_subcommand_from tunnel; and __fish_seen_subcommand_from start' -l token-file -d 'Token file path'
706
+ complete -c openchamber -n '__fish_seen_subcommand_from tunnel; and __fish_seen_subcommand_from start' -l token-stdin -d 'Read token from stdin'
707
+ complete -c openchamber -n '__fish_seen_subcommand_from tunnel; and __fish_seen_subcommand_from start' -l hostname -d 'Hostname'
708
+ complete -c openchamber -n '__fish_seen_subcommand_from tunnel; and __fish_seen_subcommand_from start' -l dry-run -d 'Validate without applying'
709
+ complete -c openchamber -n '__fish_seen_subcommand_from tunnel; and __fish_seen_subcommand_from start' -l qr -d 'Show QR code'
710
+ `;
711
+ }
712
+
713
+ return null;
714
+ }
715
+
716
+
717
+ export {
718
+ DEFAULT_PORT,
719
+ parseArgs,
720
+ showHelp,
721
+ showStartupHelp,
722
+ showConnectUrlHelp,
723
+ showTunnelHelp,
724
+ generateCompletionScript,
725
+ findClosestMatch,
726
+ };