@teamclaws/teamclaw 2026.7.1 → 2026.8.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.
Files changed (60) hide show
  1. package/README.md +8 -0
  2. package/dist/api.js +1 -0
  3. package/dist/index.js +325 -0
  4. package/dist/src/config.js +381 -0
  5. package/dist/src/controller/controller-capacity.js +14 -0
  6. package/dist/src/controller/controller-service.js +393 -0
  7. package/dist/src/controller/controller-tools.js +582 -0
  8. package/dist/src/controller/delivery-report.js +458 -0
  9. package/dist/src/controller/github-auth.js +564 -0
  10. package/dist/src/controller/http-server.js +6032 -0
  11. package/dist/src/controller/kickoff-orchestrator.js +220 -0
  12. package/dist/src/controller/managed-gateway-process.js +286 -0
  13. package/dist/src/controller/message-router.js +38 -0
  14. package/dist/src/controller/orchestration-manifest.js +173 -0
  15. package/dist/src/controller/preview-manager.js +586 -0
  16. package/dist/src/controller/prompt-injector.js +187 -0
  17. package/dist/src/controller/role-inference.js +35 -0
  18. package/dist/src/controller/task-router.js +67 -0
  19. package/dist/src/controller/tunnel-manager.js +548 -0
  20. package/dist/src/controller/websocket.js +42 -0
  21. package/dist/src/controller/worker-provisioning.js +1648 -0
  22. package/dist/src/discovery.js +86 -0
  23. package/dist/src/git-collaboration.js +694 -0
  24. package/dist/src/identity.js +131 -0
  25. package/dist/src/install-defaults.js +1 -0
  26. package/dist/src/interaction-contracts.js +531 -0
  27. package/dist/src/networking.js +91 -0
  28. package/dist/src/openclaw-workspace.js +903 -0
  29. package/dist/src/prompt-policy.js +373 -0
  30. package/dist/src/protocol.js +58 -0
  31. package/dist/src/roles.js +349 -0
  32. package/dist/src/state.js +183 -0
  33. package/dist/src/task-executor.js +1033 -0
  34. package/dist/src/teamauto/github-client.js +192 -0
  35. package/dist/src/teamauto/norms.js +85 -0
  36. package/dist/src/teamauto/repo-sync.js +201 -0
  37. package/dist/src/teamauto/scanner.js +179 -0
  38. package/dist/src/teamauto/schedule.js +123 -0
  39. package/dist/src/teamauto/scheduler.js +688 -0
  40. package/dist/src/teamauto/store.js +133 -0
  41. package/dist/src/types.js +243 -0
  42. package/dist/src/ui/app.js +4292 -0
  43. package/dist/src/ui/assets/teamclaw-app-icon.png +0 -0
  44. package/dist/src/ui/github-login.html +296 -0
  45. package/dist/src/ui/index.html +414 -0
  46. package/dist/src/ui/style.css +2611 -0
  47. package/dist/src/worker/http-handler.js +146 -0
  48. package/dist/src/worker/message-queue.js +24 -0
  49. package/dist/src/worker/prompt-injector.js +42 -0
  50. package/dist/src/worker/skill-installer.js +253 -0
  51. package/dist/src/worker/tools.js +541 -0
  52. package/dist/src/worker/worker-service.js +234 -0
  53. package/dist/src/workspace-browser.js +269 -0
  54. package/openclaw.plugin.json +1 -1
  55. package/package.json +9 -7
  56. package/src/controller/http-server.ts +26 -1
  57. package/src/controller/tunnel-manager.ts +139 -15
  58. package/src/ui/app.js +97 -20
  59. package/src/ui/index.html +16 -4
  60. package/src/ui/style.css +49 -0
@@ -42,14 +42,27 @@ export const TUNNEL_SERVER_URL = "https://apps.teamclaw.dev/api";
42
42
  const TUNNEL_HOST_SUFFIX = ".teamclaw.dev";
43
43
  const GATE_COOKIE = "tc_tunnel_gate";
44
44
 
