@cortex-agent/server 2026.6.22 → 2026.7.30
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/README.md +25 -13
- package/defaults/.claude/settings.json +4 -0
- package/defaults/config/CORTEX.md +9 -0
- package/defaults/config/hooks/01-sensitive-file-edit.json +11 -0
- package/defaults/config/hooks/02-tasks-yaml-guard.json +11 -0
- package/defaults/config/hooks/03-ask-user-question-hook.json +19 -0
- package/defaults/config/hooks/04-exit-plan-mode-hook.json +19 -0
- package/defaults/config/hooks/05-memory-ref-tracker.json +10 -0
- package/defaults/config/hooks/06-rules-loader.json +10 -0
- package/defaults/config/hooks/07-session-activity-tracker.json +10 -0
- package/defaults/config/hooks/08-cortex-md-injector-post-tool.json +10 -0
- package/defaults/config/hooks/09-permission-request-auto-allow.json +11 -0
- package/defaults/config/hooks/10-cortex-md-injector-session-start.json +10 -0
- package/defaults/config/hooks/11-task-status-check.json +14 -0
- package/defaults/config/hooks/12-session-new-hook.json +11 -0
- package/defaults/config/hooks/CORTEX.md +18 -0
- package/defaults/config/thread-templates/agents/coder-reviewer.json +25 -0
- package/defaults/config/thread-templates/agents/coder.json +30 -0
- package/defaults/config/thread-templates/agents/direct-review.json +17 -0
- package/defaults/config/thread-templates/agents/direct-web.json +16 -0
- package/defaults/config/thread-templates/agents/direct.json +16 -0
- package/defaults/config/thread-templates/agents/director.json +14 -0
- package/defaults/config/thread-templates/agents/doc-reviewer.json +14 -0
- package/defaults/config/thread-templates/agents/doc-writer.json +25 -0
- package/defaults/config/thread-templates/agents/executor-reviewer.json +14 -0
- package/defaults/config/thread-templates/agents/executor.json +25 -0
- package/defaults/config/thread-templates/agents/main.json +16 -0
- package/defaults/config/thread-templates/agents/manager.json +17 -0
- package/defaults/config/thread-templates/agents/scheduler-main.json +16 -0
- package/defaults/config/thread-templates/shells/worker-review.json +19 -0
- package/defaults/config/thread-templates/templates/coder-review.json +53 -0
- package/defaults/config/thread-templates/templates/default.json +10 -0
- package/defaults/config/thread-templates/templates/doc-review.json +6 -0
- package/defaults/config/thread-templates/templates/execute-review.json +6 -0
- package/defaults/config/thread-templates/templates/manager.json +11 -0
- package/defaults/config/thread-templates/templates/scheduler.json +19 -0
- package/defaults/context/decisions/DR-0012.md +1 -1
- package/defaults/context/user/CORTEX.md +2 -2
- package/defaults/gitignore +3 -0
- package/defaults/hooks/CORTEX.md +18 -0
- package/defaults/hooks/ask-user-question-hook.mjs +1 -0
- package/defaults/hooks/cortex-hook-api.mjs +84 -0
- package/defaults/hooks/cortex-md-injector.mjs +99 -49
- package/defaults/hooks/exit-plan-mode-hook.mjs +1 -0
- package/defaults/hooks/memory-ref-tracker.mjs +1 -0
- package/defaults/hooks/new-session-hook.mjs +1 -0
- package/defaults/hooks/post-task-hook.mjs +1 -0
- package/defaults/hooks/rules-loader.mjs +1 -0
- package/defaults/hooks/sensitive-file-edit.mjs +1 -0
- package/defaults/hooks/session-activity-tracker.mjs +8 -100
- package/defaults/hooks/task-status-check.mjs +10 -10
- package/defaults/hooks/tasks-yaml-guard.mjs +1 -0
- package/defaults/mcp-config-web.json +11 -0
- package/defaults/pi/agents/explore.md +9 -0
- package/defaults/pi/agents/general-purpose.md +6 -0
- package/defaults/pi/agents/plan.md +9 -0
- package/defaults/plugins/cortex-coder/.claude-plugin/plugin.json +1 -1
- package/defaults/plugins/cortex-coder/skills/cli-standards/SKILL.md +2 -2
- package/defaults/plugins/cortex-coder/skills/develop/SKILL.md +33 -0
- package/defaults/plugins/cortex-common/.claude-plugin/plugin.json +2 -2
- package/defaults/plugins/cortex-common/skills/debug-campaign/SKILL.md +16 -16
- package/defaults/plugins/cortex-common/skills/execute-method/SKILL.md +53 -0
- package/defaults/plugins/cortex-common/skills/execute-review-rubric/SKILL.md +102 -0
- package/defaults/plugins/cortex-common/skills/manager-method/SKILL.md +67 -0
- package/defaults/plugins/cortex-common/skills/solution-design/SKILL.md +3 -3
- package/defaults/plugins/cortex-feishu/.claude-plugin/plugin.json +5 -0
- package/defaults/plugins/cortex-feishu/skills/feishu-doc/SKILL.md +163 -0
- package/defaults/plugins/cortex-feishu/skills/feishu-doc/scripts/ensure-lark-cli.sh +53 -0
- package/defaults/plugins/cortex-stage-gate/.claude-plugin/plugin.json +2 -2
- package/defaults/plugins/cortex-stage-gate/skills/director-method/SKILL.md +54 -0
- package/defaults/plugins/cortex-stage-gate/skills/task/SKILL.md +132 -112
- package/defaults/plugins/cortex-system/.claude-plugin/plugin.json +1 -1
- package/defaults/plugins/cortex-system/skills/client-manage/SKILL.md +17 -10
- package/defaults/plugins/cortex-system/skills/feedback/SKILL.md +2 -2
- package/defaults/plugins/cortex-system/skills/orient/SKILL.md +1 -1
- package/defaults/plugins/cortex-system/skills/orient-project/SKILL.md +2 -2
- package/defaults/plugins/cortex-system/skills/thread/SKILL.md +66 -17
- package/defaults/prompts/directives/coder-reviewer.md +6 -6
- package/defaults/prompts/directives/coder.md +4 -29
- package/defaults/prompts/directives/director.md +4 -17
- package/defaults/prompts/directives/doc-reviewer.md +2 -35
- package/defaults/prompts/directives/doc-writer.md +2 -7
- package/defaults/prompts/directives/executor-reviewer.md +2 -39
- package/defaults/prompts/directives/executor.md +2 -7
- package/defaults/prompts/directives/manager.md +12 -27
- package/defaults/prompts/systemPrompts/coder.md +1 -1
- package/defaults/prompts/systemPrompts/direct.md +1 -1
- package/defaults/prompts/systemPrompts/web.md +5 -0
- package/defaults/prompts/systemPrompts/worker.md +1 -1
- package/dist/agent-adapter/bg-wait.d.ts +44 -0
- package/dist/agent-adapter/bg-wait.js +197 -0
- package/dist/agent-adapter/capabilities.d.ts +7 -1
- package/dist/agent-adapter/capabilities.js +18 -9
- package/dist/agent-adapter/claude/adapter-tui.d.ts +14 -0
- package/dist/agent-adapter/claude/adapter-tui.js +16 -0
- package/dist/agent-adapter/claude/adapter.d.ts +89 -5
- package/dist/agent-adapter/claude/adapter.js +410 -40
- package/dist/agent-adapter/claude/bg-task-tracker.d.ts +23 -8
- package/dist/agent-adapter/claude/bg-task-tracker.js +48 -19
- package/dist/agent-adapter/claude/compact-window.d.ts +9 -0
- package/dist/agent-adapter/claude/compact-window.js +46 -0
- package/dist/agent-adapter/claude/context-usage.d.ts +28 -0
- package/dist/agent-adapter/claude/context-usage.js +177 -0
- package/dist/agent-adapter/claude/defaults.d.ts +17 -3
- package/dist/agent-adapter/claude/defaults.js +25 -9
- package/dist/agent-adapter/claude/event-parser.d.ts +30 -0
- package/dist/agent-adapter/claude/event-parser.js +68 -4
- package/dist/agent-adapter/claude/hooks-builder.d.ts +23 -23
- package/dist/agent-adapter/claude/hooks-builder.js +63 -7
- package/dist/agent-adapter/claude/spawn-args.d.ts +25 -6
- package/dist/agent-adapter/claude/spawn-args.js +62 -22
- package/dist/agent-adapter/index.js +2 -4
- package/dist/agent-adapter/normalize/event-types.d.ts +8 -1
- package/dist/agent-adapter/normalize/event-types.js +1 -1
- package/dist/agent-adapter/normalize/tool-names.js +0 -9
- package/dist/agent-adapter/pi/adapter.d.ts +3 -33
- package/dist/agent-adapter/pi/adapter.js +461 -229
- package/dist/agent-adapter/pi/agent-dir.d.ts +6 -0
- package/dist/agent-adapter/pi/agent-dir.js +24 -14
- package/dist/agent-adapter/pi/defaults.d.ts +4 -0
- package/dist/agent-adapter/pi/defaults.js +11 -0
- package/dist/agent-adapter/pi/discovery.d.ts +4 -0
- package/dist/agent-adapter/pi/discovery.js +63 -0
- package/dist/agent-adapter/pi/event-parser.d.ts +13 -2
- package/dist/agent-adapter/pi/event-parser.js +139 -69
- package/dist/agent-adapter/pi/hook-bridge.d.ts +13 -28
- package/dist/agent-adapter/pi/hook-bridge.js +272 -167
- package/dist/agent-adapter/pi/mcp-bridge-logic.d.ts +24 -0
- package/dist/agent-adapter/pi/mcp-bridge-logic.js +39 -0
- package/dist/agent-adapter/pi/mcp-bridge.d.ts +13 -35
- package/dist/agent-adapter/pi/mcp-bridge.js +147 -137
- package/dist/agent-adapter/pi/pi-ext-types.d.ts +30 -0
- package/dist/agent-adapter/pi/pi-ext-types.js +2 -2
- package/dist/agent-adapter/pi/session-support.d.ts +96 -0
- package/dist/agent-adapter/pi/session-support.js +213 -0
- package/dist/agent-adapter/pi/spawn-args.d.ts +15 -0
- package/dist/agent-adapter/pi/spawn-args.js +46 -3
- package/dist/agent-adapter/pi/subagent.d.ts +68 -0
- package/dist/agent-adapter/pi/subagent.js +521 -0
- package/dist/agent-adapter/pi/tool-shims.d.ts +1 -13
- package/dist/agent-adapter/pi/tool-shims.js +182 -198
- package/dist/agent-adapter/pi/web-fetch.d.ts +13 -0
- package/dist/agent-adapter/pi/web-fetch.js +201 -0
- package/dist/agent-adapter/pi/web-search.d.ts +9 -0
- package/dist/agent-adapter/pi/web-search.js +513 -0
- package/dist/agent-adapter/types.d.ts +61 -10
- package/dist/agent-adapter/types.js +4 -4
- package/dist/core/atomic-write.d.ts +3 -5
- package/dist/core/atomic-write.js +26 -12
- package/dist/core/bg-held-sessions.d.ts +35 -0
- package/dist/core/bg-held-sessions.js +79 -0
- package/dist/core/calver.d.ts +1 -0
- package/dist/core/calver.js +29 -0
- package/dist/core/config-generator.d.ts +13 -2
- package/dist/core/config-generator.js +55 -5
- package/dist/core/debug-mode.d.ts +14 -0
- package/dist/core/debug-mode.js +32 -0
- package/dist/core/gateway-generator.js +15 -11
- package/dist/core/hook-bus.d.ts +23 -0
- package/dist/core/hook-bus.js +111 -0
- package/dist/core/hook-exec.d.ts +15 -0
- package/dist/core/hook-exec.js +90 -0
- package/dist/core/icons.d.ts +2 -0
- package/dist/core/icons.js +2 -0
- package/dist/core/locales/en.d.ts +30 -7
- package/dist/core/locales/en.js +4 -1
- package/dist/core/locales/slices/commands.d.ts +12 -2
- package/dist/core/locales/slices/commands.js +31 -7
- package/dist/core/locales/slices/init.d.ts +1 -1
- package/dist/core/locales/slices/init.js +2 -2
- package/dist/core/locales/slices/interactions.d.ts +6 -0
- package/dist/core/locales/slices/interactions.js +14 -0
- package/dist/core/locales/slices/status.d.ts +7 -3
- package/dist/core/locales/slices/status.js +16 -8
- package/dist/core/log.js +4 -3
- package/dist/core/paths.d.ts +9 -0
- package/dist/core/paths.js +20 -1
- package/dist/core/profile-generator.d.ts +2 -2
- package/dist/core/profile-generator.js +6 -9
- package/dist/core/running-executions.d.ts +10 -1
- package/dist/core/running-executions.js +10 -0
- package/dist/core/status-format.d.ts +14 -0
- package/dist/core/status-format.js +23 -1
- package/dist/core/task-node.d.ts +7 -0
- package/dist/core/task-node.js +29 -0
- package/dist/core/types/agent-types.d.ts +23 -2
- package/dist/core/types/agent-types.js +2 -2
- package/dist/core/types/thread-types.d.ts +90 -15
- package/dist/core/types/thread-types.js +3 -3
- package/dist/core/utils.d.ts +2 -2
- package/dist/core/utils.js +3 -3
- package/dist/domain/agents/config.d.ts +6 -5
- package/dist/domain/agents/config.js +17 -5
- package/dist/domain/agents/facade.d.ts +74 -10
- package/dist/domain/agents/facade.js +333 -62
- package/dist/domain/agents/index.d.ts +1 -0
- package/dist/domain/agents/index.js +1 -0
- package/dist/domain/agents/profile-manager.d.ts +14 -7
- package/dist/domain/agents/profile-manager.js +23 -7
- package/dist/domain/agents/profile-switch.d.ts +53 -0
- package/dist/domain/agents/profile-switch.js +79 -0
- package/dist/domain/costs/cost-tracker.d.ts +21 -1
- package/dist/domain/costs/cost-tracker.js +54 -26
- package/dist/domain/costs/gateway-manager.js +5 -3
- package/dist/domain/costs/rate-limit-throttle.d.ts +44 -19
- package/dist/domain/costs/rate-limit-throttle.js +331 -103
- package/dist/domain/costs/resume-registry.d.ts +17 -9
- package/dist/domain/costs/resume-registry.js +63 -8
- package/dist/domain/executions/log-tailer.d.ts +71 -0
- package/dist/domain/executions/log-tailer.js +195 -0
- package/dist/domain/executions/registry.d.ts +10 -1
- package/dist/domain/executions/registry.js +14 -0
- package/dist/domain/hooks/hook-view.d.ts +22 -0
- package/dist/domain/hooks/hook-view.js +38 -0
- package/dist/domain/mcp/core-server.d.ts +0 -1
- package/dist/domain/mcp/core-server.js +8 -40
- package/dist/domain/mcp/feishu/file.js +1 -11
- package/dist/domain/mcp/feishu/index.d.ts +0 -2
- package/dist/domain/mcp/feishu/index.js +5 -56
- package/dist/domain/mcp/feishu-server.d.ts +0 -1
- package/dist/domain/mcp/feishu-server.js +5 -6
- package/dist/domain/mcp/manager-qa-server.d.ts +1 -0
- package/dist/domain/mcp/manager-qa-server.js +23 -0
- package/dist/domain/mcp/server.d.ts +0 -1
- package/dist/domain/mcp/server.js +5 -31
- package/dist/domain/mcp/slack-server.d.ts +0 -1
- package/dist/domain/mcp/slack-server.js +3 -5
- package/dist/domain/mcp/tasks-server.d.ts +1 -0
- package/dist/domain/mcp/tasks-server.js +23 -0
- package/dist/domain/mcp/thread-server.d.ts +1 -0
- package/dist/domain/mcp/thread-server.js +25 -0
- package/dist/domain/mcp/tools/context.d.ts +3 -10
- package/dist/domain/mcp/tools/context.js +13 -29
- package/dist/domain/mcp/tools/manager-qa.d.ts +2 -1
- package/dist/domain/mcp/tools/manager-qa.js +49 -53
- package/dist/domain/mcp/tools/schedule.d.ts +1 -2
- package/dist/domain/mcp/tools/schedule.js +7 -10
- package/dist/domain/mcp/tools/slack.d.ts +0 -1
- package/dist/domain/mcp/tools/slack.js +2 -13
- package/dist/domain/mcp/tools/task-ops.js +10 -137
- package/dist/domain/mcp/tools/thread-ops.js +6 -11
- package/dist/domain/mcp/tools/tui-ask.d.ts +2 -0
- package/dist/domain/mcp/tools/tui-ask.js +8 -0
- package/dist/domain/mcp/tools/ui-file.d.ts +2 -0
- package/dist/domain/mcp/tools/ui-file.js +49 -0
- package/dist/domain/mcp/tui-server.d.ts +0 -1
- package/dist/domain/mcp/tui-server.js +39 -24
- package/dist/domain/mcp/web-server.d.ts +1 -0
- package/dist/domain/mcp/web-server.js +25 -0
- package/dist/domain/memory/cortex-md-injector.d.ts +4 -10
- package/dist/domain/memory/cortex-md-injector.js +113 -77
- package/dist/domain/memory/cortex-md-scanner.d.ts +1 -0
- package/dist/domain/memory/cortex-md-scanner.js +5 -2
- package/dist/domain/memory/skill-scanner.d.ts +3 -1
- package/dist/domain/memory/skill-scanner.js +8 -12
- package/dist/domain/memory/user-context.d.ts +6 -5
- package/dist/domain/memory/user-context.js +12 -7
- package/dist/domain/monitor/disk-monitor.js +2 -3
- package/dist/domain/projects/index.d.ts +1 -0
- package/dist/domain/projects/project-store.d.ts +18 -0
- package/dist/domain/projects/project-store.js +39 -3
- package/dist/domain/remote/client-hot-reload.d.ts +9 -2
- package/dist/domain/remote/client-hot-reload.js +81 -9
- package/dist/domain/remote/client-manager.d.ts +15 -1
- package/dist/domain/remote/client-manager.js +75 -11
- package/dist/domain/remote/cortex-client.js +6 -48
- package/dist/domain/scheduling/job-registry.d.ts +0 -2
- package/dist/domain/scheduling/job-registry.js +2 -6
- package/dist/domain/scheduling/jobs/_shared.d.ts +5 -1
- package/dist/domain/scheduling/jobs/_shared.js +2 -1
- package/dist/domain/scheduling/jobs/failed-dispatch-reconciliation.d.ts +1 -0
- package/dist/domain/scheduling/jobs/failed-dispatch-reconciliation.js +78 -0
- package/dist/domain/scheduling/jobs/scheduled-task.js +1 -3
- package/dist/domain/scheduling/jobs/task-dispatch.js +40 -31
- package/dist/domain/scheduling/scheduler.d.ts +0 -10
- package/dist/domain/scheduling/scheduler.js +9 -9
- package/dist/domain/sessions/session-hooks.d.ts +38 -15
- package/dist/domain/sessions/session-hooks.js +128 -122
- package/dist/domain/sessions/session-lifecycle.d.ts +38 -1
- package/dist/domain/sessions/session-lifecycle.js +41 -4
- package/dist/domain/sessions/session-registry.d.ts +3 -1
- package/dist/domain/system/doctor.d.ts +63 -0
- package/dist/domain/system/doctor.js +359 -0
- package/dist/domain/system/server-update-check.d.ts +2 -1
- package/dist/domain/system/server-update-check.js +7 -26
- package/dist/domain/system/system-notice.d.ts +18 -0
- package/dist/domain/system/system-notice.js +34 -0
- package/dist/domain/tasks/acceptance-ledger.d.ts +31 -0
- package/dist/domain/tasks/acceptance-ledger.js +83 -0
- package/dist/domain/tasks/claim-recovery.d.ts +10 -0
- package/dist/domain/tasks/claim-recovery.js +64 -0
- package/dist/domain/tasks/dispatch-utils.d.ts +19 -0
- package/dist/domain/tasks/dispatcher.js +1 -3
- package/dist/domain/tasks/mutator.d.ts +7 -1
- package/dist/domain/tasks/mutator.js +55 -3
- package/dist/domain/tasks/recommendation/extractor.js +3 -3
- package/dist/domain/tasks/system/cortex-run.js +0 -0
- package/dist/domain/tasks/system/task-cli.d.ts +2 -0
- package/dist/domain/tasks/system/task-cli.js +37 -7
- package/dist/domain/tasks/system/task-completion.js +148 -42
- package/dist/domain/tasks/system/task-lifecycle-edit.js +3 -0
- package/dist/domain/tasks/system/task-state.d.ts +10 -1
- package/dist/domain/tasks/system/task-state.js +31 -1
- package/dist/domain/threads/artifact-io.d.ts +3 -15
- package/dist/domain/threads/artifact-io.js +13 -119
- package/dist/domain/threads/hook-runner.d.ts +7 -2
- package/dist/domain/threads/hook-runner.js +68 -85
- package/dist/domain/threads/index.js +6 -1
- package/dist/domain/threads/prompt-builder.d.ts +14 -4
- package/dist/domain/threads/prompt-builder.js +38 -20
- package/dist/domain/threads/runner.d.ts +19 -5
- package/dist/domain/threads/runner.js +238 -82
- package/dist/domain/threads/shell-templates.d.ts +9 -0
- package/dist/domain/threads/shell-templates.js +117 -0
- package/dist/domain/threads/state-machine.d.ts +35 -7
- package/dist/domain/threads/state-machine.js +170 -29
- package/dist/domain/threads/template-loader.d.ts +15 -7
- package/dist/domain/threads/template-loader.js +204 -87
- package/dist/domain/threads/thread-transcript.d.ts +47 -0
- package/dist/domain/threads/thread-transcript.js +64 -0
- package/dist/domain/threads/utils.d.ts +8 -1
- package/dist/domain/threads/utils.js +17 -1
- package/dist/domain/tui-session/tui-session-service.js +9 -16
- package/dist/domain/tui-session/types.d.ts +12 -0
- package/dist/domain/ui-service/app-router.d.ts +670 -0
- package/dist/domain/ui-service/app-router.js +195 -0
- package/dist/domain/ui-service/index.d.ts +1 -1
- package/dist/domain/ui-service/input-schemas.d.ts +644 -0
- package/dist/domain/ui-service/input-schemas.js +385 -0
- package/dist/domain/ui-service/mutate/approvals.d.ts +31 -0
- package/dist/domain/ui-service/mutate/approvals.js +140 -0
- package/dist/domain/ui-service/mutate/config.d.ts +16 -0
- package/dist/domain/ui-service/mutate/config.js +72 -0
- package/dist/domain/ui-service/mutate/hooks.d.ts +16 -0
- package/dist/domain/ui-service/mutate/hooks.js +138 -0
- package/dist/domain/ui-service/mutate/issues.d.ts +18 -0
- package/dist/domain/ui-service/mutate/issues.js +111 -0
- package/dist/domain/ui-service/mutate/notes.d.ts +6 -0
- package/dist/domain/ui-service/mutate/notes.js +36 -0
- package/dist/domain/ui-service/mutate/projects.d.ts +4 -0
- package/dist/domain/ui-service/mutate/projects.js +10 -0
- package/dist/domain/ui-service/mutate/schedules.d.ts +2 -1
- package/dist/domain/ui-service/mutate/schedules.js +57 -3
- package/dist/domain/ui-service/mutate/sessions.d.ts +11 -0
- package/dist/domain/ui-service/mutate/sessions.js +198 -0
- package/dist/domain/ui-service/mutate/system.d.ts +2 -0
- package/dist/domain/ui-service/mutate/system.js +97 -0
- package/dist/domain/ui-service/query/approvals.d.ts +10 -0
- package/dist/domain/ui-service/query/approvals.js +109 -0
- package/dist/domain/ui-service/query/config.d.ts +8 -0
- package/dist/domain/ui-service/query/config.js +138 -0
- package/dist/domain/ui-service/query/executions.d.ts +2 -1
- package/dist/domain/ui-service/query/executions.js +47 -3
- package/dist/domain/ui-service/query/hooks.d.ts +7 -0
- package/dist/domain/ui-service/query/hooks.js +110 -0
- package/dist/domain/ui-service/query/issues.d.ts +14 -0
- package/dist/domain/ui-service/query/issues.js +85 -0
- package/dist/domain/ui-service/query/machines.d.ts +2 -0
- package/dist/domain/ui-service/query/machines.js +39 -0
- package/dist/domain/ui-service/query/memory.d.ts +5 -0
- package/dist/domain/ui-service/query/memory.js +199 -0
- package/dist/domain/ui-service/query/notes.d.ts +3 -0
- package/dist/domain/ui-service/query/notes.js +18 -0
- package/dist/domain/ui-service/query/schedules.js +1 -0
- package/dist/domain/ui-service/query/sessions.d.ts +3 -1
- package/dist/domain/ui-service/query/sessions.js +227 -15
- package/dist/domain/ui-service/query/skills.d.ts +2 -0
- package/dist/domain/ui-service/query/skills.js +14 -0
- package/dist/domain/ui-service/query/system.d.ts +3 -0
- package/dist/domain/ui-service/query/system.js +132 -0
- package/dist/domain/ui-service/query/task-verification.d.ts +2 -0
- package/dist/domain/ui-service/query/task-verification.js +60 -0
- package/dist/domain/ui-service/query/tasks.d.ts +1 -0
- package/dist/domain/ui-service/query/tasks.js +24 -16
- package/dist/domain/ui-service/query/thread-templates.d.ts +8 -0
- package/dist/domain/ui-service/query/thread-templates.js +54 -0
- package/dist/domain/ui-service/query/threads.d.ts +2 -1
- package/dist/domain/ui-service/query/threads.js +213 -4
- package/dist/domain/ui-service/subscribe.js +27 -1
- package/dist/domain/ui-service/trpc.d.ts +13 -0
- package/dist/domain/ui-service/trpc.js +12 -0
- package/dist/domain/ui-service/types.d.ts +1266 -4
- package/dist/domain/ui-service/types.js +4 -4
- package/dist/domain/ui-service/ui-service.d.ts +2 -1
- package/dist/domain/ui-service/ui-service.js +112 -10
- package/dist/entry/app.js +307 -36
- package/dist/entry/cli.js +10 -0
- package/dist/entry/daemon-notice.d.ts +17 -0
- package/dist/entry/daemon-notice.js +26 -0
- package/dist/entry/daemon.d.ts +23 -1
- package/dist/entry/daemon.js +126 -41
- package/dist/entry/doctor-cli.d.ts +12 -0
- package/dist/entry/doctor-cli.js +76 -0
- package/dist/entry/hook-cli.d.ts +18 -0
- package/dist/entry/hook-cli.js +468 -0
- package/dist/entry/init.js +22 -18
- package/dist/entry/start-ui-http.d.ts +44 -0
- package/dist/entry/start-ui-http.js +289 -0
- package/dist/entry/startup-notify.js +5 -9
- package/dist/entry/ui-http-gate.d.ts +11 -0
- package/dist/entry/ui-http-gate.js +29 -0
- package/dist/events/event-bus.d.ts +7 -2
- package/dist/events/event-bus.js +5 -2
- package/dist/events/event-logger.js +14 -0
- package/dist/events/event-types.d.ts +110 -0
- package/dist/events/event-types.js +3 -3
- package/dist/hooks/ask-user-question-hook.mjs +1 -0
- package/dist/hooks/cortex-hook-api.mjs +84 -0
- package/dist/hooks/cortex-md-injector.mjs +99 -49
- package/dist/hooks/exit-plan-mode-hook.mjs +1 -0
- package/dist/hooks/memory-ref-tracker.mjs +1 -0
- package/dist/hooks/new-session-hook.mjs +1 -0
- package/dist/hooks/post-task-hook.mjs +1 -0
- package/dist/hooks/rules-loader.mjs +1 -0
- package/dist/hooks/sensitive-file-edit.mjs +1 -0
- package/dist/hooks/session-activity-tracker.mjs +8 -100
- package/dist/hooks/task-status-check.mjs +10 -10
- package/dist/hooks/tasks-yaml-guard.mjs +1 -0
- package/dist/orchestration/agent-file-send.d.ts +54 -0
- package/dist/orchestration/agent-file-send.js +110 -0
- package/dist/orchestration/agent-runner.d.ts +49 -0
- package/dist/orchestration/agent-runner.js +368 -55
- package/dist/orchestration/bg-continuation.d.ts +51 -9
- package/dist/orchestration/bg-continuation.js +53 -15
- package/dist/orchestration/bg-wait-guard.d.ts +28 -0
- package/dist/orchestration/bg-wait-guard.js +73 -0
- package/dist/orchestration/conduit-queue.d.ts +2 -0
- package/dist/orchestration/conduit-queue.js +14 -1
- package/dist/orchestration/conversation-runner.d.ts +37 -5
- package/dist/orchestration/conversation-runner.js +71 -13
- package/dist/orchestration/delta-coalescer.d.ts +69 -0
- package/dist/orchestration/delta-coalescer.js +128 -0
- package/dist/orchestration/interactions/ask-user-question.d.ts +11 -3
- package/dist/orchestration/interactions/ask-user-question.js +27 -3
- package/dist/orchestration/interactions/interaction-handlers.js +11 -36
- package/dist/orchestration/interactions/interaction-records.d.ts +59 -0
- package/dist/orchestration/interactions/interaction-records.js +156 -0
- package/dist/orchestration/interactions/plan-approvals.d.ts +5 -0
- package/dist/orchestration/interactions/plan-approvals.js +8 -0
- package/dist/orchestration/interactions/plan-response.d.ts +8 -0
- package/dist/orchestration/interactions/plan-response.js +37 -0
- package/dist/orchestration/lifecycle.d.ts +10 -4
- package/dist/orchestration/lifecycle.js +155 -60
- package/dist/orchestration/manager-qa.d.ts +15 -4
- package/dist/orchestration/manager-qa.js +43 -37
- package/dist/orchestration/mid-turn-inject.d.ts +105 -0
- package/dist/orchestration/mid-turn-inject.js +298 -0
- package/dist/orchestration/pending-injection-recovery.d.ts +35 -0
- package/dist/orchestration/pending-injection-recovery.js +92 -0
- package/dist/orchestration/resume-dispatcher.d.ts +26 -4
- package/dist/orchestration/resume-dispatcher.js +89 -43
- package/dist/orchestration/routing/commands/cancel.d.ts +26 -0
- package/dist/orchestration/routing/commands/cancel.js +64 -18
- package/dist/orchestration/routing/commands/compact.d.ts +10 -0
- package/dist/orchestration/routing/commands/compact.js +26 -0
- package/dist/orchestration/routing/commands/index.d.ts +2 -0
- package/dist/orchestration/routing/commands/index.js +9 -0
- package/dist/orchestration/routing/commands/mode.js +24 -11
- package/dist/orchestration/routing/commands/restart.d.ts +22 -0
- package/dist/orchestration/routing/commands/restart.js +49 -0
- package/dist/orchestration/routing/commands/session.js +4 -0
- package/dist/orchestration/routing/commands/status.js +5 -0
- package/dist/orchestration/routing/edit-handler.js +1 -1
- package/dist/orchestration/routing/hook-bridge-subscribers.d.ts +2 -1
- package/dist/orchestration/routing/hook-bridge-subscribers.js +45 -4
- package/dist/orchestration/routing/hook-bridge.d.ts +10 -3
- package/dist/orchestration/routing/hook-bridge.js +26 -14
- package/dist/orchestration/routing/webhook.js +110 -19
- package/dist/orchestration/session-compact.d.ts +58 -0
- package/dist/orchestration/session-compact.js +82 -0
- package/dist/orchestration/session-events.d.ts +111 -0
- package/dist/orchestration/session-events.js +113 -0
- package/dist/orchestration/session-rewind.d.ts +72 -0
- package/dist/orchestration/session-rewind.js +104 -0
- package/dist/orchestration/session-send.d.ts +19 -0
- package/dist/orchestration/session-send.js +39 -0
- package/dist/orchestration/status-helpers.d.ts +4 -0
- package/dist/orchestration/status-helpers.js +18 -0
- package/dist/orchestration/thread-callback.d.ts +75 -3
- package/dist/orchestration/thread-callback.js +329 -74
- package/dist/orchestration/thread-executor.d.ts +1 -0
- package/dist/orchestration/thread-executor.js +23 -31
- package/dist/orchestration/web-bg-hold.d.ts +52 -0
- package/dist/orchestration/web-bg-hold.js +105 -0
- package/dist/platform/adapter.d.ts +3 -0
- package/dist/platform/adapter.js +2 -2
- package/dist/platform/adapters/composite-adapter.d.ts +6 -1
- package/dist/platform/adapters/composite-adapter.js +64 -4
- package/dist/platform/adapters/feishu.d.ts +6 -1
- package/dist/platform/adapters/feishu.js +52 -12
- package/dist/platform/adapters/slack.d.ts +2 -1
- package/dist/platform/adapters/slack.js +41 -9
- package/dist/platform/adapters/tui/index.d.ts +1 -1
- package/dist/platform/adapters/tui/ports.d.ts +8 -7
- package/dist/platform/adapters/tui/tui-gateway.d.ts +7 -0
- package/dist/platform/adapters/tui/tui-gateway.js +48 -5
- package/dist/platform/adapters/tui/tui-transcript.js +17 -29
- package/dist/platform/index.d.ts +1 -1
- package/dist/platform/index.js +1 -1
- package/dist/platform/interactive-builder.d.ts +7 -0
- package/dist/platform/interactive-builder.js +22 -2
- package/dist/platform/testing.d.ts +5 -0
- package/dist/platform/testing.js +7 -2
- package/dist/platform/tui/protocol.d.ts +0 -2
- package/dist/platform/tui/protocol.js +4 -53
- package/dist/platform/types.d.ts +12 -0
- package/dist/platform/types.js +5 -0
- package/dist/platform/ui-http/access-jwt.d.ts +28 -0
- package/dist/platform/ui-http/access-jwt.js +67 -0
- package/dist/platform/ui-http/app-update.d.ts +58 -0
- package/dist/platform/ui-http/app-update.js +155 -0
- package/dist/platform/ui-http/ui-http-server.d.ts +56 -0
- package/dist/platform/ui-http/ui-http-server.js +231 -0
- package/dist/platform/ui-http/ui-ota.d.ts +20 -0
- package/dist/platform/ui-http/ui-ota.js +128 -0
- package/dist/platform/ui-http/zip-writer.d.ts +13 -0
- package/dist/platform/ui-http/zip-writer.js +102 -0
- package/dist/platform/utils/reaction-diagnostics.d.ts +4 -0
- package/dist/platform/utils/reaction-diagnostics.js +23 -0
- package/dist/store/conversation-history-repo.d.ts +243 -0
- package/dist/store/conversation-history-repo.js +399 -0
- package/dist/store/execution-repo.d.ts +19 -1
- package/dist/store/execution-repo.js +18 -1
- package/dist/store/hook-registry.d.ts +83 -0
- package/dist/store/hook-registry.js +318 -0
- package/dist/store/hook-sync.d.ts +12 -16
- package/dist/store/hook-sync.js +169 -70
- package/dist/store/hook-writer.d.ts +49 -0
- package/dist/store/hook-writer.js +132 -0
- package/dist/store/outbound-queue.d.ts +8 -0
- package/dist/store/outbound-queue.js +24 -3
- package/dist/store/pending-injection-repo.d.ts +30 -0
- package/dist/store/pending-injection-repo.js +51 -0
- package/dist/store/plugin-sync.d.ts +21 -0
- package/dist/store/plugin-sync.js +119 -0
- package/dist/store/profile-repo.d.ts +2 -1
- package/dist/store/profile-repo.js +6 -11
- package/dist/store/project-notes-repo.d.ts +27 -0
- package/dist/store/project-notes-repo.js +214 -0
- package/dist/store/provider-state-repo.d.ts +18 -0
- package/dist/store/provider-state-repo.js +107 -0
- package/dist/store/schedule-repo.d.ts +0 -21
- package/dist/store/schedule-repo.js +4 -25
- package/dist/store/session-registry-repo.d.ts +47 -1
- package/dist/store/session-registry-repo.js +71 -3
- package/dist/store/version-migrations.d.ts +11 -0
- package/dist/store/version-migrations.js +286 -9
- package/dist/tui/App.js +219 -27
- package/dist/tui/components/Dashboard.d.ts +3 -1
- package/dist/tui/components/Dashboard.js +31 -12
- package/dist/tui/components/DashboardCostTab.js +17 -2
- package/dist/tui/components/DashboardExecutionsTab.js +21 -1
- package/dist/tui/components/DashboardSchedulesTab.js +8 -3
- package/dist/tui/components/DashboardTasksTab.js +11 -6
- package/dist/tui/components/DashboardThreadsTab.js +20 -2
- package/dist/tui/components/InputBox.d.ts +17 -1
- package/dist/tui/components/InputBox.js +263 -8
- package/dist/tui/components/Notifications.js +7 -2
- package/dist/tui/components/ProjectSwitcher.js +7 -2
- package/dist/tui/components/SessionPicker.js +10 -1
- package/dist/tui/components/SidePanel.d.ts +3 -1
- package/dist/tui/components/SidePanel.js +4 -2
- package/dist/tui/components/SlashMenu.d.ts +8 -0
- package/dist/tui/components/SlashMenu.js +14 -0
- package/dist/tui/components/StatusLine.d.ts +12 -3
- package/dist/tui/components/StatusLine.js +29 -10
- package/dist/tui/components/Transcript.d.ts +9 -0
- package/dist/tui/components/Transcript.js +131 -26
- package/dist/tui/components/dashboard-constants.d.ts +1 -0
- package/dist/tui/components/dashboard-constants.js +7 -0
- package/dist/tui/hooks/useKeybindings.d.ts +1 -0
- package/dist/tui/hooks/useKeybindings.js +9 -14
- package/dist/tui/hooks/useMouseHandler.d.ts +17 -0
- package/dist/tui/hooks/useMouseHandler.js +103 -0
- package/dist/tui/hooks/useTranscript.d.ts +7 -2
- package/dist/tui/hooks/useTranscript.js +76 -57
- package/dist/tui/index.js +106 -10
- package/dist/tui/logic.d.ts +146 -2
- package/dist/tui/logic.js +411 -6
- package/dist/tui/raf-batch.d.ts +33 -0
- package/dist/tui/raf-batch.js +103 -0
- package/dist/tui/render/inline-markdown.d.ts +22 -0
- package/dist/tui/render/inline-markdown.js +99 -0
- package/dist/tui/render/rich-blocks.js +10 -8
- package/dist/tui/render-output.d.ts +46 -0
- package/dist/tui/render-output.js +86 -0
- package/dist/tui/slash-commands.d.ts +21 -0
- package/dist/tui/slash-commands.js +73 -0
- package/dist/tui/turn-status.d.ts +10 -0
- package/dist/tui/turn-status.js +53 -0
- package/package.json +17 -7
- package/web/dist/apple-touch-icon.png +0 -0
- package/web/dist/assets/index-B19jLgji.js +138 -0
- package/web/dist/assets/index-BuFyPyRW.css +1 -0
- package/web/dist/assets/index-DCgngTJG.js +1 -0
- package/web/dist/assets/pdf-worker-DIEXcFxP.js +55 -0
- package/web/dist/assets/pdf.worker.min-DqNZU1-t.js +53 -0
- package/web/dist/favicon-32.png +0 -0
- package/web/dist/favicon.svg +7 -0
- package/web/dist/index.html +37 -0
- package/defaults/config/session-hooks.json +0 -7
- package/defaults/config/thread-templates.json +0 -594
- package/defaults/prompts/directives/milestone-executor.md +0 -119
- package/defaults/prompts/directives/milestone-reviewer.md +0 -108
- package/defaults/prompts/directives/plan-executor.md +0 -121
- package/defaults/prompts/directives/plan-reviewer.md +0 -99
- package/dist/agent-adapter/codex/adapter.d.ts +0 -42
- package/dist/agent-adapter/codex/adapter.js +0 -916
- package/dist/agent-adapter/codex/event-parser.d.ts +0 -17
- package/dist/agent-adapter/codex/event-parser.js +0 -41
- package/dist/agent-adapter/codex/spawn-args.d.ts +0 -6
- package/dist/agent-adapter/codex/spawn-args.js +0 -30
- package/dist/domain/costs/codex-event-format.d.ts +0 -4
- package/dist/domain/costs/codex-event-format.js +0 -66
- package/dist/domain/costs/codex-usage-monitor.d.ts +0 -6
- package/dist/domain/costs/codex-usage-monitor.js +0 -73
- package/dist/domain/costs/rate-limit-parser.d.ts +0 -11
- package/dist/domain/costs/rate-limit-parser.js +0 -87
- package/dist/domain/mcp/feishu/bitable.d.ts +0 -3
- package/dist/domain/mcp/feishu/bitable.js +0 -168
- package/dist/domain/mcp/feishu/block-types.d.ts +0 -44
- package/dist/domain/mcp/feishu/block-types.js +0 -127
- package/dist/domain/mcp/feishu/blocks-to-text.d.ts +0 -19
- package/dist/domain/mcp/feishu/blocks-to-text.js +0 -43
- package/dist/domain/mcp/feishu/docx.d.ts +0 -3
- package/dist/domain/mcp/feishu/docx.js +0 -163
- package/dist/domain/mcp/feishu/drive.d.ts +0 -23
- package/dist/domain/mcp/feishu/drive.js +0 -66
- package/dist/domain/mcp/feishu/markdown-to-blocks.d.ts +0 -40
- package/dist/domain/mcp/feishu/markdown-to-blocks.js +0 -191
- package/dist/domain/mcp/feishu/sheets.d.ts +0 -3
- package/dist/domain/mcp/feishu/sheets.js +0 -119
- package/dist/domain/mcp/feishu/wiki.d.ts +0 -3
- package/dist/domain/mcp/feishu/wiki.js +0 -77
- package/dist/tui/components/Header.d.ts +0 -11
- package/dist/tui/components/Header.js +0 -5
- package/dist/tui/components/MessageRow.d.ts +0 -7
- package/dist/tui/components/MessageRow.js +0 -10
package/dist/tui/App.js
CHANGED
|
@@ -3,24 +3,31 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
// output: Top-level layout + global key handler for M5 Ink client
|
|
4
4
|
// pos: Main App component wiring all pieces together
|
|
5
5
|
import { useCallback, useRef, useState, useEffect } from 'react';
|
|
6
|
-
import { Box } from 'ink';
|
|
7
|
-
import { Header } from './components/Header.js';
|
|
6
|
+
import { Box, useStdout } from 'ink';
|
|
8
7
|
import { Transcript } from './components/Transcript.js';
|
|
9
8
|
import { InputBox } from './components/InputBox.js';
|
|
10
9
|
import { StatusLine } from './components/StatusLine.js';
|
|
11
10
|
import { SidePanel } from './components/SidePanel.js';
|
|
12
|
-
import {
|
|
11
|
+
import { NotificationsModal } from './components/Notifications.js';
|
|
13
12
|
import { ProjectSwitcher } from './components/ProjectSwitcher.js';
|
|
14
13
|
import { useMutate } from './hooks/useMutate.js';
|
|
15
14
|
import { useTranscript } from './hooks/useTranscript.js';
|
|
16
15
|
import { useKeybindings } from './hooks/useKeybindings.js';
|
|
16
|
+
import { useMouseHandler } from './hooks/useMouseHandler.js';
|
|
17
|
+
import { osc52Copy } from './logic.js';
|
|
17
18
|
import { useNotifications } from './hooks/useNotifications.js';
|
|
18
19
|
import { useDashboardData } from './hooks/useDashboardData.js';
|
|
19
20
|
import { SessionPicker } from './components/SessionPicker.js';
|
|
21
|
+
import { SLASH_COMMANDS } from './slash-commands.js';
|
|
20
22
|
import { AskUserModal } from './components/AskUserModal.js';
|
|
21
23
|
import { PlanFeedbackModal } from './components/PlanFeedbackModal.js';
|
|
22
|
-
import { isNotification, isUiQueryResult, isUiEvent, isErrorFrame } from '../platform/tui/protocol.js';
|
|
23
|
-
import { computeFocusZone, isAgentResponseFrame } from './logic.js';
|
|
24
|
+
import { isNotification, isUiQueryResult, isUiEvent, isErrorFrame, isChatPost, isChatUpdate } from '../platform/tui/protocol.js';
|
|
25
|
+
import { computeFocusZone, isAgentResponseFrame, matchResumeTarget } from './logic.js';
|
|
26
|
+
import { parseTurnStatus, formatTurnStatus } from './turn-status.js';
|
|
27
|
+
/** A status message is the only TUI chat content that carries an `actions` rich-block. */
|
|
28
|
+
function hasActionsBlock(content) {
|
|
29
|
+
return !!content?.richBlocks?.some(b => b?.type === 'actions');
|
|
30
|
+
}
|
|
24
31
|
export function App({ sendFrame, connectionState, ack, onReconnect, onDisconnect, onSendCancel, serverVersion, projectId, sessionName, errorMessage, onSetDispatch, resumableSessions, resumePending, onResumeSelect, onResumeCancel, }) {
|
|
25
32
|
// ── Hooks ──
|
|
26
33
|
const [activeModal, setActiveModal] = useState(null);
|
|
@@ -50,16 +57,52 @@ export function App({ sendFrame, connectionState, ack, onReconnect, onDisconnect
|
|
|
50
57
|
const [sidePanelVisible, setSidePanelVisible] = useState(false);
|
|
51
58
|
const [notificationsOpen, setNotificationsOpen] = useState(false);
|
|
52
59
|
const [projectSwitcherOpen, setProjectSwitcherOpen] = useState(false);
|
|
60
|
+
// Bottom-line shortcuts overlay — '?' on an empty input shows it; any key dismisses it.
|
|
61
|
+
const [showShortcuts, setShowShortcuts] = useState(false);
|
|
62
|
+
// Stable callbacks so the memoized InputBox isn't re-rendered by unrelated App state changes.
|
|
63
|
+
const handleToggleShortcuts = useCallback(() => setShowShortcuts(s => !s), []);
|
|
64
|
+
const handleDismissShortcuts = useCallback(() => setShowShortcuts(false), []);
|
|
65
|
+
// Mouse capture (SGR tracking) state. Default ON so the wheel scrolls the transcript (enabled at
|
|
66
|
+
// startup in index.tsx). Ctrl+T / `/mouse` toggles it OFF — writing the SGR disable sequence —
|
|
67
|
+
// to free the mouse for native click-drag text selection + right-click paste (the wheel stops).
|
|
68
|
+
const [mouseCapture, setMouseCapture] = useState(true);
|
|
69
|
+
// Toast message (e.g. "Copied to clipboard!") — auto-clears after 3 seconds.
|
|
70
|
+
const [toast, setToast] = useState(null);
|
|
71
|
+
const toastTimerRef = useRef(null);
|
|
72
|
+
const showToast = useCallback((msg) => {
|
|
73
|
+
if (toastTimerRef.current)
|
|
74
|
+
clearTimeout(toastTimerRef.current);
|
|
75
|
+
setToast(msg);
|
|
76
|
+
toastTimerRef.current = setTimeout(() => { setToast(null); toastTimerRef.current = null; }, 3000);
|
|
77
|
+
}, []);
|
|
53
78
|
// Project switcher state
|
|
54
79
|
const [projects, setProjects] = useState([]);
|
|
55
80
|
const [projectsLoading, setProjectsLoading] = useState(false);
|
|
56
81
|
const [projectsError, setProjectsError] = useState(null);
|
|
82
|
+
// `/resume` session picker (client-side, replaces the inert Resume button).
|
|
83
|
+
const [slashResumeSessions, setSlashResumeSessions] = useState(null);
|
|
84
|
+
// `/resume <id>` direct-jump target (session id / name / suffix). Resolved against the
|
|
85
|
+
// sessions.list result; null means "show the picker".
|
|
86
|
+
const resumeTargetRef = useRef(null);
|
|
87
|
+
// Dedicated turn-status line shown above the input (state/time/turns/cost). Status
|
|
88
|
+
// frames (identified by their `actions` rich-block) are routed here, NOT the transcript.
|
|
89
|
+
const [turnStatus, setTurnStatus] = useState(null);
|
|
57
90
|
const transcriptRef = useRef(null);
|
|
58
|
-
//
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
:
|
|
91
|
+
// Terminal size — drives the full-screen root box and updates on resize so the layout
|
|
92
|
+
// always fills the alternate-screen buffer (see enterFullscreen in index.tsx).
|
|
93
|
+
const { stdout } = useStdout();
|
|
94
|
+
const [termSize, setTermSize] = useState(() => ({
|
|
95
|
+
rows: stdout?.rows ?? 24,
|
|
96
|
+
columns: stdout?.columns ?? 80,
|
|
97
|
+
}));
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
if (!stdout)
|
|
100
|
+
return;
|
|
101
|
+
const onResize = () => setTermSize({ rows: stdout.rows, columns: stdout.columns });
|
|
102
|
+
onResize();
|
|
103
|
+
stdout.on('resize', onResize);
|
|
104
|
+
return () => { stdout.off('resize', onResize); };
|
|
105
|
+
}, [stdout]);
|
|
63
106
|
// Active tab for dashboard
|
|
64
107
|
const [activeTab, setActiveTab] = useState('threads');
|
|
65
108
|
// Route non-mutate frames to the appropriate handler
|
|
@@ -76,6 +119,37 @@ export function App({ sendFrame, connectionState, ack, onReconnect, onDisconnect
|
|
|
76
119
|
return;
|
|
77
120
|
}
|
|
78
121
|
if (isUiQueryResult(frame) || isUiEvent(frame)) {
|
|
122
|
+
// Handle the `/resume` session list
|
|
123
|
+
if (isUiQueryResult(frame) && frame.id === 'slash-resume-list') {
|
|
124
|
+
const list = (frame.ok && Array.isArray(frame.data))
|
|
125
|
+
? frame.data.map((s) => ({
|
|
126
|
+
sessionId: s.sessionId ?? s.id,
|
|
127
|
+
name: s.name,
|
|
128
|
+
projectId: s.projectId,
|
|
129
|
+
label: s.label ?? null,
|
|
130
|
+
}))
|
|
131
|
+
: [];
|
|
132
|
+
// `/resume <id>`: resolve the target and jump straight in, skipping the picker.
|
|
133
|
+
const target = resumeTargetRef.current;
|
|
134
|
+
resumeTargetRef.current = null;
|
|
135
|
+
if (target) {
|
|
136
|
+
const matchedId = matchResumeTarget(list, target);
|
|
137
|
+
if (matchedId) {
|
|
138
|
+
const matched = list.find(s => s.sessionId === matchedId);
|
|
139
|
+
sendFrame({
|
|
140
|
+
type: 'session.switch',
|
|
141
|
+
id: 'slash-resume-direct',
|
|
142
|
+
projectId: matched?.projectId ?? projectId ?? 'general',
|
|
143
|
+
sessionId: matchedId,
|
|
144
|
+
});
|
|
145
|
+
setSlashResumeSessions(null);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
// No match — fall through to the picker so the user can choose.
|
|
149
|
+
}
|
|
150
|
+
setSlashResumeSessions(list);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
79
153
|
// Handle project switcher responses
|
|
80
154
|
if (isUiQueryResult(frame) && frame.id === 'proj-switcher-list') {
|
|
81
155
|
if (frame.ok) {
|
|
@@ -93,8 +167,16 @@ export function App({ sendFrame, connectionState, ack, onReconnect, onDisconnect
|
|
|
93
167
|
dashboard.dispatch(frame);
|
|
94
168
|
return;
|
|
95
169
|
}
|
|
170
|
+
// Status messages (the "⏳ Processing…/✅ Done…" line) carry an `actions` rich-block.
|
|
171
|
+
// Route them to the dedicated turn-status line above the input instead of the
|
|
172
|
+
// transcript, so the chat history holds only real user/assistant messages.
|
|
173
|
+
if ((isChatPost(frame) || isChatUpdate(frame)) && hasActionsBlock(frame.content)) {
|
|
174
|
+
const text = String(frame.content?.text ?? '');
|
|
175
|
+
setTurnStatus(text ? formatTurnStatus(parseTurnStatus(text)) : null);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
96
178
|
transcript.dispatch(frame);
|
|
97
|
-
}, [transcript.dispatch, dashboard.dispatch, notif.add]);
|
|
179
|
+
}, [transcript.dispatch, dashboard.dispatch, notif.add, sendFrame, projectId]);
|
|
98
180
|
// Mutate hook: sends ui.mutate frames, correlates results by id, 10s timeout
|
|
99
181
|
const { mutate, handleFrame } = useMutate({ sendFrame, onFrame: routeFrame });
|
|
100
182
|
// Combined dispatch: mutate intercepts mutateResult; rest routes normally
|
|
@@ -105,11 +187,21 @@ export function App({ sendFrame, connectionState, ack, onReconnect, onDisconnect
|
|
|
105
187
|
useEffect(() => {
|
|
106
188
|
sendFrame({ type: 'ui.query', id: 'dash-cost', scope: 'cost.summary', params: {} });
|
|
107
189
|
}, []);
|
|
108
|
-
// Switching project/session (session.switched is handled in index.tsx and never
|
|
109
|
-
//
|
|
190
|
+
// Switching project/session (session.switched is handled in index.tsx and never reaches
|
|
191
|
+
// routeFrame) must release any pending send-lock from the OLD session. With lazy session
|
|
192
|
+
// creation the first message transitions sessionName null→name — that is NOT a switch and
|
|
193
|
+
// must NOT clear the in-flight `awaitingResponse`/queued state, so we only reset when a real
|
|
194
|
+
// prior session existed and actually changed.
|
|
195
|
+
const prevSessionRef = useRef({ projectId, sessionName });
|
|
110
196
|
useEffect(() => {
|
|
111
|
-
|
|
112
|
-
|
|
197
|
+
const prev = prevSessionRef.current;
|
|
198
|
+
const isRealSwitch = (prev.sessionName !== null && prev.sessionName !== sessionName)
|
|
199
|
+
|| (prev.projectId !== null && prev.projectId !== projectId);
|
|
200
|
+
prevSessionRef.current = { projectId, sessionName };
|
|
201
|
+
if (isRealSwitch) {
|
|
202
|
+
setAwaitingResponse(false);
|
|
203
|
+
setQueuedCount(0);
|
|
204
|
+
}
|
|
113
205
|
}, [projectId, sessionName]);
|
|
114
206
|
// Submit message
|
|
115
207
|
const handleSubmit = useCallback((text) => {
|
|
@@ -119,9 +211,14 @@ export function App({ sendFrame, connectionState, ack, onReconnect, onDisconnect
|
|
|
119
211
|
id,
|
|
120
212
|
text,
|
|
121
213
|
});
|
|
214
|
+
// Optimistically echo genuine user messages into the transcript (the server doesn't echo
|
|
215
|
+
// them back). Skip `!`-prefixed control commands (!new/!cancel/!restart…) — they aren't chat.
|
|
216
|
+
if (text && !text.startsWith('!')) {
|
|
217
|
+
transcript.addUserMessage(text);
|
|
218
|
+
}
|
|
122
219
|
setQueuedCount(prev => prev + 1);
|
|
123
220
|
setAwaitingResponse(true);
|
|
124
|
-
}, [sendFrame]);
|
|
221
|
+
}, [sendFrame, transcript]);
|
|
125
222
|
// Cancel (sends !cancel)
|
|
126
223
|
const handleCancel = useCallback(() => {
|
|
127
224
|
onSendCancel();
|
|
@@ -137,6 +234,10 @@ export function App({ sendFrame, connectionState, ack, onReconnect, onDisconnect
|
|
|
137
234
|
const handleScrollDown = useCallback((page) => {
|
|
138
235
|
transcriptRef.current?.scrollDown(page);
|
|
139
236
|
}, []);
|
|
237
|
+
// Coalesced wheel scroll: a batched net delta from useMouseHandler applied in one update.
|
|
238
|
+
const handleScrollByLines = useCallback((delta) => {
|
|
239
|
+
transcriptRef.current?.scrollByLines(delta);
|
|
240
|
+
}, []);
|
|
140
241
|
// Side panel toggle
|
|
141
242
|
const handleToggleSidePanel = useCallback(() => {
|
|
142
243
|
setSidePanelVisible(prev => !prev);
|
|
@@ -149,6 +250,21 @@ export function App({ sendFrame, connectionState, ack, onReconnect, onDisconnect
|
|
|
149
250
|
const handleToggleProjectSwitcher = useCallback(() => {
|
|
150
251
|
setProjectSwitcherOpen(prev => !prev);
|
|
151
252
|
}, []);
|
|
253
|
+
// Toggle mouse capture. Writes the SGR mouse enable/disable sequences straight to the TTY so
|
|
254
|
+
// the change takes effect immediately: OFF frees the mouse for native text selection, ON
|
|
255
|
+
// restores wheel-scroll + in-TUI drag-select capture. ?1002h = button-event tracking (motion
|
|
256
|
+
// only while a button is held), ?1006h = SGR encoding. index.tsx's leaveFullscreen disables
|
|
257
|
+
// tracking on exit anyway.
|
|
258
|
+
const handleToggleMouse = useCallback(() => {
|
|
259
|
+
setMouseCapture(prev => {
|
|
260
|
+
const next = !prev;
|
|
261
|
+
try {
|
|
262
|
+
process.stdout.write(next ? '\x1b[?1002h\x1b[?1006h' : '\x1b[?1002l\x1b[?1006l');
|
|
263
|
+
}
|
|
264
|
+
catch { /* best effort */ }
|
|
265
|
+
return next;
|
|
266
|
+
});
|
|
267
|
+
}, []);
|
|
152
268
|
// Project switcher select
|
|
153
269
|
const handleProjectSelect = useCallback((selectedProjectId) => {
|
|
154
270
|
sendFrame({
|
|
@@ -179,8 +295,57 @@ export function App({ sendFrame, connectionState, ack, onReconnect, onDisconnect
|
|
|
179
295
|
params: {},
|
|
180
296
|
});
|
|
181
297
|
}, [sendFrame]);
|
|
298
|
+
// Slash-command dispatch from the input palette.
|
|
299
|
+
const handleCommand = useCallback((name, args) => {
|
|
300
|
+
switch (name) {
|
|
301
|
+
case 'new':
|
|
302
|
+
// Clear the view, then start a new conversation (server runs the pre-close hook).
|
|
303
|
+
handleClearView();
|
|
304
|
+
handleSubmit('!new');
|
|
305
|
+
break;
|
|
306
|
+
case 'newx':
|
|
307
|
+
// Same, but skip the pre-close hook (no save).
|
|
308
|
+
handleClearView();
|
|
309
|
+
handleSubmit('!newq');
|
|
310
|
+
break;
|
|
311
|
+
case 'cancel':
|
|
312
|
+
handleCancel();
|
|
313
|
+
break;
|
|
314
|
+
case 'restart':
|
|
315
|
+
// Send the server-restart command. The WS connection drops during the respawn
|
|
316
|
+
// and the client reconnects automatically (no need to keep the input locked).
|
|
317
|
+
handleSubmit('!restart');
|
|
318
|
+
break;
|
|
319
|
+
case 'resume':
|
|
320
|
+
// `/resume` opens the picker; `/resume <id>` jumps straight to that session.
|
|
321
|
+
resumeTargetRef.current = args.trim() || null;
|
|
322
|
+
sendFrame({ type: 'ui.query', id: 'slash-resume-list', scope: 'sessions.list', params: { resumable: true } });
|
|
323
|
+
break;
|
|
324
|
+
case 'mouse':
|
|
325
|
+
// Client-side only (the server has no !mouse): toggle mouse capture for text selection.
|
|
326
|
+
handleToggleMouse();
|
|
327
|
+
break;
|
|
328
|
+
case 'help':
|
|
329
|
+
// The palette itself lists the commands — nothing else to do.
|
|
330
|
+
break;
|
|
331
|
+
default:
|
|
332
|
+
// Every other registered slash command mirrors a server `!` command (same name). Forward
|
|
333
|
+
// it as `!<name> <args>` so the server's command dispatcher handles it and replies into
|
|
334
|
+
// the transcript. `!`-prefixed text is not echoed as a chat message (see handleSubmit).
|
|
335
|
+
handleSubmit(`!${name}${args ? ` ${args}` : ''}`);
|
|
336
|
+
break;
|
|
337
|
+
}
|
|
338
|
+
}, [handleClearView, handleSubmit, handleCancel, handleToggleMouse, sendFrame]);
|
|
339
|
+
// `/resume` picker selection → switch to the chosen session; Esc/cancel closes it.
|
|
340
|
+
const handleSlashResumeSelect = useCallback((sessionId, pickedProjectId) => {
|
|
341
|
+
sendFrame({ type: 'session.switch', id: 'slash-resume', projectId: pickedProjectId, sessionId });
|
|
342
|
+
setSlashResumeSessions(null);
|
|
343
|
+
}, [sendFrame]);
|
|
344
|
+
const handleSlashResumeCancel = useCallback(() => {
|
|
345
|
+
setSlashResumeSessions(null);
|
|
346
|
+
}, []);
|
|
182
347
|
// Modals pre-empt input; an open dashboard takes keyboard focus from the input.
|
|
183
|
-
const modalOpen = activeModal !== null || notificationsOpen || projectSwitcherOpen;
|
|
348
|
+
const modalOpen = activeModal !== null || notificationsOpen || projectSwitcherOpen || slashResumeSessions !== null;
|
|
184
349
|
const focusZone = computeFocusZone({ modalOpen, sidePanelVisible });
|
|
185
350
|
// Keyboard bindings — toggles/cancel always active outside modals; scroll only
|
|
186
351
|
// when the chat input owns focus; reconnect only when not connected.
|
|
@@ -194,26 +359,53 @@ export function App({ sendFrame, connectionState, ack, onReconnect, onDisconnect
|
|
|
194
359
|
onToggleSidePanel: handleToggleSidePanel,
|
|
195
360
|
onToggleNotifications: handleToggleNotifications,
|
|
196
361
|
onToggleProjectSwitcher: handleToggleProjectSwitcher,
|
|
362
|
+
onToggleMouse: handleToggleMouse,
|
|
197
363
|
onReconnect,
|
|
198
364
|
}, focusZone !== 'modal', {
|
|
199
365
|
allowScroll: focusZone === 'input',
|
|
200
366
|
allowReconnect: connectionState !== 'connected',
|
|
201
367
|
});
|
|
202
|
-
//
|
|
368
|
+
// Mouse handler: wheel scroll, text selection (left-drag → OSC 52 copy), right-click hint.
|
|
369
|
+
const handleSelectionComplete = useCallback((range) => {
|
|
370
|
+
const text = transcriptRef.current?.getSelectedText(range);
|
|
371
|
+
if (text && text.length > 0) {
|
|
372
|
+
osc52Copy(text);
|
|
373
|
+
showToast(`Copied ${text.length} chars to clipboard (OSC 52)`);
|
|
374
|
+
}
|
|
375
|
+
}, [showToast]);
|
|
376
|
+
const handleRightClick = useCallback(() => {
|
|
377
|
+
showToast('Use Ctrl+Shift+V to paste');
|
|
378
|
+
}, [showToast]);
|
|
379
|
+
const { selection } = useMouseHandler({
|
|
380
|
+
onScrollUp: handleScrollUp,
|
|
381
|
+
onScrollDown: handleScrollDown,
|
|
382
|
+
onScrollByLines: handleScrollByLines,
|
|
383
|
+
onSelectionComplete: handleSelectionComplete,
|
|
384
|
+
onRightClick: handleRightClick,
|
|
385
|
+
});
|
|
386
|
+
// Dashboard subscription management callbacks. Depend on the stable inner
|
|
387
|
+
// functions (each a useCallback in useDashboardData), NOT the whole `dashboard`
|
|
388
|
+
// object — that object is recreated every render, which previously made these
|
|
389
|
+
// wrappers (and thus the Dashboard effect deps) change identity on every render.
|
|
390
|
+
const { markPending, registerSubscription, unregisterSubscription } = dashboard;
|
|
203
391
|
const handleMarkPending = useCallback((tab) => {
|
|
204
|
-
|
|
205
|
-
}, [
|
|
392
|
+
markPending(tab);
|
|
393
|
+
}, [markPending]);
|
|
206
394
|
const handleRegisterSubscription = useCallback((queryId, tab) => {
|
|
207
|
-
|
|
208
|
-
}, [
|
|
395
|
+
registerSubscription(queryId, tab);
|
|
396
|
+
}, [registerSubscription]);
|
|
209
397
|
const handleUnregisterSubscription = useCallback((queryId) => {
|
|
210
|
-
|
|
211
|
-
}, [
|
|
398
|
+
unregisterSubscription(queryId);
|
|
399
|
+
}, [unregisterSubscription]);
|
|
400
|
+
// Compute the actual reserved rows for the bottom UI so Transcript sizes its viewport exactly.
|
|
401
|
+
// Base = marginTop(1) + border(3) + StatusLine(1) = 5, plus the optional line above the input
|
|
402
|
+
// (toast OR turn-status — InputBox renders one or the other) and the awaiting-response hint.
|
|
403
|
+
const reservedBottomRows = 5 + ((toast || turnStatus) ? 1 : 0) + (awaitingResponse && focusZone === 'input' ? 1 : 0);
|
|
212
404
|
// If resume mode with sessions to pick, show picker instead of main layout
|
|
213
405
|
if (resumableSessions && resumableSessions.length > 0 && onResumeSelect && onResumeCancel) {
|
|
214
|
-
return (_jsx(Box, { flexDirection: "column", height:
|
|
406
|
+
return (_jsx(Box, { flexDirection: "column", height: termSize.rows, width: termSize.columns, justifyContent: "center", alignItems: "center", children: _jsx(SessionPicker, { sessions: resumableSessions, onSelect: onResumeSelect, onCancel: onResumeCancel }) }));
|
|
215
407
|
}
|
|
216
|
-
return (_jsxs(Box, { flexDirection: "column", height:
|
|
408
|
+
return (_jsxs(Box, { flexDirection: "column", height: termSize.rows, width: termSize.columns, children: [_jsx(Box, { flexDirection: "row", flexGrow: 1, justifyContent: "center", children: sidePanelVisible ? (_jsx(SidePanel, { visible: sidePanelVisible, active: focusZone === 'dashboard', sendFrame: sendFrame, projectId: projectId, dashState: dashboard.state, onMarkPending: handleMarkPending, onRegisterSubscription: handleRegisterSubscription, onUnregisterSubscription: handleUnregisterSubscription, activeTab: activeTab, onSetActiveTab: setActiveTab, onMutate: mutate, onClose: handleToggleSidePanel })) : (_jsx(Box, { flexDirection: "column", flexGrow: 1, children: _jsx(Transcript, { ref: transcriptRef, messages: transcript.messages, ids: transcript.ids, reservedRows: reservedBottomRows, selection: selection }) })) }), activeModal ? (activeModal.modal.callbackId.startsWith('plan')
|
|
217
409
|
? _jsx(PlanFeedbackModal, { modal: activeModal.modal, triggerId: activeModal.triggerId, sendFrame: sendFrame, ackErrors: modalAckErrors, onClose: () => { setActiveModal(null); setModalAckErrors({}); } })
|
|
218
|
-
: _jsx(AskUserModal, { modal: activeModal.modal, triggerId: activeModal.triggerId, sendFrame: sendFrame, ackErrors: modalAckErrors, onClose: () => { setActiveModal(null); setModalAckErrors({}); } })) : modalOpen ? (_jsxs(Box, { borderStyle: "single", borderDimColor: true, paddingX: 1, marginTop: 1, children: [notificationsOpen ? (_jsx(NotificationsModal, { open: notificationsOpen, notifications: notif.notifications, ids: notif.ids, onMarkRead: notif.markRead, onClose: () => setNotificationsOpen(false), onSelect: handleNotificationSelect })) : null, projectSwitcherOpen ? (_jsx(ProjectSwitcher, { open: projectSwitcherOpen, projects: projects, loading: projectsLoading, error: projectsError, onSelect: handleProjectSelect, onClose: () => setProjectSwitcherOpen(false), onRequestRefresh: handleProjectsRefresh })) : null] })) : (_jsx(InputBox, { onSubmit: handleSubmit, awaitingResponse: awaitingResponse, focus: focusZone === 'input' })), _jsx(StatusLine, { connectionState: connectionState, queuedCount: queuedCount, notificationCount: notif.unreadCount,
|
|
410
|
+
: _jsx(AskUserModal, { modal: activeModal.modal, triggerId: activeModal.triggerId, sendFrame: sendFrame, ackErrors: modalAckErrors, onClose: () => { setActiveModal(null); setModalAckErrors({}); } })) : modalOpen ? (_jsxs(Box, { borderStyle: "single", borderDimColor: true, paddingX: 1, marginTop: 1, children: [notificationsOpen ? (_jsx(NotificationsModal, { open: notificationsOpen, notifications: notif.notifications, ids: notif.ids, onMarkRead: notif.markRead, onClose: () => setNotificationsOpen(false), onSelect: handleNotificationSelect })) : null, projectSwitcherOpen ? (_jsx(ProjectSwitcher, { open: projectSwitcherOpen, projects: projects, loading: projectsLoading, error: projectsError, onSelect: handleProjectSelect, onClose: () => setProjectSwitcherOpen(false), onRequestRefresh: handleProjectsRefresh })) : null, slashResumeSessions !== null ? (_jsx(SessionPicker, { sessions: slashResumeSessions, onSelect: handleSlashResumeSelect, onCancel: handleSlashResumeCancel })) : null] })) : (_jsx(InputBox, { onSubmit: handleSubmit, onCommand: handleCommand, commands: SLASH_COMMANDS, awaitingResponse: awaitingResponse, focus: focusZone === 'input', showShortcuts: showShortcuts, onToggleShortcuts: handleToggleShortcuts, onDismissShortcuts: handleDismissShortcuts, statusLine: turnStatus, toast: toast })), _jsx(StatusLine, { connectionState: connectionState, errorMessage: errorMessage, projectId: projectId, queuedCount: queuedCount, notificationCount: notif.unreadCount, showShortcuts: showShortcuts && focusZone === 'input', dashboardActive: focusZone === 'dashboard', mouseCapture: mouseCapture })] }));
|
|
219
411
|
}
|
|
@@ -18,6 +18,8 @@ interface DashboardProps {
|
|
|
18
18
|
onUnregisterSubscription: (queryId: string) => void;
|
|
19
19
|
activeTab: string;
|
|
20
20
|
onSetActiveTab: (tab: string) => void;
|
|
21
|
+
/** Close the panel (Esc while the dashboard owns the keyboard, mirrors the Ctrl+D toggle). */
|
|
22
|
+
onClose?: () => void;
|
|
21
23
|
}
|
|
22
|
-
export declare function Dashboard({ active, sendFrame, mutate, projectId, dashState, onMarkPending, onRegisterSubscription, onUnregisterSubscription, activeTab, onSetActiveTab, }: DashboardProps): React.JSX.Element;
|
|
24
|
+
export declare function Dashboard({ active, sendFrame, mutate, projectId, dashState, onMarkPending, onRegisterSubscription, onUnregisterSubscription, activeTab, onSetActiveTab, onClose, }: DashboardProps): React.JSX.Element;
|
|
23
25
|
export {};
|
|
@@ -20,6 +20,21 @@ export const DASHBOARD_TABS = [
|
|
|
20
20
|
// ── Tab content renderer ──
|
|
21
21
|
function TabContent({ tab, active, sendFrame, mutate, projectId, dashState, onMarkPending, onRegisterSubscription, onUnregisterSubscription, }) {
|
|
22
22
|
const initialQuerySent = useRef(false);
|
|
23
|
+
// The parent (App) hands us fresh callback / sendFrame identities on every render.
|
|
24
|
+
// Holding them in refs lets the query/subscribe effect depend only on
|
|
25
|
+
// [tab, projectId], so it never re-fires (and re-subscribes) merely because the
|
|
26
|
+
// parent re-rendered. Without this the effect cleaned up + re-ran every render,
|
|
27
|
+
// each run calling onMarkPending → setState → re-render → infinite loop (the
|
|
28
|
+
// Ctrl+D render storm that pegged a CPU core at ~95% with "Maximum update depth
|
|
29
|
+
// exceeded").
|
|
30
|
+
const sendFrameRef = useRef(sendFrame);
|
|
31
|
+
sendFrameRef.current = sendFrame;
|
|
32
|
+
const onMarkPendingRef = useRef(onMarkPending);
|
|
33
|
+
onMarkPendingRef.current = onMarkPending;
|
|
34
|
+
const onRegisterSubscriptionRef = useRef(onRegisterSubscription);
|
|
35
|
+
onRegisterSubscriptionRef.current = onRegisterSubscription;
|
|
36
|
+
const onUnregisterSubscriptionRef = useRef(onUnregisterSubscription);
|
|
37
|
+
onUnregisterSubscriptionRef.current = onUnregisterSubscription;
|
|
23
38
|
// Initial query + subscribe (runs once per tab mount)
|
|
24
39
|
React.useEffect(() => {
|
|
25
40
|
const scope = TAB_SCOPES[tab];
|
|
@@ -29,29 +44,29 @@ function TabContent({ tab, active, sendFrame, mutate, projectId, dashState, onMa
|
|
|
29
44
|
if (!initialQuerySent.current) {
|
|
30
45
|
initialQuerySent.current = true;
|
|
31
46
|
// Send query for initial data
|
|
32
|
-
|
|
33
|
-
|
|
47
|
+
sendFrameRef.current({ type: 'ui.query', id: queryId, scope: tab === 'cost' ? 'cost.summary' : `${tab}.list`, params: projectId ? { projectId } : {} });
|
|
48
|
+
onMarkPendingRef.current(tab);
|
|
34
49
|
// Subscribe to events
|
|
35
|
-
|
|
36
|
-
|
|
50
|
+
sendFrameRef.current({ type: 'ui.subscribe', id: queryId, filter: { events: scope.events, projectId } });
|
|
51
|
+
onRegisterSubscriptionRef.current(queryId, tab);
|
|
37
52
|
}
|
|
38
53
|
// Cleanup on unmount
|
|
39
54
|
return () => {
|
|
40
|
-
|
|
41
|
-
|
|
55
|
+
sendFrameRef.current({ type: 'ui.unsubscribe', id: queryId });
|
|
56
|
+
onUnregisterSubscriptionRef.current(queryId);
|
|
42
57
|
initialQuerySent.current = false;
|
|
43
58
|
};
|
|
44
|
-
}, [tab, projectId
|
|
59
|
+
}, [tab, projectId]);
|
|
45
60
|
// Re-fetch when loading is triggered by a subscription event
|
|
46
61
|
React.useEffect(() => {
|
|
47
62
|
const scope = TAB_SCOPES[tab];
|
|
48
63
|
if (!scope || !initialQuerySent.current)
|
|
49
64
|
return;
|
|
50
65
|
if (dashState.tabs[tab].loading) {
|
|
51
|
-
|
|
52
|
-
|
|
66
|
+
sendFrameRef.current({ type: 'ui.query', id: scope.queryId, scope: tab === 'cost' ? 'cost.summary' : `${tab}.list`, params: projectId ? { projectId } : {} });
|
|
67
|
+
onMarkPendingRef.current(tab);
|
|
53
68
|
}
|
|
54
|
-
}, [dashState.tabs[tab].loading, tab, projectId
|
|
69
|
+
}, [dashState.tabs[tab].loading, tab, projectId]);
|
|
55
70
|
switch (tab) {
|
|
56
71
|
case 'threads':
|
|
57
72
|
return _jsx(DashboardThreadsTab, { data: dashState.tabs.threads, mutate: mutate, active: active });
|
|
@@ -68,13 +83,17 @@ function TabContent({ tab, active, sendFrame, mutate, projectId, dashState, onMa
|
|
|
68
83
|
}
|
|
69
84
|
}
|
|
70
85
|
// ── Component ──
|
|
71
|
-
export function Dashboard({ active, sendFrame, mutate, projectId, dashState, onMarkPending, onRegisterSubscription, onUnregisterSubscription, activeTab, onSetActiveTab, }) {
|
|
86
|
+
export function Dashboard({ active, sendFrame, mutate, projectId, dashState, onMarkPending, onRegisterSubscription, onUnregisterSubscription, activeTab, onSetActiveTab, onClose, }) {
|
|
72
87
|
useInput((_input, key) => {
|
|
88
|
+
if (key.escape) {
|
|
89
|
+
onClose?.();
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
73
92
|
if (key.tab) {
|
|
74
93
|
const currentIdx = DASHBOARD_TABS.findIndex(t => t.key === activeTab);
|
|
75
94
|
const nextIdx = (currentIdx + 1) % DASHBOARD_TABS.length;
|
|
76
95
|
onSetActiveTab(DASHBOARD_TABS[nextIdx].key);
|
|
77
96
|
}
|
|
78
97
|
}, { isActive: active });
|
|
79
|
-
return (_jsxs(Box, { flexDirection: "column", width: "100%", children: [_jsx(Box, { children: DASHBOARD_TABS.map(t => (
|
|
98
|
+
return (_jsxs(Box, { flexDirection: "column", width: "100%", children: [_jsx(Box, { children: DASHBOARD_TABS.map((t, i) => (_jsxs(React.Fragment, { children: [i > 0 ? _jsx(Text, { dimColor: true, children: " " }) : null, _jsx(Text, { bold: t.key === activeTab, inverse: t.key === activeTab, children: t.label })] }, t.key))) }), _jsx(Box, { flexDirection: "column", flexGrow: 1, paddingX: 1, children: _jsx(TabContent, { tab: activeTab, active: active, sendFrame: sendFrame, mutate: mutate, projectId: projectId, dashState: dashState, onMarkPending: onMarkPending, onRegisterSubscription: onRegisterSubscription, onUnregisterSubscription: onUnregisterSubscription }) })] }));
|
|
80
99
|
}
|
|
@@ -10,7 +10,22 @@ export function DashboardCostTab({ data }) {
|
|
|
10
10
|
if (!data.data || (Array.isArray(data.data) && data.data.length === 0)) {
|
|
11
11
|
return _jsx(Text, { dimColor: true, children: "No cost data" });
|
|
12
12
|
}
|
|
13
|
-
//
|
|
13
|
+
// The server returns a CostSummary object (domain/costs/cost-tracker.ts): top-level
|
|
14
|
+
// today/week/month/total are USD numbers; byMode maps mode → { today, week, month, total }.
|
|
15
|
+
// useDashboardData wraps a non-array response in a single-element array.
|
|
14
16
|
const costData = Array.isArray(data.data) ? data.data[0] : data.data;
|
|
15
|
-
|
|
17
|
+
const usd = (v) => `$${typeof v === 'number' ? v.toFixed(4) : String(v)}`;
|
|
18
|
+
// byMode is keyed by PERIOD (today/week/month/total); each value is a ModeBuckets
|
|
19
|
+
// { total, api, plan, ... } breaking that period down by cost type. The all-time
|
|
20
|
+
// bucket (byMode.total) gives the api/plan split; skip the 'total' meta key.
|
|
21
|
+
const allTime = costData?.byMode?.total && typeof costData.byMode.total === 'object' ? costData.byMode.total : {};
|
|
22
|
+
const modeEntries = Object.entries(allTime)
|
|
23
|
+
.filter(([k, v]) => k !== 'total' && typeof v === 'number' && v > 0);
|
|
24
|
+
const hasAnyTotal = costData?.total != null || costData?.month != null || costData?.today != null;
|
|
25
|
+
if (!hasAnyTotal && modeEntries.length === 0) {
|
|
26
|
+
return _jsx(Text, { dimColor: true, children: "No cost summary available" });
|
|
27
|
+
}
|
|
28
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Box, { marginBottom: 1, children: _jsx(Text, { bold: true, children: "Cost Summary" }) }), costData?.total != null ? (_jsxs(Box, { children: [_jsx(Text, { children: "Total: " }), _jsx(Text, { children: usd(costData.total) })] })) : null, costData?.month != null ? (_jsxs(Box, { children: [_jsx(Text, { children: "This month: " }), _jsx(Text, { children: usd(costData.month) })] })) : null, costData?.week != null ? (_jsxs(Box, { children: [_jsx(Text, { children: "This week: " }), _jsx(Text, { children: usd(costData.week) })] })) : null, costData?.today != null ? (_jsxs(Box, { children: [_jsx(Text, { children: "Today: " }), _jsx(Text, { children: usd(costData.today) })] })) : null, modeEntries.length > 0 ? (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsx(Text, { dimColor: true, children: "By cost type (all-time):" }), modeEntries
|
|
29
|
+
.sort(([, a], [, b]) => b - a)
|
|
30
|
+
.map(([mode, v]) => (_jsxs(Box, { marginLeft: 1, children: [_jsxs(Text, { dimColor: true, children: [mode, ": "] }), _jsx(Text, { children: usd(v) })] }, mode)))] })) : null] }));
|
|
16
31
|
}
|
|
@@ -5,6 +5,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
5
5
|
import { useState, useCallback, useRef, useEffect } from 'react';
|
|
6
6
|
import { Box, Text, useInput } from 'ink';
|
|
7
7
|
import { ConfirmModal } from './ConfirmModal.js';
|
|
8
|
+
import { computeFocusWindow } from '../logic.js';
|
|
9
|
+
import { DASHBOARD_MAX_VISIBLE_ROWS } from './dashboard-constants.js';
|
|
8
10
|
export function DashboardExecutionsTab({ data, mutate, active = true }) {
|
|
9
11
|
const [focusedIndex, setFocusedIndex] = useState(0);
|
|
10
12
|
const [showConfirm, setShowConfirm] = useState(false);
|
|
@@ -66,6 +68,9 @@ export function DashboardExecutionsTab({ data, mutate, active = true }) {
|
|
|
66
68
|
}
|
|
67
69
|
// Clamp focused index to valid range
|
|
68
70
|
const safeFocused = Math.min(focusedIndex, data.data.length - 1);
|
|
71
|
+
// Cap the rendered slice so a long list can't overflow the terminal (ghost-row corruption).
|
|
72
|
+
const { start, end, hiddenAbove, hiddenBelow } = computeFocusWindow(data.data.length, safeFocused, DASHBOARD_MAX_VISIBLE_ROWS);
|
|
73
|
+
const visible = data.data.slice(start, end);
|
|
69
74
|
const focusedExec = showConfirm ? data.data[confirmIndexRef.current] : null;
|
|
70
75
|
// Build ConfirmModal body from focused execution fields
|
|
71
76
|
let confirmBody = '';
|
|
@@ -80,7 +85,22 @@ export function DashboardExecutionsTab({ data, mutate, active = true }) {
|
|
|
80
85
|
}
|
|
81
86
|
confirmBody = parts.join(' | ');
|
|
82
87
|
}
|
|
83
|
-
return (_jsxs(Box, { flexDirection: "column", children: [
|
|
88
|
+
return (_jsxs(Box, { flexDirection: "column", children: [hiddenAbove > 0 ? _jsxs(Text, { dimColor: true, children: ["\u2191 ", hiddenAbove, " more above"] }) : null, visible.map((exec, vi) => {
|
|
89
|
+
const i = start + vi;
|
|
90
|
+
return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsxs(Box, { children: [_jsx(Text, { children: i === safeFocused ? '>' : ' ' }), _jsx(Text, { children: " " }), _jsx(ExecStatusIcon, { status: exec.status }), _jsx(Text, { children: " " }), _jsx(Text, { bold: i === safeFocused, children: exec.type ?? 'local' }), exec.machine ? _jsxs(Text, { dimColor: true, children: [" @", exec.machine] }) : null] }), _jsx(Box, { marginLeft: 2, children: _jsx(Text, { dimColor: true, children: execDetailLine(exec) }) }), notFoundMsg?.index === i ? (_jsx(Box, { marginLeft: 2, children: _jsx(Text, { color: "red", children: notFoundMsg.message }) })) : null] }, exec.id ?? i));
|
|
91
|
+
}), hiddenBelow > 0 ? _jsxs(Text, { dimColor: true, children: ["\u2193 ", hiddenBelow, " more below"] }) : null, showConfirm && focusedExec ? (_jsx(ConfirmModal, { title: "Cancel execution?", body: confirmBody, onConfirm: handleConfirm, onCancel: handleCancel })) : null] }));
|
|
92
|
+
}
|
|
93
|
+
/** Compose the "45.2s | $0.1234 | <time>" detail line, omitting any missing field so a
|
|
94
|
+
* zero/absent duration no longer renders a dangling leading " | ". */
|
|
95
|
+
function execDetailLine(exec) {
|
|
96
|
+
const parts = [];
|
|
97
|
+
if (exec.durationMs)
|
|
98
|
+
parts.push(`${(exec.durationMs / 1000).toFixed(1)}s`);
|
|
99
|
+
if (exec.cost != null)
|
|
100
|
+
parts.push(`$${typeof exec.cost === 'number' ? exec.cost.toFixed(4) : exec.cost}`);
|
|
101
|
+
if (exec.finishedAt)
|
|
102
|
+
parts.push(new Date(exec.finishedAt).toLocaleString());
|
|
103
|
+
return parts.join(' | ');
|
|
84
104
|
}
|
|
85
105
|
function ExecStatusIcon({ status }) {
|
|
86
106
|
switch (status) {
|
|
@@ -5,6 +5,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
5
5
|
import { useState, useRef, useEffect, useCallback } from 'react';
|
|
6
6
|
import { Box, Text, useInput } from 'ink';
|
|
7
7
|
import { ConfirmModal } from './ConfirmModal.js';
|
|
8
|
+
import { computeFocusWindow } from '../logic.js';
|
|
9
|
+
import { DASHBOARD_MAX_VISIBLE_ROWS } from './dashboard-constants.js';
|
|
8
10
|
export function DashboardSchedulesTab({ data, mutate, active = true }) {
|
|
9
11
|
if (data.loading && data.data.length === 0) {
|
|
10
12
|
return _jsx(Text, { dimColor: true, children: "Loading schedules..." });
|
|
@@ -89,8 +91,11 @@ function SchedulesList({ data, mutate, active = true }) {
|
|
|
89
91
|
removingScheduleIdRef.current = sched.id;
|
|
90
92
|
}
|
|
91
93
|
}, { isActive: isInputActive });
|
|
92
|
-
// ── Build schedule rows ──
|
|
93
|
-
const
|
|
94
|
+
// ── Build schedule rows (windowed so a long list can't overflow the terminal) ──
|
|
95
|
+
const safeFocused = Math.min(focusedRowIndex, schedules.length - 1);
|
|
96
|
+
const { start, end, hiddenAbove, hiddenBelow } = computeFocusWindow(schedules.length, safeFocused, DASHBOARD_MAX_VISIBLE_ROWS);
|
|
97
|
+
const rows = schedules.slice(start, end).map((sched, vi) => {
|
|
98
|
+
const i = start + vi;
|
|
94
99
|
const isFocused = i === focusedRowIndex;
|
|
95
100
|
return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsxs(Box, { children: [isFocused ? _jsx(Text, { bold: true, children: '> ' }) : _jsx(Text, { children: " " }), _jsx(ScheduleTypeBadge, { type: sched.type, paused: sched.paused, focused: isFocused }), _jsx(Text, { children: " " }), _jsxs(Text, { bold: isFocused, dimColor: !isFocused, children: [String(sched.message ?? '').slice(0, 25), (sched.message ?? '').length > 25 ? '…' : ''] })] }), _jsx(Box, { marginLeft: 2, children: _jsx(Text, { dimColor: true, children: sched.paused
|
|
96
101
|
? `paused by ${sched.pausedBy ?? '?'}`
|
|
@@ -115,7 +120,7 @@ function SchedulesList({ data, mutate, active = true }) {
|
|
|
115
120
|
removingScheduleIdRef.current = null;
|
|
116
121
|
} }));
|
|
117
122
|
}
|
|
118
|
-
return (_jsxs(Box, { flexDirection: "column", children: [rows, confirmModal] }));
|
|
123
|
+
return (_jsxs(Box, { flexDirection: "column", children: [hiddenAbove > 0 ? _jsxs(Text, { dimColor: true, children: ["\u2191 ", hiddenAbove, " more above"] }) : null, rows, hiddenBelow > 0 ? _jsxs(Text, { dimColor: true, children: ["\u2193 ", hiddenBelow, " more below"] }) : null, confirmModal] }));
|
|
119
124
|
}
|
|
120
125
|
function ScheduleTypeBadge({ type, paused, focused }) {
|
|
121
126
|
const color = paused ? 'yellow' : 'green';
|
|
@@ -5,6 +5,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
5
5
|
import { useState, useRef, useEffect, useCallback } from 'react';
|
|
6
6
|
import { Box, Text, useInput } from 'ink';
|
|
7
7
|
import { ConfirmModal } from './ConfirmModal.js';
|
|
8
|
+
import { computeFocusWindow } from '../logic.js';
|
|
9
|
+
import { DASHBOARD_MAX_VISIBLE_ROWS } from './dashboard-constants.js';
|
|
8
10
|
// ── Component ──
|
|
9
11
|
export function DashboardTasksTab({ data, mutate, projectId, active = true }) {
|
|
10
12
|
if (data.loading && data.data.length === 0) {
|
|
@@ -174,12 +176,15 @@ function TasksList({ data, mutate, projectId, active = true }) {
|
|
|
174
176
|
}
|
|
175
177
|
}
|
|
176
178
|
// ── Task list ──
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
179
|
+
const safeFocused = Math.min(focusedIndex, tasks.length - 1);
|
|
180
|
+
const { start, end, hiddenAbove, hiddenBelow } = computeFocusWindow(tasks.length, safeFocused, DASHBOARD_MAX_VISIBLE_ROWS);
|
|
181
|
+
return (_jsxs(Box, { flexDirection: "column", children: [hiddenAbove > 0 ? _jsxs(Text, { dimColor: true, children: ["\u2191 ", hiddenAbove, " more above"] }) : null, tasks.slice(start, end).map((task, vi) => {
|
|
182
|
+
const i = start + vi;
|
|
183
|
+
const isFocused = i === focusedIndex;
|
|
184
|
+
const isLockBusy = lockBusyRows.has(i);
|
|
185
|
+
const hasError = errorState?.index === i;
|
|
186
|
+
return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsxs(Box, { children: [isFocused ? _jsx(Text, { color: "cyan", children: "\u25B8 " }) : _jsx(Text, { children: " " }), _jsx(TaskStatusIcon, { status: task.status }), _jsx(Text, { children: " " }), _jsx(PriorityBadge, { priority: task.priority }), _jsx(Text, { children: " " }), _jsxs(Text, { bold: isFocused, children: [String(task.text ?? '').slice(0, 30), (task.text ?? '').length > 30 ? '…' : ''] })] }), _jsx(Box, { marginLeft: 2, children: _jsxs(Text, { dimColor: true, children: [task.claimedBy ? `👤 ${task.claimedBy}` : 'unclaimed', task.blockedBy ? ` | blocked: ${task.blockedBy}` : ''] }) }), isFocused && mutate ? (_jsx(Box, { marginLeft: 2, children: _jsx(Text, { dimColor: true, children: "[c] Claim [u] Unclaim [d] Done [b] Block [B] Unblock" }) })) : null, isLockBusy ? (_jsx(Box, { marginLeft: 2, children: _jsx(Text, { color: "yellow", children: "busy \u2014 another agent holds the lock (auto-expires in 20m)" }) })) : null, hasError ? (_jsx(Box, { marginLeft: 2, children: _jsxs(Text, { color: "red", children: [errorState.code, ": ", errorState.message] }) })) : null] }, task.id ?? i));
|
|
187
|
+
}), hiddenBelow > 0 ? _jsxs(Text, { dimColor: true, children: ["\u2193 ", hiddenBelow, " more below"] }) : null] }));
|
|
183
188
|
}
|
|
184
189
|
// ── Sub-components ──
|
|
185
190
|
function TaskStatusIcon({ status }) {
|