@songsid/agend 2.4.0-beta.17 → 2.4.0-beta.19
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/dist/agent-cli-instructions.md +13 -7
- package/dist/agent-cli.js +149 -49
- package/dist/agent-cli.js.map +1 -1
- package/dist/agent-export.d.ts +3 -1
- package/dist/agent-export.js +18 -1
- package/dist/agent-export.js.map +1 -1
- package/dist/agent-whats-new.js +9 -0
- package/dist/agent-whats-new.js.map +1 -1
- package/dist/apply-job.d.ts +2 -2
- package/dist/auth-api.js +1 -1
- package/dist/auth-api.js.map +1 -1
- package/dist/backend/claude-code.d.ts +0 -6
- package/dist/backend/claude-code.js +29 -5
- package/dist/backend/claude-code.js.map +1 -1
- package/dist/backend/claude-transcript-errors.d.ts +4 -0
- package/dist/backend/claude-transcript-errors.js +5 -1
- package/dist/backend/claude-transcript-errors.js.map +1 -1
- package/dist/backend/codex-precaution.js +3 -2
- package/dist/backend/codex-precaution.js.map +1 -1
- package/dist/backend/codex.js +1 -1
- package/dist/backend/codex.js.map +1 -1
- package/dist/backend/types.d.ts +6 -0
- package/dist/backend/types.js.map +1 -1
- package/dist/build-provenance.json +1 -1
- package/dist/channel/mcp-server.js +8 -2
- package/dist/channel/mcp-server.js.map +1 -1
- package/dist/channel/mcp-tools.d.ts +27 -1
- package/dist/channel/mcp-tools.js +77 -7
- package/dist/channel/mcp-tools.js.map +1 -1
- package/dist/chat-task-refs.d.ts +61 -0
- package/dist/chat-task-refs.js +112 -0
- package/dist/chat-task-refs.js.map +1 -0
- package/dist/classic-channel-manager.d.ts +1 -1
- package/dist/classic-channel-manager.js +6 -2
- package/dist/classic-channel-manager.js.map +1 -1
- package/dist/claude-credential-launch.d.ts +6 -0
- package/dist/claude-credential-launch.js +16 -3
- package/dist/claude-credential-launch.js.map +1 -1
- package/dist/claude-credential-runner.js +3 -1
- package/dist/claude-credential-runner.js.map +1 -1
- package/dist/claude-setup-token-transport.js +25 -3
- package/dist/claude-setup-token-transport.js.map +1 -1
- package/dist/cli-audited.js +9 -8
- package/dist/cli-audited.js.map +1 -1
- package/dist/composite-tools.d.ts +11 -0
- package/dist/composite-tools.js +29 -0
- package/dist/composite-tools.js.map +1 -0
- package/dist/config-validator.js +22 -1
- package/dist/config-validator.js.map +1 -1
- package/dist/config.js +11 -0
- package/dist/config.js.map +1 -1
- package/dist/contact-auth-policy.d.ts +1 -0
- package/dist/contact-auth-policy.js +2 -1
- package/dist/contact-auth-policy.js.map +1 -1
- package/dist/contact-auth-service.js +2 -0
- package/dist/contact-auth-service.js.map +1 -1
- package/dist/contact-auth-store.js +21 -6
- package/dist/contact-auth-store.js.map +1 -1
- package/dist/contact-auth-types.d.ts +2 -0
- package/dist/contact-auth-types.js.map +1 -1
- package/dist/daemon.d.ts +8 -0
- package/dist/daemon.js +66 -13
- package/dist/daemon.js.map +1 -1
- package/dist/darwin-memory.js +2 -1
- package/dist/darwin-memory.js.map +1 -1
- package/dist/dashboard-permissions.d.ts +1 -8
- package/dist/dashboard-permissions.js +8 -9
- package/dist/dashboard-permissions.js.map +1 -1
- package/dist/delivery-outbox.d.ts +0 -6
- package/dist/delivery-outbox.js +0 -25
- package/dist/delivery-outbox.js.map +1 -1
- package/dist/delivery-outbox.test.js +132 -96
- package/dist/delivery-outbox.test.js.map +1 -1
- package/dist/fleet-context.d.ts +1 -0
- package/dist/fleet-manager.d.ts +60 -8
- package/dist/fleet-manager.js +404 -107
- package/dist/fleet-manager.js.map +1 -1
- package/dist/fleet-windows-runtime.d.ts +2 -2
- package/dist/fleet-windows-runtime.js +9 -2
- package/dist/fleet-windows-runtime.js.map +1 -1
- package/dist/fleet-yaml-stringify.d.ts +3 -0
- package/dist/fleet-yaml-stringify.js +132 -0
- package/dist/fleet-yaml-stringify.js.map +1 -0
- package/dist/general-knowledge/skills/concepts/SKILL.md +53 -4
- package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +4 -0
- package/dist/general-knowledge/skills/fleet-config/SKILL.md +21 -1
- package/dist/general-knowledge/skills/hub/SKILL.md +2 -0
- package/dist/general-knowledge/skills/instance-lifecycle/SKILL.md +5 -1
- package/dist/general-knowledge/skills/model-discovery/SKILL.md +3 -2
- package/dist/general-knowledge/skills/persona-emoji/SKILL.md +3 -0
- package/dist/general-knowledge/skills/task-board/SKILL.md +63 -0
- package/dist/general-knowledge/skills/web-appearance/SKILL.md +25 -2
- package/dist/general-knowledge/skills/web-dashboard/SKILL.md +48 -11
- package/dist/general-knowledge/skills/worker-collaboration/SKILL.md +4 -0
- package/dist/general-knowledge/steering/core-rules.md +15 -78
- package/dist/general-role-block.d.ts +19 -0
- package/dist/general-role-block.js +56 -0
- package/dist/general-role-block.js.map +1 -0
- package/dist/general-role.d.ts +1 -1
- package/dist/general-role.js +1 -0
- package/dist/general-role.js.map +1 -1
- package/dist/host-memory.d.ts +3 -0
- package/dist/host-memory.js.map +1 -1
- package/dist/host-monitoring/darwin/collector.d.ts +18 -0
- package/dist/host-monitoring/darwin/collector.js +65 -0
- package/dist/host-monitoring/darwin/collector.js.map +1 -0
- package/dist/host-monitoring/darwin/defaults.d.ts +2 -0
- package/dist/host-monitoring/darwin/defaults.js +9 -0
- package/dist/host-monitoring/darwin/defaults.js.map +1 -0
- package/dist/host-monitoring/darwin/interpretation.d.ts +20 -0
- package/dist/host-monitoring/darwin/interpretation.js +73 -0
- package/dist/host-monitoring/darwin/interpretation.js.map +1 -0
- package/dist/host-monitoring/linux/collector.d.ts +17 -0
- package/dist/host-monitoring/linux/collector.js +55 -0
- package/dist/host-monitoring/linux/collector.js.map +1 -0
- package/dist/host-monitoring/linux/defaults.d.ts +2 -0
- package/dist/host-monitoring/linux/defaults.js +9 -0
- package/dist/host-monitoring/linux/defaults.js.map +1 -0
- package/dist/host-monitoring/linux/interpretation.d.ts +22 -0
- package/dist/host-monitoring/linux/interpretation.js +76 -0
- package/dist/host-monitoring/linux/interpretation.js.map +1 -0
- package/dist/host-monitoring/transport.d.ts +42 -0
- package/dist/host-monitoring/transport.js +101 -0
- package/dist/host-monitoring/transport.js.map +1 -0
- package/dist/host-monitoring/wsl/collector.d.ts +19 -0
- package/dist/host-monitoring/wsl/collector.js +72 -0
- package/dist/host-monitoring/wsl/collector.js.map +1 -0
- package/dist/host-monitoring/wsl/defaults.d.ts +2 -0
- package/dist/host-monitoring/wsl/defaults.js +9 -0
- package/dist/host-monitoring/wsl/defaults.js.map +1 -0
- package/dist/host-monitoring/wsl/interpretation.d.ts +22 -0
- package/dist/host-monitoring/wsl/interpretation.js +77 -0
- package/dist/host-monitoring/wsl/interpretation.js.map +1 -0
- package/dist/host-monitoring-alert-policy.d.ts +73 -0
- package/dist/host-monitoring-alert-policy.js +152 -0
- package/dist/host-monitoring-alert-policy.js.map +1 -0
- package/dist/host-monitoring-alert-resources.d.ts +11 -0
- package/dist/host-monitoring-alert-resources.js +16 -0
- package/dist/host-monitoring-alert-resources.js.map +1 -0
- package/dist/host-monitoring-alert-settings.d.ts +16 -0
- package/dist/host-monitoring-alert-settings.js +68 -0
- package/dist/host-monitoring-alert-settings.js.map +1 -0
- package/dist/host-monitoring-alert-store.d.ts +49 -0
- package/dist/host-monitoring-alert-store.js +228 -0
- package/dist/host-monitoring-alert-store.js.map +1 -0
- package/dist/host-monitoring-alert-text.d.ts +7 -0
- package/dist/host-monitoring-alert-text.js +10 -0
- package/dist/host-monitoring-alert-text.js.map +1 -0
- package/dist/host-monitoring-alerts.d.ts +79 -0
- package/dist/host-monitoring-alerts.js +276 -0
- package/dist/host-monitoring-alerts.js.map +1 -0
- package/dist/host-monitoring-defaults.d.ts +19 -0
- package/dist/host-monitoring-defaults.js +10 -0
- package/dist/host-monitoring-defaults.js.map +1 -0
- package/dist/host-monitoring-footprint-policy.d.ts +45 -0
- package/dist/host-monitoring-footprint-policy.js +150 -0
- package/dist/host-monitoring-footprint-policy.js.map +1 -0
- package/dist/host-monitoring-footprint.d.ts +42 -0
- package/dist/host-monitoring-footprint.js +169 -0
- package/dist/host-monitoring-footprint.js.map +1 -0
- package/dist/host-monitoring-history-policy.d.ts +2 -0
- package/dist/host-monitoring-history-policy.js +16 -2
- package/dist/host-monitoring-history-policy.js.map +1 -1
- package/dist/host-monitoring-history-store.js +8 -6
- package/dist/host-monitoring-history-store.js.map +1 -1
- package/dist/host-monitoring-history-worker.js +19 -3
- package/dist/host-monitoring-history-worker.js.map +1 -1
- package/dist/host-monitoring-history.d.ts +9 -0
- package/dist/host-monitoring-history.js +45 -9
- package/dist/host-monitoring-history.js.map +1 -1
- package/dist/host-monitoring-platform.d.ts +18 -70
- package/dist/host-monitoring-platform.js +14 -269
- package/dist/host-monitoring-platform.js.map +1 -1
- package/dist/host-monitoring-process-identity.d.ts +8 -0
- package/dist/host-monitoring-process-identity.js +81 -0
- package/dist/host-monitoring-process-identity.js.map +1 -0
- package/dist/host-monitoring-runtime.d.ts +8 -0
- package/dist/host-monitoring-runtime.js +18 -3
- package/dist/host-monitoring-runtime.js.map +1 -1
- package/dist/host-monitoring.d.ts +15 -0
- package/dist/host-monitoring.js.map +1 -1
- package/dist/hub/agent-catalog-model.d.ts +21 -0
- package/dist/hub/agent-catalog-model.js +9 -1
- package/dist/hub/agent-catalog-model.js.map +1 -1
- package/dist/hub/agent-catalog.d.ts +4 -1
- package/dist/hub/agent-catalog.js +11 -0
- package/dist/hub/agent-catalog.js.map +1 -1
- package/dist/hub/catalog.js +12 -0
- package/dist/hub/catalog.js.map +1 -1
- package/dist/hub/client.js +4 -1
- package/dist/hub/client.js.map +1 -1
- package/dist/hub/compose/member.d.ts +5 -0
- package/dist/hub/compose/member.js +25 -5
- package/dist/hub/compose/member.js.map +1 -1
- package/dist/hub/compose/server.d.ts +2 -0
- package/dist/hub/compose/server.js +4 -2
- package/dist/hub/compose/server.js.map +1 -1
- package/dist/hub/http/compose.d.ts +5 -0
- package/dist/hub/http/compose.js +25 -2
- package/dist/hub/http/compose.js.map +1 -1
- package/dist/hub/http/deps.d.ts +2 -0
- package/dist/hub/http/schema.js +4 -0
- package/dist/hub/http/schema.js.map +1 -1
- package/dist/hub/lapse-carry.d.ts +45 -0
- package/dist/hub/lapse-carry.js +62 -0
- package/dist/hub/lapse-carry.js.map +1 -0
- package/dist/hub/member/agent-catalog.d.ts +4 -1
- package/dist/hub/member/agent-catalog.js +15 -4
- package/dist/hub/member/agent-catalog.js.map +1 -1
- package/dist/hub/member/agent-intro.d.ts +4 -3
- package/dist/hub/member/agent-intro.js +7 -0
- package/dist/hub/member/agent-intro.js.map +1 -1
- package/dist/hub/member/exposure-api.d.ts +2 -0
- package/dist/hub/member/exposure-api.js +8 -1
- package/dist/hub/member/exposure-api.js.map +1 -1
- package/dist/hub/member/room-post.d.ts +34 -6
- package/dist/hub/member/room-post.js +30 -0
- package/dist/hub/member/room-post.js.map +1 -1
- package/dist/hub/member/sharing.d.ts +2 -0
- package/dist/hub/member/sharing.js +9 -2
- package/dist/hub/member/sharing.js.map +1 -1
- package/dist/hub/protocol.d.ts +2 -0
- package/dist/hub/room-brief-model.js +2 -1
- package/dist/hub/room-brief-model.js.map +1 -1
- package/dist/hub/rooms/agents.d.ts +2 -0
- package/dist/hub/rooms/agents.js +16 -2
- package/dist/hub/rooms/agents.js.map +1 -1
- package/dist/hub/rooms/office.d.ts +82 -0
- package/dist/hub/rooms/office.js +46 -0
- package/dist/hub/rooms/office.js.map +1 -0
- package/dist/hub/rooms/service.d.ts +66 -1
- package/dist/hub/rooms/service.js +67 -11
- package/dist/hub/rooms/service.js.map +1 -1
- package/dist/hub/rooms/types.d.ts +4 -0
- package/dist/hub/runtime.d.ts +1 -1
- package/dist/hub/server.js +9 -2
- package/dist/hub/server.js.map +1 -1
- package/dist/hub/sharing-requests.d.ts +5 -2
- package/dist/hub/sharing-requests.js +19 -4
- package/dist/hub/sharing-requests.js.map +1 -1
- package/dist/instance-config-impact.js +1 -1
- package/dist/instance-config-impact.js.map +1 -1
- package/dist/instance-lifecycle.js +8 -9
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/instruction-file-sizes.d.ts +46 -0
- package/dist/instruction-file-sizes.js +115 -0
- package/dist/instruction-file-sizes.js.map +1 -0
- package/dist/instructions.d.ts +35 -1
- package/dist/instructions.js +59 -33
- package/dist/instructions.js.map +1 -1
- package/dist/locale.js +16 -4
- package/dist/locale.js.map +1 -1
- package/dist/log-steps.d.ts +5 -0
- package/dist/log-steps.js +6 -2
- package/dist/log-steps.js.map +1 -1
- package/dist/memory-guidance.d.ts +5 -0
- package/dist/memory-guidance.js +14 -0
- package/dist/memory-guidance.js.map +1 -0
- package/dist/model-defaults.d.ts +5 -0
- package/dist/model-defaults.js +6 -0
- package/dist/model-defaults.js.map +1 -0
- package/dist/native-mcp.d.ts +2 -0
- package/dist/native-mcp.js +16 -6
- package/dist/native-mcp.js.map +1 -1
- package/dist/needs-you-hub.d.ts +3 -0
- package/dist/needs-you-hub.js +7 -1
- package/dist/needs-you-hub.js.map +1 -1
- package/dist/needs-you.d.ts +15 -2
- package/dist/needs-you.js +6 -0
- package/dist/needs-you.js.map +1 -1
- package/dist/outbound-handlers.d.ts +3 -3
- package/dist/outbound-schemas.d.ts +3 -0
- package/dist/outbound-schemas.js +27 -26
- package/dist/outbound-schemas.js.map +1 -1
- package/dist/public-web-gateway.js +7 -1
- package/dist/public-web-gateway.js.map +1 -1
- package/dist/quickstart.d.ts +1 -1
- package/dist/quickstart.js +2 -3
- package/dist/quickstart.js.map +1 -1
- package/dist/remote-card-prompt.d.ts +1 -0
- package/dist/remote-card-prompt.js +1 -1
- package/dist/remote-card-prompt.js.map +1 -1
- package/dist/runtime-build-info.js +1 -1
- package/dist/runtime-build-info.js.map +1 -1
- package/dist/runtime-cli-install.js +9 -9
- package/dist/runtime-cli-install.js.map +1 -1
- package/dist/runtime-pane-mcp.js +7 -3
- package/dist/runtime-pane-mcp.js.map +1 -1
- package/dist/runtime-pane-native.js +2 -1
- package/dist/runtime-pane-native.js.map +1 -1
- package/dist/scheduler/db.js +2 -0
- package/dist/scheduler/db.js.map +1 -1
- package/dist/scheduler/task-board-mentions.d.ts +32 -0
- package/dist/scheduler/task-board-mentions.js +97 -0
- package/dist/scheduler/task-board-mentions.js.map +1 -0
- package/dist/scheduler/task-board-text.js +3 -0
- package/dist/scheduler/task-board-text.js.map +1 -1
- package/dist/scheduler/task-board.d.ts +199 -3
- package/dist/scheduler/task-board.js +492 -7
- package/dist/scheduler/task-board.js.map +1 -1
- package/dist/settings-api.d.ts +5 -1
- package/dist/settings-api.js +77 -2
- package/dist/settings-api.js.map +1 -1
- package/dist/settings-baseline.js +5 -4
- package/dist/settings-baseline.js.map +1 -1
- package/dist/settings-change.js +4 -2
- package/dist/settings-change.js.map +1 -1
- package/dist/settings-effect.d.ts +2 -0
- package/dist/settings-effect.js +20 -1
- package/dist/settings-effect.js.map +1 -1
- package/dist/settings-instance-patch.js +3 -1
- package/dist/settings-instance-patch.js.map +1 -1
- package/dist/setup-host.d.ts +2 -3
- package/dist/setup-host.js +3 -5
- package/dist/setup-host.js.map +1 -1
- package/dist/setup-wizard.js +0 -2
- package/dist/setup-wizard.js.map +1 -1
- package/dist/shared-default-adoption.d.ts +24 -0
- package/dist/shared-default-adoption.js +73 -0
- package/dist/shared-default-adoption.js.map +1 -0
- package/dist/subagent-records.d.ts +2 -0
- package/dist/subagent-records.js +11 -1
- package/dist/subagent-records.js.map +1 -1
- package/dist/subagent-service.d.ts +3 -0
- package/dist/subagent-service.js +24 -4
- package/dist/subagent-service.js.map +1 -1
- package/dist/task-board-tool.d.ts +31 -0
- package/dist/task-board-tool.js +31 -0
- package/dist/task-board-tool.js.map +1 -1
- package/dist/task-board-waker.d.ts +23 -30
- package/dist/task-board-waker.js +136 -97
- package/dist/task-board-waker.js.map +1 -1
- package/dist/topic-commands.js +4 -0
- package/dist/topic-commands.js.map +1 -1
- package/dist/types.d.ts +23 -0
- package/dist/ui/agent-details-settings.js +2 -2
- package/dist/ui/agent-export-dialog.js +4 -3
- package/dist/ui/agent-export-strings.js +4 -4
- package/dist/ui/agent-page-strings.js +18 -0
- package/dist/ui/chat-activity-groups.js +1 -1
- package/dist/ui/chat-activity.js +17 -0
- package/dist/ui/chat-store.js +34 -8
- package/dist/ui/chat-task-ref-strings.js +24 -0
- package/dist/ui/chat-task-refs.js +129 -0
- package/dist/ui/claude-setup-token.js +3 -3
- package/dist/ui/contact-auth-strings.js +33 -3
- package/dist/ui/contact-authorizations.js +17 -24
- package/dist/ui/contact-grant-editor.js +50 -0
- package/dist/ui/contact-permissions.js +21 -8
- package/dist/ui/fleet-office-card.js +18 -14
- package/dist/ui/fleet-office.js +29 -17
- package/dist/ui/fleet-task-activity.js +362 -0
- package/dist/ui/fleet-task-card.js +317 -314
- package/dist/ui/fleet-task-common.js +99 -9
- package/dist/ui/fleet-task-create.js +67 -0
- package/dist/ui/fleet-task-edit.js +204 -0
- package/dist/ui/fleet-task-follow.js +123 -0
- package/dist/ui/fleet-task-menu.js +1 -1
- package/dist/ui/fleet-task-owner.js +252 -0
- package/dist/ui/fleet-task-run.js +257 -0
- package/dist/ui/fleet-task-view.js +178 -39
- package/dist/ui/fleet-task-work.js +2 -2
- package/dist/ui/fleet-tasks.js +258 -130
- package/dist/ui/host-alerts.js +23 -0
- package/dist/ui/host-footprint.js +17 -0
- package/dist/ui/host-health.js +24 -16
- package/dist/ui/host-monitoring-darwin.js +6 -0
- package/dist/ui/host-monitoring-help.js +7 -0
- package/dist/ui/host-monitoring-linux.js +6 -0
- package/dist/ui/host-monitoring-wsl.js +6 -0
- package/dist/ui/host-time.js +5 -0
- package/dist/ui/hub-agent-copy.js +2 -0
- package/dist/ui/hub-client.js +4 -0
- package/dist/ui/hub-my-agents-strings.js +2 -0
- package/dist/ui/hub-my-agents.js +17 -1
- package/dist/ui/hub-room-composer.js +108 -5
- package/dist/ui/hub-room-members-strings.js +9 -2
- package/dist/ui/hub-room-members.js +72 -15
- package/dist/ui/hub-room-office.js +191 -0
- package/dist/ui/hub-room-purpose.js +18 -2
- package/dist/ui/hub-room-settings.js +8 -1
- package/dist/ui/hub-room-strings.js +15 -0
- package/dist/ui/hub-room-thread.js +51 -15
- package/dist/ui/hub-strings.js +1 -1
- package/dist/ui/log-row.js +7 -5
- package/dist/ui/native-instance-settings.js +4 -2
- package/dist/ui/panel-chat.js +98 -17
- package/dist/ui/panel-details.js +17 -0
- package/dist/ui/panel-fleet.js +1 -1
- package/dist/ui/panel-hub.js +4 -1
- package/dist/ui/panel-needs.js +38 -18
- package/dist/ui/panel-settings.js +58 -13
- package/dist/ui/settings-apply.js +8 -3
- package/dist/ui/settings-default-model-scope.js +40 -0
- package/dist/ui/settings-default-model-strings.js +43 -0
- package/dist/ui/settings-dialogs.js +9 -5
- package/dist/ui/settings-host-alerts.js +23 -0
- package/dist/ui/settings-host-monitoring.js +10 -8
- package/dist/ui/settings-hub.js +1 -1
- package/dist/ui/settings-layout.js +7 -2
- package/dist/ui/settings-model.js +9 -5
- package/dist/ui/settings-quota-notice.js +3 -3
- package/dist/ui/settings-registry.js +3 -0
- package/dist/ui/settings-shared-strings.js +22 -0
- package/dist/ui/settings-shared.js +59 -12
- package/dist/ui/settings-strings.js +2 -4
- package/dist/ui/shared/app-i18n.js +2 -2
- package/dist/ui/shared/app.css +169 -50
- package/dist/ui/shared/chat-composer.js +7 -6
- package/dist/ui/shared/chat-render.js +63 -10
- package/dist/ui/shared/chat-strings.js +2 -2
- package/dist/ui/shared/chat-thread.js +10 -3
- package/dist/ui/shared/composer-focus.js +21 -0
- package/dist/ui/shared/hub-chat.css +30 -2
- package/dist/ui/shared/hub-rooms-u2.css +17 -0
- package/dist/ui/shared/task-board.css +406 -8
- package/dist/ui/trigger-complete.js +71 -0
- package/dist/web-api.d.ts +11 -1
- package/dist/web-api.js +324 -18
- package/dist/web-api.js.map +1 -1
- package/dist/web-chat-history.d.ts +40 -1
- package/dist/web-chat-history.js +131 -9
- package/dist/web-chat-history.js.map +1 -1
- package/dist/web-guest-access.js +4 -4
- package/dist/web-guest-access.js.map +1 -1
- package/dist/web-upload.d.ts +1 -1
- package/dist/web-upload.js.map +1 -1
- package/dist/windows-native-mcp.js +5 -2
- package/dist/windows-native-mcp.js.map +1 -1
- package/dist/workflow-templates/default.md +4 -6
- package/package.json +1 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {hostTime} from './host-time.js';
|
|
2
|
+
import {html,useState,useEffect,useRef} from '/assets/app-html.js';
|
|
3
|
+
import {register,t,lang} from '/assets/app-i18n.js';
|
|
4
|
+
import {fleetPath} from '/assets/app-route.js';
|
|
5
|
+
register('hostAlerts',{
|
|
6
|
+
en:{started:'Started ',title:'Host alerts',warning:'Warning',urgent:'Urgent',recovered:'Recovered',cpu:'CPU',memory:'Memory pressure',filesystem:'Filesystem',backing:'Windows backing drive',value:'Current: {0} · Threshold: {1}',pressureValue:'Current: {0} ({1})',pressureWarning:'warning threshold reached',pressureUrgent:'urgent threshold reached',pressureRecovery:'waiting for recovery confirmation',ack:'Acknowledge',acknowledged:'Acknowledged',snooze:'Snooze for 1 hour',snoozed:'Snoozed until {0}',busy:'Saving…',open:'View host health',failed:'Host alerts are unavailable. Check monitoring settings and local storage.',pending:'{0} notifications pending',error:'Could not save. Refresh the page and try again.',normal:'Normal',elevated:'Elevated',critical:'Critical',none:'No active host alerts',age:'Last incident update:',kept:'Acknowledging keeps the problem visible. An urgent escalation bypasses a warning snooze.'},
|
|
7
|
+
'zh-TW':{started:'發生於 ',title:'主機警示',warning:'注意',urgent:'緊急',recovered:'已恢復',cpu:'CPU',memory:'記憶體壓力',filesystem:'檔案系統',backing:'存放 WSL 的 Windows 磁碟',value:'目前:{0} · 門檻:{1}',pressureValue:'目前:{0}({1})',pressureWarning:'達到注意門檻',pressureUrgent:'達到緊急門檻',pressureRecovery:'等待恢復確認',ack:'我已看過',acknowledged:'已看過',snooze:'暫停提醒 1 小時',snoozed:'暫停提醒至 {0}',busy:'儲存中…',open:'查看主機狀態',failed:'主機警示無法使用,請檢查監測設定與本機儲存空間。',pending:'{0} 則通知待送出',error:'無法儲存,請重新整理頁面後再試。',normal:'正常',elevated:'偏高',critical:'嚴重',none:'目前沒有主機警示',age:'問題最後更新:',kept:'標記已看過後,問題仍會顯示。升為緊急時會略過注意等級的暫停提醒。'}
|
|
8
|
+
});
|
|
9
|
+
export const hostAlertText=(key,...args)=>t('hostAlerts.'+key,...args);
|
|
10
|
+
export function hostAlertValue(record,value=record.value){return record.kind==='backing-drive'?(value/1024**3).toFixed(1)+' GiB':record.kind==='memory'?hostAlertText(['normal','elevated','critical'][value]||'failed'):value.toFixed(1)+'%';}
|
|
11
|
+
export function hostAlertName(record){const label=hostAlertText(({cpu:'cpu',memory:'memory',filesystem:'filesystem','backing-drive':'backing'})[record?.kind]||'title');return label+(record?.kind==='filesystem'&&/^disk:[a-f0-9]{16}$/.test(record.key||'')?' · '+record.key.slice(-6):'');}
|
|
12
|
+
export function hostAlertDrive(drive){return /^[A-Z]$/.test(drive||'')?(lang()==='zh-TW'?'('+drive+':)':' ('+drive+':)'):'';}
|
|
13
|
+
export function hostAlertDescription(record){return record.kind==='memory'?hostAlertText('pressureValue',hostAlertValue(record),hostAlertText(record.value>=record.threshold?(record.level==='urgent'?'pressureUrgent':'pressureWarning'):'pressureRecovery')):hostAlertText('value',hostAlertValue(record),hostAlertValue(record,record.threshold));}
|
|
14
|
+
export function HostAlertActions({record,onChange}){
|
|
15
|
+
const [busy,setBusy]=useState(false),[error,setError]=useState(false),alive=useRef(true);
|
|
16
|
+
useEffect(()=>{alive.current=true;return()=>{alive.current=false;};},[]);
|
|
17
|
+
const act=async(snoozeMs)=>{if(busy)return;setBusy(true);setError(false);try{const response=await fetch('/ui/host-alert-action',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({key:record.key,revision:record.revision,...(snoozeMs?{snoozeMs}:{})})});if(!response.ok)throw Error();if(alive.current)onChange?.();}catch{if(alive.current)setError(true);}finally{if(alive.current)setBusy(false);}};
|
|
18
|
+
return html`<div><div class="n-actions"><button type="button" class="btn btn-sm" disabled=${busy||record.acknowledgedAt!==undefined} onClick=${()=>act()}>${hostAlertText(busy?'busy':record.acknowledgedAt!==undefined?'acknowledged':'ack')}</button><button type="button" class="btn btn-sm" disabled=${busy} onClick=${()=>act(3600000)}>${hostAlertText('snooze')}</button><a class="btn btn-sm" href=${fleetPath('host-health')}>${hostAlertText('open')}</a></div>${error?html`<p class="notice warn" role="alert">${hostAlertText('error')}</p>`:null}</div>`;
|
|
19
|
+
}
|
|
20
|
+
export function HostAlerts({alerts,onChange}){
|
|
21
|
+
if(!alerts||alerts.state==='off')return null;
|
|
22
|
+
return html`<section class="card host-alerts"><h3>${hostAlertText('title')}</h3>${alerts.state==='failed'?html`<p class="notice warn" role="alert">${hostAlertText('failed')}</p>`:alerts.active.length?alerts.active.map(record=>html`<article key=${record.key} class="host-volume"><div class="host-row"><h4>${hostAlertName(record)}</h4><span class="tag">${hostAlertText(record.level)}</span></div><p>${hostAlertDescription(record)}</p><p class="note">${hostAlertText('age')}${lang()==='zh-TW'?'':' '}<span class="host-sample-time">${hostTime(record.updatedAt)}</span></p>${record.snoozedUntil>Date.now()?html`<p class="note">${hostAlertText('snoozed',hostTime(record.snoozedUntil))}</p>`:null}<${HostAlertActions} record=${record} onChange=${onChange}/></article>`):html`<p class="note">${hostAlertText('none')}</p>`}${alerts.active.length?html`<p class="note">${hostAlertText('kept')}</p>`:null}${alerts.pending?html`<p class="note">${hostAlertText('pending',alerts.pending)}</p>`:null}</section>`;
|
|
23
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {html} from '/assets/app-html.js';
|
|
2
|
+
import {register,t} from '/assets/app-i18n.js';
|
|
3
|
+
import {displayBytes} from './host-health-model.js';
|
|
4
|
+
import {hostTime} from './host-time.js';
|
|
5
|
+
register('hostFootprint',{
|
|
6
|
+
en:{title:'Agent footprint',off:'Agent footprint is off. Enable it separately in Monitoring settings.',waiting:'Waiting for a bounded process sample.',unavailable:'Process attribution is unavailable. Missing readings are not zero.',coverage:'{0} of {1} agent roots covered',agent:'Agent',cpu:'CPU',memory:'RSS estimate',managed:'Known managed files',shared:'Shared service overhead',notes:'CPU is a percentage of this computer’s total capacity. RSS includes descendants and may count shared pages twice. Processes that start and exit between samples are not included. Managed sizes cover known output files only; workspaces are not measured.',retention:'Agent samples every 60 s; raw history up to 6 hours and rollups up to 7 days, within the shared 64 MiB cap.',previous:'Previous agents',next:'More agents',unknown:'Not measured',stale:'Stale sample',sample:'Sample: {0}',historyFor:'History: {0}',select:'Select agent history',agentCpu:'Agent CPU',agentMemory:'Agent RSS'},
|
|
7
|
+
'zh-TW':{title:'Agent 資源用量',off:'Agent 資源用量已關閉,請在監測設定中另外開啟。',waiting:'正在等待下一次行程取樣。',unavailable:'無法確認行程歸屬。缺少讀數不代表零。',coverage:'{1} 個 Agent 根行程中已確認 {0} 個',agent:'Agent',cpu:'CPU',memory:'記憶體(估)',managed:'管理檔案',shared:'共用服務',notes:'CPU 代表這台電腦總容量的百分比。RSS 包含子行程,共用記憶體頁可能重複計算。兩次取樣之間啟動又結束的行程不會列入。檔案大小只計算已知的輸出檔案,不量測工作區。',retention:'Agent 每 60 秒取樣;原始資料最多 6 小時,彙整最多 7 天,共用 64 MiB 上限。',previous:'上一頁 Agent',next:'更多 Agent',unknown:'未量測',stale:'取樣已過期',sample:'取樣:{0}',historyFor:'歷史:{0}',select:'選擇 Agent 歷史',agentCpu:'Agent CPU',agentMemory:'Agent RSS'}
|
|
8
|
+
});
|
|
9
|
+
export const footprintText=(key,...args)=>t('hostFootprint.'+key,...args);
|
|
10
|
+
const copy=footprintText;
|
|
11
|
+
export function HostFootprintView({snapshot,offset=0,onOffset,onSelect,selected,charts}){
|
|
12
|
+
const reading=snapshot?.reading,number=(value,unit)=>typeof value==='number'&&Number.isFinite(value)?unit==='percent'?value.toFixed(2)+'%':displayBytes(value):copy('unknown');
|
|
13
|
+
return html`<section class="card host-footprint"><h3>${copy('title')}</h3>${!snapshot?.enabled?html`<p>${copy('off')}</p>`:!reading?html`<p role="status">${copy(snapshot.status==='starting'?'waiting':'unavailable')}</p>`:html`
|
|
14
|
+
${snapshot.status==='stale'?html`<p class="notice warn">${copy('stale')}</p>`:null}<p class="note host-footprint-sample"><span>${copy('coverage',reading.covered,reading.total)}</span><span class="host-sample-time">${copy('sample',hostTime(reading.sampledAt))}</span></p>
|
|
15
|
+
<div class="table-wrap"><table><thead><tr><th>${copy('agent')}</th><th>${copy('cpu')}</th><th class="host-footprint-memory">${copy('memory')}</th><th class="host-footprint-managed">${copy('managed')}</th></tr></thead><tbody>${reading.rows.slice(0,50).map(row=>html`<tr key=${row.id}><th><button class="btn btn-sm" type="button" aria-label=${copy('select')+': '+(row.label||copy('agent'))} aria-pressed=${selected===row.id} onClick=${()=>onSelect?.(row.id)}>${row.label||copy('agent')}</button></th><td>${number(row.cpuPercent,'percent')}</td><td>${number(row.rssBytes,'bytes')}</td><td>${number(row.managedBytes,'bytes')}</td></tr>`)}<tr><th>${copy('shared')}</th><td>${number(reading.shared.cpuPercent,'percent')}</td><td>${number(reading.shared.rssBytes,'bytes')}</td><td>${copy('unknown')}</td></tr></tbody></table></div>
|
|
16
|
+
${offset>0||reading.hasMore?html`<div class="n-actions"><button class="btn btn-sm" type="button" disabled=${offset===0} onClick=${()=>onOffset?.(Math.max(0,offset-50))}>${copy('previous')}</button><button class="btn btn-sm" type="button" disabled=${!reading.hasMore} onClick=${()=>onOffset?.(offset+50)}>${copy('next')}</button></div>`:null}${charts?html`<section class="host-agent-history"><h4>${copy('historyFor',reading.rows.find(r=>r.id===selected)?.label||copy('agent'))}</h4>${charts}</section>`:null}<p class="note">${copy('notes')}</p><p class="note">${copy('retention')}</p>`}</section>`;
|
|
17
|
+
}
|
package/dist/ui/host-health.js
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
|
+
import {monitoringHelp} from './host-monitoring-help.js';
|
|
2
|
+
import {HostFootprintView,footprintText} from './host-footprint.js';
|
|
3
|
+
import {hostTime} from './host-time.js';
|
|
4
|
+
import {HostAlerts} from './host-alerts.js';
|
|
1
5
|
import {html,useEffect,useRef,useState} from '/assets/app-html.js';
|
|
2
6
|
import {register,t,lang} from '/assets/app-i18n.js';
|
|
3
7
|
import {PageHead} from '/assets/page-head.js';
|
|
4
8
|
import {Skeleton,ErrorState} from '/assets/ui-states.js';
|
|
5
9
|
import {Icon} from '/assets/ui-icons.js';
|
|
6
10
|
import {sectionPath} from '/assets/app-route.js';
|
|
7
|
-
import {HOST_RANGES,numberOrNull,metricState,displayBytes,storageRows,historySeries,chartData,sampleCoverage} from './host-health-model.js';
|
|
11
|
+
import {HOST_RANGES,numberOrNull,metricState,displayBytes as formatBytes,storageRows,historySeries,chartData,sampleCoverage} from './host-health-model.js';
|
|
8
12
|
|
|
9
13
|
register('hostHealth',{
|
|
10
|
-
en:{title:'Host health',computer:'This computer',lead:'CPU, memory and storage from the latest recorded samples.',settings:'Monitoring settings',refresh:'Refresh',refreshing:'Refreshing…',unsupported:'Host monitoring is not available on this computer.',off:'Host monitoring is off',offHint:'Turn it on in Settings to collect samples and keep bounded local history.',admin:'Administrator sign-in required',adminHint:'Sign in as a Fleet administrator to see host metrics.',starting:'Waiting for the first samples',stopping:'Stopping monitoring',failedHint:'Monitoring could not complete. Check its settings and local storage permissions; history cleanup may still need attention.',failed:'Monitoring needs attention',unavailable:'Not available',stale:'Stale',lastLabel:'Last successful sample:',last:'Last successful sample: {0}',none:'No successful sample yet',wsl:'WSL 2',linux:'Linux',darwin:'macOS',wslNote:'CPU and memory describe WSL, not the physical Windows computer. The Windows backing drive is shown separately.',macNote:'APFS volumes may share free space. Do not add their free space together. Available memory is an estimate; pressure is shown separately.',linuxNote:'Local Linux filesystems and available memory. Unavailable fields are not treated as zero.',runtimeNote:'Paired Windows Runtimes are separate computers and are not included in these totals.',storage:'Storage',root:'Linux filesystem',state:'Fleet state',backing:'Windows backing drive',volume:'Local volume',drive:' ({0}:)',shared:'Shared APFS capacity',sharedHint:'Do not add free space across volumes.',free:'{0} available',used:'{0}% used',unknownDrive:'Windows drive not identified',chooseDrive:'Choose drive in Settings',unknownHint:'Linux free space alone does not show whether the Windows drive holding WSL has room.',cpu:'CPU',wslCpu:'WSL CPU',wslMemory:'WSL memory',cpuUsed:'{0}% used',cores:'{0} logical CPUs',loadLabel:'Load average:',load:'Load average: {0}',memory:'Memory',available:'{0} available of {1}',pressureLabel:'Memory pressure:',pressure:'Memory pressure: {0}',normal:'Normal',elevated:'Elevated',critical:'Critical',unknown:'Unknown',swap:'Swap free: {0}',history:'History',range:'History range',coverageSummary:'{0} of {1} readings have fresh data',collecting:'Collecting history…',noHistory:'No recorded samples in this range',historyUnavailable:'Recorded history is temporarily unavailable. Refresh to try again.',historyLoading:'Loading recorded history…',historyWaiting:'History has not started recording yet.',historyPaused:'History recording is paused.',historyFailed:'History could not be recorded. Current samples remain available.',lowSpace:'Low storage: keeping current samples in memory only.',recovering:'Waiting for both storage volumes to stay above 4 GiB for ten minutes.',diskUnavailable:'Storage data is unavailable; history is paused.',backingUnknown:'Identify the Windows backing drive before history can be recorded.',clockChanged:'The computer clock moved backwards; recording is waiting for it to catch up.',historyBusy:'History storage is busy; no additional write is queued.',minimum:'Minimum: {0}',maximum:'Peak: {0}',coverage:'{0} of {1} chart buckets contain recorded samples',gaps:'Gaps mean no sample was recorded; they are not zero.',retention:'History is capped at 64 MiB, with up to 24 hours of raw samples and 30 days of rollups. Older samples may be pruned earlier.',
|
|
11
|
-
'zh-TW':{title:'主機狀態',computer:'這台電腦',lead:'依最新記錄的取樣查看 CPU、記憶體與儲存空間。',settings:'監測設定',refresh:'重新整理',refreshing:'重新整理中…',unsupported:'這台電腦尚未提供主機監測。',off:'主機監測已關閉',offHint:'請在設定中開啟,開始取樣並保留容量受限的本機歷史。',admin:'需要管理員登入',adminHint:'請以 Fleet 管理員身分登入,才能查看主機資料。',starting:'等待第一筆取樣',stopping:'正在停止監測',failedHint:'主機監測未能完成操作,請檢查設定與本機儲存空間權限;歷史資料可能仍需清理。',failed:'主機監測需要處理',unavailable:'無法取得',stale:'資料已過期',lastLabel:'最後成功取樣:',last:'最後成功取樣:{0}',none:'尚無成功的取樣',wsl:'WSL 2',linux:'Linux',darwin:'macOS',wslNote:'CPU 與記憶體代表 WSL,不是實體 Windows 電腦。存放 WSL 的 Windows 磁碟會另外列出。',macNote:'APFS 磁碟區可能共用空間,請勿把可用空間相加。可用記憶體是估算值,記憶體壓力會另外顯示。',linuxNote:'本機 Linux 檔案系統與可用記憶體。無法取得的欄位不會當作零。',runtimeNote:'配對的 Windows 電腦是另一台,不算在這裡的數字裡。',storage:'儲存空間',root:'Linux 檔案系統',state:'Fleet 狀態資料',backing:'存放 WSL 的 Windows 磁碟',volume:'本機磁碟區',drive:'({0}:)',shared:'共用 APFS 容量',sharedHint:'請勿把各磁碟區的可用空間相加。',free:'可用 {0}',used:'已使用 {0}%',unknownDrive:'尚未確認 Windows 磁碟',chooseDrive:'到設定選擇磁碟',unknownHint:'只有 Linux 的可用空間,無法判斷存放 WSL 的 Windows 磁碟是否還有空間。',cpu:'CPU',wslCpu:'WSL CPU',wslMemory:'WSL 記憶體',cpuUsed:'使用率 {0}%',cores:'{0} 個邏輯 CPU',loadLabel:'平均負載:',load:'平均負載:{0}',memory:'記憶體',available:'可用 {0},共 {1}',pressureLabel:'記憶體壓力:',pressure:'記憶體壓力:{0}',normal:'正常',elevated:'偏高',critical:'嚴重',unknown:'未知',swap:'Swap 可用:{0}',history:'歷史紀錄',range:'歷史期間',coverageSummary:'{1} 項讀數中,{0} 項有最新資料',collecting:'正在累積歷史紀錄…',noHistory:'這段期間尚無記錄的取樣',historyUnavailable:'暫時無法取得歷史紀錄,請重新整理再試。',historyLoading:'正在載入歷史紀錄…',historyWaiting:'歷史紀錄尚未開始取樣。',historyPaused:'歷史紀錄已暫停。',historyFailed:'無法記錄歷史,目前的取樣仍可查看。',lowSpace:'儲存空間不足:目前取樣只保留在記憶體中。',recovering:'等待兩個儲存空間持續十分鐘都超過 4 GiB。',diskUnavailable:'無法取得儲存空間資料,歷史紀錄已暫停。',backingUnknown:'請先確認存放 WSL 的 Windows 磁碟,再記錄歷史。',clockChanged:'電腦時間往回調整,正在等待時間追上後再記錄。',historyBusy:'歷史儲存空間忙碌中,不會排入額外的寫入。',minimum:'最低:{0}',maximum:'最高:{0}',coverage:'{1} 個圖表區間中,{0} 個有記錄取樣',gaps:'缺口代表沒有記錄取樣,不是零。',retention:'歷史資料最多 64 MiB;原始取樣最多保留 24 小時,彙整最多 30 天。較舊的取樣可能提早清除。',
|
|
14
|
+
en:{title:'Host health',computer:'This computer',lead:'CPU, memory and storage from the latest recorded samples.',settings:'Monitoring settings',refresh:'Refresh',refreshing:'Refreshing…',unsupported:'Host monitoring is not available on this computer.',off:'Host monitoring is off',offHint:'Turn it on in Settings to collect samples and keep bounded local history.',admin:'Administrator sign-in required',adminHint:'Sign in as a Fleet administrator to see host metrics.',starting:'Waiting for the first samples',stopping:'Stopping monitoring',failedHint:'Monitoring could not complete. Check its settings and local storage permissions; history cleanup may still need attention.',failed:'Monitoring needs attention',unavailable:'Not available',stale:'Stale',lastLabel:'Last successful sample:',last:'Last successful sample: {0}',none:'No successful sample yet',wsl:'WSL 2',linux:'Linux',darwin:'macOS',wslNote:'CPU and memory describe WSL, not the physical Windows computer. The Windows backing drive is shown separately.',macNote:'APFS volumes may share free space. Do not add their free space together. Available memory is an estimate; pressure is shown separately.',linuxNote:'Local Linux filesystems and available memory. Unavailable fields are not treated as zero.',runtimeNote:'Paired Windows Runtimes are separate computers and are not included in these totals.',storage:'Storage',root:'Linux filesystem',state:'Fleet state',backing:'Windows backing drive',volume:'Local volume',drive:' ({0}:)',shared:'Shared APFS capacity',sharedHint:'Do not add free space across volumes.',free:'{0} available',used:'{0}% used',unknownDrive:'Windows drive not identified',chooseDrive:'Choose drive in Settings',unknownHint:'Linux free space alone does not show whether the Windows drive holding WSL has room.',cpu:'CPU',wslCpu:'WSL CPU',wslMemory:'WSL memory',cpuUsed:'{0}% used',cores:'{0} logical CPUs',loadLabel:'Load average:',load:'Load average: {0}',memory:'Memory',available:'{0} available of {1}',pressureLabel:'Memory pressure:',pressure:'Memory pressure: {0}',normal:'Normal',elevated:'Elevated',critical:'Critical',unknown:'Unknown',swap:'Swap free: {0}',history:'History',range:'History range',coverageSummary:'{0} of {1} readings have fresh data',collecting:'Collecting history…',noHistory:'No recorded samples in this range',historyUnavailable:'Recorded history is temporarily unavailable. Refresh to try again.',historyLoading:'Loading recorded history…',historyWaiting:'History has not started recording yet.',historyPaused:'History recording is paused.',historyFailed:'History could not be recorded. Current samples remain available.',lowSpace:'Low storage: keeping current samples in memory only.',recovering:'Waiting for both storage volumes to stay above 4 GiB for ten minutes.',diskUnavailable:'Storage data is unavailable; history is paused.',backingUnknown:'Identify the Windows backing drive before history can be recorded.',clockChanged:'The computer clock moved backwards; recording is waiting for it to catch up.',historyBusy:'History storage is busy; no additional write is queued.',minimum:'Minimum: {0}',maximum:'Peak: {0}',coverage:'{0} of {1} chart buckets contain recorded samples',gaps:'Gaps mean no sample was recorded; they are not zero.',retention:'History is capped at 64 MiB, with up to 24 hours of raw samples and 30 days of rollups. Older samples may be pruned earlier.',snapshotOnly:'Refresh reads saved snapshots. It does not start a new probe.',samples:'Host every 30 s · storage every 60 s',chart:'{0} history',usedHistory:'Storage used',freeHistory:'Available space trend',notMeasured:'Not measured'},
|
|
15
|
+
'zh-TW':{title:'主機狀態',computer:'這台電腦',lead:'依最新記錄的取樣查看 CPU、記憶體與儲存空間。',settings:'監測設定',refresh:'重新整理',refreshing:'重新整理中…',unsupported:'這台電腦尚未提供主機監測。',off:'主機監測已關閉',offHint:'請在設定中開啟,開始取樣並保留容量受限的本機歷史。',admin:'需要管理員登入',adminHint:'請以 Fleet 管理員身分登入,才能查看主機資料。',starting:'等待第一筆取樣',stopping:'正在停止監測',failedHint:'主機監測未能完成操作,請檢查設定與本機儲存空間權限;歷史資料可能仍需清理。',failed:'主機監測需要處理',unavailable:'無法取得',stale:'資料已過期',lastLabel:'最後成功取樣:',last:'最後成功取樣:{0}',none:'尚無成功的取樣',wsl:'WSL 2',linux:'Linux',darwin:'macOS',wslNote:'CPU 與記憶體代表 WSL,不是實體 Windows 電腦。存放 WSL 的 Windows 磁碟會另外列出。',macNote:'APFS 磁碟區可能共用空間,請勿把可用空間相加。可用記憶體是估算值,記憶體壓力會另外顯示。',linuxNote:'本機 Linux 檔案系統與可用記憶體。無法取得的欄位不會當作零。',runtimeNote:'配對的 Windows 電腦是另一台,不算在這裡的數字裡。',storage:'儲存空間',root:'Linux 檔案系統',state:'Fleet 狀態資料',backing:'存放 WSL 的 Windows 磁碟',volume:'本機磁碟區',drive:'({0}:)',shared:'共用 APFS 容量',sharedHint:'請勿把各磁碟區的可用空間相加。',free:'可用 {0}',used:'已使用 {0}%',unknownDrive:'尚未確認 Windows 磁碟',chooseDrive:'到設定選擇磁碟',unknownHint:'只有 Linux 的可用空間,無法判斷存放 WSL 的 Windows 磁碟是否還有空間。',cpu:'CPU',wslCpu:'WSL CPU',wslMemory:'WSL 記憶體',cpuUsed:'使用率 {0}%',cores:'{0} 個邏輯 CPU',loadLabel:'平均負載:',load:'平均負載:{0}',memory:'記憶體',available:'可用 {0},共 {1}',pressureLabel:'記憶體壓力:',pressure:'記憶體壓力:{0}',normal:'正常',elevated:'偏高',critical:'嚴重',unknown:'未知',swap:'Swap 可用:{0}',history:'歷史紀錄',range:'歷史期間',coverageSummary:'{1} 項讀數中,{0} 項有最新資料',collecting:'正在累積歷史紀錄…',noHistory:'這段期間尚無記錄的取樣',historyUnavailable:'暫時無法取得歷史紀錄,請重新整理再試。',historyLoading:'正在載入歷史紀錄…',historyWaiting:'歷史紀錄尚未開始取樣。',historyPaused:'歷史紀錄已暫停。',historyFailed:'無法記錄歷史,目前的取樣仍可查看。',lowSpace:'儲存空間不足:目前取樣只保留在記憶體中。',recovering:'等待兩個儲存空間持續十分鐘都超過 4 GiB。',diskUnavailable:'無法取得儲存空間資料,歷史紀錄已暫停。',backingUnknown:'請先確認存放 WSL 的 Windows 磁碟,再記錄歷史。',clockChanged:'電腦時間往回調整,正在等待時間追上後再記錄。',historyBusy:'歷史儲存空間忙碌中,不會排入額外的寫入。',minimum:'最低:{0}',maximum:'最高:{0}',coverage:'{1} 個圖表區間中,{0} 個有記錄取樣',gaps:'缺口代表沒有記錄取樣,不是零。',retention:'歷史資料最多 64 MiB;原始取樣最多保留 24 小時,彙整最多 30 天。較舊的取樣可能提早清除。',snapshotOnly:'重新整理只讀取已保存的取樣,不會啟動新的探測。',samples:'主機每 30 秒 · 儲存空間每 60 秒',chart:'{0} 歷史',usedHistory:'儲存空間使用率',freeHistory:'可用空間趨勢',notMeasured:'未量測'}
|
|
12
16
|
});
|
|
13
17
|
const text=(key,...values)=>t(`hostHealth.${key}`,...values);
|
|
14
|
-
const
|
|
15
|
-
const
|
|
18
|
+
const displayBytes=value=>formatBytes(value)?.replace(/ /g,'\u00a0')??null;
|
|
19
|
+
const keepWords=value=>lang()==='zh-TW'?value.split(/(歷史|取樣)/).map(part=>/^(歷史|取樣)$/.test(part)?html`<span class="host-word">${part}</span>`:part):value;
|
|
20
|
+
const date=value=>numberOrNull(value)===null?text('none'):hostTime(value);
|
|
21
|
+
const sampleTime=value=>html`${keepWords(text('lastLabel'))}${lang()==='zh-TW'?'':' '}<span class="host-sample-time">${date(value)}</span>`;
|
|
16
22
|
const settingLink=()=>sectionPath('notifications')+'#host-monitoring';
|
|
17
23
|
const metricLabel=(metric,interval)=>metricState(metric,interval)==='ok'?null:text(metricState(metric,interval));
|
|
18
24
|
export function historyMessage(status){
|
|
@@ -22,7 +28,7 @@ export function historyMessage(status){
|
|
|
22
28
|
function HistoryChart({answer,id,label,unit='percent'}){
|
|
23
29
|
const model=chartData(answer?.series?.find(s=>s.id===id)?.buckets);
|
|
24
30
|
const value=n=>n===null?text('unavailable'):unit==='bytes'?displayBytes(n):unit==='pressure'?text(({1:'normal',2:'elevated',3:'critical'})[Math.round(n)]||'unknown'):`${n.toFixed(1)}%`;
|
|
25
|
-
return html`<figure class="host-chart"><figcaption>${text('chart',label)}</figcaption>${model.covered>=4?html`<svg viewBox="0 0 600 110" role="img" aria-label=${`${text('chart',label)}. ${text('minimum',value(model.min))}. ${text('maximum',value(model.max))}. ${text('coverage',model.covered,model.total)}`}><line x1="0" x2="600" y1="100" y2="100" />${model.segments.map((points,i)=>html`<polyline key=${i} points=${points} />`)}${model.dots.map((point,i)=>html`<circle key=${i} cx=${point.x} cy=${point.y} r="2.5"/>`)}</svg><p class="note">${text('minimum',value(model.min))} · ${text('maximum',value(model.max))}</p><p class="note">${text('coverage',model.covered,model.total)}</p>`:html`<p class="note host-no-history">${text(answer===undefined?'historyLoading':answer?.unavailable?'historyUnavailable':model.covered?'collecting':'noHistory')}</p>`}</figure>`;
|
|
31
|
+
return html`<figure class="host-chart"><figcaption>${keepWords(label===text('freeHistory')?label:text('chart',label))}</figcaption>${model.covered>=4?html`<svg viewBox="0 0 600 110" role="img" aria-label=${`${label===text('freeHistory')?label:text('chart',label)}. ${text('minimum',value(model.min))}. ${text('maximum',value(model.max))}. ${text('coverage',model.covered,model.total)}`}><line x1="0" x2="600" y1="100" y2="100" />${model.segments.map((points,i)=>html`<polyline key=${i} points=${points} />`)}${model.dots.map((point,i)=>html`<circle key=${i} cx=${point.x} cy=${point.y} r="2.5"/>`)}</svg><p class="note">${text('minimum',value(model.min))} · ${text('maximum',value(model.max))}</p><p class="note">${text('coverage',model.covered,model.total)}</p>`:html`<p class="note host-no-history">${keepWords(text(answer===undefined?'historyLoading':answer?.unavailable?'historyUnavailable':model.covered?'collecting':'noHistory'))}</p>`}</figure>`;
|
|
26
32
|
}
|
|
27
33
|
function ValueState({metric,interval}){const state=metricLabel(metric,interval);return state?html`<span class="tag">${state}</span>`:null;}
|
|
28
34
|
function Storage({health,history}){
|
|
@@ -33,31 +39,33 @@ function Storage({health,history}){
|
|
|
33
39
|
return html`<article key=${v.id} class="host-volume"><div class="host-row"><h4>${name}${/^[A-Z]$/.test(v.drive||'')?html`<span class="note">${text('drive',v.drive)}</span>`:null}</h4>${state!=='ok'||!known?html`<span class="tag">${text(state==='stale'?'stale':'unavailable')}</span>`:null}</div><p class="host-value">${numberOrNull(v.availableBytes)!==null?text('free',displayBytes(v.availableBytes)):text('unavailable')}</p><p class="note">${numberOrNull(v.usedPercent,100)!==null?text('used',v.usedPercent.toFixed(1)):text('unavailable')} · ${sampleTime(v.sampledAt)}</p>${numberOrNull(v.usedPercent,100)===null?null:html`<progress class="host-space-meter" value=${v.usedPercent} max="100" aria-label=${text('used',v.usedPercent.toFixed(1))}></progress>`}${health.platform==='darwin'&&v.shared?html`<p class="note">${text('shared')} · ${text('sharedHint')}</p>`:null}<${HistoryChart} answer=${history} id=${`disk.${v.id}.available`} label=${text('freeHistory')} unit="bytes" /></article>`;
|
|
34
40
|
})}</section>`;
|
|
35
41
|
}
|
|
36
|
-
export function HostHealthView({health,history,busy,range,onRange,onRefresh}){
|
|
42
|
+
export function HostHealthView({health,history,busy,range,onRange,onRefresh,agentOffset=0,onAgentOffset,selectedAgent,onSelectedAgent}){
|
|
37
43
|
const at=[health?.cpu?.sampledAt,health?.memory?.sampledAt,health?.disks?.sampledAt].filter(v=>numberOrNull(v)!==null),last=at.length?Math.max(...at):null;
|
|
38
44
|
const cpu=health?.cpu?.value,memory=health?.memory?.value,coverage=sampleCoverage(health);
|
|
39
45
|
const populated=health?.enabled&&health?.platformSupported!==false,platform=text(['wsl','linux','darwin'].includes(health?.platform)?health.platform:'unavailable');
|
|
40
|
-
return html`<section class="host-health" aria-busy=${busy}><${PageHead} title=${text('title')} scope=${text('computer')+(populated?' · '+platform:'')} lead=${text('lead')} note=${html`${last===null?text('none'):sampleTime(last)}${populated?
|
|
46
|
+
return html`<section class="host-health" aria-busy=${busy}><${PageHead} title=${text('title')} scope=${text('computer')+(populated?' · '+platform:'')} lead=${text('lead')} note=${html`${last===null?text('none'):sampleTime(last)}${populated?html` <span class="host-coverage">${text('coverageSummary',coverage.covered,coverage.total)}</span>`:''}`}><button type="button" class="btn btn-sm" disabled=${busy} onClick=${onRefresh}><${Icon} name="restart" size=${15}/>${text(busy?'refreshing':'refresh')}</button>${health?.platformSupported===false?null:html`<a class="btn btn-sm" href=${settingLink()}>${text('settings')}</a>`}</${PageHead}>
|
|
41
47
|
${!populated?html`<p class="note">${text('snapshotOnly')}</p>`:null}
|
|
42
48
|
${health?.platformSupported===false?html`<section class="card"><h3>${text('unsupported')}</h3></section>`:!health?.enabled?html`<section class="card host-off"><h3>${text(health?.state==='failed'?'failed':health?.state==='stopping'?'stopping':'off')}</h3><p>${text(health?.state==='failed'?'failedHint':health?.state==='stopping'?'stopping':'offHint')}</p><a class="btn btn-primary" href=${settingLink()}>${text('settings')}</a></section>`:html`
|
|
43
49
|
${health.state!=='sampling'?html`<div class="notice" role="status">${text(({starting:'starting',stopping:'stopping',failed:'failed'})[health.state]||'unavailable')}</div>`:null}
|
|
44
|
-
${health.history?.state!=='recording'?html`<p class="notice" role="status">${historyMessage(health.history)}</p>`:null}
|
|
50
|
+
${health.history?.state!=='recording'?html`<p class="notice" role="status">${keepWords(historyMessage(health.history))}</p>`:null}
|
|
51
|
+
<${HostAlerts} alerts=${health.alerts} onChange=${onRefresh}/>
|
|
45
52
|
<div class="host-range" role="group" aria-label=${text('range')}>${HOST_RANGES.map(r=>html`<button type="button" class=${`btn btn-sm${range===r?' active':''}`} aria-pressed=${range===r} onClick=${()=>onRange(r)}>${r}</button>`)}</div>
|
|
46
53
|
<div class="host-grid"><div class="host-compute"><section class="card"><div class="host-row"><h3>${text(health.platform==='wsl'?'wslCpu':'cpu')}</h3><${ValueState} metric=${health.cpu} interval=${30000}/></div><p class="host-value">${numberOrNull(cpu?.usedPercent,100)===null?text('unavailable'):text('cpuUsed',cpu.usedPercent.toFixed(1))}</p><p class="note">${numberOrNull(cpu?.logicalCpus)!==null?text('cores',cpu.logicalCpus):text('unavailable')}</p>${Array.isArray(cpu?.loadAverage)?html`<p class="note">${text('loadLabel')}${lang()==='zh-TW'?'':' '}<span class="host-load-value">${cpu.loadAverage.slice(0,3).map(n=>numberOrNull(n)===null?'—':n.toFixed(2)).join(' / ')}</span></p>`:null}<p class="note">${sampleTime(health.cpu?.sampledAt)}</p><${HistoryChart} answer=${history} id="cpu.used" label=${text('cpu')}/></section>
|
|
47
|
-
<section class="card"><div class="host-row"><h3>${text(health.platform==='wsl'?'wslMemory':'memory')}</h3><${ValueState} metric=${health.memory} interval=${30000}/></div><p class="host-value">${text('pressureLabel')}${lang()==='zh-TW'?'':' '}<span class="host-pressure-value">${text(metricState(health.memory,30000)==='ok'&&['normal','elevated','critical'].includes(memory?.pressure)?memory.pressure:'unknown')}</span></p><p class="note">${numberOrNull(memory?.availableBytes)===null?text('unavailable'):
|
|
48
|
-
<${Storage} health=${health} history=${history}/></div><p class="note">${
|
|
54
|
+
<section class="card"><div class="host-row"><h3>${text(health.platform==='wsl'?'wslMemory':'memory')}</h3><${ValueState} metric=${health.memory} interval=${30000}/></div><p class="host-value">${text('pressureLabel')}${lang()==='zh-TW'?'':' '}<span class="host-pressure-value">${text(metricState(health.memory,30000)==='ok'&&['normal','elevated','critical'].includes(memory?.pressure)?memory.pressure:'unknown')}</span></p><p class="note">${numberOrNull(memory?.availableBytes)===null?text('unavailable'):monitoringHelp(health.platform,memory.availableKind==='free'?'availableFallback':'available',displayBytes(memory.availableBytes),displayBytes(memory.totalBytes)||text('unavailable'))}</p><p class="note" data-platform-memory-help>${monitoringHelp(health.platform,'memory')}</p><p class="note">${health.platform==='darwin'?monitoringHelp('darwin','swap',displayBytes(memory?.details?.kind==='darwin'?memory.details.swapUsedBytes:null)||text('unavailable'),displayBytes(memory?.swapTotalBytes)||text('unavailable')):monitoringHelp(health.platform,'swap',displayBytes(memory?.swapFreeBytes)||text('unavailable'))}</p>${health.platform==='darwin'?html`<p class="note" data-memory-compression>${monitoringHelp('darwin','compression',displayBytes(memory?.details?.kind==='darwin'?memory.details.compressedBytes:null)||text('unavailable'),displayBytes(memory?.details?.kind==='darwin'?memory.details.storedBytes:null)||text('unavailable'))}</p>`:html`<p class="note" data-memory-psi>${monitoringHelp(health.platform,'psi',numberOrNull(memory?.details?.psiSomeAvg60,100)===null?text('unavailable'):memory.details.psiSomeAvg60.toFixed(1),numberOrNull(memory?.details?.psiFullAvg10,100)===null?text('unavailable'):memory.details.psiFullAvg10.toFixed(1))}</p>`}<p class="note">${sampleTime(health.memory?.sampledAt)}</p><${HistoryChart} answer=${history} id="memory.available" label=${monitoringHelp(health.platform,'chart')} unit="bytes" /></section></div>
|
|
55
|
+
<${Storage} health=${health} history=${history}/></div><p class="note">${monitoringHelp(health.platform,'overall')}</p><p class="note">${keepWords(text('samples'))} · ${keepWords(text('snapshotOnly'))}</p><p class="note">${text('runtimeNote')}</p><p class="note">${text('gaps')}</p><p class="note">${text('retention')}</p><${HostFootprintView} snapshot=${health.footprint} offset=${agentOffset} onOffset=${onAgentOffset} onSelect=${onSelectedAgent} selected=${selectedAgent} charts=${selectedAgent&&health.footprint?.enabled?html`<${HistoryChart} answer=${history} id=${`agent.${selectedAgent}.cpu`} label=${footprintText('agentCpu')}/><${HistoryChart} answer=${history} id=${`agent.${selectedAgent}.rss`} label=${footprintText('agentMemory')} unit="bytes"/>`:null}/>`}
|
|
49
56
|
</section>`;
|
|
50
57
|
}
|
|
51
58
|
export function HostHealth({lease}){
|
|
59
|
+
const [agentOffset,setAgentOffset]=useState(0),[selectedAgent,setSelectedAgent]=useState(null);
|
|
52
60
|
const [data,setData]=useState(null),[history,setHistory]=useState(null),[range,setRange]=useState('1h'),[busy,setBusy]=useState(false),[error,setReadState]=useState(null),seq=useRef(0),inflight=useRef(false),pending=useRef(false),latest=useRef(null),alive=useRef(true);
|
|
53
61
|
const load=async()=>{
|
|
54
62
|
if(!alive.current||!lease.current())return;if(inflight.current){pending.current=true;return;}inflight.current=true;const mine=++seq.current;setBusy(true);
|
|
55
63
|
try{
|
|
56
|
-
const response=await lease.fetch('/ui/host-health',{cache:'no-store'});if(!alive.current||!lease.current()||mine!==seq.current)return;
|
|
64
|
+
const response=await lease.fetch('/ui/host-health'+(agentOffset?'?agentOffset='+agentOffset:''),{cache:'no-store'});if(!alive.current||!lease.current()||mine!==seq.current)return;
|
|
57
65
|
if(response.status===401||response.status===403){setData(null);setHistory(null);setReadState('admin');return;}if(!response.ok)throw Error('read failed');
|
|
58
66
|
const health=await response.json();if(!alive.current||!lease.current()||mine!==seq.current)return;setData(health);setReadState(null);
|
|
59
67
|
if(!health.enabled||health.history?.state!=='recording'){setHistory(null);return;}
|
|
60
|
-
const params=new URLSearchParams({range});for(const id of historySeries(health))params.append('series',id);
|
|
68
|
+
const params=new URLSearchParams({range});for(const id of [...historySeries(health),...(selectedAgent?[`agent.${selectedAgent}.cpu`,`agent.${selectedAgent}.rss`]:[])])params.append('series',id);
|
|
61
69
|
const r=await lease.fetch('/ui/host-history?'+params,{cache:'no-store'});if(!alive.current||!lease.current()||mine!==seq.current)return;
|
|
62
70
|
if(r.status===401||r.status===403){setData(null);setHistory(null);setReadState('admin');return;}
|
|
63
71
|
const result=r.ok?await r.json():null;if(alive.current&&lease.current()&&mine===seq.current)setHistory({range,value:result?.ok?result.value:{unavailable:true}});
|
|
@@ -65,10 +73,10 @@ export function HostHealth({lease}){
|
|
|
65
73
|
};
|
|
66
74
|
latest.current=load;
|
|
67
75
|
useEffect(()=>{alive.current=true;return()=>{alive.current=false;seq.current++;};},[lease]);
|
|
68
|
-
useEffect(()=>{seq.current++;void load();},[lease,range]);
|
|
76
|
+
useEffect(()=>{seq.current++;void load();},[lease,range,agentOffset,selectedAgent]);
|
|
69
77
|
// Only an enabled visible page refreshes its cache. Off/unmounted pages own no monitoring poll.
|
|
70
|
-
useEffect(()=>{if(!data?.enabled)return;const timer=lease.interval(()=>{if(typeof document==='undefined'||!document.hidden)void
|
|
78
|
+
useEffect(()=>{if(!data?.enabled)return;const timer=lease.interval(()=>{if(typeof document==='undefined'||!document.hidden)void latest.current?.();},30000);return()=>lease.clear(timer);},[lease,data?.enabled,range]);
|
|
71
79
|
if(error==='admin')return html`<section class="card"><h2>${text('admin')}</h2><p>${text('adminHint')}</p></section>`;
|
|
72
80
|
if(!data)return error?html`<${ErrorState} onRetry=${load}/>`:html`<${Skeleton} lines=${5}/>`;
|
|
73
|
-
return html`<div>${error?html`<${ErrorState} onRetry=${load}/>`:null}<${HostHealthView} health=${data} history=${history?.range===range?history.value:busy?undefined:null} range=${range} onRange=${setRange} onRefresh=${load} busy=${busy}/></div>`;
|
|
81
|
+
return html`<div>${error?html`<${ErrorState} onRetry=${load}/>`:null}<${HostHealthView} health=${data} history=${history?.range===range?history.value:busy?undefined:null} agentOffset=${agentOffset} onAgentOffset=${value=>{setAgentOffset(value);setSelectedAgent(null);}} selectedAgent=${selectedAgent} onSelectedAgent=${setSelectedAgent} range=${range} onRange=${setRange} onRefresh=${load} busy=${busy}/></div>`;
|
|
74
82
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import {register,t} from '/assets/app-i18n.js';
|
|
2
|
+
register('hostDarwin',{
|
|
3
|
+
en:{settings:'macOS uses its kernel memory-pressure state. Compression and swap are diagnostics, not percentages that trigger alerts. APFS volumes may share one storage pool.',memory:'Pressure comes from the macOS kernel. Low free RAM or a large swap allocation alone does not mean Critical.',available:'Reclaimable RAM estimate: {0} of {1}',availableFallback:'Reclaimable RAM estimate: {0} of {1}',swap:'Swap used: {0} · allocated now: {1}. macOS can change this pool.',compression:'Compressor RAM: {0} · stored content before compression: {1}',psi:'',alertHint:'Default: alert only at Critical. Your saved memory rule takes precedence.',overall:'macOS memory pressure, compression and dynamically allocated swap have different meanings. APFS volumes in one container share free space; it is not added once per volume.',chart:'Reclaimable RAM estimate'},
|
|
4
|
+
'zh-TW':{settings:'macOS 依核心的記憶體壓力狀態判斷。壓縮與交換空間用來說明用量,不會按使用率觸發警示。APFS 卷宗可能共用同一個儲存空間。',memory:'壓力狀態來自 macOS 核心。可用 RAM 少或交換空間配置較大,單憑這些數字不代表嚴重。',available:'可回收 RAM 估算:{0}/{1}',availableFallback:'可回收 RAM 估算:{0}/{1}',swap:'已用交換空間:{0} · 目前配置:{1}。macOS 會調整這個空間。',compression:'壓縮器佔用 RAM:{0} · 壓縮前資料量:{1}',psi:'',alertHint:'預設只在嚴重時警示;你已儲存的記憶體規則優先。',overall:'macOS 的壓力狀態、壓縮與動態配置的交換空間各有不同意義。同一個 APFS 容器內的卷宗共用可用空間,不會按卷宗重複加總。',chart:'可回收 RAM 估算'}
|
|
5
|
+
});
|
|
6
|
+
export const help=(key,...args)=>t('hostDarwin.'+key,...args);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Presentation dispatch only; each platform owns its wording and meaning.
|
|
2
|
+
import {help as darwin} from './host-monitoring-darwin.js';
|
|
3
|
+
import {help as linux} from './host-monitoring-linux.js';
|
|
4
|
+
import {help as wsl} from './host-monitoring-wsl.js';
|
|
5
|
+
import {register,t} from '/assets/app-i18n.js';
|
|
6
|
+
register('hostPlatformHelp',{en:{unavailable:'Unavailable',memory:'Memory',unknown:'Platform-specific information is unavailable until the platform is identified.'},'zh-TW':{unavailable:'無法取得',memory:'記憶體',unknown:'辨識平台後才能顯示該平台的說明。'}});
|
|
7
|
+
export function monitoringHelp(platform,key,...args){const own=platform==='darwin'?darwin:platform==='wsl'?wsl:platform==='linux'?linux:null;return own?own(key,...args):t('hostPlatformHelp.'+(['settings','memory','overall'].includes(key)?'unknown':key==='chart'?'memory':'unavailable'));}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import {register,t} from '/assets/app-i18n.js';
|
|
2
|
+
register('hostLinux',{
|
|
3
|
+
en:{settings:'Linux pressure uses MemAvailable, memory-stall information (PSI) when available, and swap. Missing PSI uses the existing RAM/swap policy.',memory:'Pressure follows the Linux policy for available RAM, swap and PSI stalls.',available:'MemAvailable: {0} of {1}',availableFallback:'Free RAM fallback (MemAvailable unavailable): {0} of {1}',swap:'Swap free: {0}',compression:'',psi:'Memory stalls: some {0}% (60 s) · full {1}% (10 s)',alertHint:'Default: warn at Elevated and alert urgently at Critical. Your saved memory rule takes precedence.',overall:'Linux reports estimated available memory, PSI stalls and swap separately. Missing signals remain unavailable; local filesystem space is shown for the relevant storage pool.',chart:'Available memory'},
|
|
4
|
+
'zh-TW':{settings:'Linux 依 MemAvailable、可取得時的記憶體停滯資料(PSI)及交換空間判斷壓力。沒有 PSI 時沿用 RAM 與交換空間規則。',memory:'壓力標籤依 Linux 的可用 RAM、交換空間與 PSI 停滯規則判斷。',available:'可用記憶體:{0}/{1}',availableFallback:'可用記憶體備用讀數:{0}/{1}',swap:'可用交換空間:{0}',compression:'',psi:'記憶體停滯:部分 {0}%(60 秒)· 全部 {1}%(10 秒)',alertHint:'預設偏高時發出注意警示、嚴重時發出緊急警示;你已儲存的記憶體規則優先。',overall:'Linux 分別呈現估算的可用記憶體、PSI 停滯與交換空間。缺少的訊號維持無法取得;本機檔案系統依相關儲存空間顯示。',chart:'可用記憶體'}
|
|
5
|
+
});
|
|
6
|
+
export const help=(key,...args)=>t('hostLinux.'+key,...args);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import {register,t} from '/assets/app-i18n.js';
|
|
2
|
+
register('hostWsl',{
|
|
3
|
+
en:{settings:'WSL pressure uses its Linux MemAvailable, PSI and swap. These are WSL figures; the Windows drive holding the virtual disk is monitored separately.',memory:'Memory and swap belong to the WSL environment, not all Windows RAM. Pressure follows the Linux RAM/swap and PSI policy.',available:'WSL MemAvailable: {0} of {1}',availableFallback:'WSL free RAM fallback (MemAvailable unavailable): {0} of {1}',swap:'WSL swap free: {0}',compression:'',psi:'WSL memory stalls: some {0}% (60 s) · full {1}% (10 s)',alertHint:'Default: warn at Elevated and alert urgently at Critical. Your saved memory rule takes precedence.',overall:'WSL memory/swap are separate from Windows host memory. The Windows drive holding the virtual disk has its own free-space reading; an unknown drive is never guessed.',chart:'WSL available memory'},
|
|
4
|
+
'zh-TW':{settings:'WSL 依自身 Linux 的 MemAvailable、PSI 與交換空間判斷壓力。這些是 WSL 的數字;存放虛擬磁碟的 Windows 磁碟另行監測。',memory:'記憶體與交換空間屬於 WSL 環境,不是整台 Windows 電腦的 RAM。壓力依 Linux 的 RAM、交換空間與 PSI 規則判斷。',available:'WSL 可用記憶體:{0}/{1}',availableFallback:'WSL 可用記憶體備用讀數:{0}/{1}',swap:'WSL 可用交換空間:{0}',compression:'',psi:'WSL 記憶體停滯:部分 {0}%(60 秒)· 全部 {1}%(10 秒)',alertHint:'預設偏高時發出注意警示、嚴重時發出緊急警示;你已儲存的記憶體規則優先。',overall:'WSL 的記憶體與交換空間不代表 Windows 主機的全部用量。存放虛擬磁碟的 Windows 磁碟另有可用空間讀數;無法辨識時不會猜測。',chart:'WSL 可用記憶體'}
|
|
5
|
+
});
|
|
6
|
+
export const help=(key,...args)=>t('hostWsl.'+key,...args);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import {lang} from '/assets/app-i18n.js';
|
|
2
|
+
/** Shared compact host timestamp: one local 24-hour format on cards and incident updates. */
|
|
3
|
+
export function hostTime(value){
|
|
4
|
+
return new Date(value).toLocaleString(lang()==='zh-TW'?'zh-TW':'en-GB',{month:'short',day:'numeric',hour:'2-digit',minute:'2-digit',second:'2-digit',hour12:false});
|
|
5
|
+
}
|
|
@@ -7,6 +7,7 @@ register("hub", {
|
|
|
7
7
|
classicRoomLead: "You can also share the agent of a ClassicBot room. Hub questions and answers are not posted in its Discord or Telegram room, and the room's chat is not copied to the Hub. It is one agent with one memory, though: it may use what it learned in the room when it answers on the Hub, and the other way round.",
|
|
8
8
|
agentShared: "Shared: Hub questions go to this agent's own conversation.",
|
|
9
9
|
republishRequired: "Shared under the older restricted mode. Hub questions are refused until you share this agent again.",
|
|
10
|
+
shareLapsed: "Its backend or folder changed since you shared it, and a share does not carry over. Hub questions are refused until you share it again.",
|
|
10
11
|
shareAgain: "Share again",
|
|
11
12
|
classicRoomTag: "ClassicBot room",
|
|
12
13
|
agentNotShareable: "This agent can't be shared right now. Reload the page and try again.",
|
|
@@ -17,6 +18,7 @@ register("hub", {
|
|
|
17
18
|
classicRoomLead: "也可以分享 ClassicBot 房間的 Agent。Hub 的提問與回答不會貼到它的 Discord 或 Telegram 房間,房間的聊天也不會複製到 Hub。但它是同一個 Agent、同一份記憶:回答 Hub 的提問時,可能用到它在房間裡得知的內容,反過來也一樣。",
|
|
18
19
|
agentShared: "已分享:Hub 的提問會送到這個 Agent 自己的對話。",
|
|
19
20
|
republishRequired: "這是舊的受限模式分享。重新分享這個 Agent 之前,Hub 的提問都會被拒絕。",
|
|
21
|
+
shareLapsed: "分享之後它的後端或資料夾換了,原本的分享不會延續。重新分享之前,Hub 的提問都會被拒絕。",
|
|
20
22
|
shareAgain: "重新分享",
|
|
21
23
|
classicRoomTag: "ClassicBot 房間",
|
|
22
24
|
agentNotShareable: "目前無法分享這個 Agent。請重新整理頁面後再試一次。",
|
package/dist/ui/hub-client.js
CHANGED
|
@@ -499,6 +499,10 @@ export function createHubWebClient({ fetchImpl = (...a) => fetch(...a), readTime
|
|
|
499
499
|
reactRoomMessage(roomId, messageId, emoji, on) { return call("POST", `/hub/v1/rooms/${id(roomId)}/messages/${id(messageId)}/reactions`, { emoji: String(emoji), on: on === true }); },
|
|
500
500
|
/** M-3340: my own pins in a group room (nobody else's) → { pins: [{ messageId, pinnedAt, message }] }, newest first. */
|
|
501
501
|
roomPins(roomId) { return call("GET", `/hub/v1/rooms/${id(roomId)}/pins`); },
|
|
502
|
+
/** M-3533 R1: a Hub that serves rooms' offices (with the session's room-office-v1). */
|
|
503
|
+
roomOfficeV1: true,
|
|
504
|
+
/** M-3533 R1: a group room's office, as a share link's /state reads (409 office-off while a manager has it off). */
|
|
505
|
+
roomOfficeState(roomId) { return call("GET", `/hub/v1/rooms/${id(roomId)}/office/state`); },
|
|
502
506
|
/** M-3340: pin (`on`) or unpin a group-room message for me only → { pins }. Past 50: the Hub refuses (pins-full). */
|
|
503
507
|
pinRoomMessage(roomId, messageId, on) { return call(on ? "PUT" : "DELETE", `/hub/v1/rooms/${id(roomId)}/pins/${id(messageId)}`); },
|
|
504
508
|
markRoomRead(roomId, upTo) { return call("POST", `/hub/v1/rooms/${id(roomId)}/read`, { upTo }); },
|
|
@@ -3,6 +3,7 @@ register("hubMyAgents", {
|
|
|
3
3
|
en: {
|
|
4
4
|
offlineShort:"Offline · last seen {0}", knownShared:"{0} shared", oldCountOne:"1 Fleet needs an update to share agents from here.", oldCount:"{0} Fleets need an update to share agents from here.", namesMore:"{0} and {1} more", lead:"The agents you can share on this Hub, and who may ask each one.", refresh:"Refresh", refreshing:"Checking…", fleet:"Fleet", connected:"Connected", offline:"This Fleet is offline. Shown as last seen at {0}.", count:"{0} of {1} shared", select:"Select all", general:"Your Fleet's General. It can manage this Fleet.", classic:"ClassicBot room", classicHint:"Hub questions and answers are not posted in its Discord or Telegram room, and the room's chat is not copied to the Hub. It is one agent with one memory: it may use what it learned in the room when it answers here.",
|
|
5
5
|
old:"Update this Fleet to share agents from here.", update:"Update this Fleet", updateHint:"On that computer, open Settings → Hub and check its connection and version.", off:"Sharing from the Hub page is turned off in this Fleet's Settings → Hub.", denied:"Your Hub administrator hasn't allowed you to share agents.", unknown:"The Hub could not check whether sharing is allowed. Refresh to check.", remote:"This kind of agent can't answer Hub questions yet.", unavailable:"This agent cannot answer Hub questions right now.", limit:"This Fleet already shares 64 agents, the most allowed.", suspended:"This Fleet is paused on this Hub.", revoked:"This Fleet was removed from this Hub.",
|
|
6
|
+
lapsed:"Its backend or folder changed since you shared it, so Hub questions are refused until you share it again. The people who may ask it stay.", shareAgain:"Share again", needsReshare:"Needs re-share", kept:"(kept)",
|
|
6
7
|
shared:"Shared", nobody:"nobody may ask yet", peopleOne:"1 person may ask", people:"{0} people may ask", subjects:"{0} people, groups or teams may ask", paused:"Paused", sharing:"Sharing…", stopping:"Stopping…", uncertain:"Not confirmed yet: this Fleet hasn't answered. Refresh to check.", refused:"Not shared: {0}", changed:"This list changed. It has been refreshed; tick again.",
|
|
7
8
|
shareOne:"Share 1 agent", stopOne:"Stop sharing 1 agent", stopTitleOne:"Stop sharing 1 agent?", accessTitleOne:"1 agent is shared. Who may ask it?", share:"Share {0} agents", stop:"Stop sharing {0} agents", mixed:"Share {0} · Stop sharing {1}", apply:"Apply changes", cancel:"Cancel", stopTitle:"Stop sharing {0} agents?", stopBody:"People will no longer be able to ask: {0}. Their lists of who may ask are cleared.", stopHint:"To keep the lists and only stop answers for now, pause sharing instead.", stopGo:"Stop sharing", pause:"Pause instead", pauseOne:"Pause sharing", later:"Decide later", accessTitle:"{0} agents are shared. Who may ask them?", accessLead:"Nobody can ask them until you choose.", same:"The same people for all {0}", each:"Choose for each agent", choose:"Choose who may ask", previousMixed:"Use the list it had before", previous:"Use the list it had before ({0} people)", used:"The previous list is saved.", saved:"Saved", saveFailed:"Could not save access for {0}. Check the current agent and try again.", personal:"On my own computer", details:"Open {0}",
|
|
8
9
|
empty:"You don't have an agent on this Hub yet.", already:"You can already ask other people's agents: open Chats, or @mention an agent in a room.", emptyLead:"To have an agent of your own that colleagues can ask:", personalOff:"Personal agents are turned off on this Hub. Ask your Hub administrator.", fleetLead:"If you run AgEnD, share the agents in it.", connectDenied:"Ask your Hub administrator to let you connect a Fleet.", apps:"Your own Claude Code or Codex can also use this Hub for you. That is for asking and posting as you. Colleagues can't ask it.", appsLink:"My AI apps", failed:"The list could not be read. Refresh to try again.",
|
|
@@ -10,6 +11,7 @@ register("hubMyAgents", {
|
|
|
10
11
|
"zh-TW": {
|
|
11
12
|
offlineShort:"離線 · 最後上線 {0}", knownShared:"已分享 {0}", oldCountOne:"有 1 個 Fleet 需要更新,才能從這裡分享 Agent。", oldCount:"有 {0} 個 Fleet 需要更新,才能從這裡分享 Agent。", namesMore:"{0} 等 {1} 個", lead:"可以分享到這個 Hub 的 Agent,以及誰可以向它們提問。", refresh:"重新整理", refreshing:"確認中…", fleet:"Fleet", connected:"已連接", offline:"這個 Fleet 目前離線,顯示的是 {0} 的狀態。", count:"已分享 {0} / {1}", select:"全選", general:"你的 Fleet 的 General,可以管理這個 Fleet。", classic:"ClassicBot 房間", classicHint:"Hub 的提問與回答不會貼到它的 Discord 或 Telegram 房間,房間的聊天也不會複製到 Hub。但它是同一個 Agent、同一份記憶:在這裡回答時,可能用到它在房間裡得知的內容。",
|
|
12
13
|
old:"請更新這個 Fleet,才能從這裡分享 Agent。", update:"更新這個 Fleet", updateHint:"請到那台電腦的「設定 → Hub」,確認連接狀態與版本。", off:"這個 Fleet 的「設定 → Hub」關閉了從 Hub 頁面分享。", denied:"Hub 管理員還沒有允許你分享 Agent。", unknown:"Hub 目前無法確認是否允許分享,請重新整理確認。", remote:"這種 Agent 還不能回答 Hub 的提問。", unavailable:"這個 Agent 目前無法回答 Hub 的提問。", limit:"這個 Fleet 已經分享 64 個 Agent,達到上限。", suspended:"這個 Fleet 在這個 Hub 已暫停。", revoked:"這個 Fleet 已從這個 Hub 移除。",
|
|
14
|
+
lapsed:"分享之後它的後端或資料夾換了,重新分享之前 Hub 的提問都會被拒絕。可以提問的人會保留。", shareAgain:"重新分享", needsReshare:"需要重新分享", kept:"(會保留)",
|
|
13
15
|
shared:"分享中", nobody:"還沒有人可以問", peopleOne:"1 人可以提問", people:"{0} 人可以提問", subjects:"{0} 個人員、群組或團隊可以提問", paused:"已暫停", sharing:"分享中…", stopping:"停止中…", uncertain:"還沒有確認:這個 Fleet 尚未回應,請重新整理確認。", refused:"沒有分享:{0}", changed:"清單已有變動並重新整理,請重新勾選。",
|
|
14
16
|
shareOne:"分享 1 個 Agent", stopOne:"停止分享 1 個 Agent", stopTitleOne:"要停止分享 1 個 Agent 嗎?", accessTitleOne:"已分享 1 個 Agent。誰可以問它?", share:"分享 {0} 個 Agent", stop:"停止分享 {0} 個 Agent", mixed:"分享 {0} 個 · 停止分享 {1} 個", apply:"套用變更", cancel:"取消", stopTitle:"要停止分享 {0} 個 Agent 嗎?", stopBody:"同仁將無法再問:{0}。這些 Agent 的「可以提問的人」名單會被清除。", stopHint:"如果只是暫時不回答、想保留名單,請改用「暫停分享」。", stopGo:"停止分享", pause:"改為暫停", pauseOne:"暫停分享", later:"稍後再決定", accessTitle:"已分享 {0} 個 Agent。誰可以問它們?", accessLead:"在你選擇之前,沒有人可以問它們。", same:"{0} 個都用同一份名單", each:"每個 Agent 分開選", choose:"選擇誰可以提問", previousMixed:"沿用之前的名單", previous:"沿用之前的名單({0} 人)", used:"已儲存之前的名單。", saved:"已儲存", saveFailed:"無法儲存 {0} 的提問權限,請確認目前的 Agent 後再試。", personal:"在我的電腦上", details:"開啟 {0}",
|
|
15
17
|
empty:"你在這個 Hub 還沒有自己的 Agent。", already:"你現在就可以問別人的 Agent:到「對話」,或在房間裡 @ 一個 Agent。", emptyLead:"想要有自己的 Agent 讓同仁提問:", personalOff:"這個 Hub 還沒有開啟個人 Agent,請洽 Hub 管理員。", fleetLead:"如果你有在使用 AgEnD,可以分享裡面的 Agent。", connectDenied:"請 Hub 管理員允許你連接 Fleet。", apps:"你自己的 Claude Code 或 Codex 也可以替你使用這個 Hub,用來提問和發言;同仁不能問它。", appsLink:"我的 AI App", failed:"無法讀取清單,請重新整理再試。",
|
package/dist/ui/hub-my-agents.js
CHANGED
|
@@ -74,6 +74,18 @@ export function HubMyAgents({ client, scope, shared = [], policy = false, person
|
|
|
74
74
|
const response = r.ok ? r : definite ? { state: "complete", result: { results: op.rows.map(row => ({ ...(row.instance ? { instance: row.instance } : { exposureId: row.id }), ok: false, code: r.code === "conflict" ? "stale-list" : r.code === "denied" ? "not-allowed" : "unavailable" })) } } : op.response;
|
|
75
75
|
persist(currentOps.current.map(x => x.input.idempotencyKey === op.input.idempotencyKey ? { ...x, response } : x));
|
|
76
76
|
};
|
|
77
|
+
// M-3543: Share again of a lapsed agent (shared, but its backend/folder changed since): one share request for it, which
|
|
78
|
+
// the Fleet answers with a republish at the next revision; the Hub keeps the people who may ask it.
|
|
79
|
+
const shareAgain = async (row, fleet) => {
|
|
80
|
+
if (writing.current) return; writing.current = true; setBusy(true); const generation = life.current;
|
|
81
|
+
try {
|
|
82
|
+
const op = { input: { idempotencyKey: crypto.randomUUID(), fleetId: fleet.id, catalogRevision: fleet.catalog.revision, share: [row.instance], stop: [] }, at: Date.now(),
|
|
83
|
+
rows: [{ instance: row.instance, name: row.displayName, before: { id: row.current.id, revision: row.current.revision } }], response: null };
|
|
84
|
+
persist([...currentOps.current.slice(-24), op]);
|
|
85
|
+
await send(op, generation);
|
|
86
|
+
await load(generation);
|
|
87
|
+
} finally { if (live(generation)) { writing.current = false; setBusy(false); } }
|
|
88
|
+
};
|
|
77
89
|
const refresh = async () => {
|
|
78
90
|
if (writing.current) return; writing.current = true; setBusy(true); const generation = life.current;
|
|
79
91
|
try {
|
|
@@ -119,7 +131,11 @@ export function HubMyAgents({ client, scope, shared = [], policy = false, person
|
|
|
119
131
|
<span class="hub-row-text">${row.current ? html`<a href=${`/ui/hub/exposures?agent=${encodeURIComponent(row.current.id)}`} aria-label=${ms("details", row.displayName)}><strong>${row.displayName}</strong></a>` : html`<strong>${row.displayName}</strong>`}
|
|
120
132
|
${row.kind === "classic-room" ? html`<small class="tag">${ms("classic")}</small>` : null}<small class="note">${reason && reason !== "offline" ? ms(reason) : row.general ? ms("general") : row.description}</small>
|
|
121
133
|
${row.current?.intro ? html`<small class="note">${row.current.intro}</small>` : null}
|
|
122
|
-
${row.shared ?
|
|
134
|
+
${row.shared ? (row.exposure?.lapsed === true && row.instance
|
|
135
|
+
? html`<small class="note hub-agent-lapsed-status">${ms("needsReshare")} · ${summary(row.current)}${lang() === "zh-TW" ? "" : " "}${ms("kept")}</small>`
|
|
136
|
+
: html`<small class="note">${ms(row.current.state !== "published" ? "paused" : "shared")} · ${summary(row.current)}</small>`) : null}
|
|
137
|
+
${row.shared && row.exposure?.lapsed === true && row.instance ? html`<small class="note hub-agent-lapsed" role="status">${ms("lapsed")}</small>
|
|
138
|
+
<button type="button" class="btn btn-sm hub-agent-share-again" data-share-again=${row.instance} disabled=${busy || !!waiting.length} onClick=${() => shareAgain(row, fleet)}>${ms("shareAgain")}</button>` : null}
|
|
123
139
|
${status ? html`<small class=${status.state === "refused" ? "err" : "note"} role="status">${status.state === "uncertain" ? ms("uncertain") : status.state === "refused" ? status.code === "stale-list" ? ms("changed") : ms("refused", ms(({ "not-allowed": "denied", "switched-off": "off", "limit": "limit", "not-shareable": "unavailable" })[status.code] || "unavailable")) : ms(status.instance ? "sharing" : "stopping")}</small>` : null}</span>
|
|
124
140
|
${pausable && row.shared && row.current.state === "published" && typeof client.ownerSharing === "function" ? html`<button type="button" class="btn btn-sm hub-agent-pause" disabled=${busy} onClick=${() => pause([{ ...row, fleet }])}>${ms("pauseOne")}</button>` : null}</div>
|
|
125
141
|
${row.kind === "classic-room" && tick && !row.shared ? html`<p class="note hub-classic-disclosure">${ms("classicHint")}</p>` : null}</div>`; })}</div></details>`;
|
|
@@ -79,6 +79,74 @@ export function mentionsIn(text, detail) {
|
|
|
79
79
|
return [...new Set(out)];
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
/**
|
|
83
|
+
* M-3533 (#4355 review): who a mention put in the box stands for — the office card's "@ it" and the members panel's — is
|
|
84
|
+
* that member, not every member of its name. A binding is one mention where it was put: { name, id, start } (its `@name`
|
|
85
|
+
* at `start`). Edits move or retire it (shiftBindings); only one still whole at its place binds (intactBindings).
|
|
86
|
+
*/
|
|
87
|
+
const tokenAt = (s, b) => s.startsWith(`@${b.name}`, b.start) && !/[\w-]/.test(s.charAt(b.start + 1 + b.name.length));
|
|
88
|
+
/**
|
|
89
|
+
* The edit that turned `prev` into `next`, from the box's selection when it began ({ start, end }) and its caret after
|
|
90
|
+
* (`caret`): prev[a, b) became next[a, caret) — typing, a paste, a cut, Backspace or Delete, an IME's composed text — or
|
|
91
|
+
* null when those do not account for the change (the change is then not the box's own: see shiftBindings).
|
|
92
|
+
*/
|
|
93
|
+
export function editRange(prev, next, sel, caret) {
|
|
94
|
+
const a0 = String(prev || ""), b0 = String(next || "");
|
|
95
|
+
if (!sel || !Number.isInteger(sel.start) || !Number.isInteger(sel.end) || !Number.isInteger(caret)) return null;
|
|
96
|
+
const a = Math.min(sel.start, caret), b = caret - (b0.length - a0.length);
|
|
97
|
+
if (a < 0 || b < a || b > a0.length || caret > b0.length) return null;
|
|
98
|
+
return a0.slice(0, a) === b0.slice(0, a) && a0.slice(b) === b0.slice(caret) ? { a, b, c: caret } : null;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The bindings after the text changed from `prev` to `next` by `range` (editRange: prev[a, b) became next[a, c)): a
|
|
102
|
+
* mention wholly before the edit stays, one wholly after it moves by the change in length, one the edit touches is gone
|
|
103
|
+
* (deleted or edited: a later pick or a name retyped by hand cannot revive it). With no range, the edit could be anywhere
|
|
104
|
+
* the two texts allow (two identical mentions: either one) — every binding it could have touched is gone, none is moved
|
|
105
|
+
* onto another member's mention.
|
|
106
|
+
*/
|
|
107
|
+
export function shiftBindings(prev, next, bindings = [], range = null) {
|
|
108
|
+
const a0 = String(prev || ""), b0 = String(next || ""), list = Array.isArray(bindings) ? bindings : [];
|
|
109
|
+
if (a0 === b0) return list;
|
|
110
|
+
const d = b0.length - a0.length;
|
|
111
|
+
let lo, hi;
|
|
112
|
+
if (range) { lo = range.a; hi = range.b; } else {
|
|
113
|
+
// The earliest and the latest the edit can be: the longest common start first, and the longest common end first.
|
|
114
|
+
let p = 0; while (p < a0.length && p < b0.length && a0[p] === b0[p]) p++;
|
|
115
|
+
let q = 0; while (q < a0.length - p && q < b0.length - p && a0[a0.length - 1 - q] === b0[b0.length - 1 - q]) q++;
|
|
116
|
+
let q2 = 0; while (q2 < a0.length && q2 < b0.length && a0[a0.length - 1 - q2] === b0[b0.length - 1 - q2]) q2++;
|
|
117
|
+
let p2 = 0; while (p2 < a0.length - q2 && p2 < b0.length - q2 && a0[p2] === b0[p2]) p2++;
|
|
118
|
+
lo = Math.min(p, p2); hi = Math.max(a0.length - q, a0.length - q2);
|
|
119
|
+
}
|
|
120
|
+
return list.flatMap((x) => {
|
|
121
|
+
const end = x.start + 1 + x.name.length;
|
|
122
|
+
if (end <= lo) return [x];
|
|
123
|
+
if (x.start >= hi) return [{ ...x, start: x.start + d }];
|
|
124
|
+
return [];
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
/** The bindings still whole where they were put in `text`. */
|
|
128
|
+
export const intactBindings = (text, bindings = []) => (Array.isArray(bindings) ? bindings : [])
|
|
129
|
+
.filter((b) => b && typeof b.name === "string" && typeof b.id === "string" && Number.isInteger(b.start) && tokenAt(String(text || ""), b));
|
|
130
|
+
/**
|
|
131
|
+
* The mentions `text` sends: as read (mentionsIn), except that a name whose every `@name` is a bound mention sends the
|
|
132
|
+
* members bound — two agents called Notes, picked one each, send those two; one picked and one typed by hand reads as
|
|
133
|
+
* typed (both).
|
|
134
|
+
*/
|
|
135
|
+
export function boundMentions(text, detail, bindings = []) {
|
|
136
|
+
const s = String(text || ""), out = mentionsIn(s, detail), live = intactBindings(s, bindings);
|
|
137
|
+
if (!live.length) return out;
|
|
138
|
+
const byName = new Map();
|
|
139
|
+
for (const b of live) { const k = b.name.toLocaleLowerCase("en-US"); byName.set(k, [...(byName.get(k) || []), b]); }
|
|
140
|
+
let result = out;
|
|
141
|
+
for (const [k, list] of byName) {
|
|
142
|
+
const name = list[0].name, said = (s.match(atName(name, "g")) || []).length;
|
|
143
|
+
if (list.length < said) continue;
|
|
144
|
+
const same = new Set(agentsOf(detail).filter((a) => String(a.name).toLocaleLowerCase("en-US") === k).map((a) => a.id));
|
|
145
|
+
result = [...result.filter((id) => !same.has(id)), ...list.map((b) => b.id)];
|
|
146
|
+
}
|
|
147
|
+
return [...new Set(result)];
|
|
148
|
+
}
|
|
149
|
+
|
|
82
150
|
// M-3308: the paste helpers live with the Hub's files (hub-attachments.js), shared with the 1:1 question's composer (M-3311).
|
|
83
151
|
export { LONG_PASTE_CHARS, pastedFile } from "./hub-attachments.js";
|
|
84
152
|
|
|
@@ -105,6 +173,9 @@ export function refusalText(r) {
|
|
|
105
173
|
*/
|
|
106
174
|
export function RoomComposer({ store, detail, reply = null, onReply = () => {}, closed = false, inputRef, insertRef, attach = null, pending = null, canSendEmpty = false }) {
|
|
107
175
|
const [value, setValue] = useState(""), [msg, setMsg] = useState(null), [busy, setBusy] = useState(false), [pick, setPick] = useState(0);
|
|
176
|
+
// M-3533: the mentions put in the box for a member, where they were put; each edit moves or retires them by its own
|
|
177
|
+
// range (editRange: the selection when it began, the caret after), never by guessing from the text.
|
|
178
|
+
const bindings = useRef([]), edit = useRef({ input: null, key: null, ime: null, composing: false });
|
|
108
179
|
const own = useRef(null), input = inputRef || own;
|
|
109
180
|
const [caret, setCaret] = useState(0);
|
|
110
181
|
const at = mentionAt(value, caret), options = at ? mentionOptions(detail, at.query) : [];
|
|
@@ -113,10 +184,36 @@ export function RoomComposer({ store, detail, reply = null, onReply = () => {},
|
|
|
113
184
|
const short = useShortPlaceholder();
|
|
114
185
|
// M-3117: the Fleet chat's box takes the focus when its conversation opens (panel-chat.js Composer): a room's too.
|
|
115
186
|
useEffect(() => { if (!closed) input.current?.focus(); }, [room.id || "", closed]);
|
|
116
|
-
// 「在這裡 @ 它」 from the members panel: the mention goes into the box, after what is there
|
|
117
|
-
|
|
187
|
+
// 「在這裡 @ 它」 from the members panel or the office card: the mention goes into the box, after what is there, bound to
|
|
188
|
+
// the member it was picked for (`bind`: { name, id }; see boundMentions).
|
|
189
|
+
if (insertRef) insertRef.current = (text, bind = null) => {
|
|
190
|
+
setValue((v) => {
|
|
191
|
+
const base = v && !/\s$/.test(v) ? `${v} ` : v;
|
|
192
|
+
// Appended after everything: no mention already in the box moves; this one is bound where it is put.
|
|
193
|
+
if (bind) bindings.current = [...bindings.current, { ...bind, start: base.length + text.indexOf(`@${bind.name}`) }];
|
|
194
|
+
return `${base}${text} `;
|
|
195
|
+
});
|
|
196
|
+
setTimeout(() => input.current?.focus(), 0);
|
|
197
|
+
};
|
|
198
|
+
// Where the box's selection was when this edit began: the edit's own beforeinput (each one, so a caret moved since is
|
|
199
|
+
// never stale); an IME's, where its composition started (kept to its end: the text arrives once, at compositionend);
|
|
200
|
+
// the latest key's (each keydown, an arrow too, replaces it) only where no beforeinput came. Spent by each edit.
|
|
201
|
+
useEffect(() => {
|
|
202
|
+
const el = input.current;
|
|
203
|
+
if (!el?.addEventListener) return undefined;
|
|
204
|
+
const at = () => ({ start: el.selectionStart, end: el.selectionEnd });
|
|
205
|
+
const on = {
|
|
206
|
+
beforeinput: () => { if (!edit.current.composing) edit.current.input = at(); },
|
|
207
|
+
keydown: () => { edit.current.key = at(); },
|
|
208
|
+
compositionstart: () => { edit.current.composing = true; edit.current.ime = at(); },
|
|
209
|
+
compositionend: () => { edit.current.composing = false; },
|
|
210
|
+
};
|
|
211
|
+
for (const [k, fn] of Object.entries(on)) el.addEventListener(k, fn);
|
|
212
|
+
return () => { for (const [k, fn] of Object.entries(on)) el.removeEventListener(k, fn); };
|
|
213
|
+
}, [input.current]);
|
|
118
214
|
const complete = (o) => {
|
|
119
215
|
const next = `${value.slice(0, at.start)}${o.label} ${value.slice(caret)}`;
|
|
216
|
+
bindings.current = shiftBindings(value, next, bindings.current, { a: at.start, b: caret, c: at.start + o.label.length + 1 });
|
|
120
217
|
setValue(next); setPick(0);
|
|
121
218
|
setTimeout(() => { const el = input.current; if (el) { const n = at.start + o.label.length + 1; el.focus(); try { el.setSelectionRange(n, n); } catch { /* not a text field */ } setCaret(n); } }, 0);
|
|
122
219
|
};
|
|
@@ -124,9 +221,9 @@ export function RoomComposer({ store, detail, reply = null, onReply = () => {},
|
|
|
124
221
|
// M-3125: `canSendEmpty` — files are ready to go, so a post may be the files alone (the server takes it).
|
|
125
222
|
const text = value.trim(); if ((!text && !canSendEmpty) || busy || closed) return;
|
|
126
223
|
setBusy(true); setMsg(null);
|
|
127
|
-
const r = await store.send(text, { mentions:
|
|
224
|
+
const r = await store.send(text, { mentions: boundMentions(value, detail, bindings.current), ...(reply ? { replyTo: reply.roomMessage } : {}) });
|
|
128
225
|
setBusy(false);
|
|
129
|
-
if (r.ok) { setValue(""); onReply(null); } else setMsg({ text: refusalText(r), retry: !REFUSALS[r.code] });
|
|
226
|
+
if (r.ok) { setValue(""); bindings.current = []; onReply(null); } else setMsg({ text: refusalText(r), retry: !REFUSALS[r.code] });
|
|
130
227
|
};
|
|
131
228
|
const onKeyDown = (e) => {
|
|
132
229
|
if (palette && (e.key === "ArrowDown" || e.key === "ArrowUp")) { e.preventDefault(); setPick((i) => (i + (e.key === "ArrowDown" ? 1 : palette.length - 1)) % palette.length); return; }
|
|
@@ -135,7 +232,13 @@ export function RoomComposer({ store, detail, reply = null, onReply = () => {},
|
|
|
135
232
|
// Enter sends, Shift+Enter is a new line — the Fleet chat's own rule (and a phone's).
|
|
136
233
|
if (globalThis.AgendChatRender?.composerKey(e, { touch: touchScreen() }) === "send") { e.preventDefault(); void send(); }
|
|
137
234
|
};
|
|
138
|
-
const track = (v) => {
|
|
235
|
+
const track = (v) => {
|
|
236
|
+
const c = input.current ? input.current.selectionStart ?? v.length : v.length;
|
|
237
|
+
const e = edit.current, began = e.ime || e.input || e.key;
|
|
238
|
+
bindings.current = shiftBindings(value, v, bindings.current, editRange(value, v, began, c));
|
|
239
|
+
edit.current = { input: null, key: null, ime: null, composing: e.composing };
|
|
240
|
+
setValue(v); setMsg(null); setCaret(c);
|
|
241
|
+
};
|
|
139
242
|
// M-3308 (the user: a screenshot pasted with Ctrl+V did nothing in a room): the Fleet chat's paste, through the room's own
|
|
140
243
|
// Attach and its file rules (hub-attachments.js pasteToAttach). A room that takes no files keeps the text (as before).
|
|
141
244
|
const onPaste = (e) => { if (!closed) pasteToAttach(e, attach); };
|
|
@@ -5,8 +5,15 @@ import { register, t } from "/assets/app-i18n.js";
|
|
|
5
5
|
|
|
6
6
|
register("hubRoomMembers", {
|
|
7
7
|
en: { askOwner: "ask {0}", fewer: "Show fewer", ownerOf: "Owner: {0}", removeFailed: "It was not removed. Try again.", agents: "Agents", ownerAgent: "{0}'s agent", ownerAgentLatin: "{0}'s agent",
|
|
8
|
-
noAgents: "No agents yet. A room manager can add or invite them in Room settings."
|
|
8
|
+
noAgents: "No agents yet. A room manager can add or invite them in Room settings.",
|
|
9
|
+
// M-3533 M1: the compact list of a large room.
|
|
10
|
+
summary: "{0} people, {1} online · {2} agents of {3} owners", filter: "Filter: name or owner", filterLabel: "Filter members",
|
|
11
|
+
notOnline: "Not online · {0}", ownerGroup: "{0} · {1}", noOwner: "—", noMatch: "No members match.",
|
|
12
|
+
membersMatch: "Members · {0} of {1} match", agentsMatch: "Agents · {0} of {1} match" },
|
|
9
13
|
"zh-TW": { askOwner: "請通知 {0}", fewer: "收合", ownerOf: "擁有者:{0}", removeFailed: "沒有移除,請再試一次。", agents: "Agent", ownerAgent: "{0}的 Agent", ownerAgentLatin: "{0} 的 Agent",
|
|
10
|
-
noAgents: "還沒有 Agent。房間管理可以在房間設定加入或邀請。"
|
|
14
|
+
noAgents: "還沒有 Agent。房間管理可以在房間設定加入或邀請。",
|
|
15
|
+
summary: "{0} 人,{1} 人在線上 · {2} 個 Agent,{3} 位擁有者", filter: "篩選:名稱或擁有者", filterLabel: "篩選成員",
|
|
16
|
+
notOnline: "不在線上 · {0}", ownerGroup: "{0} · {1}", noOwner: "—", noMatch: "沒有符合的成員。",
|
|
17
|
+
membersMatch: "成員 · 符合 {0}/{1}", agentsMatch: "Agent · 符合 {0}/{1}" },
|
|
11
18
|
});
|
|
12
19
|
export const hm = (key, ...args) => t(`hubRoomMembers.${key}`, ...args);
|