@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
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { getMachineRegistry } from '../../../domain/tasks/dispatch-utils.js';
|
|
2
|
+
import { Icons } from '../../../core/icons.js';
|
|
3
|
+
import { t } from '../../../core/i18n.js';
|
|
2
4
|
import { statSync, existsSync, mkdirSync, unlinkSync } from 'fs';
|
|
3
5
|
import { execFile } from 'child_process';
|
|
4
6
|
import * as os from 'os';
|
|
@@ -17,16 +19,16 @@ async function sendLocalFile(channel, adapter, reg, filePath, machine) {
|
|
|
17
19
|
resolved = path.resolve(reg.cortexPath, filePath);
|
|
18
20
|
}
|
|
19
21
|
if (!existsSync(resolved)) {
|
|
20
|
-
await adapter.postMessage(dest, { text:
|
|
22
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.sendfile.fileNotFound', { path: resolved })}` });
|
|
21
23
|
return;
|
|
22
24
|
}
|
|
23
25
|
const stat = statSync(resolved);
|
|
24
26
|
if (!stat.isFile()) {
|
|
25
|
-
await adapter.postMessage(dest, { text:
|
|
27
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.sendfile.notAFile', { path: resolved })}` });
|
|
26
28
|
return;
|
|
27
29
|
}
|
|
28
30
|
await adapter.uploadFile(dest, resolved, { filename: path.basename(resolved) });
|
|
29
|
-
await adapter.postMessage(dest, { text:
|
|
31
|
+
await adapter.postMessage(dest, { text: `${Icons.ok} ${t('cmd.sendfile.sent', { name: path.basename(resolved), size: (stat.size / 1024).toFixed(1), machine })}` });
|
|
30
32
|
}
|
|
31
33
|
async function sendRemoteFile(channel, adapter, reg, filePath, machine) {
|
|
32
34
|
const dest = { type: 'interactive-reply', conduit: channel, sessionId: '' };
|
|
@@ -60,13 +62,13 @@ async function sendRemoteFile(channel, adapter, reg, filePath, machine) {
|
|
|
60
62
|
});
|
|
61
63
|
}
|
|
62
64
|
catch (err) {
|
|
63
|
-
await adapter.postMessage(dest, { text:
|
|
65
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.sendfile.fetchFailed', { machine, error: err.message })}` });
|
|
64
66
|
return;
|
|
65
67
|
}
|
|
66
68
|
try {
|
|
67
69
|
const tmpStat = statSync(localTmp);
|
|
68
70
|
await adapter.uploadFile(dest, localTmp, { filename: fileName });
|
|
69
|
-
await adapter.postMessage(dest, { text:
|
|
71
|
+
await adapter.postMessage(dest, { text: `${Icons.ok} ${t('cmd.sendfile.sent', { name: fileName, size: (tmpStat.size / 1024).toFixed(1), machine })}` });
|
|
70
72
|
}
|
|
71
73
|
finally {
|
|
72
74
|
try {
|
|
@@ -79,14 +81,14 @@ export async function handleSendFileCmd(channel, adapter, trimmedMessage) {
|
|
|
79
81
|
const dest = { type: 'interactive-reply', conduit: channel, sessionId: '' };
|
|
80
82
|
const args = trimmedMessage.split(/\s+/).slice(1);
|
|
81
83
|
if (args.length < 2) {
|
|
82
|
-
await adapter.postMessage(dest, { text: '
|
|
84
|
+
await adapter.postMessage(dest, { text: t('cmd.sendfile.usage') });
|
|
83
85
|
return;
|
|
84
86
|
}
|
|
85
87
|
const machine = args[0];
|
|
86
88
|
const filePath = args.slice(1).join(' ');
|
|
87
89
|
const reg = getMachineRegistry()[machine];
|
|
88
90
|
if (!reg) {
|
|
89
|
-
await adapter.postMessage(dest, { text:
|
|
91
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.sendfile.unknownMachine', { machine, known: Object.keys(getMachineRegistry()).join(', ') })}` });
|
|
90
92
|
return;
|
|
91
93
|
}
|
|
92
94
|
if (!reg.ssh)
|
|
@@ -3,7 +3,7 @@ import type { CommandResult } from './command-context.js';
|
|
|
3
3
|
import type { CommandActionRouter } from '../../interactions/command-action-router.js';
|
|
4
4
|
export declare function handleNewCmd(channel: string, adapter: PlatformAdapter, opts?: {
|
|
5
5
|
skipHook?: boolean;
|
|
6
|
-
},
|
|
6
|
+
}, threadAnchorId?: string | null): Promise<void>;
|
|
7
7
|
export declare function createResumeHandler(router?: CommandActionRouter): (channel: string, adapter: PlatformAdapter, trimmedMessage: string) => Promise<CommandResult | void>;
|
|
8
8
|
/** @deprecated Use createResumeHandler() instead. */
|
|
9
9
|
export declare function handleResumeCmd(channel: string, adapter: PlatformAdapter, trimmedMessage: string): Promise<void>;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createLogger } from '../../../core/log.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { Icons } from '../../../core/icons.js';
|
|
3
|
+
import { t } from '../../../core/i18n.js';
|
|
4
|
+
import { closeSession, getActiveBackend, getActiveProfile } from '../../../domain/agents/index.js';
|
|
4
5
|
import { fireAndForgetPreCloseHook } from '../../../domain/sessions/session-hooks.js';
|
|
5
6
|
import { sessionStore } from '../../../store/session-registry-repo.js';
|
|
6
7
|
import { conversationLedger } from '../../../store/conversation-ledger-repo.js';
|
|
7
|
-
import
|
|
8
|
+
import { attachExistingSession, resetChannelSession } from '../../../domain/sessions/session-lifecycle.js';
|
|
8
9
|
import { planApprovals } from '../../interactions/plan-approvals.js';
|
|
9
10
|
const log = createLogger('session');
|
|
10
11
|
function formatTimeAgo(ms) {
|
|
@@ -21,12 +22,12 @@ function formatTimeAgo(ms) {
|
|
|
21
22
|
return `${days}d ago`;
|
|
22
23
|
}
|
|
23
24
|
/** Resolve the Slack thread timestamp for the session:
|
|
24
|
-
* 1. Command-level
|
|
25
|
+
* 1. Command-level threadAnchorId (user typed !new in-thread)
|
|
25
26
|
* 2. Conversation ledger's last status message ts (session's thread parent)
|
|
26
27
|
* 3. null (no thread context available) */
|
|
27
|
-
async function resolveSessionThreadTs(channel,
|
|
28
|
-
if (
|
|
29
|
-
return
|
|
28
|
+
async function resolveSessionThreadTs(channel, threadAnchorId) {
|
|
29
|
+
if (threadAnchorId)
|
|
30
|
+
return threadAnchorId;
|
|
30
31
|
const conv = await conversationLedger.getConversation(channel);
|
|
31
32
|
if (conv?.turns.length) {
|
|
32
33
|
// Walk backwards to find the last turn with a statusMessageTs
|
|
@@ -37,30 +38,20 @@ async function resolveSessionThreadTs(channel, threadTs) {
|
|
|
37
38
|
}
|
|
38
39
|
return null;
|
|
39
40
|
}
|
|
40
|
-
export async function handleNewCmd(channel, adapter, opts = {},
|
|
41
|
+
export async function handleNewCmd(channel, adapter, opts = {}, threadAnchorId) {
|
|
41
42
|
const dest = { type: 'interactive-reply', conduit: channel, sessionId: '' };
|
|
42
43
|
if (!opts.skipHook) {
|
|
43
|
-
const resolvedThreadTs = await resolveSessionThreadTs(channel,
|
|
44
|
+
const resolvedThreadTs = await resolveSessionThreadTs(channel, threadAnchorId);
|
|
44
45
|
void fireAndForgetPreCloseHook(channel, adapter, resolvedThreadTs);
|
|
45
46
|
}
|
|
46
47
|
closeSession(channel);
|
|
47
|
-
const conv = await conversationLedger.getConversation(channel);
|
|
48
48
|
const profileName = getActiveProfile(channel) || 'default';
|
|
49
|
-
|
|
50
|
-
sessionBackup.cleanupAllBackups(conv.sessionId);
|
|
51
|
-
await conversationLedger.clearConversation(channel);
|
|
52
|
-
}
|
|
53
|
-
// Clear sessions for ALL backends, not just the current one — otherwise switching
|
|
54
|
-
// profiles after !newq can resurrect a stale session from the previous backend
|
|
55
|
-
// (e.g. !newq on PI backend leaves claude:C<channel> intact; switching to Claude
|
|
56
|
-
// backend then tries to --resume a session whose claude-side file is gone).
|
|
57
|
-
const ALL_BACKENDS = ['claude', 'pi', 'codex'];
|
|
58
|
-
await Promise.all(ALL_BACKENDS.map(b => deleteSessionAsync(channel, b).catch(() => { })));
|
|
49
|
+
await resetChannelSession(channel);
|
|
59
50
|
const cleared = planApprovals.clearByChannel(channel);
|
|
60
51
|
if (cleared > 0)
|
|
61
52
|
log.info('Cleared pending plan for channel:', channel);
|
|
62
53
|
log.info('New conversation started in channel:', channel);
|
|
63
|
-
await adapter.postMessage(dest, { text:
|
|
54
|
+
await adapter.postMessage(dest, { text: t('cmd.session.newConversation', { profile: profileName }) });
|
|
64
55
|
}
|
|
65
56
|
const MAX_RESUME_BUTTONS = 10;
|
|
66
57
|
export function createResumeHandler(router) {
|
|
@@ -74,19 +65,16 @@ export function createResumeHandler(router) {
|
|
|
74
65
|
if (!record) {
|
|
75
66
|
if (ctx.messageRef) {
|
|
76
67
|
await adapter.updateMessage(ctx.messageRef, {
|
|
77
|
-
text:
|
|
68
|
+
text: `${Icons.error} ${t('cmd.session.notFound', { name })}`,
|
|
78
69
|
}).catch(() => { });
|
|
79
70
|
}
|
|
80
71
|
return;
|
|
81
72
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
await setSessionAsync(ctx.channelId, record.sessionId, record.backend);
|
|
85
|
-
await conversationLedger.switchSession(ctx.channelId, { sessionId: record.sessionId, sessionName: name, backend: record.backend, profileName: record.profileName });
|
|
86
|
-
const profileNote = record.profileName ? ` (profile: ${record.profileName})` : '';
|
|
73
|
+
await attachExistingSession(ctx.channelId, { sessionId: record.sessionId, sessionName: name, backend: record.backend, profileName: record.profileName });
|
|
74
|
+
const profileNote = record.profileName ? t('cmd.session.profileNote', { profile: record.profileName }) : '';
|
|
87
75
|
if (ctx.messageRef) {
|
|
88
76
|
await adapter.updateMessage(ctx.messageRef, {
|
|
89
|
-
text:
|
|
77
|
+
text: `${Icons.refresh} ${t('cmd.session.switched', { name, profileNote })}`,
|
|
90
78
|
}).catch(() => { });
|
|
91
79
|
}
|
|
92
80
|
};
|
|
@@ -104,31 +92,28 @@ export function createResumeHandler(router) {
|
|
|
104
92
|
const name = args[0];
|
|
105
93
|
const record = await sessionStore.lookupSession(name);
|
|
106
94
|
if (!record) {
|
|
107
|
-
await adapter.postMessage(dest, { text:
|
|
95
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.session.notFoundList', { name })}` });
|
|
108
96
|
return;
|
|
109
97
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
await
|
|
113
|
-
await conversationLedger.switchSession(channel, { sessionId: record.sessionId, sessionName: name, backend: record.backend, profileName: record.profileName });
|
|
114
|
-
const profileNote = record.profileName ? ` (profile: ${record.profileName})` : '';
|
|
115
|
-
await adapter.postMessage(dest, { text: `:arrows_counterclockwise: Switched to session \`${name}\`${profileNote}` });
|
|
98
|
+
await attachExistingSession(channel, { sessionId: record.sessionId, sessionName: name, backend: record.backend, profileName: record.profileName });
|
|
99
|
+
const profileNote = record.profileName ? t('cmd.session.profileNote', { profile: record.profileName }) : '';
|
|
100
|
+
await adapter.postMessage(dest, { text: `${Icons.refresh} ${t('cmd.session.switched', { name, profileNote })}` });
|
|
116
101
|
return;
|
|
117
102
|
}
|
|
118
103
|
const sessions = await sessionStore.listRecentSessions(10);
|
|
119
104
|
if (sessions.length === 0) {
|
|
120
|
-
await adapter.postMessage(dest, { text: '
|
|
105
|
+
await adapter.postMessage(dest, { text: t('cmd.session.noSessions') });
|
|
121
106
|
return;
|
|
122
107
|
}
|
|
123
108
|
const activeId = await sessionStore.getActiveSessionName(channel, getActiveBackend());
|
|
124
109
|
const now = Date.now();
|
|
125
|
-
const lines = ['
|
|
110
|
+
const lines = [t('cmd.session.recentHeader')];
|
|
126
111
|
for (const s of sessions) {
|
|
127
112
|
const isActive = s.name === activeId;
|
|
128
|
-
const activeTag = isActive ? '
|
|
113
|
+
const activeTag = isActive ? t('cmd.session.activeTag') : '';
|
|
129
114
|
const ago = formatTimeAgo(now - new Date(s.lastUsedAt).getTime());
|
|
130
115
|
const label = s.label ? ` — ${s.label}` : '';
|
|
131
|
-
const kind = s.kind === 'scheduled' ?
|
|
116
|
+
const kind = s.kind === 'scheduled' ? ` ${Icons.scheduled}` : '';
|
|
132
117
|
lines.push(`• \`${s.name}\`${activeTag}${kind}${label} — ${ago}`);
|
|
133
118
|
}
|
|
134
119
|
const text = lines.join('\n');
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { t } from '../../../core/i18n.js';
|
|
1
2
|
export function createStatusHandler(getExecutionStatusReport, router) {
|
|
2
3
|
// Register refresh action handler
|
|
3
4
|
if (router) {
|
|
@@ -17,7 +18,7 @@ export function createStatusHandler(getExecutionStatusReport, router) {
|
|
|
17
18
|
type: 'actions',
|
|
18
19
|
elements: [{
|
|
19
20
|
type: 'button',
|
|
20
|
-
text: '
|
|
21
|
+
text: t('cmd.status.refreshButton'),
|
|
21
22
|
actionId: 'cmd:status:refresh',
|
|
22
23
|
value: 'refresh',
|
|
23
24
|
}],
|
|
@@ -29,7 +30,7 @@ export function createStatusHandler(getExecutionStatusReport, router) {
|
|
|
29
30
|
});
|
|
30
31
|
}
|
|
31
32
|
return async function handleStatusCmd(channel, adapter) {
|
|
32
|
-
const text = getExecutionStatusReport ? getExecutionStatusReport() : '
|
|
33
|
+
const text = getExecutionStatusReport ? getExecutionStatusReport() : t('cmd.status.unavailable');
|
|
33
34
|
if (!router) {
|
|
34
35
|
await adapter.postMessage({ type: 'interactive-reply', conduit: channel, sessionId: '' }, { text });
|
|
35
36
|
return;
|
|
@@ -39,7 +40,7 @@ export function createStatusHandler(getExecutionStatusReport, router) {
|
|
|
39
40
|
richBlocks: [{ type: 'section', text }],
|
|
40
41
|
actions: [{
|
|
41
42
|
type: 'button',
|
|
42
|
-
text: '
|
|
43
|
+
text: t('cmd.status.refreshButton'),
|
|
43
44
|
actionId: 'cmd:status:refresh',
|
|
44
45
|
value: 'refresh',
|
|
45
46
|
}],
|
|
@@ -47,84 +48,90 @@ export function createStatusHandler(getExecutionStatusReport, router) {
|
|
|
47
48
|
};
|
|
48
49
|
}
|
|
49
50
|
// --- Help command categories ---
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
51
|
+
// Built per call so labels and command descriptions resolve in the ACTIVE locale (the !lang
|
|
52
|
+
// command can switch it at runtime). A module-level const would freeze English at import time.
|
|
53
|
+
function getHelpCategories() {
|
|
54
|
+
return {
|
|
55
|
+
session: {
|
|
56
|
+
label: t('cmd.help.catSession'),
|
|
57
|
+
commands: [
|
|
58
|
+
t('cmd.help.session.new'),
|
|
59
|
+
t('cmd.help.session.cancel'),
|
|
60
|
+
t('cmd.help.session.resume'),
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
config: {
|
|
64
|
+
label: t('cmd.help.catConfig'),
|
|
65
|
+
commands: [
|
|
66
|
+
t('cmd.help.config.mode'),
|
|
67
|
+
t('cmd.help.config.backend'),
|
|
68
|
+
t('cmd.help.config.model'),
|
|
69
|
+
t('cmd.help.config.profile'),
|
|
70
|
+
t('cmd.help.config.skills'),
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
monitoring: {
|
|
74
|
+
label: t('cmd.help.catMonitoring'),
|
|
75
|
+
commands: [
|
|
76
|
+
t('cmd.help.monitoring.cost'),
|
|
77
|
+
t('cmd.help.monitoring.status'),
|
|
78
|
+
t('cmd.help.monitoring.budget'),
|
|
79
|
+
t('cmd.help.monitoring.schedule'),
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
tasks: {
|
|
83
|
+
label: t('cmd.help.catTasks'),
|
|
84
|
+
commands: [
|
|
85
|
+
t('cmd.help.tasks.tasks'),
|
|
86
|
+
t('cmd.help.tasks.projects'),
|
|
87
|
+
t('cmd.help.tasks.register'),
|
|
88
|
+
t('cmd.help.tasks.unregister'),
|
|
89
|
+
t('cmd.help.tasks.projectDir'),
|
|
90
|
+
],
|
|
91
|
+
},
|
|
92
|
+
devices: {
|
|
93
|
+
label: t('cmd.help.catDevices'),
|
|
94
|
+
commands: [
|
|
95
|
+
t('cmd.help.devices.devices'),
|
|
96
|
+
t('cmd.help.devices.nvidiaSmi'),
|
|
97
|
+
t('cmd.help.devices.nvtop'),
|
|
98
|
+
t('cmd.help.devices.tail'),
|
|
99
|
+
t('cmd.help.devices.sendfile'),
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
threads: {
|
|
103
|
+
label: t('cmd.help.catThreads'),
|
|
104
|
+
commands: [
|
|
105
|
+
t('cmd.help.threads.thread'),
|
|
106
|
+
t('cmd.help.threads.agent'),
|
|
107
|
+
],
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
}
|
|
106
111
|
function buildHelpText(category) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
112
|
+
const categories = getHelpCategories();
|
|
113
|
+
if (category && category !== 'all' && categories[category]) {
|
|
114
|
+
const cat = categories[category];
|
|
115
|
+
return `${t('cmd.help.headingCategory', { label: cat.label })}\n${cat.commands.join('\n')}`;
|
|
110
116
|
}
|
|
111
|
-
const allCommands = Object.values(
|
|
112
|
-
return ['
|
|
117
|
+
const allCommands = Object.values(categories).flatMap(c => c.commands);
|
|
118
|
+
return [t('cmd.help.heading'), ...allCommands, t('cmd.help.selfLine')].join('\n');
|
|
113
119
|
}
|
|
114
120
|
// Slack section blocks have a 3000-char limit; split into one block per category.
|
|
115
121
|
function buildHelpRichBlocks(category) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
122
|
+
const categories = getHelpCategories();
|
|
123
|
+
if (category && category !== 'all' && categories[category]) {
|
|
124
|
+
const cat = categories[category];
|
|
125
|
+
return [{ type: 'section', text: `${t('cmd.help.headingCategory', { label: cat.label })}\n${cat.commands.join('\n')}` }];
|
|
119
126
|
}
|
|
120
|
-
return Object.values(
|
|
127
|
+
return Object.values(categories).map(cat => ({
|
|
121
128
|
type: 'section',
|
|
122
129
|
text: `*${cat.label}*\n${cat.commands.join('\n')}`,
|
|
123
130
|
}));
|
|
124
131
|
}
|
|
125
|
-
const HELP_CATEGORY_KEYS = [
|
|
132
|
+
const HELP_CATEGORY_KEYS = ['session', 'config', 'monitoring', 'tasks', 'devices', 'threads', 'all'];
|
|
126
133
|
function buildHelpButtons() {
|
|
127
|
-
const buttons = Object.entries(
|
|
134
|
+
const buttons = Object.entries(getHelpCategories()).map(([key, cat]) => ({
|
|
128
135
|
type: 'button',
|
|
129
136
|
text: cat.label,
|
|
130
137
|
actionId: `cmd:help:cat-${key}`,
|
|
@@ -132,7 +139,7 @@ function buildHelpButtons() {
|
|
|
132
139
|
}));
|
|
133
140
|
buttons.push({
|
|
134
141
|
type: 'button',
|
|
135
|
-
text: '
|
|
142
|
+
text: t('cmd.help.showAll'),
|
|
136
143
|
actionId: 'cmd:help:cat-all',
|
|
137
144
|
value: 'all',
|
|
138
145
|
});
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { statSync, openSync, readSync, closeSync } from 'fs';
|
|
2
2
|
import * as path from 'path';
|
|
3
3
|
import { moduleDir } from '../../../core/utils.js';
|
|
4
|
+
import { Icons } from '../../../core/icons.js';
|
|
5
|
+
import { t } from '../../../core/i18n.js';
|
|
4
6
|
const DAEMON_LOG_PATH = path.join(moduleDir(import.meta.url), '..', '..', '..', '..', 'logs', 'daemon.log');
|
|
5
7
|
const activeTails = new Map();
|
|
6
8
|
async function stopTail(channel, adapter) {
|
|
7
9
|
const dest = { type: 'interactive-reply', conduit: channel, sessionId: '' };
|
|
8
10
|
const active = activeTails.get(channel);
|
|
9
11
|
if (!active) {
|
|
10
|
-
await adapter.postMessage(dest, { text: '
|
|
12
|
+
await adapter.postMessage(dest, { text: t('cmd.tail.noActive') });
|
|
11
13
|
return;
|
|
12
14
|
}
|
|
13
15
|
clearInterval(active.interval);
|
|
14
16
|
activeTails.delete(channel);
|
|
15
|
-
await adapter.postMessage(dest, { text: '
|
|
17
|
+
await adapter.postMessage(dest, { text: `${Icons.stopped} ${t('cmd.tail.stopped')}` });
|
|
16
18
|
}
|
|
17
19
|
async function sendInitialTailPreview(channel, adapter) {
|
|
18
20
|
const previewDest = { type: 'interactive-reply', conduit: channel, sessionId: '' };
|
|
@@ -24,11 +26,11 @@ async function sendInitialTailPreview(channel, adapter) {
|
|
|
24
26
|
readSync(fd, buf, 0, previewBytes, stat.size - previewBytes);
|
|
25
27
|
closeSync(fd);
|
|
26
28
|
const lines = buf.toString('utf-8').split('\n').filter(Boolean).slice(-30);
|
|
27
|
-
await adapter.postMessage(previewDest, { text:
|
|
29
|
+
await adapter.postMessage(previewDest, { text: `${Icons.scroll} ${t('cmd.tail.preview', { n: lines.length, content: lines.join('\n') })}` });
|
|
28
30
|
return stat.size;
|
|
29
31
|
}
|
|
30
32
|
catch (err) {
|
|
31
|
-
await adapter.postMessage(previewDest, { text:
|
|
33
|
+
await adapter.postMessage(previewDest, { text: `${Icons.error} ${t('cmd.tail.cannotRead', { error: err.message })}` });
|
|
32
34
|
return null;
|
|
33
35
|
}
|
|
34
36
|
}
|
|
@@ -67,7 +69,7 @@ export async function handleTailCmd(channel, adapter, trimmedMessage) {
|
|
|
67
69
|
return stopTail(channel, adapter);
|
|
68
70
|
const cmdDest = { type: 'interactive-reply', conduit: channel, sessionId: '' };
|
|
69
71
|
if (activeTails.has(channel)) {
|
|
70
|
-
await adapter.postMessage(cmdDest, { text: '
|
|
72
|
+
await adapter.postMessage(cmdDest, { text: t('cmd.tail.alreadyTailing') });
|
|
71
73
|
return;
|
|
72
74
|
}
|
|
73
75
|
const offset = await sendInitialTailPreview(channel, adapter);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Icons } from '../../../core/icons.js';
|
|
2
|
+
import { t } from '../../../core/i18n.js';
|
|
1
3
|
import { scanAllTasks, completedHashSet, isActionable } from '../../../domain/tasks/parser.js';
|
|
2
4
|
import { PROJECTS_DIR } from '../../../core/utils.js';
|
|
3
5
|
import * as path from 'path';
|
|
@@ -12,37 +14,37 @@ function formatTaskList(tasks, filter, project) {
|
|
|
12
14
|
default: return true;
|
|
13
15
|
}
|
|
14
16
|
});
|
|
15
|
-
const filterLabel = filter === 'all' ? '' :
|
|
16
|
-
const lines = [
|
|
17
|
+
const filterLabel = filter === 'all' ? '' : t('cmd.task.filterLabel', { filter });
|
|
18
|
+
const lines = [`${t('cmd.task.header', { project, shown: filtered.length, total: tasks.length, filterLabel })}\n`];
|
|
17
19
|
for (const task of filtered) {
|
|
18
|
-
const status = task.status === 'done' ?
|
|
20
|
+
const status = task.status === 'done' ? Icons.ok : (task.blocked_by ? Icons.blocked : (task.claimed_by ? Icons.refresh : (task.paused ? Icons.paused : Icons.pending)));
|
|
19
21
|
const id = task.id ? `\`${task.id}\`` : '—';
|
|
20
22
|
const tags = [];
|
|
21
23
|
if (task.priority)
|
|
22
24
|
tags.push(task.priority);
|
|
23
25
|
if (task.gpu)
|
|
24
26
|
tags.push(`gpu:${task.gpu}`);
|
|
25
|
-
const statusLabel = task.status === 'done' ? '
|
|
26
|
-
: task.blocked_by ?
|
|
27
|
-
: task.claimed_by ?
|
|
28
|
-
: task.paused ? '
|
|
29
|
-
: (task.approval_needed && !task.approved_at) ? '
|
|
30
|
-
: isActionable(task, completed) ? '
|
|
31
|
-
: '
|
|
27
|
+
const statusLabel = task.status === 'done' ? t('cmd.task.statusCompleted')
|
|
28
|
+
: task.blocked_by ? t('cmd.task.statusBlocked', { by: task.blocked_by })
|
|
29
|
+
: task.claimed_by ? t('cmd.task.statusInProgress', { by: task.claimed_by })
|
|
30
|
+
: task.paused ? t('cmd.task.statusPaused')
|
|
31
|
+
: (task.approval_needed && !task.approved_at) ? t('cmd.task.statusApprovalNeeded')
|
|
32
|
+
: isActionable(task, completed) ? t('cmd.task.statusActionable')
|
|
33
|
+
: t('cmd.task.statusOpen');
|
|
32
34
|
lines.push(`${status} ${id} *${task.text}*`);
|
|
33
|
-
lines.push(
|
|
35
|
+
lines.push(t('cmd.task.statusLine', { status: statusLabel, priority: task.priority }));
|
|
34
36
|
if (tags.length)
|
|
35
|
-
lines.push(
|
|
37
|
+
lines.push(t('cmd.task.tagsLine', { tags: tags.join(', ') }));
|
|
36
38
|
if (task.why)
|
|
37
|
-
lines.push(
|
|
39
|
+
lines.push(t('cmd.task.whyLine', { why: task.why }));
|
|
38
40
|
if (task.done_when)
|
|
39
|
-
lines.push(
|
|
41
|
+
lines.push(t('cmd.task.doneWhenLine', { doneWhen: task.done_when }));
|
|
40
42
|
if (task.depends_on.length)
|
|
41
|
-
lines.push(
|
|
43
|
+
lines.push(t('cmd.task.dependsLine', { depends: task.depends_on.join(', ') }));
|
|
42
44
|
lines.push('');
|
|
43
45
|
}
|
|
44
46
|
if (filtered.length === 0) {
|
|
45
|
-
lines.push(
|
|
47
|
+
lines.push(t('cmd.task.noneFound', { filter }));
|
|
46
48
|
}
|
|
47
49
|
return lines.join('\n');
|
|
48
50
|
}
|
|
@@ -67,10 +69,10 @@ function textToSectionBlocks(text) {
|
|
|
67
69
|
}
|
|
68
70
|
function buildFilterButtons(project) {
|
|
69
71
|
const TASK_FILTERS = [
|
|
70
|
-
{ label: '
|
|
71
|
-
{ label: '
|
|
72
|
-
{ label: '
|
|
73
|
-
{ label: '
|
|
72
|
+
{ label: t('cmd.task.filterAll'), value: 'all' },
|
|
73
|
+
{ label: t('cmd.task.filterActionable'), value: 'actionable' },
|
|
74
|
+
{ label: t('cmd.task.filterInProgress'), value: 'in-progress' },
|
|
75
|
+
{ label: t('cmd.task.filterBlocked'), value: 'blocked' },
|
|
74
76
|
];
|
|
75
77
|
return TASK_FILTERS.map(f => ({
|
|
76
78
|
type: 'button',
|
|
@@ -110,18 +112,18 @@ export function createTasksHandler(router) {
|
|
|
110
112
|
const dest = { type: 'interactive-reply', conduit: channel, sessionId: '' };
|
|
111
113
|
const args = trimmedMessage.split(/\s+/).slice(1);
|
|
112
114
|
if (args.length === 0) {
|
|
113
|
-
await adapter.postMessage(dest, { text:
|
|
115
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.task.usage')}` });
|
|
114
116
|
return;
|
|
115
117
|
}
|
|
116
118
|
const project = args[0];
|
|
117
119
|
const projectDir = path.join(PROJECTS_DIR, project);
|
|
118
120
|
if (!existsSync(projectDir)) {
|
|
119
|
-
await adapter.postMessage(dest, { text:
|
|
121
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.task.projectNotFound', { project })}` });
|
|
120
122
|
return;
|
|
121
123
|
}
|
|
122
124
|
const tasks = scanAllTasks(project);
|
|
123
125
|
if (tasks.length === 0) {
|
|
124
|
-
await adapter.postMessage(dest, { text:
|
|
126
|
+
await adapter.postMessage(dest, { text: t('cmd.task.noTasks', { project }) });
|
|
125
127
|
return;
|
|
126
128
|
}
|
|
127
129
|
const text = formatTaskList(tasks, 'all', project);
|