@teamclaws/teamclaw 2026.11.0 → 2026.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.mjs +272 -2
- package/dist/index.js +54 -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/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 +67 -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/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/types.js +15 -1
- package/dist/src/ui/app.js +846 -62
- package/dist/src/ui/github-login.html +1 -0
- package/dist/src/ui/index.html +102 -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 +61 -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/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 +133 -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 +19 -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/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/scheduler.ts +2 -1
- package/src/types.ts +130 -1
- package/src/ui/app.js +846 -62
- package/src/ui/github-login.html +1 -0
- package/src/ui/index.html +102 -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,6 +70,7 @@
|
|
|
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",
|
|
@@ -151,7 +160,6 @@
|
|
|
151
160
|
"runtime.title": "TeamClaw is installed but cannot work yet.",
|
|
152
161
|
"runtime.noModel": "No TeamClaw model is configured for this instance.",
|
|
153
162
|
"runtime.noAuth": "No usable OpenClaw auth profile was found for TeamClaw.",
|
|
154
|
-
"gh.login": "Sign in with GitHub",
|
|
155
163
|
"teamauto.refreshRepos": "Refresh repos",
|
|
156
164
|
"teamauto.bind": "Bind",
|
|
157
165
|
"teamauto.bindStageVerify": "Verifying access",
|
|
@@ -234,7 +242,113 @@
|
|
|
234
242
|
"teamProfile.switchFailed": "Team profile switch to {name} failed",
|
|
235
243
|
"teamProfile.archivedTitle": "Archived teams",
|
|
236
244
|
"teamProfile.archivedEmpty": "No archived teams yet.",
|
|
237
|
-
"teamProfile.archivedTasks": "{n} tasks"
|
|
245
|
+
"teamProfile.archivedTasks": "{n} tasks",
|
|
246
|
+
"security.bannerTitle": "Device protection recommended",
|
|
247
|
+
"security.bannerHint": "External access was detected from outside your local network. Enable device pairing so only your paired devices can control this team.",
|
|
248
|
+
"security.enableAction": "Enable protection",
|
|
249
|
+
"security.pairTitle": "Pair your devices",
|
|
250
|
+
"security.pairHint": "This browser is paired automatically. To pair another device (worker, desktop or CLI), run this command within 60 seconds:",
|
|
251
|
+
"security.pairExpiresIn": "Expires in {n}s",
|
|
252
|
+
"security.pairExpired": "Pairing code expired - request a new one.",
|
|
253
|
+
"security.pairNewCode": "New pairing code",
|
|
254
|
+
"security.devicesTitle": "Device security",
|
|
255
|
+
"security.statusOn": "Protection enabled · {n} paired device(s)",
|
|
256
|
+
"security.statusOff": "Local mode · protection off",
|
|
257
|
+
"security.revoke": "Revoke",
|
|
258
|
+
"security.selfRevokeWarn": "Revoking this browser will sign it out; it must re-pair from the controller host.",
|
|
259
|
+
"security.selfRevoked": "This device was revoked. Re-pair it from the controller host.",
|
|
260
|
+
"security.resetAll": "Reset all devices",
|
|
261
|
+
"security.resetConfirm": "This revokes every paired device and returns the controller to unpaired local mode. Continue?",
|
|
262
|
+
"security.resetDone": "Device protection reset - the controller is back to local mode.",
|
|
263
|
+
"security.devicesUnavailable": "Device management needs a paired browser.",
|
|
264
|
+
"security.noDevices": "No paired devices yet.",
|
|
265
|
+
"workflow.sectionTitle": "Common workflows",
|
|
266
|
+
"workflow.stepsTooltip": "{n} steps · {roles}",
|
|
267
|
+
"workflow.started": "Workflow {name} started",
|
|
268
|
+
"workflow.startFailed": "Failed to start workflow - {reason}",
|
|
269
|
+
"workflow.badgeRound": "Round {n}",
|
|
270
|
+
"roleDisplay.title": "Role display",
|
|
271
|
+
"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.",
|
|
272
|
+
"roleDisplay.save": "Save",
|
|
273
|
+
"roleDisplay.reset": "Reset to defaults",
|
|
274
|
+
"roleDisplay.saved": "Role display settings saved",
|
|
275
|
+
"roleDisplay.resetDone": "Role display reset to the profile defaults",
|
|
276
|
+
// chore-web-i18n-migration: keys for previously hardcoded copy. ctl.*
|
|
277
|
+
// values are copied VERBATIM from desktop/renderer/i18n.js so both
|
|
278
|
+
// renderers resolve shared keys to identical strings (enforced by
|
|
279
|
+
// tests/test-i18n-parity.mjs); the rest are web-only surfaces.
|
|
280
|
+
"action.cancel": "Cancel",
|
|
281
|
+
"task.details": "Task details",
|
|
282
|
+
"task.timeline": "Timeline",
|
|
283
|
+
"task.messages": "Messages",
|
|
284
|
+
"command.placeholder": "Send a controller message or slash command... (e.g., 继续工作, /status, /assign task-id developer)",
|
|
285
|
+
"command.send": "Send to Controller",
|
|
286
|
+
"detail.taskId": "Task ID: {id}",
|
|
287
|
+
"detail.worker": "Worker: {id}",
|
|
288
|
+
"detail.role": "Role: {id}",
|
|
289
|
+
"header.toasts": "Toasts",
|
|
290
|
+
"header.tunnelLiveTitle": "Managed tunnel is live - open in a new tab",
|
|
291
|
+
"header.githubUserTitle": "GitHub: click to sign out",
|
|
292
|
+
"header.teamFallback": "Team",
|
|
293
|
+
"workspace.location": "Location",
|
|
294
|
+
"clarification.needAnswer": "Please provide an answer before submitting.",
|
|
295
|
+
"models.kicker": "Model settings",
|
|
296
|
+
"models.providerDefault": "(provider default)",
|
|
297
|
+
"models.current": "(current)",
|
|
298
|
+
"models.loadFailed": "Failed to load model catalog",
|
|
299
|
+
"ws.kicker": "Workspace setup",
|
|
300
|
+
"ws.browse": "Browse...",
|
|
301
|
+
"ws.keepDefault": "Keep default",
|
|
302
|
+
"ws.restartNote": "Applies after a gateway restart. Existing files are not moved automatically.",
|
|
303
|
+
"ws.unknown": "(unknown)",
|
|
304
|
+
"ws.pickerNoPath": "Browser directory picker cannot return full server paths; please type the absolute path instead.",
|
|
305
|
+
"ws.pickerUnsupported": "This browser does not support a native directory picker; please type the absolute path instead.",
|
|
306
|
+
"ws.needAbsolute": "Please enter an absolute path starting with /",
|
|
307
|
+
"tunnel.visitorNote": "This dashboard is shared via a TeamClaw tunnel.",
|
|
308
|
+
"tunnel.quick": "Quick tunnel",
|
|
309
|
+
"tunnel.waitingUrl": "waiting for URL…",
|
|
310
|
+
"tunnel.quickNote": "One-off URL - dies on restart. Anyone with the link can open the dashboard.",
|
|
311
|
+
"tunnel.selfHostedLive": "Self-hosted Cloudflare tunnel: live on your own domain",
|
|
312
|
+
"tunnel.selfHostedNote": "Public hostname is managed in your Cloudflare Zero Trust dashboard.",
|
|
313
|
+
"tunnel.envTokenReady": "Connector token detected via TEAMCLAW_TUNNEL_TOKEN — ready to start.",
|
|
314
|
+
"tunnel.startSelf": "Start self-hosted tunnel",
|
|
315
|
+
"tunnel.selfHostedLabel": "Self-hosted tunnel (your own Cloudflare account/domain):",
|
|
316
|
+
"tunnel.tokenPlaceholder": "Cloudflare connector token",
|
|
317
|
+
"tunnel.setupHelp": "How to get a token & set up the tunnel",
|
|
318
|
+
"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.",
|
|
319
|
+
"tunnel.or": "— or —",
|
|
320
|
+
"tunnel.requiresGithub": "requires GitHub login",
|
|
321
|
+
"tunnel.startQuick": "Anonymous one-off tunnel (trycloudflare.com)",
|
|
322
|
+
"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.",
|
|
323
|
+
"tunnel.needToken": "Paste a Cloudflare connector token first.",
|
|
324
|
+
"ctl.tab.models": "Models",
|
|
325
|
+
"ctl.tab.tunnel": "Tunnel",
|
|
326
|
+
"ctl.models.title": "Team models",
|
|
327
|
+
"ctl.models.hint": "Default model applies to the controller and every role; per-role selections override it for that role.",
|
|
328
|
+
"ctl.models.default": "Default model",
|
|
329
|
+
"ctl.models.useDefault": "(use default)",
|
|
330
|
+
"ctl.models.save": "Save models",
|
|
331
|
+
"ctl.models.saved": "Saved. Hot-reload applies; restart the gateway if needed.",
|
|
332
|
+
"ctl.models.failed": "Failed to save model settings",
|
|
333
|
+
"ctl.tunnel.title": "Internet tunnel",
|
|
334
|
+
"ctl.tunnel.share": "Share via tunnel",
|
|
335
|
+
"ctl.tunnel.stop": "Stop sharing",
|
|
336
|
+
"ctl.tunnel.install": "Install cloudflared",
|
|
337
|
+
"ctl.tunnel.loading": "Loading…",
|
|
338
|
+
"ctl.tunnel.starting": "Starting tunnel",
|
|
339
|
+
"ctl.tunnel.installing": "Installing cloudflared",
|
|
340
|
+
"ctl.tunnel.live": "Live",
|
|
341
|
+
"ctl.tunnel.gateToken": "Gate token",
|
|
342
|
+
"ctl.tunnel.notInstalled": "cloudflared connector is not installed on the controller machine.",
|
|
343
|
+
"ctl.tunnel.actionFailed": "Tunnel action failed: ",
|
|
344
|
+
"ctl.ws.title": "Workspace directory",
|
|
345
|
+
"ctl.ws.current": "Current:",
|
|
346
|
+
"ctl.ws.default": "default",
|
|
347
|
+
"ctl.ws.hint": "Point the team workspace at any absolute path on the controller machine. Applies after a gateway restart.",
|
|
348
|
+
"ctl.ws.apply": "Apply workspace",
|
|
349
|
+
"ctl.ws.saved": "Updated. Restart the gateway (openclaw gateway restart) to apply.",
|
|
350
|
+
"ctl.ws.failed": "Failed to update workspace",
|
|
351
|
+
"ctl.gh.login": "Sign in with GitHub"
|
|
238
352
|
},
|
|
239
353
|
zh: {
|
|
240
354
|
"action.refresh": "刷新",
|
|
@@ -242,6 +356,7 @@
|
|
|
242
356
|
"action.dismiss": "稍后处理",
|
|
243
357
|
"action.copyCommand": "复制命令",
|
|
244
358
|
"action.copied": "已复制",
|
|
359
|
+
"action.copyToken": "复制令牌",
|
|
245
360
|
"sidebar.workers": "成员",
|
|
246
361
|
"sidebar.roles": "角色",
|
|
247
362
|
"tab.planning": "规划",
|
|
@@ -331,7 +446,6 @@
|
|
|
331
446
|
"runtime.title": "TeamClaw 已安装,但当前还无法工作。",
|
|
332
447
|
"runtime.noModel": "当前实例还没有为 TeamClaw 配置模型。",
|
|
333
448
|
"runtime.noAuth": "未找到 TeamClaw 可用的 OpenClaw 认证配置。",
|
|
334
|
-
"gh.login": "使用 GitHub 登录",
|
|
335
449
|
"teamauto.refreshRepos": "刷新仓库",
|
|
336
450
|
"teamauto.bind": "绑定",
|
|
337
451
|
"teamauto.bindStageVerify": "验证访问权限",
|
|
@@ -414,7 +528,111 @@
|
|
|
414
528
|
"teamProfile.switchFailed": "切换到 {name} 的团队画像失败",
|
|
415
529
|
"teamProfile.archivedTitle": "已归档团队",
|
|
416
530
|
"teamProfile.archivedEmpty": "暂无已归档团队。",
|
|
417
|
-
"teamProfile.archivedTasks": "{n} 个任务"
|
|
531
|
+
"teamProfile.archivedTasks": "{n} 个任务",
|
|
532
|
+
"security.bannerTitle": "建议启用设备保护",
|
|
533
|
+
"security.bannerHint": "检测到来自局域网之外的外部访问。启用设备配对后,只有已配对的设备才能操作这个团队。",
|
|
534
|
+
"security.enableAction": "启用保护",
|
|
535
|
+
"security.pairTitle": "配对设备",
|
|
536
|
+
"security.pairHint": "本浏览器已自动配对。要在其他设备(worker、桌面端或 CLI)上配对,请在 60 秒内运行以下命令:",
|
|
537
|
+
"security.pairExpiresIn": "{n} 秒后失效",
|
|
538
|
+
"security.pairExpired": "配对码已过期 - 请生成新的配对码。",
|
|
539
|
+
"security.pairNewCode": "添加配对码",
|
|
540
|
+
"security.devicesTitle": "设备安全",
|
|
541
|
+
"security.statusOn": "保护已启用 · {n} 台设备",
|
|
542
|
+
"security.statusOff": "本机模式 · 未启用",
|
|
543
|
+
"security.revoke": "撤销",
|
|
544
|
+
"security.selfRevokeWarn": "撤销本浏览器会使它退出配对,需在 controller 主机上重新配对。",
|
|
545
|
+
"security.selfRevoked": "本设备已被撤销。请在 controller 主机上重新配对。",
|
|
546
|
+
"security.resetAll": "重置全部设备",
|
|
547
|
+
"security.resetConfirm": "这将撤销所有已配对设备,并让 controller 回到未保护的本机模式。继续?",
|
|
548
|
+
"security.resetDone": "设备保护已重置 - controller 已回到本机模式。",
|
|
549
|
+
"security.devicesUnavailable": "需要在已配对的浏览器中管理设备。",
|
|
550
|
+
"security.noDevices": "暂无已配对设备。",
|
|
551
|
+
"workflow.sectionTitle": "常用工作流",
|
|
552
|
+
"workflow.stepsTooltip": "{n} 步 · {roles}",
|
|
553
|
+
"workflow.started": "工作流「{name}」已启动",
|
|
554
|
+
"workflow.startFailed": "启动工作流失败 - {reason}",
|
|
555
|
+
"workflow.badgeRound": "第{n}轮",
|
|
556
|
+
"roleDisplay.title": "角色显示",
|
|
557
|
+
"roleDisplay.hint": "隐藏本团队用不到的角色,或改成本团队的叫法。仅保存在此浏览器(纯显示层)——不修改团队画像本身。“团队模型”面板始终列出全部角色(模型覆盖保存在服务端),此处隐藏不会将其移除。",
|
|
558
|
+
"roleDisplay.save": "保存",
|
|
559
|
+
"roleDisplay.reset": "恢复默认",
|
|
560
|
+
"roleDisplay.saved": "角色显示设置已保存",
|
|
561
|
+
"roleDisplay.resetDone": "角色显示已恢复画像默认",
|
|
562
|
+
// chore-web-i18n-migration: ctl.* 值从 desktop/renderer/i18n.js 原样
|
|
563
|
+
// 复制,双端共享键必须逐字一致(tests/test-i18n-parity.mjs 强制)。
|
|
564
|
+
"action.cancel": "取消",
|
|
565
|
+
"task.details": "任务详情",
|
|
566
|
+
"task.timeline": "时间线",
|
|
567
|
+
"task.messages": "消息",
|
|
568
|
+
"command.placeholder": "发送 controller 消息或斜杠命令...(例如:继续工作、/status、/assign task-id developer)",
|
|
569
|
+
"command.send": "发送给 Controller",
|
|
570
|
+
"detail.taskId": "任务 ID:{id}",
|
|
571
|
+
"detail.worker": "Worker:{id}",
|
|
572
|
+
"detail.role": "角色:{id}",
|
|
573
|
+
"header.toasts": "通知",
|
|
574
|
+
"header.tunnelLiveTitle": "托管隧道已开启 - 在新标签页打开",
|
|
575
|
+
"header.githubUserTitle": "GitHub:点击退出登录",
|
|
576
|
+
"header.teamFallback": "团队",
|
|
577
|
+
"workspace.location": "位置",
|
|
578
|
+
"clarification.needAnswer": "提交前请先填写回答。",
|
|
579
|
+
"models.kicker": "模型设置",
|
|
580
|
+
"models.providerDefault": "(提供商默认)",
|
|
581
|
+
"models.current": "(当前)",
|
|
582
|
+
"models.loadFailed": "加载模型目录失败",
|
|
583
|
+
"ws.kicker": "工作区设置",
|
|
584
|
+
"ws.browse": "浏览...",
|
|
585
|
+
"ws.keepDefault": "保留默认",
|
|
586
|
+
"ws.restartNote": "重启网关后生效。已有文件不会自动移动。",
|
|
587
|
+
"ws.unknown": "(未知)",
|
|
588
|
+
"ws.pickerNoPath": "浏览器目录选择器无法返回服务器端完整路径;请直接输入绝对路径。",
|
|
589
|
+
"ws.pickerUnsupported": "此浏览器不支持原生目录选择器;请直接输入绝对路径。",
|
|
590
|
+
"ws.needAbsolute": "请输入以 / 开头的绝对路径",
|
|
591
|
+
"tunnel.visitorNote": "本仪表盘通过 TeamClaw 隧道分享。",
|
|
592
|
+
"tunnel.quick": "快速隧道",
|
|
593
|
+
"tunnel.waitingUrl": "等待 URL 中…",
|
|
594
|
+
"tunnel.quickNote": "一次性 URL,重启即失效。任何拿到链接的人都能打开仪表盘。",
|
|
595
|
+
"tunnel.selfHostedLive": "自托管 Cloudflare 隧道:已在自己的域名上运行",
|
|
596
|
+
"tunnel.selfHostedNote": "公共域名在你的 Cloudflare Zero Trust 控制台中管理。",
|
|
597
|
+
"tunnel.envTokenReady": "检测到 TEAMCLAW_TUNNEL_TOKEN 连接器令牌——可随时启动。",
|
|
598
|
+
"tunnel.startSelf": "启动自托管隧道",
|
|
599
|
+
"tunnel.selfHostedLabel": "自托管隧道(你自己的 Cloudflare 账号/域名):",
|
|
600
|
+
"tunnel.tokenPlaceholder": "Cloudflare 连接器令牌",
|
|
601
|
+
"tunnel.setupHelp": "如何获取令牌并配置隧道",
|
|
602
|
+
"tunnel.setupHelpBody": "Cloudflare Zero Trust → 网络(Networks)→ Tunnels → 你的隧道 → 复制令牌。将其公共域名指向本机 URL(Service:HTTP + 文档中所示的控制器端口)。建议用 Cloudflare Access 保护——自托管域名不走 TeamClaw 门禁。",
|
|
603
|
+
"tunnel.or": "— 或 —",
|
|
604
|
+
"tunnel.requiresGithub": "需要 GitHub 登录",
|
|
605
|
+
"tunnel.startQuick": "匿名一次性隧道(trycloudflare.com)",
|
|
606
|
+
"tunnel.quickDemoNote": "无需账号。随机 URL,重启即失效,任何拿到链接的人都能打开仪表盘——仅用于快速演示。需要 cloudflared 二进制。",
|
|
607
|
+
"tunnel.needToken": "请先粘贴 Cloudflare 连接器令牌。",
|
|
608
|
+
"ctl.tab.models": "模型",
|
|
609
|
+
"ctl.tab.tunnel": "隧道",
|
|
610
|
+
"ctl.models.title": "团队模型",
|
|
611
|
+
"ctl.models.hint": "默认模型作用于控制器与所有角色;按角色的选择会覆盖默认值。",
|
|
612
|
+
"ctl.models.default": "默认模型",
|
|
613
|
+
"ctl.models.useDefault": "(跟随默认)",
|
|
614
|
+
"ctl.models.save": "保存模型",
|
|
615
|
+
"ctl.models.saved": "已保存。配置热重载生效;如未生效请重启网关。",
|
|
616
|
+
"ctl.models.failed": "保存模型设置失败",
|
|
617
|
+
"ctl.tunnel.title": "互联网隧道",
|
|
618
|
+
"ctl.tunnel.share": "通过隧道分享",
|
|
619
|
+
"ctl.tunnel.stop": "停止分享",
|
|
620
|
+
"ctl.tunnel.install": "安装 cloudflared",
|
|
621
|
+
"ctl.tunnel.loading": "加载中…",
|
|
622
|
+
"ctl.tunnel.starting": "正在启动隧道",
|
|
623
|
+
"ctl.tunnel.installing": "正在安装 cloudflared",
|
|
624
|
+
"ctl.tunnel.live": "在线",
|
|
625
|
+
"ctl.tunnel.gateToken": "门禁令牌",
|
|
626
|
+
"ctl.tunnel.notInstalled": "控制器机器上尚未安装 cloudflared 连接器。",
|
|
627
|
+
"ctl.tunnel.actionFailed": "隧道操作失败:",
|
|
628
|
+
"ctl.ws.title": "工作区目录",
|
|
629
|
+
"ctl.ws.current": "当前:",
|
|
630
|
+
"ctl.ws.default": "默认",
|
|
631
|
+
"ctl.ws.hint": "可将团队工作区指向控制器机器上的任意绝对路径。需重启网关后生效。",
|
|
632
|
+
"ctl.ws.apply": "应用工作区",
|
|
633
|
+
"ctl.ws.saved": "已更新。请重启网关(openclaw gateway restart)后生效。",
|
|
634
|
+
"ctl.ws.failed": "更新工作区失败",
|
|
635
|
+
"ctl.gh.login": "使用 GitHub 登录"
|
|
418
636
|
}
|
|
419
637
|
};
|
|
420
638
|
|
|
@@ -460,6 +678,18 @@
|
|
|
460
678
|
element.setAttribute("placeholder", t(key));
|
|
461
679
|
}
|
|
462
680
|
});
|
|
681
|
+
$$("[data-i18n-title]").forEach(function (element) {
|
|
682
|
+
var key = element.getAttribute("data-i18n-title");
|
|
683
|
+
if (key) {
|
|
684
|
+
element.setAttribute("title", t(key));
|
|
685
|
+
}
|
|
686
|
+
});
|
|
687
|
+
$$("[data-i18n-aria]").forEach(function (element) {
|
|
688
|
+
var key = element.getAttribute("data-i18n-aria");
|
|
689
|
+
if (key) {
|
|
690
|
+
element.setAttribute("aria-label", t(key));
|
|
691
|
+
}
|
|
692
|
+
});
|
|
463
693
|
var languageToggle = $("#language-toggle");
|
|
464
694
|
if (languageToggle) {
|
|
465
695
|
languageToggle.textContent = currentLanguage === "zh" ? "English" : "中文";
|
|
@@ -1716,9 +1946,15 @@
|
|
|
1716
1946
|
}
|
|
1717
1947
|
|
|
1718
1948
|
if (!res.ok) {
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1949
|
+
// Issue #23 review follow-up: surface the backend's actionable `hint`
|
|
1950
|
+
// alongside the error code (e.g. a remote browser clicking "Enable
|
|
1951
|
+
// protection" gets the full loopback-only explanation, not a bare
|
|
1952
|
+
// "forbidden"). Same error+hint join as the CLI's describeSecurityError.
|
|
1953
|
+
const parts = [];
|
|
1954
|
+
const code = data && typeof (data.error || data.message) === "string" ? (data.error || data.message) : "";
|
|
1955
|
+
if (code) parts.push(code);
|
|
1956
|
+
if (data && typeof data.hint === "string" && data.hint.trim()) parts.push(data.hint.trim());
|
|
1957
|
+
const message = parts.length ? parts.join(" - ") : ("Request failed: " + res.status);
|
|
1722
1958
|
throw new Error(message);
|
|
1723
1959
|
}
|
|
1724
1960
|
|
|
@@ -2076,6 +2312,273 @@
|
|
|
2076
2312
|
);
|
|
2077
2313
|
}
|
|
2078
2314
|
|
|
2315
|
+
// =========================================================================
|
|
2316
|
+
// Device pairing security (issue #23, client wave) - zero friction by
|
|
2317
|
+
// design: this browser NEVER logs in (the loopback enable call sets the
|
|
2318
|
+
// HttpOnly session cookie), the banner only appears when the backend
|
|
2319
|
+
// observed a non-LAN peer while protection is off, and the pairing modal
|
|
2320
|
+
// shows a one-shot 60s code plus the copyable CLI command for the FIRST
|
|
2321
|
+
// external device.
|
|
2322
|
+
// =========================================================================
|
|
2323
|
+
|
|
2324
|
+
function renderSecurityBanner() {
|
|
2325
|
+
var banner = $("#security-suggest-banner");
|
|
2326
|
+
if (!banner) return;
|
|
2327
|
+
var suggested = Boolean(securityStatus && securityStatus.suggested && !securityStatus.protection);
|
|
2328
|
+
if (!suggested) {
|
|
2329
|
+
banner.hidden = true;
|
|
2330
|
+
banner.innerHTML = "";
|
|
2331
|
+
return;
|
|
2332
|
+
}
|
|
2333
|
+
banner.hidden = false;
|
|
2334
|
+
banner.innerHTML = (
|
|
2335
|
+
"<div style='display:flex;gap:12px;align-items:center;flex-wrap:wrap'>" +
|
|
2336
|
+
"<div style='flex:1;min-width:220px'>" +
|
|
2337
|
+
"<strong>" + escapeHtml(t("security.bannerTitle")) + "</strong> " +
|
|
2338
|
+
escapeHtml(t("security.bannerHint")) +
|
|
2339
|
+
"</div>" +
|
|
2340
|
+
"<button id='security-enable-btn' class='btn btn-primary btn-small' type='button'>" +
|
|
2341
|
+
escapeHtml(t("security.enableAction")) +
|
|
2342
|
+
"</button>" +
|
|
2343
|
+
"</div>"
|
|
2344
|
+
);
|
|
2345
|
+
var enableBtn = $("#security-enable-btn");
|
|
2346
|
+
if (enableBtn) {
|
|
2347
|
+
enableBtn.addEventListener("click", function () {
|
|
2348
|
+
enableBtn.disabled = true;
|
|
2349
|
+
enableProtection();
|
|
2350
|
+
});
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
|
|
2354
|
+
function enableProtection() {
|
|
2355
|
+
// Same-origin fetch carries the loopback enable's session cookie
|
|
2356
|
+
// automatically; the response body never contains the token.
|
|
2357
|
+
apiPost("/security/enable", {})
|
|
2358
|
+
.then(function (data) {
|
|
2359
|
+
securityStatus = { protection: true, suggested: false, deviceCount: 1 };
|
|
2360
|
+
renderSecurityBanner();
|
|
2361
|
+
if (data && data.pairingCode && data.pairingCode.code) {
|
|
2362
|
+
openSecurityPairModal(data.pairingCode.code, data.pairingCode.expiresAt || 0);
|
|
2363
|
+
}
|
|
2364
|
+
refreshAll();
|
|
2365
|
+
})
|
|
2366
|
+
.catch(function (err) {
|
|
2367
|
+
showError(err instanceof Error ? err.message : "Failed to enable device protection");
|
|
2368
|
+
renderSecurityBanner();
|
|
2369
|
+
});
|
|
2370
|
+
}
|
|
2371
|
+
|
|
2372
|
+
function securityPairCommand(code) {
|
|
2373
|
+
// Controller URL is this page's own origin - the console browser IS the
|
|
2374
|
+
// machine-name source of truth for the CLI command it hands out.
|
|
2375
|
+
return "npx @teamclaws/teamclaw pair " + window.location.origin + " --code " + code;
|
|
2376
|
+
}
|
|
2377
|
+
|
|
2378
|
+
function openSecurityPairModal(code, expiresAt) {
|
|
2379
|
+
var modal = $("#security-pair-modal");
|
|
2380
|
+
if (!modal) return;
|
|
2381
|
+
renderSecurityPairCode(code, expiresAt);
|
|
2382
|
+
modal.classList.add("open");
|
|
2383
|
+
modal.setAttribute("aria-hidden", "false");
|
|
2384
|
+
}
|
|
2385
|
+
|
|
2386
|
+
function closeSecurityPairModal() {
|
|
2387
|
+
var modal = $("#security-pair-modal");
|
|
2388
|
+
if (!modal) return;
|
|
2389
|
+
modal.classList.remove("open");
|
|
2390
|
+
modal.setAttribute("aria-hidden", "true");
|
|
2391
|
+
stopSecurityPairTimer();
|
|
2392
|
+
}
|
|
2393
|
+
|
|
2394
|
+
function stopSecurityPairTimer() {
|
|
2395
|
+
if (securityPairTimer) {
|
|
2396
|
+
clearInterval(securityPairTimer);
|
|
2397
|
+
securityPairTimer = null;
|
|
2398
|
+
}
|
|
2399
|
+
}
|
|
2400
|
+
|
|
2401
|
+
function renderSecurityPairCode(code, expiresAt) {
|
|
2402
|
+
var codeEl = $("#security-pair-code");
|
|
2403
|
+
var countdownEl = $("#security-pair-countdown");
|
|
2404
|
+
var commandEl = $("#security-pair-command");
|
|
2405
|
+
if (!codeEl || !countdownEl || !commandEl) return;
|
|
2406
|
+
codeEl.textContent = code || "";
|
|
2407
|
+
commandEl.textContent = securityPairCommand(code || "");
|
|
2408
|
+
stopSecurityPairTimer();
|
|
2409
|
+
securityPairingExpiresAt = expiresAt || (Date.now() + 60_000);
|
|
2410
|
+
var tick = function () {
|
|
2411
|
+
var remaining = Math.max(0, Math.ceil((securityPairingExpiresAt - Date.now()) / 1000));
|
|
2412
|
+
if (remaining <= 0) {
|
|
2413
|
+
countdownEl.textContent = t("security.pairExpired");
|
|
2414
|
+
stopSecurityPairTimer();
|
|
2415
|
+
return;
|
|
2416
|
+
}
|
|
2417
|
+
countdownEl.textContent = t("security.pairExpiresIn", { n: remaining });
|
|
2418
|
+
};
|
|
2419
|
+
tick();
|
|
2420
|
+
securityPairTimer = setInterval(tick, 1000);
|
|
2421
|
+
}
|
|
2422
|
+
|
|
2423
|
+
function requestSecurityPairCode() {
|
|
2424
|
+
// A new code invalidates the previous one by replacement (backend
|
|
2425
|
+
// semantics); the console browser may mint one because its session
|
|
2426
|
+
// cookie authenticates it (or it is the loopback console).
|
|
2427
|
+
apiPost("/security/pair/start", {})
|
|
2428
|
+
.then(function (data) {
|
|
2429
|
+
if (data && data.pairingCode && data.pairingCode.code) {
|
|
2430
|
+
var modal = $("#security-pair-modal");
|
|
2431
|
+
if (modal && !modal.classList.contains("open")) {
|
|
2432
|
+
openSecurityPairModal(data.pairingCode.code, data.pairingCode.expiresAt || 0);
|
|
2433
|
+
} else {
|
|
2434
|
+
renderSecurityPairCode(data.pairingCode.code, data.pairingCode.expiresAt || 0);
|
|
2435
|
+
}
|
|
2436
|
+
}
|
|
2437
|
+
})
|
|
2438
|
+
.catch(function (err) {
|
|
2439
|
+
showError(err instanceof Error ? err.message : "Failed to issue a pairing code");
|
|
2440
|
+
});
|
|
2441
|
+
}
|
|
2442
|
+
|
|
2443
|
+
function securityDeviceKindIcon(kind) {
|
|
2444
|
+
var icons = { web: "\uD83C\uDF10", worker: "\u2699\uFE0F", desktop: "\uD83D\uDDA5\uFE0F", cli: "\u2328\uFE0F" };
|
|
2445
|
+
return icons[kind] || "\uD83D\uDD11";
|
|
2446
|
+
}
|
|
2447
|
+
|
|
2448
|
+
function securityDeviceSeenLabel(device) {
|
|
2449
|
+
if (!device || typeof device.lastSeenAt !== "number" || !device.lastSeenAt) {
|
|
2450
|
+
return "";
|
|
2451
|
+
}
|
|
2452
|
+
try {
|
|
2453
|
+
return new Date(device.lastSeenAt).toLocaleString(currentLanguage === "zh" ? "zh-CN" : "en");
|
|
2454
|
+
} catch (_err) {
|
|
2455
|
+
return "";
|
|
2456
|
+
}
|
|
2457
|
+
}
|
|
2458
|
+
|
|
2459
|
+
function renderSecurityDevices() {
|
|
2460
|
+
var statusEl = $("#security-devices-status");
|
|
2461
|
+
var listEl = $("#security-devices-list");
|
|
2462
|
+
var actionsEl = $("#security-devices-actions");
|
|
2463
|
+
if (!statusEl || !listEl || !actionsEl) return;
|
|
2464
|
+
var protection = Boolean(securityStatus && securityStatus.protection);
|
|
2465
|
+
statusEl.textContent = protection
|
|
2466
|
+
? t("security.statusOn", { n: (securityStatus && securityStatus.deviceCount) || 0 })
|
|
2467
|
+
: t("security.statusOff");
|
|
2468
|
+
if (!protection) {
|
|
2469
|
+
listEl.innerHTML = "";
|
|
2470
|
+
actionsEl.innerHTML = "";
|
|
2471
|
+
return;
|
|
2472
|
+
}
|
|
2473
|
+
// GET /security requires a paired caller (this browser's cookie). An
|
|
2474
|
+
// unpaired browser keeps the status line and gets the manage-elsewhere
|
|
2475
|
+
// note instead of a device list.
|
|
2476
|
+
apiGet("/security")
|
|
2477
|
+
.then(function (data) {
|
|
2478
|
+
var devices = (data && Array.isArray(data.devices)) ? data.devices : [];
|
|
2479
|
+
if (!devices.length) {
|
|
2480
|
+
listEl.innerHTML = '<div class="empty-state">' + escapeHtml(t("security.noDevices")) + "</div>";
|
|
2481
|
+
} else {
|
|
2482
|
+
listEl.innerHTML = devices.map(function (device) {
|
|
2483
|
+
var seen = securityDeviceSeenLabel(device);
|
|
2484
|
+
return (
|
|
2485
|
+
'<div class="team-profile-archive-row" data-security-device="' + escapeHtml(device.id) + '">' +
|
|
2486
|
+
"<span>" + securityDeviceKindIcon(device.kind) + " <strong>" + escapeHtml(device.name || device.id) + "</strong>" +
|
|
2487
|
+
' <small style="opacity:.65">(' + escapeHtml(device.kind || "") + ")</small></span>" +
|
|
2488
|
+
"<span style='opacity:.75'>" + (seen ? escapeHtml(seen) : "") + "</span>" +
|
|
2489
|
+
'<button class="btn btn-small" type="button" data-security-revoke="' + escapeHtml(device.id) + '"' +
|
|
2490
|
+
(device.kind === "web" ? ' title="' + escapeHtml(t("security.selfRevokeWarn")) + '"' : "") + ">" +
|
|
2491
|
+
escapeHtml(t("security.revoke")) +
|
|
2492
|
+
"</button>" +
|
|
2493
|
+
"</div>"
|
|
2494
|
+
);
|
|
2495
|
+
}).join("");
|
|
2496
|
+
listEl.querySelectorAll("[data-security-revoke]").forEach(function (btn) {
|
|
2497
|
+
btn.addEventListener("click", function () {
|
|
2498
|
+
revokeSecurityDevice(btn.getAttribute("data-security-revoke") || "");
|
|
2499
|
+
});
|
|
2500
|
+
});
|
|
2501
|
+
}
|
|
2502
|
+
actionsEl.innerHTML =
|
|
2503
|
+
'<button id="security-reset-btn" class="btn btn-small" type="button">' + escapeHtml(t("security.resetAll")) + "</button> " +
|
|
2504
|
+
'<button id="security-new-code-btn" class="btn btn-small" type="button">' + escapeHtml(t("security.pairNewCode")) + "</button>";
|
|
2505
|
+
var resetBtn = $("#security-reset-btn");
|
|
2506
|
+
if (resetBtn) {
|
|
2507
|
+
resetBtn.addEventListener("click", resetSecurityProtection);
|
|
2508
|
+
}
|
|
2509
|
+
var newCodeBtn = $("#security-new-code-btn");
|
|
2510
|
+
if (newCodeBtn) {
|
|
2511
|
+
newCodeBtn.addEventListener("click", requestSecurityPairCode);
|
|
2512
|
+
}
|
|
2513
|
+
})
|
|
2514
|
+
.catch(function () {
|
|
2515
|
+
listEl.innerHTML = '<div class="empty-state">' + escapeHtml(t("security.devicesUnavailable")) + "</div>";
|
|
2516
|
+
actionsEl.innerHTML =
|
|
2517
|
+
'<button id="security-new-code-btn" class="btn btn-small" type="button">' + escapeHtml(t("security.pairNewCode")) + "</button>";
|
|
2518
|
+
var fallbackNewCode = $("#security-new-code-btn");
|
|
2519
|
+
if (fallbackNewCode) {
|
|
2520
|
+
fallbackNewCode.addEventListener("click", requestSecurityPairCode);
|
|
2521
|
+
}
|
|
2522
|
+
});
|
|
2523
|
+
}
|
|
2524
|
+
|
|
2525
|
+
function revokeSecurityDevice(deviceId) {
|
|
2526
|
+
if (!deviceId) return;
|
|
2527
|
+
apiRequest("/security/devices/" + encodeURIComponent(deviceId), { method: "DELETE" })
|
|
2528
|
+
.then(function (data) {
|
|
2529
|
+
if (data && data.revokedSelf) {
|
|
2530
|
+
// This browser just unpaired itself: every later API call will be
|
|
2531
|
+
// 401 until it re-pairs from the controller host.
|
|
2532
|
+
showError(t("security.selfRevoked"));
|
|
2533
|
+
}
|
|
2534
|
+
renderSecurityDevices();
|
|
2535
|
+
refreshAll();
|
|
2536
|
+
})
|
|
2537
|
+
.catch(function (err) {
|
|
2538
|
+
showError(err instanceof Error ? err.message : "Failed to revoke device");
|
|
2539
|
+
});
|
|
2540
|
+
}
|
|
2541
|
+
|
|
2542
|
+
function resetSecurityProtection() {
|
|
2543
|
+
if (!window.confirm(t("security.resetConfirm"))) return;
|
|
2544
|
+
apiPost("/security/reset", {})
|
|
2545
|
+
.then(function () {
|
|
2546
|
+
showError(t("security.resetDone"));
|
|
2547
|
+
renderSecurityDevices();
|
|
2548
|
+
refreshAll();
|
|
2549
|
+
})
|
|
2550
|
+
.catch(function (err) {
|
|
2551
|
+
showError(err instanceof Error ? err.message : "Failed to reset device protection");
|
|
2552
|
+
});
|
|
2553
|
+
}
|
|
2554
|
+
|
|
2555
|
+
function bindSecurityUi() {
|
|
2556
|
+
var pairModal = $("#security-pair-modal");
|
|
2557
|
+
if (pairModal && !pairModal.dataset.bound) {
|
|
2558
|
+
pairModal.dataset.bound = "true";
|
|
2559
|
+
pairModal.addEventListener("click", function (event) {
|
|
2560
|
+
if (event.target && event.target.hasAttribute && event.target.hasAttribute("data-security-pair-close")) {
|
|
2561
|
+
closeSecurityPairModal();
|
|
2562
|
+
}
|
|
2563
|
+
});
|
|
2564
|
+
var copyBtn = $("#security-pair-copy");
|
|
2565
|
+
if (copyBtn) {
|
|
2566
|
+
copyBtn.addEventListener("click", function () {
|
|
2567
|
+
var commandEl = $("#security-pair-command");
|
|
2568
|
+
if (!commandEl || !commandEl.textContent) return;
|
|
2569
|
+
copyText(commandEl.textContent).then(function () {
|
|
2570
|
+
copyBtn.textContent = t("action.copied");
|
|
2571
|
+
setTimeout(function () { copyBtn.textContent = t("action.copyCommand"); }, 1500);
|
|
2572
|
+
}).catch(function () {});
|
|
2573
|
+
});
|
|
2574
|
+
}
|
|
2575
|
+
var newCodeBtn = $("#security-pair-new");
|
|
2576
|
+
if (newCodeBtn) {
|
|
2577
|
+
newCodeBtn.addEventListener("click", requestSecurityPairCode);
|
|
2578
|
+
}
|
|
2579
|
+
}
|
|
2580
|
+
}
|
|
2581
|
+
|
|
2079
2582
|
function renderExternalWorkerInstallToggle() {
|
|
2080
2583
|
var button = $("#worker-install-toggle");
|
|
2081
2584
|
if (!button) return;
|
|
@@ -2102,7 +2605,7 @@
|
|
|
2102
2605
|
card.classList.add("hidden");
|
|
2103
2606
|
return;
|
|
2104
2607
|
}
|
|
2105
|
-
var roles = Array.isArray(info.roles) ? info.roles : [];
|
|
2608
|
+
var roles = visibleRoles(Array.isArray(info.roles) ? info.roles : []);
|
|
2106
2609
|
if (!roles.length) {
|
|
2107
2610
|
card.classList.add("hidden");
|
|
2108
2611
|
card.innerHTML = "";
|
|
@@ -2116,7 +2619,7 @@
|
|
|
2116
2619
|
}
|
|
2117
2620
|
var roleOptions = roles.map(function (role) {
|
|
2118
2621
|
return '<option value="' + escapeHtml(role.id) + '"' + (role.id === selectedExternalWorkerRole ? " selected" : "") + ">" +
|
|
2119
|
-
escapeHtml((role.icon ? role.icon + " " : "") + (role
|
|
2622
|
+
escapeHtml((role.icon ? role.icon + " " : "") + roleDisplayLabel(role)) +
|
|
2120
2623
|
"</option>";
|
|
2121
2624
|
}).join("");
|
|
2122
2625
|
var command = buildExternalWorkerCommand(info, selectedExternalWorkerRole, selectedExternalWorkerDiscoveryMode);
|
|
@@ -2458,6 +2961,15 @@
|
|
|
2458
2961
|
externalWorkerInstall: statusRes.externalWorkerInstall || null,
|
|
2459
2962
|
};
|
|
2460
2963
|
|
|
2964
|
+
// Issue #23: the /team/status `security` object drives the suggestion
|
|
2965
|
+
// banner (protection off + non-LAN peer observed) and the device
|
|
2966
|
+
// section status line. Absent on older controllers => null => hidden.
|
|
2967
|
+
securityStatus = statusRes.security || null;
|
|
2968
|
+
renderSecurityBanner();
|
|
2969
|
+
if (($("#team-profile-modal") || {}).classList?.contains("open")) {
|
|
2970
|
+
renderSecurityDevices();
|
|
2971
|
+
}
|
|
2972
|
+
|
|
2461
2973
|
// Active team profile (Phase 5.1): drives the header indicator, the
|
|
2462
2974
|
// capability-gated tab visibility, and the switch transition notice.
|
|
2463
2975
|
// Tolerated like /roles - an older controller without the endpoint
|
|
@@ -2474,6 +2986,10 @@
|
|
|
2474
2986
|
reconcileTeamProfileSwitch();
|
|
2475
2987
|
}
|
|
2476
2988
|
|
|
2989
|
+
// Workflow quick actions + running badges read the same profile mirror:
|
|
2990
|
+
// unguarded so a failed/absent fetch re-hides the launcher cleanly.
|
|
2991
|
+
renderWorkflowLauncher();
|
|
2992
|
+
|
|
2477
2993
|
renderWorkers(teamState.workers);
|
|
2478
2994
|
renderTasks(teamState.tasks);
|
|
2479
2995
|
renderPlanningTab(teamState.controllerRuns);
|
|
@@ -2624,7 +3140,7 @@
|
|
|
2624
3140
|
'<div class="task-card' + liveClass + '" data-task-id="' + escapeHtml(task.id) + '" tabindex="0" role="button" aria-label="Open details for ' + escapeHtml(task.title) + '">' +
|
|
2625
3141
|
' <span class="task-priority ' + escapeHtml(priority) + '">' + escapeHtml(priority) + "</span>" +
|
|
2626
3142
|
' <div class="task-body">' +
|
|
2627
|
-
' <div class="task-title-row"><div class="task-title">' + escapeHtml(task.title) + "</div>" + creatorBadge + "</div>" +
|
|
3143
|
+
' <div class="task-title-row"><div class="task-title">' + escapeHtml(task.title) + "</div>" + creatorBadge + workflowBadgeHtml(task) + "</div>" +
|
|
2628
3144
|
(task.description ? '<div class="task-desc clamp">' + escapeHtml(task.description).slice(0, 220) + "</div>" : "") +
|
|
2629
3145
|
renderSkillPills(recommendedSkills, "skill-pills task-skill-pills") +
|
|
2630
3146
|
contractSummary +
|
|
@@ -2649,6 +3165,115 @@
|
|
|
2649
3165
|
}
|
|
2650
3166
|
}
|
|
2651
3167
|
|
|
3168
|
+
// ==================== Workflow template launcher (design 2.4) ====================
|
|
3169
|
+
// Quick-action button group over the ACTIVE profile's workflow templates
|
|
3170
|
+
// (GET /team/profile -> profile.workflows[], serialized verbatim by the
|
|
3171
|
+
// backend - PR #243 API contract). Profiles without workflows
|
|
3172
|
+
// (software-rd) and older controllers without the field both resolve to an
|
|
3173
|
+
// empty template list, so the launcher hides itself - purely data-driven,
|
|
3174
|
+
// no per-profile branches. Click posts POST /api/v1/workflows/{id}/start
|
|
3175
|
+
// with an empty context (minimal v1 invocation); 201 -> refreshAll() so
|
|
3176
|
+
// the new task chain appears; 404/503 surface the backend message.
|
|
3177
|
+
|
|
3178
|
+
function activeWorkflows() {
|
|
3179
|
+
return activeTeamProfile && activeTeamProfile.profile && Array.isArray(activeTeamProfile.profile.workflows)
|
|
3180
|
+
? activeTeamProfile.profile.workflows
|
|
3181
|
+
: [];
|
|
3182
|
+
}
|
|
3183
|
+
|
|
3184
|
+
function workflowStepRoleLabel(step) {
|
|
3185
|
+
var id = step && typeof step.role === "string" ? step.role : "";
|
|
3186
|
+
if (!id) return "";
|
|
3187
|
+
var entry = roleRegistry.filter(function (role) { return role && role.id === id; })[0];
|
|
3188
|
+
// Route through the rename layer so tooltip chains honor custom names.
|
|
3189
|
+
return entry ? roleDisplayLabel(entry) : id;
|
|
3190
|
+
}
|
|
3191
|
+
|
|
3192
|
+
function renderWorkflowLauncher() {
|
|
3193
|
+
var container = $("#workflow-launcher");
|
|
3194
|
+
if (!container) return;
|
|
3195
|
+
var workflows = activeWorkflows();
|
|
3196
|
+
if (!workflows.length) {
|
|
3197
|
+
container.hidden = true;
|
|
3198
|
+
container.innerHTML = "";
|
|
3199
|
+
return;
|
|
3200
|
+
}
|
|
3201
|
+
container.hidden = false;
|
|
3202
|
+
container.setAttribute("aria-label", t("workflow.sectionTitle"));
|
|
3203
|
+
container.innerHTML = workflows.map(function (workflow) {
|
|
3204
|
+
if (!workflow || typeof workflow.id !== "string" || !workflow.id) return "";
|
|
3205
|
+
var steps = Array.isArray(workflow.steps) ? workflow.steps : [];
|
|
3206
|
+
var roles = steps.map(workflowStepRoleLabel).filter(Boolean).join(" → ");
|
|
3207
|
+
var tooltip = t("workflow.stepsTooltip", { n: steps.length, roles: roles });
|
|
3208
|
+
return (
|
|
3209
|
+
'<button type="button" class="filter-btn workflow-launch-btn" data-workflow-id="' + escapeHtml(workflow.id) +
|
|
3210
|
+
'" title="' + escapeHtml((workflow.name || workflow.id) + " — " + tooltip) + '">' +
|
|
3211
|
+
escapeHtml(workflow.name || workflow.id) +
|
|
3212
|
+
"</button>"
|
|
3213
|
+
);
|
|
3214
|
+
}).join("");
|
|
3215
|
+
container.querySelectorAll("[data-workflow-id]").forEach(function (button) {
|
|
3216
|
+
button.addEventListener("click", function () {
|
|
3217
|
+
startWorkflow(button.getAttribute("data-workflow-id") || "", button);
|
|
3218
|
+
});
|
|
3219
|
+
});
|
|
3220
|
+
}
|
|
3221
|
+
|
|
3222
|
+
function startWorkflow(workflowId, button) {
|
|
3223
|
+
if (!workflowId) return;
|
|
3224
|
+
if (button) button.disabled = true;
|
|
3225
|
+
apiPost("/workflows/" + encodeURIComponent(workflowId) + "/start", { context: "" })
|
|
3226
|
+
.then(function (data) {
|
|
3227
|
+
var name = (data && data.workflowName) || workflowId;
|
|
3228
|
+
showError(t("workflow.started", { name: name }));
|
|
3229
|
+
// The task chain itself is the workflow run state (design 2.4): a
|
|
3230
|
+
// full refresh makes the first step task (workflow badge on) appear.
|
|
3231
|
+
return refreshAll();
|
|
3232
|
+
})
|
|
3233
|
+
.catch(function (err) {
|
|
3234
|
+
// 404 unknown id / 400 bad context / 503 mid-switch: apiRequest
|
|
3235
|
+
// already extracts the backend error string; prefix the context.
|
|
3236
|
+
showError(t("workflow.startFailed", {
|
|
3237
|
+
reason: err instanceof Error ? err.message : String(err || "request failed"),
|
|
3238
|
+
}));
|
|
3239
|
+
})
|
|
3240
|
+
.finally(function () {
|
|
3241
|
+
if (button) button.disabled = false;
|
|
3242
|
+
});
|
|
3243
|
+
}
|
|
3244
|
+
|
|
3245
|
+
// Running-workflow badge: tasks created by the workflow engine carry
|
|
3246
|
+
// task.workflow { workflowId, runId, stepKey, visitCounts }. The context
|
|
3247
|
+
// holds ids only - the display join (workflow name, step title) resolves
|
|
3248
|
+
// against the active profile's templates, and visitCounts > 1 on the
|
|
3249
|
+
// current step surfaces the re-entry round (return-edge loops).
|
|
3250
|
+
function workflowBadgeHtml(task) {
|
|
3251
|
+
var context = task && task.workflow;
|
|
3252
|
+
if (!context || !context.workflowId) return "";
|
|
3253
|
+
var template = activeWorkflows().filter(function (workflow) {
|
|
3254
|
+
return workflow.id === context.workflowId;
|
|
3255
|
+
})[0];
|
|
3256
|
+
var workflowName = template ? (template.name || template.id) : context.workflowId;
|
|
3257
|
+
var stepTitle = "";
|
|
3258
|
+
if (template && Array.isArray(template.steps)) {
|
|
3259
|
+
var step = template.steps.filter(function (entry) {
|
|
3260
|
+
return String(entry && entry.id) === String(context.stepKey);
|
|
3261
|
+
})[0];
|
|
3262
|
+
if (step && step.title) stepTitle = step.title;
|
|
3263
|
+
}
|
|
3264
|
+
var visits = context.visitCounts ? context.visitCounts[String(context.stepKey)] : undefined;
|
|
3265
|
+
var roundPart = typeof visits === "number" && visits > 1
|
|
3266
|
+
? " · " + t("workflow.badgeRound", { n: visits })
|
|
3267
|
+
: "";
|
|
3268
|
+
var label = workflowName + (stepTitle ? " · " + stepTitle : "") + roundPart;
|
|
3269
|
+
return (
|
|
3270
|
+
'<span class="task-origin-badge task-workflow-badge" title="' +
|
|
3271
|
+
escapeHtml(t("workflow.sectionTitle") + ": " + label) + '">' +
|
|
3272
|
+
escapeHtml(label) +
|
|
3273
|
+
"</span>"
|
|
3274
|
+
);
|
|
3275
|
+
}
|
|
3276
|
+
|
|
2652
3277
|
function renderControllerRuns(runs) {
|
|
2653
3278
|
const container = $("#controller-runs");
|
|
2654
3279
|
if (!container) return;
|
|
@@ -2812,9 +3437,9 @@
|
|
|
2812
3437
|
if (subtitle) {
|
|
2813
3438
|
subtitle.textContent = task
|
|
2814
3439
|
? [
|
|
2815
|
-
"
|
|
2816
|
-
task.assignedWorkerId ? "
|
|
2817
|
-
task.assignedRole ? "
|
|
3440
|
+
t("detail.taskId", { id: task.id }),
|
|
3441
|
+
task.assignedWorkerId ? t("detail.worker", { id: task.assignedWorkerId }) : null,
|
|
3442
|
+
task.assignedRole ? t("detail.role", { id: task.assignedRole }) : null,
|
|
2818
3443
|
].filter(Boolean).join(" • ")
|
|
2819
3444
|
: "";
|
|
2820
3445
|
}
|
|
@@ -3216,11 +3841,11 @@
|
|
|
3216
3841
|
const container = $("#roles-list");
|
|
3217
3842
|
if (!container) return;
|
|
3218
3843
|
|
|
3219
|
-
container.innerHTML = roles.map(function (role) {
|
|
3844
|
+
container.innerHTML = visibleRoles(roles).map(function (role) {
|
|
3220
3845
|
return (
|
|
3221
3846
|
'<div class="role-chip">' +
|
|
3222
3847
|
" <span>" + escapeHtml(role.icon || "") + "</span>" +
|
|
3223
|
-
" <span>" + escapeHtml(role
|
|
3848
|
+
" <span>" + escapeHtml(roleDisplayLabel(role)) + "</span>" +
|
|
3224
3849
|
"</div>"
|
|
3225
3850
|
);
|
|
3226
3851
|
}).join("");
|
|
@@ -3237,11 +3862,11 @@
|
|
|
3237
3862
|
while (select.options.length > 1) {
|
|
3238
3863
|
select.remove(1);
|
|
3239
3864
|
}
|
|
3240
|
-
roleRegistry.forEach(function (role) {
|
|
3865
|
+
visibleRoles(roleRegistry).forEach(function (role) {
|
|
3241
3866
|
if (!role || typeof role.id !== "string" || !role.id) return;
|
|
3242
3867
|
const option = document.createElement("option");
|
|
3243
3868
|
option.value = role.id;
|
|
3244
|
-
option.textContent = role
|
|
3869
|
+
option.textContent = roleDisplayLabel(role);
|
|
3245
3870
|
select.appendChild(option);
|
|
3246
3871
|
});
|
|
3247
3872
|
if (previous && Array.prototype.some.call(select.options, function (option) { return option.value === previous; })) {
|
|
@@ -3260,6 +3885,131 @@
|
|
|
3260
3885
|
return roles.length > 0 ? roles[0].id : "";
|
|
3261
3886
|
}
|
|
3262
3887
|
|
|
3888
|
+
// ============ Role display prefs (Phase 4 lightweight customization) ============
|
|
3889
|
+
// v1 lightweight customization (design Phase 4): hide roles the team does
|
|
3890
|
+
// not use and rename the rest for the local team. PURE UI filter layer -
|
|
3891
|
+
// prefs persist in this browser's localStorage only; /roles, TeamState and
|
|
3892
|
+
// the profile JSON schema stay untouched (the full JSON editor is v2).
|
|
3893
|
+
// Applied at render time to the manual-task role select, the
|
|
3894
|
+
// external-worker role select and the sidebar Roles list.
|
|
3895
|
+
const ROLE_DISPLAY_STORAGE_KEY = "teamclaw.ui.roleDisplay.v1";
|
|
3896
|
+
let roleDisplayPrefs = loadRoleDisplayPrefs();
|
|
3897
|
+
|
|
3898
|
+
function defaultRoleDisplayPrefs() {
|
|
3899
|
+
return { hidden: {}, names: {} };
|
|
3900
|
+
}
|
|
3901
|
+
|
|
3902
|
+
function loadRoleDisplayPrefs() {
|
|
3903
|
+
try {
|
|
3904
|
+
var raw = window.localStorage.getItem(ROLE_DISPLAY_STORAGE_KEY);
|
|
3905
|
+
if (!raw) return defaultRoleDisplayPrefs();
|
|
3906
|
+
var parsed = JSON.parse(raw);
|
|
3907
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return defaultRoleDisplayPrefs();
|
|
3908
|
+
return {
|
|
3909
|
+
hidden: parsed.hidden && typeof parsed.hidden === "object" && !Array.isArray(parsed.hidden) ? parsed.hidden : {},
|
|
3910
|
+
names: parsed.names && typeof parsed.names === "object" && !Array.isArray(parsed.names) ? parsed.names : {},
|
|
3911
|
+
};
|
|
3912
|
+
} catch (_err) {
|
|
3913
|
+
return defaultRoleDisplayPrefs();
|
|
3914
|
+
}
|
|
3915
|
+
}
|
|
3916
|
+
|
|
3917
|
+
function saveRoleDisplayPrefs(prefs) {
|
|
3918
|
+
roleDisplayPrefs = prefs || defaultRoleDisplayPrefs();
|
|
3919
|
+
try {
|
|
3920
|
+
window.localStorage.setItem(ROLE_DISPLAY_STORAGE_KEY, JSON.stringify(roleDisplayPrefs));
|
|
3921
|
+
} catch (_err) {}
|
|
3922
|
+
}
|
|
3923
|
+
|
|
3924
|
+
function resetRoleDisplayPrefs() {
|
|
3925
|
+
roleDisplayPrefs = defaultRoleDisplayPrefs();
|
|
3926
|
+
try {
|
|
3927
|
+
window.localStorage.removeItem(ROLE_DISPLAY_STORAGE_KEY);
|
|
3928
|
+
} catch (_err) {}
|
|
3929
|
+
}
|
|
3930
|
+
|
|
3931
|
+
function isRoleVisible(roleId) {
|
|
3932
|
+
return !(roleDisplayPrefs.hidden && roleDisplayPrefs.hidden[roleId]);
|
|
3933
|
+
}
|
|
3934
|
+
|
|
3935
|
+
// Rename layer: a non-empty custom name wins; anything else falls back to
|
|
3936
|
+
// the registry label (and the id when even the label is missing).
|
|
3937
|
+
function roleDisplayLabel(role) {
|
|
3938
|
+
if (!role) return "";
|
|
3939
|
+
var custom = roleDisplayPrefs.names ? roleDisplayPrefs.names[role.id] : "";
|
|
3940
|
+
if (typeof custom === "string" && custom.trim()) return custom.trim();
|
|
3941
|
+
return role.label || role.id || "";
|
|
3942
|
+
}
|
|
3943
|
+
|
|
3944
|
+
function visibleRoles(roles) {
|
|
3945
|
+
return (roles || []).filter(function (role) {
|
|
3946
|
+
return role && typeof role.id === "string" && role.id && isRoleVisible(role.id);
|
|
3947
|
+
});
|
|
3948
|
+
}
|
|
3949
|
+
|
|
3950
|
+
// Re-render every surface the prefs drive (manual-task select, external
|
|
3951
|
+
// worker card, sidebar chips) after a save/reset.
|
|
3952
|
+
function rerenderRoleSurfaces() {
|
|
3953
|
+
renderTaskRoleOptions();
|
|
3954
|
+
renderExternalWorkerInstallCard();
|
|
3955
|
+
renderRoles(roleRegistry);
|
|
3956
|
+
}
|
|
3957
|
+
|
|
3958
|
+
// Editor rows live in the team-profile modal's "Role display" section:
|
|
3959
|
+
// one row per /roles registry entry - visibility checkbox (keyed by the
|
|
3960
|
+
// stable role id) + display-name input whose placeholder is the registry
|
|
3961
|
+
// label (an empty value falls back to it on save).
|
|
3962
|
+
function renderRoleDisplayEditor() {
|
|
3963
|
+
var listEl = $("#role-display-list");
|
|
3964
|
+
if (!listEl) return;
|
|
3965
|
+
if (!roleRegistry.length) {
|
|
3966
|
+
listEl.innerHTML = "";
|
|
3967
|
+
return;
|
|
3968
|
+
}
|
|
3969
|
+
listEl.innerHTML = roleRegistry.map(function (role) {
|
|
3970
|
+
var fallback = role.label || role.id;
|
|
3971
|
+
var customName = (roleDisplayPrefs.names && roleDisplayPrefs.names[role.id]) || "";
|
|
3972
|
+
return (
|
|
3973
|
+
'<div class="team-profile-archive-row role-display-row" data-role-display-id="' + escapeHtml(role.id) + '">' +
|
|
3974
|
+
'<label class="role-display-visible">' +
|
|
3975
|
+
'<input type="checkbox" data-role-display-visible' + (isRoleVisible(role.id) ? " checked" : "") + "> " +
|
|
3976
|
+
escapeHtml((role.icon ? role.icon + " " : "") + role.id) +
|
|
3977
|
+
"</label>" +
|
|
3978
|
+
'<input type="text" class="role-display-name" data-role-display-name spellcheck="false" autocomplete="off" value="' +
|
|
3979
|
+
escapeHtml(customName) + '" placeholder="' + escapeHtml(fallback) + '">' +
|
|
3980
|
+
"</div>"
|
|
3981
|
+
);
|
|
3982
|
+
}).join("");
|
|
3983
|
+
}
|
|
3984
|
+
|
|
3985
|
+
function saveRoleDisplayFromEditor() {
|
|
3986
|
+
var listEl = $("#role-display-list");
|
|
3987
|
+
if (!listEl) return;
|
|
3988
|
+
var prefs = defaultRoleDisplayPrefs();
|
|
3989
|
+
listEl.querySelectorAll("[data-role-display-id]").forEach(function (row) {
|
|
3990
|
+
var roleId = row.getAttribute("data-role-display-id") || "";
|
|
3991
|
+
if (!roleId) return;
|
|
3992
|
+
var checkbox = row.querySelector("[data-role-display-visible]");
|
|
3993
|
+
if (checkbox && !checkbox.checked) prefs.hidden[roleId] = true;
|
|
3994
|
+
var nameInput = row.querySelector("[data-role-display-name]");
|
|
3995
|
+
if (nameInput) {
|
|
3996
|
+
var custom = nameInput.value.trim();
|
|
3997
|
+
if (custom) prefs.names[roleId] = custom;
|
|
3998
|
+
}
|
|
3999
|
+
});
|
|
4000
|
+
saveRoleDisplayPrefs(prefs);
|
|
4001
|
+
rerenderRoleSurfaces();
|
|
4002
|
+
renderRoleDisplayEditor();
|
|
4003
|
+
showError(t("roleDisplay.saved"));
|
|
4004
|
+
}
|
|
4005
|
+
|
|
4006
|
+
function resetRoleDisplay() {
|
|
4007
|
+
resetRoleDisplayPrefs();
|
|
4008
|
+
rerenderRoleSurfaces();
|
|
4009
|
+
renderRoleDisplayEditor();
|
|
4010
|
+
showError(t("roleDisplay.resetDone"));
|
|
4011
|
+
}
|
|
4012
|
+
|
|
3263
4013
|
function tabNameFromHash() {
|
|
3264
4014
|
const match = /^#\/tab\/([a-z][a-z0-9-]*)$/i.exec(window.location.hash || "");
|
|
3265
4015
|
const name = match ? match[1] : "";
|
|
@@ -3544,7 +4294,7 @@
|
|
|
3544
4294
|
const answer = answerInput ? answerInput.value.trim() : "";
|
|
3545
4295
|
|
|
3546
4296
|
if (!clarificationId || !answer) {
|
|
3547
|
-
showError("
|
|
4297
|
+
showError(t("clarification.needAnswer"));
|
|
3548
4298
|
return;
|
|
3549
4299
|
}
|
|
3550
4300
|
|
|
@@ -3775,7 +4525,7 @@
|
|
|
3775
4525
|
if (!el) return;
|
|
3776
4526
|
apiGet("/workspace/status").then(function (data) {
|
|
3777
4527
|
if (data && typeof data.workspaceDir === "string") {
|
|
3778
|
-
el.textContent = data.workspaceDir + (data.isDefault ? " (default)" : "");
|
|
4528
|
+
el.textContent = data.workspaceDir + (data.isDefault ? " (" + t("ctl.ws.default") + ")" : "");
|
|
3779
4529
|
el.title = data.workspaceDir;
|
|
3780
4530
|
}
|
|
3781
4531
|
}).catch(function () { /* leave placeholder */ });
|
|
@@ -3786,7 +4536,7 @@
|
|
|
3786
4536
|
var pathEl = $("#workspace-prompt-path");
|
|
3787
4537
|
var input = $("#workspace-prompt-input");
|
|
3788
4538
|
if (!modal || !pathEl || !input) return;
|
|
3789
|
-
pathEl.textContent = currentPath || "
|
|
4539
|
+
pathEl.textContent = currentPath || t("ws.unknown");
|
|
3790
4540
|
input.value = currentPath || "";
|
|
3791
4541
|
modal.classList.add("open");
|
|
3792
4542
|
modal.setAttribute("aria-hidden", "false");
|
|
@@ -3838,13 +4588,13 @@
|
|
|
3838
4588
|
input.value = handle.name || input.value;
|
|
3839
4589
|
input.dataset.verifiedPath = "";
|
|
3840
4590
|
}
|
|
3841
|
-
showError("
|
|
4591
|
+
showError(t("ws.pickerNoPath"));
|
|
3842
4592
|
})
|
|
3843
4593
|
.catch(function () {
|
|
3844
4594
|
/* user cancelled */
|
|
3845
4595
|
});
|
|
3846
4596
|
} else {
|
|
3847
|
-
showError("
|
|
4597
|
+
showError(t("ws.pickerUnsupported"));
|
|
3848
4598
|
}
|
|
3849
4599
|
});
|
|
3850
4600
|
}
|
|
@@ -3853,17 +4603,17 @@
|
|
|
3853
4603
|
apply.addEventListener("click", function () {
|
|
3854
4604
|
var value = input && typeof input.value === "string" ? input.value.trim() : "";
|
|
3855
4605
|
if (!value || value.indexOf("/") !== 0) {
|
|
3856
|
-
showError("
|
|
4606
|
+
showError(t("ws.needAbsolute"));
|
|
3857
4607
|
return;
|
|
3858
4608
|
}
|
|
3859
4609
|
apply.disabled = true;
|
|
3860
4610
|
apiPost("/workspace/change-dir", { workspaceDir: value }).then(function () {
|
|
3861
4611
|
localStorage.setItem(WORKSPACE_PROMPT_DISMISSED_KEY, "1");
|
|
3862
4612
|
closeWorkspacePromptModal();
|
|
3863
|
-
showError("
|
|
4613
|
+
showError(t("ctl.ws.saved"));
|
|
3864
4614
|
updateWorkspacePathIndicator();
|
|
3865
4615
|
}).catch(function (err) {
|
|
3866
|
-
showError(err instanceof Error ? err.message : "
|
|
4616
|
+
showError(err instanceof Error ? err.message : t("ctl.ws.failed"));
|
|
3867
4617
|
}).finally(function () {
|
|
3868
4618
|
apply.disabled = false;
|
|
3869
4619
|
});
|
|
@@ -3880,6 +4630,7 @@
|
|
|
3880
4630
|
promptWorkspaceIfDefault();
|
|
3881
4631
|
updateWorkspacePathIndicator();
|
|
3882
4632
|
bindTeamProfileModal();
|
|
4633
|
+
bindSecurityUi();
|
|
3883
4634
|
bindModelSettings();
|
|
3884
4635
|
bindGithubCorner();
|
|
3885
4636
|
|
|
@@ -3954,6 +4705,13 @@
|
|
|
3954
4705
|
modal.classList.add("open");
|
|
3955
4706
|
modal.setAttribute("aria-hidden", "false");
|
|
3956
4707
|
refreshTeamProfileModalData();
|
|
4708
|
+
// Role display editor renders from the /roles mirror + the saved prefs;
|
|
4709
|
+
// rendered on open (not on refreshAll) so an in-progress edit survives
|
|
4710
|
+
// background refreshes while the modal is open.
|
|
4711
|
+
renderRoleDisplayEditor();
|
|
4712
|
+
// Issue #23: the devices section lives at the bottom of this modal; it
|
|
4713
|
+
// re-renders on every refreshAll while the modal is open.
|
|
4714
|
+
renderSecurityDevices();
|
|
3957
4715
|
}
|
|
3958
4716
|
|
|
3959
4717
|
function closeTeamProfileModal() {
|
|
@@ -4270,6 +5028,15 @@
|
|
|
4270
5028
|
submitTeamProfileSwitch(pendingSwitchTarget.id);
|
|
4271
5029
|
});
|
|
4272
5030
|
}
|
|
5031
|
+
|
|
5032
|
+
var roleDisplaySave = $("#role-display-save");
|
|
5033
|
+
if (roleDisplaySave) {
|
|
5034
|
+
roleDisplaySave.addEventListener("click", saveRoleDisplayFromEditor);
|
|
5035
|
+
}
|
|
5036
|
+
var roleDisplayReset = $("#role-display-reset");
|
|
5037
|
+
if (roleDisplayReset) {
|
|
5038
|
+
roleDisplayReset.addEventListener("click", resetRoleDisplay);
|
|
5039
|
+
}
|
|
4273
5040
|
}
|
|
4274
5041
|
|
|
4275
5042
|
function bindModelSettings() {
|
|
@@ -4278,7 +5045,10 @@
|
|
|
4278
5045
|
opener.className = "btn btn-small";
|
|
4279
5046
|
opener.type = "button";
|
|
4280
5047
|
opener.id = "model-settings-open";
|
|
4281
|
-
|
|
5048
|
+
// data-i18n lets applyStaticTranslations refresh the label on language
|
|
5049
|
+
// switches (the same mechanism as the static header buttons).
|
|
5050
|
+
opener.setAttribute("data-i18n", "ctl.tab.models");
|
|
5051
|
+
opener.textContent = t("ctl.tab.models");
|
|
4282
5052
|
var refreshBtn = document.querySelector("#workspace-tree-refresh");
|
|
4283
5053
|
if (refreshBtn && refreshBtn.parentElement) {
|
|
4284
5054
|
refreshBtn.parentElement.appendChild(opener);
|
|
@@ -4315,10 +5085,10 @@
|
|
|
4315
5085
|
headers: { "Content-Type": "application/json" },
|
|
4316
5086
|
body: JSON.stringify(payload),
|
|
4317
5087
|
}).then(function () {
|
|
4318
|
-
showError("
|
|
5088
|
+
showError(t("ctl.models.saved"));
|
|
4319
5089
|
closeModelSettings();
|
|
4320
5090
|
}).catch(function (err) {
|
|
4321
|
-
showError(err instanceof Error ? err.message : "
|
|
5091
|
+
showError(err instanceof Error ? err.message : t("ctl.models.failed"));
|
|
4322
5092
|
}).finally(function () {
|
|
4323
5093
|
save.disabled = false;
|
|
4324
5094
|
});
|
|
@@ -4392,7 +5162,7 @@ function renderGithubCorner(status) {
|
|
|
4392
5162
|
loginBtn.hidden = true;
|
|
4393
5163
|
} else {
|
|
4394
5164
|
userChip.classList.add("hidden");
|
|
4395
|
-
loginBtn.textContent = t("gh.login");
|
|
5165
|
+
loginBtn.textContent = t("ctl.gh.login");
|
|
4396
5166
|
loginBtn.hidden = false;
|
|
4397
5167
|
}
|
|
4398
5168
|
}
|
|
@@ -4413,11 +5183,11 @@ function openModelSettings() {
|
|
|
4413
5183
|
options.push({ value: provider.id + "/" + modelId, label: provider.id + " / " + modelId });
|
|
4414
5184
|
});
|
|
4415
5185
|
if (!provider.models || provider.models.length === 0) {
|
|
4416
|
-
options.push({ value: provider.id, label: provider.id + " (
|
|
5186
|
+
options.push({ value: provider.id, label: provider.id + " " + t("models.providerDefault") });
|
|
4417
5187
|
}
|
|
4418
5188
|
});
|
|
4419
5189
|
if (catalog.defaultModel && !options.some(function (opt) { return opt.value === catalog.defaultModel; })) {
|
|
4420
|
-
options.unshift({ value: catalog.defaultModel, label: catalog.defaultModel + " (current)
|
|
5190
|
+
options.unshift({ value: catalog.defaultModel, label: catalog.defaultModel + " " + t("models.current") });
|
|
4421
5191
|
}
|
|
4422
5192
|
|
|
4423
5193
|
var defaultSelect = document.querySelector("#model-settings-default");
|
|
@@ -4436,7 +5206,7 @@ function openModelSettings() {
|
|
|
4436
5206
|
'<label class="model-settings-field">' +
|
|
4437
5207
|
' <span class="model-settings-label">' + escapeHtml(role.label) + '</span>' +
|
|
4438
5208
|
' <select data-role-model="' + escapeHtml(role.id) + '">' +
|
|
4439
|
-
' <option value="">(
|
|
5209
|
+
' <option value="">' + escapeHtml(t("ctl.models.useDefault")) + '</option>' +
|
|
4440
5210
|
options.map(function (opt) {
|
|
4441
5211
|
return '<option value="' + escapeHtml(opt.value) + '"' + (current === opt.value ? " selected" : "") + '>' + escapeHtml(opt.label) + "</option>";
|
|
4442
5212
|
}).join("") +
|
|
@@ -4449,7 +5219,7 @@ function openModelSettings() {
|
|
|
4449
5219
|
modal.classList.add("open");
|
|
4450
5220
|
modal.setAttribute("aria-hidden", "false");
|
|
4451
5221
|
}).catch(function (err) {
|
|
4452
|
-
showError(err instanceof Error ? err.message : "
|
|
5222
|
+
showError(err instanceof Error ? err.message : t("models.loadFailed"));
|
|
4453
5223
|
});
|
|
4454
5224
|
}
|
|
4455
5225
|
|
|
@@ -4754,7 +5524,7 @@ function closeModelSettings() {
|
|
|
4754
5524
|
const host = (location.hostname || "").toLowerCase();
|
|
4755
5525
|
const isLocalView = host === "127.0.0.1" || host === "localhost" || host.endsWith(".local");
|
|
4756
5526
|
if (!isLocalView) {
|
|
4757
|
-
wrap.querySelector(".tunnel-state").innerHTML = '<span class="tunnel-note">
|
|
5527
|
+
wrap.querySelector(".tunnel-state").innerHTML = '<span class="tunnel-note">' + escapeHtml(t("tunnel.visitorNote")) + '</span>';
|
|
4758
5528
|
if (toggleBtn) toggleBtn.hidden = true;
|
|
4759
5529
|
return;
|
|
4760
5530
|
}
|
|
@@ -4771,62 +5541,76 @@ function closeModelSettings() {
|
|
|
4771
5541
|
}
|
|
4772
5542
|
}
|
|
4773
5543
|
var progress = st.startOp && st.startOp.running
|
|
4774
|
-
? '<div class="tunnel-note">
|
|
5544
|
+
? '<div class="tunnel-note">' + escapeHtml(t("ctl.tunnel.starting") + ": " + String(st.startOp.phase || "") + "…") + '</div>'
|
|
4775
5545
|
: (st.install && st.install.running
|
|
4776
|
-
? '<div class="tunnel-note">
|
|
5546
|
+
? '<div class="tunnel-note">' + escapeHtml(t("ctl.tunnel.installing") + " " + String(st.install.phase || "") + (st.install.percent != null ? " " + st.install.percent + "%" : "") + "…") + '</div>'
|
|
4777
5547
|
: '');
|
|
4778
5548
|
if (progress) { wrap.querySelector(".tunnel-state").innerHTML = progress; return; }
|
|
4779
5549
|
if (st.active && st.mode === "quick") {
|
|
4780
5550
|
wrap.querySelector(".tunnel-state").innerHTML =
|
|
4781
|
-
'<div class="tunnel-on">
|
|
4782
|
-
+ '<div class="tunnel-note">
|
|
4783
|
-
+ '<button class="btn btn-small" data-act="stop">
|
|
5551
|
+
'<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>'
|
|
5552
|
+
+ '<div class="tunnel-note">' + escapeHtml(t("tunnel.quickNote")) + '</div>'
|
|
5553
|
+
+ '<button class="btn btn-small" data-act="stop">' + escapeHtml(t("ctl.tunnel.stop")) + '</button>';
|
|
4784
5554
|
return;
|
|
4785
5555
|
}
|
|
4786
5556
|
if (st.active && st.mode === "self-hosted") {
|
|
4787
5557
|
wrap.querySelector(".tunnel-state").innerHTML =
|
|
4788
|
-
'<div class="tunnel-on">
|
|
4789
|
-
+ '<div class="tunnel-note">
|
|
4790
|
-
+ '<button class="btn btn-small" data-act="stop">
|
|
5558
|
+
'<div class="tunnel-on">' + escapeHtml(t("tunnel.selfHostedLive")) + '</div>'
|
|
5559
|
+
+ '<div class="tunnel-note">' + escapeHtml(t("tunnel.selfHostedNote")) + '</div>'
|
|
5560
|
+
+ '<button class="btn btn-small" data-act="stop">' + escapeHtml(t("ctl.tunnel.stop")) + '</button>';
|
|
4791
5561
|
return;
|
|
4792
5562
|
}
|
|
4793
5563
|
if (st.active) {
|
|
5564
|
+
// Gate token label: shared with desktop via ctl.tunnel.gateToken
|
|
5565
|
+
// ("Gate token" / 门禁令牌), appended with a colon here.
|
|
4794
5566
|
wrap.querySelector(".tunnel-state").innerHTML =
|
|
4795
|
-
'<div class="tunnel-on">
|
|
4796
|
-
+ '<div class="tunnel-token">
|
|
4797
|
-
+ '<button class="btn btn-small" data-act="stop">
|
|
5567
|
+
'<div class="tunnel-on">' + escapeHtml(t("ctl.tunnel.live") + ": ") + '<a href="https://' + st.hostname + '" target="_blank" rel="noopener">https://' + st.hostname + '</a></div>'
|
|
5568
|
+
+ '<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>'
|
|
5569
|
+
+ '<button class="btn btn-small" data-act="stop">' + escapeHtml(t("ctl.tunnel.stop")) + '</button>';
|
|
4798
5570
|
return;
|
|
4799
5571
|
}
|
|
4800
5572
|
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">
|
|
5573
|
+
wrap.querySelector(".tunnel-state").innerHTML = '<div class="tunnel-note">' + escapeHtml(t("ctl.tunnel.notInstalled")) + '</div>'
|
|
5574
|
+
+ '<button class="btn btn-small btn-primary" data-act="install">' + escapeHtml(t("ctl.tunnel.install")) + '</button>';
|
|
4803
5575
|
return;
|
|
4804
5576
|
}
|
|
4805
5577
|
// Idle: self-hosted (env token detected -> one click; otherwise token
|
|
4806
5578
|
// input) alongside the managed share button.
|
|
4807
5579
|
var html = '';
|
|
4808
5580
|
if (st.envTokenDetected) {
|
|
4809
|
-
html += '<div class="tunnel-note">
|
|
4810
|
-
+ '<button class="btn btn-small btn-primary" data-act="start-self">
|
|
5581
|
+
html += '<div class="tunnel-note">' + escapeHtml(t("tunnel.envTokenReady")) + '</div>'
|
|
5582
|
+
+ '<button class="btn btn-small btn-primary" data-act="start-self">' + escapeHtml(t("tunnel.startSelf")) + '</button>';
|
|
4811
5583
|
} 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">
|
|
5584
|
+
html += '<div class="tunnel-note">' + escapeHtml(t("tunnel.selfHostedLabel")) + '</div>'
|
|
5585
|
+
+ '<input type="password" class="tunnel-token-input" data-input="token" placeholder="' + escapeHtml(t("tunnel.tokenPlaceholder")) + '" autocomplete="off">'
|
|
5586
|
+
+ '<button class="btn btn-small btn-primary" data-act="start-self-token">' + escapeHtml(t("tunnel.startSelf")) + '</button>'
|
|
5587
|
+
+ '<details class="tunnel-setup-help"><summary>' + escapeHtml(t("tunnel.setupHelp")) + '</summary>'
|
|
5588
|
+
+ '<div class="tunnel-note">' + escapeHtml(t("tunnel.setupHelpBody")) + '</div></details>';
|
|
4817
5589
|
}
|
|
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">
|
|
5590
|
+
html += '<div class="tunnel-note">' + escapeHtml(t("tunnel.or")) + '</div>'
|
|
5591
|
+
+ '<button class="btn btn-small" data-act="start">' + escapeHtml(t("ctl.tunnel.share")) + '</button>'
|
|
5592
|
+
+ '<span class="tunnel-note">' + escapeHtml(t("tunnel.requiresGithub")) + '</span>'
|
|
5593
|
+
+ '<div class="tunnel-note">' + escapeHtml(t("tunnel.or")) + '</div>'
|
|
5594
|
+
+ '<button class="btn btn-small" data-act="start-quick">' + escapeHtml(t("tunnel.startQuick")) + '</button>'
|
|
5595
|
+
+ '<div class="tunnel-note">' + escapeHtml(t("tunnel.quickDemoNote")) + '</div>';
|
|
4824
5596
|
wrap.querySelector(".tunnel-state").innerHTML = html;
|
|
4825
5597
|
};
|
|
4826
5598
|
const refresh = () => apiGet("/tunnel/status").then((st) => render(st || {})).catch(() => {});
|
|
4827
5599
|
wrap.addEventListener("click", (e) => {
|
|
4828
5600
|
const act = e.target.getAttribute && e.target.getAttribute("data-act");
|
|
4829
5601
|
if (!act) return;
|
|
5602
|
+
// Gate token copy (#237 review follow-up): handled before the generic
|
|
5603
|
+
// action dispatch below, which disables the button and expects an API
|
|
5604
|
+
// call. Reuses the copyText + action.copied feedback pattern of the
|
|
5605
|
+
// security pairing command copy.
|
|
5606
|
+
if (act === "copy-token") {
|
|
5607
|
+
const tokenEl = wrap.querySelector(".tunnel-token b");
|
|
5608
|
+
copyText(tokenEl ? tokenEl.textContent : "").then(() => {
|
|
5609
|
+
e.target.textContent = t("action.copied");
|
|
5610
|
+
setTimeout(() => { e.target.textContent = t("action.copyToken"); }, 1500);
|
|
5611
|
+
}).catch(() => {});
|
|
5612
|
+
return;
|
|
5613
|
+
}
|
|
4830
5614
|
e.target.disabled = true;
|
|
4831
5615
|
var call;
|
|
4832
5616
|
if (act === "start-quick") {
|
|
@@ -4836,7 +5620,7 @@ function closeModelSettings() {
|
|
|
4836
5620
|
if (act === "start-self-token") {
|
|
4837
5621
|
const input = wrap.querySelector('[data-input="token"]');
|
|
4838
5622
|
if (!input || !input.value.trim()) {
|
|
4839
|
-
wrap.querySelector(".tunnel-state").innerHTML = '<div class="tunnel-err">
|
|
5623
|
+
wrap.querySelector(".tunnel-state").innerHTML = '<div class="tunnel-err">' + escapeHtml(t("tunnel.needToken")) + '</div>';
|
|
4840
5624
|
return;
|
|
4841
5625
|
}
|
|
4842
5626
|
opts.body = JSON.stringify({ token: input.value.trim() });
|
|
@@ -4847,7 +5631,7 @@ function closeModelSettings() {
|
|
|
4847
5631
|
: act === "install" ? apiRequest("/tunnel/install-cloudflared", { method: "POST" })
|
|
4848
5632
|
: apiRequest("/tunnel/stop", { method: "POST" });
|
|
4849
5633
|
}
|
|
4850
|
-
call.then(refresh).catch((err) => { wrap.querySelector(".tunnel-state").innerHTML = '<div class="tunnel-err">' + escapeHtml(String(err.message || err)) + "</div>"; });
|
|
5634
|
+
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
5635
|
});
|
|
4852
5636
|
refresh();
|
|
4853
5637
|
setInterval(refresh, 5000);
|