@cortex-agent/server 2026.5.25 → 2026.6.15
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/defaults/config/thread-templates.json +28 -1
- package/defaults/hooks/cortex-md-injector.mjs +47 -31
- package/defaults/hooks/post-task-hook.mjs +6 -0
- package/defaults/hooks/task-status-check.mjs +8 -0
- package/defaults/mcp-config-slack.json +11 -0
- package/defaults/plugins/cortex-stage-gate/skills/task/SKILL.md +18 -0
- package/defaults/plugins/cortex-system/skills/schedule/SKILL.md +5 -6
- package/defaults/prompts/directives/manager.md +67 -0
- package/dist/agent-adapter/claude/adapter-tui.d.ts +35 -3
- package/dist/agent-adapter/claude/adapter-tui.js +91 -12
- package/dist/agent-adapter/claude/adapter.js +11 -0
- package/dist/agent-adapter/claude/defaults.d.ts +30 -0
- package/dist/agent-adapter/claude/defaults.js +30 -0
- package/dist/agent-adapter/claude/jsonl-tail.d.ts +2 -2
- package/dist/agent-adapter/claude/jsonl-tail.js +25 -20
- package/dist/agent-adapter/claude/spawn-args.d.ts +11 -0
- package/dist/agent-adapter/claude/spawn-args.js +49 -7
- package/dist/agent-adapter/claude/tmux-control.d.ts +20 -0
- package/dist/agent-adapter/claude/tmux-control.js +54 -8
- package/dist/agent-adapter/codex/adapter.js +1 -1
- package/dist/agent-adapter/normalize/event-types.d.ts +1 -0
- package/dist/agent-adapter/pi/adapter.js +46 -19
- package/dist/agent-adapter/pi/agent-dir.d.ts +21 -0
- package/dist/agent-adapter/pi/agent-dir.js +53 -2
- package/dist/agent-adapter/pi/event-parser.js +13 -1
- package/dist/agent-adapter/pi/mcp-bridge.d.ts +12 -0
- package/dist/agent-adapter/pi/mcp-bridge.js +47 -9
- package/dist/agent-adapter/pi/tool-shims.d.ts +14 -0
- package/dist/agent-adapter/pi/tool-shims.js +167 -140
- package/dist/agent-adapter/types.d.ts +7 -2
- package/dist/core/atomic-write.js +21 -0
- package/dist/core/config-generator.d.ts +10 -0
- package/dist/core/config-generator.js +28 -0
- package/dist/core/gateway-generator.d.ts +77 -7
- package/dist/core/gateway-generator.js +323 -30
- package/dist/core/i18n.d.ts +19 -0
- package/dist/core/i18n.js +46 -0
- package/dist/core/icons.d.ts +68 -0
- package/dist/core/icons.js +67 -0
- package/dist/core/locales/en.d.ts +438 -0
- package/dist/core/locales/en.js +24 -0
- package/dist/core/locales/slices/commands.d.ts +214 -0
- package/dist/core/locales/slices/commands.js +462 -0
- package/dist/core/locales/slices/init.d.ts +121 -0
- package/dist/core/locales/slices/init.js +380 -0
- package/dist/core/locales/slices/interactions.d.ts +47 -0
- package/dist/core/locales/slices/interactions.js +102 -0
- package/dist/core/locales/slices/lang.d.ts +8 -0
- package/dist/core/locales/slices/lang.js +18 -0
- package/dist/core/locales/slices/scheduling.d.ts +36 -0
- package/dist/core/locales/slices/scheduling.js +74 -0
- package/dist/core/locales/slices/startup.d.ts +6 -0
- package/dist/core/locales/slices/startup.js +14 -0
- package/dist/core/locales/slices/status.d.ts +20 -0
- package/dist/core/locales/slices/status.js +48 -0
- package/dist/core/locales/zh.d.ts +5 -0
- package/dist/core/locales/zh.js +23 -0
- package/dist/core/profile-generator.d.ts +6 -0
- package/dist/core/profile-generator.js +35 -7
- package/dist/core/running-executions.d.ts +51 -41
- package/dist/core/running-executions.js +120 -73
- package/dist/core/singleton-lock.d.ts +23 -0
- package/dist/core/singleton-lock.js +53 -0
- package/dist/core/status-format.js +4 -2
- package/dist/core/task-parser.d.ts +3 -0
- package/dist/core/task-parser.js +3 -1
- package/dist/core/types/thread-types.d.ts +54 -8
- package/dist/core/utils.d.ts +9 -1
- package/dist/core/utils.js +9 -1
- package/dist/domain/agents/config.d.ts +2 -1
- package/dist/domain/agents/config.js +25 -6
- package/dist/domain/agents/facade.d.ts +18 -0
- package/dist/domain/agents/facade.js +26 -3
- package/dist/domain/agents/profile-manager.d.ts +11 -0
- package/dist/domain/agents/profile-manager.js +21 -2
- package/dist/domain/costs/codex-usage-monitor.js +2 -1
- package/dist/domain/costs/rate-limit-throttle.js +14 -2
- package/dist/domain/executions/registry.d.ts +24 -0
- package/dist/domain/executions/registry.js +38 -0
- package/dist/domain/mcp/core-server.js +15 -3
- package/dist/domain/mcp/feishu/bitable.d.ts +3 -0
- package/dist/domain/mcp/feishu/bitable.js +168 -0
- package/dist/domain/mcp/feishu/block-types.d.ts +44 -0
- package/dist/domain/mcp/feishu/block-types.js +127 -0
- package/dist/domain/mcp/feishu/blocks-to-text.d.ts +19 -0
- package/dist/domain/mcp/feishu/blocks-to-text.js +43 -0
- package/dist/domain/mcp/feishu/client.d.ts +46 -0
- package/dist/domain/mcp/feishu/client.js +87 -0
- package/dist/domain/mcp/feishu/docx.d.ts +3 -0
- package/dist/domain/mcp/feishu/docx.js +163 -0
- package/dist/domain/mcp/feishu/drive.d.ts +23 -0
- package/dist/domain/mcp/feishu/drive.js +66 -0
- package/dist/domain/mcp/feishu/file.d.ts +14 -0
- package/dist/domain/mcp/feishu/file.js +107 -0
- package/dist/domain/mcp/feishu/index.d.ts +6 -0
- package/dist/domain/mcp/feishu/index.js +61 -0
- package/dist/domain/mcp/feishu/markdown-to-blocks.d.ts +40 -0
- package/dist/domain/mcp/feishu/markdown-to-blocks.js +191 -0
- package/dist/domain/mcp/feishu/sheets.d.ts +3 -0
- package/dist/domain/mcp/feishu/sheets.js +119 -0
- package/dist/domain/mcp/feishu/types.d.ts +26 -0
- package/dist/domain/mcp/feishu/types.js +38 -0
- package/dist/domain/mcp/feishu/user-auth.d.ts +140 -0
- package/dist/domain/mcp/feishu/user-auth.js +286 -0
- package/dist/domain/mcp/feishu/wiki.d.ts +3 -0
- package/dist/domain/mcp/feishu/wiki.js +77 -0
- package/dist/domain/mcp/feishu-server.d.ts +2 -0
- package/dist/domain/mcp/feishu-server.js +33 -0
- package/dist/domain/mcp/server.d.ts +0 -1
- package/dist/domain/mcp/server.js +6 -25
- package/dist/domain/mcp/slack-server.d.ts +3 -0
- package/dist/domain/mcp/slack-server.js +46 -0
- package/dist/domain/mcp/tools/context.js +1 -1
- package/dist/domain/mcp/tools/schedule.d.ts +1 -1
- package/dist/domain/mcp/tools/schedule.js +6 -20
- package/dist/domain/mcp/tools/slack.js +20 -7
- package/dist/domain/mcp/tools/thread-ops.d.ts +2 -0
- package/dist/domain/mcp/tools/thread-ops.js +121 -0
- package/dist/domain/mcp/tools/time.d.ts +2 -0
- package/dist/domain/mcp/tools/time.js +66 -0
- package/dist/domain/mcp/tools/tui-ask.js +1 -1
- package/dist/domain/mcp/tools/tui-plan.js +2 -2
- package/dist/domain/mcp/tui-server.js +1 -0
- package/dist/domain/monitor/disk-monitor.js +2 -1
- package/dist/domain/monitor/gpu-monitor.js +2 -1
- package/dist/domain/remote/client-hot-reload.js +3 -2
- package/dist/domain/remote/client-manager.js +8 -6
- package/dist/domain/scheduling/job-registry.d.ts +4 -0
- package/dist/domain/scheduling/job-registry.js +1 -0
- package/dist/domain/scheduling/jobs/_shared.js +2 -1
- package/dist/domain/scheduling/jobs/memory-index-regen.js +3 -2
- package/dist/domain/scheduling/jobs/scheduled-task.js +9 -23
- package/dist/domain/scheduling/jobs/sync-public.js +4 -3
- package/dist/domain/scheduling/jobs/target-dispatch.d.ts +1 -8
- package/dist/domain/scheduling/jobs/target-dispatch.js +0 -7
- package/dist/domain/scheduling/jobs/task-archive.js +3 -2
- package/dist/domain/scheduling/jobs/task-dispatch.js +126 -20
- package/dist/domain/scheduling/schedule-command.js +45 -43
- package/dist/domain/scheduling/scheduler.d.ts +1 -1
- package/dist/domain/scheduling/scheduler.js +2 -1
- package/dist/domain/sessions/session-hooks.d.ts +2 -2
- package/dist/domain/sessions/session-hooks.js +19 -18
- package/dist/domain/sessions/session-lifecycle.d.ts +38 -0
- package/dist/domain/sessions/session-lifecycle.js +44 -0
- package/dist/domain/system/github-release.d.ts +18 -0
- package/dist/domain/system/github-release.js +106 -0
- package/dist/domain/system/install-cli.d.ts +7 -0
- package/dist/domain/system/install-cli.js +106 -0
- package/dist/domain/system/preferences.d.ts +12 -0
- package/dist/domain/system/preferences.js +36 -0
- package/dist/domain/system/server-update-check.js +2 -2
- package/dist/domain/tasks/dispatch-utils.d.ts +58 -1
- package/dist/domain/tasks/dispatch-utils.js +53 -4
- package/dist/domain/tasks/dispatcher.d.ts +11 -2
- package/dist/domain/tasks/dispatcher.js +63 -7
- package/dist/domain/tasks/lint.js +28 -0
- package/dist/domain/tasks/mutator.d.ts +16 -3
- package/dist/domain/tasks/mutator.js +41 -12
- package/dist/domain/tasks/pending-tracker.js +6 -5
- package/dist/domain/tasks/system/task-cli.d.ts +2 -0
- package/dist/domain/tasks/system/task-cli.js +37 -6
- package/dist/domain/tasks/system/task-lifecycle-edit.js +6 -1
- package/dist/domain/tasks/system/task-mutations.d.ts +41 -3
- package/dist/domain/tasks/system/task-mutations.js +166 -8
- package/dist/domain/threads/contract.d.ts +17 -0
- package/dist/domain/threads/contract.js +59 -0
- package/dist/domain/threads/hook-runner.js +7 -6
- package/dist/domain/threads/index.d.ts +2 -0
- package/dist/domain/threads/index.js +3 -1
- package/dist/domain/threads/prompt-builder.d.ts +21 -1
- package/dist/domain/threads/prompt-builder.js +60 -4
- package/dist/domain/threads/runner.d.ts +6 -5
- package/dist/domain/threads/runner.js +128 -79
- package/dist/domain/threads/state-machine.d.ts +23 -21
- package/dist/domain/threads/state-machine.js +113 -54
- package/dist/domain/threads/template-loader.js +3 -2
- package/dist/domain/threads/tree.d.ts +45 -0
- package/dist/domain/threads/tree.js +171 -0
- package/dist/domain/tui-session/index.d.ts +2 -0
- package/dist/domain/tui-session/index.js +3 -0
- package/dist/domain/tui-session/tui-session-service.d.ts +2 -0
- package/dist/domain/tui-session/tui-session-service.js +103 -0
- package/dist/domain/tui-session/types.d.ts +67 -0
- package/dist/domain/tui-session/types.js +4 -0
- package/dist/domain/ui-service/index.d.ts +5 -0
- package/dist/domain/ui-service/index.js +3 -0
- package/dist/domain/ui-service/mutate/executions.d.ts +4 -0
- package/dist/domain/ui-service/mutate/executions.js +15 -0
- package/dist/domain/ui-service/mutate/schedules.d.ts +10 -0
- package/dist/domain/ui-service/mutate/schedules.js +39 -0
- package/dist/domain/ui-service/mutate/tasks.d.ts +23 -0
- package/dist/domain/ui-service/mutate/tasks.js +59 -0
- package/dist/domain/ui-service/mutate/threads.d.ts +4 -0
- package/dist/domain/ui-service/mutate/threads.js +21 -0
- package/dist/domain/ui-service/query/cost.d.ts +3 -0
- package/dist/domain/ui-service/query/cost.js +6 -0
- package/dist/domain/ui-service/query/executions.d.ts +2 -0
- package/dist/domain/ui-service/query/executions.js +35 -0
- package/dist/domain/ui-service/query/projects.d.ts +2 -0
- package/dist/domain/ui-service/query/projects.js +30 -0
- package/dist/domain/ui-service/query/schedules.d.ts +2 -0
- package/dist/domain/ui-service/query/schedules.js +23 -0
- package/dist/domain/ui-service/query/sessions.d.ts +2 -0
- package/dist/domain/ui-service/query/sessions.js +35 -0
- package/dist/domain/ui-service/query/tasks.d.ts +2 -0
- package/dist/domain/ui-service/query/tasks.js +30 -0
- package/dist/domain/ui-service/query/threads.d.ts +2 -0
- package/dist/domain/ui-service/query/threads.js +27 -0
- package/dist/domain/ui-service/subscribe.d.ts +5 -0
- package/dist/domain/ui-service/subscribe.js +118 -0
- package/dist/domain/ui-service/types.d.ts +237 -0
- package/dist/domain/ui-service/types.js +5 -0
- package/dist/domain/ui-service/ui-service.d.ts +2 -0
- package/dist/domain/ui-service/ui-service.js +83 -0
- package/dist/entry/app.js +130 -8
- package/dist/entry/cli.d.ts +12 -0
- package/dist/entry/cli.js +122 -12
- package/dist/entry/daemon.js +12 -30
- package/dist/entry/feishu-login.d.ts +28 -0
- package/dist/entry/feishu-login.js +218 -0
- package/dist/entry/init.d.ts +29 -5
- package/dist/entry/init.js +323 -233
- package/dist/entry/startup-notify.js +6 -3
- package/dist/events/event-types.d.ts +14 -0
- package/dist/hooks/cortex-md-injector.mjs +47 -31
- package/dist/hooks/post-task-hook.mjs +6 -0
- package/dist/hooks/task-status-check.mjs +8 -0
- package/dist/orchestration/agent-runner.d.ts +2 -1
- package/dist/orchestration/agent-runner.js +55 -55
- package/dist/orchestration/conduit-queue.d.ts +18 -0
- package/dist/orchestration/conduit-queue.js +32 -0
- package/dist/orchestration/conversation-runner.d.ts +48 -0
- package/dist/orchestration/conversation-runner.js +109 -0
- package/dist/orchestration/dispatch-reconciler.js +8 -1
- package/dist/orchestration/interactions/ask-user-question.d.ts +1 -1
- package/dist/orchestration/interactions/ask-user-question.js +3 -3
- package/dist/orchestration/interactions/interaction-handlers.js +55 -23
- package/dist/orchestration/interactions/plan-handler.d.ts +2 -2
- package/dist/orchestration/interactions/plan-handler.js +4 -3
- package/dist/orchestration/interactions/update-prompt-slack.js +11 -10
- package/dist/orchestration/interactions/update-prompt.d.ts +6 -0
- package/dist/orchestration/interactions/update-prompt.js +155 -0
- package/dist/orchestration/lifecycle.d.ts +4 -4
- package/dist/orchestration/lifecycle.js +25 -22
- package/dist/orchestration/orchestrator.d.ts +1 -1
- package/dist/orchestration/routing/commands/cancel.js +45 -52
- package/dist/orchestration/routing/commands/channel.js +41 -27
- package/dist/orchestration/routing/commands/cost.js +11 -2
- package/dist/orchestration/routing/commands/device.js +12 -9
- package/dist/orchestration/routing/commands/dispatch.js +11 -10
- package/dist/orchestration/routing/commands/index.d.ts +1 -1
- package/dist/orchestration/routing/commands/index.js +15 -10
- package/dist/orchestration/routing/commands/lang.d.ts +3 -0
- package/dist/orchestration/routing/commands/lang.js +31 -0
- package/dist/orchestration/routing/commands/mode.js +32 -30
- package/dist/orchestration/routing/commands/nvtop.js +15 -13
- package/dist/orchestration/routing/commands/orient.js +2 -1
- package/dist/orchestration/routing/commands/schedule.js +23 -22
- package/dist/orchestration/routing/commands/sendfile.js +9 -7
- package/dist/orchestration/routing/commands/session.d.ts +1 -1
- package/dist/orchestration/routing/commands/session.js +24 -39
- package/dist/orchestration/routing/commands/status.js +78 -71
- package/dist/orchestration/routing/commands/tail.js +7 -5
- package/dist/orchestration/routing/commands/task.js +25 -23
- package/dist/orchestration/routing/commands/thread-handlers.js +55 -44
- package/dist/orchestration/routing/edit-handler.js +8 -7
- package/dist/orchestration/routing/hook-bridge-subscribers.js +17 -1
- package/dist/orchestration/routing/message-router.d.ts +1 -1
- package/dist/orchestration/routing/message-router.js +9 -9
- package/dist/orchestration/routing/webhook.js +233 -2
- package/dist/orchestration/status-helpers.d.ts +5 -1
- package/dist/orchestration/status-helpers.js +13 -11
- package/dist/orchestration/thread-callback.d.ts +67 -0
- package/dist/orchestration/thread-callback.js +465 -0
- package/dist/orchestration/thread-executor.d.ts +22 -1
- package/dist/orchestration/thread-executor.js +85 -36
- package/dist/platform/adapter.d.ts +6 -2
- package/dist/platform/adapters/composite-adapter.d.ts +89 -0
- package/dist/platform/adapters/composite-adapter.js +318 -0
- package/dist/platform/adapters/feishu-output-stream.d.ts +26 -4
- package/dist/platform/adapters/feishu-output-stream.js +274 -36
- package/dist/platform/adapters/feishu.d.ts +50 -5
- package/dist/platform/adapters/feishu.js +370 -116
- package/dist/platform/adapters/index.d.ts +24 -3
- package/dist/platform/adapters/index.js +89 -11
- package/dist/platform/adapters/project-conduits.d.ts +9 -0
- package/dist/platform/adapters/project-conduits.js +42 -0
- package/dist/platform/adapters/slack-project-conduits.d.ts +1 -9
- package/dist/platform/adapters/slack-project-conduits.js +6 -40
- package/dist/platform/adapters/slack.d.ts +9 -2
- package/dist/platform/adapters/slack.js +83 -39
- package/dist/platform/adapters/tui/index.d.ts +9 -0
- package/dist/platform/adapters/tui/index.js +10 -0
- package/dist/platform/adapters/tui/ports.d.ts +20 -0
- package/dist/platform/adapters/tui/ports.js +4 -0
- package/dist/platform/adapters/tui/tui-conduit-state.d.ts +10 -0
- package/dist/platform/adapters/tui/tui-conduit-state.js +17 -0
- package/dist/platform/adapters/tui/tui-connection.d.ts +30 -0
- package/dist/platform/adapters/tui/tui-connection.js +53 -0
- package/dist/platform/adapters/tui/tui-gateway.d.ts +120 -0
- package/dist/platform/adapters/tui/tui-gateway.js +919 -0
- package/dist/platform/adapters/tui/tui-notifications.d.ts +12 -0
- package/dist/platform/adapters/tui/tui-notifications.js +60 -0
- package/dist/platform/adapters/tui/tui-output-stream.d.ts +36 -0
- package/dist/platform/adapters/tui/tui-output-stream.js +99 -0
- package/dist/platform/adapters/tui/tui-transcript.d.ts +8 -0
- package/dist/platform/adapters/tui/tui-transcript.js +56 -0
- package/dist/platform/index.d.ts +1 -0
- package/dist/platform/index.js +2 -1
- package/dist/platform/interactive-builder.js +21 -19
- package/dist/platform/output-stream.d.ts +5 -0
- package/dist/platform/testing.d.ts +7 -11
- package/dist/platform/testing.js +18 -15
- package/dist/platform/tool-trace.js +15 -5
- package/dist/platform/tui/protocol.d.ts +355 -0
- package/dist/platform/tui/protocol.js +199 -0
- package/dist/platform/types.d.ts +12 -3
- package/dist/store/execution-repo.d.ts +6 -1
- package/dist/store/execution-repo.js +13 -3
- package/dist/store/hook-sync.d.ts +18 -0
- package/dist/store/hook-sync.js +92 -0
- package/dist/store/outbound-queue.js +2 -2
- package/dist/store/profile-repo.js +3 -2
- package/dist/store/schedule-repo.d.ts +1 -8
- package/dist/store/session-registry-repo.d.ts +9 -1
- package/dist/store/session-registry-repo.js +19 -3
- package/dist/store/session-repo.d.ts +14 -0
- package/dist/store/session-repo.js +23 -0
- package/dist/store/thread-repo.d.ts +3 -0
- package/dist/store/thread-repo.js +49 -2
- package/dist/store/version-migrations.d.ts +7 -0
- package/dist/store/version-migrations.js +183 -0
- package/dist/tui/App.d.ts +27 -0
- package/dist/tui/App.js +219 -0
- package/dist/tui/components/AskUserModal.d.ts +11 -0
- package/dist/tui/components/AskUserModal.js +364 -0
- package/dist/tui/components/ConfirmModal.d.ts +12 -0
- package/dist/tui/components/ConfirmModal.js +31 -0
- package/dist/tui/components/Dashboard.d.ts +23 -0
- package/dist/tui/components/Dashboard.js +80 -0
- package/dist/tui/components/DashboardCostTab.d.ts +7 -0
- package/dist/tui/components/DashboardCostTab.js +16 -0
- package/dist/tui/components/DashboardExecutionsTab.d.ts +11 -0
- package/dist/tui/components/DashboardExecutionsTab.js +94 -0
- package/dist/tui/components/DashboardSchedulesTab.d.ts +11 -0
- package/dist/tui/components/DashboardSchedulesTab.js +124 -0
- package/dist/tui/components/DashboardTasksTab.d.ts +12 -0
- package/dist/tui/components/DashboardTasksTab.js +200 -0
- package/dist/tui/components/DashboardThreadsTab.d.ts +11 -0
- package/dist/tui/components/DashboardThreadsTab.js +81 -0
- package/dist/tui/components/Header.d.ts +11 -0
- package/dist/tui/components/Header.js +5 -0
- package/dist/tui/components/InputBox.d.ts +10 -0
- package/dist/tui/components/InputBox.js +19 -0
- package/dist/tui/components/MessageRow.d.ts +7 -0
- package/dist/tui/components/MessageRow.js +10 -0
- package/dist/tui/components/Notifications.d.ts +19 -0
- package/dist/tui/components/Notifications.js +72 -0
- package/dist/tui/components/PlanFeedbackModal.d.ts +11 -0
- package/dist/tui/components/PlanFeedbackModal.js +161 -0
- package/dist/tui/components/ProjectSwitcher.d.ts +18 -0
- package/dist/tui/components/ProjectSwitcher.js +43 -0
- package/dist/tui/components/SessionPicker.d.ts +14 -0
- package/dist/tui/components/SessionPicker.js +34 -0
- package/dist/tui/components/SidePanel.d.ts +19 -0
- package/dist/tui/components/SidePanel.js +8 -0
- package/dist/tui/components/StatusLine.d.ts +10 -0
- package/dist/tui/components/StatusLine.js +29 -0
- package/dist/tui/components/Transcript.d.ts +13 -0
- package/dist/tui/components/Transcript.js +56 -0
- package/dist/tui/hooks/useDashboardData.d.ts +32 -0
- package/dist/tui/hooks/useDashboardData.js +104 -0
- package/dist/tui/hooks/useKeybindings.d.ts +19 -0
- package/dist/tui/hooks/useKeybindings.js +87 -0
- package/dist/tui/hooks/useMutate.d.ts +22 -0
- package/dist/tui/hooks/useMutate.js +56 -0
- package/dist/tui/hooks/useNotifications.d.ts +28 -0
- package/dist/tui/hooks/useNotifications.js +70 -0
- package/dist/tui/hooks/useTranscript.d.ts +39 -0
- package/dist/tui/hooks/useTranscript.js +265 -0
- package/dist/tui/hooks/useWsClient.d.ts +29 -0
- package/dist/tui/hooks/useWsClient.js +69 -0
- package/dist/tui/index.d.ts +2 -0
- package/dist/tui/index.js +210 -0
- package/dist/tui/logic.d.ts +16 -0
- package/dist/tui/logic.js +49 -0
- package/dist/tui/render/markdown.d.ts +10 -0
- package/dist/tui/render/markdown.js +38 -0
- package/dist/tui/render/rich-blocks.d.ts +11 -0
- package/dist/tui/render/rich-blocks.js +24 -0
- package/dist/tui/ws-client.d.ts +44 -0
- package/dist/tui/ws-client.js +157 -0
- package/package.json +11 -3
- package/dist/orchestration/channel-queue.d.ts +0 -18
- package/dist/orchestration/channel-queue.js +0 -32
|
@@ -3,34 +3,35 @@
|
|
|
3
3
|
// pos: !dispatch <threadId> [--profile <name>]
|
|
4
4
|
import { threadStore } from '../../../store/thread-repo.js';
|
|
5
5
|
import { resolveProfile } from '../../../domain/agents/profile-manager.js';
|
|
6
|
-
|
|
6
|
+
import { Icons } from '../../../core/icons.js';
|
|
7
|
+
import { t } from '../../../core/i18n.js';
|
|
7
8
|
export async function handleDispatchCmd(channel, adapter, trimmedMessage) {
|
|
8
9
|
const dest = { type: 'interactive-reply', conduit: channel, sessionId: '' };
|
|
9
10
|
const args = trimmedMessage.split(/\s+/).slice(1);
|
|
10
11
|
if (args.length === 0) {
|
|
11
|
-
await adapter.postMessage(dest, { text:
|
|
12
|
+
await adapter.postMessage(dest, { text: t('cmd.dispatch.usage') });
|
|
12
13
|
return;
|
|
13
14
|
}
|
|
14
15
|
const threadId = args[0];
|
|
15
16
|
const thread = threadStore.get(threadId);
|
|
16
17
|
if (!thread) {
|
|
17
|
-
await adapter.postMessage(dest, { text:
|
|
18
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.dispatch.threadNotFound', { threadId })}` });
|
|
18
19
|
return;
|
|
19
20
|
}
|
|
20
21
|
if (thread.metadata?.trigger !== 'task-dispatch') {
|
|
21
|
-
await adapter.postMessage(dest, { text:
|
|
22
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.dispatch.notDispatchThread', { threadId })}` });
|
|
22
23
|
return;
|
|
23
24
|
}
|
|
24
25
|
if (thread.status === 'completed' || thread.status === 'failed' || thread.status === 'cancelled' || thread.status === 'aborted') {
|
|
25
26
|
await adapter.postMessage(dest, {
|
|
26
|
-
text:
|
|
27
|
+
text: `${Icons.warning} ${t('cmd.dispatch.terminalWarning', { threadId: threadId.substring(0, 12), status: thread.status })}`,
|
|
27
28
|
});
|
|
28
29
|
// Allow the change to go through even for completed threads — it takes effect if continued.
|
|
29
30
|
}
|
|
30
31
|
const profileIdx = args.indexOf('--profile');
|
|
31
32
|
if (profileIdx === -1 || profileIdx + 1 >= args.length) {
|
|
32
33
|
const current = thread.metadata?.profileOverride || '(not set)';
|
|
33
|
-
await adapter.postMessage(dest, { text:
|
|
34
|
+
await adapter.postMessage(dest, { text: `${t('cmd.dispatch.currentOverride', { threadId: threadId.substring(0, 12), current })}\n${t('cmd.dispatch.usage')}` });
|
|
34
35
|
return;
|
|
35
36
|
}
|
|
36
37
|
const profileName = args[profileIdx + 1];
|
|
@@ -38,13 +39,13 @@ export async function handleDispatchCmd(channel, adapter, trimmedMessage) {
|
|
|
38
39
|
resolveProfile(profileName);
|
|
39
40
|
}
|
|
40
41
|
catch {
|
|
41
|
-
await adapter.postMessage(dest, { text:
|
|
42
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.dispatch.unknownProfile', { profile: profileName })}` });
|
|
42
43
|
return;
|
|
43
44
|
}
|
|
44
|
-
await threadStore.mutate(threadId, (
|
|
45
|
-
|
|
45
|
+
await threadStore.mutate(threadId, (th) => {
|
|
46
|
+
th.metadata = { ...th.metadata, profileOverride: profileName };
|
|
46
47
|
});
|
|
47
48
|
await adapter.postMessage(dest, {
|
|
48
|
-
text:
|
|
49
|
+
text: `${Icons.ok} ${t('cmd.dispatch.overrideSet', { threadId: threadId.substring(0, 12), profile: profileName })}`,
|
|
49
50
|
});
|
|
50
51
|
}
|
|
@@ -12,4 +12,4 @@ export interface CommandDeps {
|
|
|
12
12
|
getExecutionStatusReport?: (() => string) | null;
|
|
13
13
|
commandRouter?: CommandActionRouter;
|
|
14
14
|
}
|
|
15
|
-
export declare function registerCommands(deps: CommandDeps): (trimmedMessage: string | undefined, channel: string, adapter: PlatformAdapter,
|
|
15
|
+
export declare function registerCommands(deps: CommandDeps): (trimmedMessage: string | undefined, channel: string, adapter: PlatformAdapter, threadAnchorId?: string | null) => boolean;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { createLogger } from '../../../core/log.js';
|
|
2
|
+
import { Icons } from '../../../core/icons.js';
|
|
3
|
+
import { t } from '../../../core/i18n.js';
|
|
2
4
|
import { handleOrientCmd } from './orient.js';
|
|
3
5
|
import { handleThreadCmd } from './thread.js';
|
|
4
6
|
import { createScheduleHandler } from './schedule.js';
|
|
@@ -14,14 +16,15 @@ import { createDevicesHandler } from './device.js';
|
|
|
14
16
|
import { handleTailCmd } from './tail.js';
|
|
15
17
|
import { handleSendFileCmd } from './sendfile.js';
|
|
16
18
|
import { handleDispatchCmd } from './dispatch.js';
|
|
19
|
+
import { handleLangCmd } from './lang.js';
|
|
17
20
|
const log = createLogger('command-handler');
|
|
18
21
|
/**
|
|
19
22
|
* Execute a command handler and handle its return.
|
|
20
23
|
* - If handler returns CommandResult (with `text`), dispatch layer delivers the message.
|
|
21
24
|
* - If handler returns void, it already posted its own response (backward compat).
|
|
22
25
|
*/
|
|
23
|
-
async function executeCommand(handler, channel, adapter, trimmedMessage, _commandName,
|
|
24
|
-
const result = await handler(channel, adapter, trimmedMessage,
|
|
26
|
+
async function executeCommand(handler, channel, adapter, trimmedMessage, _commandName, threadAnchorId) {
|
|
27
|
+
const result = await handler(channel, adapter, trimmedMessage, threadAnchorId);
|
|
25
28
|
const cmdDest = { type: 'interactive-reply', conduit: channel, sessionId: '' };
|
|
26
29
|
if (result && typeof result === 'object' && 'text' in result) {
|
|
27
30
|
if (result.actions && result.actions.length > 0) {
|
|
@@ -45,13 +48,13 @@ async function executeCommand(handler, channel, adapter, trimmedMessage, _comman
|
|
|
45
48
|
}
|
|
46
49
|
}
|
|
47
50
|
}
|
|
48
|
-
const catchHandlerError = (promise, cmd, channel, adapter,
|
|
51
|
+
const catchHandlerError = (promise, cmd, channel, adapter, threadAnchorId) => {
|
|
49
52
|
Promise.resolve(promise).catch(err => {
|
|
50
53
|
log.error(`Error in ${cmd}:`, err?.message || err);
|
|
51
54
|
if (err?.data)
|
|
52
55
|
log.error(`Slack error data:`, JSON.stringify(err.data));
|
|
53
56
|
const cmdDest = { type: 'interactive-reply', conduit: channel, sessionId: '' };
|
|
54
|
-
adapter.postMessage(cmdDest, { text:
|
|
57
|
+
adapter.postMessage(cmdDest, { text: `${Icons.error} ${t('cmd.error', { error: err?.message || t('cmd.errorUnknown') })}` }).catch(() => { });
|
|
55
58
|
});
|
|
56
59
|
};
|
|
57
60
|
export function registerCommands(deps) {
|
|
@@ -69,8 +72,8 @@ export function registerCommands(deps) {
|
|
|
69
72
|
const handleScheduleCmd = createScheduleHandler(deps.scheduler, router);
|
|
70
73
|
const EXACT_COMMANDS = {
|
|
71
74
|
'!help': (ch, ad, _msg) => handleHelpCmd(ch, ad),
|
|
72
|
-
'!new': (ch, ad, _msg,
|
|
73
|
-
'!newq': (ch, ad, _msg,
|
|
75
|
+
'!new': (ch, ad, _msg, threadAnchorId) => handleNewCmd(ch, ad, {}, threadAnchorId),
|
|
76
|
+
'!newq': (ch, ad, _msg, threadAnchorId) => handleNewCmd(ch, ad, { skipHook: true }, threadAnchorId),
|
|
74
77
|
'!cancel': (ch, ad, msg) => handleCancelCmd(ch, ad, msg),
|
|
75
78
|
'!mode': (ch, ad, _msg) => handleModeCmd(ch, ad),
|
|
76
79
|
'!skills': (ch, ad, _msg) => handleSkillsCmd(ch, ad),
|
|
@@ -83,6 +86,7 @@ export function registerCommands(deps) {
|
|
|
83
86
|
'!thread': (ch, ad, msg) => handleThreadCmd(ch, ad, msg),
|
|
84
87
|
'!agent': (ch, ad, msg) => handleAgentCmdInteractive(ch, ad, msg),
|
|
85
88
|
'!orient': (ch, ad, _msg) => handleOrientCmd(ch, ad),
|
|
89
|
+
'!lang': (ch, ad, msg) => handleLangCmd(ch, ad, msg),
|
|
86
90
|
};
|
|
87
91
|
const PREFIX_COMMANDS = [
|
|
88
92
|
{ prefix: '!cancel', handler: handleCancelCmd },
|
|
@@ -104,25 +108,26 @@ export function registerCommands(deps) {
|
|
|
104
108
|
{ prefix: '!agent', handler: handleAgentCmdInteractive },
|
|
105
109
|
{ prefix: '!sendFile', handler: handleSendFileCmd },
|
|
106
110
|
{ prefix: '!dispatch', handler: handleDispatchCmd },
|
|
111
|
+
{ prefix: '!lang', handler: handleLangCmd },
|
|
107
112
|
];
|
|
108
|
-
const dispatchFn = function dispatchCommand(trimmedMessage, channel, adapter,
|
|
113
|
+
const dispatchFn = function dispatchCommand(trimmedMessage, channel, adapter, threadAnchorId) {
|
|
109
114
|
if (!trimmedMessage)
|
|
110
115
|
return false;
|
|
111
116
|
const exact = EXACT_COMMANDS[trimmedMessage];
|
|
112
117
|
if (exact) {
|
|
113
|
-
catchHandlerError(executeCommand(exact, channel, adapter, trimmedMessage, trimmedMessage,
|
|
118
|
+
catchHandlerError(executeCommand(exact, channel, adapter, trimmedMessage, trimmedMessage, threadAnchorId), trimmedMessage, channel, adapter, threadAnchorId);
|
|
114
119
|
return true;
|
|
115
120
|
}
|
|
116
121
|
for (const { prefix, handler } of PREFIX_COMMANDS) {
|
|
117
122
|
if (trimmedMessage.startsWith(prefix)) {
|
|
118
|
-
catchHandlerError(executeCommand(handler, channel, adapter, trimmedMessage, prefix,
|
|
123
|
+
catchHandlerError(executeCommand(handler, channel, adapter, trimmedMessage, prefix, threadAnchorId), prefix, channel, adapter, threadAnchorId);
|
|
119
124
|
return true;
|
|
120
125
|
}
|
|
121
126
|
}
|
|
122
127
|
if (trimmedMessage.startsWith('!')) {
|
|
123
128
|
const cmd = trimmedMessage.split(/\s+/)[0];
|
|
124
129
|
const cmdDest = { type: 'interactive-reply', conduit: channel, sessionId: '' };
|
|
125
|
-
adapter.postMessage(cmdDest, { text:
|
|
130
|
+
adapter.postMessage(cmdDest, { text: `${Icons.error} ${t('cmd.unknown', { cmd })}` });
|
|
126
131
|
return true;
|
|
127
132
|
}
|
|
128
133
|
return false;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// input: core/i18n (t/setLocale/getLocale), domain/system/preferences (setLang)
|
|
2
|
+
// output: handleLangCmd — !lang [en|zh] show/switch handler
|
|
3
|
+
// pos: !lang command. Persists to config/preferences.json AND switches the live locale
|
|
4
|
+
// (no restart). Registered in commands/index.ts.
|
|
5
|
+
// >>> If I am updated, update my header comment and the parent folder's CORTEX.md <<<
|
|
6
|
+
import { Icons } from '../../../core/icons.js';
|
|
7
|
+
import { t, setLocale, getLocale } from '../../../core/i18n.js';
|
|
8
|
+
import { setLang } from '../../../domain/system/preferences.js';
|
|
9
|
+
/** Human labels for the confirmation text (shown regardless of active locale). */
|
|
10
|
+
const LANG_LABELS = { en: 'English', zh: '中文' };
|
|
11
|
+
export async function handleLangCmd(_channel, _adapter, trimmedMessage) {
|
|
12
|
+
const arg = (trimmedMessage.split(/\s+/)[1] || '').trim().toLowerCase();
|
|
13
|
+
// No argument → show current language, the available set, and usage.
|
|
14
|
+
if (!arg) {
|
|
15
|
+
const cur = getLocale();
|
|
16
|
+
return {
|
|
17
|
+
text: [
|
|
18
|
+
t('lang.current', { lang: LANG_LABELS[cur] }),
|
|
19
|
+
t('lang.available'),
|
|
20
|
+
t('lang.usage'),
|
|
21
|
+
].join('\n'),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
if (arg !== 'en' && arg !== 'zh') {
|
|
25
|
+
return { text: `${Icons.error} ${t('lang.unknown', { lang: arg })}` };
|
|
26
|
+
}
|
|
27
|
+
const loc = arg;
|
|
28
|
+
setLang(loc); // persist to preferences.json
|
|
29
|
+
setLocale(loc); // live switch — subsequent t() calls render in the new locale
|
|
30
|
+
return { text: `${Icons.ok} ${t('lang.switched', { lang: LANG_LABELS[loc] })}` };
|
|
31
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Icons } from '../../../core/icons.js';
|
|
2
|
+
import { t } from '../../../core/i18n.js';
|
|
1
3
|
import { switchMode, getActiveBackend, setActiveBackend, getClaudeModel, setClaudeModel, getActiveProfile, setActiveProfile, clearChannelProfile, getDefaultAgent, setDefaultAgent } from '../../../domain/agents/index.js';
|
|
2
4
|
import { getDefaultProfileName, listProfiles, resolveProfile } from '../../../domain/agents/profile-manager.js';
|
|
3
5
|
import { getDisplaySkillGroups } from '../../../domain/memory/skill-scanner.js';
|
|
@@ -10,11 +12,11 @@ function formatProfileList(channel) {
|
|
|
10
12
|
return listProfiles().map(profile => {
|
|
11
13
|
const markers = [];
|
|
12
14
|
if (profile.name === defaultName)
|
|
13
|
-
markers.push('
|
|
15
|
+
markers.push(t('cmd.profile.markerDefault'));
|
|
14
16
|
if (profile.name === (globalActive || defaultName))
|
|
15
|
-
markers.push('
|
|
17
|
+
markers.push(t('cmd.profile.markerGlobal'));
|
|
16
18
|
if (channel && channelActive !== globalActive && profile.name === channelActive)
|
|
17
|
-
markers.push('
|
|
19
|
+
markers.push(t('cmd.profile.markerChannel'));
|
|
18
20
|
const suffix = markers.length ? ` (${markers.join(', ')})` : '';
|
|
19
21
|
const backend = profile.backend || 'claude';
|
|
20
22
|
const mode = profile.mode || '-';
|
|
@@ -24,7 +26,7 @@ function formatProfileList(channel) {
|
|
|
24
26
|
export async function handleModeCmd(channel, adapter) {
|
|
25
27
|
const { newMode } = switchMode();
|
|
26
28
|
const dest = { type: 'interactive-reply', conduit: channel, sessionId: '' };
|
|
27
|
-
await adapter.postMessage(dest, { text:
|
|
29
|
+
await adapter.postMessage(dest, { text: `${Icons.refresh} ${t('cmd.mode.switched', { mode: newMode === 'api' ? t('cmd.mode.apiLabel') : t('cmd.mode.planLabel') })}` });
|
|
28
30
|
}
|
|
29
31
|
export async function handleBackendCmd(channel, adapter, trimmedMessage) {
|
|
30
32
|
const arg = trimmedMessage.split(/\s+/)[1];
|
|
@@ -32,23 +34,23 @@ export async function handleBackendCmd(channel, adapter, trimmedMessage) {
|
|
|
32
34
|
setActiveBackend(newBackend);
|
|
33
35
|
const dest = { type: 'interactive-reply', conduit: channel, sessionId: '' };
|
|
34
36
|
await adapter.postMessage(dest, {
|
|
35
|
-
text:
|
|
37
|
+
text: `${Icons.refresh} ${t('cmd.backend.switched', { backend: newBackend === 'claude' ? t('cmd.backend.claudeLabel') : t('cmd.backend.codexLabel') })}`,
|
|
36
38
|
});
|
|
37
39
|
}
|
|
38
40
|
export async function handleModelCmd(channel, adapter, trimmedMessage) {
|
|
39
41
|
const args = trimmedMessage.split(/\s+/).slice(1);
|
|
40
42
|
const dest = { type: 'interactive-reply', conduit: channel, sessionId: '' };
|
|
41
43
|
if (args.length === 0) {
|
|
42
|
-
await adapter.postMessage(dest, { text:
|
|
44
|
+
await adapter.postMessage(dest, { text: t('cmd.model.current', { model: getClaudeModel() }) });
|
|
43
45
|
return;
|
|
44
46
|
}
|
|
45
47
|
const model = args.join(' ').trim();
|
|
46
48
|
if (!model) {
|
|
47
|
-
await adapter.postMessage(dest, { text: '
|
|
49
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.model.usage')}` });
|
|
48
50
|
return;
|
|
49
51
|
}
|
|
50
52
|
setClaudeModel(model);
|
|
51
|
-
await adapter.postMessage(dest, { text:
|
|
53
|
+
await adapter.postMessage(dest, { text: `${Icons.ok} ${t('cmd.model.set', { model: getClaudeModel() })}` });
|
|
52
54
|
}
|
|
53
55
|
const MAX_PROFILE_BUTTONS = 10;
|
|
54
56
|
function buildProfileText(channel) {
|
|
@@ -56,8 +58,8 @@ function buildProfileText(channel) {
|
|
|
56
58
|
const globalProfile = getActiveProfile() || getDefaultProfileName();
|
|
57
59
|
const isOverridden = channel && effective !== globalProfile;
|
|
58
60
|
const header = isOverridden
|
|
59
|
-
?
|
|
60
|
-
:
|
|
61
|
+
? t('cmd.profile.channelHeader', { effective, global: globalProfile })
|
|
62
|
+
: t('cmd.profile.activeHeader', { effective });
|
|
61
63
|
return `${header}\n${formatProfileList(channel)}`;
|
|
62
64
|
}
|
|
63
65
|
function buildProfileButtons(channel) {
|
|
@@ -79,7 +81,7 @@ export function createProfileHandler(router) {
|
|
|
79
81
|
const { name, channel } = JSON.parse(ctx.value);
|
|
80
82
|
resolveProfile(name);
|
|
81
83
|
setActiveProfile(name, channel);
|
|
82
|
-
const text =
|
|
84
|
+
const text = `${Icons.ok} ${t('cmd.profile.channelSet', { name })}\n${formatProfileList(channel)}`;
|
|
83
85
|
if (ctx.messageRef) {
|
|
84
86
|
await adapter.updateMessage(ctx.messageRef, {
|
|
85
87
|
text,
|
|
@@ -94,7 +96,7 @@ export function createProfileHandler(router) {
|
|
|
94
96
|
catch (error) {
|
|
95
97
|
if (ctx.messageRef) {
|
|
96
98
|
await adapter.updateMessage(ctx.messageRef, {
|
|
97
|
-
text:
|
|
99
|
+
text: `${Icons.error} ${error.message}`,
|
|
98
100
|
}).catch(() => { });
|
|
99
101
|
}
|
|
100
102
|
}
|
|
@@ -113,24 +115,24 @@ export function createProfileHandler(router) {
|
|
|
113
115
|
if (args[0] === 'reset') {
|
|
114
116
|
clearChannelProfile(channel);
|
|
115
117
|
const fallback = getActiveProfile() || getDefaultProfileName();
|
|
116
|
-
await adapter.postMessage(dest, { text:
|
|
118
|
+
await adapter.postMessage(dest, { text: `${Icons.ok} ${t('cmd.profile.cleared', { name: fallback })}` });
|
|
117
119
|
await handleNewCmd(channel, adapter, { skipHook: true });
|
|
118
120
|
return;
|
|
119
121
|
}
|
|
120
122
|
if (args[0] === 'global') {
|
|
121
123
|
if (args.length < 2) {
|
|
122
|
-
await adapter.postMessage(dest, { text: '
|
|
124
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.profile.globalUsage')}` });
|
|
123
125
|
return;
|
|
124
126
|
}
|
|
125
127
|
const profileName = args[1];
|
|
126
128
|
try {
|
|
127
129
|
resolveProfile(profileName);
|
|
128
130
|
setActiveProfile(profileName);
|
|
129
|
-
await adapter.postMessage(dest, { text:
|
|
131
|
+
await adapter.postMessage(dest, { text: `${Icons.ok} ${t('cmd.profile.globalSet', { name: profileName })}\n${formatProfileList(channel)}` });
|
|
130
132
|
await handleNewCmd(channel, adapter, { skipHook: true });
|
|
131
133
|
}
|
|
132
134
|
catch (error) {
|
|
133
|
-
await adapter.postMessage(dest, { text:
|
|
135
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${error.message}` });
|
|
134
136
|
}
|
|
135
137
|
return;
|
|
136
138
|
}
|
|
@@ -138,11 +140,11 @@ export function createProfileHandler(router) {
|
|
|
138
140
|
try {
|
|
139
141
|
resolveProfile(profileName);
|
|
140
142
|
setActiveProfile(profileName, channel);
|
|
141
|
-
await adapter.postMessage(dest, { text:
|
|
143
|
+
await adapter.postMessage(dest, { text: `${Icons.ok} ${t('cmd.profile.channelSet', { name: profileName })}\n${formatProfileList(channel)}` });
|
|
142
144
|
await handleNewCmd(channel, adapter, { skipHook: true });
|
|
143
145
|
}
|
|
144
146
|
catch (error) {
|
|
145
|
-
await adapter.postMessage(dest, { text:
|
|
147
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${error.message}` });
|
|
146
148
|
}
|
|
147
149
|
return;
|
|
148
150
|
}
|
|
@@ -167,12 +169,12 @@ export async function handleSkillsCmd(channel, adapter) {
|
|
|
167
169
|
const groups = getDisplaySkillGroups();
|
|
168
170
|
const dest = { type: 'interactive-reply', conduit: channel, sessionId: '' };
|
|
169
171
|
if (groups.length === 0) {
|
|
170
|
-
await adapter.postMessage(dest, { text: '
|
|
172
|
+
await adapter.postMessage(dest, { text: t('cmd.skills.none') });
|
|
171
173
|
return;
|
|
172
174
|
}
|
|
173
|
-
const lines = ['
|
|
175
|
+
const lines = [t('cmd.skills.header')];
|
|
174
176
|
for (const { plugin, skills } of groups) {
|
|
175
|
-
lines.push(plugin ? `_${plugin}_` : '
|
|
177
|
+
lines.push(plugin ? `_${plugin}_` : `_${t('cmd.skills.localGroup')}_`);
|
|
176
178
|
for (const skill of skills) {
|
|
177
179
|
lines.push(`• \`${skill}\``);
|
|
178
180
|
}
|
|
@@ -187,9 +189,9 @@ function buildAgentText() {
|
|
|
187
189
|
const agentDef = getAgent(current);
|
|
188
190
|
const profile = agentDef?.profile || '?';
|
|
189
191
|
const claudeAgentStr = agentDef?.claudeAgent ? ` · agent:${agentDef.claudeAgent}` : '';
|
|
190
|
-
return
|
|
192
|
+
return t('cmd.agent.current', { name: current, detail: `${profile}${claudeAgentStr}` });
|
|
191
193
|
}
|
|
192
|
-
return '
|
|
194
|
+
return t('cmd.agent.none', { agents: agents.map(a => `\`${a.name}\``).join(', ') });
|
|
193
195
|
}
|
|
194
196
|
function buildAgentButtons() {
|
|
195
197
|
const agents = listAgents();
|
|
@@ -201,7 +203,7 @@ function buildAgentButtons() {
|
|
|
201
203
|
}));
|
|
202
204
|
buttons.push({
|
|
203
205
|
type: 'button',
|
|
204
|
-
text: '
|
|
206
|
+
text: t('cmd.agent.disableButton'),
|
|
205
207
|
actionId: 'cmd:agent:disable',
|
|
206
208
|
value: 'off',
|
|
207
209
|
style: 'danger',
|
|
@@ -220,7 +222,7 @@ export function createAgentHandler(router) {
|
|
|
220
222
|
return;
|
|
221
223
|
setDefaultAgent(name);
|
|
222
224
|
const claudeAgentStr = agentDef.claudeAgent ? ` · agent:${agentDef.claudeAgent}` : '';
|
|
223
|
-
const text =
|
|
225
|
+
const text = `${Icons.ok} ${t('cmd.agent.defaultSet', { name, detail: `${agentDef.profile}${claudeAgentStr}` })}`;
|
|
224
226
|
if (ctx.messageRef) {
|
|
225
227
|
await adapter.updateMessage(ctx.messageRef, {
|
|
226
228
|
text,
|
|
@@ -238,9 +240,9 @@ export function createAgentHandler(router) {
|
|
|
238
240
|
setDefaultAgent(null);
|
|
239
241
|
if (ctx.messageRef) {
|
|
240
242
|
await adapter.updateMessage(ctx.messageRef, {
|
|
241
|
-
text: '
|
|
243
|
+
text: `${Icons.ok} ${t('cmd.agent.disabled')}`,
|
|
242
244
|
richBlocks: [
|
|
243
|
-
{ type: 'section', text: '
|
|
245
|
+
{ type: 'section', text: `${Icons.ok} ${t('cmd.agent.disabled')}` },
|
|
244
246
|
{ type: 'actions', elements: buildAgentButtons() },
|
|
245
247
|
],
|
|
246
248
|
}).catch(() => { });
|
|
@@ -263,18 +265,18 @@ export function createAgentHandler(router) {
|
|
|
263
265
|
const name = args.split(/\s+/)[0];
|
|
264
266
|
if (name === 'off' || name === 'none' || name === 'disable') {
|
|
265
267
|
setDefaultAgent(null);
|
|
266
|
-
await adapter.postMessage(dest, { text: '
|
|
268
|
+
await adapter.postMessage(dest, { text: `${Icons.ok} ${t('cmd.agent.disabled')}` });
|
|
267
269
|
return;
|
|
268
270
|
}
|
|
269
271
|
const agentDef = getAgent(name);
|
|
270
272
|
if (!agentDef) {
|
|
271
273
|
const available = listAgents().map(a => `\`${a.name}\``).join(', ');
|
|
272
|
-
await adapter.postMessage(dest, { text:
|
|
274
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.agent.unknown', { name, available })}` });
|
|
273
275
|
return;
|
|
274
276
|
}
|
|
275
277
|
setDefaultAgent(name);
|
|
276
278
|
const claudeAgentStr = agentDef.claudeAgent ? ` · agent:${agentDef.claudeAgent}` : '';
|
|
277
|
-
await adapter.postMessage(dest, { text:
|
|
279
|
+
await adapter.postMessage(dest, { text: `${Icons.ok} ${t('cmd.agent.defaultSet', { name, detail: `${agentDef.profile}${claudeAgentStr}` })}` });
|
|
278
280
|
return;
|
|
279
281
|
}
|
|
280
282
|
const text = buildAgentText();
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { queryGpuSnapshot, renderGpuSnapshot } from '../../../domain/monitor/gpu-monitor.js';
|
|
2
2
|
import { getMachineRegistry, getLocalMachine } from '../../../domain/tasks/dispatch-utils.js';
|
|
3
3
|
import { sendCommand, isDeviceOnline } from '../../../domain/remote/client-manager.js';
|
|
4
|
+
import { Icons } from '../../../core/icons.js';
|
|
5
|
+
import { t } from '../../../core/i18n.js';
|
|
4
6
|
const NVTOP_REFRESH_MS = 1000;
|
|
5
7
|
const NVTOP_HISTORY_LIMIT = 12;
|
|
6
8
|
const activeNvtopMonitors = new Map();
|
|
@@ -20,7 +22,7 @@ async function updateNvtopMessage(channel, adapter) {
|
|
|
20
22
|
const snapshot = await queryGpuSnapshot(active.machine);
|
|
21
23
|
rememberGpuHistory(active.historyByGpu, snapshot);
|
|
22
24
|
const text = renderGpuSnapshot(snapshot, active.historyByGpu, NVTOP_REFRESH_MS / 1000);
|
|
23
|
-
await adapter.updateMessage({ channel, messageId: active.trackingTs }, { text });
|
|
25
|
+
await adapter.updateMessage({ conduit: channel, messageId: active.trackingTs }, { text });
|
|
24
26
|
}
|
|
25
27
|
export async function handleNvidiaSmiCmd(channel, adapter, trimmedMessage) {
|
|
26
28
|
const args = trimmedMessage.split(/\s+/).slice(1);
|
|
@@ -29,24 +31,24 @@ export async function handleNvidiaSmiCmd(channel, adapter, trimmedMessage) {
|
|
|
29
31
|
const reg = getMachineRegistry()[machine];
|
|
30
32
|
if (!reg) {
|
|
31
33
|
const valid = Object.keys(getMachineRegistry()).filter(m => getMachineRegistry()[m].gpuCount > 0).map(m => `\`${m}\``).join(', ');
|
|
32
|
-
await adapter.postMessage(dest, { text:
|
|
34
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.nvtop.unknownMachineGpu', { machine, valid })}` });
|
|
33
35
|
return;
|
|
34
36
|
}
|
|
35
37
|
if (reg.gpuCount === 0) {
|
|
36
|
-
await adapter.postMessage(dest, { text:
|
|
38
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.nvtop.noGpu', { machine })}` });
|
|
37
39
|
return;
|
|
38
40
|
}
|
|
39
41
|
if (!isDeviceOnline(machine)) {
|
|
40
|
-
await adapter.postMessage(dest, { text:
|
|
42
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.nvtop.deviceOffline', { machine })}` });
|
|
41
43
|
return;
|
|
42
44
|
}
|
|
43
45
|
try {
|
|
44
46
|
const result = await sendCommand(machine, { action: 'bash', params: { command: 'nvidia-smi' }, timeout: 15000 });
|
|
45
|
-
const output = result.stdout || result.stderr || '
|
|
46
|
-
await adapter.postMessage(dest, { text:
|
|
47
|
+
const output = result.stdout || result.stderr || t('cmd.nvtop.noOutput');
|
|
48
|
+
await adapter.postMessage(dest, { text: t('cmd.nvtop.smiHeader', { machine, output }) });
|
|
47
49
|
}
|
|
48
50
|
catch (err) {
|
|
49
|
-
await adapter.postMessage(dest, { text:
|
|
51
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.nvtop.smiFailed', { machine, error: err.message })}` });
|
|
50
52
|
}
|
|
51
53
|
}
|
|
52
54
|
export async function handleNvtopCmd(channel, adapter, trimmedMessage) {
|
|
@@ -55,27 +57,27 @@ export async function handleNvtopCmd(channel, adapter, trimmedMessage) {
|
|
|
55
57
|
if (args[0] === 'stop') {
|
|
56
58
|
const active = activeNvtopMonitors.get(channel);
|
|
57
59
|
if (!active) {
|
|
58
|
-
await adapter.postMessage(dest, { text: '
|
|
60
|
+
await adapter.postMessage(dest, { text: t('cmd.nvtop.noActive') });
|
|
59
61
|
return;
|
|
60
62
|
}
|
|
61
63
|
clearInterval(active.interval);
|
|
62
64
|
activeNvtopMonitors.delete(channel);
|
|
63
|
-
await adapter.postMessage(dest, { text:
|
|
65
|
+
await adapter.postMessage(dest, { text: `${Icons.stopped} ${t('cmd.nvtop.stopped', { machine: active.machine })}` });
|
|
64
66
|
return;
|
|
65
67
|
}
|
|
66
68
|
if (activeNvtopMonitors.has(channel)) {
|
|
67
|
-
await adapter.postMessage(dest, { text: '
|
|
69
|
+
await adapter.postMessage(dest, { text: t('cmd.nvtop.alreadyRunning') });
|
|
68
70
|
return;
|
|
69
71
|
}
|
|
70
72
|
const machine = args[0] || getLocalMachine();
|
|
71
73
|
const reg = getMachineRegistry()[machine];
|
|
72
74
|
if (!reg) {
|
|
73
75
|
const valid = Object.keys(getMachineRegistry()).filter(m => getMachineRegistry()[m].gpuCount > 0).map(m => `\`${m}\``).join(', ');
|
|
74
|
-
await adapter.postMessage(dest, { text:
|
|
76
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.nvtop.unknownMachineGpu', { machine, valid })}` });
|
|
75
77
|
return;
|
|
76
78
|
}
|
|
77
79
|
if (reg.gpuCount === 0) {
|
|
78
|
-
await adapter.postMessage(dest, { text:
|
|
80
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.nvtop.notSupported', { machine })}` });
|
|
79
81
|
return;
|
|
80
82
|
}
|
|
81
83
|
try {
|
|
@@ -100,6 +102,6 @@ export async function handleNvtopCmd(channel, adapter, trimmedMessage) {
|
|
|
100
102
|
});
|
|
101
103
|
}
|
|
102
104
|
catch (err) {
|
|
103
|
-
await adapter.postMessage(dest, { text:
|
|
105
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.nvtop.failed', { machine, error: err.message })}` });
|
|
104
106
|
}
|
|
105
107
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import { t } from '../../../core/i18n.js';
|
|
1
2
|
export async function handleOrientCmd(channel, adapter) {
|
|
2
3
|
const dest = { type: 'interactive-reply', conduit: channel, sessionId: '' };
|
|
3
|
-
await adapter.postMessage(dest, { text: '
|
|
4
|
+
await adapter.postMessage(dest, { text: t('cmd.orient.notImplemented') });
|
|
4
5
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { handleScheduleCommand } from '../../../domain/scheduling/schedule-command.js';
|
|
2
|
+
import { t } from '../../../core/i18n.js';
|
|
2
3
|
const MAX_SCHEDULE_BUTTONS = 10;
|
|
3
4
|
const FMT_OPTS = { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', hour12: false };
|
|
4
5
|
const fmtTime = (ts) => new Date(ts).toLocaleString('en-US', FMT_OPTS);
|
|
5
6
|
function formatTimeUntilCompact(ms) {
|
|
6
7
|
if (ms <= 0)
|
|
7
|
-
return 'now';
|
|
8
|
+
return t('cmd.schedule.now');
|
|
8
9
|
const seconds = Math.floor(ms / 1000);
|
|
9
10
|
if (seconds < 60)
|
|
10
11
|
return `${seconds}s`;
|
|
@@ -16,35 +17,35 @@ function formatTimeUntilCompact(ms) {
|
|
|
16
17
|
return `${hours}h`;
|
|
17
18
|
return `${Math.floor(hours / 24)}d`;
|
|
18
19
|
}
|
|
19
|
-
function formatTaskLine(
|
|
20
|
-
const id = `\`${
|
|
21
|
-
const profile =
|
|
22
|
-
const paused =
|
|
23
|
-
const nextMs = (
|
|
24
|
-
const next =
|
|
25
|
-
const msg =
|
|
26
|
-
return `${id} ${
|
|
20
|
+
function formatTaskLine(task, now) {
|
|
21
|
+
const id = `\`${task.id}\``;
|
|
22
|
+
const profile = task.profile ? ` · ${task.profile}` : '';
|
|
23
|
+
const paused = task.isPaused ? ` · *${t('cmd.schedule.paused')}*` : '';
|
|
24
|
+
const nextMs = (task.nextRun || task.runAt || 0) - now;
|
|
25
|
+
const next = task.isPaused ? '' : ` · ${t('cmd.schedule.nextLabel')}: ${formatTimeUntilCompact(nextMs)}`;
|
|
26
|
+
const msg = task.message.length > 40 ? task.message.slice(0, 37) + '...' : task.message;
|
|
27
|
+
return `${id} ${task.type}${profile}${paused}${next} · "${msg}"`;
|
|
27
28
|
}
|
|
28
29
|
function buildScheduleTaskButtons(tasks) {
|
|
29
30
|
const buttons = [];
|
|
30
31
|
for (let i = 0; i < Math.min(tasks.length, MAX_SCHEDULE_BUTTONS); i++) {
|
|
31
|
-
const
|
|
32
|
-
if (
|
|
32
|
+
const task = tasks[i];
|
|
33
|
+
if (task.type === 'once') {
|
|
33
34
|
buttons.push({
|
|
34
|
-
type: 'button', text:
|
|
35
|
-
actionId: `cmd:schedule:remove-${i}`, value:
|
|
35
|
+
type: 'button', text: t('cmd.schedule.removeButton', { id: task.id }),
|
|
36
|
+
actionId: `cmd:schedule:remove-${i}`, value: task.id, style: 'danger',
|
|
36
37
|
});
|
|
37
38
|
}
|
|
38
|
-
else if (
|
|
39
|
+
else if (task.isPaused) {
|
|
39
40
|
buttons.push({
|
|
40
|
-
type: 'button', text:
|
|
41
|
-
actionId: `cmd:schedule:resume-${i}`, value:
|
|
41
|
+
type: 'button', text: t('cmd.schedule.resumeButton', { id: task.id }),
|
|
42
|
+
actionId: `cmd:schedule:resume-${i}`, value: task.id,
|
|
42
43
|
});
|
|
43
44
|
}
|
|
44
45
|
else {
|
|
45
46
|
buttons.push({
|
|
46
|
-
type: 'button', text:
|
|
47
|
-
actionId: `cmd:schedule:pause-${i}`, value:
|
|
47
|
+
type: 'button', text: t('cmd.schedule.pauseButton', { id: task.id }),
|
|
48
|
+
actionId: `cmd:schedule:pause-${i}`, value: task.id,
|
|
48
49
|
});
|
|
49
50
|
}
|
|
50
51
|
}
|
|
@@ -56,8 +57,8 @@ export function createScheduleHandler(scheduler, router) {
|
|
|
56
57
|
const tasks = await scheduler.list();
|
|
57
58
|
const now = Date.now();
|
|
58
59
|
const text = tasks.length === 0
|
|
59
|
-
? '
|
|
60
|
-
:
|
|
60
|
+
? t('cmd.schedule.none')
|
|
61
|
+
: `${t('cmd.schedule.header', { n: tasks.length })}\n${tasks.map(task => `• ${formatTaskLine(task, now)}`).join('\n')}`;
|
|
61
62
|
await adapter.updateMessage(messageRef, {
|
|
62
63
|
text,
|
|
63
64
|
richBlocks: [
|
|
@@ -117,11 +118,11 @@ export function createScheduleHandler(scheduler, router) {
|
|
|
117
118
|
if (router && scheduler && (!sub || sub === 'list')) {
|
|
118
119
|
const tasks = await scheduler.list();
|
|
119
120
|
if (tasks.length === 0) {
|
|
120
|
-
await adapter.postMessage(dest, { text: '
|
|
121
|
+
await adapter.postMessage(dest, { text: t('cmd.schedule.none') });
|
|
121
122
|
return;
|
|
122
123
|
}
|
|
123
124
|
const now = Date.now();
|
|
124
|
-
const text =
|
|
125
|
+
const text = `${t('cmd.schedule.header', { n: tasks.length })}\n${tasks.map(task => `• ${formatTaskLine(task, now)}`).join('\n')}`;
|
|
125
126
|
return {
|
|
126
127
|
text,
|
|
127
128
|
richBlocks: [{ type: 'section', text }],
|