@cortex-agent/server 2026.6.24 → 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/gitignore +3 -0
- package/defaults/hooks/CORTEX.md +18 -0
- package/defaults/hooks/cortex-hook-api.mjs +84 -0
- package/defaults/hooks/cortex-md-injector.mjs +99 -49
- package/defaults/hooks/session-activity-tracker.mjs +8 -101
- package/defaults/hooks/task-status-check.mjs +10 -11
- 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-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.md +7 -31
- 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 +2 -0
- package/dist/agent-adapter/claude/adapter-tui.js +1 -0
- package/dist/agent-adapter/claude/adapter.d.ts +89 -5
- package/dist/agent-adapter/claude/adapter.js +404 -38
- package/dist/agent-adapter/claude/bg-task-tracker.d.ts +22 -15
- package/dist/agent-adapter/claude/bg-task-tracker.js +48 -32
- 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 +5 -10
- 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 +24 -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/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/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 +87 -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 +61 -10
- package/dist/domain/agents/facade.js +309 -61
- 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 +3 -8
- package/dist/domain/mcp/feishu-server.d.ts +0 -1
- package/dist/domain/mcp/feishu-server.js +4 -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/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.js +4 -3
- 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 +39 -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 +7 -14
- package/dist/domain/sessions/session-hooks.js +66 -112
- 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.js +4 -7
- 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 +30 -3
- package/dist/domain/tasks/system/task-completion.js +148 -42
- package/dist/domain/tasks/system/task-lifecycle-edit.js +3 -0
- 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 +7 -0
- package/dist/domain/threads/prompt-builder.js +30 -13
- package/dist/domain/threads/runner.d.ts +19 -5
- package/dist/domain/threads/runner.js +211 -78
- 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 +281 -34
- 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/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/cortex-hook-api.mjs +84 -0
- package/dist/hooks/cortex-md-injector.mjs +99 -49
- package/dist/hooks/session-activity-tracker.mjs +8 -101
- package/dist/hooks/task-status-check.mjs +10 -11
- 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 +365 -53
- 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 +70 -15
- 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 +8 -3
- package/dist/orchestration/lifecycle.js +143 -62
- package/dist/orchestration/manager-qa.d.ts +12 -2
- package/dist/orchestration/manager-qa.js +34 -33
- 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 +21 -4
- package/dist/orchestration/resume-dispatcher.js +67 -37
- 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 -7
- package/dist/orchestration/thread-callback.js +300 -49
- 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/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 +2 -0
- package/dist/store/version-migrations.js +186 -9
- package/dist/tui/App.js +208 -20
- package/dist/tui/components/Dashboard.d.ts +3 -1
- package/dist/tui/components/Dashboard.js +5 -1
- 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 +237 -21
- 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 -600
- 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/block-types.d.ts +0 -44
- package/dist/domain/mcp/feishu/block-types.js +0 -127
- 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
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// input: UiServiceDeps + MachinesListParams (empty)
|
|
2
|
+
// output: machines.list handler → MachineInfo[] (joined from machines.json + client-manager + executionRegistry)
|
|
3
|
+
// pos: query handler for 'machines.list' (plan §12 A item 1). Joins three real sources:
|
|
4
|
+
// 1. deps.clientRegistry.getMachineRegistry() — static config (cortexPath/gpuCount/ssh/win)
|
|
5
|
+
// 2. deps.clientRegistry.getOnlineDevices() — live WebSocket state (online/timestamps/capabilities)
|
|
6
|
+
// 3. deps.executionRegistry.getAll() — running dispatch execution count per machine
|
|
7
|
+
// SECURITY: ssh field is a presence flag only (sshConfigured:boolean) — raw user@host never returned.
|
|
8
|
+
// >>> If I am updated, update CORTEX.md and the parent folder's CORTEX.md <<<
|
|
9
|
+
export async function handleMachinesList(deps, _params) {
|
|
10
|
+
const registry = deps.clientRegistry.getMachineRegistry();
|
|
11
|
+
const onlineDevices = deps.clientRegistry.getOnlineDevices();
|
|
12
|
+
const allExecutions = deps.executionRegistry.getAll();
|
|
13
|
+
// Build device-name → online info map for O(1) lookups
|
|
14
|
+
const onlineMap = new Map(onlineDevices.map((d) => [d.device, d]));
|
|
15
|
+
// Count running dispatch executions per machine
|
|
16
|
+
const liveRunsMap = new Map();
|
|
17
|
+
for (const exec of allExecutions) {
|
|
18
|
+
const machine = exec.dispatch?.machine;
|
|
19
|
+
if (exec.status === 'running' && typeof machine === 'string' && machine) {
|
|
20
|
+
liveRunsMap.set(machine, (liveRunsMap.get(machine) ?? 0) + 1);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return Object.entries(registry).map(([name, entry]) => {
|
|
24
|
+
const onlineInfo = onlineMap.get(name);
|
|
25
|
+
return {
|
|
26
|
+
name,
|
|
27
|
+
cortexPath: typeof entry.cortexPath === 'string' ? entry.cortexPath : null,
|
|
28
|
+
gpuCount: typeof entry.gpuCount === 'number' ? entry.gpuCount : null,
|
|
29
|
+
// ssh presence flag only — raw user@host is never exposed
|
|
30
|
+
sshConfigured: typeof entry.ssh === 'string' && entry.ssh.length > 0,
|
|
31
|
+
os: entry.win === true ? 'windows' : 'unix',
|
|
32
|
+
online: !!onlineInfo,
|
|
33
|
+
connectedAt: onlineInfo ? onlineInfo.connectedAt.toISOString() : null,
|
|
34
|
+
lastHeartbeat: onlineInfo ? onlineInfo.lastHeartbeat.toISOString() : null,
|
|
35
|
+
capabilities: onlineInfo ? [...onlineInfo.capabilities] : [],
|
|
36
|
+
liveRuns: liveRunsMap.get(name) ?? 0,
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { UiServiceDeps, MemoryTreeParams, MemoryFileParams, MemoryTree, MemoryFile, MemoryBlameLine } from '../types.js';
|
|
2
|
+
export declare function handleMemoryTree(deps: UiServiceDeps, params: MemoryTreeParams): Promise<MemoryTree>;
|
|
3
|
+
export declare function parseTaskRef(subject: string): string | null;
|
|
4
|
+
export declare function parseBlamePorcelain(out: string): MemoryBlameLine[];
|
|
5
|
+
export declare function handleMemoryFile(deps: UiServiceDeps, params: MemoryFileParams): Promise<MemoryFile>;
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
// input: UiServiceDeps + MemoryTreeParams / MemoryFileParams
|
|
2
|
+
// output: handleMemoryTree → MemoryTree; handleMemoryFile → MemoryFile
|
|
3
|
+
// pos: read-only fs query handlers for 'memory.tree' and 'memory.file'. All paths are
|
|
4
|
+
// restricted to the project root (Project.contextDir under PROJECTS_DIR); traversal,
|
|
5
|
+
// absolute paths, and symlink escape are rejected. No write API is used.
|
|
6
|
+
import * as fs from 'node:fs';
|
|
7
|
+
import * as path from 'node:path';
|
|
8
|
+
import { execFileSync } from 'node:child_process';
|
|
9
|
+
// Canonical top-level memory files, in display order. Missing ones are omitted (not errored).
|
|
10
|
+
const TOP_LEVEL_FILES = ['mission.md', 'roadmap.md', 'STATUS.md', 'TASKS.yaml'];
|
|
11
|
+
// Memory subdirectories whose `*.md` entries are counted (excluding the auto-generated index.md).
|
|
12
|
+
const MEMORY_DIRS = ['experiments', 'knowledge', 'patterns', 'decisions'];
|
|
13
|
+
function notFound(message) {
|
|
14
|
+
return Object.assign(new Error(message), { code: 'not-found' });
|
|
15
|
+
}
|
|
16
|
+
function invalidArgs(message) {
|
|
17
|
+
return Object.assign(new Error(message), { code: 'invalid-args' });
|
|
18
|
+
}
|
|
19
|
+
// Resolve the project's real (symlink-canonical) root directory, or throw not-found.
|
|
20
|
+
function resolveProjectRoot(deps, projectId) {
|
|
21
|
+
const project = deps.projectStore.get(projectId);
|
|
22
|
+
if (!project)
|
|
23
|
+
throw notFound(`project not found: ${projectId}`);
|
|
24
|
+
try {
|
|
25
|
+
return fs.realpathSync(project.contextDir);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
throw notFound(`project directory not found: ${projectId}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
// True when `child` is `root` itself or strictly nested under it.
|
|
32
|
+
function isWithin(root, child) {
|
|
33
|
+
return child === root || child.startsWith(root + path.sep);
|
|
34
|
+
}
|
|
35
|
+
// Resolve a project-root-relative file path to an absolute path, rejecting absolute inputs,
|
|
36
|
+
// `..` traversal, non-files, and symlink escape (via realpath re-check). Read-only.
|
|
37
|
+
function resolveMemoryFilePath(realRoot, relPath) {
|
|
38
|
+
if (path.isAbsolute(relPath))
|
|
39
|
+
throw invalidArgs(`absolute path not allowed: ${relPath}`);
|
|
40
|
+
const resolved = path.resolve(realRoot, relPath);
|
|
41
|
+
if (!isWithin(realRoot, resolved))
|
|
42
|
+
throw invalidArgs(`path escapes project root: ${relPath}`);
|
|
43
|
+
let real;
|
|
44
|
+
try {
|
|
45
|
+
real = fs.realpathSync(resolved);
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
throw notFound(`file not found: ${relPath}`);
|
|
49
|
+
}
|
|
50
|
+
// Symlink escape: the real (canonical) path must still live under the real root.
|
|
51
|
+
if (!isWithin(realRoot, real))
|
|
52
|
+
throw invalidArgs(`path escapes project root: ${relPath}`);
|
|
53
|
+
if (!fs.statSync(real).isFile())
|
|
54
|
+
throw invalidArgs(`not a file: ${relPath}`);
|
|
55
|
+
return real;
|
|
56
|
+
}
|
|
57
|
+
export async function handleMemoryTree(deps, params) {
|
|
58
|
+
const root = resolveProjectRoot(deps, params.projectId);
|
|
59
|
+
const files = TOP_LEVEL_FILES.flatMap((name) => {
|
|
60
|
+
const abs = path.join(root, name);
|
|
61
|
+
let st;
|
|
62
|
+
try {
|
|
63
|
+
st = fs.statSync(abs);
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
if (!st.isFile())
|
|
69
|
+
return [];
|
|
70
|
+
return [{ name, sizeBytes: st.size, modifiedAt: st.mtime.toISOString() }];
|
|
71
|
+
});
|
|
72
|
+
const dirs = MEMORY_DIRS.flatMap((name) => {
|
|
73
|
+
const abs = path.join(root, name);
|
|
74
|
+
let dirents;
|
|
75
|
+
try {
|
|
76
|
+
dirents = fs.readdirSync(abs, { withFileTypes: true });
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
const entries = dirents
|
|
82
|
+
.filter((e) => e.isFile() && e.name.endsWith('.md') && e.name !== 'index.md' && e.name !== 'CORTEX.md')
|
|
83
|
+
.map((e) => {
|
|
84
|
+
const st = fs.statSync(path.join(abs, e.name));
|
|
85
|
+
return { name: e.name, sizeBytes: st.size, modifiedAt: st.mtime.toISOString() };
|
|
86
|
+
})
|
|
87
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
88
|
+
return [{ name, entryCount: entries.length, entries }];
|
|
89
|
+
});
|
|
90
|
+
return { projectId: params.projectId, files, dirs };
|
|
91
|
+
}
|
|
92
|
+
// Real working-tree-vs-HEAD line counts via `git diff --numstat`. Returns null (honest placeholder,
|
|
93
|
+
// never fabricated) when the project dir is not a git work tree, git is unavailable, or the diff is
|
|
94
|
+
// binary/unresolvable. Read-only; array args (no shell) — `relPath` is the already-validated
|
|
95
|
+
// project-relative path, so there is no injection surface.
|
|
96
|
+
function gitLineDiff(root, relPath) {
|
|
97
|
+
let out;
|
|
98
|
+
try {
|
|
99
|
+
out = execFileSync('git', ['diff', '--numstat', 'HEAD', '--', relPath], {
|
|
100
|
+
cwd: root,
|
|
101
|
+
encoding: 'utf8',
|
|
102
|
+
timeout: 5000,
|
|
103
|
+
maxBuffer: 1024 * 1024,
|
|
104
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
105
|
+
env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
// git missing / not a repo / non-zero exit → unknown, not fabricated.
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
const line = out.split('\n').find((l) => l.trim().length > 0);
|
|
113
|
+
// No diff vs HEAD (e.g. a clean auto-committed file) → the real answer is 0/0.
|
|
114
|
+
if (!line)
|
|
115
|
+
return { added: 0, removed: 0 };
|
|
116
|
+
const [addedRaw, removedRaw] = line.split('\t');
|
|
117
|
+
// Binary files report `-\t-\t<path>` → counts are unknowable, honest null.
|
|
118
|
+
const added = Number(addedRaw);
|
|
119
|
+
const removed = Number(removedRaw);
|
|
120
|
+
if (!Number.isFinite(added) || !Number.isFinite(removed))
|
|
121
|
+
return null;
|
|
122
|
+
return { added, removed };
|
|
123
|
+
}
|
|
124
|
+
// Extract a task reference (4-hex id) from a commit subject. A ref is only recognized when it is
|
|
125
|
+
// anchored to a `task` / `manager` / `gate` keyword — bare 4-hex tokens (or 4-digit years) are NOT
|
|
126
|
+
// assumed to be refs, so an unsourced line stays an honest `null` rather than a fabricated ref.
|
|
127
|
+
const TASK_REF_RE = /\b(?:task|manager|gate)\s+([0-9a-f]{4})\b/i;
|
|
128
|
+
export function parseTaskRef(subject) {
|
|
129
|
+
const m = TASK_REF_RE.exec(subject);
|
|
130
|
+
return m ? m[1].toLowerCase() : null;
|
|
131
|
+
}
|
|
132
|
+
// Parse `git blame --line-porcelain` output into per-line attribution. Each line group starts with a
|
|
133
|
+
// `<40-hex> <origLine> <finalLine> [<n>]` header, carries a `summary <subject>` field, and ends with
|
|
134
|
+
// the TAB-prefixed content line. The commit hash is shortened to 8 hex; the subject → parseTaskRef.
|
|
135
|
+
export function parseBlamePorcelain(out) {
|
|
136
|
+
const rows = [];
|
|
137
|
+
// git emits the full commit header (incl. `summary`) only the FIRST time a commit is seen;
|
|
138
|
+
// later lines of the same commit carry only the abbreviated header + content. Cache the parsed
|
|
139
|
+
// task ref per commit so repeated lines keep their ref.
|
|
140
|
+
const refByCommit = new Map();
|
|
141
|
+
let commit = null;
|
|
142
|
+
let lineNo = 0;
|
|
143
|
+
for (const raw of out.split('\n')) {
|
|
144
|
+
if (raw.startsWith('\t')) {
|
|
145
|
+
// Content line closes the current group.
|
|
146
|
+
if (commit) {
|
|
147
|
+
rows.push({ line: lineNo, commit: commit.slice(0, 8), taskRef: refByCommit.get(commit) ?? null });
|
|
148
|
+
}
|
|
149
|
+
commit = null;
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
const header = /^([0-9a-f]{40}) \d+ (\d+)(?: \d+)?$/.exec(raw);
|
|
153
|
+
if (header) {
|
|
154
|
+
commit = header[1];
|
|
155
|
+
lineNo = Number(header[2]);
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (commit && raw.startsWith('summary ')) {
|
|
159
|
+
refByCommit.set(commit, parseTaskRef(raw.slice('summary '.length)));
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return rows;
|
|
163
|
+
}
|
|
164
|
+
// Real per-line blame (commit hash + parsed task ref). Returns null (honest placeholder, never
|
|
165
|
+
// fabricated) when the project dir is not a git work tree, git is unavailable, or the file is
|
|
166
|
+
// binary/unblameable. Read-only; array args (no shell) — `relPath` is already validated.
|
|
167
|
+
function gitBlame(root, relPath) {
|
|
168
|
+
let out;
|
|
169
|
+
try {
|
|
170
|
+
out = execFileSync('git', ['blame', '--line-porcelain', 'HEAD', '--', relPath], {
|
|
171
|
+
cwd: root,
|
|
172
|
+
encoding: 'utf8',
|
|
173
|
+
timeout: 5000,
|
|
174
|
+
maxBuffer: 8 * 1024 * 1024,
|
|
175
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
176
|
+
env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
catch {
|
|
180
|
+
// git missing / not a repo / binary / non-zero exit → unknown, not fabricated.
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
return parseBlamePorcelain(out);
|
|
184
|
+
}
|
|
185
|
+
export async function handleMemoryFile(deps, params) {
|
|
186
|
+
const root = resolveProjectRoot(deps, params.projectId);
|
|
187
|
+
const abs = resolveMemoryFilePath(root, params.path);
|
|
188
|
+
const st = fs.statSync(abs);
|
|
189
|
+
const content = fs.readFileSync(abs, 'utf8');
|
|
190
|
+
return {
|
|
191
|
+
projectId: params.projectId,
|
|
192
|
+
path: params.path,
|
|
193
|
+
content,
|
|
194
|
+
sizeBytes: st.size,
|
|
195
|
+
modifiedAt: st.mtime.toISOString(),
|
|
196
|
+
lineDiff: gitLineDiff(root, params.path),
|
|
197
|
+
blame: gitBlame(root, params.path),
|
|
198
|
+
};
|
|
199
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { NoteInfo, NotesListParams, UiServiceDeps } from '../types.js';
|
|
2
|
+
export declare function resolveNotesPath(deps: UiServiceDeps, projectId: string): string;
|
|
3
|
+
export declare function handleNotesList(deps: UiServiceDeps, params: NotesListParams): Promise<NoteInfo[]>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// input: UiServiceDeps, NotesListParams, projectNotesRepository
|
|
2
|
+
// output: resolved project NOTES.md entries
|
|
3
|
+
// pos: Read handler for user-private project notes
|
|
4
|
+
// >>> 一旦我被更新,务必更新我的开头注释与所属文件夹 CORTEX.md <<<
|
|
5
|
+
import * as path from 'node:path';
|
|
6
|
+
import { projectNotesRepository } from '../../../store/project-notes-repo.js';
|
|
7
|
+
function notFound(projectId) {
|
|
8
|
+
return Object.assign(new Error(`Project not found: ${projectId}`), { code: 'not-found' });
|
|
9
|
+
}
|
|
10
|
+
export function resolveNotesPath(deps, projectId) {
|
|
11
|
+
const project = deps.projectStore.get(projectId);
|
|
12
|
+
if (!project)
|
|
13
|
+
throw notFound(projectId);
|
|
14
|
+
return path.join(project.contextDir, 'NOTES.md');
|
|
15
|
+
}
|
|
16
|
+
export async function handleNotesList(deps, params) {
|
|
17
|
+
return projectNotesRepository.list(resolveNotesPath(deps, params.projectId));
|
|
18
|
+
}
|
|
@@ -15,6 +15,7 @@ export async function handleSchedulesList(deps, params) {
|
|
|
15
15
|
type: s.type,
|
|
16
16
|
message: s.message,
|
|
17
17
|
projectId: s.projectId,
|
|
18
|
+
profile: s.profile ?? null,
|
|
18
19
|
nextRun: s.nextRun != null ? new Date(s.nextRun).toISOString() : null,
|
|
19
20
|
lastRun: s.lastRun != null ? new Date(s.lastRun).toISOString() : null,
|
|
20
21
|
paused: s.isPaused ?? false,
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
import type { UiServiceDeps, SessionInfo, SessionsListParams } from '../types.js';
|
|
1
|
+
import type { UiServiceDeps, SessionInfo, SessionsListParams, SessionsTranscriptParams, SessionTranscript, SessionsPendingInteractionParams, SessionsPendingInteraction } from '../types.js';
|
|
2
2
|
export declare function handleSessionsList(deps: UiServiceDeps, params: SessionsListParams): Promise<SessionInfo[]>;
|
|
3
|
+
export declare function handleSessionsTranscript(deps: UiServiceDeps, params: SessionsTranscriptParams): Promise<SessionTranscript>;
|
|
4
|
+
export declare function handleSessionsPendingInteraction(deps: UiServiceDeps, params: SessionsPendingInteractionParams): Promise<SessionsPendingInteraction>;
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
// input:
|
|
2
|
-
// output:
|
|
3
|
-
// pos: query
|
|
1
|
+
// input: session/history stores plus process DEBUG size policy
|
|
2
|
+
// output: session snapshots with compact support and transcript DTOs
|
|
3
|
+
// pos: Authoritative query boundary for session transcripts
|
|
4
|
+
// >>> If I am updated, update my header comment and the parent folder's CORTEX.md <<<
|
|
5
|
+
import { effectiveBackendSessionId } from '../../../store/session-registry-repo.js';
|
|
6
|
+
import { isDebugMode, isDebugToolOverWarningThreshold } from '../../../core/debug-mode.js';
|
|
4
7
|
export async function handleSessionsList(deps, params) {
|
|
5
|
-
const { projectId, resumable } = params;
|
|
8
|
+
const { projectId, resumable, origin } = params;
|
|
6
9
|
let sessions;
|
|
7
|
-
if (
|
|
10
|
+
if (origin) {
|
|
11
|
+
// Origin filter takes precedence: the workbench left rail passes origin='direct' so only
|
|
12
|
+
// user conversations show (thread/scheduled sessions live in their own views).
|
|
13
|
+
sessions = await deps.sessionStore.listByOrigin(origin, projectId);
|
|
14
|
+
}
|
|
15
|
+
else if (resumable) {
|
|
8
16
|
sessions = await deps.sessionStore.listResumable(projectId);
|
|
9
17
|
}
|
|
10
18
|
else if (projectId) {
|
|
@@ -21,15 +29,219 @@ export async function handleSessionsList(deps, params) {
|
|
|
21
29
|
}
|
|
22
30
|
sessions = results;
|
|
23
31
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
// Live running snapshot: an interactive turn = a non-thread execution registered on the
|
|
33
|
+
// session's channel (threads run their own executions on the same channel and must not
|
|
34
|
+
// mark the session itself running). Snapshot + delta: this field is the queryable snapshot;
|
|
35
|
+
// the `session.status` event stream is the delta.
|
|
36
|
+
const isChannelInTurn = (channel) => !!channel && deps.runningExecutions.getByChannel(channel).some((e) => !e.threadId);
|
|
37
|
+
// Live agent-turn count of the in-flight interactive turn (the running snapshot): the non-thread
|
|
38
|
+
// execution on the channel carries its own live numTurns, updated in-memory on each turn_progress.
|
|
39
|
+
const liveTurnsForChannel = (channel) => {
|
|
40
|
+
if (!channel)
|
|
41
|
+
return null;
|
|
42
|
+
const exec = deps.runningExecutions.getByChannel(channel).find((e) => !e.threadId);
|
|
43
|
+
return exec && typeof exec.numTurns === 'number' ? exec.numTurns : null;
|
|
44
|
+
};
|
|
45
|
+
// Idle snapshot: the last COMPLETED interactive run's turn count AND total cost. One pass over the
|
|
46
|
+
// execution registry builds channel → latest non-thread execution (by startedAt), carrying both its
|
|
47
|
+
// numTurns and metrics.costUsd (same run). A running turn never falls back to this (avoids showing
|
|
48
|
+
// the previous run's count/cost during a fresh turn). costUsd is only known at turn end — there is
|
|
49
|
+
// no live in-memory cost source — so the running case has no live cost (null).
|
|
50
|
+
const lastRunByChannel = new Map();
|
|
51
|
+
for (const e of deps.executionRegistry.getAll()) {
|
|
52
|
+
const channel = e?.channel ?? undefined;
|
|
53
|
+
const numTurns = e?.metrics?.numTurns;
|
|
54
|
+
if (!channel || e?.thread?.threadId || typeof numTurns !== 'number')
|
|
55
|
+
continue;
|
|
56
|
+
const startedAt = e?.runtime?.startedAt ?? '';
|
|
57
|
+
const costUsd = e?.metrics?.costUsd;
|
|
58
|
+
const prev = lastRunByChannel.get(channel);
|
|
59
|
+
if (!prev || startedAt.localeCompare(prev.startedAt) >= 0) {
|
|
60
|
+
lastRunByChannel.set(channel, { startedAt, numTurns, costUsd: typeof costUsd === 'number' ? costUsd : null });
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const resolveNumTurns = (channel, running) => {
|
|
64
|
+
if (running)
|
|
65
|
+
return liveTurnsForChannel(channel);
|
|
66
|
+
return channel ? (lastRunByChannel.get(channel)?.numTurns ?? null) : null;
|
|
67
|
+
};
|
|
68
|
+
// Last run's cost: idle → the latest non-thread run's finalized cost; running → null (no live source).
|
|
69
|
+
const resolveCost = (channel, running) => {
|
|
70
|
+
if (running)
|
|
71
|
+
return null;
|
|
72
|
+
return channel ? (lastRunByChannel.get(channel)?.costUsd ?? null) : null;
|
|
73
|
+
};
|
|
74
|
+
const infos = sessions.map((s) => {
|
|
75
|
+
const inTurn = isChannelInTurn(s.channel);
|
|
76
|
+
// Web bg-hold snapshot: the foreground execution is gone from runningExecutions, but a
|
|
77
|
+
// background task still holds the session (running stays true per the session.status contract).
|
|
78
|
+
// A live foreground turn wins — the session then renders as plain running. Metrics
|
|
79
|
+
// (numTurns/costUsd) key off the foreground turn: a held session shows its last completed run.
|
|
80
|
+
const bgHeld = !inTurn && (deps.isSessionBgHeld?.(s.sessionId) ?? false);
|
|
81
|
+
const running = inTurn || bgHeld;
|
|
82
|
+
// Awaiting user action: the session is blocked on a pending ask-user question or plan approval
|
|
83
|
+
// (keyed by the session's channel). This is the ONLY signal that turns the rail dot amber —
|
|
84
|
+
// running/background stay blue. Absent deps (fixtures/TUI) ⇒ false.
|
|
85
|
+
const awaitingInput = !!deps.getPendingAskUser?.(s.channel) || !!deps.getPendingPlan?.(s.channel);
|
|
86
|
+
return {
|
|
87
|
+
sessionId: s.sessionId,
|
|
88
|
+
// Backend CLI resume target (registry backendSessionId, legacy fallback to sessionId) — the
|
|
89
|
+
// real UUID the "Session ID" surface shows, decoupled from the track sessionId above.
|
|
90
|
+
backendSessionId: effectiveBackendSessionId(s),
|
|
91
|
+
name: s.name,
|
|
92
|
+
projectId: s.projectId,
|
|
93
|
+
backend: s.backend,
|
|
94
|
+
kind: s.kind,
|
|
95
|
+
origin: s.origin ?? 'direct',
|
|
96
|
+
createdAt: s.createdAt,
|
|
97
|
+
lastUsedAt: s.lastUsedAt,
|
|
98
|
+
resumable: s.kind !== 'scheduled',
|
|
99
|
+
label: s.label ?? null,
|
|
100
|
+
profileName: s.profileName ?? null,
|
|
101
|
+
contextUsage: s.contextUsage ?? null,
|
|
102
|
+
contextCompactionSupported: deps.supportsSessionCompaction?.(s) ?? false,
|
|
103
|
+
running,
|
|
104
|
+
backgroundRunning: bgHeld,
|
|
105
|
+
awaitingInput,
|
|
106
|
+
numTurns: resolveNumTurns(s.channel, inTurn),
|
|
107
|
+
costUsd: resolveCost(s.channel, inTurn),
|
|
108
|
+
// Unread = activity (lastUsedAt, bumped at turn end) after the user's last view
|
|
109
|
+
// (sessions.markRead → lastReadAt). Legacy records without lastReadAt → read.
|
|
110
|
+
unread: !!s.lastReadAt && s.lastUsedAt > s.lastReadAt,
|
|
111
|
+
};
|
|
112
|
+
});
|
|
113
|
+
// Title label-less sessions from their first user message so the left rail shows the conversation's
|
|
114
|
+
// opening text instead of the opaque `cortex-XXXX` name. Read-only + bounded (only for sessions
|
|
115
|
+
// with no persisted label, capped) so a large unscoped list stays cheap; new sessions already get a
|
|
116
|
+
// persisted label at their first turn (agent-runner.ensureSessionLabel).
|
|
117
|
+
const getFirstUserText = deps.conversationHistory.getFirstUserText;
|
|
118
|
+
if (getFirstUserText) {
|
|
119
|
+
const LABEL_DERIVE_CAP = 80;
|
|
120
|
+
let derived = 0;
|
|
121
|
+
for (const info of infos) {
|
|
122
|
+
if (derived >= LABEL_DERIVE_CAP)
|
|
123
|
+
break;
|
|
124
|
+
if (info.label && info.label.trim())
|
|
125
|
+
continue;
|
|
126
|
+
derived++;
|
|
127
|
+
const first = await getFirstUserText(info.sessionId).catch(() => null);
|
|
128
|
+
if (first)
|
|
129
|
+
info.label = first.length > 60 ? first.slice(0, 60) : first;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return infos;
|
|
133
|
+
}
|
|
134
|
+
// ── sessions.transcript (S4 chat) ─────────────────────────────────
|
|
135
|
+
// Wrap the backend-independent conversation history and group its already-turn-tagged event
|
|
136
|
+
// stream into turns. An absent/empty history is not an error — it maps to zero turns.
|
|
137
|
+
/** Pending interactions older than this derive to expired at read time (matches the
|
|
138
|
+
* hook-bridge / ask-user 30-minute TTLs). */
|
|
139
|
+
const INTERACTION_TTL_MS = 30 * 60 * 1000;
|
|
140
|
+
function transcriptDebugDetails(ev) {
|
|
141
|
+
if (!isDebugMode() || ev.debug === undefined)
|
|
142
|
+
return undefined;
|
|
143
|
+
if (ev.type !== 'tool' || !isDebugToolOverWarningThreshold(ev.debug))
|
|
144
|
+
return ev.debug;
|
|
145
|
+
return { ...ev.debug, overCharacterThreshold: true };
|
|
146
|
+
}
|
|
147
|
+
/** Legacy-compatible subtype derived from kind+status (old clients render InteractionRow off it). */
|
|
148
|
+
function interactionSubtype(kind, status) {
|
|
149
|
+
if (kind === 'plan-approval')
|
|
150
|
+
return status === 'approved' ? 'plan-approved' : status === 'rejected' ? 'plan-rejected' : `plan-${status}`;
|
|
151
|
+
return status === 'answered' ? 'ask-user-answered' : `ask-user-${status}`;
|
|
152
|
+
}
|
|
153
|
+
async function pendingUserSnapshot(deps, sessionId) {
|
|
154
|
+
const records = await deps.pendingInjections?.listBySession(sessionId) ?? [];
|
|
155
|
+
return records.map((record) => ({
|
|
156
|
+
id: record.id,
|
|
157
|
+
text: record.text,
|
|
158
|
+
ts: record.createdAt,
|
|
159
|
+
...(record.attachments ? { attachments: record.attachments } : {}),
|
|
34
160
|
}));
|
|
35
161
|
}
|
|
162
|
+
export async function handleSessionsTranscript(deps, params) {
|
|
163
|
+
// Read active state first, then committed history. Commit order is history → active remove, so
|
|
164
|
+
// this sequence must observe the message on at least one side of that cross-store handoff.
|
|
165
|
+
const pendingSnapshot = await pendingUserSnapshot(deps, params.sessionId);
|
|
166
|
+
const history = await deps.conversationHistory.getHistory(params.sessionId);
|
|
167
|
+
if (!history)
|
|
168
|
+
return { sessionId: params.sessionId, turns: [], pendingUserMessages: pendingSnapshot };
|
|
169
|
+
const committedIds = new Set(history.committedSourceIds ?? []);
|
|
170
|
+
const pendingUserMessages = pendingSnapshot.filter((message) => !committedIds.has(message.id));
|
|
171
|
+
const byTurn = new Map();
|
|
172
|
+
const order = [];
|
|
173
|
+
// Real per-message elapsed: delta from the previous event in the flat chronological stream
|
|
174
|
+
// (history.events is already chronological). First message → null; either ts unparseable → null.
|
|
175
|
+
let prevMs = null;
|
|
176
|
+
for (const ev of history.events) {
|
|
177
|
+
let turn = byTurn.get(ev.turnIndex);
|
|
178
|
+
if (!turn) {
|
|
179
|
+
turn = { turnIndex: ev.turnIndex, messages: [] };
|
|
180
|
+
byTurn.set(ev.turnIndex, turn);
|
|
181
|
+
order.push(ev.turnIndex);
|
|
182
|
+
}
|
|
183
|
+
const curMs = Date.parse(ev.ts);
|
|
184
|
+
const curValid = Number.isFinite(curMs);
|
|
185
|
+
const elapsedMs = prevMs !== null && curValid ? curMs - prevMs : null;
|
|
186
|
+
// Interaction entity rows: derive `expired` for pending rows whose live resolver is gone
|
|
187
|
+
// (server restarted) or older than the TTL. The in-process pending index (via
|
|
188
|
+
// deps.isInteractionPending) is the liveness signal.
|
|
189
|
+
let interaction;
|
|
190
|
+
let entitySubtype;
|
|
191
|
+
if (ev.type === 'interaction' && ev.id) {
|
|
192
|
+
let status = ev.status ?? 'pending';
|
|
193
|
+
if (status === 'pending') {
|
|
194
|
+
const live = deps.isInteractionPending?.(ev.id) ?? false;
|
|
195
|
+
const age = curValid ? Date.now() - curMs : Infinity;
|
|
196
|
+
if (!live || age > INTERACTION_TTL_MS)
|
|
197
|
+
status = 'expired';
|
|
198
|
+
}
|
|
199
|
+
interaction = {
|
|
200
|
+
id: ev.id,
|
|
201
|
+
kind: (ev.kind ?? 'ask-user'),
|
|
202
|
+
status: status,
|
|
203
|
+
payload: ev.payload ?? {},
|
|
204
|
+
...(ev.result !== undefined ? { result: ev.result } : {}),
|
|
205
|
+
...(ev.resolvedVia !== undefined ? { resolvedVia: ev.resolvedVia } : {}),
|
|
206
|
+
};
|
|
207
|
+
entitySubtype = interactionSubtype(interaction.kind, interaction.status);
|
|
208
|
+
}
|
|
209
|
+
const debug = transcriptDebugDetails(ev);
|
|
210
|
+
turn.messages.push({
|
|
211
|
+
type: ev.type,
|
|
212
|
+
text: ev.type === 'tool' ? null : (ev.text ?? ''),
|
|
213
|
+
toolName: ev.type === 'tool' ? (ev.toolName ?? '') : null,
|
|
214
|
+
toolInput: ev.type === 'tool' ? (ev.toolInput ?? '') : null,
|
|
215
|
+
ts: ev.ts,
|
|
216
|
+
elapsedMs,
|
|
217
|
+
// Only materialize the key when present — an explicit `attachments: undefined` breaks
|
|
218
|
+
// deep-equality with the DTO shape (pre-existing red test, fixed in passing). Both user
|
|
219
|
+
// uploads (15a) and agent-sent files (20a, assistant events) carry attachments.
|
|
220
|
+
...((ev.type === 'user' || ev.type === 'assistant') && ev.attachments !== undefined ? { attachments: ev.attachments } : {}),
|
|
221
|
+
...(ev.type === 'assistant' && ev.noticeLevel !== undefined ? { noticeLevel: ev.noticeLevel } : {}),
|
|
222
|
+
// Edit+rewind marker (sessions.rewind): backs the「已编辑」badge + original-message card.
|
|
223
|
+
...(ev.type === 'user' && ev.edited !== undefined ? { edited: ev.edited } : {}),
|
|
224
|
+
// Defense in depth: persisted debug records stay hidden when DEBUG is off. Large-tool
|
|
225
|
+
// warnings are derived here from the current agent-server env and never written to history.
|
|
226
|
+
...(debug !== undefined ? { debug } : {}),
|
|
227
|
+
...(ev.type === 'interaction' && (entitySubtype ?? ev.subtype) ? { subtype: entitySubtype ?? ev.subtype } : {}),
|
|
228
|
+
...(interaction !== undefined ? { interaction } : {}),
|
|
229
|
+
});
|
|
230
|
+
prevMs = curValid ? curMs : null;
|
|
231
|
+
}
|
|
232
|
+
return {
|
|
233
|
+
sessionId: history.sessionId,
|
|
234
|
+
turns: order.map((i) => byTurn.get(i)),
|
|
235
|
+
pendingUserMessages,
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
// ── sessions.pendingInteraction ───────────────────────────────────
|
|
239
|
+
// Returns the current pending ask-user or plan approval for a session, if any.
|
|
240
|
+
// Reads from the server's in-memory Maps (same lifetime as the blocked MCP tool).
|
|
241
|
+
export async function handleSessionsPendingInteraction(deps, params) {
|
|
242
|
+
const channel = `web:${params.sessionId}`;
|
|
243
|
+
return {
|
|
244
|
+
askUser: deps.getPendingAskUser?.(channel) ?? null,
|
|
245
|
+
plan: deps.getPendingPlan?.(channel) ?? null,
|
|
246
|
+
};
|
|
247
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// input: UiServiceDeps + SkillsListParams (empty)
|
|
2
|
+
// output: skills.list handler → SkillGroup[] (from domain/memory/skill-scanner getDisplaySkillGroups)
|
|
3
|
+
// pos: query handler for 'skills.list' (plan §12 A item 2 / 8a). Delegates to the module-level
|
|
4
|
+
// getDisplaySkillGroups() which reads DATA_DIR/.claude/skills + DATA_DIR/plugins/*/skills and
|
|
5
|
+
// caches results for 60 s. The returned groups are already sorted (null plugin first for
|
|
6
|
+
// user-owned skills, then plugins alphabetically; skills within each group are sorted).
|
|
7
|
+
// Domain-to-domain import (ui-service ← memory) is acceptable within L3.
|
|
8
|
+
// >>> If I am updated, update CORTEX.md <<<
|
|
9
|
+
import { getDisplaySkillGroups } from '../../memory/skill-scanner.js';
|
|
10
|
+
export async function handleSkillsList(_deps, _params) {
|
|
11
|
+
// getDisplaySkillGroups() returns Array<{ plugin: string | null; skills: string[] }> —
|
|
12
|
+
// structurally identical to SkillGroup[]. Spread to avoid returning the cached array reference.
|
|
13
|
+
return getDisplaySkillGroups().map((g) => ({ plugin: g.plugin, skills: [...g.skills] }));
|
|
14
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { SystemDaemonStatus, SystemDaemonStatusParams, SystemRateLimitStatus, SystemRateLimitStatusParams } from '../types.js';
|
|
2
|
+
export declare function handleSystemDaemonStatus(_params: SystemDaemonStatusParams): Promise<SystemDaemonStatus>;
|
|
3
|
+
export declare function handleSystemRateLimitStatus(_params: SystemRateLimitStatusParams): Promise<SystemRateLimitStatus>;
|