@teamclaws/teamclaw 2026.8.1 → 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 +318 -17
- package/dist/index.js +54 -32
- package/dist/src/config.js +57 -2
- package/dist/src/controller/auth-routes.js +129 -0
- package/dist/src/controller/clarification-routes.js +315 -0
- package/dist/src/controller/controller-intake.js +895 -0
- package/dist/src/controller/controller-planning.js +814 -0
- package/dist/src/controller/controller-routes.js +195 -0
- package/dist/src/controller/controller-runs.js +175 -0
- package/dist/src/controller/controller-service.js +338 -50
- package/dist/src/controller/controller-tools.js +14 -7
- package/dist/src/controller/github-auth.js +2 -1
- package/dist/src/controller/http-server.js +290 -6003
- package/dist/src/controller/kickoff-orchestrator.js +33 -43
- package/dist/src/controller/message-delivery.js +31 -0
- package/dist/src/controller/message-routes.js +114 -0
- package/dist/src/controller/orchestration-manifest.js +11 -93
- package/dist/src/controller/preview-manager.js +51 -3
- package/dist/src/controller/preview-proxy.js +98 -0
- package/dist/src/controller/profile-switch.js +309 -0
- package/dist/src/controller/project-registry.js +294 -0
- package/dist/src/controller/prompt-injector.js +19 -9
- 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 +129 -0
- package/dist/src/controller/report-routes.js +56 -0
- package/dist/src/controller/role-inference.js +231 -20
- package/dist/src/controller/route-table.js +375 -0
- package/dist/src/controller/security.js +775 -0
- package/dist/src/controller/status-routes.js +287 -0
- package/dist/src/controller/task-assignment.js +511 -0
- package/dist/src/controller/task-cleanup.js +258 -0
- package/dist/src/controller/task-execution.js +271 -0
- package/dist/src/controller/task-results.js +471 -0
- package/dist/src/controller/task-router.js +74 -4
- package/dist/src/controller/task-routes.js +703 -0
- package/dist/src/controller/teamauto-routes.js +124 -0
- package/dist/src/controller/tunnel-manager.js +41 -8
- package/dist/src/controller/tunnel-routes.js +225 -0
- package/dist/src/controller/ui-assets.js +68 -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 +69 -953
- package/dist/src/controller/worker-routes.js +188 -0
- 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 +15 -3
- package/dist/src/interaction-contracts.js +7 -7
- package/dist/src/openclaw-workspace.js +40 -18
- package/dist/src/profile-loader.js +604 -0
- package/dist/src/profiles/banking.json +202 -0
- package/dist/src/profiles/crossborder-ecom.json +253 -0
- package/dist/src/profiles/insurance.json +157 -0
- package/dist/src/profiles/knowledge/hs-structure.md +97 -0
- package/dist/src/profiles/knowledge/incoterms-2020.md +188 -0
- package/dist/src/profiles/knowledge/vat-principles.md +85 -0
- package/dist/src/profiles/schema.json +281 -0
- package/dist/src/profiles/securities.json +137 -0
- package/dist/src/profiles/software-rd.json +264 -0
- package/dist/src/profiles/trading-co.json +200 -0
- package/dist/src/prompt-policy.js +42 -17
- package/dist/src/protocol.js +66 -3
- package/dist/src/role-ids.js +29 -0
- package/dist/src/roles.js +54 -13
- package/dist/src/session-roles.js +14 -0
- 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 +275 -11
- package/dist/src/task-executor.js +7 -17
- package/dist/src/teamauto/github-client.js +18 -0
- package/dist/src/teamauto/repo-sync.js +228 -6
- package/dist/src/teamauto/scanner.js +40 -12
- package/dist/src/teamauto/scheduler.js +231 -12
- package/dist/src/types.js +77 -16
- package/dist/src/ui/app.js +1434 -82
- package/dist/src/ui/github-login.html +1 -0
- package/dist/src/ui/index.html +144 -45
- package/dist/src/ui/style.css +194 -0
- package/dist/src/worker/http-handler.js +59 -0
- package/dist/src/worker/prompt-injector.js +44 -8
- package/dist/src/worker/skill-installer.js +6 -10
- package/dist/src/worker/tools.js +20 -10
- package/dist/src/worker/worker-service.js +93 -7
- package/index.ts +61 -32
- package/openclaw.plugin.json +50 -2
- package/package.json +3 -2
- package/src/config.ts +57 -2
- package/src/controller/auth-routes.ts +157 -0
- package/src/controller/clarification-routes.ts +404 -0
- package/src/controller/controller-intake.ts +1113 -0
- package/src/controller/controller-planning.ts +1037 -0
- package/src/controller/controller-routes.ts +237 -0
- package/src/controller/controller-runs.ts +239 -0
- package/src/controller/controller-service.ts +422 -50
- package/src/controller/controller-tools.ts +16 -9
- package/src/controller/github-auth.ts +28 -63
- package/src/controller/http-server.ts +336 -6964
- package/src/controller/kickoff-orchestrator.ts +69 -45
- package/src/controller/message-delivery.ts +52 -0
- package/src/controller/message-routes.ts +137 -0
- package/src/controller/orchestration-manifest.ts +14 -100
- package/src/controller/preview-manager.ts +53 -3
- package/src/controller/preview-proxy.ts +127 -0
- package/src/controller/profile-switch.ts +396 -0
- package/src/controller/project-registry.ts +361 -0
- package/src/controller/prompt-injector.ts +23 -8
- 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 +163 -0
- package/src/controller/report-routes.ts +64 -0
- package/src/controller/role-inference.ts +260 -22
- package/src/controller/route-table.ts +597 -0
- package/src/controller/security.ts +899 -0
- package/src/controller/status-routes.ts +354 -0
- package/src/controller/task-assignment.ts +622 -0
- package/src/controller/task-cleanup.ts +344 -0
- package/src/controller/task-execution.ts +399 -0
- package/src/controller/task-results.ts +556 -0
- package/src/controller/task-router.ts +98 -6
- package/src/controller/task-routes.ts +812 -0
- package/src/controller/teamauto-routes.ts +121 -0
- package/src/controller/tunnel-manager.ts +45 -8
- package/src/controller/tunnel-routes.ts +231 -0
- package/src/controller/ui-assets.ts +70 -0
- package/src/controller/websocket.ts +32 -4
- package/src/controller/webui-routes.ts +55 -0
- package/src/controller/worker-provisioning.ts +83 -1121
- package/src/controller/worker-routes.ts +241 -0
- 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 +16 -3
- package/src/interaction-contracts.ts +7 -7
- package/src/openclaw-workspace.ts +44 -18
- package/src/profile-loader.ts +816 -0
- package/src/profiles/banking.json +202 -0
- package/src/profiles/crossborder-ecom.json +253 -0
- package/src/profiles/insurance.json +157 -0
- package/src/profiles/knowledge/hs-structure.md +97 -0
- package/src/profiles/knowledge/incoterms-2020.md +188 -0
- package/src/profiles/knowledge/vat-principles.md +85 -0
- package/src/profiles/schema.json +281 -0
- package/src/profiles/securities.json +137 -0
- package/src/profiles/software-rd.json +264 -0
- package/src/profiles/trading-co.json +200 -0
- package/src/prompt-policy.ts +44 -17
- package/src/protocol.ts +72 -2
- package/src/role-ids.ts +31 -0
- package/src/roles.ts +60 -14
- package/src/session-roles.ts +14 -0
- 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 +326 -10
- package/src/task-executor.ts +7 -18
- package/src/teamauto/github-client.ts +23 -1
- package/src/teamauto/repo-sync.ts +248 -7
- package/src/teamauto/scanner.ts +47 -13
- package/src/teamauto/scheduler.ts +261 -17
- package/src/teamauto/store.ts +12 -0
- package/src/types.ts +263 -17
- package/src/ui/app.js +1434 -82
- package/src/ui/github-login.html +1 -0
- package/src/ui/index.html +144 -45
- package/src/ui/style.css +194 -0
- package/src/worker/http-handler.ts +64 -1
- package/src/worker/prompt-injector.ts +48 -8
- package/src/worker/skill-installer.ts +6 -10
- package/src/worker/tools.ts +21 -10
- package/src/worker/worker-service.ts +101 -7
package/dist/src/ui/app.js
CHANGED
|
@@ -9,7 +9,16 @@
|
|
|
9
9
|
let terminalTasksVisible = 20;
|
|
10
10
|
let activeTab = "tasks";
|
|
11
11
|
let teamState = { workers: [], tasks: [], controllerRuns: [], messages: [], clarifications: [], modelReadiness: null, externalWorkerInstall: null };
|
|
12
|
-
|
|
12
|
+
// Role registry mirror (GET /api/v1/roles) — single data source for the
|
|
13
|
+
// manual-task role options, kickoff icons, and the external-worker role
|
|
14
|
+
// default. Kept empty until the first successful /roles response; renders
|
|
15
|
+
// that need it degrade to the Auto-assign option / the generic icon.
|
|
16
|
+
let roleRegistry = [];
|
|
17
|
+
// Optional default role id advertised by the backend (e.g. profile default
|
|
18
|
+
// once /roles returns profile content); empty when the field is absent,
|
|
19
|
+
// in which case the first registry entry is the default.
|
|
20
|
+
let roleDefaultId = "";
|
|
21
|
+
let selectedExternalWorkerRole = "";
|
|
13
22
|
let selectedExternalWorkerDiscoveryMode = "mdns";
|
|
14
23
|
let externalWorkerInstallVisible = false;
|
|
15
24
|
let selectedTaskId = null;
|
|
@@ -21,6 +30,24 @@
|
|
|
21
30
|
let selectedWorkspaceFile = null;
|
|
22
31
|
let selectedWorkspaceView = "source";
|
|
23
32
|
let workspaceLoaded = false;
|
|
33
|
+
// Team profile switcher (Phase 5.1): registry mirror of GET /api/v1/profiles
|
|
34
|
+
// and the latest GET /api/v1/team/profile response (active profile detail
|
|
35
|
+
// incl. capabilities + transition tracking). Empty until the first
|
|
36
|
+
// successful fetch; capability-gated entries stay visible meanwhile so
|
|
37
|
+
// older controllers behave exactly as before.
|
|
38
|
+
let teamProfileRegistry = [];
|
|
39
|
+
let activeTeamProfile = null;
|
|
40
|
+
let pendingSwitchTarget = null;
|
|
41
|
+
let pendingSwitchProfileId = "";
|
|
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;
|
|
24
51
|
let clarificationPromptOpen = false;
|
|
25
52
|
let activeClarificationId = null;
|
|
26
53
|
let dismissedClarificationIds = [];
|
|
@@ -43,6 +70,7 @@
|
|
|
43
70
|
"action.dismiss": "Dismiss",
|
|
44
71
|
"action.copyCommand": "Copy command",
|
|
45
72
|
"action.copied": "Copied",
|
|
73
|
+
"action.copyToken": "Copy token",
|
|
46
74
|
"sidebar.workers": "Workers",
|
|
47
75
|
"sidebar.roles": "Roles",
|
|
48
76
|
"tab.planning": "Planning",
|
|
@@ -132,7 +160,6 @@
|
|
|
132
160
|
"runtime.title": "TeamClaw is installed but cannot work yet.",
|
|
133
161
|
"runtime.noModel": "No TeamClaw model is configured for this instance.",
|
|
134
162
|
"runtime.noAuth": "No usable OpenClaw auth profile was found for TeamClaw.",
|
|
135
|
-
"gh.login": "Sign in with GitHub",
|
|
136
163
|
"teamauto.refreshRepos": "Refresh repos",
|
|
137
164
|
"teamauto.bind": "Bind",
|
|
138
165
|
"teamauto.bindStageVerify": "Verifying access",
|
|
@@ -147,7 +174,7 @@
|
|
|
147
174
|
"teamauto.scheduleHint": "Schedules: */N * * * * (every N min), M * * * * (hourly at :M), 0 */N * * * (every N h), M H * * * (daily at H:M), @hourly, @daily, @weekly, @monthly. Sweeps align to the clock and survive restarts.",
|
|
148
175
|
"teamauto.loginFirst": "Sign in to GitHub first (top-right Login).",
|
|
149
176
|
"teamauto.loadingRepos": "Loading your repos...",
|
|
150
|
-
"teamauto.noCandidates": "No selectable repos (check GitHub login)
|
|
177
|
+
"teamauto.noCandidates": "No selectable repos (check GitHub login)",
|
|
151
178
|
"teamauto.needRepo": "Select a repository first",
|
|
152
179
|
"teamauto.active": "active",
|
|
153
180
|
"teamauto.disabled": "disabled",
|
|
@@ -157,6 +184,7 @@
|
|
|
157
184
|
"teamauto.enable": "Enable",
|
|
158
185
|
"teamauto.unbind": "Unbind",
|
|
159
186
|
"teamauto.save": "Save config",
|
|
187
|
+
"teamauto.tabConfig": "Config",
|
|
160
188
|
"teamauto.saved": "Saved",
|
|
161
189
|
"teamauto.schedule": "Schedule",
|
|
162
190
|
"teamauto.maxPerSweep": "Max/sweep",
|
|
@@ -194,7 +222,133 @@
|
|
|
194
222
|
"detail.kicker": "Task Details",
|
|
195
223
|
"live.idle": "Idle",
|
|
196
224
|
"clarification.kicker": "Clarification needed",
|
|
197
|
-
"clarification.title": "Human input required"
|
|
225
|
+
"clarification.title": "Human input required",
|
|
226
|
+
"teamProfile.kicker": "Team profile",
|
|
227
|
+
"teamProfile.title": "Switch team profile",
|
|
228
|
+
"teamProfile.headerButtonTitle": "Team profile - click to view or switch",
|
|
229
|
+
"teamProfile.current": "Current",
|
|
230
|
+
"teamProfile.pendingSignoff": "Pending human sign-off",
|
|
231
|
+
"teamProfile.roleCount": "{n} roles",
|
|
232
|
+
"teamProfile.loadFailed": "Failed to load team profiles",
|
|
233
|
+
"teamProfile.confirmArchive": "The current team's {n} task(s) will be archived as read-only history. This cannot be undone.",
|
|
234
|
+
"teamProfile.confirmWorkers": "All workers stop and re-warm for the new team; task submissions are rejected while the switch runs.",
|
|
235
|
+
"teamProfile.capabilityRestartHint": "Capabilities {list} change with this switch: turning one off stops it immediately, and turning one back on only takes effect after a gateway restart.",
|
|
236
|
+
"teamProfile.confirmButton": "Switch team",
|
|
237
|
+
"teamProfile.cancel": "Back",
|
|
238
|
+
"teamProfile.switching": "Switching…",
|
|
239
|
+
"teamProfile.switchStarted": "Switch started - waiting for the new team to warm up…",
|
|
240
|
+
"teamProfile.transitionPending": "A switch to {name} is already in progress (phase: {phase}).",
|
|
241
|
+
"teamProfile.switchCompleted": "Team profile switched to {name}",
|
|
242
|
+
"teamProfile.switchFailed": "Team profile switch to {name} failed",
|
|
243
|
+
"teamProfile.archivedTitle": "Archived teams",
|
|
244
|
+
"teamProfile.archivedEmpty": "No archived teams yet.",
|
|
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"
|
|
198
352
|
},
|
|
199
353
|
zh: {
|
|
200
354
|
"action.refresh": "刷新",
|
|
@@ -202,6 +356,7 @@
|
|
|
202
356
|
"action.dismiss": "稍后处理",
|
|
203
357
|
"action.copyCommand": "复制命令",
|
|
204
358
|
"action.copied": "已复制",
|
|
359
|
+
"action.copyToken": "复制令牌",
|
|
205
360
|
"sidebar.workers": "成员",
|
|
206
361
|
"sidebar.roles": "角色",
|
|
207
362
|
"tab.planning": "规划",
|
|
@@ -291,7 +446,6 @@
|
|
|
291
446
|
"runtime.title": "TeamClaw 已安装,但当前还无法工作。",
|
|
292
447
|
"runtime.noModel": "当前实例还没有为 TeamClaw 配置模型。",
|
|
293
448
|
"runtime.noAuth": "未找到 TeamClaw 可用的 OpenClaw 认证配置。",
|
|
294
|
-
"gh.login": "使用 GitHub 登录",
|
|
295
449
|
"teamauto.refreshRepos": "刷新仓库",
|
|
296
450
|
"teamauto.bind": "绑定",
|
|
297
451
|
"teamauto.bindStageVerify": "验证访问权限",
|
|
@@ -306,7 +460,7 @@
|
|
|
306
460
|
"teamauto.scheduleHint": "支持的表达式:*/N * * * *(每 N 分钟)、M * * * *(每小时第 M 分)、0 */N * * *(每 N 小时)、M H * * *(每天 H:M)、@hourly、@daily、@weekly、@monthly。扫描按墙钟对齐,重启后自动恢复。",
|
|
307
461
|
"teamauto.loginFirst": "请先登录 GitHub(右上角 Login)。",
|
|
308
462
|
"teamauto.loadingRepos": "正在加载你的仓库...",
|
|
309
|
-
"teamauto.noCandidates": "无可选仓库(请检查 GitHub
|
|
463
|
+
"teamauto.noCandidates": "无可选仓库(请检查 GitHub 登录)",
|
|
310
464
|
"teamauto.needRepo": "请先选择一个仓库",
|
|
311
465
|
"teamauto.active": "运行中",
|
|
312
466
|
"teamauto.disabled": "已停用",
|
|
@@ -316,6 +470,7 @@
|
|
|
316
470
|
"teamauto.enable": "启用",
|
|
317
471
|
"teamauto.unbind": "解绑",
|
|
318
472
|
"teamauto.save": "保存配置",
|
|
473
|
+
"teamauto.tabConfig": "配置",
|
|
319
474
|
"teamauto.saved": "已保存",
|
|
320
475
|
"teamauto.schedule": "节奏",
|
|
321
476
|
"teamauto.maxPerSweep": "每轮上限",
|
|
@@ -326,7 +481,7 @@
|
|
|
326
481
|
"teamauto.confirmUnbind": "确定解绑该仓库?",
|
|
327
482
|
"teamauto.empty": "尚未绑定仓库。在上方选择后点击绑定。",
|
|
328
483
|
"teamauto.activity": "动态",
|
|
329
|
-
"teamauto.activityEmpty": "暂无 TeamAuto
|
|
484
|
+
"teamauto.activityEmpty": "暂无 TeamAuto 动态 - 扫描与写回会出现在这里。",
|
|
330
485
|
"worker.add": "添加 worker",
|
|
331
486
|
"worker.hide": "隐藏 worker 命令",
|
|
332
487
|
"worker.cardTitle": "注册新的外部 worker",
|
|
@@ -353,7 +508,131 @@
|
|
|
353
508
|
"detail.kicker": "任务详情",
|
|
354
509
|
"live.idle": "空闲",
|
|
355
510
|
"clarification.kicker": "需要澄清",
|
|
356
|
-
"clarification.title": "需要人工输入"
|
|
511
|
+
"clarification.title": "需要人工输入",
|
|
512
|
+
"teamProfile.kicker": "团队画像",
|
|
513
|
+
"teamProfile.title": "切换团队画像",
|
|
514
|
+
"teamProfile.headerButtonTitle": "团队画像 - 点击查看或切换",
|
|
515
|
+
"teamProfile.current": "当前",
|
|
516
|
+
"teamProfile.pendingSignoff": "待人工签署",
|
|
517
|
+
"teamProfile.roleCount": "{n} 个角色",
|
|
518
|
+
"teamProfile.loadFailed": "加载团队画像失败",
|
|
519
|
+
"teamProfile.confirmArchive": "当前团队的 {n} 个任务将归档为只读历史,此操作不可撤销。",
|
|
520
|
+
"teamProfile.confirmWorkers": "所有 worker 将停止并按新团队重新预热;切换期间提交的任务会被拒绝。",
|
|
521
|
+
"teamProfile.capabilityRestartHint": "能力 {list} 将随本次切换变化:关闭会立即停用,重新开启需重启网关才会生效。",
|
|
522
|
+
"teamProfile.confirmButton": "切换团队",
|
|
523
|
+
"teamProfile.cancel": "返回",
|
|
524
|
+
"teamProfile.switching": "切换中…",
|
|
525
|
+
"teamProfile.switchStarted": "切换已开始 - 等待新团队预热完成…",
|
|
526
|
+
"teamProfile.transitionPending": "到 {name} 的切换正在进行中(阶段:{phase})。",
|
|
527
|
+
"teamProfile.switchCompleted": "团队画像已切换到 {name}",
|
|
528
|
+
"teamProfile.switchFailed": "切换到 {name} 的团队画像失败",
|
|
529
|
+
"teamProfile.archivedTitle": "已归档团队",
|
|
530
|
+
"teamProfile.archivedEmpty": "暂无已归档团队。",
|
|
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 登录"
|
|
357
636
|
}
|
|
358
637
|
};
|
|
359
638
|
|
|
@@ -399,6 +678,18 @@
|
|
|
399
678
|
element.setAttribute("placeholder", t(key));
|
|
400
679
|
}
|
|
401
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
|
+
});
|
|
402
693
|
var languageToggle = $("#language-toggle");
|
|
403
694
|
if (languageToggle) {
|
|
404
695
|
languageToggle.textContent = currentLanguage === "zh" ? "English" : "中文";
|
|
@@ -1017,19 +1308,12 @@
|
|
|
1017
1308
|
});
|
|
1018
1309
|
}
|
|
1019
1310
|
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
devops: "⚙️",
|
|
1027
|
-
"tech-lead": "👨💻",
|
|
1028
|
-
"data-engineer": "📊",
|
|
1029
|
-
"ml-engineer": "🤖",
|
|
1030
|
-
"infra-engineer": "🖧",
|
|
1031
|
-
"dba": "🗄️",
|
|
1032
|
-
};
|
|
1311
|
+
// Role icons come from the /roles registry (RoleDefinition.icon) instead of
|
|
1312
|
+
// a hand-maintained per-UI map, so profile role sets render their own icons.
|
|
1313
|
+
function roleIcon(roleId) {
|
|
1314
|
+
var role = roleRegistry.find(function (entry) { return entry.id === roleId; });
|
|
1315
|
+
return (role && role.icon) || "👤";
|
|
1316
|
+
}
|
|
1033
1317
|
|
|
1034
1318
|
function renderKickoffMeetingPanel(kickoffPlan) {
|
|
1035
1319
|
if (!kickoffPlan || !Array.isArray(kickoffPlan.assessments) || kickoffPlan.assessments.length === 0) {
|
|
@@ -1053,7 +1337,7 @@
|
|
|
1053
1337
|
"</div>";
|
|
1054
1338
|
|
|
1055
1339
|
var roleCards = assessments.map(function (a) {
|
|
1056
|
-
var icon =
|
|
1340
|
+
var icon = roleIcon(a.role);
|
|
1057
1341
|
var statusCls = a.needed ? "kickoff-role-needed" : "kickoff-role-dismissed";
|
|
1058
1342
|
var statusLabel = a.needed ? "Confirmed" : "Not Needed";
|
|
1059
1343
|
|
|
@@ -1206,7 +1490,7 @@
|
|
|
1206
1490
|
if (manifest.requiredRoles && manifest.requiredRoles.length) {
|
|
1207
1491
|
reqLines.push('<div class="planning-req-section"><div class="planning-req-label">' + escapeHtml(t("planning.requiredRoles")) + "</div>");
|
|
1208
1492
|
reqLines.push('<div class="kickoff-deps">' + manifest.requiredRoles.map(function (r) {
|
|
1209
|
-
var icon =
|
|
1493
|
+
var icon = roleIcon(r);
|
|
1210
1494
|
return '<span class="kickoff-dep-chip">' + icon + " " + escapeHtml(r) + "</span>";
|
|
1211
1495
|
}).join("") + "</div></div>");
|
|
1212
1496
|
}
|
|
@@ -1284,7 +1568,7 @@
|
|
|
1284
1568
|
|
|
1285
1569
|
// Role cards
|
|
1286
1570
|
assessments.forEach(function (a) {
|
|
1287
|
-
var icon =
|
|
1571
|
+
var icon = roleIcon(a.role);
|
|
1288
1572
|
var statusCls = a.needed ? "kickoff-role-needed" : "kickoff-role-dismissed";
|
|
1289
1573
|
var statusLabel = a.needed ? "Confirmed" : "Not Needed";
|
|
1290
1574
|
|
|
@@ -1662,9 +1946,15 @@
|
|
|
1662
1946
|
}
|
|
1663
1947
|
|
|
1664
1948
|
if (!res.ok) {
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
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);
|
|
1668
1958
|
throw new Error(message);
|
|
1669
1959
|
}
|
|
1670
1960
|
|
|
@@ -2022,6 +2312,273 @@
|
|
|
2022
2312
|
);
|
|
2023
2313
|
}
|
|
2024
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
|
+
|
|
2025
2582
|
function renderExternalWorkerInstallToggle() {
|
|
2026
2583
|
var button = $("#worker-install-toggle");
|
|
2027
2584
|
if (!button) return;
|
|
@@ -2048,21 +2605,21 @@
|
|
|
2048
2605
|
card.classList.add("hidden");
|
|
2049
2606
|
return;
|
|
2050
2607
|
}
|
|
2051
|
-
var roles = Array.isArray(info.roles) ? info.roles : [];
|
|
2608
|
+
var roles = visibleRoles(Array.isArray(info.roles) ? info.roles : []);
|
|
2052
2609
|
if (!roles.length) {
|
|
2053
2610
|
card.classList.add("hidden");
|
|
2054
2611
|
card.innerHTML = "";
|
|
2055
2612
|
return;
|
|
2056
2613
|
}
|
|
2057
2614
|
if (!roles.some(function (role) { return role.id === selectedExternalWorkerRole; })) {
|
|
2058
|
-
selectedExternalWorkerRole = roles
|
|
2615
|
+
selectedExternalWorkerRole = resolveDefaultRoleId(roles, info.defaultRole);
|
|
2059
2616
|
}
|
|
2060
2617
|
if (selectedExternalWorkerDiscoveryMode === "manual" && !info.recommendedControllerUrl) {
|
|
2061
2618
|
selectedExternalWorkerDiscoveryMode = "mdns";
|
|
2062
2619
|
}
|
|
2063
2620
|
var roleOptions = roles.map(function (role) {
|
|
2064
2621
|
return '<option value="' + escapeHtml(role.id) + '"' + (role.id === selectedExternalWorkerRole ? " selected" : "") + ">" +
|
|
2065
|
-
escapeHtml((role.icon ? role.icon + " " : "") + (role
|
|
2622
|
+
escapeHtml((role.icon ? role.icon + " " : "") + roleDisplayLabel(role)) +
|
|
2066
2623
|
"</option>";
|
|
2067
2624
|
}).join("");
|
|
2068
2625
|
var command = buildExternalWorkerCommand(info, selectedExternalWorkerRole, selectedExternalWorkerDiscoveryMode);
|
|
@@ -2282,6 +2839,52 @@
|
|
|
2282
2839
|
case "report:ready":
|
|
2283
2840
|
handleReportReady(event.data || {});
|
|
2284
2841
|
break;
|
|
2842
|
+
case "team.switch_started": {
|
|
2843
|
+
// Section 2.3 switch semantics: archive + re-warm in progress. Pull
|
|
2844
|
+
// fresh state so the transition notice surfaces; task submissions
|
|
2845
|
+
// get 503 server-side while the transition runs.
|
|
2846
|
+
const startedData = event.data || {};
|
|
2847
|
+
refreshAll();
|
|
2848
|
+
renderTeamProfileTransitionNotice({
|
|
2849
|
+
phase: "draining",
|
|
2850
|
+
targetProfileId: startedData.profileId || "",
|
|
2851
|
+
});
|
|
2852
|
+
break;
|
|
2853
|
+
}
|
|
2854
|
+
case "team.switch_completed": {
|
|
2855
|
+
// Full re-pull (roles/workers/tasks change wholesale with the new
|
|
2856
|
+
// profile); close the switcher modal when this UI initiated it.
|
|
2857
|
+
const completedProfileId = (event.data || {}).profileId || "";
|
|
2858
|
+
refreshAll();
|
|
2859
|
+
if (teamProfileSwitchInFlight || pendingSwitchProfileId) {
|
|
2860
|
+
finishTeamProfileSwitch(completedProfileId);
|
|
2861
|
+
}
|
|
2862
|
+
showNotice(
|
|
2863
|
+
"team:switch_completed",
|
|
2864
|
+
"success",
|
|
2865
|
+
t("teamProfile.switchCompleted", { name: teamProfileDisplayNameById(completedProfileId) }),
|
|
2866
|
+
"",
|
|
2867
|
+
);
|
|
2868
|
+
break;
|
|
2869
|
+
}
|
|
2870
|
+
case "team.switch_failed": {
|
|
2871
|
+
// Server-side switch failure: release the loading/confirm state with
|
|
2872
|
+
// an explicit failure toast instead of waiting for the reconcile
|
|
2873
|
+
// fallback to silently re-enable the button. The reason may state
|
|
2874
|
+
// that the archive was preserved and the team is partially switched;
|
|
2875
|
+
// the state may have moved partway, so re-pull everything.
|
|
2876
|
+
const failedData = event.data || {};
|
|
2877
|
+
const failedTargetId = failedData.targetProfileId || pendingSwitchProfileId || "";
|
|
2878
|
+
refreshAll();
|
|
2879
|
+
releaseTeamProfileSwitchUi();
|
|
2880
|
+
showNotice(
|
|
2881
|
+
"team:switch_failed",
|
|
2882
|
+
"attention",
|
|
2883
|
+
t("teamProfile.switchFailed", { name: teamProfileDisplayNameById(failedTargetId) }),
|
|
2884
|
+
String(failedData.reason || ""),
|
|
2885
|
+
);
|
|
2886
|
+
break;
|
|
2887
|
+
}
|
|
2285
2888
|
}
|
|
2286
2889
|
}
|
|
2287
2890
|
|
|
@@ -2333,11 +2936,20 @@
|
|
|
2333
2936
|
try {
|
|
2334
2937
|
const statusRes = await apiGet("/team/status");
|
|
2335
2938
|
let rolesRes = { roles: [] };
|
|
2939
|
+
let rolesLoaded = false;
|
|
2336
2940
|
try {
|
|
2337
2941
|
rolesRes = await apiGet("/roles");
|
|
2942
|
+
rolesLoaded = true;
|
|
2338
2943
|
} catch (rolesErr) {
|
|
2339
2944
|
console.error("Failed to load roles:", rolesErr);
|
|
2340
2945
|
}
|
|
2946
|
+
if (rolesLoaded) {
|
|
2947
|
+
// Keep the last known registry when a later refresh fails so the
|
|
2948
|
+
// manual-task options and role icons survive transient /roles errors.
|
|
2949
|
+
roleRegistry = Array.isArray(rolesRes.roles) ? rolesRes.roles : [];
|
|
2950
|
+
roleDefaultId = typeof rolesRes.defaultRole === "string" ? rolesRes.defaultRole : "";
|
|
2951
|
+
renderTaskRoleOptions();
|
|
2952
|
+
}
|
|
2341
2953
|
|
|
2342
2954
|
teamState = {
|
|
2343
2955
|
workers: statusRes.workers || [],
|
|
@@ -2349,6 +2961,35 @@
|
|
|
2349
2961
|
externalWorkerInstall: statusRes.externalWorkerInstall || null,
|
|
2350
2962
|
};
|
|
2351
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
|
+
|
|
2973
|
+
// Active team profile (Phase 5.1): drives the header indicator, the
|
|
2974
|
+
// capability-gated tab visibility, and the switch transition notice.
|
|
2975
|
+
// Tolerated like /roles - an older controller without the endpoint
|
|
2976
|
+
// keeps the default (software-rd) presentation.
|
|
2977
|
+
try {
|
|
2978
|
+
activeTeamProfile = await apiGet("/team/profile");
|
|
2979
|
+
} catch (profileErr) {
|
|
2980
|
+
console.error("Failed to load team profile:", profileErr);
|
|
2981
|
+
}
|
|
2982
|
+
if (activeTeamProfile) {
|
|
2983
|
+
applyCapabilitiesVisibility(activeTeamProfile);
|
|
2984
|
+
renderTeamProfileHeaderButton();
|
|
2985
|
+
renderTeamProfileTransitionNotice();
|
|
2986
|
+
reconcileTeamProfileSwitch();
|
|
2987
|
+
}
|
|
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
|
+
|
|
2352
2993
|
renderWorkers(teamState.workers);
|
|
2353
2994
|
renderTasks(teamState.tasks);
|
|
2354
2995
|
renderPlanningTab(teamState.controllerRuns);
|
|
@@ -2499,7 +3140,7 @@
|
|
|
2499
3140
|
'<div class="task-card' + liveClass + '" data-task-id="' + escapeHtml(task.id) + '" tabindex="0" role="button" aria-label="Open details for ' + escapeHtml(task.title) + '">' +
|
|
2500
3141
|
' <span class="task-priority ' + escapeHtml(priority) + '">' + escapeHtml(priority) + "</span>" +
|
|
2501
3142
|
' <div class="task-body">' +
|
|
2502
|
-
' <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>" +
|
|
2503
3144
|
(task.description ? '<div class="task-desc clamp">' + escapeHtml(task.description).slice(0, 220) + "</div>" : "") +
|
|
2504
3145
|
renderSkillPills(recommendedSkills, "skill-pills task-skill-pills") +
|
|
2505
3146
|
contractSummary +
|
|
@@ -2524,6 +3165,115 @@
|
|
|
2524
3165
|
}
|
|
2525
3166
|
}
|
|
2526
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
|
+
|
|
2527
3277
|
function renderControllerRuns(runs) {
|
|
2528
3278
|
const container = $("#controller-runs");
|
|
2529
3279
|
if (!container) return;
|
|
@@ -2687,9 +3437,9 @@
|
|
|
2687
3437
|
if (subtitle) {
|
|
2688
3438
|
subtitle.textContent = task
|
|
2689
3439
|
? [
|
|
2690
|
-
"
|
|
2691
|
-
task.assignedWorkerId ? "
|
|
2692
|
-
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,
|
|
2693
3443
|
].filter(Boolean).join(" • ")
|
|
2694
3444
|
: "";
|
|
2695
3445
|
}
|
|
@@ -2831,8 +3581,10 @@
|
|
|
2831
3581
|
var opts = options || {};
|
|
2832
3582
|
return normalizeArray(items).map(function (item) {
|
|
2833
3583
|
const status = item.status || "pending";
|
|
3584
|
+
// Worker context is written in markdown (headings, bold, lists) - run
|
|
3585
|
+
// it through the shared renderer instead of raw textContent.
|
|
2834
3586
|
const context = item.context
|
|
2835
|
-
? '<div class="clarification-context"><strong>Context:</strong>
|
|
3587
|
+
? '<div class="clarification-context"><strong>Context:</strong><div class="clarification-context-md">' + renderMarkdown(item.context) + "</div></div>"
|
|
2836
3588
|
: "";
|
|
2837
3589
|
const taskLink = opts.linkToTask && item.taskId
|
|
2838
3590
|
? '<button type="button" class="btn btn-small" data-open-task-id="' + escapeHtml(item.taskId) + '">Open task</button>'
|
|
@@ -3089,16 +3841,175 @@
|
|
|
3089
3841
|
const container = $("#roles-list");
|
|
3090
3842
|
if (!container) return;
|
|
3091
3843
|
|
|
3092
|
-
container.innerHTML = roles.map(function (role) {
|
|
3844
|
+
container.innerHTML = visibleRoles(roles).map(function (role) {
|
|
3093
3845
|
return (
|
|
3094
3846
|
'<div class="role-chip">' +
|
|
3095
3847
|
" <span>" + escapeHtml(role.icon || "") + "</span>" +
|
|
3096
|
-
" <span>" + escapeHtml(role
|
|
3848
|
+
" <span>" + escapeHtml(roleDisplayLabel(role)) + "</span>" +
|
|
3097
3849
|
"</div>"
|
|
3098
3850
|
);
|
|
3099
3851
|
}).join("");
|
|
3100
3852
|
}
|
|
3101
3853
|
|
|
3854
|
+
// Manual-task form: role options are generated from the /roles registry
|
|
3855
|
+
// (rendered on each refresh); the Auto-assign placeholder stays in the
|
|
3856
|
+
// static HTML so i18n keeps applying to it. Preserves the current selection
|
|
3857
|
+
// across refreshes when the role is still offered.
|
|
3858
|
+
function renderTaskRoleOptions() {
|
|
3859
|
+
const select = $("#task-role");
|
|
3860
|
+
if (!select) return;
|
|
3861
|
+
const previous = select.value;
|
|
3862
|
+
while (select.options.length > 1) {
|
|
3863
|
+
select.remove(1);
|
|
3864
|
+
}
|
|
3865
|
+
visibleRoles(roleRegistry).forEach(function (role) {
|
|
3866
|
+
if (!role || typeof role.id !== "string" || !role.id) return;
|
|
3867
|
+
const option = document.createElement("option");
|
|
3868
|
+
option.value = role.id;
|
|
3869
|
+
option.textContent = roleDisplayLabel(role);
|
|
3870
|
+
select.appendChild(option);
|
|
3871
|
+
});
|
|
3872
|
+
if (previous && Array.prototype.some.call(select.options, function (option) { return option.value === previous; })) {
|
|
3873
|
+
select.value = previous;
|
|
3874
|
+
}
|
|
3875
|
+
}
|
|
3876
|
+
|
|
3877
|
+
// Default role for the external-worker install card: prefer the default the
|
|
3878
|
+
// backend advertises on the externalWorkerInstall payload (/team/status),
|
|
3879
|
+
// then one advertised on /roles, else fall back to the first registry entry.
|
|
3880
|
+
function resolveDefaultRoleId(roles, payloadDefaultId) {
|
|
3881
|
+
var preferred = typeof payloadDefaultId === "string" && payloadDefaultId ? payloadDefaultId : roleDefaultId;
|
|
3882
|
+
if (preferred && roles.some(function (role) { return role.id === preferred; })) {
|
|
3883
|
+
return preferred;
|
|
3884
|
+
}
|
|
3885
|
+
return roles.length > 0 ? roles[0].id : "";
|
|
3886
|
+
}
|
|
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
|
+
|
|
3102
4013
|
function tabNameFromHash() {
|
|
3103
4014
|
const match = /^#\/tab\/([a-z][a-z0-9-]*)$/i.exec(window.location.hash || "");
|
|
3104
4015
|
const name = match ? match[1] : "";
|
|
@@ -3120,6 +4031,20 @@
|
|
|
3120
4031
|
}
|
|
3121
4032
|
|
|
3122
4033
|
function activateTab(nextTab) {
|
|
4034
|
+
// TeamAuto sub-tabs (Config / Activity) - delegated once, DOM-level.
|
|
4035
|
+
// NOTE: guard via function property - document.dataset is undefined on
|
|
4036
|
+
// Document (it only exists on Element) and threw during init, killing
|
|
4037
|
+
// every listener registered after it (user-visible: ALL clicks dead).
|
|
4038
|
+
if (!activateTab.taSubtabsBound) {
|
|
4039
|
+
activateTab.taSubtabsBound = true;
|
|
4040
|
+
document.addEventListener("click", function (event) {
|
|
4041
|
+
const btn = event.target instanceof Element && event.target.closest("[data-ta-pane]");
|
|
4042
|
+
if (!btn || btn.tagName !== "BUTTON") return;
|
|
4043
|
+
const pane = btn.getAttribute("data-ta-pane");
|
|
4044
|
+
$$("[data-ta-pane]").forEach((b) => b.classList.toggle("active", b === btn));
|
|
4045
|
+
$$("[data-ta-pane-body]").forEach((p) => p.classList.toggle("is-hidden", p.getAttribute("data-ta-pane-body") !== pane));
|
|
4046
|
+
});
|
|
4047
|
+
}
|
|
3123
4048
|
activeTab = nextTab || "tasks";
|
|
3124
4049
|
$$(".tab").forEach(function (item) {
|
|
3125
4050
|
item.classList.toggle("active", item.dataset.tab === activeTab);
|
|
@@ -3369,7 +4294,7 @@
|
|
|
3369
4294
|
const answer = answerInput ? answerInput.value.trim() : "";
|
|
3370
4295
|
|
|
3371
4296
|
if (!clarificationId || !answer) {
|
|
3372
|
-
showError("
|
|
4297
|
+
showError(t("clarification.needAnswer"));
|
|
3373
4298
|
return;
|
|
3374
4299
|
}
|
|
3375
4300
|
|
|
@@ -3524,6 +4449,9 @@
|
|
|
3524
4449
|
type: "controller-input",
|
|
3525
4450
|
content: cmd,
|
|
3526
4451
|
});
|
|
4452
|
+
// User spec: sending an intake IS a conversation action - jump to the
|
|
4453
|
+
// Messages tab so the reply lands in view without an extra click.
|
|
4454
|
+
activateTab("messages");
|
|
3527
4455
|
|
|
3528
4456
|
apiPost("/controller/intake", {
|
|
3529
4457
|
message: cmd,
|
|
@@ -3597,7 +4525,7 @@
|
|
|
3597
4525
|
if (!el) return;
|
|
3598
4526
|
apiGet("/workspace/status").then(function (data) {
|
|
3599
4527
|
if (data && typeof data.workspaceDir === "string") {
|
|
3600
|
-
el.textContent = data.workspaceDir + (data.isDefault ? " (default)" : "");
|
|
4528
|
+
el.textContent = data.workspaceDir + (data.isDefault ? " (" + t("ctl.ws.default") + ")" : "");
|
|
3601
4529
|
el.title = data.workspaceDir;
|
|
3602
4530
|
}
|
|
3603
4531
|
}).catch(function () { /* leave placeholder */ });
|
|
@@ -3608,7 +4536,7 @@
|
|
|
3608
4536
|
var pathEl = $("#workspace-prompt-path");
|
|
3609
4537
|
var input = $("#workspace-prompt-input");
|
|
3610
4538
|
if (!modal || !pathEl || !input) return;
|
|
3611
|
-
pathEl.textContent = currentPath || "
|
|
4539
|
+
pathEl.textContent = currentPath || t("ws.unknown");
|
|
3612
4540
|
input.value = currentPath || "";
|
|
3613
4541
|
modal.classList.add("open");
|
|
3614
4542
|
modal.setAttribute("aria-hidden", "false");
|
|
@@ -3660,13 +4588,13 @@
|
|
|
3660
4588
|
input.value = handle.name || input.value;
|
|
3661
4589
|
input.dataset.verifiedPath = "";
|
|
3662
4590
|
}
|
|
3663
|
-
showError("
|
|
4591
|
+
showError(t("ws.pickerNoPath"));
|
|
3664
4592
|
})
|
|
3665
4593
|
.catch(function () {
|
|
3666
4594
|
/* user cancelled */
|
|
3667
4595
|
});
|
|
3668
4596
|
} else {
|
|
3669
|
-
showError("
|
|
4597
|
+
showError(t("ws.pickerUnsupported"));
|
|
3670
4598
|
}
|
|
3671
4599
|
});
|
|
3672
4600
|
}
|
|
@@ -3675,17 +4603,17 @@
|
|
|
3675
4603
|
apply.addEventListener("click", function () {
|
|
3676
4604
|
var value = input && typeof input.value === "string" ? input.value.trim() : "";
|
|
3677
4605
|
if (!value || value.indexOf("/") !== 0) {
|
|
3678
|
-
showError("
|
|
4606
|
+
showError(t("ws.needAbsolute"));
|
|
3679
4607
|
return;
|
|
3680
4608
|
}
|
|
3681
4609
|
apply.disabled = true;
|
|
3682
4610
|
apiPost("/workspace/change-dir", { workspaceDir: value }).then(function () {
|
|
3683
4611
|
localStorage.setItem(WORKSPACE_PROMPT_DISMISSED_KEY, "1");
|
|
3684
4612
|
closeWorkspacePromptModal();
|
|
3685
|
-
showError("
|
|
4613
|
+
showError(t("ctl.ws.saved"));
|
|
3686
4614
|
updateWorkspacePathIndicator();
|
|
3687
4615
|
}).catch(function (err) {
|
|
3688
|
-
showError(err instanceof Error ? err.message : "
|
|
4616
|
+
showError(err instanceof Error ? err.message : t("ctl.ws.failed"));
|
|
3689
4617
|
}).finally(function () {
|
|
3690
4618
|
apply.disabled = false;
|
|
3691
4619
|
});
|
|
@@ -3701,16 +4629,426 @@
|
|
|
3701
4629
|
bindWorkspacePrompt();
|
|
3702
4630
|
promptWorkspaceIfDefault();
|
|
3703
4631
|
updateWorkspacePathIndicator();
|
|
4632
|
+
bindTeamProfileModal();
|
|
4633
|
+
bindSecurityUi();
|
|
3704
4634
|
bindModelSettings();
|
|
3705
4635
|
bindGithubCorner();
|
|
3706
4636
|
|
|
4637
|
+
// ==================== Team profile switcher (Phase 5.1) ====================
|
|
4638
|
+
// Header mini-button + modal over the model-settings-modal precedent:
|
|
4639
|
+
// step 1 lists GET /api/v1/profiles cards, step 2 confirms the section 2.3
|
|
4640
|
+
// archive consequences, then POST /api/v1/team/profile is tracked via the
|
|
4641
|
+
// team.switch_started / team.switch_completed WS events. The archived
|
|
4642
|
+
// teams section lists GET /api/v1/archived-teams metadata read-only.
|
|
4643
|
+
|
|
4644
|
+
function profileDisplayLabel(profile) {
|
|
4645
|
+
if (!profile) return "";
|
|
4646
|
+
if (currentLanguage === "zh") {
|
|
4647
|
+
return profile.nameZh || profile.name || profile.id || "";
|
|
4648
|
+
}
|
|
4649
|
+
return profile.name || profile.nameZh || profile.id || "";
|
|
4650
|
+
}
|
|
4651
|
+
|
|
4652
|
+
function teamProfileDisplayNameById(profileId) {
|
|
4653
|
+
if (!profileId) return "";
|
|
4654
|
+
var entry = teamProfileRegistry.filter(function (p) { return p.id === profileId; })[0];
|
|
4655
|
+
if (entry) return profileDisplayLabel(entry);
|
|
4656
|
+
if (activeTeamProfile && activeTeamProfile.profile && activeTeamProfile.profile.id === profileId) {
|
|
4657
|
+
return profileDisplayLabel(activeTeamProfile.profile);
|
|
4658
|
+
}
|
|
4659
|
+
return profileId;
|
|
4660
|
+
}
|
|
4661
|
+
|
|
4662
|
+
// reviewedBy carries the review-trail strings from the profile packs; a
|
|
4663
|
+
// "Human sign-off pending" entry means the finance-domain review is not
|
|
4664
|
+
// countersigned yet and the card must say so rather than hide it.
|
|
4665
|
+
function profileHasPendingSignoff(profile) {
|
|
4666
|
+
return (profile && Array.isArray(profile.reviewedBy) ? profile.reviewedBy : []).some(function (entry) {
|
|
4667
|
+
return String(entry).indexOf("Human sign-off pending") !== -1;
|
|
4668
|
+
});
|
|
4669
|
+
}
|
|
4670
|
+
|
|
4671
|
+
function renderTeamProfileHeaderButton() {
|
|
4672
|
+
var button = $("#team-profile-toggle");
|
|
4673
|
+
if (!button) return;
|
|
4674
|
+
var profile = activeTeamProfile && activeTeamProfile.profile;
|
|
4675
|
+
var icon = profile && profile.icon ? profile.icon + " " : "";
|
|
4676
|
+
var label = profile
|
|
4677
|
+
? profileDisplayLabel(profile)
|
|
4678
|
+
: ((activeTeamProfile && activeTeamProfile.profileId) || "Team");
|
|
4679
|
+
button.textContent = icon + label;
|
|
4680
|
+
button.title = t("teamProfile.headerButtonTitle");
|
|
4681
|
+
}
|
|
4682
|
+
|
|
4683
|
+
// UI contract (design section 4 / P2.3): GET /team/profile carries the
|
|
4684
|
+
// active capabilities and the UI hides capability-gated entries. The
|
|
4685
|
+
// teamauto tab is hidden (NOT removed) so the DOM keeps its full tab set
|
|
4686
|
+
// for contract tests; unknown/missing capabilities default to visible so
|
|
4687
|
+
// software-rd and older controllers behave exactly as before.
|
|
4688
|
+
function applyCapabilitiesVisibility(profileInfo) {
|
|
4689
|
+
var caps = profileInfo && profileInfo.profile && profileInfo.profile.capabilities;
|
|
4690
|
+
var teamautoEnabled = !caps || caps.teamauto !== false;
|
|
4691
|
+
var teamautoTab = $('[data-tab="teamauto"]');
|
|
4692
|
+
if (teamautoTab) {
|
|
4693
|
+
teamautoTab.hidden = !teamautoEnabled;
|
|
4694
|
+
}
|
|
4695
|
+
if (!teamautoEnabled && activeTab === "teamauto") {
|
|
4696
|
+
activateTab("tasks");
|
|
4697
|
+
}
|
|
4698
|
+
}
|
|
4699
|
+
|
|
4700
|
+
function openTeamProfileModal() {
|
|
4701
|
+
var modal = $("#team-profile-modal");
|
|
4702
|
+
if (!modal) return;
|
|
4703
|
+
showTeamProfileListStep();
|
|
4704
|
+
renderTeamProfileTransitionNotice();
|
|
4705
|
+
modal.classList.add("open");
|
|
4706
|
+
modal.setAttribute("aria-hidden", "false");
|
|
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();
|
|
4715
|
+
}
|
|
4716
|
+
|
|
4717
|
+
function closeTeamProfileModal() {
|
|
4718
|
+
var modal = $("#team-profile-modal");
|
|
4719
|
+
if (!modal) return;
|
|
4720
|
+
modal.classList.remove("open");
|
|
4721
|
+
modal.setAttribute("aria-hidden", "true");
|
|
4722
|
+
// A switch in flight keeps its confirm-step state so the completion
|
|
4723
|
+
// event still closes cleanly; otherwise reset for the next open.
|
|
4724
|
+
if (!teamProfileSwitchInFlight) {
|
|
4725
|
+
showTeamProfileListStep();
|
|
4726
|
+
}
|
|
4727
|
+
}
|
|
4728
|
+
|
|
4729
|
+
function refreshTeamProfileModalData() {
|
|
4730
|
+
apiGet("/profiles").then(function (data) {
|
|
4731
|
+
teamProfileRegistry = data && Array.isArray(data.profiles) ? data.profiles : [];
|
|
4732
|
+
renderTeamProfileCards();
|
|
4733
|
+
}).catch(function (err) {
|
|
4734
|
+
var listEl = $("#team-profile-list");
|
|
4735
|
+
if (listEl) {
|
|
4736
|
+
listEl.innerHTML = '<div class="empty-state">' + escapeHtml(t("teamProfile.loadFailed")) + "</div>";
|
|
4737
|
+
}
|
|
4738
|
+
showError(err instanceof Error ? err.message : t("teamProfile.loadFailed"));
|
|
4739
|
+
});
|
|
4740
|
+
renderTeamProfileArchives();
|
|
4741
|
+
}
|
|
4742
|
+
|
|
4743
|
+
function renderTeamProfileCards() {
|
|
4744
|
+
var listEl = $("#team-profile-list");
|
|
4745
|
+
if (!listEl) return;
|
|
4746
|
+
if (!teamProfileRegistry.length) {
|
|
4747
|
+
listEl.innerHTML = '<div class="empty-state">' + escapeHtml(t("teamProfile.loadFailed")) + "</div>";
|
|
4748
|
+
return;
|
|
4749
|
+
}
|
|
4750
|
+
var activeId = (activeTeamProfile && activeTeamProfile.profileId) || "";
|
|
4751
|
+
var locked = Boolean(activeTeamProfile && activeTeamProfile.transition);
|
|
4752
|
+
listEl.innerHTML = teamProfileRegistry.map(function (profile) {
|
|
4753
|
+
var isActive = profile.id === activeId;
|
|
4754
|
+
var pending = profileHasPendingSignoff(profile);
|
|
4755
|
+
var primary = currentLanguage === "zh"
|
|
4756
|
+
? (profile.nameZh || profile.name || profile.id)
|
|
4757
|
+
: (profile.name || profile.nameZh || profile.id);
|
|
4758
|
+
var secondary = currentLanguage === "zh"
|
|
4759
|
+
? (profile.name && profile.name !== primary ? profile.name : "")
|
|
4760
|
+
: (profile.nameZh && profile.nameZh !== primary ? profile.nameZh : "");
|
|
4761
|
+
return (
|
|
4762
|
+
'<button type="button" class="team-profile-card' + (isActive ? " active" : "") + (locked ? " is-locked" : "") +
|
|
4763
|
+
'" data-profile-id="' + escapeHtml(profile.id) + '"' + (isActive ? ' aria-current="true"' : "") + '>' +
|
|
4764
|
+
' <span class="team-profile-card-icon">' + escapeHtml(profile.icon || "") + "</span>" +
|
|
4765
|
+
' <span class="team-profile-card-main">' +
|
|
4766
|
+
' <span class="team-profile-card-name">' + escapeHtml(primary) +
|
|
4767
|
+
(secondary ? ' <span class="team-profile-card-name-alt">' + escapeHtml(secondary) + "</span>" : "") +
|
|
4768
|
+
(pending ? ' <span class="team-profile-chip pending" title="' + escapeHtml((profile.reviewedBy || []).join(" | ")) + '">' + escapeHtml(t("teamProfile.pendingSignoff")) + "</span>" : "") +
|
|
4769
|
+
"</span>" +
|
|
4770
|
+
' <span class="team-profile-card-desc">' + escapeHtml(profile.description || "") + "</span>" +
|
|
4771
|
+
' <span class="team-profile-card-meta">' +
|
|
4772
|
+
' <span class="team-profile-chip">' + escapeHtml(profile.industry || "") + "</span>" +
|
|
4773
|
+
' <span class="team-profile-chip">v' + escapeHtml(profile.version || "") + "</span>" +
|
|
4774
|
+
' <span class="team-profile-chip">' + escapeHtml(t("teamProfile.roleCount", { n: profile.roleCount || 0 })) + "</span>" +
|
|
4775
|
+
" </span>" +
|
|
4776
|
+
" </span>" +
|
|
4777
|
+
(isActive ? '<span class="team-profile-card-current">' + escapeHtml(t("teamProfile.current")) + "</span>" : "") +
|
|
4778
|
+
"</button>"
|
|
4779
|
+
);
|
|
4780
|
+
}).join("");
|
|
4781
|
+
}
|
|
4782
|
+
|
|
4783
|
+
function showTeamProfileListStep() {
|
|
4784
|
+
var listEl = $("#team-profile-list");
|
|
4785
|
+
var confirmEl = $("#team-profile-confirm");
|
|
4786
|
+
var statusEl = $("#team-profile-switch-status");
|
|
4787
|
+
if (!teamProfileSwitchInFlight) {
|
|
4788
|
+
pendingSwitchTarget = null;
|
|
4789
|
+
pendingSwitchProfileId = "";
|
|
4790
|
+
if (listEl) listEl.hidden = false;
|
|
4791
|
+
if (confirmEl) confirmEl.hidden = true;
|
|
4792
|
+
if (statusEl) statusEl.hidden = true;
|
|
4793
|
+
resetTeamProfileConfirmButton();
|
|
4794
|
+
renderTeamProfileCards();
|
|
4795
|
+
} else {
|
|
4796
|
+
// Keep the confirm step visible while the switch runs.
|
|
4797
|
+
if (listEl) listEl.hidden = true;
|
|
4798
|
+
if (confirmEl) confirmEl.hidden = false;
|
|
4799
|
+
}
|
|
4800
|
+
}
|
|
4801
|
+
|
|
4802
|
+
// Capability off->on restart semantics (#193): runtime teardown during a
|
|
4803
|
+
// switch is one-directional - switching a capability OFF stops its
|
|
4804
|
+
// subsystem immediately, but switching it back ON does not (re)start it
|
|
4805
|
+
// (TeamAuto scheduling / preview restoration are wired at controller
|
|
4806
|
+
// startup only). Any capability that DIFFERS between the active profile
|
|
4807
|
+
// and the selected target therefore deserves a heads-up in the confirm
|
|
4808
|
+
// step. Data: the active profile's capabilities from /team/profile, the
|
|
4809
|
+
// target's from the /profiles listing. Older controllers without the
|
|
4810
|
+
// capabilities field simply skip the hint.
|
|
4811
|
+
function teamProfileCapabilitiesChanging(targetProfile) {
|
|
4812
|
+
var activeCaps = activeTeamProfile && activeTeamProfile.profile && activeTeamProfile.profile.capabilities;
|
|
4813
|
+
var targetCaps = targetProfile && targetProfile.capabilities;
|
|
4814
|
+
if (!activeCaps || !targetCaps) return [];
|
|
4815
|
+
return Object.keys(targetCaps).filter(function (key) {
|
|
4816
|
+
return Boolean(activeCaps[key]) !== Boolean(targetCaps[key]);
|
|
4817
|
+
});
|
|
4818
|
+
}
|
|
4819
|
+
|
|
4820
|
+
function showTeamProfileConfirmStep(profile) {
|
|
4821
|
+
if (!profile) return;
|
|
4822
|
+
var listEl = $("#team-profile-list");
|
|
4823
|
+
var confirmEl = $("#team-profile-confirm");
|
|
4824
|
+
var bodyEl = $("#team-profile-confirm-body");
|
|
4825
|
+
var statusEl = $("#team-profile-switch-status");
|
|
4826
|
+
pendingSwitchTarget = profile;
|
|
4827
|
+
pendingSwitchProfileId = profile.id;
|
|
4828
|
+
if (listEl) listEl.hidden = true;
|
|
4829
|
+
if (confirmEl) confirmEl.hidden = false;
|
|
4830
|
+
if (statusEl) statusEl.hidden = true;
|
|
4831
|
+
var taskCount = (teamState.tasks || []).length;
|
|
4832
|
+
var changingCaps = teamProfileCapabilitiesChanging(profile);
|
|
4833
|
+
if (bodyEl) {
|
|
4834
|
+
bodyEl.innerHTML = (
|
|
4835
|
+
"<h3>" + escapeHtml((profile.icon ? profile.icon + " " : "") + profileDisplayLabel(profile)) + "</h3>" +
|
|
4836
|
+
'<p class="team-profile-confirm-warning">' + escapeHtml(t("teamProfile.confirmArchive", { n: taskCount })) + "</p>" +
|
|
4837
|
+
'<p class="workspace-prompt-note">' + escapeHtml(t("teamProfile.confirmWorkers")) + "</p>" +
|
|
4838
|
+
(changingCaps.length
|
|
4839
|
+
? '<p class="team-profile-confirm-warning">' +
|
|
4840
|
+
escapeHtml(t("teamProfile.capabilityRestartHint", { list: changingCaps.join(", ") })) +
|
|
4841
|
+
"</p>"
|
|
4842
|
+
: "")
|
|
4843
|
+
);
|
|
4844
|
+
}
|
|
4845
|
+
resetTeamProfileConfirmButton();
|
|
4846
|
+
}
|
|
4847
|
+
|
|
4848
|
+
function resetTeamProfileConfirmButton() {
|
|
4849
|
+
var button = $("#team-profile-confirm-btn");
|
|
4850
|
+
if (!button) return;
|
|
4851
|
+
button.disabled = false;
|
|
4852
|
+
button.textContent = t("teamProfile.confirmButton");
|
|
4853
|
+
}
|
|
4854
|
+
|
|
4855
|
+
// POST /team/profile resolves 202 immediately; progress arrives through
|
|
4856
|
+
// the WS events, so this fetch is separate from apiRequest to read the
|
|
4857
|
+
// 409 (transition in progress) status and body directly.
|
|
4858
|
+
function submitTeamProfileSwitch(profileId) {
|
|
4859
|
+
var button = $("#team-profile-confirm-btn");
|
|
4860
|
+
var statusEl = $("#team-profile-switch-status");
|
|
4861
|
+
if (!profileId) return;
|
|
4862
|
+
if (button) {
|
|
4863
|
+
button.disabled = true;
|
|
4864
|
+
button.textContent = t("teamProfile.switching");
|
|
4865
|
+
}
|
|
4866
|
+
if (statusEl) {
|
|
4867
|
+
statusEl.hidden = false;
|
|
4868
|
+
statusEl.textContent = t("teamProfile.switchStarted");
|
|
4869
|
+
}
|
|
4870
|
+
teamProfileSwitchInFlight = true;
|
|
4871
|
+
pendingSwitchProfileId = profileId;
|
|
4872
|
+
fetch(API_BASE + "/team/profile", {
|
|
4873
|
+
method: "POST",
|
|
4874
|
+
headers: { "Content-Type": "application/json" },
|
|
4875
|
+
body: JSON.stringify({ profileId: profileId }),
|
|
4876
|
+
}).then(function (res) {
|
|
4877
|
+
return res.json().catch(function () { return {}; }).then(function (data) {
|
|
4878
|
+
return { status: res.status, ok: res.ok, data: data };
|
|
4879
|
+
});
|
|
4880
|
+
}).then(function (result) {
|
|
4881
|
+
if (result.status === 202) {
|
|
4882
|
+
// Progress + completion arrive via team.switch_started /
|
|
4883
|
+
// team.switch_completed; reconcileTeamProfileSwitch covers a lost
|
|
4884
|
+
// WS connection on every refreshAll.
|
|
4885
|
+
renderTeamProfileTransitionNotice({ phase: "draining", targetProfileId: profileId });
|
|
4886
|
+
return;
|
|
4887
|
+
}
|
|
4888
|
+
if (result.status === 409) {
|
|
4889
|
+
var transition = (result.data && result.data.transition) ||
|
|
4890
|
+
(activeTeamProfile && activeTeamProfile.transition) || null;
|
|
4891
|
+
renderTeamProfileTransitionNotice(transition, result.data && result.data.error);
|
|
4892
|
+
releaseTeamProfileSwitchUi();
|
|
4893
|
+
return;
|
|
4894
|
+
}
|
|
4895
|
+
throw new Error((result.data && (result.data.error || result.data.message)) || ("Request failed: " + result.status));
|
|
4896
|
+
}).catch(function (err) {
|
|
4897
|
+
showError(err instanceof Error ? err.message : "Failed to switch team profile");
|
|
4898
|
+
releaseTeamProfileSwitchUi();
|
|
4899
|
+
});
|
|
4900
|
+
}
|
|
4901
|
+
|
|
4902
|
+
function releaseTeamProfileSwitchUi() {
|
|
4903
|
+
teamProfileSwitchInFlight = false;
|
|
4904
|
+
pendingSwitchProfileId = "";
|
|
4905
|
+
resetTeamProfileConfirmButton();
|
|
4906
|
+
var statusEl = $("#team-profile-switch-status");
|
|
4907
|
+
if (statusEl) statusEl.hidden = true;
|
|
4908
|
+
}
|
|
4909
|
+
|
|
4910
|
+
function finishTeamProfileSwitch(completedProfileId) {
|
|
4911
|
+
var targetId = completedProfileId || pendingSwitchProfileId || "";
|
|
4912
|
+
releaseTeamProfileSwitchUi();
|
|
4913
|
+
pendingSwitchTarget = null;
|
|
4914
|
+
closeTeamProfileModal();
|
|
4915
|
+
showTeamProfileListStep();
|
|
4916
|
+
showNotice(
|
|
4917
|
+
"team:switch_completed",
|
|
4918
|
+
"success",
|
|
4919
|
+
t("teamProfile.switchCompleted", { name: teamProfileDisplayNameById(targetId) }),
|
|
4920
|
+
"",
|
|
4921
|
+
);
|
|
4922
|
+
}
|
|
4923
|
+
|
|
4924
|
+
// Called from refreshAll: if a switch this UI initiated is no longer in a
|
|
4925
|
+
// transition, it either completed (profileId moved to the target - close
|
|
4926
|
+
// the modal) or aborted (re-enable the button).
|
|
4927
|
+
function reconcileTeamProfileSwitch() {
|
|
4928
|
+
if (!pendingSwitchProfileId && !teamProfileSwitchInFlight) return;
|
|
4929
|
+
if (activeTeamProfile.transition) {
|
|
4930
|
+
renderTeamProfileTransitionNotice(activeTeamProfile.transition);
|
|
4931
|
+
return;
|
|
4932
|
+
}
|
|
4933
|
+
if (activeTeamProfile.profileId === pendingSwitchProfileId) {
|
|
4934
|
+
finishTeamProfileSwitch(activeTeamProfile.profileId);
|
|
4935
|
+
} else {
|
|
4936
|
+
releaseTeamProfileSwitchUi();
|
|
4937
|
+
}
|
|
4938
|
+
}
|
|
4939
|
+
|
|
4940
|
+
function renderTeamProfileTransitionNotice(transition, errorText) {
|
|
4941
|
+
var el = $("#team-profile-transition");
|
|
4942
|
+
if (!el) return;
|
|
4943
|
+
var tr = transition || (activeTeamProfile && activeTeamProfile.transition) || null;
|
|
4944
|
+
if (!tr) {
|
|
4945
|
+
el.hidden = true;
|
|
4946
|
+
el.textContent = "";
|
|
4947
|
+
return;
|
|
4948
|
+
}
|
|
4949
|
+
el.hidden = false;
|
|
4950
|
+
el.textContent = t("teamProfile.transitionPending", {
|
|
4951
|
+
name: teamProfileDisplayNameById(tr.targetProfileId),
|
|
4952
|
+
phase: tr.phase || "",
|
|
4953
|
+
}) + (errorText ? " - " + errorText : "");
|
|
4954
|
+
}
|
|
4955
|
+
|
|
4956
|
+
function renderTeamProfileArchives() {
|
|
4957
|
+
var el = $("#team-profile-archives");
|
|
4958
|
+
if (!el) return;
|
|
4959
|
+
apiGet("/archived-teams").then(function (data) {
|
|
4960
|
+
var archives = data && Array.isArray(data.archives) ? data.archives : [];
|
|
4961
|
+
if (!archives.length) {
|
|
4962
|
+
el.innerHTML = '<div class="empty-state">' + escapeHtml(t("teamProfile.archivedEmpty")) + "</div>";
|
|
4963
|
+
return;
|
|
4964
|
+
}
|
|
4965
|
+
el.innerHTML = archives.map(function (archive) {
|
|
4966
|
+
var when = archive.archivedAt ? new Date(archive.archivedAt).toLocaleString() : "";
|
|
4967
|
+
return (
|
|
4968
|
+
'<div class="team-profile-archive-row">' +
|
|
4969
|
+
'<span class="team-profile-archive-team">' + escapeHtml(archive.teamName || archive.profileName || archive.profileId || "") + "</span>" +
|
|
4970
|
+
'<span class="team-profile-archive-profile">' + escapeHtml(archive.profileName || archive.profileId || "") + "</span>" +
|
|
4971
|
+
'<span class="team-profile-archive-meta">' + escapeHtml(when) + " · " + escapeHtml(t("teamProfile.archivedTasks", { n: archive.taskCount || 0 })) + "</span>" +
|
|
4972
|
+
"</div>"
|
|
4973
|
+
);
|
|
4974
|
+
}).join("");
|
|
4975
|
+
}).catch(function () {
|
|
4976
|
+
el.innerHTML = '<div class="empty-state">' + escapeHtml(t("teamProfile.archivedEmpty")) + "</div>";
|
|
4977
|
+
});
|
|
4978
|
+
}
|
|
4979
|
+
|
|
4980
|
+
function bindTeamProfileModal() {
|
|
4981
|
+
var toggle = $("#team-profile-toggle");
|
|
4982
|
+
if (toggle && !toggle.dataset.bound) {
|
|
4983
|
+
toggle.dataset.bound = "true";
|
|
4984
|
+
toggle.addEventListener("click", openTeamProfileModal);
|
|
4985
|
+
}
|
|
4986
|
+
var modal = $("#team-profile-modal");
|
|
4987
|
+
if (!modal || modal.dataset.bound === "true") return;
|
|
4988
|
+
modal.dataset.bound = "true";
|
|
4989
|
+
|
|
4990
|
+
modal.addEventListener("click", function (event) {
|
|
4991
|
+
if (event.target && event.target.hasAttribute && event.target.hasAttribute("data-team-profile-close")) {
|
|
4992
|
+
closeTeamProfileModal();
|
|
4993
|
+
}
|
|
4994
|
+
});
|
|
4995
|
+
|
|
4996
|
+
var listEl = $("#team-profile-list");
|
|
4997
|
+
if (listEl) {
|
|
4998
|
+
listEl.addEventListener("click", function (event) {
|
|
4999
|
+
var card = event.target instanceof Element ? event.target.closest("[data-profile-id]") : null;
|
|
5000
|
+
if (!card) return;
|
|
5001
|
+
var profileId = card.getAttribute("data-profile-id") || "";
|
|
5002
|
+
var profile = teamProfileRegistry.filter(function (p) { return p.id === profileId; })[0];
|
|
5003
|
+
if (!profile) return;
|
|
5004
|
+
var activeId = (activeTeamProfile && activeTeamProfile.profileId) || "";
|
|
5005
|
+
if (profileId === activeId) return; // current team: informational only
|
|
5006
|
+
if (activeTeamProfile && activeTeamProfile.transition) {
|
|
5007
|
+
// A switch is already running (section 2.3 409 matrix): surface
|
|
5008
|
+
// the in-progress notice instead of a second confirmation.
|
|
5009
|
+
renderTeamProfileTransitionNotice(activeTeamProfile.transition);
|
|
5010
|
+
return;
|
|
5011
|
+
}
|
|
5012
|
+
showTeamProfileConfirmStep(profile);
|
|
5013
|
+
});
|
|
5014
|
+
}
|
|
5015
|
+
|
|
5016
|
+
var backButton = $("#team-profile-confirm-back");
|
|
5017
|
+
if (backButton) {
|
|
5018
|
+
backButton.addEventListener("click", function () {
|
|
5019
|
+
if (teamProfileSwitchInFlight) return; // switch already submitted
|
|
5020
|
+
showTeamProfileListStep();
|
|
5021
|
+
});
|
|
5022
|
+
}
|
|
5023
|
+
|
|
5024
|
+
var confirmButton = $("#team-profile-confirm-btn");
|
|
5025
|
+
if (confirmButton) {
|
|
5026
|
+
confirmButton.addEventListener("click", function () {
|
|
5027
|
+
if (!pendingSwitchTarget || teamProfileSwitchInFlight) return;
|
|
5028
|
+
submitTeamProfileSwitch(pendingSwitchTarget.id);
|
|
5029
|
+
});
|
|
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
|
+
}
|
|
5040
|
+
}
|
|
5041
|
+
|
|
3707
5042
|
function bindModelSettings() {
|
|
3708
5043
|
/* Module-level IIFE helper: delegated here to keep startup order simple. */
|
|
3709
5044
|
var opener = document.createElement("button");
|
|
3710
5045
|
opener.className = "btn btn-small";
|
|
3711
5046
|
opener.type = "button";
|
|
3712
5047
|
opener.id = "model-settings-open";
|
|
3713
|
-
|
|
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");
|
|
3714
5052
|
var refreshBtn = document.querySelector("#workspace-tree-refresh");
|
|
3715
5053
|
if (refreshBtn && refreshBtn.parentElement) {
|
|
3716
5054
|
refreshBtn.parentElement.appendChild(opener);
|
|
@@ -3747,10 +5085,10 @@
|
|
|
3747
5085
|
headers: { "Content-Type": "application/json" },
|
|
3748
5086
|
body: JSON.stringify(payload),
|
|
3749
5087
|
}).then(function () {
|
|
3750
|
-
showError("
|
|
5088
|
+
showError(t("ctl.models.saved"));
|
|
3751
5089
|
closeModelSettings();
|
|
3752
5090
|
}).catch(function (err) {
|
|
3753
|
-
showError(err instanceof Error ? err.message : "
|
|
5091
|
+
showError(err instanceof Error ? err.message : t("ctl.models.failed"));
|
|
3754
5092
|
}).finally(function () {
|
|
3755
5093
|
save.disabled = false;
|
|
3756
5094
|
});
|
|
@@ -3824,7 +5162,7 @@ function renderGithubCorner(status) {
|
|
|
3824
5162
|
loginBtn.hidden = true;
|
|
3825
5163
|
} else {
|
|
3826
5164
|
userChip.classList.add("hidden");
|
|
3827
|
-
loginBtn.textContent = t("gh.login");
|
|
5165
|
+
loginBtn.textContent = t("ctl.gh.login");
|
|
3828
5166
|
loginBtn.hidden = false;
|
|
3829
5167
|
}
|
|
3830
5168
|
}
|
|
@@ -3845,11 +5183,11 @@ function openModelSettings() {
|
|
|
3845
5183
|
options.push({ value: provider.id + "/" + modelId, label: provider.id + " / " + modelId });
|
|
3846
5184
|
});
|
|
3847
5185
|
if (!provider.models || provider.models.length === 0) {
|
|
3848
|
-
options.push({ value: provider.id, label: provider.id + " (
|
|
5186
|
+
options.push({ value: provider.id, label: provider.id + " " + t("models.providerDefault") });
|
|
3849
5187
|
}
|
|
3850
5188
|
});
|
|
3851
5189
|
if (catalog.defaultModel && !options.some(function (opt) { return opt.value === catalog.defaultModel; })) {
|
|
3852
|
-
options.unshift({ value: catalog.defaultModel, label: catalog.defaultModel + " (current)
|
|
5190
|
+
options.unshift({ value: catalog.defaultModel, label: catalog.defaultModel + " " + t("models.current") });
|
|
3853
5191
|
}
|
|
3854
5192
|
|
|
3855
5193
|
var defaultSelect = document.querySelector("#model-settings-default");
|
|
@@ -3868,7 +5206,7 @@ function openModelSettings() {
|
|
|
3868
5206
|
'<label class="model-settings-field">' +
|
|
3869
5207
|
' <span class="model-settings-label">' + escapeHtml(role.label) + '</span>' +
|
|
3870
5208
|
' <select data-role-model="' + escapeHtml(role.id) + '">' +
|
|
3871
|
-
' <option value="">(
|
|
5209
|
+
' <option value="">' + escapeHtml(t("ctl.models.useDefault")) + '</option>' +
|
|
3872
5210
|
options.map(function (opt) {
|
|
3873
5211
|
return '<option value="' + escapeHtml(opt.value) + '"' + (current === opt.value ? " selected" : "") + '>' + escapeHtml(opt.label) + "</option>";
|
|
3874
5212
|
}).join("") +
|
|
@@ -3881,7 +5219,7 @@ function openModelSettings() {
|
|
|
3881
5219
|
modal.classList.add("open");
|
|
3882
5220
|
modal.setAttribute("aria-hidden", "false");
|
|
3883
5221
|
}).catch(function (err) {
|
|
3884
|
-
showError(err instanceof Error ? err.message : "
|
|
5222
|
+
showError(err instanceof Error ? err.message : t("models.loadFailed"));
|
|
3885
5223
|
});
|
|
3886
5224
|
}
|
|
3887
5225
|
|
|
@@ -4186,7 +5524,7 @@ function closeModelSettings() {
|
|
|
4186
5524
|
const host = (location.hostname || "").toLowerCase();
|
|
4187
5525
|
const isLocalView = host === "127.0.0.1" || host === "localhost" || host.endsWith(".local");
|
|
4188
5526
|
if (!isLocalView) {
|
|
4189
|
-
wrap.querySelector(".tunnel-state").innerHTML = '<span class="tunnel-note">
|
|
5527
|
+
wrap.querySelector(".tunnel-state").innerHTML = '<span class="tunnel-note">' + escapeHtml(t("tunnel.visitorNote")) + '</span>';
|
|
4190
5528
|
if (toggleBtn) toggleBtn.hidden = true;
|
|
4191
5529
|
return;
|
|
4192
5530
|
}
|
|
@@ -4203,62 +5541,76 @@ function closeModelSettings() {
|
|
|
4203
5541
|
}
|
|
4204
5542
|
}
|
|
4205
5543
|
var progress = st.startOp && st.startOp.running
|
|
4206
|
-
? '<div class="tunnel-note">
|
|
5544
|
+
? '<div class="tunnel-note">' + escapeHtml(t("ctl.tunnel.starting") + ": " + String(st.startOp.phase || "") + "…") + '</div>'
|
|
4207
5545
|
: (st.install && st.install.running
|
|
4208
|
-
? '<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>'
|
|
4209
5547
|
: '');
|
|
4210
5548
|
if (progress) { wrap.querySelector(".tunnel-state").innerHTML = progress; return; }
|
|
4211
5549
|
if (st.active && st.mode === "quick") {
|
|
4212
5550
|
wrap.querySelector(".tunnel-state").innerHTML =
|
|
4213
|
-
'<div class="tunnel-on">
|
|
4214
|
-
+ '<div class="tunnel-note">
|
|
4215
|
-
+ '<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>';
|
|
4216
5554
|
return;
|
|
4217
5555
|
}
|
|
4218
5556
|
if (st.active && st.mode === "self-hosted") {
|
|
4219
5557
|
wrap.querySelector(".tunnel-state").innerHTML =
|
|
4220
|
-
'<div class="tunnel-on">
|
|
4221
|
-
+ '<div class="tunnel-note">
|
|
4222
|
-
+ '<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>';
|
|
4223
5561
|
return;
|
|
4224
5562
|
}
|
|
4225
5563
|
if (st.active) {
|
|
5564
|
+
// Gate token label: shared with desktop via ctl.tunnel.gateToken
|
|
5565
|
+
// ("Gate token" / 门禁令牌), appended with a colon here.
|
|
4226
5566
|
wrap.querySelector(".tunnel-state").innerHTML =
|
|
4227
|
-
'<div class="tunnel-on">
|
|
4228
|
-
+ '<div class="tunnel-token">
|
|
4229
|
-
+ '<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>';
|
|
4230
5570
|
return;
|
|
4231
5571
|
}
|
|
4232
5572
|
if (st.cloudflaredInstalled === false) {
|
|
4233
|
-
wrap.querySelector(".tunnel-state").innerHTML = '<div class="tunnel-note">
|
|
4234
|
-
+ '<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>';
|
|
4235
5575
|
return;
|
|
4236
5576
|
}
|
|
4237
5577
|
// Idle: self-hosted (env token detected -> one click; otherwise token
|
|
4238
5578
|
// input) alongside the managed share button.
|
|
4239
5579
|
var html = '';
|
|
4240
5580
|
if (st.envTokenDetected) {
|
|
4241
|
-
html += '<div class="tunnel-note">
|
|
4242
|
-
+ '<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>';
|
|
4243
5583
|
} else {
|
|
4244
|
-
html += '<div class="tunnel-note">
|
|
4245
|
-
+ '<input type="password" class="tunnel-token-input" data-input="token" placeholder="
|
|
4246
|
-
+ '<button class="btn btn-small btn-primary" data-act="start-self-token">
|
|
4247
|
-
+ '<details class="tunnel-setup-help"><summary>
|
|
4248
|
-
+ '<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>';
|
|
4249
5589
|
}
|
|
4250
|
-
html += '<div class="tunnel-note"
|
|
4251
|
-
+ '<button class="btn btn-small" data-act="start">
|
|
4252
|
-
+ '<span class="tunnel-note">
|
|
4253
|
-
+ '<div class="tunnel-note"
|
|
4254
|
-
+ '<button class="btn btn-small" data-act="start-quick">
|
|
4255
|
-
+ '<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>';
|
|
4256
5596
|
wrap.querySelector(".tunnel-state").innerHTML = html;
|
|
4257
5597
|
};
|
|
4258
5598
|
const refresh = () => apiGet("/tunnel/status").then((st) => render(st || {})).catch(() => {});
|
|
4259
5599
|
wrap.addEventListener("click", (e) => {
|
|
4260
5600
|
const act = e.target.getAttribute && e.target.getAttribute("data-act");
|
|
4261
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
|
+
}
|
|
4262
5614
|
e.target.disabled = true;
|
|
4263
5615
|
var call;
|
|
4264
5616
|
if (act === "start-quick") {
|
|
@@ -4268,7 +5620,7 @@ function closeModelSettings() {
|
|
|
4268
5620
|
if (act === "start-self-token") {
|
|
4269
5621
|
const input = wrap.querySelector('[data-input="token"]');
|
|
4270
5622
|
if (!input || !input.value.trim()) {
|
|
4271
|
-
wrap.querySelector(".tunnel-state").innerHTML = '<div class="tunnel-err">
|
|
5623
|
+
wrap.querySelector(".tunnel-state").innerHTML = '<div class="tunnel-err">' + escapeHtml(t("tunnel.needToken")) + '</div>';
|
|
4272
5624
|
return;
|
|
4273
5625
|
}
|
|
4274
5626
|
opts.body = JSON.stringify({ token: input.value.trim() });
|
|
@@ -4279,7 +5631,7 @@ function closeModelSettings() {
|
|
|
4279
5631
|
: act === "install" ? apiRequest("/tunnel/install-cloudflared", { method: "POST" })
|
|
4280
5632
|
: apiRequest("/tunnel/stop", { method: "POST" });
|
|
4281
5633
|
}
|
|
4282
|
-
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>"; });
|
|
4283
5635
|
});
|
|
4284
5636
|
refresh();
|
|
4285
5637
|
setInterval(refresh, 5000);
|