@cortex-agent/server 2026.5.19-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/defaults/.claude/settings.json +13 -0
- package/defaults/CORTEX.md +15 -0
- package/defaults/config/budget.json +4 -0
- package/defaults/config/session-hooks.json +7 -0
- package/defaults/config/thread-templates.json +528 -0
- package/defaults/context/CORTEX.md +40 -0
- package/defaults/context/decisions/DR-0012.md +54 -0
- package/defaults/context/ideas/CORTEX.md +10 -0
- package/defaults/context/projects/CORTEX.md +25 -0
- package/defaults/context/scans/CORTEX.md +13 -0
- package/defaults/context/user/CORTEX.md +21 -0
- package/defaults/data/schedules.json +52 -0
- package/defaults/gitignore +44 -0
- package/defaults/hooks/ask-user-question-hook.mjs +66 -0
- package/defaults/hooks/cortex-md-injector.mjs +237 -0
- package/defaults/hooks/exit-plan-mode-hook.mjs +84 -0
- package/defaults/hooks/memory-ref-tracker.mjs +154 -0
- package/defaults/hooks/new-session-hook.mjs +83 -0
- package/defaults/hooks/post-task-hook.mjs +63 -0
- package/defaults/hooks/rules-loader.mjs +212 -0
- package/defaults/hooks/sensitive-file-edit.mjs +84 -0
- package/defaults/hooks/session-activity-tracker.mjs +254 -0
- package/defaults/hooks/task-status-check.mjs +218 -0
- package/defaults/hooks/tasks-yaml-guard.mjs +230 -0
- package/defaults/plugins/cortex-coder/.claude-plugin/plugin.json +5 -0
- package/defaults/plugins/cortex-coder/skills/cli-standards/SKILL.md +208 -0
- package/defaults/plugins/cortex-coder/skills/code-standards/SKILL.md +146 -0
- package/defaults/plugins/cortex-coder/skills/develop/SKILL.md +164 -0
- package/defaults/plugins/cortex-common/.claude-plugin/plugin.json +5 -0
- package/defaults/plugins/cortex-common/skills/compound/SKILL.md +349 -0
- package/defaults/plugins/cortex-common/skills/compound-simple/SKILL.md +104 -0
- package/defaults/plugins/cortex-common/skills/critique/SKILL.md +88 -0
- package/defaults/plugins/cortex-common/skills/debug-campaign/SKILL.md +508 -0
- package/defaults/plugins/cortex-common/skills/diagnose/SKILL.md +169 -0
- package/defaults/plugins/cortex-common/skills/postmortem/SKILL.md +135 -0
- package/defaults/plugins/cortex-common/skills/solution-design/SKILL.md +183 -0
- package/defaults/plugins/cortex-common/skills/synthesize/SKILL.md +120 -0
- package/defaults/plugins/cortex-stage-gate/.claude-plugin/plugin.json +5 -0
- package/defaults/plugins/cortex-stage-gate/skills/need-approval/SKILL.md +89 -0
- package/defaults/plugins/cortex-stage-gate/skills/reorient/SKILL.md +163 -0
- package/defaults/plugins/cortex-stage-gate/skills/task/SKILL.md +425 -0
- package/defaults/plugins/cortex-system/.claude-plugin/plugin.json +5 -0
- package/defaults/plugins/cortex-system/skills/approval/SKILL.md +84 -0
- package/defaults/plugins/cortex-system/skills/client-manage/SKILL.md +199 -0
- package/defaults/plugins/cortex-system/skills/deep-retrospective/CORTEX.md +8 -0
- package/defaults/plugins/cortex-system/skills/deep-retrospective/SKILL.md +201 -0
- package/defaults/plugins/cortex-system/skills/deep-retrospective/scripts/CORTEX.md +8 -0
- package/defaults/plugins/cortex-system/skills/deep-retrospective/scripts/extract_session.py +165 -0
- package/defaults/plugins/cortex-system/skills/deep-retrospective/scripts/scan_logs.py +402 -0
- package/defaults/plugins/cortex-system/skills/evolve/SKILL.md +115 -0
- package/defaults/plugins/cortex-system/skills/feedback/SKILL.md +262 -0
- package/defaults/plugins/cortex-system/skills/gravity/SKILL.md +125 -0
- package/defaults/plugins/cortex-system/skills/orient/SKILL.md +310 -0
- package/defaults/plugins/cortex-system/skills/orient-project/SKILL.md +85 -0
- package/defaults/plugins/cortex-system/skills/project-init/SKILL.md +167 -0
- package/defaults/plugins/cortex-system/skills/refresh-skills/SKILL.md +153 -0
- package/defaults/plugins/cortex-system/skills/schedule/SKILL.md +209 -0
- package/defaults/plugins/cortex-system/skills/thread/SKILL.md +478 -0
- package/defaults/plugins/cortex-system/skills/user-learn/SKILL.md +95 -0
- package/defaults/prompts/directives/coder-reviewer.md +106 -0
- package/defaults/prompts/directives/coder.md +90 -0
- package/defaults/prompts/directives/director.md +97 -0
- package/defaults/prompts/directives/doc-reviewer.md +93 -0
- package/defaults/prompts/directives/doc-writer.md +85 -0
- package/defaults/prompts/directives/executor-reviewer.md +96 -0
- package/defaults/prompts/directives/executor.md +85 -0
- package/defaults/prompts/directives/milestone-executor.md +119 -0
- package/defaults/prompts/directives/milestone-reviewer.md +108 -0
- package/defaults/prompts/directives/plan-executor.md +121 -0
- package/defaults/prompts/directives/plan-reviewer.md +99 -0
- package/defaults/prompts/systemPrompts/coder.md +64 -0
- package/defaults/prompts/systemPrompts/direct.md +92 -0
- package/defaults/prompts/systemPrompts/web-opus-4-6.md +68 -0
- package/defaults/prompts/systemPrompts/web-sonnet-4-6.md +76 -0
- package/defaults/prompts/systemPrompts/web.md +50 -0
- package/defaults/prompts/systemPrompts/worker.md +67 -0
- package/defaults/rules/correction-propagation.md +31 -0
- package/defaults/rules/decision-records.md +49 -0
- package/defaults/rules/experiment-format.md +165 -0
- package/defaults/rules/issues-md.md +37 -0
- package/defaults/rules/meta-conventions.md +45 -0
- package/defaults/rules/mission-md.md +47 -0
- package/defaults/rules/overview-md.md +41 -0
- package/defaults/rules/roadmap-md.md +55 -0
- package/defaults/rules/status-md.md +49 -0
- package/defaults/rules/task-system.md +53 -0
- package/dist/agent-adapter/capabilities.d.ts +12 -0
- package/dist/agent-adapter/capabilities.js +52 -0
- package/dist/agent-adapter/claude/adapter-tui.d.ts +140 -0
- package/dist/agent-adapter/claude/adapter-tui.js +422 -0
- package/dist/agent-adapter/claude/adapter.d.ts +85 -0
- package/dist/agent-adapter/claude/adapter.js +771 -0
- package/dist/agent-adapter/claude/cost-from-usage.d.ts +62 -0
- package/dist/agent-adapter/claude/cost-from-usage.js +97 -0
- package/dist/agent-adapter/claude/defaults.d.ts +30 -0
- package/dist/agent-adapter/claude/defaults.js +49 -0
- package/dist/agent-adapter/claude/event-parser.d.ts +28 -0
- package/dist/agent-adapter/claude/event-parser.js +173 -0
- package/dist/agent-adapter/claude/hooks-builder.d.ts +36 -0
- package/dist/agent-adapter/claude/hooks-builder.js +57 -0
- package/dist/agent-adapter/claude/jsonl-tail.d.ts +68 -0
- package/dist/agent-adapter/claude/jsonl-tail.js +344 -0
- package/dist/agent-adapter/claude/spawn-args.d.ts +38 -0
- package/dist/agent-adapter/claude/spawn-args.js +83 -0
- package/dist/agent-adapter/claude/tmux-control.d.ts +69 -0
- package/dist/agent-adapter/claude/tmux-control.js +127 -0
- package/dist/agent-adapter/claude/tool-summarizers.d.ts +2 -0
- package/dist/agent-adapter/claude/tool-summarizers.js +24 -0
- package/dist/agent-adapter/codex/adapter.d.ts +42 -0
- package/dist/agent-adapter/codex/adapter.js +916 -0
- package/dist/agent-adapter/codex/event-parser.d.ts +17 -0
- package/dist/agent-adapter/codex/event-parser.js +41 -0
- package/dist/agent-adapter/codex/spawn-args.d.ts +6 -0
- package/dist/agent-adapter/codex/spawn-args.js +30 -0
- package/dist/agent-adapter/index.d.ts +8 -0
- package/dist/agent-adapter/index.js +33 -0
- package/dist/agent-adapter/normalize/event-stream.d.ts +6 -0
- package/dist/agent-adapter/normalize/event-stream.js +47 -0
- package/dist/agent-adapter/normalize/event-types.d.ts +58 -0
- package/dist/agent-adapter/normalize/event-types.js +5 -0
- package/dist/agent-adapter/normalize/hooks.d.ts +26 -0
- package/dist/agent-adapter/normalize/hooks.js +5 -0
- package/dist/agent-adapter/normalize/prompt-builder.d.ts +6 -0
- package/dist/agent-adapter/normalize/prompt-builder.js +23 -0
- package/dist/agent-adapter/normalize/tool-names.d.ts +6 -0
- package/dist/agent-adapter/normalize/tool-names.js +73 -0
- package/dist/agent-adapter/pi/adapter.d.ts +60 -0
- package/dist/agent-adapter/pi/adapter.js +626 -0
- package/dist/agent-adapter/pi/agent-dir.d.ts +11 -0
- package/dist/agent-adapter/pi/agent-dir.js +34 -0
- package/dist/agent-adapter/pi/event-parser.d.ts +26 -0
- package/dist/agent-adapter/pi/event-parser.js +313 -0
- package/dist/agent-adapter/pi/framing.d.ts +6 -0
- package/dist/agent-adapter/pi/framing.js +35 -0
- package/dist/agent-adapter/pi/hook-bridge.d.ts +59 -0
- package/dist/agent-adapter/pi/hook-bridge.js +233 -0
- package/dist/agent-adapter/pi/mcp-bridge.d.ts +26 -0
- package/dist/agent-adapter/pi/mcp-bridge.js +140 -0
- package/dist/agent-adapter/pi/pi-ext-types.d.ts +90 -0
- package/dist/agent-adapter/pi/pi-ext-types.js +5 -0
- package/dist/agent-adapter/pi/spawn-args.d.ts +20 -0
- package/dist/agent-adapter/pi/spawn-args.js +54 -0
- package/dist/agent-adapter/pi/tool-shims.d.ts +2 -0
- package/dist/agent-adapter/pi/tool-shims.js +181 -0
- package/dist/agent-adapter/types.d.ts +94 -0
- package/dist/agent-adapter/types.js +5 -0
- package/dist/core/async-mutex.d.ts +6 -0
- package/dist/core/async-mutex.js +36 -0
- package/dist/core/cli-utils.d.ts +37 -0
- package/dist/core/cli-utils.js +69 -0
- package/dist/core/config-generator.d.ts +9 -0
- package/dist/core/config-generator.js +58 -0
- package/dist/core/gateway-generator.d.ts +46 -0
- package/dist/core/gateway-generator.js +336 -0
- package/dist/core/log.d.ts +7 -0
- package/dist/core/log.js +103 -0
- package/dist/core/paths.d.ts +32 -0
- package/dist/core/paths.js +49 -0
- package/dist/core/profile-generator.d.ts +65 -0
- package/dist/core/profile-generator.js +310 -0
- package/dist/core/running-executions.d.ts +88 -0
- package/dist/core/running-executions.js +186 -0
- package/dist/core/status-format.d.ts +18 -0
- package/dist/core/status-format.js +31 -0
- package/dist/core/task-parser.d.ts +69 -0
- package/dist/core/task-parser.js +423 -0
- package/dist/core/types/agent-types.d.ts +31 -0
- package/dist/core/types/agent-types.js +5 -0
- package/dist/core/types/thread-types.d.ts +261 -0
- package/dist/core/types/thread-types.js +5 -0
- package/dist/core/utils.d.ts +29 -0
- package/dist/core/utils.js +98 -0
- package/dist/core/version.d.ts +3 -0
- package/dist/core/version.js +12 -0
- package/dist/domain/agents/config.d.ts +58 -0
- package/dist/domain/agents/config.js +313 -0
- package/dist/domain/agents/facade.d.ts +52 -0
- package/dist/domain/agents/facade.js +264 -0
- package/dist/domain/agents/index.d.ts +2 -0
- package/dist/domain/agents/index.js +4 -0
- package/dist/domain/agents/profile-manager.d.ts +54 -0
- package/dist/domain/agents/profile-manager.js +161 -0
- package/dist/domain/costs/codex-event-format.d.ts +4 -0
- package/dist/domain/costs/codex-event-format.js +66 -0
- package/dist/domain/costs/codex-usage-monitor.d.ts +7 -0
- package/dist/domain/costs/codex-usage-monitor.js +72 -0
- package/dist/domain/costs/cost-tracker.d.ts +115 -0
- package/dist/domain/costs/cost-tracker.js +327 -0
- package/dist/domain/costs/gateway-manager.d.ts +6 -0
- package/dist/domain/costs/gateway-manager.js +228 -0
- package/dist/domain/costs/rate-limit-parser.d.ts +11 -0
- package/dist/domain/costs/rate-limit-parser.js +87 -0
- package/dist/domain/costs/rate-limit-throttle.d.ts +32 -0
- package/dist/domain/costs/rate-limit-throttle.js +129 -0
- package/dist/domain/executions/registry.d.ts +20 -0
- package/dist/domain/executions/registry.js +124 -0
- package/dist/domain/mcp/core-server.d.ts +2 -0
- package/dist/domain/mcp/core-server.js +34 -0
- package/dist/domain/mcp/server.d.ts +3 -0
- package/dist/domain/mcp/server.js +78 -0
- package/dist/domain/mcp/tools/context.d.ts +23 -0
- package/dist/domain/mcp/tools/context.js +51 -0
- package/dist/domain/mcp/tools/cortex-md.d.ts +17 -0
- package/dist/domain/mcp/tools/cortex-md.js +36 -0
- package/dist/domain/mcp/tools/cost.d.ts +2 -0
- package/dist/domain/mcp/tools/cost.js +54 -0
- package/dist/domain/mcp/tools/executions.d.ts +2 -0
- package/dist/domain/mcp/tools/executions.js +94 -0
- package/dist/domain/mcp/tools/schedule.d.ts +23 -0
- package/dist/domain/mcp/tools/schedule.js +245 -0
- package/dist/domain/mcp/tools/slack.d.ts +21 -0
- package/dist/domain/mcp/tools/slack.js +124 -0
- package/dist/domain/mcp/tools/task-ops.d.ts +2 -0
- package/dist/domain/mcp/tools/task-ops.js +509 -0
- package/dist/domain/mcp/tools/tui-ask.d.ts +31 -0
- package/dist/domain/mcp/tools/tui-ask.js +108 -0
- package/dist/domain/mcp/tools/tui-plan.d.ts +28 -0
- package/dist/domain/mcp/tools/tui-plan.js +118 -0
- package/dist/domain/mcp/tui-server.d.ts +2 -0
- package/dist/domain/mcp/tui-server.js +69 -0
- package/dist/domain/memory/consolidate.d.ts +55 -0
- package/dist/domain/memory/consolidate.js +471 -0
- package/dist/domain/memory/cortex-md-injector.d.ts +30 -0
- package/dist/domain/memory/cortex-md-injector.js +123 -0
- package/dist/domain/memory/cortex-md-scanner.d.ts +9 -0
- package/dist/domain/memory/cortex-md-scanner.js +67 -0
- package/dist/domain/memory/index-regen.d.ts +19 -0
- package/dist/domain/memory/index-regen.js +398 -0
- package/dist/domain/memory/rules-loader.d.ts +27 -0
- package/dist/domain/memory/rules-loader.js +97 -0
- package/dist/domain/memory/skill-scanner.d.ts +5 -0
- package/dist/domain/memory/skill-scanner.js +132 -0
- package/dist/domain/memory/user-context.d.ts +5 -0
- package/dist/domain/memory/user-context.js +34 -0
- package/dist/domain/memory/watcher.d.ts +2 -0
- package/dist/domain/memory/watcher.js +81 -0
- package/dist/domain/monitor/disk-monitor.d.ts +20 -0
- package/dist/domain/monitor/disk-monitor.js +97 -0
- package/dist/domain/monitor/gpu-monitor.d.ts +26 -0
- package/dist/domain/monitor/gpu-monitor.js +135 -0
- package/dist/domain/remote/client-bootstrap.d.ts +1 -0
- package/dist/domain/remote/client-bootstrap.js +139 -0
- package/dist/domain/remote/client-hot-reload.d.ts +18 -0
- package/dist/domain/remote/client-hot-reload.js +142 -0
- package/dist/domain/remote/client-manager.d.ts +50 -0
- package/dist/domain/remote/client-manager.js +452 -0
- package/dist/domain/remote/cortex-client.d.ts +1 -0
- package/dist/domain/remote/cortex-client.js +704 -0
- package/dist/domain/scheduling/job-registry.d.ts +31 -0
- package/dist/domain/scheduling/job-registry.js +34 -0
- package/dist/domain/scheduling/jobs/_shared.d.ts +14 -0
- package/dist/domain/scheduling/jobs/_shared.js +45 -0
- package/dist/domain/scheduling/jobs/memory-index-regen.d.ts +1 -0
- package/dist/domain/scheduling/jobs/memory-index-regen.js +16 -0
- package/dist/domain/scheduling/jobs/scheduled-task.d.ts +11 -0
- package/dist/domain/scheduling/jobs/scheduled-task.js +186 -0
- package/dist/domain/scheduling/jobs/target-dispatch.d.ts +41 -0
- package/dist/domain/scheduling/jobs/target-dispatch.js +48 -0
- package/dist/domain/scheduling/jobs/task-archive.d.ts +1 -0
- package/dist/domain/scheduling/jobs/task-archive.js +19 -0
- package/dist/domain/scheduling/jobs/task-dispatch.d.ts +12 -0
- package/dist/domain/scheduling/jobs/task-dispatch.js +214 -0
- package/dist/domain/scheduling/runner.d.ts +13 -0
- package/dist/domain/scheduling/runner.js +24 -0
- package/dist/domain/scheduling/schedule-cli.d.ts +16 -0
- package/dist/domain/scheduling/schedule-cli.js +268 -0
- package/dist/domain/scheduling/schedule-command.d.ts +4 -0
- package/dist/domain/scheduling/schedule-command.js +274 -0
- package/dist/domain/scheduling/scheduler.d.ts +86 -0
- package/dist/domain/scheduling/scheduler.js +544 -0
- package/dist/domain/sessions/session-backup.d.ts +49 -0
- package/dist/domain/sessions/session-backup.js +217 -0
- package/dist/domain/sessions/session-hooks.d.ts +103 -0
- package/dist/domain/sessions/session-hooks.js +311 -0
- package/dist/domain/sessions/session-registry.d.ts +21 -0
- package/dist/domain/sessions/session-registry.js +31 -0
- package/dist/domain/sessions/session.d.ts +3 -0
- package/dist/domain/sessions/session.js +14 -0
- package/dist/domain/tasks/archiver.d.ts +9 -0
- package/dist/domain/tasks/archiver.js +123 -0
- package/dist/domain/tasks/dispatch-utils.d.ts +37 -0
- package/dist/domain/tasks/dispatch-utils.js +143 -0
- package/dist/domain/tasks/dispatcher.d.ts +48 -0
- package/dist/domain/tasks/dispatcher.js +285 -0
- package/dist/domain/tasks/lint.d.ts +12 -0
- package/dist/domain/tasks/lint.js +102 -0
- package/dist/domain/tasks/mutator.d.ts +21 -0
- package/dist/domain/tasks/mutator.js +208 -0
- package/dist/domain/tasks/parser.d.ts +1 -0
- package/dist/domain/tasks/parser.js +6 -0
- package/dist/domain/tasks/pending-tracker.d.ts +67 -0
- package/dist/domain/tasks/pending-tracker.js +163 -0
- package/dist/domain/tasks/recommendation/extractor.d.ts +12 -0
- package/dist/domain/tasks/recommendation/extractor.js +563 -0
- package/dist/domain/tasks/recommendation/patterns.d.ts +11 -0
- package/dist/domain/tasks/recommendation/patterns.js +99 -0
- package/dist/domain/tasks/recommendation/types.d.ts +67 -0
- package/dist/domain/tasks/recommendation/types.js +5 -0
- package/dist/domain/tasks/store.d.ts +1 -0
- package/dist/domain/tasks/store.js +3 -0
- package/dist/domain/tasks/system/cortex-run.d.ts +24 -0
- package/dist/domain/tasks/system/cortex-run.js +342 -0
- package/dist/domain/tasks/system/task-cli.d.ts +49 -0
- package/dist/domain/tasks/system/task-cli.js +664 -0
- package/dist/domain/tasks/system/task-completion.d.ts +22 -0
- package/dist/domain/tasks/system/task-completion.js +89 -0
- package/dist/domain/tasks/system/task-id-utils.d.ts +24 -0
- package/dist/domain/tasks/system/task-id-utils.js +84 -0
- package/dist/domain/tasks/system/task-lifecycle-edit.d.ts +34 -0
- package/dist/domain/tasks/system/task-lifecycle-edit.js +208 -0
- package/dist/domain/tasks/system/task-lock.d.ts +25 -0
- package/dist/domain/tasks/system/task-lock.js +139 -0
- package/dist/domain/tasks/system/task-mutations.d.ts +31 -0
- package/dist/domain/tasks/system/task-mutations.js +110 -0
- package/dist/domain/tasks/system/task-process.d.ts +37 -0
- package/dist/domain/tasks/system/task-process.js +119 -0
- package/dist/domain/tasks/system/task-state.d.ts +70 -0
- package/dist/domain/tasks/system/task-state.js +176 -0
- package/dist/domain/threads/artifact-io.d.ts +18 -0
- package/dist/domain/threads/artifact-io.js +182 -0
- package/dist/domain/threads/auto-thread.d.ts +3 -0
- package/dist/domain/threads/auto-thread.js +19 -0
- package/dist/domain/threads/hook-runner.d.ts +4 -0
- package/dist/domain/threads/hook-runner.js +250 -0
- package/dist/domain/threads/index.d.ts +5 -0
- package/dist/domain/threads/index.js +7 -0
- package/dist/domain/threads/prompt-builder.d.ts +25 -0
- package/dist/domain/threads/prompt-builder.js +176 -0
- package/dist/domain/threads/runner.d.ts +83 -0
- package/dist/domain/threads/runner.js +434 -0
- package/dist/domain/threads/state-machine.d.ts +61 -0
- package/dist/domain/threads/state-machine.js +440 -0
- package/dist/domain/threads/template-loader.d.ts +20 -0
- package/dist/domain/threads/template-loader.js +189 -0
- package/dist/domain/threads/template-resolver.d.ts +1 -0
- package/dist/domain/threads/template-resolver.js +95 -0
- package/dist/domain/threads/utils.d.ts +19 -0
- package/dist/domain/threads/utils.js +49 -0
- package/dist/entry/app.d.ts +1 -0
- package/dist/entry/app.js +234 -0
- package/dist/entry/cli.d.ts +12 -0
- package/dist/entry/cli.js +254 -0
- package/dist/entry/daemon.d.ts +11 -0
- package/dist/entry/daemon.js +521 -0
- package/dist/entry/init.d.ts +93 -0
- package/dist/entry/init.js +1299 -0
- package/dist/entry/startup-helpers.d.ts +2 -0
- package/dist/entry/startup-helpers.js +56 -0
- package/dist/entry/startup-notify.d.ts +10 -0
- package/dist/entry/startup-notify.js +20 -0
- package/dist/events/event-bus.d.ts +42 -0
- package/dist/events/event-bus.js +84 -0
- package/dist/events/event-logger.d.ts +12 -0
- package/dist/events/event-logger.js +135 -0
- package/dist/events/event-replay.d.ts +1 -0
- package/dist/events/event-replay.js +51 -0
- package/dist/events/event-types.d.ts +145 -0
- package/dist/events/event-types.js +5 -0
- package/dist/events/index.d.ts +5 -0
- package/dist/events/index.js +6 -0
- package/dist/hooks/ask-user-question-hook.mjs +66 -0
- package/dist/hooks/cortex-md-injector.mjs +237 -0
- package/dist/hooks/exit-plan-mode-hook.mjs +84 -0
- package/dist/hooks/memory-ref-tracker.mjs +154 -0
- package/dist/hooks/new-session-hook.mjs +83 -0
- package/dist/hooks/post-task-hook.mjs +63 -0
- package/dist/hooks/rules-loader.mjs +212 -0
- package/dist/hooks/sensitive-file-edit.mjs +84 -0
- package/dist/hooks/session-activity-tracker.mjs +254 -0
- package/dist/hooks/task-status-check.mjs +218 -0
- package/dist/hooks/tasks-yaml-guard.mjs +230 -0
- package/dist/orchestration/agent-runner.d.ts +72 -0
- package/dist/orchestration/agent-runner.js +289 -0
- package/dist/orchestration/busy-tracker.d.ts +12 -0
- package/dist/orchestration/busy-tracker.js +35 -0
- package/dist/orchestration/channel-queue.d.ts +18 -0
- package/dist/orchestration/channel-queue.js +32 -0
- package/dist/orchestration/dispatch-reconciler.d.ts +1 -0
- package/dist/orchestration/dispatch-reconciler.js +16 -0
- package/dist/orchestration/durable-helpers.d.ts +4 -0
- package/dist/orchestration/durable-helpers.js +42 -0
- package/dist/orchestration/interactions/ask-user-question.d.ts +32 -0
- package/dist/orchestration/interactions/ask-user-question.js +182 -0
- package/dist/orchestration/interactions/command-action-router.d.ts +47 -0
- package/dist/orchestration/interactions/command-action-router.js +91 -0
- package/dist/orchestration/interactions/interaction-handlers.d.ts +5 -0
- package/dist/orchestration/interactions/interaction-handlers.js +279 -0
- package/dist/orchestration/interactions/plan-approvals.d.ts +47 -0
- package/dist/orchestration/interactions/plan-approvals.js +77 -0
- package/dist/orchestration/interactions/plan-handler.d.ts +6 -0
- package/dist/orchestration/interactions/plan-handler.js +12 -0
- package/dist/orchestration/lifecycle.d.ts +50 -0
- package/dist/orchestration/lifecycle.js +308 -0
- package/dist/orchestration/orchestrator.d.ts +29 -0
- package/dist/orchestration/orchestrator.js +25 -0
- package/dist/orchestration/routing/commands/cancel.d.ts +10 -0
- package/dist/orchestration/routing/commands/cancel.js +136 -0
- package/dist/orchestration/routing/commands/channel.d.ts +11 -0
- package/dist/orchestration/routing/commands/channel.js +219 -0
- package/dist/orchestration/routing/commands/command-context.d.ts +29 -0
- package/dist/orchestration/routing/commands/command-context.js +4 -0
- package/dist/orchestration/routing/commands/cost.d.ts +3 -0
- package/dist/orchestration/routing/commands/cost.js +22 -0
- package/dist/orchestration/routing/commands/device.d.ts +6 -0
- package/dist/orchestration/routing/commands/device.js +83 -0
- package/dist/orchestration/routing/commands/dispatch.d.ts +2 -0
- package/dist/orchestration/routing/commands/dispatch.js +49 -0
- package/dist/orchestration/routing/commands/index.d.ts +15 -0
- package/dist/orchestration/routing/commands/index.js +130 -0
- package/dist/orchestration/routing/commands/mode.d.ts +13 -0
- package/dist/orchestration/routing/commands/mode.js +290 -0
- package/dist/orchestration/routing/commands/nvtop.d.ts +3 -0
- package/dist/orchestration/routing/commands/nvtop.js +103 -0
- package/dist/orchestration/routing/commands/orient.d.ts +2 -0
- package/dist/orchestration/routing/commands/orient.js +3 -0
- package/dist/orchestration/routing/commands/schedule.d.ts +4 -0
- package/dist/orchestration/routing/commands/schedule.js +132 -0
- package/dist/orchestration/routing/commands/sendfile.d.ts +2 -0
- package/dist/orchestration/routing/commands/sendfile.js +92 -0
- package/dist/orchestration/routing/commands/session.d.ts +9 -0
- package/dist/orchestration/routing/commands/session.js +153 -0
- package/dist/orchestration/routing/commands/status.d.ts +7 -0
- package/dist/orchestration/routing/commands/status.js +180 -0
- package/dist/orchestration/routing/commands/tail.d.ts +2 -0
- package/dist/orchestration/routing/commands/tail.js +73 -0
- package/dist/orchestration/routing/commands/task.d.ts +6 -0
- package/dist/orchestration/routing/commands/task.js +142 -0
- package/dist/orchestration/routing/commands/thread-handlers.d.ts +2 -0
- package/dist/orchestration/routing/commands/thread-handlers.js +138 -0
- package/dist/orchestration/routing/commands/thread.d.ts +2 -0
- package/dist/orchestration/routing/commands/thread.js +2 -0
- package/dist/orchestration/routing/edit-handler.d.ts +24 -0
- package/dist/orchestration/routing/edit-handler.js +161 -0
- package/dist/orchestration/routing/file-handler.d.ts +6 -0
- package/dist/orchestration/routing/file-handler.js +23 -0
- package/dist/orchestration/routing/hook-bridge-subscribers.d.ts +4 -0
- package/dist/orchestration/routing/hook-bridge-subscribers.js +79 -0
- package/dist/orchestration/routing/hook-bridge.d.ts +30 -0
- package/dist/orchestration/routing/hook-bridge.js +112 -0
- package/dist/orchestration/routing/message-router.d.ts +6 -0
- package/dist/orchestration/routing/message-router.js +70 -0
- package/dist/orchestration/routing/webhook.d.ts +10 -0
- package/dist/orchestration/routing/webhook.js +239 -0
- package/dist/orchestration/status-helpers.d.ts +66 -0
- package/dist/orchestration/status-helpers.js +222 -0
- package/dist/orchestration/superseded-edits.d.ts +22 -0
- package/dist/orchestration/superseded-edits.js +31 -0
- package/dist/orchestration/thread-executor.d.ts +31 -0
- package/dist/orchestration/thread-executor.js +234 -0
- package/dist/platform/adapter.d.ts +28 -0
- package/dist/platform/adapter.js +5 -0
- package/dist/platform/adapters/feishu.d.ts +66 -0
- package/dist/platform/adapters/feishu.js +558 -0
- package/dist/platform/adapters/index.d.ts +16 -0
- package/dist/platform/adapters/index.js +65 -0
- package/dist/platform/adapters/slack.d.ts +90 -0
- package/dist/platform/adapters/slack.js +630 -0
- package/dist/platform/index.d.ts +12 -0
- package/dist/platform/index.js +10 -0
- package/dist/platform/interactive-builder.d.ts +27 -0
- package/dist/platform/interactive-builder.js +120 -0
- package/dist/platform/testing.d.ts +100 -0
- package/dist/platform/testing.js +190 -0
- package/dist/platform/tool-trace.d.ts +33 -0
- package/dist/platform/tool-trace.js +165 -0
- package/dist/platform/types.d.ts +176 -0
- package/dist/platform/types.js +5 -0
- package/dist/platform/utils/rate-limiter.d.ts +92 -0
- package/dist/platform/utils/rate-limiter.js +213 -0
- package/dist/platform/virtual-message.d.ts +68 -0
- package/dist/platform/virtual-message.js +464 -0
- package/dist/store/atomic-write.d.ts +6 -0
- package/dist/store/atomic-write.js +18 -0
- package/dist/store/channel-repo.d.ts +21 -0
- package/dist/store/channel-repo.js +55 -0
- package/dist/store/conversation-ledger-repo.d.ts +86 -0
- package/dist/store/conversation-ledger-repo.js +220 -0
- package/dist/store/cost-repo.d.ts +57 -0
- package/dist/store/cost-repo.js +135 -0
- package/dist/store/execution-repo.d.ts +172 -0
- package/dist/store/execution-repo.js +343 -0
- package/dist/store/in-memory-repository.d.ts +14 -0
- package/dist/store/in-memory-repository.js +31 -0
- package/dist/store/json-repository.d.ts +51 -0
- package/dist/store/json-repository.js +118 -0
- package/dist/store/outbound-queue.d.ts +65 -0
- package/dist/store/outbound-queue.js +269 -0
- package/dist/store/profile-repo.d.ts +36 -0
- package/dist/store/profile-repo.js +144 -0
- package/dist/store/project-dir-repo.d.ts +22 -0
- package/dist/store/project-dir-repo.js +60 -0
- package/dist/store/schedule-repo.d.ts +92 -0
- package/dist/store/schedule-repo.js +88 -0
- package/dist/store/session-registry-repo.d.ts +38 -0
- package/dist/store/session-registry-repo.js +96 -0
- package/dist/store/session-repo.d.ts +14 -0
- package/dist/store/session-repo.js +56 -0
- package/dist/store/task-repo.d.ts +41 -0
- package/dist/store/task-repo.js +137 -0
- package/dist/store/thread-repo.d.ts +50 -0
- package/dist/store/thread-repo.js +190 -0
- package/package.json +58 -0
- package/scripts/postinstall-restart-trigger.mjs +39 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { getTaskStatsFromTasks } from './parser.js';
|
|
2
|
+
export function findCycles(tasks) {
|
|
3
|
+
const byId = Object.fromEntries(tasks.filter((t) => t.id).map((t) => [t.id, t]));
|
|
4
|
+
const adjacency = Object.fromEntries(tasks.filter((t) => t.id).map((t) => [t.id, t.depends_on.filter((d) => byId[d])]));
|
|
5
|
+
const seen = new Set();
|
|
6
|
+
const visiting = new Set();
|
|
7
|
+
const stack = [];
|
|
8
|
+
const cycles = [];
|
|
9
|
+
function dfs(node) {
|
|
10
|
+
if (visiting.has(node)) {
|
|
11
|
+
const index = stack.indexOf(node);
|
|
12
|
+
if (index !== -1)
|
|
13
|
+
cycles.push([...stack.slice(index), node]);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (seen.has(node))
|
|
17
|
+
return;
|
|
18
|
+
visiting.add(node);
|
|
19
|
+
stack.push(node);
|
|
20
|
+
for (const next of adjacency[node] || [])
|
|
21
|
+
dfs(next);
|
|
22
|
+
stack.pop();
|
|
23
|
+
visiting.delete(node);
|
|
24
|
+
seen.add(node);
|
|
25
|
+
}
|
|
26
|
+
for (const node of Object.keys(adjacency))
|
|
27
|
+
dfs(node);
|
|
28
|
+
const deduped = [];
|
|
29
|
+
const seenKeys = new Set();
|
|
30
|
+
for (const cycle of cycles) {
|
|
31
|
+
const key = cycle.join('->');
|
|
32
|
+
if (!seenKeys.has(key)) {
|
|
33
|
+
seenKeys.add(key);
|
|
34
|
+
deduped.push(cycle);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return deduped;
|
|
38
|
+
}
|
|
39
|
+
function lintSingleTask(task, warnings, errors, duplicateCounts, byId, validTemplateNames) {
|
|
40
|
+
if (task.id) {
|
|
41
|
+
duplicateCounts[task.id] = (duplicateCounts[task.id] || 0) + 1;
|
|
42
|
+
if (!byId[task.id])
|
|
43
|
+
byId[task.id] = task;
|
|
44
|
+
}
|
|
45
|
+
else if (task.status !== 'done') {
|
|
46
|
+
warnings.push({ code: 'missing-id', project: task.project, text: task.text });
|
|
47
|
+
}
|
|
48
|
+
const id = task.id || null;
|
|
49
|
+
if (!task.why)
|
|
50
|
+
warnings.push({ code: 'missing-why', project: task.project, task_id: id, text: task.text });
|
|
51
|
+
if (!task.done_when)
|
|
52
|
+
warnings.push({ code: 'missing-done-when', project: task.project, task_id: id, text: task.text });
|
|
53
|
+
if (task.status !== 'done' && !task.template)
|
|
54
|
+
warnings.push({ code: 'missing-template', project: task.project, task_id: id, text: task.text });
|
|
55
|
+
if (task.status !== 'done' && !task.plan)
|
|
56
|
+
warnings.push({ code: 'missing-plan', project: task.project, task_id: id, text: task.text });
|
|
57
|
+
if (task.status !== 'done' && task.template && validTemplateNames && !validTemplateNames.has(task.template)) {
|
|
58
|
+
errors.push({ code: 'unknown-template', project: task.project, task_id: id, text: task.text, template: task.template });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function lintDuplicates(duplicateCounts, errors) {
|
|
62
|
+
for (const [taskId, count] of Object.entries(duplicateCounts)) {
|
|
63
|
+
if (count > 1)
|
|
64
|
+
errors.push({ code: 'duplicate-id', task_id: taskId, count });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function lintDependencies(tasks, byId, errors) {
|
|
68
|
+
for (const task of tasks) {
|
|
69
|
+
for (const dep of task.depends_on) {
|
|
70
|
+
if (byId[dep])
|
|
71
|
+
continue;
|
|
72
|
+
errors.push({ code: 'missing-dependency', task_id: task.id || null, missing: dep, project: task.project, text: task.text });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
for (const cycle of findCycles(tasks)) {
|
|
76
|
+
errors.push({ code: 'dependency-cycle', cycle });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function lintSupplyHealth(summary, info) {
|
|
80
|
+
for (const [project, raw] of Object.entries(summary.projects)) {
|
|
81
|
+
const s = raw;
|
|
82
|
+
s.healthy_supply = s.actionable >= 2;
|
|
83
|
+
if (!s.healthy_supply) {
|
|
84
|
+
info.push({ code: 'low-actionable-supply', project, actionable: s.actionable });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
export function lintTasks(tasks, options = {}) {
|
|
89
|
+
const errors = [];
|
|
90
|
+
const warnings = [];
|
|
91
|
+
const info = [];
|
|
92
|
+
const byId = {};
|
|
93
|
+
const duplicateCounts = {};
|
|
94
|
+
const validTemplateNames = options.validTemplateNames || null;
|
|
95
|
+
for (const task of tasks)
|
|
96
|
+
lintSingleTask(task, warnings, errors, duplicateCounts, byId, validTemplateNames);
|
|
97
|
+
lintDuplicates(duplicateCounts, errors);
|
|
98
|
+
lintDependencies(tasks, byId, errors);
|
|
99
|
+
const summary = getTaskStatsFromTasks(tasks);
|
|
100
|
+
lintSupplyHealth(summary, info);
|
|
101
|
+
return { ok: errors.length === 0, errors, warnings, info, summary };
|
|
102
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { TaskRepo } from '../../store/task-repo.js';
|
|
2
|
+
export declare class TaskMutator {
|
|
3
|
+
private store;
|
|
4
|
+
constructor(store?: TaskRepo);
|
|
5
|
+
claim(taskId: string, agent: string): Promise<any>;
|
|
6
|
+
unclaim(taskId: string): Promise<any>;
|
|
7
|
+
complete(taskId: string, note?: string): Promise<any>;
|
|
8
|
+
uncomplete(taskId: string): Promise<any>;
|
|
9
|
+
block(taskId: string, reason: string): Promise<any>;
|
|
10
|
+
unblock(taskId: string): Promise<any>;
|
|
11
|
+
pause(taskId: string): Promise<any>;
|
|
12
|
+
resume(taskId: string): Promise<any>;
|
|
13
|
+
requestApproval(taskId: string): Promise<any>;
|
|
14
|
+
approve(taskId: string): Promise<any>;
|
|
15
|
+
clearApproval(taskId: string): Promise<any>;
|
|
16
|
+
batchEdit(project: string, taskIds: string[], options: any): Promise<any>;
|
|
17
|
+
add(project: string, text: string, why: string, doneWhen: string, priority?: string, template?: string, dependsOn?: string[]): Promise<any>;
|
|
18
|
+
edit(project: string, options: any): Promise<any>;
|
|
19
|
+
decompose(project: string, taskText: string, subtasks: any[], taskId?: string): Promise<any>;
|
|
20
|
+
}
|
|
21
|
+
export declare const taskMutator: TaskMutator;
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { taskStore } from '../../store/task-repo.js';
|
|
2
|
+
import { approveTask as lifecycleApproveTask, blockTask as lifecycleBlockTask, claimTask as lifecycleClaimTask, clearApprovalTask as lifecycleClearApprovalTask, pauseTask as lifecyclePauseTask, requestApprovalTask as lifecycleRequestApprovalTask, resumeTask as lifecycleResumeTask, unblockTask as lifecycleUnblockTask, unclaimTask as lifecycleUnclaimTask, } from './system/task-state.js';
|
|
3
|
+
import { completeTask as lifecycleCompleteTask, uncompleteTask as lifecycleUncompleteTask, } from './system/task-completion.js';
|
|
4
|
+
import { addTask as lifecycleAddTask, batchEdit as lifecycleBatchEdit, decomposeTask as lifecycleDecomposeTask, } from './system/task-mutations.js';
|
|
5
|
+
import { editTask as lifecycleEditTask } from './system/task-lifecycle-edit.js';
|
|
6
|
+
import { assertLockHeld, getOwnerIdentity } from './system/task-lock.js';
|
|
7
|
+
export class TaskMutator {
|
|
8
|
+
store;
|
|
9
|
+
constructor(store = taskStore) {
|
|
10
|
+
this.store = store;
|
|
11
|
+
}
|
|
12
|
+
async claim(taskId, agent) {
|
|
13
|
+
return this.store.runExclusive(() => {
|
|
14
|
+
const task = this.store.getById(taskId);
|
|
15
|
+
if (!task)
|
|
16
|
+
return { success: false, message: `Task not found: ${taskId}` };
|
|
17
|
+
const result = lifecycleClaimTask(task.text, task.project, agent, taskId);
|
|
18
|
+
if (result.success) {
|
|
19
|
+
this.store.refresh();
|
|
20
|
+
this.store.commitAndPush(`task-store: claim ${taskId} by ${agent}`);
|
|
21
|
+
}
|
|
22
|
+
return result;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
async unclaim(taskId) {
|
|
26
|
+
return this.store.runExclusive(() => {
|
|
27
|
+
const task = this.store.getById(taskId);
|
|
28
|
+
if (!task)
|
|
29
|
+
return { success: false, message: `Task not found: ${taskId}` };
|
|
30
|
+
const result = lifecycleUnclaimTask(task.text, task.project, taskId);
|
|
31
|
+
if (result.success) {
|
|
32
|
+
this.store.refresh();
|
|
33
|
+
this.store.commitAndPush(`task-store: unclaim ${taskId}`);
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async complete(taskId, note) {
|
|
39
|
+
return this.store.runExclusive(() => {
|
|
40
|
+
const task = this.store.getById(taskId);
|
|
41
|
+
if (!task)
|
|
42
|
+
return { success: false, message: `Task not found: ${taskId}` };
|
|
43
|
+
const result = lifecycleCompleteTask(task.text, task.project, note || '', taskId);
|
|
44
|
+
if (result.success) {
|
|
45
|
+
this.store.refresh();
|
|
46
|
+
this.store.commitAndPush(`task-store: complete ${taskId}`);
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
async uncomplete(taskId) {
|
|
52
|
+
return this.store.runExclusive(() => {
|
|
53
|
+
const task = this.store.getById(taskId);
|
|
54
|
+
if (!task)
|
|
55
|
+
return { success: false, message: `Task not found: ${taskId}` };
|
|
56
|
+
const result = lifecycleUncompleteTask(task.text, task.project, taskId);
|
|
57
|
+
if (result.success) {
|
|
58
|
+
this.store.refresh();
|
|
59
|
+
this.store.commitAndPush(`task-store: uncomplete ${taskId}`);
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
async block(taskId, reason) {
|
|
65
|
+
return this.store.runExclusive(() => {
|
|
66
|
+
const task = this.store.getById(taskId);
|
|
67
|
+
if (!task)
|
|
68
|
+
return { success: false, message: `Task not found: ${taskId}` };
|
|
69
|
+
const result = lifecycleBlockTask(task.text, task.project, reason, taskId);
|
|
70
|
+
if (result.success) {
|
|
71
|
+
this.store.refresh();
|
|
72
|
+
this.store.commitAndPush(`task-store: block ${taskId}`);
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
async unblock(taskId) {
|
|
78
|
+
return this.store.runExclusive(() => {
|
|
79
|
+
const task = this.store.getById(taskId);
|
|
80
|
+
if (!task)
|
|
81
|
+
return { success: false, message: `Task not found: ${taskId}` };
|
|
82
|
+
const result = lifecycleUnblockTask(task.text, task.project, taskId);
|
|
83
|
+
if (result.success) {
|
|
84
|
+
this.store.refresh();
|
|
85
|
+
this.store.commitAndPush(`task-store: unblock ${taskId}`);
|
|
86
|
+
}
|
|
87
|
+
return result;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
async pause(taskId) {
|
|
91
|
+
return this.store.runExclusive(() => {
|
|
92
|
+
const task = this.store.getById(taskId);
|
|
93
|
+
if (!task)
|
|
94
|
+
return { success: false, message: `Task not found: ${taskId}` };
|
|
95
|
+
const result = lifecyclePauseTask(task.text, task.project, taskId);
|
|
96
|
+
if (result.success) {
|
|
97
|
+
this.store.refresh();
|
|
98
|
+
this.store.commitAndPush(`task-store: pause ${taskId}`);
|
|
99
|
+
}
|
|
100
|
+
return result;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
async resume(taskId) {
|
|
104
|
+
return this.store.runExclusive(() => {
|
|
105
|
+
const task = this.store.getById(taskId);
|
|
106
|
+
if (!task)
|
|
107
|
+
return { success: false, message: `Task not found: ${taskId}` };
|
|
108
|
+
const result = lifecycleResumeTask(task.text, task.project, taskId);
|
|
109
|
+
if (result.success) {
|
|
110
|
+
this.store.refresh();
|
|
111
|
+
this.store.commitAndPush(`task-store: resume ${taskId}`);
|
|
112
|
+
}
|
|
113
|
+
return result;
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
async requestApproval(taskId) {
|
|
117
|
+
return this.store.runExclusive(() => {
|
|
118
|
+
const task = this.store.getById(taskId);
|
|
119
|
+
if (!task)
|
|
120
|
+
return { success: false, message: `Task not found: ${taskId}` };
|
|
121
|
+
const result = lifecycleRequestApprovalTask(task.text, task.project, taskId);
|
|
122
|
+
if (result.success) {
|
|
123
|
+
this.store.refresh();
|
|
124
|
+
this.store.commitAndPush(`task-store: requestApproval ${taskId}`);
|
|
125
|
+
}
|
|
126
|
+
return result;
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
async approve(taskId) {
|
|
130
|
+
return this.store.runExclusive(() => {
|
|
131
|
+
const task = this.store.getById(taskId);
|
|
132
|
+
if (!task)
|
|
133
|
+
return { success: false, message: `Task not found: ${taskId}` };
|
|
134
|
+
const result = lifecycleApproveTask(task.text, task.project, taskId);
|
|
135
|
+
if (result.success) {
|
|
136
|
+
this.store.refresh();
|
|
137
|
+
this.store.commitAndPush(`task-store: approve ${taskId}`);
|
|
138
|
+
}
|
|
139
|
+
return result;
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
async clearApproval(taskId) {
|
|
143
|
+
return this.store.runExclusive(() => {
|
|
144
|
+
const task = this.store.getById(taskId);
|
|
145
|
+
if (!task)
|
|
146
|
+
return { success: false, message: `Task not found: ${taskId}` };
|
|
147
|
+
const result = lifecycleClearApprovalTask(task.text, task.project, taskId);
|
|
148
|
+
if (result.success) {
|
|
149
|
+
this.store.refresh();
|
|
150
|
+
this.store.commitAndPush(`task-store: clearApproval ${taskId}`);
|
|
151
|
+
}
|
|
152
|
+
return result;
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
async batchEdit(project, taskIds, options) {
|
|
156
|
+
return this.store.runExclusive(() => {
|
|
157
|
+
const lockError = assertLockHeld(project, getOwnerIdentity());
|
|
158
|
+
if (lockError)
|
|
159
|
+
return { success: false, message: lockError };
|
|
160
|
+
const result = lifecycleBatchEdit(project, taskIds, options);
|
|
161
|
+
if (result.success) {
|
|
162
|
+
this.store.refresh();
|
|
163
|
+
this.store.commitAndPush(`task-store: batch-edit ${taskIds.length} tasks in ${project}`);
|
|
164
|
+
}
|
|
165
|
+
return result;
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
async add(project, text, why, doneWhen, priority, template, dependsOn) {
|
|
169
|
+
return this.store.runExclusive(() => {
|
|
170
|
+
const lockError = assertLockHeld(project, getOwnerIdentity());
|
|
171
|
+
if (lockError)
|
|
172
|
+
return { success: false, message: lockError };
|
|
173
|
+
const result = lifecycleAddTask(project, text, why, doneWhen, priority || 'medium', template || null, dependsOn || null);
|
|
174
|
+
if (result.success) {
|
|
175
|
+
this.store.refresh();
|
|
176
|
+
this.store.commitAndPush(`task-store: add task to ${project}`);
|
|
177
|
+
}
|
|
178
|
+
return result;
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
async edit(project, options) {
|
|
182
|
+
return this.store.runExclusive(() => {
|
|
183
|
+
const lockError = assertLockHeld(project, getOwnerIdentity());
|
|
184
|
+
if (lockError)
|
|
185
|
+
return { success: false, message: lockError };
|
|
186
|
+
const result = lifecycleEditTask(project, options);
|
|
187
|
+
if (result.success) {
|
|
188
|
+
this.store.refresh();
|
|
189
|
+
this.store.commitAndPush(`task-store: edit task in ${project}`);
|
|
190
|
+
}
|
|
191
|
+
return result;
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
async decompose(project, taskText, subtasks, taskId) {
|
|
195
|
+
return this.store.runExclusive(() => {
|
|
196
|
+
const lockError = assertLockHeld(project, getOwnerIdentity());
|
|
197
|
+
if (lockError)
|
|
198
|
+
return { success: false, message: lockError };
|
|
199
|
+
const result = lifecycleDecomposeTask(project, taskText, subtasks, taskId || null);
|
|
200
|
+
if (result.success) {
|
|
201
|
+
this.store.refresh();
|
|
202
|
+
this.store.commitAndPush(`task-store: decompose task in ${project}`);
|
|
203
|
+
}
|
|
204
|
+
return result;
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
export const taskMutator = new TaskMutator();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../core/task-parser.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// input: re-exports from core/task-parser.ts (read-only parsing utilities)
|
|
2
|
+
// output: same public API surface as before, but implementation lives in core/
|
|
3
|
+
// pos: store/task-repo.ts imports from @core/task-parser.js instead of @domain/tasks/parser.js
|
|
4
|
+
// This satisfies the dep-cruiser store→domain rule (S4 refactor).
|
|
5
|
+
// >>> If I am updated, update my header comment and the parent folder's CORTEX.md <<<
|
|
6
|
+
export * from '../../core/task-parser.js';
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { PlatformAdapter } from '../../platform/index.js';
|
|
2
|
+
interface PendingTaskEntry {
|
|
3
|
+
channel: string;
|
|
4
|
+
machine: string;
|
|
5
|
+
launchedAt: number;
|
|
6
|
+
scheduleTaskId: string | null;
|
|
7
|
+
taskText: string | null;
|
|
8
|
+
taskHash: string | null;
|
|
9
|
+
project: string | null;
|
|
10
|
+
trackingTs: string | null;
|
|
11
|
+
sessionName: string | null;
|
|
12
|
+
tmuxName: string | null;
|
|
13
|
+
pid: string | null;
|
|
14
|
+
}
|
|
15
|
+
declare function buildTrackingMetaParts({ startedAtMs, elapsed_s }: {
|
|
16
|
+
startedAtMs?: number;
|
|
17
|
+
elapsed_s?: number;
|
|
18
|
+
}): string;
|
|
19
|
+
declare function buildTrackingMessage({ taskId, machine, taskText, startedAtMs, elapsed_s, turn_count, status, cost_usd, duration_s, num_turns, finalOutput }: {
|
|
20
|
+
taskId: string;
|
|
21
|
+
machine?: string;
|
|
22
|
+
taskText?: string | null;
|
|
23
|
+
startedAtMs?: number;
|
|
24
|
+
elapsed_s?: number;
|
|
25
|
+
turn_count?: number;
|
|
26
|
+
status: string;
|
|
27
|
+
cost_usd?: number | null;
|
|
28
|
+
duration_s?: number | null;
|
|
29
|
+
num_turns?: number | null;
|
|
30
|
+
finalOutput?: string | null;
|
|
31
|
+
}): string;
|
|
32
|
+
declare function init(adapter: PlatformAdapter): void;
|
|
33
|
+
declare function onTaskLaunched({ taskId, machine, channel, scheduleTaskId, taskText, taskHash, project, sessionName, tmuxName, pid }: {
|
|
34
|
+
taskId: string;
|
|
35
|
+
machine: string;
|
|
36
|
+
channel: string;
|
|
37
|
+
scheduleTaskId?: string | null;
|
|
38
|
+
taskText?: string | null;
|
|
39
|
+
taskHash?: string | null;
|
|
40
|
+
project?: string | null;
|
|
41
|
+
sessionName?: string | null;
|
|
42
|
+
tmuxName?: string | null;
|
|
43
|
+
pid?: string | null;
|
|
44
|
+
}): Promise<void>;
|
|
45
|
+
declare function handleTaskProgress({ task_id, machine, cost_usd, turn_count, elapsed_s }: {
|
|
46
|
+
task_id?: string;
|
|
47
|
+
machine?: string;
|
|
48
|
+
cost_usd?: number | null;
|
|
49
|
+
turn_count?: number;
|
|
50
|
+
elapsed_s?: number;
|
|
51
|
+
}): void;
|
|
52
|
+
declare function clearTask(taskId: string): void;
|
|
53
|
+
declare function getPendingTasksForSchedule(scheduleTaskId: string): Array<PendingTaskEntry & {
|
|
54
|
+
taskId: string;
|
|
55
|
+
}>;
|
|
56
|
+
declare function findPendingTaskMatch({ scheduleTaskId, taskHash, project, taskText }: {
|
|
57
|
+
scheduleTaskId: string;
|
|
58
|
+
taskHash?: string | null;
|
|
59
|
+
project?: string;
|
|
60
|
+
taskText?: string;
|
|
61
|
+
}): (PendingTaskEntry & {
|
|
62
|
+
taskId: string;
|
|
63
|
+
}) | null;
|
|
64
|
+
declare function getTask(taskId: string): PendingTaskEntry | null;
|
|
65
|
+
declare function hasPendingTasks(): boolean;
|
|
66
|
+
declare function pendingTaskCount(): number;
|
|
67
|
+
export { init, onTaskLaunched, handleTaskProgress, clearTask, getPendingTasksForSchedule, findPendingTaskMatch, getTask, hasPendingTasks, pendingTaskCount, buildTrackingMessage, buildTrackingMetaParts, };
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
// input: pending-tasks.json + channel/execution registries
|
|
2
|
+
// output: init/onTaskLaunched/handleTaskProgress + trackers
|
|
3
|
+
// pos: dispatched task tracking view and Slack status messages
|
|
4
|
+
// >>> If I am updated, update my header comment and the parent folder's CORTEX.md <<<
|
|
5
|
+
import { readFileSync, writeFileSync } from 'fs';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
import { STORE_DIR, formatDurationCompact } from '../../core/utils.js';
|
|
8
|
+
import { createLogger } from '../../core/log.js';
|
|
9
|
+
import { channelRepo } from '../../store/channel-repo.js';
|
|
10
|
+
import * as executionRegistry from '../executions/registry.js';
|
|
11
|
+
const log = createLogger('pending-task-tracker');
|
|
12
|
+
const PENDING_TASKS_FILE = path.join(STORE_DIR, 'pending-tasks.json');
|
|
13
|
+
const TASK_STALE_MS = 4 * 60 * 60 * 1000;
|
|
14
|
+
let _adapter = null;
|
|
15
|
+
// --- Persistence ---
|
|
16
|
+
function loadPendingTasks() {
|
|
17
|
+
try {
|
|
18
|
+
const data = JSON.parse(readFileSync(PENDING_TASKS_FILE, 'utf8'));
|
|
19
|
+
return new Map(Object.entries(data));
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return new Map();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function savePendingTasks() {
|
|
26
|
+
const obj = Object.fromEntries(pendingTasks);
|
|
27
|
+
writeFileSync(PENDING_TASKS_FILE, JSON.stringify(obj, null, 2));
|
|
28
|
+
}
|
|
29
|
+
const pendingTasks = loadPendingTasks();
|
|
30
|
+
if (pendingTasks.size > 0) {
|
|
31
|
+
log.info(`Restored ${pendingTasks.size} pending task(s) from disk`);
|
|
32
|
+
}
|
|
33
|
+
// --- Message builders ---
|
|
34
|
+
function buildTrackingMetaParts({ startedAtMs, elapsed_s }) {
|
|
35
|
+
const elapsed = elapsed_s ?? ((Date.now() - startedAtMs) / 1000);
|
|
36
|
+
return `:stopwatch: ${formatDurationCompact(elapsed || 0)}`;
|
|
37
|
+
}
|
|
38
|
+
function buildTrackingMessage({ taskId, machine, taskText, startedAtMs, elapsed_s, turn_count, status, cost_usd, duration_s, num_turns, finalOutput }) {
|
|
39
|
+
const label = taskText ? `${taskText}` : `Task ${taskId}`;
|
|
40
|
+
if (status === 'completed') {
|
|
41
|
+
const dur = formatDurationCompact(duration_s || elapsed_s || 0);
|
|
42
|
+
const costStr = cost_usd != null ? ` | $${cost_usd.toFixed(4)}` : '';
|
|
43
|
+
const outputStr = finalOutput ? `\n\n${finalOutput}` : '';
|
|
44
|
+
return `:white_check_mark: *[${taskId}]* ${label}\nCompleted on ${machine} | :stopwatch: ${dur} | ${num_turns || turn_count || '?'} turns${costStr}${outputStr}`;
|
|
45
|
+
}
|
|
46
|
+
if (status === 'failed') {
|
|
47
|
+
const dur = formatDurationCompact(duration_s || elapsed_s || 0);
|
|
48
|
+
const costStr = cost_usd != null ? ` | $${cost_usd.toFixed(4)}` : '';
|
|
49
|
+
const outputStr = finalOutput ? `\n\n${finalOutput}` : '';
|
|
50
|
+
return `:x: *[${taskId}]* ${label}\nFailed on ${machine} | :stopwatch: ${dur} | ${num_turns || turn_count || '?'} turns${costStr}${outputStr}`;
|
|
51
|
+
}
|
|
52
|
+
return `:satellite: *[${taskId}]* ${label}\nRunning on ${machine} | ${buildTrackingMetaParts({ startedAtMs, elapsed_s })}`;
|
|
53
|
+
}
|
|
54
|
+
// --- Public API ---
|
|
55
|
+
function init(adapter) {
|
|
56
|
+
_adapter = adapter;
|
|
57
|
+
}
|
|
58
|
+
async function onTaskLaunched({ taskId, machine, channel, scheduleTaskId, taskText, taskHash, project, sessionName, tmuxName, pid }) {
|
|
59
|
+
const trackingChannel = (project && await channelRepo.getProjectChannel(project)) || channel;
|
|
60
|
+
executionRegistry.registerDispatchExecution({
|
|
61
|
+
taskId,
|
|
62
|
+
machine,
|
|
63
|
+
channel: trackingChannel,
|
|
64
|
+
project,
|
|
65
|
+
scheduleTaskId,
|
|
66
|
+
taskText,
|
|
67
|
+
taskHash,
|
|
68
|
+
sessionName,
|
|
69
|
+
tmuxName,
|
|
70
|
+
pid,
|
|
71
|
+
});
|
|
72
|
+
pendingTasks.set(taskId, {
|
|
73
|
+
channel: trackingChannel, machine, launchedAt: Date.now(),
|
|
74
|
+
scheduleTaskId: scheduleTaskId || null, taskText: taskText || null, taskHash: taskHash || null,
|
|
75
|
+
project: project || null, trackingTs: null,
|
|
76
|
+
sessionName: sessionName || null, tmuxName: tmuxName || null, pid: pid || null,
|
|
77
|
+
});
|
|
78
|
+
savePendingTasks();
|
|
79
|
+
log.info(`Task registered: ${taskId} on ${machine} (channel: ${trackingChannel}, project: ${project || 'none'}, schedule: ${scheduleTaskId || 'none'}, pending: ${pendingTasks.size})`);
|
|
80
|
+
const trackingText = buildTrackingMessage({ taskId, machine, taskText, startedAtMs: Date.now(), elapsed_s: 0, turn_count: 0, status: 'running' });
|
|
81
|
+
if (trackingChannel && _adapter) {
|
|
82
|
+
(async () => {
|
|
83
|
+
try {
|
|
84
|
+
const ref = await _adapter.postMessage(trackingChannel, { text: trackingText });
|
|
85
|
+
const t = pendingTasks.get(taskId);
|
|
86
|
+
if (t) {
|
|
87
|
+
t.trackingTs = ref.messageId;
|
|
88
|
+
savePendingTasks();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
catch (e) {
|
|
92
|
+
log.error(`Failed to send tracking message for ${taskId}:`, e.message);
|
|
93
|
+
}
|
|
94
|
+
})();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function handleTaskProgress({ task_id, machine, cost_usd, turn_count, elapsed_s }) {
|
|
98
|
+
if (!task_id)
|
|
99
|
+
return;
|
|
100
|
+
const t = pendingTasks.get(task_id);
|
|
101
|
+
const execution = executionRegistry.getExecutionByTaskId(task_id);
|
|
102
|
+
if (execution) {
|
|
103
|
+
executionRegistry.touchExecution(execution.id, {
|
|
104
|
+
metrics: {
|
|
105
|
+
costUsd: cost_usd ?? execution.metrics.costUsd,
|
|
106
|
+
numTurns: turn_count ?? execution.metrics.numTurns,
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
if (!t || !t.trackingTs || !_adapter)
|
|
111
|
+
return;
|
|
112
|
+
const trackingChannel = t.channel;
|
|
113
|
+
const text = buildTrackingMessage({ taskId: task_id, machine: machine || t.machine, taskText: t.taskText, startedAtMs: t.launchedAt, elapsed_s, turn_count, cost_usd, status: 'running' });
|
|
114
|
+
(async () => {
|
|
115
|
+
try {
|
|
116
|
+
await _adapter.updateMessage({ channel: trackingChannel, messageId: t.trackingTs }, { text });
|
|
117
|
+
}
|
|
118
|
+
catch (e) {
|
|
119
|
+
log.error(`Failed to update tracking for ${task_id}:`, e.message);
|
|
120
|
+
}
|
|
121
|
+
})();
|
|
122
|
+
}
|
|
123
|
+
function clearTask(taskId) {
|
|
124
|
+
if (pendingTasks.has(taskId)) {
|
|
125
|
+
const t = pendingTasks.get(taskId);
|
|
126
|
+
pendingTasks.delete(taskId);
|
|
127
|
+
savePendingTasks();
|
|
128
|
+
log.info(`Task cleared: ${taskId} on ${t.machine} (pending: ${pendingTasks.size})`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function getPendingTasksForSchedule(scheduleTaskId) {
|
|
132
|
+
const now = Date.now();
|
|
133
|
+
let changed = false;
|
|
134
|
+
for (const [tid, t] of pendingTasks) {
|
|
135
|
+
if (now - t.launchedAt > TASK_STALE_MS) {
|
|
136
|
+
log.info(`Clearing stale task ${tid} on ${t.machine} (${((now - t.launchedAt) / 60000).toFixed(0)}m old)`);
|
|
137
|
+
pendingTasks.delete(tid);
|
|
138
|
+
changed = true;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (changed)
|
|
142
|
+
savePendingTasks();
|
|
143
|
+
return [...pendingTasks.entries()]
|
|
144
|
+
.filter(([, t]) => t.scheduleTaskId === scheduleTaskId)
|
|
145
|
+
.map(([tid, t]) => ({ taskId: tid, ...t }));
|
|
146
|
+
}
|
|
147
|
+
function findPendingTaskMatch({ scheduleTaskId, taskHash, project, taskText }) {
|
|
148
|
+
return getPendingTasksForSchedule(scheduleTaskId).find((task) => {
|
|
149
|
+
if (taskHash && task.taskHash)
|
|
150
|
+
return task.taskHash === taskHash;
|
|
151
|
+
return task.project === project && task.taskText === taskText;
|
|
152
|
+
}) || null;
|
|
153
|
+
}
|
|
154
|
+
function getTask(taskId) {
|
|
155
|
+
return pendingTasks.get(taskId) || null;
|
|
156
|
+
}
|
|
157
|
+
function hasPendingTasks() {
|
|
158
|
+
return pendingTasks.size > 0;
|
|
159
|
+
}
|
|
160
|
+
function pendingTaskCount() {
|
|
161
|
+
return pendingTasks.size;
|
|
162
|
+
}
|
|
163
|
+
export { init, onTaskLaunched, handleTaskProgress, clearTask, getPendingTasksForSchedule, findPendingTaskMatch, getTask, hasPendingTasks, pendingTaskCount, buildTrackingMessage, buildTrackingMetaParts, };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { RecommendationSection, Recommendation, TaskCandidate, ReflectionField, ImpliedTaskMatch, ScanResult, CliResult } from './types.js';
|
|
2
|
+
declare function extractRecommendationSections(content: string, sourceFile: string): RecommendationSection[];
|
|
3
|
+
declare function parseRecommendations(body: string, sourceId: string, sectionHeader: string, sourceFile: string): Recommendation[];
|
|
4
|
+
declare function extractReflectionFields(content: string, sourceFile: string, days?: number): ReflectionField[];
|
|
5
|
+
declare function extractImpliedTasksFromExperiments(content: string, sourceFile: string, days?: number): ImpliedTaskMatch[];
|
|
6
|
+
declare function deduplicateCandidates(candidates: TaskCandidate[], existingTasksContent: string): TaskCandidate[];
|
|
7
|
+
declare function recommendationToCandidate(recommendation: Recommendation): TaskCandidate | null;
|
|
8
|
+
declare function impliedTaskToCandidate(task: ImpliedTaskMatch): TaskCandidate;
|
|
9
|
+
declare function reflectionToCandidate(field: ReflectionField): TaskCandidate;
|
|
10
|
+
declare function scanProjectRecommendations(_baseDir: string, project?: string | null, days?: number): ScanResult;
|
|
11
|
+
declare function runCli(argv: string[]): CliResult;
|
|
12
|
+
export { extractRecommendationSections, parseRecommendations, extractReflectionFields, extractImpliedTasksFromExperiments, recommendationToCandidate, impliedTaskToCandidate, reflectionToCandidate, deduplicateCandidates, scanProjectRecommendations, runCli, };
|