@teamclaws/teamclaw 2026.7.1 → 2026.8.0
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 +8 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +9 -7
- package/src/controller/http-server.ts +26 -1
- package/src/controller/tunnel-manager.ts +139 -15
- package/src/ui/app.js +97 -20
- package/src/ui/index.html +16 -4
- package/src/ui/style.css +49 -0
package/README.md
CHANGED
|
@@ -118,6 +118,14 @@ For a first-time setup, the safest path is:
|
|
|
118
118
|
|
|
119
119
|
When on-demand provisioning is enabled, TeamClaw now treats controller startup as a readiness phase, not just a process-up check. During that warm-up, `/api/v1/health` returns a non-OK status until the controller has verified writable runtime paths and successfully brought the configured startup worker roles online. If `workerProvisioningRoles` is empty, startup readiness defaults to waiting for a warm `developer` worker.
|
|
120
120
|
|
|
121
|
+
## Internet tunnel sharing
|
|
122
|
+
|
|
123
|
+
The Web UI ships with zero-config internet sharing (header `Tunnel` button):
|
|
124
|
+
managed `*.teamclaw.dev` (GitHub login, gate token), self-hosted Cloudflare
|
|
125
|
+
tunnels via connector token (`TEAMCLAW_TUNNEL_TOKEN` env or UI input), and
|
|
126
|
+
anonymous one-off tunnels (`*.trycloudflare.com` via cloudflared). See
|
|
127
|
+
the repo README's "Internet tunnel" section for the full matrix.
|
|
128
|
+
|
|
121
129
|
## Documentation
|
|
122
130
|
|
|
123
131
|
- Website: <https://topcheer.github.io/teamclaw/>
|
package/openclaw.plugin.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "teamclaw",
|
|
3
3
|
"name": "TeamClaw",
|
|
4
4
|
"description": "Virtual team collaboration - multiple OpenClaw instances form a virtual software company with role-based task routing.",
|
|
5
|
-
"version": "2026.
|
|
5
|
+
"version": "2026.8.0",
|
|
6
6
|
"activation": {
|
|
7
7
|
"onStartup": true
|
|
8
8
|
},
|
package/package.json
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamclaws/teamclaw",
|
|
3
|
-
"version": "2026.
|
|
4
|
-
"description": "OpenClaw virtual software team orchestration plugin",
|
|
3
|
+
"version": "2026.8.0",
|
|
4
|
+
"description": "OpenClaw virtual software team orchestration plugin - controller, role-based workers, Web UI with internet tunnel sharing",
|
|
5
5
|
"private": false,
|
|
6
6
|
"keywords": [
|
|
7
|
-
"
|
|
8
|
-
"plugin",
|
|
9
|
-
"teamclaw",
|
|
7
|
+
"cloudflared",
|
|
10
8
|
"multi-agent",
|
|
9
|
+
"multi-role",
|
|
10
|
+
"openclaw",
|
|
11
11
|
"orchestration",
|
|
12
|
-
"
|
|
12
|
+
"plugin",
|
|
13
13
|
"sdlc",
|
|
14
|
-
"
|
|
14
|
+
"teamclaw",
|
|
15
|
+
"tunnel",
|
|
16
|
+
"virtual-team"
|
|
15
17
|
],
|
|
16
18
|
"author": "Junjun Zhang <topcheer@me.com>",
|
|
17
19
|
"homepage": "https://github.com/topcheer/teamclaw/tree/main/src#readme",
|
|
@@ -54,7 +54,7 @@ import type { WorkerProvisioningManager } from "./worker-provisioning.js";
|
|
|
54
54
|
import type { PreviewManager } from "./preview-manager.js";
|
|
55
55
|
import { createControllerPromptInjector } from "./prompt-injector.js";
|
|
56
56
|
import { getGithubAuthManager } from "./github-auth.js";
|
|
57
|
-
import { createTunnelManager, gatePageHtml, computeGateCookie, GATE_COOKIE_NAME, type TunnelManager } from "./tunnel-manager.js";
|
|
57
|
+
import { createTunnelManager, gatePageHtml, computeGateCookie, GATE_COOKIE_NAME, selfHostedTokenFromEnv, type TunnelManager } from "./tunnel-manager.js";
|
|
58
58
|
import { createGithubClient } from "../teamauto/github-client.js";
|
|
59
59
|
import type { TeamAutoScheduler } from "../teamauto/scheduler.js";
|
|
60
60
|
import { buildControllerNoWorkersMessage, shouldBlockControllerWithoutWorkers } from "./controller-capacity.js";
|
|
@@ -4786,6 +4786,31 @@ export function createControllerHttpServer(deps: ControllerHttpDeps): http.Serve
|
|
|
4786
4786
|
sendJson(res, 202, { launched, status: tunnelManager.status() });
|
|
4787
4787
|
return;
|
|
4788
4788
|
}
|
|
4789
|
+
// Self-hosted: user-owned Cloudflare tunnel via connector token (no
|
|
4790
|
+
// GitHub login, no platform tunnel server). Token from the request
|
|
4791
|
+
// body, or the TEAMCLAW_TUNNEL_TOKEN env injection when body is empty.
|
|
4792
|
+
if (req.method === "POST" && pathname === "/api/v1/tunnel/start-self-hosted") {
|
|
4793
|
+
let token = "";
|
|
4794
|
+
try {
|
|
4795
|
+
const body = await readFormBody(req) as { token?: unknown };
|
|
4796
|
+
token = String(body.token ?? "");
|
|
4797
|
+
} catch { /* fall through to env */ }
|
|
4798
|
+
if (!token.trim()) {
|
|
4799
|
+
const envToken = selfHostedTokenFromEnv();
|
|
4800
|
+
if (!envToken) { sendError(res, 400, "connector token required (or set TEAMCLAW_TUNNEL_TOKEN)"); return; }
|
|
4801
|
+
token = envToken;
|
|
4802
|
+
}
|
|
4803
|
+
const r = tunnelManager.startSelfHosted(token);
|
|
4804
|
+
if (!r.launched) { sendError(res, 400, r.error ?? "failed to start self-hosted tunnel"); return; }
|
|
4805
|
+
sendJson(res, 202, { launched: true, status: tunnelManager.status() });
|
|
4806
|
+
return;
|
|
4807
|
+
}
|
|
4808
|
+
if (req.method === "POST" && pathname === "/api/v1/tunnel/start-quick") {
|
|
4809
|
+
const r = tunnelManager.startQuick();
|
|
4810
|
+
if (!r.launched) { sendError(res, 400, r.error ?? "failed to start quick tunnel"); return; }
|
|
4811
|
+
sendJson(res, 202, { launched: true, status: tunnelManager.status() });
|
|
4812
|
+
return;
|
|
4813
|
+
}
|
|
4789
4814
|
if (req.method === "POST" && pathname === "/api/v1/tunnel/stop") {
|
|
4790
4815
|
await tunnelManager.stop();
|
|
4791
4816
|
sendJson(res, 200, tunnelManager.status());
|
|
@@ -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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
310
|
-
hostname: handle?.hostname
|
|
311
|
-
gateToken: handle?.gateToken
|
|
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-
|
|
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
|
|
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 = '<
|
|
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
|
-
|
|
4188
|
-
|
|
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
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
+ '<
|
|
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 & 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
|
|
4203
|
-
|
|
4204
|
-
|
|
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; }
|