@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,110 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import { collectAllExistingHashes, generateHash } from './task-id-utils.js';
|
|
3
|
+
import { editTask, findTask, getTasksPath, readTasks, validateTemplateName, writeTasks } from './task-lifecycle-edit.js';
|
|
4
|
+
function addTask(project, text, why, doneWhen, priority = 'medium', template = null, dependsOn = null, plan = null) {
|
|
5
|
+
if (!text || text === 'null') {
|
|
6
|
+
return { success: false, message: '--text is required and must not be empty' };
|
|
7
|
+
}
|
|
8
|
+
if (!template) {
|
|
9
|
+
return { success: false, message: '--template is required (use --help to list available templates)' };
|
|
10
|
+
}
|
|
11
|
+
const templateError = validateTemplateName(template);
|
|
12
|
+
if (templateError)
|
|
13
|
+
return { success: false, message: templateError };
|
|
14
|
+
const tasksPath = getTasksPath(project);
|
|
15
|
+
if (!fs.existsSync(tasksPath)) {
|
|
16
|
+
return { success: false, message: `TASKS.yaml not found for project ${project}` };
|
|
17
|
+
}
|
|
18
|
+
const tasks = readTasks(project);
|
|
19
|
+
const existingHashes = collectAllExistingHashes();
|
|
20
|
+
const taskHash = generateHash(existingHashes);
|
|
21
|
+
const dependsOnList = dependsOn
|
|
22
|
+
? dependsOn.flatMap((d) => d.includes(',') ? d.split(',').map((s) => s.trim()).filter(Boolean) : [d])
|
|
23
|
+
: [];
|
|
24
|
+
const newTask = {
|
|
25
|
+
id: taskHash,
|
|
26
|
+
text,
|
|
27
|
+
why: why || '',
|
|
28
|
+
done_when: doneWhen || '',
|
|
29
|
+
priority: (['high', 'medium', 'low'].includes(priority) ? priority : 'medium'),
|
|
30
|
+
status: 'open',
|
|
31
|
+
template,
|
|
32
|
+
plan: plan?.trim() || '',
|
|
33
|
+
project,
|
|
34
|
+
depends_on: dependsOnList,
|
|
35
|
+
gpu: null,
|
|
36
|
+
gpu_count: 1,
|
|
37
|
+
blocked_by: null,
|
|
38
|
+
claimed_by: null,
|
|
39
|
+
claimed_at: null,
|
|
40
|
+
paused: false,
|
|
41
|
+
approval_needed: false,
|
|
42
|
+
approved_at: null,
|
|
43
|
+
not_before: null,
|
|
44
|
+
completed_at: null,
|
|
45
|
+
completed_note: null,
|
|
46
|
+
pending_at: null,
|
|
47
|
+
};
|
|
48
|
+
tasks.push(newTask);
|
|
49
|
+
writeTasks(project, tasks);
|
|
50
|
+
return { success: true, message: `Task added to ${project}`, task_id: taskHash };
|
|
51
|
+
}
|
|
52
|
+
function batchEdit(project, taskIds, options = {}) {
|
|
53
|
+
const results = [];
|
|
54
|
+
for (const id of taskIds) {
|
|
55
|
+
const result = editTask(project, { ...options, taskId: id });
|
|
56
|
+
results.push({ taskId: id, success: result.success, message: result.message || '' });
|
|
57
|
+
}
|
|
58
|
+
const succeeded = results.filter((r) => r.success).length;
|
|
59
|
+
const failed = results.filter((r) => !r.success);
|
|
60
|
+
let message = `Batch edit: ${succeeded}/${taskIds.length} tasks updated`;
|
|
61
|
+
if (failed.length > 0) {
|
|
62
|
+
message += `\nFailed:\n${failed.map((r) => ` [${r.taskId}] ${r.message}`).join('\n')}`;
|
|
63
|
+
}
|
|
64
|
+
return { success: failed.length === 0, message, results };
|
|
65
|
+
}
|
|
66
|
+
function decomposeTask(project, originalText, subtasks, taskId = null) {
|
|
67
|
+
const tasks = readTasks(project);
|
|
68
|
+
if (tasks.length === 0 && !fs.existsSync(getTasksPath(project))) {
|
|
69
|
+
return { success: false, message: `TASKS.yaml not found for project ${project}` };
|
|
70
|
+
}
|
|
71
|
+
const found = findTask(tasks, originalText, taskId);
|
|
72
|
+
if ('error' in found)
|
|
73
|
+
return { success: false, message: found.error };
|
|
74
|
+
const parentIndex = found.index;
|
|
75
|
+
const parentTask = found.task;
|
|
76
|
+
const existingHashes = collectAllExistingHashes();
|
|
77
|
+
const newTasks = [];
|
|
78
|
+
for (const sub of subtasks) {
|
|
79
|
+
const hash = generateHash(existingHashes);
|
|
80
|
+
existingHashes.add(hash);
|
|
81
|
+
newTasks.push({
|
|
82
|
+
id: hash,
|
|
83
|
+
text: sub.text,
|
|
84
|
+
why: sub.why || '',
|
|
85
|
+
done_when: sub.done_when || '',
|
|
86
|
+
priority: (sub.priority || 'medium'),
|
|
87
|
+
status: 'open',
|
|
88
|
+
template: sub.template || parentTask.template,
|
|
89
|
+
plan: (sub.plan?.trim()) || parentTask.plan,
|
|
90
|
+
project,
|
|
91
|
+
depends_on: sub.depends_on || [],
|
|
92
|
+
gpu: null,
|
|
93
|
+
gpu_count: 1,
|
|
94
|
+
blocked_by: null,
|
|
95
|
+
claimed_by: null,
|
|
96
|
+
claimed_at: null,
|
|
97
|
+
paused: false,
|
|
98
|
+
approval_needed: false,
|
|
99
|
+
approved_at: null,
|
|
100
|
+
not_before: null,
|
|
101
|
+
completed_at: null,
|
|
102
|
+
completed_note: null,
|
|
103
|
+
pending_at: null,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
tasks.splice(parentIndex, 1, ...newTasks);
|
|
107
|
+
writeTasks(project, tasks);
|
|
108
|
+
return { success: true, message: `Task decomposed into ${subtasks.length} subtasks` };
|
|
109
|
+
}
|
|
110
|
+
export { addTask, batchEdit, decomposeTask };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
declare function stopTask(taskId: string): {
|
|
2
|
+
success: boolean;
|
|
3
|
+
message: string;
|
|
4
|
+
dispatch_id?: undefined;
|
|
5
|
+
machine?: undefined;
|
|
6
|
+
task_hash?: undefined;
|
|
7
|
+
project?: undefined;
|
|
8
|
+
steps?: undefined;
|
|
9
|
+
} | {
|
|
10
|
+
success: boolean;
|
|
11
|
+
message: string;
|
|
12
|
+
dispatch_id: string;
|
|
13
|
+
machine: any;
|
|
14
|
+
task_hash: any;
|
|
15
|
+
project: any;
|
|
16
|
+
steps: string[];
|
|
17
|
+
};
|
|
18
|
+
declare function stopTaskDryRun(taskId: string): {
|
|
19
|
+
success: boolean;
|
|
20
|
+
message: string;
|
|
21
|
+
dry_run?: undefined;
|
|
22
|
+
dispatch_id?: undefined;
|
|
23
|
+
machine?: undefined;
|
|
24
|
+
task_hash?: undefined;
|
|
25
|
+
project?: undefined;
|
|
26
|
+
actions?: undefined;
|
|
27
|
+
} | {
|
|
28
|
+
success: boolean;
|
|
29
|
+
dry_run: boolean;
|
|
30
|
+
message: string;
|
|
31
|
+
dispatch_id: string;
|
|
32
|
+
machine: any;
|
|
33
|
+
task_hash: any;
|
|
34
|
+
project: any;
|
|
35
|
+
actions: string[];
|
|
36
|
+
};
|
|
37
|
+
export { stopTask, stopTaskDryRun };
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { STORE_DIR } from '../../../core/utils.js';
|
|
4
|
+
import { findTask, readTasks, writeTasks } from './task-lifecycle-edit.js';
|
|
5
|
+
function stopTask(taskId) {
|
|
6
|
+
const pendingTasksFile = path.join(STORE_DIR, 'pending-tasks.json');
|
|
7
|
+
let pendingTasks = {};
|
|
8
|
+
try {
|
|
9
|
+
pendingTasks = JSON.parse(fs.readFileSync(pendingTasksFile, 'utf8'));
|
|
10
|
+
}
|
|
11
|
+
catch { }
|
|
12
|
+
let dispatchId = null;
|
|
13
|
+
let taskInfo = null;
|
|
14
|
+
if (pendingTasks[taskId]) {
|
|
15
|
+
dispatchId = taskId;
|
|
16
|
+
taskInfo = pendingTasks[taskId];
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
for (const [id, info] of Object.entries(pendingTasks)) {
|
|
20
|
+
if (info.taskHash === taskId) {
|
|
21
|
+
dispatchId = id;
|
|
22
|
+
taskInfo = info;
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (!taskInfo) {
|
|
28
|
+
return { success: false, message: `No running dispatched task found for '${taskId}'. Use dispatch task ID or TASKS.yaml hash.` };
|
|
29
|
+
}
|
|
30
|
+
const machine = taskInfo.machine;
|
|
31
|
+
const tmuxName = taskInfo.tmuxName;
|
|
32
|
+
const steps = [];
|
|
33
|
+
if (taskInfo.pid) {
|
|
34
|
+
try {
|
|
35
|
+
process.kill(taskInfo.pid, 'SIGTERM');
|
|
36
|
+
steps.push(`Sent SIGTERM to PID ${taskInfo.pid} on ${machine}`);
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
steps.push(`Process kill warning: ${err.message}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else if (tmuxName) {
|
|
43
|
+
steps.push(`No PID tracked for ${tmuxName} — process may still be running`);
|
|
44
|
+
}
|
|
45
|
+
const tasksmdHash = taskInfo.taskHash;
|
|
46
|
+
const project = taskInfo.project;
|
|
47
|
+
if (project && tasksmdHash) {
|
|
48
|
+
const tasks = readTasks(project);
|
|
49
|
+
const found = findTask(tasks, null, tasksmdHash);
|
|
50
|
+
if (!('error' in found)) {
|
|
51
|
+
found.task.claimed_by = null;
|
|
52
|
+
found.task.claimed_at = null;
|
|
53
|
+
writeTasks(project, tasks);
|
|
54
|
+
steps.push(`Unclaimed task [${tasksmdHash}] in ${project}/TASKS.yaml`);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
steps.push(`Unclaim skipped: ${found.error}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
delete pendingTasks[dispatchId];
|
|
61
|
+
fs.writeFileSync(pendingTasksFile, JSON.stringify(pendingTasks, null, 2));
|
|
62
|
+
steps.push('Removed from pending-tasks.json');
|
|
63
|
+
const executionsFile = process.env.CORTEX_EXECUTIONS_FILE || path.join(STORE_DIR, 'executions.json');
|
|
64
|
+
try {
|
|
65
|
+
const executions = JSON.parse(fs.readFileSync(executionsFile, 'utf8'));
|
|
66
|
+
const timestamp = new Date().toISOString();
|
|
67
|
+
for (const record of Object.values(executions)) {
|
|
68
|
+
if (record.dispatch?.taskId === dispatchId && record.status === 'running') {
|
|
69
|
+
record.status = 'cancelled';
|
|
70
|
+
record.runtime.updatedAt = timestamp;
|
|
71
|
+
record.runtime.endedAt = timestamp;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
fs.writeFileSync(executionsFile, JSON.stringify(executions, null, 2));
|
|
75
|
+
steps.push('Marked cancelled in executions.json');
|
|
76
|
+
}
|
|
77
|
+
catch { }
|
|
78
|
+
return { success: true, message: `Task [${dispatchId}] stopped on ${machine}`, dispatch_id: dispatchId, machine, task_hash: tasksmdHash || null, project: project || null, steps };
|
|
79
|
+
}
|
|
80
|
+
function stopTaskDryRun(taskId) {
|
|
81
|
+
const pendingTasksFile = path.join(STORE_DIR, 'pending-tasks.json');
|
|
82
|
+
let pendingTasks = {};
|
|
83
|
+
try {
|
|
84
|
+
pendingTasks = JSON.parse(fs.readFileSync(pendingTasksFile, 'utf8'));
|
|
85
|
+
}
|
|
86
|
+
catch { }
|
|
87
|
+
let dispatchId = null;
|
|
88
|
+
let taskInfo = null;
|
|
89
|
+
if (pendingTasks[taskId]) {
|
|
90
|
+
dispatchId = taskId;
|
|
91
|
+
taskInfo = pendingTasks[taskId];
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
for (const [id, info] of Object.entries(pendingTasks)) {
|
|
95
|
+
if (info.taskHash === taskId) {
|
|
96
|
+
dispatchId = id;
|
|
97
|
+
taskInfo = info;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (!taskInfo) {
|
|
103
|
+
return { success: false, message: `No running dispatched task found for '${taskId}'.` };
|
|
104
|
+
}
|
|
105
|
+
const actions = [];
|
|
106
|
+
if (taskInfo.tmuxName)
|
|
107
|
+
actions.push(`Kill tmux session '${taskInfo.tmuxName}' on ${taskInfo.machine}`);
|
|
108
|
+
if (taskInfo.project && taskInfo.taskHash)
|
|
109
|
+
actions.push(`Unclaim task [${taskInfo.taskHash}] in ${taskInfo.project}/TASKS.yaml`);
|
|
110
|
+
actions.push('Remove from pending-tasks.json');
|
|
111
|
+
actions.push('Mark cancelled in executions.json');
|
|
112
|
+
return {
|
|
113
|
+
success: true, dry_run: true,
|
|
114
|
+
message: `Would stop task [${dispatchId}] on ${taskInfo.machine}`,
|
|
115
|
+
dispatch_id: dispatchId, machine: taskInfo.machine,
|
|
116
|
+
task_hash: taskInfo.taskHash || null, project: taskInfo.project || null, actions,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
export { stopTask, stopTaskDryRun };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
declare function claimTask(taskText: string | null, project: string, agentId: string, taskId?: string | null): {
|
|
2
|
+
success: boolean;
|
|
3
|
+
message: string;
|
|
4
|
+
task_id?: undefined;
|
|
5
|
+
agent?: undefined;
|
|
6
|
+
claimed_at?: undefined;
|
|
7
|
+
} | {
|
|
8
|
+
success: boolean;
|
|
9
|
+
message: string;
|
|
10
|
+
task_id: string;
|
|
11
|
+
agent: string;
|
|
12
|
+
claimed_at: string;
|
|
13
|
+
};
|
|
14
|
+
declare function unclaimTask(taskText: string | null, project: string, taskId?: string | null): {
|
|
15
|
+
success: boolean;
|
|
16
|
+
message: string;
|
|
17
|
+
task_id?: undefined;
|
|
18
|
+
} | {
|
|
19
|
+
success: boolean;
|
|
20
|
+
message: string;
|
|
21
|
+
task_id: string;
|
|
22
|
+
};
|
|
23
|
+
declare function pauseTask(taskText: string | null, project: string, taskId?: string | null): {
|
|
24
|
+
success: boolean;
|
|
25
|
+
message: string;
|
|
26
|
+
};
|
|
27
|
+
declare function resumeTask(taskText: string | null, project: string, taskId?: string | null): {
|
|
28
|
+
success: boolean;
|
|
29
|
+
message: string;
|
|
30
|
+
};
|
|
31
|
+
declare function requestApprovalTask(taskText: string | null, project: string, taskId?: string | null): {
|
|
32
|
+
success: boolean;
|
|
33
|
+
message: string;
|
|
34
|
+
};
|
|
35
|
+
declare function approveTask(taskText: string | null, project: string, taskId?: string | null): {
|
|
36
|
+
success: boolean;
|
|
37
|
+
message: string;
|
|
38
|
+
};
|
|
39
|
+
declare function clearApprovalTask(taskText: string | null, project: string, taskId?: string | null): {
|
|
40
|
+
success: boolean;
|
|
41
|
+
message: string;
|
|
42
|
+
};
|
|
43
|
+
declare function blockTask(taskText: string | null, project: string, reason: string, taskId?: string | null): {
|
|
44
|
+
success: boolean;
|
|
45
|
+
message: string;
|
|
46
|
+
task_id?: undefined;
|
|
47
|
+
} | {
|
|
48
|
+
success: boolean;
|
|
49
|
+
message: string;
|
|
50
|
+
task_id: string;
|
|
51
|
+
};
|
|
52
|
+
declare function pendingTask(taskText: string | null, project: string, taskId?: string | null): {
|
|
53
|
+
success: boolean;
|
|
54
|
+
message: string;
|
|
55
|
+
task_id?: undefined;
|
|
56
|
+
} | {
|
|
57
|
+
success: boolean;
|
|
58
|
+
message: string;
|
|
59
|
+
task_id: string;
|
|
60
|
+
};
|
|
61
|
+
declare function unblockTask(taskText: string | null, project: string, taskId?: string | null): {
|
|
62
|
+
success: boolean;
|
|
63
|
+
message: string;
|
|
64
|
+
task_id?: undefined;
|
|
65
|
+
} | {
|
|
66
|
+
success: boolean;
|
|
67
|
+
message: string;
|
|
68
|
+
task_id: string;
|
|
69
|
+
};
|
|
70
|
+
export { approveTask, blockTask, claimTask, clearApprovalTask, pauseTask, pendingTask, requestApprovalTask, resumeTask, unblockTask, unclaimTask, };
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { todayISO } from '../../../core/utils.js';
|
|
2
|
+
import { findTask, getTasksPath, readTasks, writeTasks } from './task-lifecycle-edit.js';
|
|
3
|
+
import * as fs from 'node:fs';
|
|
4
|
+
function claimTask(taskText, project, agentId, taskId = null) {
|
|
5
|
+
const tasks = readTasks(project);
|
|
6
|
+
if (tasks.length === 0 && !fs.existsSync(getTasksPath(project))) {
|
|
7
|
+
return { success: false, message: `TASKS.yaml not found for project ${project}` };
|
|
8
|
+
}
|
|
9
|
+
const found = findTask(tasks, taskText, taskId);
|
|
10
|
+
if ('error' in found)
|
|
11
|
+
return { success: false, message: found.error };
|
|
12
|
+
const task = found.task;
|
|
13
|
+
if (task.claimed_by)
|
|
14
|
+
return { success: false, message: 'Task already claimed (409 conflict)' };
|
|
15
|
+
if (task.status === 'done')
|
|
16
|
+
return { success: false, message: 'Task already completed' };
|
|
17
|
+
if (task.blocked_by)
|
|
18
|
+
return { success: false, message: 'Task is blocked' };
|
|
19
|
+
const today = todayISO();
|
|
20
|
+
task.claimed_by = agentId;
|
|
21
|
+
task.claimed_at = today;
|
|
22
|
+
writeTasks(project, tasks);
|
|
23
|
+
return { success: true, message: `Task claimed by ${agentId} on ${today}`, task_id: task.id, agent: agentId, claimed_at: today };
|
|
24
|
+
}
|
|
25
|
+
function unclaimTask(taskText, project, taskId = null) {
|
|
26
|
+
const tasks = readTasks(project);
|
|
27
|
+
if (tasks.length === 0 && !fs.existsSync(getTasksPath(project))) {
|
|
28
|
+
return { success: false, message: `TASKS.yaml not found for project ${project}` };
|
|
29
|
+
}
|
|
30
|
+
const found = findTask(tasks, taskText, taskId);
|
|
31
|
+
if ('error' in found)
|
|
32
|
+
return { success: false, message: found.error };
|
|
33
|
+
const task = found.task;
|
|
34
|
+
if (!task.claimed_by)
|
|
35
|
+
return { success: false, message: 'Task is not in-progress' };
|
|
36
|
+
task.claimed_by = null;
|
|
37
|
+
task.claimed_at = null;
|
|
38
|
+
writeTasks(project, tasks);
|
|
39
|
+
return { success: true, message: 'Task unclaimed', task_id: task.id };
|
|
40
|
+
}
|
|
41
|
+
function pauseTask(taskText, project, taskId = null) {
|
|
42
|
+
const tasks = readTasks(project);
|
|
43
|
+
if (tasks.length === 0 && !fs.existsSync(getTasksPath(project))) {
|
|
44
|
+
return { success: false, message: `TASKS.yaml not found for project ${project}` };
|
|
45
|
+
}
|
|
46
|
+
const found = findTask(tasks, taskText, taskId);
|
|
47
|
+
if ('error' in found)
|
|
48
|
+
return { success: false, message: found.error };
|
|
49
|
+
const task = found.task;
|
|
50
|
+
if (task.paused)
|
|
51
|
+
return { success: false, message: 'Task is already paused' };
|
|
52
|
+
task.claimed_by = null;
|
|
53
|
+
task.claimed_at = null;
|
|
54
|
+
task.paused = true;
|
|
55
|
+
writeTasks(project, tasks);
|
|
56
|
+
return { success: true, message: 'Task paused' };
|
|
57
|
+
}
|
|
58
|
+
function resumeTask(taskText, project, taskId = null) {
|
|
59
|
+
const tasks = readTasks(project);
|
|
60
|
+
if (tasks.length === 0 && !fs.existsSync(getTasksPath(project))) {
|
|
61
|
+
return { success: false, message: `TASKS.yaml not found for project ${project}` };
|
|
62
|
+
}
|
|
63
|
+
const found = findTask(tasks, taskText, taskId);
|
|
64
|
+
if ('error' in found)
|
|
65
|
+
return { success: false, message: found.error };
|
|
66
|
+
const task = found.task;
|
|
67
|
+
if (!task.paused)
|
|
68
|
+
return { success: false, message: 'Task is not paused' };
|
|
69
|
+
task.paused = false;
|
|
70
|
+
writeTasks(project, tasks);
|
|
71
|
+
return { success: true, message: 'Task resumed' };
|
|
72
|
+
}
|
|
73
|
+
function requestApprovalTask(taskText, project, taskId = null) {
|
|
74
|
+
const tasks = readTasks(project);
|
|
75
|
+
if (tasks.length === 0 && !fs.existsSync(getTasksPath(project))) {
|
|
76
|
+
return { success: false, message: `TASKS.yaml not found for project ${project}` };
|
|
77
|
+
}
|
|
78
|
+
const found = findTask(tasks, taskText, taskId);
|
|
79
|
+
if ('error' in found)
|
|
80
|
+
return { success: false, message: found.error };
|
|
81
|
+
const task = found.task;
|
|
82
|
+
if (task.approval_needed)
|
|
83
|
+
return { success: false, message: 'Task already requires approval' };
|
|
84
|
+
task.approved_at = null;
|
|
85
|
+
task.approval_needed = true;
|
|
86
|
+
writeTasks(project, tasks);
|
|
87
|
+
return { success: true, message: 'Task marked as approval-needed' };
|
|
88
|
+
}
|
|
89
|
+
function approveTask(taskText, project, taskId = null) {
|
|
90
|
+
const tasks = readTasks(project);
|
|
91
|
+
if (tasks.length === 0 && !fs.existsSync(getTasksPath(project))) {
|
|
92
|
+
return { success: false, message: `TASKS.yaml not found for project ${project}` };
|
|
93
|
+
}
|
|
94
|
+
const found = findTask(tasks, taskText, taskId);
|
|
95
|
+
if ('error' in found)
|
|
96
|
+
return { success: false, message: found.error };
|
|
97
|
+
const task = found.task;
|
|
98
|
+
if (task.status === 'done')
|
|
99
|
+
return { success: false, message: 'Cannot approve a completed task' };
|
|
100
|
+
if (task.blocked_by)
|
|
101
|
+
return { success: false, message: 'Cannot approve a blocked task — unblock it first' };
|
|
102
|
+
const today = todayISO();
|
|
103
|
+
task.approval_needed = false;
|
|
104
|
+
task.approved_at = today;
|
|
105
|
+
writeTasks(project, tasks);
|
|
106
|
+
return { success: true, message: `Task approved on ${today}` };
|
|
107
|
+
}
|
|
108
|
+
function clearApprovalTask(taskText, project, taskId = null) {
|
|
109
|
+
const tasks = readTasks(project);
|
|
110
|
+
if (tasks.length === 0 && !fs.existsSync(getTasksPath(project))) {
|
|
111
|
+
return { success: false, message: `TASKS.yaml not found for project ${project}` };
|
|
112
|
+
}
|
|
113
|
+
const found = findTask(tasks, taskText, taskId);
|
|
114
|
+
if ('error' in found)
|
|
115
|
+
return { success: false, message: found.error };
|
|
116
|
+
const task = found.task;
|
|
117
|
+
if (!task.approval_needed && !task.approved_at) {
|
|
118
|
+
return { success: false, message: 'Task has no approval tags' };
|
|
119
|
+
}
|
|
120
|
+
task.approval_needed = false;
|
|
121
|
+
task.approved_at = null;
|
|
122
|
+
writeTasks(project, tasks);
|
|
123
|
+
return { success: true, message: 'Approval tags cleared' };
|
|
124
|
+
}
|
|
125
|
+
function blockTask(taskText, project, reason, taskId = null) {
|
|
126
|
+
const tasks = readTasks(project);
|
|
127
|
+
if (tasks.length === 0 && !fs.existsSync(getTasksPath(project))) {
|
|
128
|
+
return { success: false, message: `TASKS.yaml not found for project ${project}` };
|
|
129
|
+
}
|
|
130
|
+
const found = findTask(tasks, taskText, taskId);
|
|
131
|
+
if ('error' in found)
|
|
132
|
+
return { success: false, message: found.error };
|
|
133
|
+
const task = found.task;
|
|
134
|
+
task.claimed_by = null;
|
|
135
|
+
task.claimed_at = null;
|
|
136
|
+
task.pending_at = null;
|
|
137
|
+
task.blocked_by = reason;
|
|
138
|
+
writeTasks(project, tasks);
|
|
139
|
+
return { success: true, message: `Task blocked: ${reason}`, task_id: task.id };
|
|
140
|
+
}
|
|
141
|
+
function pendingTask(taskText, project, taskId = null) {
|
|
142
|
+
const tasks = readTasks(project);
|
|
143
|
+
if (tasks.length === 0 && !fs.existsSync(getTasksPath(project))) {
|
|
144
|
+
return { success: false, message: `TASKS.yaml not found for project ${project}` };
|
|
145
|
+
}
|
|
146
|
+
const found = findTask(tasks, taskText, taskId);
|
|
147
|
+
if ('error' in found)
|
|
148
|
+
return { success: false, message: found.error };
|
|
149
|
+
const task = found.task;
|
|
150
|
+
if (task.status === 'pending')
|
|
151
|
+
return { success: true, message: 'Task is already pending (idempotent)', task_id: task.id };
|
|
152
|
+
if (task.status === 'done')
|
|
153
|
+
return { success: false, message: 'Cannot mark a completed task as pending' };
|
|
154
|
+
const today = todayISO();
|
|
155
|
+
task.status = 'pending';
|
|
156
|
+
task.claimed_by = null;
|
|
157
|
+
task.claimed_at = null;
|
|
158
|
+
task.blocked_by = null;
|
|
159
|
+
task.pending_at = today;
|
|
160
|
+
writeTasks(project, tasks);
|
|
161
|
+
return { success: true, message: `Task marked pending on ${today}`, task_id: task.id };
|
|
162
|
+
}
|
|
163
|
+
function unblockTask(taskText, project, taskId = null) {
|
|
164
|
+
const tasks = readTasks(project);
|
|
165
|
+
if (tasks.length === 0 && !fs.existsSync(getTasksPath(project))) {
|
|
166
|
+
return { success: false, message: `TASKS.yaml not found for project ${project}` };
|
|
167
|
+
}
|
|
168
|
+
const found = findTask(tasks, taskText, taskId);
|
|
169
|
+
if ('error' in found)
|
|
170
|
+
return { success: false, message: found.error };
|
|
171
|
+
const task = found.task;
|
|
172
|
+
task.blocked_by = null;
|
|
173
|
+
writeTasks(project, tasks);
|
|
174
|
+
return { success: true, message: 'Task unblocked', task_id: task.id };
|
|
175
|
+
}
|
|
176
|
+
export { approveTask, blockTask, claimTask, clearApprovalTask, pauseTask, pendingTask, requestApprovalTask, resumeTask, unblockTask, unclaimTask, };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface FileChange {
|
|
2
|
+
file_path: string;
|
|
3
|
+
device?: string;
|
|
4
|
+
mode: 'net' | 'degraded' | 'no-diff';
|
|
5
|
+
unifiedDiff: string;
|
|
6
|
+
}
|
|
7
|
+
/** Read modified file paths from session-activity JSONL for a given session ID.
|
|
8
|
+
* Collects both edit_file and write_file events, deduplicates, returns unique paths. */
|
|
9
|
+
export declare function getModifiedFilesFromSession(sessionId: string | null | undefined): string[];
|
|
10
|
+
/** Compute net unified diffs for every (device, file_path) touched in a session.
|
|
11
|
+
* Returns one entry per file, ordered by first-touch time. */
|
|
12
|
+
export declare function getSessionFileChanges(sessionId: string | null | undefined): FileChange[];
|
|
13
|
+
/** Render FileChange[] as markdown with fenced ```diff blocks per file. Empty when changes is empty. */
|
|
14
|
+
export declare function renderModifiedFilesWithDiff(changes: FileChange[]): string;
|
|
15
|
+
/** Read the artifact file content for a thread */
|
|
16
|
+
export declare function readArtifact(threadId: string): string | null;
|
|
17
|
+
/** Remove the workspace directory for a thread */
|
|
18
|
+
export declare function cleanupWorkspace(threadId: string): void;
|