@cortex-agent/server 2026.5.25 → 2026.6.11
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 +301 -29
- package/dist/core/icons.d.ts +68 -0
- package/dist/core/icons.js +67 -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/status-format.js +3 -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/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 +120 -10
- package/dist/domain/scheduling/schedule-command.js +16 -15
- 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/install-cli.d.ts +7 -0
- package/dist/domain/system/install-cli.js +106 -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.js +26 -0
- 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 +15 -1
- package/dist/domain/threads/prompt-builder.js +41 -2
- 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 +94 -5
- package/dist/entry/cli.d.ts +12 -0
- package/dist/entry/cli.js +122 -12
- package/dist/entry/feishu-login.d.ts +28 -0
- package/dist/entry/feishu-login.js +218 -0
- package/dist/entry/init.d.ts +25 -2
- package/dist/entry/init.js +211 -64
- 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 +48 -17
- 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.d.ts +6 -0
- package/dist/orchestration/interactions/update-prompt.js +100 -0
- package/dist/orchestration/lifecycle.d.ts +4 -4
- package/dist/orchestration/lifecycle.js +24 -22
- package/dist/orchestration/orchestrator.d.ts +1 -1
- package/dist/orchestration/routing/commands/cancel.js +39 -47
- package/dist/orchestration/routing/commands/channel.js +24 -11
- package/dist/orchestration/routing/commands/cost.js +2 -1
- package/dist/orchestration/routing/commands/device.js +3 -2
- package/dist/orchestration/routing/commands/dispatch.js +6 -5
- package/dist/orchestration/routing/commands/index.d.ts +1 -1
- package/dist/orchestration/routing/commands/index.js +11 -10
- package/dist/orchestration/routing/commands/mode.js +19 -18
- package/dist/orchestration/routing/commands/nvtop.js +10 -9
- package/dist/orchestration/routing/commands/sendfile.js +7 -6
- package/dist/orchestration/routing/commands/session.d.ts +1 -1
- package/dist/orchestration/routing/commands/session.js +17 -33
- package/dist/orchestration/routing/commands/tail.js +4 -3
- package/dist/orchestration/routing/commands/task.js +4 -3
- package/dist/orchestration/routing/commands/thread-handlers.js +16 -6
- 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 +7 -6
- 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 +3 -2
- 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.js +95 -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,6 +1,19 @@
|
|
|
1
1
|
import { projectStore } from '../../../domain/projects/index.js';
|
|
2
2
|
import { projectDirRepo } from '../../../store/project-dir-repo.js';
|
|
3
|
+
import { Icons } from '../../../core/icons.js';
|
|
3
4
|
import { getMachineRegistry } from '../../../domain/tasks/dispatch-utils.js';
|
|
5
|
+
/**
|
|
6
|
+
* Render a (possibly platform-prefixed) conduit for display.
|
|
7
|
+
* Slack channels become a `<#id>` mention; other platforms (Feishu/TUI) show
|
|
8
|
+
* the bare id in code formatting since `<#…>` is Slack-only syntax.
|
|
9
|
+
*/
|
|
10
|
+
function displayConduit(conduit) {
|
|
11
|
+
if (conduit.startsWith('slack:'))
|
|
12
|
+
return `<#${conduit.slice('slack:'.length)}>`;
|
|
13
|
+
const colon = conduit.indexOf(':');
|
|
14
|
+
const bare = colon === -1 ? conduit : conduit.slice(colon + 1);
|
|
15
|
+
return `\`${bare}\``;
|
|
16
|
+
}
|
|
4
17
|
export async function handleProjectsCmd(channel, adapter) {
|
|
5
18
|
const dest = { type: 'interactive-reply', conduit: channel, sessionId: '' };
|
|
6
19
|
const projects = projectStore.list().map(p => p.id);
|
|
@@ -11,7 +24,7 @@ export async function handleProjectsCmd(channel, adapter) {
|
|
|
11
24
|
const registrations = await adapter.getProjectConduits();
|
|
12
25
|
const lines = projects.map(p => {
|
|
13
26
|
const ch = registrations[p];
|
|
14
|
-
const status = ch ? ` →
|
|
27
|
+
const status = ch ? ` → ${displayConduit(ch)}` : '';
|
|
15
28
|
return `• \`${p}\`${status}`;
|
|
16
29
|
});
|
|
17
30
|
await adapter.postMessage(dest, { text: `*Projects*\n${lines.join('\n')}` });
|
|
@@ -28,7 +41,7 @@ export function createRegisterHandler(router) {
|
|
|
28
41
|
await adapter.bindProjectConduit(project, ctx.channelId);
|
|
29
42
|
if (ctx.messageRef) {
|
|
30
43
|
await adapter.updateMessage(ctx.messageRef, {
|
|
31
|
-
text:
|
|
44
|
+
text: `${Icons.ok} Registered for \`${project}\` task notifications.`,
|
|
32
45
|
}).catch(() => { });
|
|
33
46
|
}
|
|
34
47
|
}
|
|
@@ -48,11 +61,11 @@ export function createRegisterHandler(router) {
|
|
|
48
61
|
const project = args[0];
|
|
49
62
|
const projects = projectStore.list().map(p => p.id);
|
|
50
63
|
if (!projects.includes(project)) {
|
|
51
|
-
await adapter.postMessage(dest, { text:
|
|
64
|
+
await adapter.postMessage(dest, { text: `${Icons.error} Unknown project: \`${project}\`\nAvailable: ${projects.map(p => `\`${p}\``).join(', ')}` });
|
|
52
65
|
return;
|
|
53
66
|
}
|
|
54
67
|
await adapter.bindProjectConduit(project, channel);
|
|
55
|
-
await adapter.postMessage(dest, { text:
|
|
68
|
+
await adapter.postMessage(dest, { text: `${Icons.ok} This channel is now registered for project \`${project}\` task notifications.` });
|
|
56
69
|
return;
|
|
57
70
|
}
|
|
58
71
|
const registrations = await adapter.getProjectConduits();
|
|
@@ -103,11 +116,11 @@ export async function handleUnregisterCmd(channel, adapter, trimmedMessage) {
|
|
|
103
116
|
const registrations = await adapter.getProjectConduits();
|
|
104
117
|
const current = registrations[project] ?? null;
|
|
105
118
|
if (!current || current !== channel) {
|
|
106
|
-
await adapter.postMessage(dest, { text:
|
|
119
|
+
await adapter.postMessage(dest, { text: `${Icons.error} This channel is not registered for project \`${project}\`.` });
|
|
107
120
|
return;
|
|
108
121
|
}
|
|
109
122
|
await adapter.unbindProjectConduit(project);
|
|
110
|
-
await adapter.postMessage(dest, { text:
|
|
123
|
+
await adapter.postMessage(dest, { text: `${Icons.ok} Unregistered this channel from project \`${project}\`.` });
|
|
111
124
|
}
|
|
112
125
|
function buildProjectDirModal(channel) {
|
|
113
126
|
const machines = Object.keys(getMachineRegistry());
|
|
@@ -154,7 +167,7 @@ export function createProjectDirHandler(router) {
|
|
|
154
167
|
return;
|
|
155
168
|
await projectDirRepo.setProjectDir(project, machine, dirPath);
|
|
156
169
|
await adapter.postMessage(modalDest, {
|
|
157
|
-
text:
|
|
170
|
+
text: `${Icons.ok} \`${project}\` on \`${machine}\` → \`${dirPath}\``,
|
|
158
171
|
});
|
|
159
172
|
},
|
|
160
173
|
}],
|
|
@@ -165,19 +178,19 @@ export function createProjectDirHandler(router) {
|
|
|
165
178
|
const args = trimmedMessage.split(/\s+/).slice(1);
|
|
166
179
|
if (args.length > 0) {
|
|
167
180
|
if (args.length < 2) {
|
|
168
|
-
await adapter.postMessage(dest, { text:
|
|
181
|
+
await adapter.postMessage(dest, { text: `${Icons.error} Usage: \`!project-dir <project> <machine> <path>\` or \`!project-dir <project> <machine> --remove\`` });
|
|
169
182
|
return;
|
|
170
183
|
}
|
|
171
184
|
const [project, machine] = args;
|
|
172
185
|
const validMachines = Object.keys(getMachineRegistry());
|
|
173
186
|
if (!validMachines.includes(machine)) {
|
|
174
|
-
await adapter.postMessage(dest, { text:
|
|
187
|
+
await adapter.postMessage(dest, { text: `${Icons.error} Unknown machine: \`${machine}\`\nValid: ${validMachines.map(m => `\`${m}\``).join(', ')}` });
|
|
175
188
|
return;
|
|
176
189
|
}
|
|
177
190
|
if (args.length === 2 || args[2] === '--remove') {
|
|
178
191
|
if (args[2] === '--remove') {
|
|
179
192
|
await projectDirRepo.removeProjectDir(project, machine);
|
|
180
|
-
await adapter.postMessage(dest, { text:
|
|
193
|
+
await adapter.postMessage(dest, { text: `${Icons.ok} Removed \`${project}\` directory on \`${machine}\`.` });
|
|
181
194
|
}
|
|
182
195
|
else {
|
|
183
196
|
const dir = await projectDirRepo.getProjectDir(project, machine);
|
|
@@ -192,7 +205,7 @@ export function createProjectDirHandler(router) {
|
|
|
192
205
|
}
|
|
193
206
|
const dirPath = args.slice(2).join(' ');
|
|
194
207
|
await projectDirRepo.setProjectDir(project, machine, dirPath);
|
|
195
|
-
await adapter.postMessage(dest, { text:
|
|
208
|
+
await adapter.postMessage(dest, { text: `${Icons.ok} \`${project}\` on \`${machine}\` → \`${dirPath}\`` });
|
|
196
209
|
return;
|
|
197
210
|
}
|
|
198
211
|
const allDirs = await projectDirRepo.getAllProjectDirs();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { formatCostReport, checkBudget, setBudget } from '../../../domain/costs/cost-tracker.js';
|
|
2
|
+
import { Icons } from '../../../core/icons.js';
|
|
2
3
|
export async function handleCostCmd(channel, adapter, trimmedMessage) {
|
|
3
4
|
const dest = { type: 'interactive-reply', conduit: channel, sessionId: '' };
|
|
4
5
|
const project = trimmedMessage.split(/\s+/).slice(1).join(' ').trim() || null;
|
|
@@ -20,5 +21,5 @@ export async function handleBudgetCmd(channel, adapter, trimmedMessage) {
|
|
|
20
21
|
daily_usd: daily ? parseFloat(daily) : undefined,
|
|
21
22
|
monthly_usd: monthly ? parseFloat(monthly) : undefined,
|
|
22
23
|
});
|
|
23
|
-
await adapter.postMessage(dest, { text:
|
|
24
|
+
await adapter.postMessage(dest, { text: `${Icons.ok} Budget updated: $${result.daily_usd}/day, $${result.monthly_usd}/month` });
|
|
24
25
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getOnlineDevices } from '../../../domain/remote/client-manager.js';
|
|
2
2
|
import { getMachineRegistry } from '../../../domain/tasks/dispatch-utils.js';
|
|
3
|
+
import { Icons } from '../../../core/icons.js';
|
|
3
4
|
function formatTimeAgo(ms) {
|
|
4
5
|
const seconds = Math.floor(ms / 1000);
|
|
5
6
|
if (seconds < 60)
|
|
@@ -25,10 +26,10 @@ function buildDevicesText() {
|
|
|
25
26
|
if (online) {
|
|
26
27
|
const connAgo = formatTimeAgo(now - online.connectedAt.getTime());
|
|
27
28
|
const hbAgo = formatTimeAgo(now - online.lastHeartbeat.getTime());
|
|
28
|
-
lines.push(
|
|
29
|
+
lines.push(`${Icons.ok} \`${name}\` ${online.platform} connected ${connAgo} heartbeat ${hbAgo}`);
|
|
29
30
|
}
|
|
30
31
|
else {
|
|
31
|
-
lines.push(
|
|
32
|
+
lines.push(`${Icons.error} \`${name}\` offline`);
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
if (knownNames.size === 0) {
|
|
@@ -3,6 +3,7 @@
|
|
|
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
|
+
import { Icons } from '../../../core/icons.js';
|
|
6
7
|
const USAGE = 'Usage: `!dispatch <threadId> [--profile <name>]`';
|
|
7
8
|
export async function handleDispatchCmd(channel, adapter, trimmedMessage) {
|
|
8
9
|
const dest = { type: 'interactive-reply', conduit: channel, sessionId: '' };
|
|
@@ -14,16 +15,16 @@ export async function handleDispatchCmd(channel, adapter, trimmedMessage) {
|
|
|
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} Thread not found: \`${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} Thread \`${threadId}\` is not a dispatch thread.` });
|
|
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} Dispatch \`${threadId.substring(0, 12)}\` is \`${thread.status}\`. Profile override will only apply if the thread is continued via \`!thread add\`.${thread.status === 'completed' ? '' : ''}`,
|
|
27
28
|
});
|
|
28
29
|
// Allow the change to go through even for completed threads — it takes effect if continued.
|
|
29
30
|
}
|
|
@@ -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} Unknown profile: \`${profileName}\`. Use \`!profile\` to see available profiles.` });
|
|
42
43
|
return;
|
|
43
44
|
}
|
|
44
45
|
await threadStore.mutate(threadId, (t) => {
|
|
45
46
|
t.metadata = { ...t.metadata, profileOverride: profileName };
|
|
46
47
|
});
|
|
47
48
|
await adapter.postMessage(dest, {
|
|
48
|
-
text:
|
|
49
|
+
text: `${Icons.ok} Dispatch \`${threadId.substring(0, 12)}\`: \`profileOverride\` set to \`${profileName}\`. Next step will use this profile.`,
|
|
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,5 @@
|
|
|
1
1
|
import { createLogger } from '../../../core/log.js';
|
|
2
|
+
import { Icons } from '../../../core/icons.js';
|
|
2
3
|
import { handleOrientCmd } from './orient.js';
|
|
3
4
|
import { handleThreadCmd } from './thread.js';
|
|
4
5
|
import { createScheduleHandler } from './schedule.js';
|
|
@@ -20,8 +21,8 @@ const log = createLogger('command-handler');
|
|
|
20
21
|
* - If handler returns CommandResult (with `text`), dispatch layer delivers the message.
|
|
21
22
|
* - If handler returns void, it already posted its own response (backward compat).
|
|
22
23
|
*/
|
|
23
|
-
async function executeCommand(handler, channel, adapter, trimmedMessage, _commandName,
|
|
24
|
-
const result = await handler(channel, adapter, trimmedMessage,
|
|
24
|
+
async function executeCommand(handler, channel, adapter, trimmedMessage, _commandName, threadAnchorId) {
|
|
25
|
+
const result = await handler(channel, adapter, trimmedMessage, threadAnchorId);
|
|
25
26
|
const cmdDest = { type: 'interactive-reply', conduit: channel, sessionId: '' };
|
|
26
27
|
if (result && typeof result === 'object' && 'text' in result) {
|
|
27
28
|
if (result.actions && result.actions.length > 0) {
|
|
@@ -45,13 +46,13 @@ async function executeCommand(handler, channel, adapter, trimmedMessage, _comman
|
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
|
-
const catchHandlerError = (promise, cmd, channel, adapter,
|
|
49
|
+
const catchHandlerError = (promise, cmd, channel, adapter, threadAnchorId) => {
|
|
49
50
|
Promise.resolve(promise).catch(err => {
|
|
50
51
|
log.error(`Error in ${cmd}:`, err?.message || err);
|
|
51
52
|
if (err?.data)
|
|
52
53
|
log.error(`Slack error data:`, JSON.stringify(err.data));
|
|
53
54
|
const cmdDest = { type: 'interactive-reply', conduit: channel, sessionId: '' };
|
|
54
|
-
adapter.postMessage(cmdDest, { text:
|
|
55
|
+
adapter.postMessage(cmdDest, { text: `${Icons.error} Command error: ${err?.message || 'unknown error'}` }).catch(() => { });
|
|
55
56
|
});
|
|
56
57
|
};
|
|
57
58
|
export function registerCommands(deps) {
|
|
@@ -69,8 +70,8 @@ export function registerCommands(deps) {
|
|
|
69
70
|
const handleScheduleCmd = createScheduleHandler(deps.scheduler, router);
|
|
70
71
|
const EXACT_COMMANDS = {
|
|
71
72
|
'!help': (ch, ad, _msg) => handleHelpCmd(ch, ad),
|
|
72
|
-
'!new': (ch, ad, _msg,
|
|
73
|
-
'!newq': (ch, ad, _msg,
|
|
73
|
+
'!new': (ch, ad, _msg, threadAnchorId) => handleNewCmd(ch, ad, {}, threadAnchorId),
|
|
74
|
+
'!newq': (ch, ad, _msg, threadAnchorId) => handleNewCmd(ch, ad, { skipHook: true }, threadAnchorId),
|
|
74
75
|
'!cancel': (ch, ad, msg) => handleCancelCmd(ch, ad, msg),
|
|
75
76
|
'!mode': (ch, ad, _msg) => handleModeCmd(ch, ad),
|
|
76
77
|
'!skills': (ch, ad, _msg) => handleSkillsCmd(ch, ad),
|
|
@@ -105,24 +106,24 @@ export function registerCommands(deps) {
|
|
|
105
106
|
{ prefix: '!sendFile', handler: handleSendFileCmd },
|
|
106
107
|
{ prefix: '!dispatch', handler: handleDispatchCmd },
|
|
107
108
|
];
|
|
108
|
-
const dispatchFn = function dispatchCommand(trimmedMessage, channel, adapter,
|
|
109
|
+
const dispatchFn = function dispatchCommand(trimmedMessage, channel, adapter, threadAnchorId) {
|
|
109
110
|
if (!trimmedMessage)
|
|
110
111
|
return false;
|
|
111
112
|
const exact = EXACT_COMMANDS[trimmedMessage];
|
|
112
113
|
if (exact) {
|
|
113
|
-
catchHandlerError(executeCommand(exact, channel, adapter, trimmedMessage, trimmedMessage,
|
|
114
|
+
catchHandlerError(executeCommand(exact, channel, adapter, trimmedMessage, trimmedMessage, threadAnchorId), trimmedMessage, channel, adapter, threadAnchorId);
|
|
114
115
|
return true;
|
|
115
116
|
}
|
|
116
117
|
for (const { prefix, handler } of PREFIX_COMMANDS) {
|
|
117
118
|
if (trimmedMessage.startsWith(prefix)) {
|
|
118
|
-
catchHandlerError(executeCommand(handler, channel, adapter, trimmedMessage, prefix,
|
|
119
|
+
catchHandlerError(executeCommand(handler, channel, adapter, trimmedMessage, prefix, threadAnchorId), prefix, channel, adapter, threadAnchorId);
|
|
119
120
|
return true;
|
|
120
121
|
}
|
|
121
122
|
}
|
|
122
123
|
if (trimmedMessage.startsWith('!')) {
|
|
123
124
|
const cmd = trimmedMessage.split(/\s+/)[0];
|
|
124
125
|
const cmdDest = { type: 'interactive-reply', conduit: channel, sessionId: '' };
|
|
125
|
-
adapter.postMessage(cmdDest, { text:
|
|
126
|
+
adapter.postMessage(cmdDest, { text: `${Icons.error} Unknown command: \`${cmd}\`. Run \`!help\` for available commands.` });
|
|
126
127
|
return true;
|
|
127
128
|
}
|
|
128
129
|
return false;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Icons } from '../../../core/icons.js';
|
|
1
2
|
import { switchMode, getActiveBackend, setActiveBackend, getClaudeModel, setClaudeModel, getActiveProfile, setActiveProfile, clearChannelProfile, getDefaultAgent, setDefaultAgent } from '../../../domain/agents/index.js';
|
|
2
3
|
import { getDefaultProfileName, listProfiles, resolveProfile } from '../../../domain/agents/profile-manager.js';
|
|
3
4
|
import { getDisplaySkillGroups } from '../../../domain/memory/skill-scanner.js';
|
|
@@ -24,7 +25,7 @@ function formatProfileList(channel) {
|
|
|
24
25
|
export async function handleModeCmd(channel, adapter) {
|
|
25
26
|
const { newMode } = switchMode();
|
|
26
27
|
const dest = { type: 'interactive-reply', conduit: channel, sessionId: '' };
|
|
27
|
-
await adapter.postMessage(dest, { text:
|
|
28
|
+
await adapter.postMessage(dest, { text: `${Icons.refresh} Switched to *${newMode === 'api' ? 'API' : 'Plan'}* mode` });
|
|
28
29
|
}
|
|
29
30
|
export async function handleBackendCmd(channel, adapter, trimmedMessage) {
|
|
30
31
|
const arg = trimmedMessage.split(/\s+/)[1];
|
|
@@ -32,7 +33,7 @@ export async function handleBackendCmd(channel, adapter, trimmedMessage) {
|
|
|
32
33
|
setActiveBackend(newBackend);
|
|
33
34
|
const dest = { type: 'interactive-reply', conduit: channel, sessionId: '' };
|
|
34
35
|
await adapter.postMessage(dest, {
|
|
35
|
-
text:
|
|
36
|
+
text: `${Icons.refresh} Backend: *${newBackend === 'claude' ? 'Claude Code' : 'Codex'}*`,
|
|
36
37
|
});
|
|
37
38
|
}
|
|
38
39
|
export async function handleModelCmd(channel, adapter, trimmedMessage) {
|
|
@@ -44,11 +45,11 @@ export async function handleModelCmd(channel, adapter, trimmedMessage) {
|
|
|
44
45
|
}
|
|
45
46
|
const model = args.join(' ').trim();
|
|
46
47
|
if (!model) {
|
|
47
|
-
await adapter.postMessage(dest, { text:
|
|
48
|
+
await adapter.postMessage(dest, { text: `${Icons.error} Usage: \`!model <model-name>\`` });
|
|
48
49
|
return;
|
|
49
50
|
}
|
|
50
51
|
setClaudeModel(model);
|
|
51
|
-
await adapter.postMessage(dest, { text:
|
|
52
|
+
await adapter.postMessage(dest, { text: `${Icons.ok} Claude model set to *${getClaudeModel()}*` });
|
|
52
53
|
}
|
|
53
54
|
const MAX_PROFILE_BUTTONS = 10;
|
|
54
55
|
function buildProfileText(channel) {
|
|
@@ -79,7 +80,7 @@ export function createProfileHandler(router) {
|
|
|
79
80
|
const { name, channel } = JSON.parse(ctx.value);
|
|
80
81
|
resolveProfile(name);
|
|
81
82
|
setActiveProfile(name, channel);
|
|
82
|
-
const text =
|
|
83
|
+
const text = `${Icons.ok} Channel profile set to *${name}*\n${formatProfileList(channel)}`;
|
|
83
84
|
if (ctx.messageRef) {
|
|
84
85
|
await adapter.updateMessage(ctx.messageRef, {
|
|
85
86
|
text,
|
|
@@ -94,7 +95,7 @@ export function createProfileHandler(router) {
|
|
|
94
95
|
catch (error) {
|
|
95
96
|
if (ctx.messageRef) {
|
|
96
97
|
await adapter.updateMessage(ctx.messageRef, {
|
|
97
|
-
text:
|
|
98
|
+
text: `${Icons.error} ${error.message}`,
|
|
98
99
|
}).catch(() => { });
|
|
99
100
|
}
|
|
100
101
|
}
|
|
@@ -113,24 +114,24 @@ export function createProfileHandler(router) {
|
|
|
113
114
|
if (args[0] === 'reset') {
|
|
114
115
|
clearChannelProfile(channel);
|
|
115
116
|
const fallback = getActiveProfile() || getDefaultProfileName();
|
|
116
|
-
await adapter.postMessage(dest, { text:
|
|
117
|
+
await adapter.postMessage(dest, { text: `${Icons.ok} Channel profile cleared, using global: *${fallback}*` });
|
|
117
118
|
await handleNewCmd(channel, adapter, { skipHook: true });
|
|
118
119
|
return;
|
|
119
120
|
}
|
|
120
121
|
if (args[0] === 'global') {
|
|
121
122
|
if (args.length < 2) {
|
|
122
|
-
await adapter.postMessage(dest, { text:
|
|
123
|
+
await adapter.postMessage(dest, { text: `${Icons.error} Usage: \`!profile global <name>\`` });
|
|
123
124
|
return;
|
|
124
125
|
}
|
|
125
126
|
const profileName = args[1];
|
|
126
127
|
try {
|
|
127
128
|
resolveProfile(profileName);
|
|
128
129
|
setActiveProfile(profileName);
|
|
129
|
-
await adapter.postMessage(dest, { text:
|
|
130
|
+
await adapter.postMessage(dest, { text: `${Icons.ok} Global profile set to *${profileName}*\n${formatProfileList(channel)}` });
|
|
130
131
|
await handleNewCmd(channel, adapter, { skipHook: true });
|
|
131
132
|
}
|
|
132
133
|
catch (error) {
|
|
133
|
-
await adapter.postMessage(dest, { text:
|
|
134
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${error.message}` });
|
|
134
135
|
}
|
|
135
136
|
return;
|
|
136
137
|
}
|
|
@@ -138,11 +139,11 @@ export function createProfileHandler(router) {
|
|
|
138
139
|
try {
|
|
139
140
|
resolveProfile(profileName);
|
|
140
141
|
setActiveProfile(profileName, channel);
|
|
141
|
-
await adapter.postMessage(dest, { text:
|
|
142
|
+
await adapter.postMessage(dest, { text: `${Icons.ok} Channel profile set to *${profileName}*\n${formatProfileList(channel)}` });
|
|
142
143
|
await handleNewCmd(channel, adapter, { skipHook: true });
|
|
143
144
|
}
|
|
144
145
|
catch (error) {
|
|
145
|
-
await adapter.postMessage(dest, { text:
|
|
146
|
+
await adapter.postMessage(dest, { text: `${Icons.error} ${error.message}` });
|
|
146
147
|
}
|
|
147
148
|
return;
|
|
148
149
|
}
|
|
@@ -220,7 +221,7 @@ export function createAgentHandler(router) {
|
|
|
220
221
|
return;
|
|
221
222
|
setDefaultAgent(name);
|
|
222
223
|
const claudeAgentStr = agentDef.claudeAgent ? ` · agent:${agentDef.claudeAgent}` : '';
|
|
223
|
-
const text =
|
|
224
|
+
const text = `${Icons.ok} Default agent set to *${name}* (${agentDef.profile}${claudeAgentStr})`;
|
|
224
225
|
if (ctx.messageRef) {
|
|
225
226
|
await adapter.updateMessage(ctx.messageRef, {
|
|
226
227
|
text,
|
|
@@ -238,9 +239,9 @@ export function createAgentHandler(router) {
|
|
|
238
239
|
setDefaultAgent(null);
|
|
239
240
|
if (ctx.messageRef) {
|
|
240
241
|
await adapter.updateMessage(ctx.messageRef, {
|
|
241
|
-
text:
|
|
242
|
+
text: `${Icons.ok} Default agent disabled.`,
|
|
242
243
|
richBlocks: [
|
|
243
|
-
{ type: 'section', text:
|
|
244
|
+
{ type: 'section', text: `${Icons.ok} Default agent disabled.` },
|
|
244
245
|
{ type: 'actions', elements: buildAgentButtons() },
|
|
245
246
|
],
|
|
246
247
|
}).catch(() => { });
|
|
@@ -263,18 +264,18 @@ export function createAgentHandler(router) {
|
|
|
263
264
|
const name = args.split(/\s+/)[0];
|
|
264
265
|
if (name === 'off' || name === 'none' || name === 'disable') {
|
|
265
266
|
setDefaultAgent(null);
|
|
266
|
-
await adapter.postMessage(dest, { text:
|
|
267
|
+
await adapter.postMessage(dest, { text: `${Icons.ok} Default agent disabled.` });
|
|
267
268
|
return;
|
|
268
269
|
}
|
|
269
270
|
const agentDef = getAgent(name);
|
|
270
271
|
if (!agentDef) {
|
|
271
272
|
const available = listAgents().map(a => `\`${a.name}\``).join(', ');
|
|
272
|
-
await adapter.postMessage(dest, { text:
|
|
273
|
+
await adapter.postMessage(dest, { text: `${Icons.error} Unknown agent: \`${name}\`\nAvailable: ${available}` });
|
|
273
274
|
return;
|
|
274
275
|
}
|
|
275
276
|
setDefaultAgent(name);
|
|
276
277
|
const claudeAgentStr = agentDef.claudeAgent ? ` · agent:${agentDef.claudeAgent}` : '';
|
|
277
|
-
await adapter.postMessage(dest, { text:
|
|
278
|
+
await adapter.postMessage(dest, { text: `${Icons.ok} Default agent set to *${name}* (${agentDef.profile}${claudeAgentStr})` });
|
|
278
279
|
return;
|
|
279
280
|
}
|
|
280
281
|
const text = buildAgentText();
|
|
@@ -1,6 +1,7 @@
|
|
|
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';
|
|
4
5
|
const NVTOP_REFRESH_MS = 1000;
|
|
5
6
|
const NVTOP_HISTORY_LIMIT = 12;
|
|
6
7
|
const activeNvtopMonitors = new Map();
|
|
@@ -20,7 +21,7 @@ async function updateNvtopMessage(channel, adapter) {
|
|
|
20
21
|
const snapshot = await queryGpuSnapshot(active.machine);
|
|
21
22
|
rememberGpuHistory(active.historyByGpu, snapshot);
|
|
22
23
|
const text = renderGpuSnapshot(snapshot, active.historyByGpu, NVTOP_REFRESH_MS / 1000);
|
|
23
|
-
await adapter.updateMessage({ channel, messageId: active.trackingTs }, { text });
|
|
24
|
+
await adapter.updateMessage({ conduit: channel, messageId: active.trackingTs }, { text });
|
|
24
25
|
}
|
|
25
26
|
export async function handleNvidiaSmiCmd(channel, adapter, trimmedMessage) {
|
|
26
27
|
const args = trimmedMessage.split(/\s+/).slice(1);
|
|
@@ -29,15 +30,15 @@ export async function handleNvidiaSmiCmd(channel, adapter, trimmedMessage) {
|
|
|
29
30
|
const reg = getMachineRegistry()[machine];
|
|
30
31
|
if (!reg) {
|
|
31
32
|
const valid = Object.keys(getMachineRegistry()).filter(m => getMachineRegistry()[m].gpuCount > 0).map(m => `\`${m}\``).join(', ');
|
|
32
|
-
await adapter.postMessage(dest, { text:
|
|
33
|
+
await adapter.postMessage(dest, { text: `${Icons.error} Unknown machine: \`${machine}\`\nGPU machines: ${valid}` });
|
|
33
34
|
return;
|
|
34
35
|
}
|
|
35
36
|
if (reg.gpuCount === 0) {
|
|
36
|
-
await adapter.postMessage(dest, { text:
|
|
37
|
+
await adapter.postMessage(dest, { text: `${Icons.error} \`${machine}\` has no GPU.` });
|
|
37
38
|
return;
|
|
38
39
|
}
|
|
39
40
|
if (!isDeviceOnline(machine)) {
|
|
40
|
-
await adapter.postMessage(dest, { text:
|
|
41
|
+
await adapter.postMessage(dest, { text: `${Icons.error} Device \`${machine}\` is not online.` });
|
|
41
42
|
return;
|
|
42
43
|
}
|
|
43
44
|
try {
|
|
@@ -46,7 +47,7 @@ export async function handleNvidiaSmiCmd(channel, adapter, trimmedMessage) {
|
|
|
46
47
|
await adapter.postMessage(dest, { text: `*nvidia-smi* on \`${machine}\`\n\`\`\`\n${output}\n\`\`\`` });
|
|
47
48
|
}
|
|
48
49
|
catch (err) {
|
|
49
|
-
await adapter.postMessage(dest, { text:
|
|
50
|
+
await adapter.postMessage(dest, { text: `${Icons.error} nvidia-smi failed on \`${machine}\`: ${err.message}` });
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
53
|
export async function handleNvtopCmd(channel, adapter, trimmedMessage) {
|
|
@@ -60,7 +61,7 @@ export async function handleNvtopCmd(channel, adapter, trimmedMessage) {
|
|
|
60
61
|
}
|
|
61
62
|
clearInterval(active.interval);
|
|
62
63
|
activeNvtopMonitors.delete(channel);
|
|
63
|
-
await adapter.postMessage(dest, { text:
|
|
64
|
+
await adapter.postMessage(dest, { text: `${Icons.stopped} nvtop stopped on \`${active.machine}\`.` });
|
|
64
65
|
return;
|
|
65
66
|
}
|
|
66
67
|
if (activeNvtopMonitors.has(channel)) {
|
|
@@ -71,11 +72,11 @@ export async function handleNvtopCmd(channel, adapter, trimmedMessage) {
|
|
|
71
72
|
const reg = getMachineRegistry()[machine];
|
|
72
73
|
if (!reg) {
|
|
73
74
|
const valid = Object.keys(getMachineRegistry()).filter(m => getMachineRegistry()[m].gpuCount > 0).map(m => `\`${m}\``).join(', ');
|
|
74
|
-
await adapter.postMessage(dest, { text:
|
|
75
|
+
await adapter.postMessage(dest, { text: `${Icons.error} Unknown machine: \`${machine}\`\nGPU machines: ${valid}` });
|
|
75
76
|
return;
|
|
76
77
|
}
|
|
77
78
|
if (reg.gpuCount === 0) {
|
|
78
|
-
await adapter.postMessage(dest, { text:
|
|
79
|
+
await adapter.postMessage(dest, { text: `${Icons.error} nvtop monitoring is not supported on \`${machine}\` yet.` });
|
|
79
80
|
return;
|
|
80
81
|
}
|
|
81
82
|
try {
|
|
@@ -100,6 +101,6 @@ export async function handleNvtopCmd(channel, adapter, trimmedMessage) {
|
|
|
100
101
|
});
|
|
101
102
|
}
|
|
102
103
|
catch (err) {
|
|
103
|
-
await adapter.postMessage(dest, { text:
|
|
104
|
+
await adapter.postMessage(dest, { text: `${Icons.error} nvtop failed on \`${machine}\`: ${err.message}` });
|
|
104
105
|
}
|
|
105
106
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getMachineRegistry } from '../../../domain/tasks/dispatch-utils.js';
|
|
2
|
+
import { Icons } from '../../../core/icons.js';
|
|
2
3
|
import { statSync, existsSync, mkdirSync, unlinkSync } from 'fs';
|
|
3
4
|
import { execFile } from 'child_process';
|
|
4
5
|
import * as os from 'os';
|
|
@@ -17,16 +18,16 @@ async function sendLocalFile(channel, adapter, reg, filePath, machine) {
|
|
|
17
18
|
resolved = path.resolve(reg.cortexPath, filePath);
|
|
18
19
|
}
|
|
19
20
|
if (!existsSync(resolved)) {
|
|
20
|
-
await adapter.postMessage(dest, { text:
|
|
21
|
+
await adapter.postMessage(dest, { text: `${Icons.error} File not found: \`${resolved}\`` });
|
|
21
22
|
return;
|
|
22
23
|
}
|
|
23
24
|
const stat = statSync(resolved);
|
|
24
25
|
if (!stat.isFile()) {
|
|
25
|
-
await adapter.postMessage(dest, { text:
|
|
26
|
+
await adapter.postMessage(dest, { text: `${Icons.error} Not a file: \`${resolved}\`` });
|
|
26
27
|
return;
|
|
27
28
|
}
|
|
28
29
|
await adapter.uploadFile(dest, resolved, { filename: path.basename(resolved) });
|
|
29
|
-
await adapter.postMessage(dest, { text:
|
|
30
|
+
await adapter.postMessage(dest, { text: `${Icons.ok} Sent \`${path.basename(resolved)}\` (${(stat.size / 1024).toFixed(1)} KB) from ${machine}` });
|
|
30
31
|
}
|
|
31
32
|
async function sendRemoteFile(channel, adapter, reg, filePath, machine) {
|
|
32
33
|
const dest = { type: 'interactive-reply', conduit: channel, sessionId: '' };
|
|
@@ -60,13 +61,13 @@ async function sendRemoteFile(channel, adapter, reg, filePath, machine) {
|
|
|
60
61
|
});
|
|
61
62
|
}
|
|
62
63
|
catch (err) {
|
|
63
|
-
await adapter.postMessage(dest, { text:
|
|
64
|
+
await adapter.postMessage(dest, { text: `${Icons.error} Failed to fetch from ${machine}: ${err.message}` });
|
|
64
65
|
return;
|
|
65
66
|
}
|
|
66
67
|
try {
|
|
67
68
|
const tmpStat = statSync(localTmp);
|
|
68
69
|
await adapter.uploadFile(dest, localTmp, { filename: fileName });
|
|
69
|
-
await adapter.postMessage(dest, { text:
|
|
70
|
+
await adapter.postMessage(dest, { text: `${Icons.ok} Sent \`${fileName}\` (${(tmpStat.size / 1024).toFixed(1)} KB) from ${machine}` });
|
|
70
71
|
}
|
|
71
72
|
finally {
|
|
72
73
|
try {
|
|
@@ -86,7 +87,7 @@ export async function handleSendFileCmd(channel, adapter, trimmedMessage) {
|
|
|
86
87
|
const filePath = args.slice(1).join(' ');
|
|
87
88
|
const reg = getMachineRegistry()[machine];
|
|
88
89
|
if (!reg) {
|
|
89
|
-
await adapter.postMessage(dest, { text:
|
|
90
|
+
await adapter.postMessage(dest, { text: `${Icons.error} Unknown machine: \`${machine}\`. Known: ${Object.keys(getMachineRegistry()).join(', ')}` });
|
|
90
91
|
return;
|
|
91
92
|
}
|
|
92
93
|
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>;
|