@teamclaws/teamclaw 2026.11.0 → 2026.11.2
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/cli.mjs +368 -13
- package/dist/index.js +61 -32
- package/dist/src/config.js +24 -0
- package/dist/src/controller/auth-routes.js +129 -0
- package/dist/src/controller/clarification-routes.js +1 -1
- package/dist/src/controller/config-routes.js +138 -0
- package/dist/src/controller/controller-planning.js +1 -0
- package/dist/src/controller/controller-routes.js +195 -0
- package/dist/src/controller/controller-service.js +67 -10
- package/dist/src/controller/controller-tools.js +3 -1
- package/dist/src/controller/github-auth.js +2 -1
- package/dist/src/controller/http-server.js +51 -16
- package/dist/src/controller/kickoff-orchestrator.js +3 -39
- package/dist/src/controller/message-delivery.js +4 -1
- package/dist/src/controller/orchestration-manifest.js +5 -65
- package/dist/src/controller/preview-manager.js +51 -3
- package/dist/src/controller/profile-switch.js +42 -22
- package/dist/src/controller/provisioning/backend-contract.js +9 -0
- package/dist/src/controller/provisioning/container-shared.js +64 -0
- package/dist/src/controller/provisioning/docker.js +214 -0
- package/dist/src/controller/provisioning/kubernetes.js +244 -0
- package/dist/src/controller/provisioning/plugin-root.js +41 -0
- package/dist/src/controller/provisioning/process-supervisor.js +190 -0
- package/dist/src/controller/provisioning-config.js +239 -0
- package/dist/src/controller/repo-routes.js +70 -4
- package/dist/src/controller/report-routes.js +56 -0
- package/dist/src/controller/route-table.js +73 -1045
- package/dist/src/controller/security.js +775 -0
- package/dist/src/controller/status-routes.js +287 -0
- package/dist/src/controller/task-assignment.js +5 -2
- package/dist/src/controller/task-execution.js +31 -0
- package/dist/src/controller/task-results.js +10 -0
- package/dist/src/controller/tunnel-manager.js +41 -8
- package/dist/src/controller/tunnel-routes.js +225 -0
- package/dist/src/controller/websocket.js +6 -2
- package/dist/src/controller/webui-routes.js +49 -0
- package/dist/src/controller/worker-provisioning.js +39 -949
- package/dist/src/controller/workflow-routes.js +407 -0
- package/dist/src/controller/workspace-routes.js +200 -0
- package/dist/src/git-collaboration.js +4 -9
- package/dist/src/identity.js +12 -1
- package/dist/src/openclaw-workspace.js +36 -0
- package/dist/src/profile-loader.js +119 -1
- package/dist/src/profiles/banking.json +26 -2
- package/dist/src/profiles/schema.json +82 -2
- package/dist/src/prompt-policy.js +18 -6
- package/dist/src/protocol.js +66 -3
- package/dist/src/shared/clarification-schema.js +65 -0
- package/dist/src/shared/github-auth.js +15 -0
- package/dist/src/shared/kickoff-prompt.js +37 -0
- package/dist/src/shared/utils.js +47 -0
- package/dist/src/state.js +89 -3
- package/dist/src/teamauto/scanner.js +21 -2
- package/dist/src/teamauto/scheduler.js +9 -2
- package/dist/src/types.js +15 -1
- package/dist/src/ui/app.js +990 -73
- package/dist/src/ui/github-login.html +1 -0
- package/dist/src/ui/index.html +125 -36
- package/dist/src/worker/http-handler.js +59 -0
- package/dist/src/worker/skill-installer.js +3 -9
- package/dist/src/worker/tools.js +20 -10
- package/dist/src/worker/worker-service.js +17 -4
- package/index.ts +69 -32
- package/openclaw.plugin.json +23 -2
- package/package.json +1 -1
- package/src/config.ts +24 -0
- package/src/controller/auth-routes.ts +157 -0
- package/src/controller/clarification-routes.ts +1 -1
- package/src/controller/config-routes.ts +152 -0
- package/src/controller/controller-planning.ts +8 -0
- package/src/controller/controller-routes.ts +237 -0
- package/src/controller/controller-service.ts +128 -10
- package/src/controller/controller-tools.ts +5 -2
- package/src/controller/github-auth.ts +28 -63
- package/src/controller/http-server.ts +66 -17
- package/src/controller/kickoff-orchestrator.ts +3 -42
- package/src/controller/message-delivery.ts +4 -1
- package/src/controller/orchestration-manifest.ts +8 -71
- package/src/controller/preview-manager.ts +53 -3
- package/src/controller/profile-switch.ts +53 -23
- package/src/controller/provisioning/backend-contract.ts +51 -0
- package/src/controller/provisioning/container-shared.ts +84 -0
- package/src/controller/provisioning/docker.ts +260 -0
- package/src/controller/provisioning/kubernetes.ts +263 -0
- package/src/controller/provisioning/plugin-root.ts +42 -0
- package/src/controller/provisioning/process-supervisor.ts +214 -0
- package/src/controller/provisioning-config.ts +289 -0
- package/src/controller/repo-routes.ts +84 -12
- package/src/controller/report-routes.ts +64 -0
- package/src/controller/route-table.ts +139 -1152
- package/src/controller/security.ts +899 -0
- package/src/controller/status-routes.ts +354 -0
- package/src/controller/task-assignment.ts +5 -1
- package/src/controller/task-execution.ts +43 -0
- package/src/controller/task-results.ts +12 -0
- package/src/controller/tunnel-manager.ts +45 -8
- package/src/controller/tunnel-routes.ts +231 -0
- package/src/controller/websocket.ts +20 -3
- package/src/controller/webui-routes.ts +55 -0
- package/src/controller/worker-provisioning.ts +51 -1117
- package/src/controller/workflow-routes.ts +498 -0
- package/src/controller/workspace-routes.ts +222 -0
- package/src/git-collaboration.ts +4 -9
- package/src/identity.ts +13 -1
- package/src/openclaw-workspace.ts +47 -0
- package/src/profile-loader.ts +167 -1
- package/src/profiles/banking.json +26 -2
- package/src/profiles/schema.json +82 -2
- package/src/prompt-policy.ts +19 -6
- package/src/protocol.ts +72 -2
- package/src/shared/clarification-schema.ts +81 -0
- package/src/shared/github-auth.ts +92 -0
- package/src/shared/kickoff-prompt.ts +47 -0
- package/src/shared/utils.ts +51 -0
- package/src/state.ts +92 -3
- package/src/teamauto/github-client.ts +2 -1
- package/src/teamauto/repo-sync.ts +2 -1
- package/src/teamauto/scanner.ts +22 -3
- package/src/teamauto/scheduler.ts +11 -3
- package/src/teamauto/store.ts +5 -0
- package/src/types.ts +130 -1
- package/src/ui/app.js +990 -73
- package/src/ui/github-login.html +1 -0
- package/src/ui/index.html +125 -36
- package/src/worker/http-handler.ts +64 -1
- package/src/worker/skill-installer.ts +3 -9
- package/src/worker/tools.ts +21 -10
- package/src/worker/worker-service.ts +18 -4
package/src/ui/app.js
CHANGED
|
@@ -40,6 +40,14 @@
|
|
|
40
40
|
let pendingSwitchTarget = null;
|
|
41
41
|
let pendingSwitchProfileId = "";
|
|
42
42
|
let teamProfileSwitchInFlight = false;
|
|
43
|
+
// Device pairing security (issue #23, client wave): the `security` object
|
|
44
|
+
// from GET /team/status (protection/suggested/deviceCount) plus pairing
|
|
45
|
+
// modal bookkeeping. The suggestion banner renders only while protection
|
|
46
|
+
// is off AND a non-LAN peer was observed; enable is loopback-only server
|
|
47
|
+
// side, so a remote browser never gets an actionable enable path.
|
|
48
|
+
let securityStatus = null;
|
|
49
|
+
let securityPairingExpiresAt = 0;
|
|
50
|
+
let securityPairTimer = null;
|
|
43
51
|
let clarificationPromptOpen = false;
|
|
44
52
|
let activeClarificationId = null;
|
|
45
53
|
let dismissedClarificationIds = [];
|
|
@@ -62,11 +70,21 @@
|
|
|
62
70
|
"action.dismiss": "Dismiss",
|
|
63
71
|
"action.copyCommand": "Copy command",
|
|
64
72
|
"action.copied": "Copied",
|
|
73
|
+
"action.copyToken": "Copy token",
|
|
65
74
|
"sidebar.workers": "Workers",
|
|
66
75
|
"sidebar.roles": "Roles",
|
|
67
76
|
"tab.planning": "Planning",
|
|
68
77
|
"tab.tasks": "Tasks",
|
|
69
78
|
"tab.workspace": "Workspace",
|
|
79
|
+
"common.showOlder": "Show older ({n})",
|
|
80
|
+
"tab.settings": "Settings",
|
|
81
|
+
"settings.models.title": "Model settings",
|
|
82
|
+
"settings.models.hint": "Default model and per-role overrides.",
|
|
83
|
+
"settings.workers.title": "Worker scaling (hot)",
|
|
84
|
+
"settings.workers.hint": "Applies immediately without restarting the gateway. Lowering a cap never kills busy workers.",
|
|
85
|
+
"settings.workers.max": "Max workers / role",
|
|
86
|
+
"settings.workers.min": "Min warm / role",
|
|
87
|
+
"settings.workers.ttl": "Idle TTL (ms)",
|
|
70
88
|
"tab.teamauto": "TeamAuto",
|
|
71
89
|
"tab.clarifications": "Clarifications",
|
|
72
90
|
"tab.messages": "Messages",
|
|
@@ -151,7 +169,6 @@
|
|
|
151
169
|
"runtime.title": "TeamClaw is installed but cannot work yet.",
|
|
152
170
|
"runtime.noModel": "No TeamClaw model is configured for this instance.",
|
|
153
171
|
"runtime.noAuth": "No usable OpenClaw auth profile was found for TeamClaw.",
|
|
154
|
-
"gh.login": "Sign in with GitHub",
|
|
155
172
|
"teamauto.refreshRepos": "Refresh repos",
|
|
156
173
|
"teamauto.bind": "Bind",
|
|
157
174
|
"teamauto.bindStageVerify": "Verifying access",
|
|
@@ -234,7 +251,113 @@
|
|
|
234
251
|
"teamProfile.switchFailed": "Team profile switch to {name} failed",
|
|
235
252
|
"teamProfile.archivedTitle": "Archived teams",
|
|
236
253
|
"teamProfile.archivedEmpty": "No archived teams yet.",
|
|
237
|
-
"teamProfile.archivedTasks": "{n} tasks"
|
|
254
|
+
"teamProfile.archivedTasks": "{n} tasks",
|
|
255
|
+
"security.bannerTitle": "Device protection recommended",
|
|
256
|
+
"security.bannerHint": "External access was detected from outside your local network. Enable device pairing so only your paired devices can control this team.",
|
|
257
|
+
"security.enableAction": "Enable protection",
|
|
258
|
+
"security.pairTitle": "Pair your devices",
|
|
259
|
+
"security.pairHint": "This browser is paired automatically. To pair another device (worker, desktop or CLI), run this command within 60 seconds:",
|
|
260
|
+
"security.pairExpiresIn": "Expires in {n}s",
|
|
261
|
+
"security.pairExpired": "Pairing code expired - request a new one.",
|
|
262
|
+
"security.pairNewCode": "New pairing code",
|
|
263
|
+
"security.devicesTitle": "Device security",
|
|
264
|
+
"security.statusOn": "Protection enabled · {n} paired device(s)",
|
|
265
|
+
"security.statusOff": "Local mode · protection off",
|
|
266
|
+
"security.revoke": "Revoke",
|
|
267
|
+
"security.selfRevokeWarn": "Revoking this browser will sign it out; it must re-pair from the controller host.",
|
|
268
|
+
"security.selfRevoked": "This device was revoked. Re-pair it from the controller host.",
|
|
269
|
+
"security.resetAll": "Reset all devices",
|
|
270
|
+
"security.resetConfirm": "This revokes every paired device and returns the controller to unpaired local mode. Continue?",
|
|
271
|
+
"security.resetDone": "Device protection reset - the controller is back to local mode.",
|
|
272
|
+
"security.devicesUnavailable": "Device management needs a paired browser.",
|
|
273
|
+
"security.noDevices": "No paired devices yet.",
|
|
274
|
+
"workflow.sectionTitle": "Common workflows",
|
|
275
|
+
"workflow.stepsTooltip": "{n} steps · {roles}",
|
|
276
|
+
"workflow.started": "Workflow {name} started",
|
|
277
|
+
"workflow.startFailed": "Failed to start workflow - {reason}",
|
|
278
|
+
"workflow.badgeRound": "Round {n}",
|
|
279
|
+
"roleDisplay.title": "Role display",
|
|
280
|
+
"roleDisplay.hint": "Hide roles this team does not use, or rename them for your team. Saved in this browser only (display layer) - the team profile itself is not modified. The Team models panel always lists every role because model overrides live server-side, so hiding a role here does not remove it there.",
|
|
281
|
+
"roleDisplay.save": "Save",
|
|
282
|
+
"roleDisplay.reset": "Reset to defaults",
|
|
283
|
+
"roleDisplay.saved": "Role display settings saved",
|
|
284
|
+
"roleDisplay.resetDone": "Role display reset to the profile defaults",
|
|
285
|
+
// chore-web-i18n-migration: keys for previously hardcoded copy. ctl.*
|
|
286
|
+
// values are copied VERBATIM from desktop/renderer/i18n.js so both
|
|
287
|
+
// renderers resolve shared keys to identical strings (enforced by
|
|
288
|
+
// tests/test-i18n-parity.mjs); the rest are web-only surfaces.
|
|
289
|
+
"action.cancel": "Cancel",
|
|
290
|
+
"task.details": "Task details",
|
|
291
|
+
"task.timeline": "Timeline",
|
|
292
|
+
"task.messages": "Messages",
|
|
293
|
+
"command.placeholder": "Send a controller message or slash command... (e.g., 继续工作, /status, /assign task-id developer)",
|
|
294
|
+
"command.send": "Send to Controller",
|
|
295
|
+
"detail.taskId": "Task ID: {id}",
|
|
296
|
+
"detail.worker": "Worker: {id}",
|
|
297
|
+
"detail.role": "Role: {id}",
|
|
298
|
+
"header.toasts": "Toasts",
|
|
299
|
+
"header.tunnelLiveTitle": "Managed tunnel is live - open in a new tab",
|
|
300
|
+
"header.githubUserTitle": "GitHub: click to sign out",
|
|
301
|
+
"header.teamFallback": "Team",
|
|
302
|
+
"workspace.location": "Location",
|
|
303
|
+
"clarification.needAnswer": "Please provide an answer before submitting.",
|
|
304
|
+
"models.kicker": "Model settings",
|
|
305
|
+
"models.providerDefault": "(provider default)",
|
|
306
|
+
"models.current": "(current)",
|
|
307
|
+
"models.loadFailed": "Failed to load model catalog",
|
|
308
|
+
"ws.kicker": "Workspace setup",
|
|
309
|
+
"ws.browse": "Browse...",
|
|
310
|
+
"ws.keepDefault": "Keep default",
|
|
311
|
+
"ws.restartNote": "Applies after a gateway restart. Existing files are not moved automatically.",
|
|
312
|
+
"ws.unknown": "(unknown)",
|
|
313
|
+
"ws.pickerNoPath": "Browser directory picker cannot return full server paths; please type the absolute path instead.",
|
|
314
|
+
"ws.pickerUnsupported": "This browser does not support a native directory picker; please type the absolute path instead.",
|
|
315
|
+
"ws.needAbsolute": "Please enter an absolute path starting with /",
|
|
316
|
+
"tunnel.visitorNote": "This dashboard is shared via a TeamClaw tunnel.",
|
|
317
|
+
"tunnel.quick": "Quick tunnel",
|
|
318
|
+
"tunnel.waitingUrl": "waiting for URL…",
|
|
319
|
+
"tunnel.quickNote": "One-off URL - dies on restart. Anyone with the link can open the dashboard.",
|
|
320
|
+
"tunnel.selfHostedLive": "Self-hosted Cloudflare tunnel: live on your own domain",
|
|
321
|
+
"tunnel.selfHostedNote": "Public hostname is managed in your Cloudflare Zero Trust dashboard.",
|
|
322
|
+
"tunnel.envTokenReady": "Connector token detected via TEAMCLAW_TUNNEL_TOKEN — ready to start.",
|
|
323
|
+
"tunnel.startSelf": "Start self-hosted tunnel",
|
|
324
|
+
"tunnel.selfHostedLabel": "Self-hosted tunnel (your own Cloudflare account/domain):",
|
|
325
|
+
"tunnel.tokenPlaceholder": "Cloudflare connector token",
|
|
326
|
+
"tunnel.setupHelp": "How to get a token & set up the tunnel",
|
|
327
|
+
"tunnel.setupHelpBody": "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.",
|
|
328
|
+
"tunnel.or": "— or —",
|
|
329
|
+
"tunnel.requiresGithub": "requires GitHub login",
|
|
330
|
+
"tunnel.startQuick": "Anonymous one-off tunnel (trycloudflare.com)",
|
|
331
|
+
"tunnel.quickDemoNote": "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.",
|
|
332
|
+
"tunnel.needToken": "Paste a Cloudflare connector token first.",
|
|
333
|
+
"ctl.tab.models": "Models",
|
|
334
|
+
"ctl.tab.tunnel": "Tunnel",
|
|
335
|
+
"ctl.models.title": "Team models",
|
|
336
|
+
"ctl.models.hint": "Default model applies to the controller and every role; per-role selections override it for that role.",
|
|
337
|
+
"ctl.models.default": "Default model",
|
|
338
|
+
"ctl.models.useDefault": "(use default)",
|
|
339
|
+
"ctl.models.save": "Save models",
|
|
340
|
+
"ctl.models.saved": "Saved. Hot-reload applies; restart the gateway if needed.",
|
|
341
|
+
"ctl.models.failed": "Failed to save model settings",
|
|
342
|
+
"ctl.tunnel.title": "Internet tunnel",
|
|
343
|
+
"ctl.tunnel.share": "Share via tunnel",
|
|
344
|
+
"ctl.tunnel.stop": "Stop sharing",
|
|
345
|
+
"ctl.tunnel.install": "Install cloudflared",
|
|
346
|
+
"ctl.tunnel.loading": "Loading…",
|
|
347
|
+
"ctl.tunnel.starting": "Starting tunnel",
|
|
348
|
+
"ctl.tunnel.installing": "Installing cloudflared",
|
|
349
|
+
"ctl.tunnel.live": "Live",
|
|
350
|
+
"ctl.tunnel.gateToken": "Gate token",
|
|
351
|
+
"ctl.tunnel.notInstalled": "cloudflared connector is not installed on the controller machine.",
|
|
352
|
+
"ctl.tunnel.actionFailed": "Tunnel action failed: ",
|
|
353
|
+
"ctl.ws.title": "Workspace directory",
|
|
354
|
+
"ctl.ws.current": "Current:",
|
|
355
|
+
"ctl.ws.default": "default",
|
|
356
|
+
"ctl.ws.hint": "Point the team workspace at any absolute path on the controller machine. Applies after a gateway restart.",
|
|
357
|
+
"ctl.ws.apply": "Apply workspace",
|
|
358
|
+
"ctl.ws.saved": "Updated. Restart the gateway (openclaw gateway restart) to apply.",
|
|
359
|
+
"ctl.ws.failed": "Failed to update workspace",
|
|
360
|
+
"ctl.gh.login": "Sign in with GitHub"
|
|
238
361
|
},
|
|
239
362
|
zh: {
|
|
240
363
|
"action.refresh": "刷新",
|
|
@@ -242,11 +365,21 @@
|
|
|
242
365
|
"action.dismiss": "稍后处理",
|
|
243
366
|
"action.copyCommand": "复制命令",
|
|
244
367
|
"action.copied": "已复制",
|
|
368
|
+
"action.copyToken": "复制令牌",
|
|
245
369
|
"sidebar.workers": "成员",
|
|
246
370
|
"sidebar.roles": "角色",
|
|
247
371
|
"tab.planning": "规划",
|
|
248
372
|
"tab.tasks": "任务",
|
|
249
373
|
"tab.workspace": "工作区",
|
|
374
|
+
"common.showOlder": "显示更早({n})",
|
|
375
|
+
"tab.settings": "设置",
|
|
376
|
+
"settings.models.title": "模型设置",
|
|
377
|
+
"settings.models.hint": "默认模型与按角色覆盖。",
|
|
378
|
+
"settings.workers.title": "Worker 弹性伸缩(热)",
|
|
379
|
+
"settings.workers.hint": "立即生效无需重启 gateway。下调上限不会终止忙碌 worker。",
|
|
380
|
+
"settings.workers.max": "每角色最大 worker",
|
|
381
|
+
"settings.workers.min": "每角色保活下限",
|
|
382
|
+
"settings.workers.ttl": "空闲回收 TTL(毫秒)",
|
|
250
383
|
"tab.teamauto": "TeamAuto",
|
|
251
384
|
"tab.clarifications": "澄清",
|
|
252
385
|
"tab.messages": "消息",
|
|
@@ -331,7 +464,6 @@
|
|
|
331
464
|
"runtime.title": "TeamClaw 已安装,但当前还无法工作。",
|
|
332
465
|
"runtime.noModel": "当前实例还没有为 TeamClaw 配置模型。",
|
|
333
466
|
"runtime.noAuth": "未找到 TeamClaw 可用的 OpenClaw 认证配置。",
|
|
334
|
-
"gh.login": "使用 GitHub 登录",
|
|
335
467
|
"teamauto.refreshRepos": "刷新仓库",
|
|
336
468
|
"teamauto.bind": "绑定",
|
|
337
469
|
"teamauto.bindStageVerify": "验证访问权限",
|
|
@@ -414,7 +546,111 @@
|
|
|
414
546
|
"teamProfile.switchFailed": "切换到 {name} 的团队画像失败",
|
|
415
547
|
"teamProfile.archivedTitle": "已归档团队",
|
|
416
548
|
"teamProfile.archivedEmpty": "暂无已归档团队。",
|
|
417
|
-
"teamProfile.archivedTasks": "{n} 个任务"
|
|
549
|
+
"teamProfile.archivedTasks": "{n} 个任务",
|
|
550
|
+
"security.bannerTitle": "建议启用设备保护",
|
|
551
|
+
"security.bannerHint": "检测到来自局域网之外的外部访问。启用设备配对后,只有已配对的设备才能操作这个团队。",
|
|
552
|
+
"security.enableAction": "启用保护",
|
|
553
|
+
"security.pairTitle": "配对设备",
|
|
554
|
+
"security.pairHint": "本浏览器已自动配对。要在其他设备(worker、桌面端或 CLI)上配对,请在 60 秒内运行以下命令:",
|
|
555
|
+
"security.pairExpiresIn": "{n} 秒后失效",
|
|
556
|
+
"security.pairExpired": "配对码已过期 - 请生成新的配对码。",
|
|
557
|
+
"security.pairNewCode": "添加配对码",
|
|
558
|
+
"security.devicesTitle": "设备安全",
|
|
559
|
+
"security.statusOn": "保护已启用 · {n} 台设备",
|
|
560
|
+
"security.statusOff": "本机模式 · 未启用",
|
|
561
|
+
"security.revoke": "撤销",
|
|
562
|
+
"security.selfRevokeWarn": "撤销本浏览器会使它退出配对,需在 controller 主机上重新配对。",
|
|
563
|
+
"security.selfRevoked": "本设备已被撤销。请在 controller 主机上重新配对。",
|
|
564
|
+
"security.resetAll": "重置全部设备",
|
|
565
|
+
"security.resetConfirm": "这将撤销所有已配对设备,并让 controller 回到未保护的本机模式。继续?",
|
|
566
|
+
"security.resetDone": "设备保护已重置 - controller 已回到本机模式。",
|
|
567
|
+
"security.devicesUnavailable": "需要在已配对的浏览器中管理设备。",
|
|
568
|
+
"security.noDevices": "暂无已配对设备。",
|
|
569
|
+
"workflow.sectionTitle": "常用工作流",
|
|
570
|
+
"workflow.stepsTooltip": "{n} 步 · {roles}",
|
|
571
|
+
"workflow.started": "工作流「{name}」已启动",
|
|
572
|
+
"workflow.startFailed": "启动工作流失败 - {reason}",
|
|
573
|
+
"workflow.badgeRound": "第{n}轮",
|
|
574
|
+
"roleDisplay.title": "角色显示",
|
|
575
|
+
"roleDisplay.hint": "隐藏本团队用不到的角色,或改成本团队的叫法。仅保存在此浏览器(纯显示层)——不修改团队画像本身。“团队模型”面板始终列出全部角色(模型覆盖保存在服务端),此处隐藏不会将其移除。",
|
|
576
|
+
"roleDisplay.save": "保存",
|
|
577
|
+
"roleDisplay.reset": "恢复默认",
|
|
578
|
+
"roleDisplay.saved": "角色显示设置已保存",
|
|
579
|
+
"roleDisplay.resetDone": "角色显示已恢复画像默认",
|
|
580
|
+
// chore-web-i18n-migration: ctl.* 值从 desktop/renderer/i18n.js 原样
|
|
581
|
+
// 复制,双端共享键必须逐字一致(tests/test-i18n-parity.mjs 强制)。
|
|
582
|
+
"action.cancel": "取消",
|
|
583
|
+
"task.details": "任务详情",
|
|
584
|
+
"task.timeline": "时间线",
|
|
585
|
+
"task.messages": "消息",
|
|
586
|
+
"command.placeholder": "发送 controller 消息或斜杠命令...(例如:继续工作、/status、/assign task-id developer)",
|
|
587
|
+
"command.send": "发送给 Controller",
|
|
588
|
+
"detail.taskId": "任务 ID:{id}",
|
|
589
|
+
"detail.worker": "Worker:{id}",
|
|
590
|
+
"detail.role": "角色:{id}",
|
|
591
|
+
"header.toasts": "通知",
|
|
592
|
+
"header.tunnelLiveTitle": "托管隧道已开启 - 在新标签页打开",
|
|
593
|
+
"header.githubUserTitle": "GitHub:点击退出登录",
|
|
594
|
+
"header.teamFallback": "团队",
|
|
595
|
+
"workspace.location": "位置",
|
|
596
|
+
"clarification.needAnswer": "提交前请先填写回答。",
|
|
597
|
+
"models.kicker": "模型设置",
|
|
598
|
+
"models.providerDefault": "(提供商默认)",
|
|
599
|
+
"models.current": "(当前)",
|
|
600
|
+
"models.loadFailed": "加载模型目录失败",
|
|
601
|
+
"ws.kicker": "工作区设置",
|
|
602
|
+
"ws.browse": "浏览...",
|
|
603
|
+
"ws.keepDefault": "保留默认",
|
|
604
|
+
"ws.restartNote": "重启网关后生效。已有文件不会自动移动。",
|
|
605
|
+
"ws.unknown": "(未知)",
|
|
606
|
+
"ws.pickerNoPath": "浏览器目录选择器无法返回服务器端完整路径;请直接输入绝对路径。",
|
|
607
|
+
"ws.pickerUnsupported": "此浏览器不支持原生目录选择器;请直接输入绝对路径。",
|
|
608
|
+
"ws.needAbsolute": "请输入以 / 开头的绝对路径",
|
|
609
|
+
"tunnel.visitorNote": "本仪表盘通过 TeamClaw 隧道分享。",
|
|
610
|
+
"tunnel.quick": "快速隧道",
|
|
611
|
+
"tunnel.waitingUrl": "等待 URL 中…",
|
|
612
|
+
"tunnel.quickNote": "一次性 URL,重启即失效。任何拿到链接的人都能打开仪表盘。",
|
|
613
|
+
"tunnel.selfHostedLive": "自托管 Cloudflare 隧道:已在自己的域名上运行",
|
|
614
|
+
"tunnel.selfHostedNote": "公共域名在你的 Cloudflare Zero Trust 控制台中管理。",
|
|
615
|
+
"tunnel.envTokenReady": "检测到 TEAMCLAW_TUNNEL_TOKEN 连接器令牌——可随时启动。",
|
|
616
|
+
"tunnel.startSelf": "启动自托管隧道",
|
|
617
|
+
"tunnel.selfHostedLabel": "自托管隧道(你自己的 Cloudflare 账号/域名):",
|
|
618
|
+
"tunnel.tokenPlaceholder": "Cloudflare 连接器令牌",
|
|
619
|
+
"tunnel.setupHelp": "如何获取令牌并配置隧道",
|
|
620
|
+
"tunnel.setupHelpBody": "Cloudflare Zero Trust → 网络(Networks)→ Tunnels → 你的隧道 → 复制令牌。将其公共域名指向本机 URL(Service:HTTP + 文档中所示的控制器端口)。建议用 Cloudflare Access 保护——自托管域名不走 TeamClaw 门禁。",
|
|
621
|
+
"tunnel.or": "— 或 —",
|
|
622
|
+
"tunnel.requiresGithub": "需要 GitHub 登录",
|
|
623
|
+
"tunnel.startQuick": "匿名一次性隧道(trycloudflare.com)",
|
|
624
|
+
"tunnel.quickDemoNote": "无需账号。随机 URL,重启即失效,任何拿到链接的人都能打开仪表盘——仅用于快速演示。需要 cloudflared 二进制。",
|
|
625
|
+
"tunnel.needToken": "请先粘贴 Cloudflare 连接器令牌。",
|
|
626
|
+
"ctl.tab.models": "模型",
|
|
627
|
+
"ctl.tab.tunnel": "隧道",
|
|
628
|
+
"ctl.models.title": "团队模型",
|
|
629
|
+
"ctl.models.hint": "默认模型作用于控制器与所有角色;按角色的选择会覆盖默认值。",
|
|
630
|
+
"ctl.models.default": "默认模型",
|
|
631
|
+
"ctl.models.useDefault": "(跟随默认)",
|
|
632
|
+
"ctl.models.save": "保存模型",
|
|
633
|
+
"ctl.models.saved": "已保存。配置热重载生效;如未生效请重启网关。",
|
|
634
|
+
"ctl.models.failed": "保存模型设置失败",
|
|
635
|
+
"ctl.tunnel.title": "互联网隧道",
|
|
636
|
+
"ctl.tunnel.share": "通过隧道分享",
|
|
637
|
+
"ctl.tunnel.stop": "停止分享",
|
|
638
|
+
"ctl.tunnel.install": "安装 cloudflared",
|
|
639
|
+
"ctl.tunnel.loading": "加载中…",
|
|
640
|
+
"ctl.tunnel.starting": "正在启动隧道",
|
|
641
|
+
"ctl.tunnel.installing": "正在安装 cloudflared",
|
|
642
|
+
"ctl.tunnel.live": "在线",
|
|
643
|
+
"ctl.tunnel.gateToken": "门禁令牌",
|
|
644
|
+
"ctl.tunnel.notInstalled": "控制器机器上尚未安装 cloudflared 连接器。",
|
|
645
|
+
"ctl.tunnel.actionFailed": "隧道操作失败:",
|
|
646
|
+
"ctl.ws.title": "工作区目录",
|
|
647
|
+
"ctl.ws.current": "当前:",
|
|
648
|
+
"ctl.ws.default": "默认",
|
|
649
|
+
"ctl.ws.hint": "可将团队工作区指向控制器机器上的任意绝对路径。需重启网关后生效。",
|
|
650
|
+
"ctl.ws.apply": "应用工作区",
|
|
651
|
+
"ctl.ws.saved": "已更新。请重启网关(openclaw gateway restart)后生效。",
|
|
652
|
+
"ctl.ws.failed": "更新工作区失败",
|
|
653
|
+
"ctl.gh.login": "使用 GitHub 登录"
|
|
418
654
|
}
|
|
419
655
|
};
|
|
420
656
|
|
|
@@ -460,6 +696,18 @@
|
|
|
460
696
|
element.setAttribute("placeholder", t(key));
|
|
461
697
|
}
|
|
462
698
|
});
|
|
699
|
+
$$("[data-i18n-title]").forEach(function (element) {
|
|
700
|
+
var key = element.getAttribute("data-i18n-title");
|
|
701
|
+
if (key) {
|
|
702
|
+
element.setAttribute("title", t(key));
|
|
703
|
+
}
|
|
704
|
+
});
|
|
705
|
+
$$("[data-i18n-aria]").forEach(function (element) {
|
|
706
|
+
var key = element.getAttribute("data-i18n-aria");
|
|
707
|
+
if (key) {
|
|
708
|
+
element.setAttribute("aria-label", t(key));
|
|
709
|
+
}
|
|
710
|
+
});
|
|
463
711
|
var languageToggle = $("#language-toggle");
|
|
464
712
|
if (languageToggle) {
|
|
465
713
|
languageToggle.textContent = currentLanguage === "zh" ? "English" : "中文";
|
|
@@ -1187,12 +1435,16 @@
|
|
|
1187
1435
|
var selectedPlanningRunId = null;
|
|
1188
1436
|
|
|
1189
1437
|
function renderPlanningTab(runs) {
|
|
1438
|
+
lastRenderedData.planning = runs || [];
|
|
1190
1439
|
var sessionList = $("#planning-session-list");
|
|
1191
1440
|
if (!sessionList) return;
|
|
1192
1441
|
|
|
1193
1442
|
var planningRuns = (runs || [])
|
|
1194
1443
|
.filter(function (r) { return r && r.manifest; })
|
|
1195
1444
|
.sort(function (a, b) { return (b.updatedAt || 0) - (a.updatedAt || 0); });
|
|
1445
|
+
var planningWindow = splitByRecency(planningRuns, function (r) { return r.updatedAt || r.createdAt; }, "planning");
|
|
1446
|
+
planningRuns = planningWindow.shown;
|
|
1447
|
+
var planningOlderHtml = olderToggleHtml(planningWindow.olderCount, "planning");
|
|
1196
1448
|
|
|
1197
1449
|
if (planningRuns.length === 0) {
|
|
1198
1450
|
sessionList.innerHTML = '<div class="empty-state">' + escapeHtml(t("empty.noPlanningSessions")) + "</div>";
|
|
@@ -1222,7 +1474,7 @@
|
|
|
1222
1474
|
' <div class="planning-session-meta">' + escapeHtml(humanizeStatus(status)) + " · " + roles + " roles" + (assessments.length ? " · " + needed + " confirmed" : "") + " · " + escapeHtml(formatTime(run.updatedAt) || "") + "</div>" +
|
|
1223
1475
|
"</button>"
|
|
1224
1476
|
);
|
|
1225
|
-
}).join("");
|
|
1477
|
+
}).join("") + planningOlderHtml;
|
|
1226
1478
|
|
|
1227
1479
|
// Render selected run
|
|
1228
1480
|
renderPlanningDetail(planningRuns.find(function (r) { return r.id === selectedPlanningRunId; }));
|
|
@@ -1716,9 +1968,15 @@
|
|
|
1716
1968
|
}
|
|
1717
1969
|
|
|
1718
1970
|
if (!res.ok) {
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1971
|
+
// Issue #23 review follow-up: surface the backend's actionable `hint`
|
|
1972
|
+
// alongside the error code (e.g. a remote browser clicking "Enable
|
|
1973
|
+
// protection" gets the full loopback-only explanation, not a bare
|
|
1974
|
+
// "forbidden"). Same error+hint join as the CLI's describeSecurityError.
|
|
1975
|
+
const parts = [];
|
|
1976
|
+
const code = data && typeof (data.error || data.message) === "string" ? (data.error || data.message) : "";
|
|
1977
|
+
if (code) parts.push(code);
|
|
1978
|
+
if (data && typeof data.hint === "string" && data.hint.trim()) parts.push(data.hint.trim());
|
|
1979
|
+
const message = parts.length ? parts.join(" - ") : ("Request failed: " + res.status);
|
|
1722
1980
|
throw new Error(message);
|
|
1723
1981
|
}
|
|
1724
1982
|
|
|
@@ -2076,6 +2334,273 @@
|
|
|
2076
2334
|
);
|
|
2077
2335
|
}
|
|
2078
2336
|
|
|
2337
|
+
// =========================================================================
|
|
2338
|
+
// Device pairing security (issue #23, client wave) - zero friction by
|
|
2339
|
+
// design: this browser NEVER logs in (the loopback enable call sets the
|
|
2340
|
+
// HttpOnly session cookie), the banner only appears when the backend
|
|
2341
|
+
// observed a non-LAN peer while protection is off, and the pairing modal
|
|
2342
|
+
// shows a one-shot 60s code plus the copyable CLI command for the FIRST
|
|
2343
|
+
// external device.
|
|
2344
|
+
// =========================================================================
|
|
2345
|
+
|
|
2346
|
+
function renderSecurityBanner() {
|
|
2347
|
+
var banner = $("#security-suggest-banner");
|
|
2348
|
+
if (!banner) return;
|
|
2349
|
+
var suggested = Boolean(securityStatus && securityStatus.suggested && !securityStatus.protection);
|
|
2350
|
+
if (!suggested) {
|
|
2351
|
+
banner.hidden = true;
|
|
2352
|
+
banner.innerHTML = "";
|
|
2353
|
+
return;
|
|
2354
|
+
}
|
|
2355
|
+
banner.hidden = false;
|
|
2356
|
+
banner.innerHTML = (
|
|
2357
|
+
"<div style='display:flex;gap:12px;align-items:center;flex-wrap:wrap'>" +
|
|
2358
|
+
"<div style='flex:1;min-width:220px'>" +
|
|
2359
|
+
"<strong>" + escapeHtml(t("security.bannerTitle")) + "</strong> " +
|
|
2360
|
+
escapeHtml(t("security.bannerHint")) +
|
|
2361
|
+
"</div>" +
|
|
2362
|
+
"<button id='security-enable-btn' class='btn btn-primary btn-small' type='button'>" +
|
|
2363
|
+
escapeHtml(t("security.enableAction")) +
|
|
2364
|
+
"</button>" +
|
|
2365
|
+
"</div>"
|
|
2366
|
+
);
|
|
2367
|
+
var enableBtn = $("#security-enable-btn");
|
|
2368
|
+
if (enableBtn) {
|
|
2369
|
+
enableBtn.addEventListener("click", function () {
|
|
2370
|
+
enableBtn.disabled = true;
|
|
2371
|
+
enableProtection();
|
|
2372
|
+
});
|
|
2373
|
+
}
|
|
2374
|
+
}
|
|
2375
|
+
|
|
2376
|
+
function enableProtection() {
|
|
2377
|
+
// Same-origin fetch carries the loopback enable's session cookie
|
|
2378
|
+
// automatically; the response body never contains the token.
|
|
2379
|
+
apiPost("/security/enable", {})
|
|
2380
|
+
.then(function (data) {
|
|
2381
|
+
securityStatus = { protection: true, suggested: false, deviceCount: 1 };
|
|
2382
|
+
renderSecurityBanner();
|
|
2383
|
+
if (data && data.pairingCode && data.pairingCode.code) {
|
|
2384
|
+
openSecurityPairModal(data.pairingCode.code, data.pairingCode.expiresAt || 0);
|
|
2385
|
+
}
|
|
2386
|
+
refreshAll();
|
|
2387
|
+
})
|
|
2388
|
+
.catch(function (err) {
|
|
2389
|
+
showError(err instanceof Error ? err.message : "Failed to enable device protection");
|
|
2390
|
+
renderSecurityBanner();
|
|
2391
|
+
});
|
|
2392
|
+
}
|
|
2393
|
+
|
|
2394
|
+
function securityPairCommand(code) {
|
|
2395
|
+
// Controller URL is this page's own origin - the console browser IS the
|
|
2396
|
+
// machine-name source of truth for the CLI command it hands out.
|
|
2397
|
+
return "npx @teamclaws/teamclaw pair " + window.location.origin + " --code " + code;
|
|
2398
|
+
}
|
|
2399
|
+
|
|
2400
|
+
function openSecurityPairModal(code, expiresAt) {
|
|
2401
|
+
var modal = $("#security-pair-modal");
|
|
2402
|
+
if (!modal) return;
|
|
2403
|
+
renderSecurityPairCode(code, expiresAt);
|
|
2404
|
+
modal.classList.add("open");
|
|
2405
|
+
modal.setAttribute("aria-hidden", "false");
|
|
2406
|
+
}
|
|
2407
|
+
|
|
2408
|
+
function closeSecurityPairModal() {
|
|
2409
|
+
var modal = $("#security-pair-modal");
|
|
2410
|
+
if (!modal) return;
|
|
2411
|
+
modal.classList.remove("open");
|
|
2412
|
+
modal.setAttribute("aria-hidden", "true");
|
|
2413
|
+
stopSecurityPairTimer();
|
|
2414
|
+
}
|
|
2415
|
+
|
|
2416
|
+
function stopSecurityPairTimer() {
|
|
2417
|
+
if (securityPairTimer) {
|
|
2418
|
+
clearInterval(securityPairTimer);
|
|
2419
|
+
securityPairTimer = null;
|
|
2420
|
+
}
|
|
2421
|
+
}
|
|
2422
|
+
|
|
2423
|
+
function renderSecurityPairCode(code, expiresAt) {
|
|
2424
|
+
var codeEl = $("#security-pair-code");
|
|
2425
|
+
var countdownEl = $("#security-pair-countdown");
|
|
2426
|
+
var commandEl = $("#security-pair-command");
|
|
2427
|
+
if (!codeEl || !countdownEl || !commandEl) return;
|
|
2428
|
+
codeEl.textContent = code || "";
|
|
2429
|
+
commandEl.textContent = securityPairCommand(code || "");
|
|
2430
|
+
stopSecurityPairTimer();
|
|
2431
|
+
securityPairingExpiresAt = expiresAt || (Date.now() + 60_000);
|
|
2432
|
+
var tick = function () {
|
|
2433
|
+
var remaining = Math.max(0, Math.ceil((securityPairingExpiresAt - Date.now()) / 1000));
|
|
2434
|
+
if (remaining <= 0) {
|
|
2435
|
+
countdownEl.textContent = t("security.pairExpired");
|
|
2436
|
+
stopSecurityPairTimer();
|
|
2437
|
+
return;
|
|
2438
|
+
}
|
|
2439
|
+
countdownEl.textContent = t("security.pairExpiresIn", { n: remaining });
|
|
2440
|
+
};
|
|
2441
|
+
tick();
|
|
2442
|
+
securityPairTimer = setInterval(tick, 1000);
|
|
2443
|
+
}
|
|
2444
|
+
|
|
2445
|
+
function requestSecurityPairCode() {
|
|
2446
|
+
// A new code invalidates the previous one by replacement (backend
|
|
2447
|
+
// semantics); the console browser may mint one because its session
|
|
2448
|
+
// cookie authenticates it (or it is the loopback console).
|
|
2449
|
+
apiPost("/security/pair/start", {})
|
|
2450
|
+
.then(function (data) {
|
|
2451
|
+
if (data && data.pairingCode && data.pairingCode.code) {
|
|
2452
|
+
var modal = $("#security-pair-modal");
|
|
2453
|
+
if (modal && !modal.classList.contains("open")) {
|
|
2454
|
+
openSecurityPairModal(data.pairingCode.code, data.pairingCode.expiresAt || 0);
|
|
2455
|
+
} else {
|
|
2456
|
+
renderSecurityPairCode(data.pairingCode.code, data.pairingCode.expiresAt || 0);
|
|
2457
|
+
}
|
|
2458
|
+
}
|
|
2459
|
+
})
|
|
2460
|
+
.catch(function (err) {
|
|
2461
|
+
showError(err instanceof Error ? err.message : "Failed to issue a pairing code");
|
|
2462
|
+
});
|
|
2463
|
+
}
|
|
2464
|
+
|
|
2465
|
+
function securityDeviceKindIcon(kind) {
|
|
2466
|
+
var icons = { web: "\uD83C\uDF10", worker: "\u2699\uFE0F", desktop: "\uD83D\uDDA5\uFE0F", cli: "\u2328\uFE0F" };
|
|
2467
|
+
return icons[kind] || "\uD83D\uDD11";
|
|
2468
|
+
}
|
|
2469
|
+
|
|
2470
|
+
function securityDeviceSeenLabel(device) {
|
|
2471
|
+
if (!device || typeof device.lastSeenAt !== "number" || !device.lastSeenAt) {
|
|
2472
|
+
return "";
|
|
2473
|
+
}
|
|
2474
|
+
try {
|
|
2475
|
+
return new Date(device.lastSeenAt).toLocaleString(currentLanguage === "zh" ? "zh-CN" : "en");
|
|
2476
|
+
} catch (_err) {
|
|
2477
|
+
return "";
|
|
2478
|
+
}
|
|
2479
|
+
}
|
|
2480
|
+
|
|
2481
|
+
function renderSecurityDevices() {
|
|
2482
|
+
var statusEl = $("#security-devices-status");
|
|
2483
|
+
var listEl = $("#security-devices-list");
|
|
2484
|
+
var actionsEl = $("#security-devices-actions");
|
|
2485
|
+
if (!statusEl || !listEl || !actionsEl) return;
|
|
2486
|
+
var protection = Boolean(securityStatus && securityStatus.protection);
|
|
2487
|
+
statusEl.textContent = protection
|
|
2488
|
+
? t("security.statusOn", { n: (securityStatus && securityStatus.deviceCount) || 0 })
|
|
2489
|
+
: t("security.statusOff");
|
|
2490
|
+
if (!protection) {
|
|
2491
|
+
listEl.innerHTML = "";
|
|
2492
|
+
actionsEl.innerHTML = "";
|
|
2493
|
+
return;
|
|
2494
|
+
}
|
|
2495
|
+
// GET /security requires a paired caller (this browser's cookie). An
|
|
2496
|
+
// unpaired browser keeps the status line and gets the manage-elsewhere
|
|
2497
|
+
// note instead of a device list.
|
|
2498
|
+
apiGet("/security")
|
|
2499
|
+
.then(function (data) {
|
|
2500
|
+
var devices = (data && Array.isArray(data.devices)) ? data.devices : [];
|
|
2501
|
+
if (!devices.length) {
|
|
2502
|
+
listEl.innerHTML = '<div class="empty-state">' + escapeHtml(t("security.noDevices")) + "</div>";
|
|
2503
|
+
} else {
|
|
2504
|
+
listEl.innerHTML = devices.map(function (device) {
|
|
2505
|
+
var seen = securityDeviceSeenLabel(device);
|
|
2506
|
+
return (
|
|
2507
|
+
'<div class="team-profile-archive-row" data-security-device="' + escapeHtml(device.id) + '">' +
|
|
2508
|
+
"<span>" + securityDeviceKindIcon(device.kind) + " <strong>" + escapeHtml(device.name || device.id) + "</strong>" +
|
|
2509
|
+
' <small style="opacity:.65">(' + escapeHtml(device.kind || "") + ")</small></span>" +
|
|
2510
|
+
"<span style='opacity:.75'>" + (seen ? escapeHtml(seen) : "") + "</span>" +
|
|
2511
|
+
'<button class="btn btn-small" type="button" data-security-revoke="' + escapeHtml(device.id) + '"' +
|
|
2512
|
+
(device.kind === "web" ? ' title="' + escapeHtml(t("security.selfRevokeWarn")) + '"' : "") + ">" +
|
|
2513
|
+
escapeHtml(t("security.revoke")) +
|
|
2514
|
+
"</button>" +
|
|
2515
|
+
"</div>"
|
|
2516
|
+
);
|
|
2517
|
+
}).join("");
|
|
2518
|
+
listEl.querySelectorAll("[data-security-revoke]").forEach(function (btn) {
|
|
2519
|
+
btn.addEventListener("click", function () {
|
|
2520
|
+
revokeSecurityDevice(btn.getAttribute("data-security-revoke") || "");
|
|
2521
|
+
});
|
|
2522
|
+
});
|
|
2523
|
+
}
|
|
2524
|
+
actionsEl.innerHTML =
|
|
2525
|
+
'<button id="security-reset-btn" class="btn btn-small" type="button">' + escapeHtml(t("security.resetAll")) + "</button> " +
|
|
2526
|
+
'<button id="security-new-code-btn" class="btn btn-small" type="button">' + escapeHtml(t("security.pairNewCode")) + "</button>";
|
|
2527
|
+
var resetBtn = $("#security-reset-btn");
|
|
2528
|
+
if (resetBtn) {
|
|
2529
|
+
resetBtn.addEventListener("click", resetSecurityProtection);
|
|
2530
|
+
}
|
|
2531
|
+
var newCodeBtn = $("#security-new-code-btn");
|
|
2532
|
+
if (newCodeBtn) {
|
|
2533
|
+
newCodeBtn.addEventListener("click", requestSecurityPairCode);
|
|
2534
|
+
}
|
|
2535
|
+
})
|
|
2536
|
+
.catch(function () {
|
|
2537
|
+
listEl.innerHTML = '<div class="empty-state">' + escapeHtml(t("security.devicesUnavailable")) + "</div>";
|
|
2538
|
+
actionsEl.innerHTML =
|
|
2539
|
+
'<button id="security-new-code-btn" class="btn btn-small" type="button">' + escapeHtml(t("security.pairNewCode")) + "</button>";
|
|
2540
|
+
var fallbackNewCode = $("#security-new-code-btn");
|
|
2541
|
+
if (fallbackNewCode) {
|
|
2542
|
+
fallbackNewCode.addEventListener("click", requestSecurityPairCode);
|
|
2543
|
+
}
|
|
2544
|
+
});
|
|
2545
|
+
}
|
|
2546
|
+
|
|
2547
|
+
function revokeSecurityDevice(deviceId) {
|
|
2548
|
+
if (!deviceId) return;
|
|
2549
|
+
apiRequest("/security/devices/" + encodeURIComponent(deviceId), { method: "DELETE" })
|
|
2550
|
+
.then(function (data) {
|
|
2551
|
+
if (data && data.revokedSelf) {
|
|
2552
|
+
// This browser just unpaired itself: every later API call will be
|
|
2553
|
+
// 401 until it re-pairs from the controller host.
|
|
2554
|
+
showError(t("security.selfRevoked"));
|
|
2555
|
+
}
|
|
2556
|
+
renderSecurityDevices();
|
|
2557
|
+
refreshAll();
|
|
2558
|
+
})
|
|
2559
|
+
.catch(function (err) {
|
|
2560
|
+
showError(err instanceof Error ? err.message : "Failed to revoke device");
|
|
2561
|
+
});
|
|
2562
|
+
}
|
|
2563
|
+
|
|
2564
|
+
function resetSecurityProtection() {
|
|
2565
|
+
if (!window.confirm(t("security.resetConfirm"))) return;
|
|
2566
|
+
apiPost("/security/reset", {})
|
|
2567
|
+
.then(function () {
|
|
2568
|
+
showError(t("security.resetDone"));
|
|
2569
|
+
renderSecurityDevices();
|
|
2570
|
+
refreshAll();
|
|
2571
|
+
})
|
|
2572
|
+
.catch(function (err) {
|
|
2573
|
+
showError(err instanceof Error ? err.message : "Failed to reset device protection");
|
|
2574
|
+
});
|
|
2575
|
+
}
|
|
2576
|
+
|
|
2577
|
+
function bindSecurityUi() {
|
|
2578
|
+
var pairModal = $("#security-pair-modal");
|
|
2579
|
+
if (pairModal && !pairModal.dataset.bound) {
|
|
2580
|
+
pairModal.dataset.bound = "true";
|
|
2581
|
+
pairModal.addEventListener("click", function (event) {
|
|
2582
|
+
if (event.target && event.target.hasAttribute && event.target.hasAttribute("data-security-pair-close")) {
|
|
2583
|
+
closeSecurityPairModal();
|
|
2584
|
+
}
|
|
2585
|
+
});
|
|
2586
|
+
var copyBtn = $("#security-pair-copy");
|
|
2587
|
+
if (copyBtn) {
|
|
2588
|
+
copyBtn.addEventListener("click", function () {
|
|
2589
|
+
var commandEl = $("#security-pair-command");
|
|
2590
|
+
if (!commandEl || !commandEl.textContent) return;
|
|
2591
|
+
copyText(commandEl.textContent).then(function () {
|
|
2592
|
+
copyBtn.textContent = t("action.copied");
|
|
2593
|
+
setTimeout(function () { copyBtn.textContent = t("action.copyCommand"); }, 1500);
|
|
2594
|
+
}).catch(function () {});
|
|
2595
|
+
});
|
|
2596
|
+
}
|
|
2597
|
+
var newCodeBtn = $("#security-pair-new");
|
|
2598
|
+
if (newCodeBtn) {
|
|
2599
|
+
newCodeBtn.addEventListener("click", requestSecurityPairCode);
|
|
2600
|
+
}
|
|
2601
|
+
}
|
|
2602
|
+
}
|
|
2603
|
+
|
|
2079
2604
|
function renderExternalWorkerInstallToggle() {
|
|
2080
2605
|
var button = $("#worker-install-toggle");
|
|
2081
2606
|
if (!button) return;
|
|
@@ -2102,7 +2627,7 @@
|
|
|
2102
2627
|
card.classList.add("hidden");
|
|
2103
2628
|
return;
|
|
2104
2629
|
}
|
|
2105
|
-
var roles = Array.isArray(info.roles) ? info.roles : [];
|
|
2630
|
+
var roles = visibleRoles(Array.isArray(info.roles) ? info.roles : []);
|
|
2106
2631
|
if (!roles.length) {
|
|
2107
2632
|
card.classList.add("hidden");
|
|
2108
2633
|
card.innerHTML = "";
|
|
@@ -2116,7 +2641,7 @@
|
|
|
2116
2641
|
}
|
|
2117
2642
|
var roleOptions = roles.map(function (role) {
|
|
2118
2643
|
return '<option value="' + escapeHtml(role.id) + '"' + (role.id === selectedExternalWorkerRole ? " selected" : "") + ">" +
|
|
2119
|
-
escapeHtml((role.icon ? role.icon + " " : "") + (role
|
|
2644
|
+
escapeHtml((role.icon ? role.icon + " " : "") + roleDisplayLabel(role)) +
|
|
2120
2645
|
"</option>";
|
|
2121
2646
|
}).join("");
|
|
2122
2647
|
var command = buildExternalWorkerCommand(info, selectedExternalWorkerRole, selectedExternalWorkerDiscoveryMode);
|
|
@@ -2458,6 +2983,15 @@
|
|
|
2458
2983
|
externalWorkerInstall: statusRes.externalWorkerInstall || null,
|
|
2459
2984
|
};
|
|
2460
2985
|
|
|
2986
|
+
// Issue #23: the /team/status `security` object drives the suggestion
|
|
2987
|
+
// banner (protection off + non-LAN peer observed) and the device
|
|
2988
|
+
// section status line. Absent on older controllers => null => hidden.
|
|
2989
|
+
securityStatus = statusRes.security || null;
|
|
2990
|
+
renderSecurityBanner();
|
|
2991
|
+
if (($("#team-profile-modal") || {}).classList?.contains("open")) {
|
|
2992
|
+
renderSecurityDevices();
|
|
2993
|
+
}
|
|
2994
|
+
|
|
2461
2995
|
// Active team profile (Phase 5.1): drives the header indicator, the
|
|
2462
2996
|
// capability-gated tab visibility, and the switch transition notice.
|
|
2463
2997
|
// Tolerated like /roles - an older controller without the endpoint
|
|
@@ -2474,6 +3008,10 @@
|
|
|
2474
3008
|
reconcileTeamProfileSwitch();
|
|
2475
3009
|
}
|
|
2476
3010
|
|
|
3011
|
+
// Workflow quick actions + running badges read the same profile mirror:
|
|
3012
|
+
// unguarded so a failed/absent fetch re-hides the launcher cleanly.
|
|
3013
|
+
renderWorkflowLauncher();
|
|
3014
|
+
|
|
2477
3015
|
renderWorkers(teamState.workers);
|
|
2478
3016
|
renderTasks(teamState.tasks);
|
|
2479
3017
|
renderPlanningTab(teamState.controllerRuns);
|
|
@@ -2562,7 +3100,38 @@
|
|
|
2562
3100
|
return haystack.includes(keyword);
|
|
2563
3101
|
}
|
|
2564
3102
|
|
|
3103
|
+
// ---- 24h recency window + lazy "show older" (#recent-window) ----
|
|
3104
|
+
// Planning / Tasks / Clarifications / Messages only list items from the
|
|
3105
|
+
// last 24h by default; older items appear after an explicit click.
|
|
3106
|
+
const TWENTY_FOUR_H_MS = 24 * 60 * 60 * 1000;
|
|
3107
|
+
const showOlderSections = { tasks: false, planning: false, clarifications: false, messages: false };
|
|
3108
|
+
const lastRenderedData = { tasks: [], planning: [], clarifications: [], messages: [] };
|
|
3109
|
+
function splitByRecency(items, tsOf, section) {
|
|
3110
|
+
const cutoff = Date.now() - TWENTY_FOUR_H_MS;
|
|
3111
|
+
const recent = [];
|
|
3112
|
+
const older = [];
|
|
3113
|
+
for (const item of items || []) {
|
|
3114
|
+
((tsOf(item) || 0) >= cutoff ? recent : older).push(item);
|
|
3115
|
+
}
|
|
3116
|
+
return showOlderSections[section] ? { shown: recent.concat(older), olderCount: 0 } : { shown: recent, olderCount: older.length };
|
|
3117
|
+
}
|
|
3118
|
+
function olderToggleHtml(count, section) {
|
|
3119
|
+
if (!count) return "";
|
|
3120
|
+
return '<div style="text-align:center;padding:8px"><button type="button" class="btn btn-small" data-show-older="' + section + '">' +
|
|
3121
|
+
escapeHtml(t("common.showOlder", { n: count })) + "</button></div>";
|
|
3122
|
+
}
|
|
3123
|
+
document.addEventListener("click", function (event) {
|
|
3124
|
+
const btn = event.target instanceof Element && event.target.closest("[data-show-older]");
|
|
3125
|
+
if (!btn || btn.tagName !== "BUTTON") return;
|
|
3126
|
+
showOlderSections[btn.getAttribute("data-show-older")] = true;
|
|
3127
|
+
renderTasks(lastRenderedData.tasks);
|
|
3128
|
+
renderPlanningTab(lastRenderedData.planning);
|
|
3129
|
+
renderClarifications(lastRenderedData.clarifications);
|
|
3130
|
+
renderMessages(lastRenderedData.messages);
|
|
3131
|
+
});
|
|
3132
|
+
|
|
2565
3133
|
function renderTasks(tasks) {
|
|
3134
|
+
lastRenderedData.tasks = tasks || [];
|
|
2566
3135
|
const container = $("#tasks-board");
|
|
2567
3136
|
if (!container) return;
|
|
2568
3137
|
|
|
@@ -2583,10 +3152,13 @@
|
|
|
2583
3152
|
}
|
|
2584
3153
|
|
|
2585
3154
|
const sorted = filtered.slice().sort(taskComparator);
|
|
3155
|
+
// #recent-window: 24h recency first, older tasks behind the lazy toggle
|
|
3156
|
+
// (applied before the terminal chunking, so both windows stay fast).
|
|
3157
|
+
const recency = splitByRecency(sorted, function (task) { return task.updatedAt || task.createdAt; }, "tasks");
|
|
2586
3158
|
// Active tasks render in full; terminal ones chunk so long-lived installs
|
|
2587
3159
|
// with hundreds of completed tasks stay fast and meaningful.
|
|
2588
|
-
const activeTasks =
|
|
2589
|
-
const terminalTasks =
|
|
3160
|
+
const activeTasks = recency.shown.filter(function (task) { return !TERMINAL_STATUSES[task.status]; });
|
|
3161
|
+
const terminalTasks = recency.shown.filter(function (task) { return TERMINAL_STATUSES[task.status]; });
|
|
2590
3162
|
const visibleTerminal = terminalTasks.slice(0, terminalTasksVisible);
|
|
2591
3163
|
const hiddenTerminal = terminalTasks.length - visibleTerminal.length;
|
|
2592
3164
|
const visibleList = activeTasks.concat(visibleTerminal);
|
|
@@ -2624,7 +3196,7 @@
|
|
|
2624
3196
|
'<div class="task-card' + liveClass + '" data-task-id="' + escapeHtml(task.id) + '" tabindex="0" role="button" aria-label="Open details for ' + escapeHtml(task.title) + '">' +
|
|
2625
3197
|
' <span class="task-priority ' + escapeHtml(priority) + '">' + escapeHtml(priority) + "</span>" +
|
|
2626
3198
|
' <div class="task-body">' +
|
|
2627
|
-
' <div class="task-title-row"><div class="task-title">' + escapeHtml(task.title) + "</div>" + creatorBadge + "</div>" +
|
|
3199
|
+
' <div class="task-title-row"><div class="task-title">' + escapeHtml(task.title) + "</div>" + creatorBadge + workflowBadgeHtml(task) + "</div>" +
|
|
2628
3200
|
(task.description ? '<div class="task-desc clamp">' + escapeHtml(task.description).slice(0, 220) + "</div>" : "") +
|
|
2629
3201
|
renderSkillPills(recommendedSkills, "skill-pills task-skill-pills") +
|
|
2630
3202
|
contractSummary +
|
|
@@ -2638,7 +3210,7 @@
|
|
|
2638
3210
|
" </div>" +
|
|
2639
3211
|
"</div>"
|
|
2640
3212
|
);
|
|
2641
|
-
}).join("") + showMoreHtml;
|
|
3213
|
+
}).join("") + showMoreHtml + olderToggleHtml(recency.olderCount, "tasks");
|
|
2642
3214
|
|
|
2643
3215
|
const showMoreBtn = $("#tasks-show-more");
|
|
2644
3216
|
if (showMoreBtn) {
|
|
@@ -2649,6 +3221,115 @@
|
|
|
2649
3221
|
}
|
|
2650
3222
|
}
|
|
2651
3223
|
|
|
3224
|
+
// ==================== Workflow template launcher (design 2.4) ====================
|
|
3225
|
+
// Quick-action button group over the ACTIVE profile's workflow templates
|
|
3226
|
+
// (GET /team/profile -> profile.workflows[], serialized verbatim by the
|
|
3227
|
+
// backend - PR #243 API contract). Profiles without workflows
|
|
3228
|
+
// (software-rd) and older controllers without the field both resolve to an
|
|
3229
|
+
// empty template list, so the launcher hides itself - purely data-driven,
|
|
3230
|
+
// no per-profile branches. Click posts POST /api/v1/workflows/{id}/start
|
|
3231
|
+
// with an empty context (minimal v1 invocation); 201 -> refreshAll() so
|
|
3232
|
+
// the new task chain appears; 404/503 surface the backend message.
|
|
3233
|
+
|
|
3234
|
+
function activeWorkflows() {
|
|
3235
|
+
return activeTeamProfile && activeTeamProfile.profile && Array.isArray(activeTeamProfile.profile.workflows)
|
|
3236
|
+
? activeTeamProfile.profile.workflows
|
|
3237
|
+
: [];
|
|
3238
|
+
}
|
|
3239
|
+
|
|
3240
|
+
function workflowStepRoleLabel(step) {
|
|
3241
|
+
var id = step && typeof step.role === "string" ? step.role : "";
|
|
3242
|
+
if (!id) return "";
|
|
3243
|
+
var entry = roleRegistry.filter(function (role) { return role && role.id === id; })[0];
|
|
3244
|
+
// Route through the rename layer so tooltip chains honor custom names.
|
|
3245
|
+
return entry ? roleDisplayLabel(entry) : id;
|
|
3246
|
+
}
|
|
3247
|
+
|
|
3248
|
+
function renderWorkflowLauncher() {
|
|
3249
|
+
var container = $("#workflow-launcher");
|
|
3250
|
+
if (!container) return;
|
|
3251
|
+
var workflows = activeWorkflows();
|
|
3252
|
+
if (!workflows.length) {
|
|
3253
|
+
container.hidden = true;
|
|
3254
|
+
container.innerHTML = "";
|
|
3255
|
+
return;
|
|
3256
|
+
}
|
|
3257
|
+
container.hidden = false;
|
|
3258
|
+
container.setAttribute("aria-label", t("workflow.sectionTitle"));
|
|
3259
|
+
container.innerHTML = workflows.map(function (workflow) {
|
|
3260
|
+
if (!workflow || typeof workflow.id !== "string" || !workflow.id) return "";
|
|
3261
|
+
var steps = Array.isArray(workflow.steps) ? workflow.steps : [];
|
|
3262
|
+
var roles = steps.map(workflowStepRoleLabel).filter(Boolean).join(" → ");
|
|
3263
|
+
var tooltip = t("workflow.stepsTooltip", { n: steps.length, roles: roles });
|
|
3264
|
+
return (
|
|
3265
|
+
'<button type="button" class="filter-btn workflow-launch-btn" data-workflow-id="' + escapeHtml(workflow.id) +
|
|
3266
|
+
'" title="' + escapeHtml((workflow.name || workflow.id) + " — " + tooltip) + '">' +
|
|
3267
|
+
escapeHtml(workflow.name || workflow.id) +
|
|
3268
|
+
"</button>"
|
|
3269
|
+
);
|
|
3270
|
+
}).join("");
|
|
3271
|
+
container.querySelectorAll("[data-workflow-id]").forEach(function (button) {
|
|
3272
|
+
button.addEventListener("click", function () {
|
|
3273
|
+
startWorkflow(button.getAttribute("data-workflow-id") || "", button);
|
|
3274
|
+
});
|
|
3275
|
+
});
|
|
3276
|
+
}
|
|
3277
|
+
|
|
3278
|
+
function startWorkflow(workflowId, button) {
|
|
3279
|
+
if (!workflowId) return;
|
|
3280
|
+
if (button) button.disabled = true;
|
|
3281
|
+
apiPost("/workflows/" + encodeURIComponent(workflowId) + "/start", { context: "" })
|
|
3282
|
+
.then(function (data) {
|
|
3283
|
+
var name = (data && data.workflowName) || workflowId;
|
|
3284
|
+
showError(t("workflow.started", { name: name }));
|
|
3285
|
+
// The task chain itself is the workflow run state (design 2.4): a
|
|
3286
|
+
// full refresh makes the first step task (workflow badge on) appear.
|
|
3287
|
+
return refreshAll();
|
|
3288
|
+
})
|
|
3289
|
+
.catch(function (err) {
|
|
3290
|
+
// 404 unknown id / 400 bad context / 503 mid-switch: apiRequest
|
|
3291
|
+
// already extracts the backend error string; prefix the context.
|
|
3292
|
+
showError(t("workflow.startFailed", {
|
|
3293
|
+
reason: err instanceof Error ? err.message : String(err || "request failed"),
|
|
3294
|
+
}));
|
|
3295
|
+
})
|
|
3296
|
+
.finally(function () {
|
|
3297
|
+
if (button) button.disabled = false;
|
|
3298
|
+
});
|
|
3299
|
+
}
|
|
3300
|
+
|
|
3301
|
+
// Running-workflow badge: tasks created by the workflow engine carry
|
|
3302
|
+
// task.workflow { workflowId, runId, stepKey, visitCounts }. The context
|
|
3303
|
+
// holds ids only - the display join (workflow name, step title) resolves
|
|
3304
|
+
// against the active profile's templates, and visitCounts > 1 on the
|
|
3305
|
+
// current step surfaces the re-entry round (return-edge loops).
|
|
3306
|
+
function workflowBadgeHtml(task) {
|
|
3307
|
+
var context = task && task.workflow;
|
|
3308
|
+
if (!context || !context.workflowId) return "";
|
|
3309
|
+
var template = activeWorkflows().filter(function (workflow) {
|
|
3310
|
+
return workflow.id === context.workflowId;
|
|
3311
|
+
})[0];
|
|
3312
|
+
var workflowName = template ? (template.name || template.id) : context.workflowId;
|
|
3313
|
+
var stepTitle = "";
|
|
3314
|
+
if (template && Array.isArray(template.steps)) {
|
|
3315
|
+
var step = template.steps.filter(function (entry) {
|
|
3316
|
+
return String(entry && entry.id) === String(context.stepKey);
|
|
3317
|
+
})[0];
|
|
3318
|
+
if (step && step.title) stepTitle = step.title;
|
|
3319
|
+
}
|
|
3320
|
+
var visits = context.visitCounts ? context.visitCounts[String(context.stepKey)] : undefined;
|
|
3321
|
+
var roundPart = typeof visits === "number" && visits > 1
|
|
3322
|
+
? " · " + t("workflow.badgeRound", { n: visits })
|
|
3323
|
+
: "";
|
|
3324
|
+
var label = workflowName + (stepTitle ? " · " + stepTitle : "") + roundPart;
|
|
3325
|
+
return (
|
|
3326
|
+
'<span class="task-origin-badge task-workflow-badge" title="' +
|
|
3327
|
+
escapeHtml(t("workflow.sectionTitle") + ": " + label) + '">' +
|
|
3328
|
+
escapeHtml(label) +
|
|
3329
|
+
"</span>"
|
|
3330
|
+
);
|
|
3331
|
+
}
|
|
3332
|
+
|
|
2652
3333
|
function renderControllerRuns(runs) {
|
|
2653
3334
|
const container = $("#controller-runs");
|
|
2654
3335
|
if (!container) return;
|
|
@@ -2812,9 +3493,9 @@
|
|
|
2812
3493
|
if (subtitle) {
|
|
2813
3494
|
subtitle.textContent = task
|
|
2814
3495
|
? [
|
|
2815
|
-
"
|
|
2816
|
-
task.assignedWorkerId ? "
|
|
2817
|
-
task.assignedRole ? "
|
|
3496
|
+
t("detail.taskId", { id: task.id }),
|
|
3497
|
+
task.assignedWorkerId ? t("detail.worker", { id: task.assignedWorkerId }) : null,
|
|
3498
|
+
task.assignedRole ? t("detail.role", { id: task.assignedRole }) : null,
|
|
2818
3499
|
].filter(Boolean).join(" • ")
|
|
2819
3500
|
: "";
|
|
2820
3501
|
}
|
|
@@ -3183,6 +3864,7 @@
|
|
|
3183
3864
|
}
|
|
3184
3865
|
|
|
3185
3866
|
function renderClarifications(clarifications) {
|
|
3867
|
+
lastRenderedData.clarifications = clarifications || [];
|
|
3186
3868
|
const container = $("#clarifications-list");
|
|
3187
3869
|
if (!container) return;
|
|
3188
3870
|
|
|
@@ -3191,14 +3873,21 @@
|
|
|
3191
3873
|
return;
|
|
3192
3874
|
}
|
|
3193
3875
|
|
|
3194
|
-
|
|
3876
|
+
const clWindow = splitByRecency(sortClarifications(clarifications), function (c) { return c.createdAt || c.updatedAt; }, "clarifications");
|
|
3877
|
+
if (clWindow.shown.length === 0) {
|
|
3878
|
+
container.innerHTML = olderToggleHtml(clWindow.olderCount, "clarifications");
|
|
3879
|
+
return;
|
|
3880
|
+
}
|
|
3881
|
+
container.innerHTML = renderClarificationCards(clWindow.shown, { linkToTask: true }) +
|
|
3882
|
+
olderToggleHtml(clWindow.olderCount, "clarifications");
|
|
3195
3883
|
}
|
|
3196
3884
|
|
|
3197
3885
|
function renderMessages(messages) {
|
|
3886
|
+
lastRenderedData.messages = messages || [];
|
|
3198
3887
|
const container = $("#messages-feed");
|
|
3199
3888
|
if (!container) return;
|
|
3200
3889
|
|
|
3201
|
-
|
|
3890
|
+
var recent = (messages || [])
|
|
3202
3891
|
.concat(controllerConversation || [])
|
|
3203
3892
|
.sort(function (left, right) {
|
|
3204
3893
|
return (right.createdAt || 0) - (left.createdAt || 0);
|
|
@@ -3209,18 +3898,24 @@
|
|
|
3209
3898
|
return;
|
|
3210
3899
|
}
|
|
3211
3900
|
|
|
3212
|
-
|
|
3901
|
+
const msgWindow = splitByRecency(recent, function (m) { return m.createdAt; }, "messages");
|
|
3902
|
+
if (msgWindow.shown.length === 0) {
|
|
3903
|
+
container.innerHTML = olderToggleHtml(msgWindow.olderCount, "messages");
|
|
3904
|
+
return;
|
|
3905
|
+
}
|
|
3906
|
+
container.innerHTML = renderMessageCards(msgWindow.shown) +
|
|
3907
|
+
olderToggleHtml(msgWindow.olderCount, "messages");
|
|
3213
3908
|
}
|
|
3214
3909
|
|
|
3215
3910
|
function renderRoles(roles) {
|
|
3216
3911
|
const container = $("#roles-list");
|
|
3217
3912
|
if (!container) return;
|
|
3218
3913
|
|
|
3219
|
-
container.innerHTML = roles.map(function (role) {
|
|
3914
|
+
container.innerHTML = visibleRoles(roles).map(function (role) {
|
|
3220
3915
|
return (
|
|
3221
3916
|
'<div class="role-chip">' +
|
|
3222
3917
|
" <span>" + escapeHtml(role.icon || "") + "</span>" +
|
|
3223
|
-
" <span>" + escapeHtml(role
|
|
3918
|
+
" <span>" + escapeHtml(roleDisplayLabel(role)) + "</span>" +
|
|
3224
3919
|
"</div>"
|
|
3225
3920
|
);
|
|
3226
3921
|
}).join("");
|
|
@@ -3237,11 +3932,11 @@
|
|
|
3237
3932
|
while (select.options.length > 1) {
|
|
3238
3933
|
select.remove(1);
|
|
3239
3934
|
}
|
|
3240
|
-
roleRegistry.forEach(function (role) {
|
|
3935
|
+
visibleRoles(roleRegistry).forEach(function (role) {
|
|
3241
3936
|
if (!role || typeof role.id !== "string" || !role.id) return;
|
|
3242
3937
|
const option = document.createElement("option");
|
|
3243
3938
|
option.value = role.id;
|
|
3244
|
-
option.textContent = role
|
|
3939
|
+
option.textContent = roleDisplayLabel(role);
|
|
3245
3940
|
select.appendChild(option);
|
|
3246
3941
|
});
|
|
3247
3942
|
if (previous && Array.prototype.some.call(select.options, function (option) { return option.value === previous; })) {
|
|
@@ -3260,6 +3955,131 @@
|
|
|
3260
3955
|
return roles.length > 0 ? roles[0].id : "";
|
|
3261
3956
|
}
|
|
3262
3957
|
|
|
3958
|
+
// ============ Role display prefs (Phase 4 lightweight customization) ============
|
|
3959
|
+
// v1 lightweight customization (design Phase 4): hide roles the team does
|
|
3960
|
+
// not use and rename the rest for the local team. PURE UI filter layer -
|
|
3961
|
+
// prefs persist in this browser's localStorage only; /roles, TeamState and
|
|
3962
|
+
// the profile JSON schema stay untouched (the full JSON editor is v2).
|
|
3963
|
+
// Applied at render time to the manual-task role select, the
|
|
3964
|
+
// external-worker role select and the sidebar Roles list.
|
|
3965
|
+
const ROLE_DISPLAY_STORAGE_KEY = "teamclaw.ui.roleDisplay.v1";
|
|
3966
|
+
let roleDisplayPrefs = loadRoleDisplayPrefs();
|
|
3967
|
+
|
|
3968
|
+
function defaultRoleDisplayPrefs() {
|
|
3969
|
+
return { hidden: {}, names: {} };
|
|
3970
|
+
}
|
|
3971
|
+
|
|
3972
|
+
function loadRoleDisplayPrefs() {
|
|
3973
|
+
try {
|
|
3974
|
+
var raw = window.localStorage.getItem(ROLE_DISPLAY_STORAGE_KEY);
|
|
3975
|
+
if (!raw) return defaultRoleDisplayPrefs();
|
|
3976
|
+
var parsed = JSON.parse(raw);
|
|
3977
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return defaultRoleDisplayPrefs();
|
|
3978
|
+
return {
|
|
3979
|
+
hidden: parsed.hidden && typeof parsed.hidden === "object" && !Array.isArray(parsed.hidden) ? parsed.hidden : {},
|
|
3980
|
+
names: parsed.names && typeof parsed.names === "object" && !Array.isArray(parsed.names) ? parsed.names : {},
|
|
3981
|
+
};
|
|
3982
|
+
} catch (_err) {
|
|
3983
|
+
return defaultRoleDisplayPrefs();
|
|
3984
|
+
}
|
|
3985
|
+
}
|
|
3986
|
+
|
|
3987
|
+
function saveRoleDisplayPrefs(prefs) {
|
|
3988
|
+
roleDisplayPrefs = prefs || defaultRoleDisplayPrefs();
|
|
3989
|
+
try {
|
|
3990
|
+
window.localStorage.setItem(ROLE_DISPLAY_STORAGE_KEY, JSON.stringify(roleDisplayPrefs));
|
|
3991
|
+
} catch (_err) {}
|
|
3992
|
+
}
|
|
3993
|
+
|
|
3994
|
+
function resetRoleDisplayPrefs() {
|
|
3995
|
+
roleDisplayPrefs = defaultRoleDisplayPrefs();
|
|
3996
|
+
try {
|
|
3997
|
+
window.localStorage.removeItem(ROLE_DISPLAY_STORAGE_KEY);
|
|
3998
|
+
} catch (_err) {}
|
|
3999
|
+
}
|
|
4000
|
+
|
|
4001
|
+
function isRoleVisible(roleId) {
|
|
4002
|
+
return !(roleDisplayPrefs.hidden && roleDisplayPrefs.hidden[roleId]);
|
|
4003
|
+
}
|
|
4004
|
+
|
|
4005
|
+
// Rename layer: a non-empty custom name wins; anything else falls back to
|
|
4006
|
+
// the registry label (and the id when even the label is missing).
|
|
4007
|
+
function roleDisplayLabel(role) {
|
|
4008
|
+
if (!role) return "";
|
|
4009
|
+
var custom = roleDisplayPrefs.names ? roleDisplayPrefs.names[role.id] : "";
|
|
4010
|
+
if (typeof custom === "string" && custom.trim()) return custom.trim();
|
|
4011
|
+
return role.label || role.id || "";
|
|
4012
|
+
}
|
|
4013
|
+
|
|
4014
|
+
function visibleRoles(roles) {
|
|
4015
|
+
return (roles || []).filter(function (role) {
|
|
4016
|
+
return role && typeof role.id === "string" && role.id && isRoleVisible(role.id);
|
|
4017
|
+
});
|
|
4018
|
+
}
|
|
4019
|
+
|
|
4020
|
+
// Re-render every surface the prefs drive (manual-task select, external
|
|
4021
|
+
// worker card, sidebar chips) after a save/reset.
|
|
4022
|
+
function rerenderRoleSurfaces() {
|
|
4023
|
+
renderTaskRoleOptions();
|
|
4024
|
+
renderExternalWorkerInstallCard();
|
|
4025
|
+
renderRoles(roleRegistry);
|
|
4026
|
+
}
|
|
4027
|
+
|
|
4028
|
+
// Editor rows live in the team-profile modal's "Role display" section:
|
|
4029
|
+
// one row per /roles registry entry - visibility checkbox (keyed by the
|
|
4030
|
+
// stable role id) + display-name input whose placeholder is the registry
|
|
4031
|
+
// label (an empty value falls back to it on save).
|
|
4032
|
+
function renderRoleDisplayEditor() {
|
|
4033
|
+
var listEl = $("#role-display-list");
|
|
4034
|
+
if (!listEl) return;
|
|
4035
|
+
if (!roleRegistry.length) {
|
|
4036
|
+
listEl.innerHTML = "";
|
|
4037
|
+
return;
|
|
4038
|
+
}
|
|
4039
|
+
listEl.innerHTML = roleRegistry.map(function (role) {
|
|
4040
|
+
var fallback = role.label || role.id;
|
|
4041
|
+
var customName = (roleDisplayPrefs.names && roleDisplayPrefs.names[role.id]) || "";
|
|
4042
|
+
return (
|
|
4043
|
+
'<div class="team-profile-archive-row role-display-row" data-role-display-id="' + escapeHtml(role.id) + '">' +
|
|
4044
|
+
'<label class="role-display-visible">' +
|
|
4045
|
+
'<input type="checkbox" data-role-display-visible' + (isRoleVisible(role.id) ? " checked" : "") + "> " +
|
|
4046
|
+
escapeHtml((role.icon ? role.icon + " " : "") + role.id) +
|
|
4047
|
+
"</label>" +
|
|
4048
|
+
'<input type="text" class="role-display-name" data-role-display-name spellcheck="false" autocomplete="off" value="' +
|
|
4049
|
+
escapeHtml(customName) + '" placeholder="' + escapeHtml(fallback) + '">' +
|
|
4050
|
+
"</div>"
|
|
4051
|
+
);
|
|
4052
|
+
}).join("");
|
|
4053
|
+
}
|
|
4054
|
+
|
|
4055
|
+
function saveRoleDisplayFromEditor() {
|
|
4056
|
+
var listEl = $("#role-display-list");
|
|
4057
|
+
if (!listEl) return;
|
|
4058
|
+
var prefs = defaultRoleDisplayPrefs();
|
|
4059
|
+
listEl.querySelectorAll("[data-role-display-id]").forEach(function (row) {
|
|
4060
|
+
var roleId = row.getAttribute("data-role-display-id") || "";
|
|
4061
|
+
if (!roleId) return;
|
|
4062
|
+
var checkbox = row.querySelector("[data-role-display-visible]");
|
|
4063
|
+
if (checkbox && !checkbox.checked) prefs.hidden[roleId] = true;
|
|
4064
|
+
var nameInput = row.querySelector("[data-role-display-name]");
|
|
4065
|
+
if (nameInput) {
|
|
4066
|
+
var custom = nameInput.value.trim();
|
|
4067
|
+
if (custom) prefs.names[roleId] = custom;
|
|
4068
|
+
}
|
|
4069
|
+
});
|
|
4070
|
+
saveRoleDisplayPrefs(prefs);
|
|
4071
|
+
rerenderRoleSurfaces();
|
|
4072
|
+
renderRoleDisplayEditor();
|
|
4073
|
+
showError(t("roleDisplay.saved"));
|
|
4074
|
+
}
|
|
4075
|
+
|
|
4076
|
+
function resetRoleDisplay() {
|
|
4077
|
+
resetRoleDisplayPrefs();
|
|
4078
|
+
rerenderRoleSurfaces();
|
|
4079
|
+
renderRoleDisplayEditor();
|
|
4080
|
+
showError(t("roleDisplay.resetDone"));
|
|
4081
|
+
}
|
|
4082
|
+
|
|
3263
4083
|
function tabNameFromHash() {
|
|
3264
4084
|
const match = /^#\/tab\/([a-z][a-z0-9-]*)$/i.exec(window.location.hash || "");
|
|
3265
4085
|
const name = match ? match[1] : "";
|
|
@@ -3308,6 +4128,9 @@
|
|
|
3308
4128
|
if (activeTab === "workspace") {
|
|
3309
4129
|
refreshWorkspaceTree(false);
|
|
3310
4130
|
}
|
|
4131
|
+
if (activeTab === "settings") {
|
|
4132
|
+
renderWorkerSettingsPanel();
|
|
4133
|
+
}
|
|
3311
4134
|
if (activeTab === "teamauto") {
|
|
3312
4135
|
refreshTeamAutoTab();
|
|
3313
4136
|
}
|
|
@@ -3544,7 +4367,7 @@
|
|
|
3544
4367
|
const answer = answerInput ? answerInput.value.trim() : "";
|
|
3545
4368
|
|
|
3546
4369
|
if (!clarificationId || !answer) {
|
|
3547
|
-
showError("
|
|
4370
|
+
showError(t("clarification.needAnswer"));
|
|
3548
4371
|
return;
|
|
3549
4372
|
}
|
|
3550
4373
|
|
|
@@ -3775,7 +4598,7 @@
|
|
|
3775
4598
|
if (!el) return;
|
|
3776
4599
|
apiGet("/workspace/status").then(function (data) {
|
|
3777
4600
|
if (data && typeof data.workspaceDir === "string") {
|
|
3778
|
-
el.textContent = data.workspaceDir + (data.isDefault ? " (default)" : "");
|
|
4601
|
+
el.textContent = data.workspaceDir + (data.isDefault ? " (" + t("ctl.ws.default") + ")" : "");
|
|
3779
4602
|
el.title = data.workspaceDir;
|
|
3780
4603
|
}
|
|
3781
4604
|
}).catch(function () { /* leave placeholder */ });
|
|
@@ -3786,7 +4609,7 @@
|
|
|
3786
4609
|
var pathEl = $("#workspace-prompt-path");
|
|
3787
4610
|
var input = $("#workspace-prompt-input");
|
|
3788
4611
|
if (!modal || !pathEl || !input) return;
|
|
3789
|
-
pathEl.textContent = currentPath || "
|
|
4612
|
+
pathEl.textContent = currentPath || t("ws.unknown");
|
|
3790
4613
|
input.value = currentPath || "";
|
|
3791
4614
|
modal.classList.add("open");
|
|
3792
4615
|
modal.setAttribute("aria-hidden", "false");
|
|
@@ -3838,13 +4661,13 @@
|
|
|
3838
4661
|
input.value = handle.name || input.value;
|
|
3839
4662
|
input.dataset.verifiedPath = "";
|
|
3840
4663
|
}
|
|
3841
|
-
showError("
|
|
4664
|
+
showError(t("ws.pickerNoPath"));
|
|
3842
4665
|
})
|
|
3843
4666
|
.catch(function () {
|
|
3844
4667
|
/* user cancelled */
|
|
3845
4668
|
});
|
|
3846
4669
|
} else {
|
|
3847
|
-
showError("
|
|
4670
|
+
showError(t("ws.pickerUnsupported"));
|
|
3848
4671
|
}
|
|
3849
4672
|
});
|
|
3850
4673
|
}
|
|
@@ -3853,17 +4676,17 @@
|
|
|
3853
4676
|
apply.addEventListener("click", function () {
|
|
3854
4677
|
var value = input && typeof input.value === "string" ? input.value.trim() : "";
|
|
3855
4678
|
if (!value || value.indexOf("/") !== 0) {
|
|
3856
|
-
showError("
|
|
4679
|
+
showError(t("ws.needAbsolute"));
|
|
3857
4680
|
return;
|
|
3858
4681
|
}
|
|
3859
4682
|
apply.disabled = true;
|
|
3860
4683
|
apiPost("/workspace/change-dir", { workspaceDir: value }).then(function () {
|
|
3861
4684
|
localStorage.setItem(WORKSPACE_PROMPT_DISMISSED_KEY, "1");
|
|
3862
4685
|
closeWorkspacePromptModal();
|
|
3863
|
-
showError("
|
|
4686
|
+
showError(t("ctl.ws.saved"));
|
|
3864
4687
|
updateWorkspacePathIndicator();
|
|
3865
4688
|
}).catch(function (err) {
|
|
3866
|
-
showError(err instanceof Error ? err.message : "
|
|
4689
|
+
showError(err instanceof Error ? err.message : t("ctl.ws.failed"));
|
|
3867
4690
|
}).finally(function () {
|
|
3868
4691
|
apply.disabled = false;
|
|
3869
4692
|
});
|
|
@@ -3880,6 +4703,7 @@
|
|
|
3880
4703
|
promptWorkspaceIfDefault();
|
|
3881
4704
|
updateWorkspacePathIndicator();
|
|
3882
4705
|
bindTeamProfileModal();
|
|
4706
|
+
bindSecurityUi();
|
|
3883
4707
|
bindModelSettings();
|
|
3884
4708
|
bindGithubCorner();
|
|
3885
4709
|
|
|
@@ -3954,6 +4778,13 @@
|
|
|
3954
4778
|
modal.classList.add("open");
|
|
3955
4779
|
modal.setAttribute("aria-hidden", "false");
|
|
3956
4780
|
refreshTeamProfileModalData();
|
|
4781
|
+
// Role display editor renders from the /roles mirror + the saved prefs;
|
|
4782
|
+
// rendered on open (not on refreshAll) so an in-progress edit survives
|
|
4783
|
+
// background refreshes while the modal is open.
|
|
4784
|
+
renderRoleDisplayEditor();
|
|
4785
|
+
// Issue #23: the devices section lives at the bottom of this modal; it
|
|
4786
|
+
// re-renders on every refreshAll while the modal is open.
|
|
4787
|
+
renderSecurityDevices();
|
|
3957
4788
|
}
|
|
3958
4789
|
|
|
3959
4790
|
function closeTeamProfileModal() {
|
|
@@ -4270,6 +5101,15 @@
|
|
|
4270
5101
|
submitTeamProfileSwitch(pendingSwitchTarget.id);
|
|
4271
5102
|
});
|
|
4272
5103
|
}
|
|
5104
|
+
|
|
5105
|
+
var roleDisplaySave = $("#role-display-save");
|
|
5106
|
+
if (roleDisplaySave) {
|
|
5107
|
+
roleDisplaySave.addEventListener("click", saveRoleDisplayFromEditor);
|
|
5108
|
+
}
|
|
5109
|
+
var roleDisplayReset = $("#role-display-reset");
|
|
5110
|
+
if (roleDisplayReset) {
|
|
5111
|
+
roleDisplayReset.addEventListener("click", resetRoleDisplay);
|
|
5112
|
+
}
|
|
4273
5113
|
}
|
|
4274
5114
|
|
|
4275
5115
|
function bindModelSettings() {
|
|
@@ -4278,12 +5118,18 @@
|
|
|
4278
5118
|
opener.className = "btn btn-small";
|
|
4279
5119
|
opener.type = "button";
|
|
4280
5120
|
opener.id = "model-settings-open";
|
|
4281
|
-
|
|
5121
|
+
// data-i18n lets applyStaticTranslations refresh the label on language
|
|
5122
|
+
// switches (the same mechanism as the static header buttons).
|
|
5123
|
+
opener.setAttribute("data-i18n", "ctl.tab.models");
|
|
5124
|
+
opener.textContent = t("ctl.tab.models");
|
|
4282
5125
|
var refreshBtn = document.querySelector("#workspace-tree-refresh");
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
5126
|
+
// Settings tab (#hot-config): the models opener now lives in the Settings
|
|
5127
|
+
// tab slot instead of the workspace header (its old home raised "why is
|
|
5128
|
+
// models inside workspace"). Workspace fallback only if the slot is absent.
|
|
5129
|
+
var settingsSlot = document.querySelector("#settings-models-slot");
|
|
5130
|
+
var mount = settingsSlot || (refreshBtn && refreshBtn.parentElement) || document.body;
|
|
5131
|
+
mount.appendChild(opener);
|
|
5132
|
+
opener.addEventListener("click", openModelSettings);
|
|
4287
5133
|
|
|
4288
5134
|
var modal = document.querySelector("#model-settings-modal");
|
|
4289
5135
|
if (!modal || modal.dataset.bound === "true") return;
|
|
@@ -4315,10 +5161,10 @@
|
|
|
4315
5161
|
headers: { "Content-Type": "application/json" },
|
|
4316
5162
|
body: JSON.stringify(payload),
|
|
4317
5163
|
}).then(function () {
|
|
4318
|
-
showError("
|
|
5164
|
+
showError(t("ctl.models.saved"));
|
|
4319
5165
|
closeModelSettings();
|
|
4320
5166
|
}).catch(function (err) {
|
|
4321
|
-
showError(err instanceof Error ? err.message : "
|
|
5167
|
+
showError(err instanceof Error ? err.message : t("ctl.models.failed"));
|
|
4322
5168
|
}).finally(function () {
|
|
4323
5169
|
save.disabled = false;
|
|
4324
5170
|
});
|
|
@@ -4392,7 +5238,7 @@ function renderGithubCorner(status) {
|
|
|
4392
5238
|
loginBtn.hidden = true;
|
|
4393
5239
|
} else {
|
|
4394
5240
|
userChip.classList.add("hidden");
|
|
4395
|
-
loginBtn.textContent = t("gh.login");
|
|
5241
|
+
loginBtn.textContent = t("ctl.gh.login");
|
|
4396
5242
|
loginBtn.hidden = false;
|
|
4397
5243
|
}
|
|
4398
5244
|
}
|
|
@@ -4403,6 +5249,63 @@ function refreshGithubAuthStatus() {
|
|
|
4403
5249
|
});
|
|
4404
5250
|
}
|
|
4405
5251
|
|
|
5252
|
+
// Hot worker-provisioning config (#hot-config): renders into the Settings
|
|
5253
|
+
// tab's static form (#tab-settings). PATCH /team/config applies in-memory to
|
|
5254
|
+
// the running controller (no restart) and persists to the host openclaw.json
|
|
5255
|
+
// where the deployment shape allows it.
|
|
5256
|
+
var workerSettingsBound = false;
|
|
5257
|
+
function renderWorkerSettingsPanel() {
|
|
5258
|
+
var modal = document.getElementById("wk-save");
|
|
5259
|
+
if (!modal) return;
|
|
5260
|
+
apiRequest("/team/config").then(function (cfg) {
|
|
5261
|
+
if (cfg.workerProvisioningMaxPerRole != null) {
|
|
5262
|
+
var mx = document.getElementById("wk-max");
|
|
5263
|
+
if (mx) mx.value = cfg.workerProvisioningMaxPerRole;
|
|
5264
|
+
}
|
|
5265
|
+
if (cfg.workerProvisioningMinPerRole != null) {
|
|
5266
|
+
var mn = document.getElementById("wk-min");
|
|
5267
|
+
if (mn) mn.value = cfg.workerProvisioningMinPerRole;
|
|
5268
|
+
}
|
|
5269
|
+
if (cfg.workerProvisioningIdleTtlMs != null) {
|
|
5270
|
+
var ttl = document.getElementById("wk-ttl");
|
|
5271
|
+
if (ttl) ttl.value = cfg.workerProvisioningIdleTtlMs;
|
|
5272
|
+
}
|
|
5273
|
+
var mode = document.getElementById("wk-mode");
|
|
5274
|
+
if (mode) {
|
|
5275
|
+
mode.textContent = "provisioning: " + (cfg.workerProvisioningType || "process") +
|
|
5276
|
+
(cfg.persistenceMode === "memory-only" ? " | persistence: memory-only (restart reverts)" : " | persistence: host config");
|
|
5277
|
+
}
|
|
5278
|
+
}).catch(function (err) {
|
|
5279
|
+
var mode = document.getElementById("wk-mode");
|
|
5280
|
+
if (mode) mode.textContent = (err && err.message) || "load failed";
|
|
5281
|
+
});
|
|
5282
|
+
if (workerSettingsBound) return;
|
|
5283
|
+
workerSettingsBound = true;
|
|
5284
|
+
document.getElementById("wk-save").addEventListener("click", function () {
|
|
5285
|
+
var payload = {};
|
|
5286
|
+
var mxEl = document.getElementById("wk-max");
|
|
5287
|
+
var mnEl = document.getElementById("wk-min");
|
|
5288
|
+
var ttlEl = document.getElementById("wk-ttl");
|
|
5289
|
+
var mx = Number(mxEl && mxEl.value);
|
|
5290
|
+
var mn = Number(mnEl && mnEl.value);
|
|
5291
|
+
var ttl = Number(ttlEl && ttlEl.value);
|
|
5292
|
+
if (mxEl && mxEl.value !== "" && Number.isFinite(mx)) payload.workerProvisioningMaxPerRole = mx;
|
|
5293
|
+
if (mnEl && mnEl.value !== "" && Number.isFinite(mn)) payload.workerProvisioningMinPerRole = mn;
|
|
5294
|
+
if (ttlEl && ttlEl.value !== "" && Number.isFinite(ttl)) payload.workerProvisioningIdleTtlMs = ttl;
|
|
5295
|
+
if (!Object.keys(payload).length) return;
|
|
5296
|
+
var save = document.getElementById("wk-save");
|
|
5297
|
+
save.disabled = true;
|
|
5298
|
+
apiRequest("/team/config", { method: "PATCH", headers: { "Content-Type": "application/json" }, body: JSON.stringify(payload) })
|
|
5299
|
+
.then(function (out) {
|
|
5300
|
+
document.getElementById("wk-result").textContent = out && out.persisted === false ? "Applied (memory only)" : "Applied";
|
|
5301
|
+
})
|
|
5302
|
+
.catch(function (err) {
|
|
5303
|
+
document.getElementById("wk-result").textContent = (err && err.message) || "failed";
|
|
5304
|
+
})
|
|
5305
|
+
.finally(function () { save.disabled = false; });
|
|
5306
|
+
});
|
|
5307
|
+
}
|
|
5308
|
+
|
|
4406
5309
|
function openModelSettings() {
|
|
4407
5310
|
var modal = document.querySelector("#model-settings-modal");
|
|
4408
5311
|
if (!modal) return;
|
|
@@ -4413,11 +5316,11 @@ function openModelSettings() {
|
|
|
4413
5316
|
options.push({ value: provider.id + "/" + modelId, label: provider.id + " / " + modelId });
|
|
4414
5317
|
});
|
|
4415
5318
|
if (!provider.models || provider.models.length === 0) {
|
|
4416
|
-
options.push({ value: provider.id, label: provider.id + " (
|
|
5319
|
+
options.push({ value: provider.id, label: provider.id + " " + t("models.providerDefault") });
|
|
4417
5320
|
}
|
|
4418
5321
|
});
|
|
4419
5322
|
if (catalog.defaultModel && !options.some(function (opt) { return opt.value === catalog.defaultModel; })) {
|
|
4420
|
-
options.unshift({ value: catalog.defaultModel, label: catalog.defaultModel + " (current)
|
|
5323
|
+
options.unshift({ value: catalog.defaultModel, label: catalog.defaultModel + " " + t("models.current") });
|
|
4421
5324
|
}
|
|
4422
5325
|
|
|
4423
5326
|
var defaultSelect = document.querySelector("#model-settings-default");
|
|
@@ -4436,7 +5339,7 @@ function openModelSettings() {
|
|
|
4436
5339
|
'<label class="model-settings-field">' +
|
|
4437
5340
|
' <span class="model-settings-label">' + escapeHtml(role.label) + '</span>' +
|
|
4438
5341
|
' <select data-role-model="' + escapeHtml(role.id) + '">' +
|
|
4439
|
-
' <option value="">(
|
|
5342
|
+
' <option value="">' + escapeHtml(t("ctl.models.useDefault")) + '</option>' +
|
|
4440
5343
|
options.map(function (opt) {
|
|
4441
5344
|
return '<option value="' + escapeHtml(opt.value) + '"' + (current === opt.value ? " selected" : "") + '>' + escapeHtml(opt.label) + "</option>";
|
|
4442
5345
|
}).join("") +
|
|
@@ -4449,7 +5352,7 @@ function openModelSettings() {
|
|
|
4449
5352
|
modal.classList.add("open");
|
|
4450
5353
|
modal.setAttribute("aria-hidden", "false");
|
|
4451
5354
|
}).catch(function (err) {
|
|
4452
|
-
showError(err instanceof Error ? err.message : "
|
|
5355
|
+
showError(err instanceof Error ? err.message : t("models.loadFailed"));
|
|
4453
5356
|
});
|
|
4454
5357
|
}
|
|
4455
5358
|
|
|
@@ -4754,7 +5657,7 @@ function closeModelSettings() {
|
|
|
4754
5657
|
const host = (location.hostname || "").toLowerCase();
|
|
4755
5658
|
const isLocalView = host === "127.0.0.1" || host === "localhost" || host.endsWith(".local");
|
|
4756
5659
|
if (!isLocalView) {
|
|
4757
|
-
wrap.querySelector(".tunnel-state").innerHTML = '<span class="tunnel-note">
|
|
5660
|
+
wrap.querySelector(".tunnel-state").innerHTML = '<span class="tunnel-note">' + escapeHtml(t("tunnel.visitorNote")) + '</span>';
|
|
4758
5661
|
if (toggleBtn) toggleBtn.hidden = true;
|
|
4759
5662
|
return;
|
|
4760
5663
|
}
|
|
@@ -4771,62 +5674,76 @@ function closeModelSettings() {
|
|
|
4771
5674
|
}
|
|
4772
5675
|
}
|
|
4773
5676
|
var progress = st.startOp && st.startOp.running
|
|
4774
|
-
? '<div class="tunnel-note">
|
|
5677
|
+
? '<div class="tunnel-note">' + escapeHtml(t("ctl.tunnel.starting") + ": " + String(st.startOp.phase || "") + "…") + '</div>'
|
|
4775
5678
|
: (st.install && st.install.running
|
|
4776
|
-
? '<div class="tunnel-note">
|
|
5679
|
+
? '<div class="tunnel-note">' + escapeHtml(t("ctl.tunnel.installing") + " " + String(st.install.phase || "") + (st.install.percent != null ? " " + st.install.percent + "%" : "") + "…") + '</div>'
|
|
4777
5680
|
: '');
|
|
4778
5681
|
if (progress) { wrap.querySelector(".tunnel-state").innerHTML = progress; return; }
|
|
4779
5682
|
if (st.active && st.mode === "quick") {
|
|
4780
5683
|
wrap.querySelector(".tunnel-state").innerHTML =
|
|
4781
|
-
'<div class="tunnel-on">
|
|
4782
|
-
+ '<div class="tunnel-note">
|
|
4783
|
-
+ '<button class="btn btn-small" data-act="stop">
|
|
5684
|
+
'<div class="tunnel-on">' + escapeHtml(t("tunnel.quick") + ": ") + (st.hostname ? '<a href="https://' + st.hostname + '" target="_blank" rel="noopener">https://' + st.hostname + '</a>' : escapeHtml(t("tunnel.waitingUrl"))) + '</div>'
|
|
5685
|
+
+ '<div class="tunnel-note">' + escapeHtml(t("tunnel.quickNote")) + '</div>'
|
|
5686
|
+
+ '<button class="btn btn-small" data-act="stop">' + escapeHtml(t("ctl.tunnel.stop")) + '</button>';
|
|
4784
5687
|
return;
|
|
4785
5688
|
}
|
|
4786
5689
|
if (st.active && st.mode === "self-hosted") {
|
|
4787
5690
|
wrap.querySelector(".tunnel-state").innerHTML =
|
|
4788
|
-
'<div class="tunnel-on">
|
|
4789
|
-
+ '<div class="tunnel-note">
|
|
4790
|
-
+ '<button class="btn btn-small" data-act="stop">
|
|
5691
|
+
'<div class="tunnel-on">' + escapeHtml(t("tunnel.selfHostedLive")) + '</div>'
|
|
5692
|
+
+ '<div class="tunnel-note">' + escapeHtml(t("tunnel.selfHostedNote")) + '</div>'
|
|
5693
|
+
+ '<button class="btn btn-small" data-act="stop">' + escapeHtml(t("ctl.tunnel.stop")) + '</button>';
|
|
4791
5694
|
return;
|
|
4792
5695
|
}
|
|
4793
5696
|
if (st.active) {
|
|
5697
|
+
// Gate token label: shared with desktop via ctl.tunnel.gateToken
|
|
5698
|
+
// ("Gate token" / 门禁令牌), appended with a colon here.
|
|
4794
5699
|
wrap.querySelector(".tunnel-state").innerHTML =
|
|
4795
|
-
'<div class="tunnel-on">
|
|
4796
|
-
+ '<div class="tunnel-token">
|
|
4797
|
-
+ '<button class="btn btn-small" data-act="stop">
|
|
5700
|
+
'<div class="tunnel-on">' + escapeHtml(t("ctl.tunnel.live") + ": ") + '<a href="https://' + st.hostname + '" target="_blank" rel="noopener">https://' + st.hostname + '</a></div>'
|
|
5701
|
+
+ '<div class="tunnel-token">' + escapeHtml(t("ctl.tunnel.gateToken") + ": ") + '<b>' + st.gateToken + '</b> <button class="btn btn-small" data-act="copy-token">' + escapeHtml(t("action.copyToken")) + '</button></div>'
|
|
5702
|
+
+ '<button class="btn btn-small" data-act="stop">' + escapeHtml(t("ctl.tunnel.stop")) + '</button>';
|
|
4798
5703
|
return;
|
|
4799
5704
|
}
|
|
4800
5705
|
if (st.cloudflaredInstalled === false) {
|
|
4801
|
-
wrap.querySelector(".tunnel-state").innerHTML = '<div class="tunnel-note">
|
|
4802
|
-
+ '<button class="btn btn-small btn-primary" data-act="install">
|
|
5706
|
+
wrap.querySelector(".tunnel-state").innerHTML = '<div class="tunnel-note">' + escapeHtml(t("ctl.tunnel.notInstalled")) + '</div>'
|
|
5707
|
+
+ '<button class="btn btn-small btn-primary" data-act="install">' + escapeHtml(t("ctl.tunnel.install")) + '</button>';
|
|
4803
5708
|
return;
|
|
4804
5709
|
}
|
|
4805
5710
|
// Idle: self-hosted (env token detected -> one click; otherwise token
|
|
4806
5711
|
// input) alongside the managed share button.
|
|
4807
5712
|
var html = '';
|
|
4808
5713
|
if (st.envTokenDetected) {
|
|
4809
|
-
html += '<div class="tunnel-note">
|
|
4810
|
-
+ '<button class="btn btn-small btn-primary" data-act="start-self">
|
|
5714
|
+
html += '<div class="tunnel-note">' + escapeHtml(t("tunnel.envTokenReady")) + '</div>'
|
|
5715
|
+
+ '<button class="btn btn-small btn-primary" data-act="start-self">' + escapeHtml(t("tunnel.startSelf")) + '</button>';
|
|
4811
5716
|
} else {
|
|
4812
|
-
html += '<div class="tunnel-note">
|
|
4813
|
-
+ '<input type="password" class="tunnel-token-input" data-input="token" placeholder="
|
|
4814
|
-
+ '<button class="btn btn-small btn-primary" data-act="start-self-token">
|
|
4815
|
-
+ '<details class="tunnel-setup-help"><summary>
|
|
4816
|
-
+ '<div class="tunnel-note">
|
|
5717
|
+
html += '<div class="tunnel-note">' + escapeHtml(t("tunnel.selfHostedLabel")) + '</div>'
|
|
5718
|
+
+ '<input type="password" class="tunnel-token-input" data-input="token" placeholder="' + escapeHtml(t("tunnel.tokenPlaceholder")) + '" autocomplete="off">'
|
|
5719
|
+
+ '<button class="btn btn-small btn-primary" data-act="start-self-token">' + escapeHtml(t("tunnel.startSelf")) + '</button>'
|
|
5720
|
+
+ '<details class="tunnel-setup-help"><summary>' + escapeHtml(t("tunnel.setupHelp")) + '</summary>'
|
|
5721
|
+
+ '<div class="tunnel-note">' + escapeHtml(t("tunnel.setupHelpBody")) + '</div></details>';
|
|
4817
5722
|
}
|
|
4818
|
-
html += '<div class="tunnel-note"
|
|
4819
|
-
+ '<button class="btn btn-small" data-act="start">
|
|
4820
|
-
+ '<span class="tunnel-note">
|
|
4821
|
-
+ '<div class="tunnel-note"
|
|
4822
|
-
+ '<button class="btn btn-small" data-act="start-quick">
|
|
4823
|
-
+ '<div class="tunnel-note">
|
|
5723
|
+
html += '<div class="tunnel-note">' + escapeHtml(t("tunnel.or")) + '</div>'
|
|
5724
|
+
+ '<button class="btn btn-small" data-act="start">' + escapeHtml(t("ctl.tunnel.share")) + '</button>'
|
|
5725
|
+
+ '<span class="tunnel-note">' + escapeHtml(t("tunnel.requiresGithub")) + '</span>'
|
|
5726
|
+
+ '<div class="tunnel-note">' + escapeHtml(t("tunnel.or")) + '</div>'
|
|
5727
|
+
+ '<button class="btn btn-small" data-act="start-quick">' + escapeHtml(t("tunnel.startQuick")) + '</button>'
|
|
5728
|
+
+ '<div class="tunnel-note">' + escapeHtml(t("tunnel.quickDemoNote")) + '</div>';
|
|
4824
5729
|
wrap.querySelector(".tunnel-state").innerHTML = html;
|
|
4825
5730
|
};
|
|
4826
5731
|
const refresh = () => apiGet("/tunnel/status").then((st) => render(st || {})).catch(() => {});
|
|
4827
5732
|
wrap.addEventListener("click", (e) => {
|
|
4828
5733
|
const act = e.target.getAttribute && e.target.getAttribute("data-act");
|
|
4829
5734
|
if (!act) return;
|
|
5735
|
+
// Gate token copy (#237 review follow-up): handled before the generic
|
|
5736
|
+
// action dispatch below, which disables the button and expects an API
|
|
5737
|
+
// call. Reuses the copyText + action.copied feedback pattern of the
|
|
5738
|
+
// security pairing command copy.
|
|
5739
|
+
if (act === "copy-token") {
|
|
5740
|
+
const tokenEl = wrap.querySelector(".tunnel-token b");
|
|
5741
|
+
copyText(tokenEl ? tokenEl.textContent : "").then(() => {
|
|
5742
|
+
e.target.textContent = t("action.copied");
|
|
5743
|
+
setTimeout(() => { e.target.textContent = t("action.copyToken"); }, 1500);
|
|
5744
|
+
}).catch(() => {});
|
|
5745
|
+
return;
|
|
5746
|
+
}
|
|
4830
5747
|
e.target.disabled = true;
|
|
4831
5748
|
var call;
|
|
4832
5749
|
if (act === "start-quick") {
|
|
@@ -4836,7 +5753,7 @@ function closeModelSettings() {
|
|
|
4836
5753
|
if (act === "start-self-token") {
|
|
4837
5754
|
const input = wrap.querySelector('[data-input="token"]');
|
|
4838
5755
|
if (!input || !input.value.trim()) {
|
|
4839
|
-
wrap.querySelector(".tunnel-state").innerHTML = '<div class="tunnel-err">
|
|
5756
|
+
wrap.querySelector(".tunnel-state").innerHTML = '<div class="tunnel-err">' + escapeHtml(t("tunnel.needToken")) + '</div>';
|
|
4840
5757
|
return;
|
|
4841
5758
|
}
|
|
4842
5759
|
opts.body = JSON.stringify({ token: input.value.trim() });
|
|
@@ -4847,7 +5764,7 @@ function closeModelSettings() {
|
|
|
4847
5764
|
: act === "install" ? apiRequest("/tunnel/install-cloudflared", { method: "POST" })
|
|
4848
5765
|
: apiRequest("/tunnel/stop", { method: "POST" });
|
|
4849
5766
|
}
|
|
4850
|
-
call.then(refresh).catch((err) => { wrap.querySelector(".tunnel-state").innerHTML = '<div class="tunnel-err">' + escapeHtml(String(err.message || err)) + "</div>"; });
|
|
5767
|
+
call.then(refresh).catch((err) => { wrap.querySelector(".tunnel-state").innerHTML = '<div class="tunnel-err">' + escapeHtml(t("ctl.tunnel.actionFailed") + String(err.message || err)) + "</div>"; });
|
|
4851
5768
|
});
|
|
4852
5769
|
refresh();
|
|
4853
5770
|
setInterval(refresh, 5000);
|