45
+ /** Env var that injects a user-owned Cloudflare connector token. When set,
46
+ * the UI skips the token input and offers direct one-click start. */
47
+ export const SELF_HOSTED_TOKEN_ENV = "TEAMCLAW_TUNNEL_TOKEN";
48
+ export function selfHostedTokenFromEnv(): string | null {
49
+ const v = process.env[SELF_HOSTED_TOKEN_ENV]?.trim();
50
+ return v ? v : null;
51
+ }
52
+
45
53
  export type TunnelStatus = {
46
54
  active: boolean;
55
+ /** "managed": platform tunnel on *.teamclaw.dev (gate-protected).
56
+ * "self-hosted": user-owned Cloudflare tunnel via connector token. */
57
+ mode: "managed" | "self-hosted" | "quick" | null;
47
58
  hostname: string | null;
48
59
  gateToken: string | null;
49
60
  connectorRunning: boolean;
50
61
  tunnelId: string | null;
51
62
  cloudflaredInstalled: boolean;
52
63
  cloudflaredPath: string | null;
64
+ /** True when SELF_HOSTED_TOKEN_ENV carries a token (UI hint: skip input). */
65
+ envTokenDetected: boolean;
53
66
  startOp: { running: boolean; phase: string; detail: string | null };
54
67
  install: { running: boolean; phase: string; percent: number | null; detail: string | null };
55
68
  error: string | null;
@@ -184,6 +197,11 @@ export function createTunnelManager(deps: { logger: PluginLogger; localPort: num
184
197
  let child: ChildProcess | null = null;
185
198
  let handle: TunnelHandle | null = null;
186
199
  let lastError: string | null = null;
200
+ // True while stop()/a restart path intentionally kills the connector; the
201
+ // cloudflared exit handler uses this to distinguish planned teardown from
202
+ // an unexpected crash (which must clear the active state so /tunnel/status
203
+ // never reports a dead tunnel as live).
204
+ let userStopping = false;
187
205
  let startOp: { running: boolean; phase: string; detail: string | null } = { running: false, phase: "idle", detail: null };
188
206
  let installState: { running: boolean; phase: string; percent: number | null; detail: string | null } = { running: false, phase: "idle", percent: null, detail: null };
189
207
 
@@ -232,6 +250,89 @@ export function createTunnelManager(deps: { logger: PluginLogger; localPort: num
232
250
  return handle;
233
251
  }
234
252
 
253
+ /** Start a user-owned Cloudflare tunnel from a connector token (Zero Trust
254
+ * dashboard -> Tunnels -> <tunnel> -> copy token). The public hostname lives
255
+ * in the user's own CF zone, so it does NOT pass the .teamclaw.dev gate -
256
+ * protect it with Cloudflare Access if needed. Returns immediately; poll
257
+ * status() for connectorRunning. */
258
+ function startSelfHosted(rawToken: string): { launched: boolean; error: string | null } {
259
+ const token = rawToken.trim();
260
+ if (!token) return { launched: false, error: "empty connector token" };
261
+ if (token.length < 40 || !/^[A-Za-z0-9_\-=]+$/.test(token)) {
262
+ return { launched: false, error: "not a Cloudflare connector token (expected a long base64url string from the Zero Trust dashboard)" };
263
+ }
264
+ if (handle && child) return { launched: true, error: null };
265
+ const bin = findCloudflared();
266
+ if (!bin) return { launched: false, error: "cloudflared not found (brew install cloudflared)" };
267
+ startOp = { running: true, phase: "starting-connector", detail: "self-hosted tunnel" };
268
+ stopConnector();
269
+ child = spawnConnector(bin, token);
270
+ handle = { tunnelId: "self-hosted", hostname: "", gateToken: "", deleteToken: "" };
271
+ writeTunnelState({ tunnelId: "self-hosted", hostname: "", gateToken: "", deleteToken: "", connectorToken: token, pid: child.pid ?? null, savedAt: Date.now() });
272
+ startOp = { running: false, phase: "done", detail: "self-hosted tunnel" };
273
+ lastError = null;
274
+ logger.info("TeamClaw tunnel: self-hosted Cloudflare tunnel connector started");
275
+ return { launched: true, error: null };
276
+ }
277
+
278
+ /** Anonymous one-off tunnel: `cloudflared tunnel --url`, no Cloudflare
279
+ * account, no token, no platform server. Cloudflare assigns a random
280
+ * trycloudflare.com URL (printed on stderr) which dies with the process -
281
+ * it is NOT recovered on restart and must not be treated as stable. No
282
+ * TeamClaw gate: anyone with the URL can reach the dashboard. */
283
+ function startQuick(): { launched: boolean; error: string | null } {
284
+ if (handle && child) return { launched: true, error: null };
285
+ const bin = findCloudflared();
286
+ if (!bin) return { launched: false, error: "cloudflared not found (brew install cloudflared)" };
287
+ startOp = { running: true, phase: "starting-connector", detail: "quick tunnel" };
288
+ stopConnector();
289
+ const proc = spawn(bin, ["tunnel", "--no-autoupdate", "--url", "http://127.0.0.1:" + deps.localPort], {
290
+ stdio: ["ignore", "ignore", "pipe"],
291
+ detached: false,
292
+ env: { ...process.env, HOME: tunnelRuntimeHome() },
293
+ });
294
+ child = proc;
295
+ handle = { tunnelId: "quick", hostname: "", gateToken: "", deleteToken: "" };
296
+ lastError = null;
297
+ // The trycloudflare.com URL appears on stderr once the edge assigns it.
298
+ let announced = false;
299
+ const urlRe = /https:\/\/([a-z0-9-]+\.trycloudflare\.com)/i;
300
+ const timer = setTimeout(() => {
301
+ if (!announced) {
302
+ lastError = "quick tunnel did not announce its URL within 20s";
303
+ startOp = { running: false, phase: "error", detail: lastError };
304
+ }
305
+ }, 20000);
306
+ proc.stderr?.on("data", (c: Buffer) => {
307
+ const m = c.toString().match(urlRe);
308
+ if (m && !announced) {
309
+ announced = true;
310
+ clearTimeout(timer);
311
+ if (handle) handle.hostname = m[1]!;
312
+ startOp = { running: false, phase: "done", detail: m[1] };
313
+ logger.info(`TeamClaw tunnel: quick tunnel live at https://${m[1]}`);
314
+ }
315
+ try { fs.appendFileSync(path.join(tunnelRuntimeHome(), "cloudflared.log"), c); } catch { /* best effort */ }
316
+ });
317
+ // Quick tunnels are one-off: no persistent state, no recovery - but the
318
+ // connector-exit contract still applies: a dead connector must clear the
319
+ // active state so status() never reports a dead tunnel as live.
320
+ proc.on("exit", (code: number | null) => {
321
+ clearTimeout(timer);
322
+ logger.warn(`TeamClaw tunnel: cloudflared exited (code ${code})`);
323
+ if (child !== proc) return;
324
+ child = null;
325
+ if (!userStopping && handle) {
326
+ handle = null;
327
+ lastError = `tunnel connector exited unexpectedly (code ${code ?? "null"})`;
328
+ startOp = { running: false, phase: "error", detail: lastError };
329
+ clearTunnelState();
330
+ logger.warn("TeamClaw tunnel: state cleared after unexpected exit (quick)");
331
+ }
332
+ });
333
+ return { launched: true, error: null };
334
+ }
335
+
235
336
  function spawnConnector(bin: string, connectorToken: string): ChildProcess {
236
337
  const proc = spawn(bin, ["tunnel", "--no-autoupdate", "--protocol", "http2", "run", "--token", connectorToken], {
237
338
  stdio: ["ignore", "ignore", "pipe"],
@@ -243,7 +344,22 @@ export function createTunnelManager(deps: { logger: PluginLogger; localPort: num
243
344
  });
244
345
  proc.on("exit", (code: number | null) => {
245
346
  logger.warn(`TeamClaw tunnel: cloudflared exited (code ${code})`);
246
- if (child === proc) child = null;
347
+ if (child !== proc) return;
348
+ child = null;
349
+ // Unexpected exit (crash, network loss, cloudflared auto-kill): tear
350
+ // the logical state down too, otherwise status() keeps reporting
351
+ // active=true and the UI shows a dead tunnel as live forever.
352
+ if (!userStopping && handle) {
353
+ const gone = handle;
354
+ handle = null;
355
+ lastError = `tunnel connector exited unexpectedly (code ${code ?? "null"})`;
356
+ startOp = { running: false, phase: "error", detail: lastError };
357
+ if (gone.tunnelId !== "self-hosted" && gone.tunnelId !== "quick") {
358
+ void tunnelFetch(`/tunnels/${gone.tunnelId}?user=${encodeURIComponent(gone.hostname.split(".")[0]!.replace(/^team-/, ""))}&token=${encodeURIComponent(gone.deleteToken)}`, "DELETE").catch(() => undefined);
359
+ }
360
+ clearTunnelState();
361
+ logger.warn(`TeamClaw tunnel: state cleared after unexpected exit (${gone.tunnelId})`);
362
+ }
247
363
  });
248
364
  // cloudflared logs (stderr) land in a single file for diagnosis.
249
365
  // (stdout is "ignore" in stdio above, so there is nothing to pipe.)
@@ -260,14 +376,20 @@ export function createTunnelManager(deps: { logger: PluginLogger; localPort: num
260
376
  }
261
377
 
262
378
  async function stop(): Promise<void> {
379
+ userStopping = true;
263
380
  stopConnector();
264
381
  if (handle) {
265
382
  const gone = handle;
266
383
  handle = null;
267
- await tunnelFetch(`/tunnels/${gone.tunnelId}?user=${encodeURIComponent(gone.hostname.split(".")[0]!.replace(/^team-/, ""))}&token=${encodeURIComponent(gone.deleteToken)}`, "DELETE").catch(() => undefined);
384
+ // Self-hosted tunnels live in the user's CF account - nothing to
385
+ // delete server-side; the connector stop is the whole teardown.
386
+ if (gone.tunnelId !== "self-hosted" && gone.tunnelId !== "quick") {
387
+ await tunnelFetch(`/tunnels/${gone.tunnelId}?user=${encodeURIComponent(gone.hostname.split(".")[0]!.replace(/^team-/, ""))}&token=${encodeURIComponent(gone.deleteToken)}`, "DELETE").catch(() => undefined);
388
+ }
268
389
  clearTunnelState();
269
- logger.info(`TeamClaw tunnel: stopped ${gone.hostname}`);
390
+ logger.info(gone.tunnelId === "self-hosted" || gone.tunnelId === "quick" ? "TeamClaw tunnel: connector stopped" : `TeamClaw tunnel: stopped ${gone.hostname}`);
270
391
  }
392
+ userStopping = false;
271
393
  }
272
394
 
273
395
  // Boot reconciliation: reconnect the share persisted by a previous run.
@@ -277,41 +399,43 @@ export function createTunnelManager(deps: { logger: PluginLogger; localPort: num
277
399
  async function recover(): Promise<TunnelHandle | null> {
278
400
  if (handle) return handle;
279
401
  const st = readTunnelState();
280
- if (!st) return null;
402
+ if (!st || st.tunnelId === "quick") return null; // one-off, not recoverable
281
403
  const bin = findCloudflared();
282
404
  if (!bin) {
283
405
  logger.warn("TeamClaw tunnel: previous share found but cloudflared is not installed; not recovering");
284
406
  return null;
285
407
  }
286
- // kill -9 of the gateway leaves an orphaned connector behind (SIGKILL
287
- // cannot run the close handler). Reap it before reconnecting - pid-reuse
288
- // safe: only when the binary still matches.
289
408
  if (st.pid && connectorPidIsCloudflared(st.pid)) {
290
409
  try {
291
410
  process.kill(st.pid, "SIGKILL");
292
411
  logger.warn(`TeamClaw tunnel: killed orphaned connector (pid ${st.pid})`);
293
412
  } catch { /* already gone */ }
294
413
  }
295
- startOp = { running: true, phase: "starting-connector", detail: st.hostname };
414
+ startOp = { running: true, phase: "starting-connector", detail: st.hostname || "self-hosted tunnel" };
296
415
  stopConnector();
297
416
  child = spawnConnector(bin, st.connectorToken);
298
- handle = { tunnelId: st.tunnelId, hostname: st.hostname, gateToken: st.gateToken, deleteToken: st.deleteToken };
417
+ const selfHosted = st.tunnelId === "self-hosted";
418
+ handle = selfHosted
419
+ ? { tunnelId: "self-hosted", hostname: "", gateToken: "", deleteToken: "" }
420
+ : { tunnelId: st.tunnelId, hostname: st.hostname, gateToken: st.gateToken, deleteToken: st.deleteToken };
299
421
  writeTunnelState({ ...st, pid: child.pid ?? null, savedAt: Date.now() });
300
- startOp = { running: false, phase: "done", detail: st.hostname };
422
+ startOp = { running: false, phase: "done", detail: st.hostname || "self-hosted tunnel" };
301
423
  lastError = null;
302
- logger.info(`TeamClaw tunnel: recovered https://${st.hostname} (tunnel id and gate token preserved)`);
424
+ logger.info(selfHosted ? "TeamClaw tunnel: recovered self-hosted Cloudflare tunnel" : `TeamClaw tunnel: recovered https://${st.hostname} (tunnel id and gate token preserved)`);
303
425
  return handle;
304
426
  }
305
427
 
306
428
  function status(): TunnelStatus {
307
429
  return {
308
430
  active: Boolean(handle),
309
- tunnelId: handle?.tunnelId ?? null,
310
- hostname: handle?.hostname ?? null,
311
- gateToken: handle?.gateToken ?? null,
431
+ mode: handle ? (handle.tunnelId === "self-hosted" ? "self-hosted" : handle.tunnelId === "quick" ? "quick" : "managed") : null,
432
+ hostname: handle?.hostname || null,
433
+ gateToken: handle?.gateToken || null,
312
434
  connectorRunning: Boolean(child),
435
+ tunnelId: handle?.tunnelId ?? null,
313
436
  cloudflaredInstalled: findCloudflared() !== null,
314
437
  cloudflaredPath: findCloudflared(),
438
+ envTokenDetected: selfHostedTokenFromEnv() !== null,
315
439
  startOp: { ...startOp },
316
440
  install: { ...installState },
317
441
  error: lastError,
@@ -423,7 +547,7 @@ export function createTunnelManager(deps: { logger: PluginLogger; localPort: num
423
547
  }
424
548
 
425
549
 
426
- return { start: launchStart, stop, recover, status, installCloudflared, isTunnelRequest, gateAllows };
550
+ return { start: launchStart, startSelfHosted, startQuick, stop, recover, status, installCloudflared, isTunnelRequest, gateAllows };
427
551
  }
428
552
 
429
553
  export type TunnelManager = ReturnType<typeof createTunnelManager>;
package/src/ui/app.js CHANGED
@@ -2481,14 +2481,14 @@
2481
2481
  ? '<span class="task-origin-badge">' + escapeHtml(task.createdBy) + "</span>"
2482
2482
  : "";
2483
2483
  const contractSummary = task.resultContract
2484
- ? '<div class="task-contract-summary"><strong>Result:</strong> ' + escapeHtml(task.resultContract.summary || "") + "</div>"
2484
+ ? '<div class="task-contract-summary clamp"><strong>Result:</strong> ' + escapeHtml(task.resultContract.summary || "") + "</div>"
2485
2485
  : task.lastHandoff
2486
- ? '<div class="task-contract-summary"><strong>Handoff:</strong> ' + escapeHtml(task.lastHandoff.summary || "") + "</div>"
2486
+ ? '<div class="task-contract-summary clamp"><strong>Handoff:</strong> ' + escapeHtml(task.lastHandoff.summary || "") + "</div>"
2487
2487
  : task.progressContract
2488
- ? '<div class="task-contract-summary"><strong>Progress:</strong> ' + escapeHtml(task.progressContract.summary || "") + "</div>"
2488
+ ? '<div class="task-contract-summary clamp"><strong>Progress:</strong> ' + escapeHtml(task.progressContract.summary || "") + "</div>"
2489
2489
  : "";
2490
2490
  const note = task.progress
2491
- ? '<div class="task-note">' + escapeHtml(task.progress).slice(0, 220) + "</div>"
2491
+ ? '<div class="task-note clamp">' + escapeHtml(task.progress).slice(0, 220) + "</div>"
2492
2492
  : "";
2493
2493
  const clarification = task.clarificationRequestId
2494
2494
  ? '<span>Clarification: ' + escapeHtml(task.clarificationRequestId) + "</span>"
@@ -2500,7 +2500,7 @@
2500
2500
  ' <span class="task-priority ' + escapeHtml(priority) + '">' + escapeHtml(priority) + "</span>" +
2501
2501
  ' <div class="task-body">' +
2502
2502
  ' <div class="task-title-row"><div class="task-title">' + escapeHtml(task.title) + "</div>" + creatorBadge + "</div>" +
2503
- (task.description ? '<div class="task-desc">' + escapeHtml(task.description).slice(0, 220) + "</div>" : "") +
2503
+ (task.description ? '<div class="task-desc clamp">' + escapeHtml(task.description).slice(0, 220) + "</div>" : "") +
2504
2504
  renderSkillPills(recommendedSkills, "skill-pills task-skill-pills") +
2505
2505
  contractSummary +
2506
2506
  note +
@@ -4163,45 +4163,122 @@ function closeModelSettings() {
4163
4163
  }, 10000);
4164
4164
 
4165
4165
 
4166
- // Tunnel sharing (internet gate for the local web UI).
4166
+ // Tunnel sharing (internet gate for the local web UI). The settings UI is
4167
+ // a header-triggered popover; while the MANAGED tunnel (*.teamclaw.dev) is
4168
+ // active its URL surfaces as #tunnel-live-pill in the header (self-hosted
4169
+ // hostnames live in the user's Cloudflare dashboard and are not shown).
4167
4170
  function initTunnelPanel() {
4168
- const wrap = document.getElementById("tunnel-panel");
4171
+ const wrap = document.getElementById("tunnel-popover");
4172
+ const pill = document.getElementById("tunnel-live-pill");
4173
+ const toggleBtn = document.getElementById("tunnel-settings-toggle");
4169
4174
  if (!wrap || wrap.dataset.bound) return;
4170
4175
  wrap.dataset.bound = "true";
4176
+ const openPopover = () => { wrap.hidden = false; };
4177
+ const closePopover = () => { wrap.hidden = true; };
4178
+ if (toggleBtn) toggleBtn.addEventListener("click", () => { wrap.hidden = !wrap.hidden; });
4179
+ wrap.addEventListener("click", (e) => {
4180
+ if (e.target.getAttribute && e.target.getAttribute("data-act") === "close") closePopover();
4181
+ });
4182
+ document.addEventListener("keydown", (e) => { if (e.key === "Escape" && !wrap.hidden) closePopover(); });
4171
4183
  // Visitor view: when the dashboard itself is reached through a tunnel
4172
- // domain, management APIs are gated - degrade to a provenance badge
4184
+ // domain, management APIs are gated - degrade to a provenance note
4173
4185
  // instead of a spinner that can never resolve.
4174
4186
  const host = (location.hostname || "").toLowerCase();
4175
4187
  const isLocalView = host === "127.0.0.1" || host === "localhost" || host.endsWith(".local");
4176
4188
  if (!isLocalView) {
4177
- wrap.innerHTML = '<h3>Internet Tunnel</h3><div class="tunnel-state"><span class="tunnel-note">This dashboard is shared via a TeamClaw tunnel.</span></div>';
4189
+ wrap.querySelector(".tunnel-state").innerHTML = '<span class="tunnel-note">This dashboard is shared via a TeamClaw tunnel.</span>';
4190
+ if (toggleBtn) toggleBtn.hidden = true;
4178
4191
  return;
4179
4192
  }
4180
4193
  const render = (st) => {
4194
+ // Header pill: managed tunnel only (*.teamclaw.dev). Self-hosted
4195
+ // hostnames are managed in the user's Cloudflare dashboard.
4196
+ if (pill) {
4197
+ if (st.active && st.mode === "managed" && st.hostname) {
4198
+ pill.href = "https://" + st.hostname;
4199
+ pill.textContent = st.hostname;
4200
+ pill.hidden = false;
4201
+ } else {
4202
+ pill.hidden = true;
4203
+ }
4204
+ }
4181
4205
  var progress = st.startOp && st.startOp.running
4182
4206
  ? '<div class="tunnel-note">Starting tunnel: ' + escapeHtml(st.startOp.phase) + '…</div>'
4183
4207
  : (st.install && st.install.running
4184
4208
  ? '<div class="tunnel-note">cloudflared ' + escapeHtml(st.install.phase) + (st.install.percent != null ? ' ' + st.install.percent + '%' : '') + '…</div>'
4185
4209
  : '');
4186
4210
  if (progress) { wrap.querySelector(".tunnel-state").innerHTML = progress; return; }
4187
- wrap.querySelector(".tunnel-state").innerHTML = st.active
4188
- ? '<div class="tunnel-on">Live: <a href="https://' + st.hostname + '" target="_blank" rel="noopener">https://' + st.hostname + '</a></div>'
4211
+ if (st.active && st.mode === "quick") {
4212
+ wrap.querySelector(".tunnel-state").innerHTML =
4213
+ '<div class="tunnel-on">Quick tunnel: ' + (st.hostname ? '<a href="https://' + st.hostname + '" target="_blank" rel="noopener">https://' + st.hostname + '</a>' : 'waiting for URL…') + '</div>'
4214
+ + '<div class="tunnel-note">One-off URL - dies on restart. Anyone with the link can open the dashboard.</div>'
4215
+ + '<button class="btn btn-small" data-act="stop">Stop sharing</button>';
4216
+ return;
4217
+ }
4218
+ if (st.active && st.mode === "self-hosted") {
4219
+ wrap.querySelector(".tunnel-state").innerHTML =
4220
+ '<div class="tunnel-on">Self-hosted Cloudflare tunnel: live on your own domain</div>'
4221
+ + '<div class="tunnel-note">Public hostname is managed in your Cloudflare Zero Trust dashboard.</div>'
4222
+ + '<button class="btn btn-small" data-act="stop">Stop sharing</button>';
4223
+ return;
4224
+ }
4225
+ if (st.active) {
4226
+ wrap.querySelector(".tunnel-state").innerHTML =
4227
+ '<div class="tunnel-on">Live: <a href="https://' + st.hostname + '" target="_blank" rel="noopener">https://' + st.hostname + '</a></div>'
4189
4228
  + '<div class="tunnel-token">Gate token: <b>' + st.gateToken + '</b></div>'
4190
- + '<button class="btn btn-small" data-act="stop">Stop sharing</button>'
4191
- : st.cloudflaredInstalled === false
4192
- ? '<div class="tunnel-note">cloudflared connector is not installed.</div>'
4193
- + '<button class="btn btn-small btn-primary" data-act="install">Install cloudflared</button>'
4194
- : '<button class="btn btn-small btn-primary" data-act="start">Share via tunnel</button>'
4195
- + '<span class="tunnel-note">requires GitHub login</span>';
4229
+ + '<button class="btn btn-small" data-act="stop">Stop sharing</button>';
4230
+ return;
4231
+ }
4232
+ if (st.cloudflaredInstalled === false) {
4233
+ wrap.querySelector(".tunnel-state").innerHTML = '<div class="tunnel-note">cloudflared connector is not installed.</div>'
4234
+ + '<button class="btn btn-small btn-primary" data-act="install">Install cloudflared</button>';
4235
+ return;
4236
+ }
4237
+ // Idle: self-hosted (env token detected -> one click; otherwise token
4238
+ // input) alongside the managed share button.
4239
+ var html = '';
4240
+ if (st.envTokenDetected) {
4241
+ html += '<div class="tunnel-note">Connector token detected via TEAMCLAW_TUNNEL_TOKEN — ready to start.</div>'
4242
+ + '<button class="btn btn-small btn-primary" data-act="start-self">Start self-hosted tunnel</button>';
4243
+ } else {
4244
+ html += '<div class="tunnel-note">Self-hosted tunnel (your own Cloudflare account/domain):</div>'
4245
+ + '<input type="password" class="tunnel-token-input" data-input="token" placeholder="Cloudflare connector token" autocomplete="off">'
4246
+ + '<button class="btn btn-small btn-primary" data-act="start-self-token">Start self-hosted tunnel</button>'
4247
+ + '<details class="tunnel-setup-help"><summary>How to get a token &amp; set up the tunnel</summary>'
4248
+ + '<div class="tunnel-note">Cloudflare Zero Trust → Networks → Tunnels → your tunnel → copy token. Point its public hostname at this machine’s URL (Service: HTTP + the controller port shown in the docs). Protect it with Cloudflare Access — self-hosted domains skip the TeamClaw gate.</div></details>';
4249
+ }
4250
+ html += '<div class="tunnel-note">— or —</div>'
4251
+ + '<button class="btn btn-small" data-act="start">Share via *.teamclaw.dev</button>'
4252
+ + '<span class="tunnel-note">requires GitHub login</span>'
4253
+ + '<div class="tunnel-note">— or —</div>'
4254
+ + '<button class="btn btn-small" data-act="start-quick">Anonymous one-off tunnel (trycloudflare.com)</button>'
4255
+ + '<div class="tunnel-note">No account needed. Random URL, dies on restart, anyone with the link can open the dashboard - use for quick demos only. Needs the cloudflared binary.</div>';
4256
+ wrap.querySelector(".tunnel-state").innerHTML = html;
4196
4257
  };
4197
4258
  const refresh = () => apiGet("/tunnel/status").then((st) => render(st || {})).catch(() => {});
4198
4259
  wrap.addEventListener("click", (e) => {
4199
4260
  const act = e.target.getAttribute && e.target.getAttribute("data-act");
4200
4261
  if (!act) return;
4201
4262
  e.target.disabled = true;
4202
- var call = act === "start" ? apiRequest("/tunnel/start", { method: "POST" })
4203
- : act === "install" ? apiRequest("/tunnel/install-cloudflared", { method: "POST" })
4204
- : apiRequest("/tunnel/stop", { method: "POST" });
4263
+ var call;
4264
+ if (act === "start-quick") {
4265
+ call = apiRequest("/tunnel/start-quick", { method: "POST" });
4266
+ } else if (act === "start-self" || act === "start-self-token") {
4267
+ const opts = { method: "POST", headers: { "Content-Type": "application/json" } };
4268
+ if (act === "start-self-token") {
4269
+ const input = wrap.querySelector('[data-input="token"]');
4270
+ if (!input || !input.value.trim()) {
4271
+ wrap.querySelector(".tunnel-state").innerHTML = '<div class="tunnel-err">Paste a Cloudflare connector token first.</div>';
4272
+ return;
4273
+ }
4274
+ opts.body = JSON.stringify({ token: input.value.trim() });
4275
+ }
4276
+ call = apiRequest("/tunnel/start-self-hosted", opts);
4277
+ } else {
4278
+ call = act === "start" ? apiRequest("/tunnel/start", { method: "POST" })
4279
+ : act === "install" ? apiRequest("/tunnel/install-cloudflared", { method: "POST" })
4280
+ : apiRequest("/tunnel/stop", { method: "POST" });
4281
+ }
4205
4282
  call.then(refresh).catch((err) => { wrap.querySelector(".tunnel-state").innerHTML = '<div class="tunnel-err">' + escapeHtml(String(err.message || err)) + "</div>"; });
4206
4283
  });
4207
4284
  refresh();
package/src/ui/index.html CHANGED
@@ -24,6 +24,8 @@
24
24
  </div>
25
25
  <div class="header-status">
26
26
  <span id="connection-status" class="status-dot disconnected"></span>
27
+ <a id="tunnel-live-pill" class="tunnel-live-pill" hidden target="_blank" rel="noopener" title="Managed tunnel is live - open in a new tab"></a>
28
+ <button id="tunnel-settings-toggle" class="header-mini-btn" type="button" title="Internet tunnel settings">Tunnel</button>
27
29
  <button id="language-toggle" class="header-mini-btn" type="button">中文</button>
28
30
  <button id="toast-settings-toggle" class="header-mini-btn" type="button" title="Toast notifications">Toasts</button>
29
31
  <button id="worker-install-toggle" class="header-mini-btn" type="button" hidden>Add worker</button>
@@ -131,10 +133,6 @@
131
133
 
132
134
  <!-- Workspace Tab -->
133
135
  <div id="tab-workspace" class="tab-panel">
134
- <div class="tunnel-card" id="tunnel-panel">
135
- <h3>Internet Tunnel</h3>
136
- <div class="tunnel-state"><span class="tunnel-note">loading…</span></div>
137
- </div>
138
136
  <div class="workspace-browser">
139
137
  <aside class="workspace-sidebar-panel">
140
138
  <div class="workspace-panel-header">
@@ -397,6 +395,20 @@
397
395
  </div>
398
396
  </footer>
399
397
 
398
+ <!-- Internet tunnel configuration popover (opened from the header
399
+ Tunnel button; the managed URL surfaces as #tunnel-live-pill while
400
+ active). -->
401
+ <div id="tunnel-popover" class="tunnel-popover" hidden>
402
+ <div class="tunnel-popover-backdrop" data-act="close"></div>
403
+ <div class="tunnel-popover-card" role="dialog" aria-modal="true" aria-label="Internet tunnel settings">
404
+ <div class="tunnel-popover-head">
405
+ <h3>Internet Tunnel</h3>
406
+ <button class="tunnel-popover-close" data-act="close" type="button" aria-label="Close">×</button>
407
+ </div>
408
+ <div class="tunnel-state"><span class="tunnel-note">loading…</span></div>
409
+ </div>
410
+ </div>
411
+
400
412
  <script src="/ui/app.js"></script>
401
413
  </body>
402
414
  </html>
package/src/ui/style.css CHANGED
@@ -502,6 +502,18 @@ body {
502
502
  }
503
503
  .task-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
504
504
  .task-desc { font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }
505
+ /* List-density relief: long contract results/descriptions/notes clamp to
506
+ 3 lines on the card; full text lives in the task detail panel. */
507
+ .task-card .clamp {
508
+ display: -webkit-box;
509
+ -webkit-line-clamp: 3;
510
+ -webkit-box-orient: vertical;
511
+ overflow: hidden;
512
+ }
513
+ .tunnel-setup-help { margin: 6px 0 2px; }
514
+ .tunnel-setup-help summary { cursor: pointer; color: var(--text-muted); font-size: 12px; user-select: none; }
515
+ .tunnel-setup-help[open] summary { margin-bottom: 4px; }
516
+ .tunnel-setup-help div { padding-left: 2px; }
505
517
  .task-origin-badge {
506
518
  font-size: 10px;
507
519
  font-weight: 600;
@@ -2558,5 +2570,42 @@ body {
2558
2570
  .tunnel-on a { color: var(--accent); font-family: var(--mono); }
2559
2571
  .tunnel-token { margin: 8px 0; font-size: 13px; }
2560
2572
  .tunnel-token b { font-family: var(--mono); letter-spacing: .15em; color: var(--accent); }
2573
+ .tunnel-token-input {
2574
+ display: block; width: 100%; box-sizing: border-box; margin: 6px 0;
2575
+ padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border, #3a3731);
2576
+ background: var(--surface-2, #232120); color: var(--text, #ecebe6);
2577
+ font-size: 12.5px; font-family: var(--mono, monospace);
2578
+ }
2579
+ /* Header pill: live managed (*.teamclaw.dev) tunnel URL. */
2580
+ .tunnel-live-pill {
2581
+ display: inline-flex; align-items: center; gap: 6px;
2582
+ max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
2583
+ padding: 3px 10px; border-radius: 999px;
2584
+ background: rgba(108, 190, 128, 0.14); border: 1px solid rgba(108, 190, 128, 0.4);
2585
+ color: #6cbe80; font-size: 11.5px; font-family: var(--mono, monospace);
2586
+ text-decoration: none; vertical-align: middle;
2587
+ }
2588
+ .tunnel-live-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #6cbe80; flex: none; box-shadow: 0 0 6px #6cbe80; }
2589
+ .tunnel-live-pill:hover { background: rgba(108, 190, 128, 0.22); }
2590
+ /* Tunnel settings popover (opened from the header Tunnel button). */
2591
+ .tunnel-popover { position: fixed; inset: 0; z-index: 300; }
2592
+ .tunnel-popover[hidden] { display: none; }
2593
+ .tunnel-popover-backdrop { position: absolute; inset: 0; background: rgba(10, 9, 7, 0.55); backdrop-filter: blur(2px); }
2594
+ .tunnel-popover-card {
2595
+ position: absolute; top: 64px; right: 18px; width: min(420px, calc(100vw - 36px));
2596
+ background: var(--surface-1, #1a1917); border: 1px solid var(--border, #2d2b27);
2597
+ border-radius: 14px; padding: 16px 18px 18px; box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
2598
+ }
2599
+ .tunnel-popover-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
2600
+ .tunnel-popover-head h3 { margin: 0; font-size: 14px; }
2601
+ .tunnel-popover-close {
2602
+ background: none; border: none; color: var(--text-muted); font-size: 18px;
2603
+ line-height: 1; cursor: pointer; padding: 2px 6px; border-radius: 6px;
2604
+ }
2605
+ .tunnel-popover-close:hover { background: var(--surface-2); color: var(--text); }
2606
+ .tunnel-popover-card .tunnel-state { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
2607
+ .tunnel-popover-card .tunnel-token-input { width: 100%; }
2608
+ .tunnel-popover-card .tunnel-note { margin-left: 0; }
2609
+ .tunnel-popover-card .tunnel-on { word-break: break-all; }
2561
2610
  .tunnel-note { margin-left: 10px; color: var(--text-muted); font-size: 12px; }
2562
2611
  .tunnel-err { color: var(--danger); font-size: 12.5px; margin-top: 8px; }