@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,423 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { parse as yamlParse, stringify as yamlStringify } from 'yaml';
|
|
4
|
+
import { PROJECTS_DIR, CONTEXT_DIR } from './paths.js';
|
|
5
|
+
import { listProjectDirs } from './utils.js';
|
|
6
|
+
// ── YAML key mapping (kebab-case ↔ snake_case) ──
|
|
7
|
+
const YAML_TO_TS = {
|
|
8
|
+
'done-when': 'done_when',
|
|
9
|
+
'depends-on': 'depends_on',
|
|
10
|
+
'gpu-count': 'gpu_count',
|
|
11
|
+
'blocked-by': 'blocked_by',
|
|
12
|
+
'claimed-by': 'claimed_by',
|
|
13
|
+
'claimed-at': 'claimed_at',
|
|
14
|
+
'approval-needed': 'approval_needed',
|
|
15
|
+
'approved-at': 'approved_at',
|
|
16
|
+
'not-before': 'not_before',
|
|
17
|
+
'completed-at': 'completed_at',
|
|
18
|
+
'completed-note': 'completed_note',
|
|
19
|
+
'pending-at': 'pending_at',
|
|
20
|
+
};
|
|
21
|
+
const TS_TO_YAML = Object.fromEntries(Object.entries(YAML_TO_TS).map(([k, v]) => [v, k]));
|
|
22
|
+
function yamlKeyToTs(key) {
|
|
23
|
+
return YAML_TO_TS[key] ?? key;
|
|
24
|
+
}
|
|
25
|
+
function tsKeyToYaml(key) {
|
|
26
|
+
return TS_TO_YAML[key] ?? key;
|
|
27
|
+
}
|
|
28
|
+
// ── Constants ──
|
|
29
|
+
const OVERVIEW_PRIORITY_MAP = { '主线': 3, '高': 3, '中': 2, '低': 1 };
|
|
30
|
+
const PRIORITY_ORDER = { high: 3, medium: 2, low: 1 };
|
|
31
|
+
const VALID_STATUSES = new Set([
|
|
32
|
+
'actionable', 'open', 'blocked', 'in-progress', 'paused',
|
|
33
|
+
'pending', 'completed', 'approval-needed', 'approved',
|
|
34
|
+
]);
|
|
35
|
+
const TASK_DEFAULTS = {
|
|
36
|
+
depends_on: [],
|
|
37
|
+
gpu: null,
|
|
38
|
+
gpu_count: 1,
|
|
39
|
+
blocked_by: null,
|
|
40
|
+
claimed_by: null,
|
|
41
|
+
claimed_at: null,
|
|
42
|
+
paused: false,
|
|
43
|
+
approval_needed: false,
|
|
44
|
+
approved_at: null,
|
|
45
|
+
not_before: null,
|
|
46
|
+
completed_at: null,
|
|
47
|
+
completed_note: null,
|
|
48
|
+
pending_at: null,
|
|
49
|
+
};
|
|
50
|
+
// ── Parsing ──
|
|
51
|
+
function rawToTask(raw, project) {
|
|
52
|
+
const mapped = {};
|
|
53
|
+
for (const [key, value] of Object.entries(raw)) {
|
|
54
|
+
mapped[yamlKeyToTs(key)] = value;
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
id: String(mapped.id ?? ''),
|
|
58
|
+
text: String(mapped.text ?? ''),
|
|
59
|
+
why: String(mapped.why ?? ''),
|
|
60
|
+
done_when: String(mapped.done_when ?? ''),
|
|
61
|
+
priority: PRIORITY_ORDER[mapped.priority] ? mapped.priority : 'medium',
|
|
62
|
+
status: (mapped.status === 'done' || mapped.status === 'pending') ? mapped.status : 'open',
|
|
63
|
+
template: String(mapped.template ?? ''),
|
|
64
|
+
plan: String(mapped.plan ?? ''),
|
|
65
|
+
project,
|
|
66
|
+
depends_on: Array.isArray(mapped.depends_on) ? mapped.depends_on.map(String) : [],
|
|
67
|
+
gpu: mapped.gpu != null ? String(mapped.gpu) : null,
|
|
68
|
+
gpu_count: typeof mapped.gpu_count === 'number' ? mapped.gpu_count : 1,
|
|
69
|
+
blocked_by: mapped.blocked_by != null ? String(mapped.blocked_by) : null,
|
|
70
|
+
claimed_by: mapped.claimed_by != null ? String(mapped.claimed_by) : null,
|
|
71
|
+
claimed_at: mapped.claimed_at != null ? String(mapped.claimed_at) : null,
|
|
72
|
+
paused: Boolean(mapped.paused),
|
|
73
|
+
approval_needed: Boolean(mapped.approval_needed),
|
|
74
|
+
approved_at: mapped.approved_at != null ? String(mapped.approved_at) : null,
|
|
75
|
+
not_before: mapped.not_before != null ? String(mapped.not_before) : null,
|
|
76
|
+
completed_at: mapped.completed_at != null ? String(mapped.completed_at) : null,
|
|
77
|
+
completed_note: mapped.completed_note != null ? String(mapped.completed_note) : null,
|
|
78
|
+
pending_at: mapped.pending_at != null ? String(mapped.pending_at) : null,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function parseTasksFile(content, project) {
|
|
82
|
+
if (!content.trim())
|
|
83
|
+
return [];
|
|
84
|
+
let parsed;
|
|
85
|
+
try {
|
|
86
|
+
parsed = yamlParse(content);
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
return [];
|
|
90
|
+
}
|
|
91
|
+
if (!parsed || !Array.isArray(parsed.tasks))
|
|
92
|
+
return [];
|
|
93
|
+
return parsed.tasks.map((raw) => rawToTask(raw, project));
|
|
94
|
+
}
|
|
95
|
+
function parseTasksFileWithLock(content, project) {
|
|
96
|
+
if (!content.trim())
|
|
97
|
+
return { tasks: [], lock: null };
|
|
98
|
+
let parsed;
|
|
99
|
+
try {
|
|
100
|
+
parsed = yamlParse(content);
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
return { tasks: [], lock: null };
|
|
104
|
+
}
|
|
105
|
+
if (!parsed || typeof parsed !== 'object')
|
|
106
|
+
return { tasks: [], lock: null };
|
|
107
|
+
let lock = null;
|
|
108
|
+
if (parsed.lock && typeof parsed.lock === 'object') {
|
|
109
|
+
const l = parsed.lock;
|
|
110
|
+
if (typeof l.owner === 'string' && typeof l.acquired_at === 'string' && typeof l.expires_at === 'string') {
|
|
111
|
+
lock = {
|
|
112
|
+
owner: l.owner,
|
|
113
|
+
acquired_at: l.acquired_at,
|
|
114
|
+
expires_at: l.expires_at,
|
|
115
|
+
note: typeof l.note === 'string' ? l.note : undefined,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const tasks = Array.isArray(parsed.tasks) ? parsed.tasks.map((raw) => rawToTask(raw, project)) : [];
|
|
120
|
+
return { tasks, lock };
|
|
121
|
+
}
|
|
122
|
+
// ── Serialization ──
|
|
123
|
+
const REQUIRED_KEYS = ['id', 'text', 'why', 'done_when', 'priority', 'status', 'template', 'plan'];
|
|
124
|
+
const OPTIONAL_KEY_ORDER = [
|
|
125
|
+
'depends_on', 'gpu', 'gpu_count', 'blocked_by', 'claimed_by', 'claimed_at',
|
|
126
|
+
'paused', 'approval_needed', 'approved_at', 'not_before', 'pending_at', 'completed_at', 'completed_note',
|
|
127
|
+
];
|
|
128
|
+
function isDefault(key, value) {
|
|
129
|
+
const def = TASK_DEFAULTS[key];
|
|
130
|
+
if (def === undefined)
|
|
131
|
+
return false;
|
|
132
|
+
if (Array.isArray(def))
|
|
133
|
+
return Array.isArray(value) && value.length === 0;
|
|
134
|
+
return value === def;
|
|
135
|
+
}
|
|
136
|
+
function taskToYamlObj(task) {
|
|
137
|
+
const obj = {};
|
|
138
|
+
for (const key of REQUIRED_KEYS) {
|
|
139
|
+
obj[tsKeyToYaml(key)] = task[key];
|
|
140
|
+
}
|
|
141
|
+
for (const key of OPTIONAL_KEY_ORDER) {
|
|
142
|
+
const value = task[key];
|
|
143
|
+
if (!isDefault(key, value)) {
|
|
144
|
+
obj[tsKeyToYaml(key)] = value;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return obj;
|
|
148
|
+
}
|
|
149
|
+
function serializeTasksFile(tasks) {
|
|
150
|
+
if (tasks.length === 0)
|
|
151
|
+
return 'tasks: []\n';
|
|
152
|
+
const objs = tasks.map(taskToYamlObj);
|
|
153
|
+
return yamlStringify({ tasks: objs }, { lineWidth: 0 });
|
|
154
|
+
}
|
|
155
|
+
function serializeTasksFileWithLock({ tasks, lock }) {
|
|
156
|
+
if (tasks.length === 0 && !lock)
|
|
157
|
+
return 'tasks: []\n';
|
|
158
|
+
const objs = tasks.map(taskToYamlObj);
|
|
159
|
+
if (lock) {
|
|
160
|
+
return yamlStringify({ lock, tasks: objs }, { lineWidth: 0 });
|
|
161
|
+
}
|
|
162
|
+
return yamlStringify({ tasks: objs }, { lineWidth: 0 });
|
|
163
|
+
}
|
|
164
|
+
// ── Scanning ──
|
|
165
|
+
function getTasksYamlPath(project) {
|
|
166
|
+
return path.join(PROJECTS_DIR, project, 'TASKS.yaml');
|
|
167
|
+
}
|
|
168
|
+
function scanAllTasks(project = null) {
|
|
169
|
+
if (!fs.existsSync(PROJECTS_DIR))
|
|
170
|
+
return [];
|
|
171
|
+
const tasks = [];
|
|
172
|
+
for (const projectName of listProjectDirs()) {
|
|
173
|
+
if (project && projectName !== project)
|
|
174
|
+
continue;
|
|
175
|
+
const tasksPath = getTasksYamlPath(projectName);
|
|
176
|
+
if (!fs.existsSync(tasksPath))
|
|
177
|
+
continue;
|
|
178
|
+
tasks.push(...parseTasksFile(fs.readFileSync(tasksPath, 'utf8'), projectName));
|
|
179
|
+
}
|
|
180
|
+
return tasks;
|
|
181
|
+
}
|
|
182
|
+
// ── Query helpers ──
|
|
183
|
+
function parseProjectPriorities() {
|
|
184
|
+
const overviewPath = path.join(CONTEXT_DIR, 'OVERVIEW.md');
|
|
185
|
+
if (!fs.existsSync(overviewPath))
|
|
186
|
+
return {};
|
|
187
|
+
const lines = fs.readFileSync(overviewPath, 'utf8').split('\n');
|
|
188
|
+
const priorities = {};
|
|
189
|
+
let headerFound = false;
|
|
190
|
+
for (const line of lines) {
|
|
191
|
+
const stripped = line.trim();
|
|
192
|
+
if (!stripped.startsWith('|')) {
|
|
193
|
+
if (headerFound)
|
|
194
|
+
break;
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
const columns = stripped.split('|').slice(1, -1).map((col) => col.trim());
|
|
198
|
+
if (columns.length < 3)
|
|
199
|
+
continue;
|
|
200
|
+
if (!headerFound) {
|
|
201
|
+
headerFound = columns[0].toLowerCase() === 'project';
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
if (columns[0].startsWith('-'))
|
|
205
|
+
continue;
|
|
206
|
+
priorities[columns[0]] = OVERVIEW_PRIORITY_MAP[columns[2].replace(/\*\*/g, '')] || 0;
|
|
207
|
+
}
|
|
208
|
+
return priorities;
|
|
209
|
+
}
|
|
210
|
+
function completedHashSet(tasks) {
|
|
211
|
+
return new Set(tasks.filter((t) => t.status === 'done' && t.id).map((t) => t.id));
|
|
212
|
+
}
|
|
213
|
+
function isActionable(task, completedHashes = null) {
|
|
214
|
+
const hasUnmetDeps = completedHashes
|
|
215
|
+
? task.depends_on.some((dep) => !completedHashes.has(dep))
|
|
216
|
+
: task.depends_on.length > 0;
|
|
217
|
+
const today = new Date().toISOString().slice(0, 10);
|
|
218
|
+
return !(task.status === 'done'
|
|
219
|
+
|| task.status === 'pending'
|
|
220
|
+
|| task.paused
|
|
221
|
+
|| task.claimed_by
|
|
222
|
+
|| task.blocked_by
|
|
223
|
+
|| (task.approval_needed && !task.approved_at)
|
|
224
|
+
|| hasUnmetDeps
|
|
225
|
+
|| (task.not_before && task.not_before > today));
|
|
226
|
+
}
|
|
227
|
+
function taskSortKey(task, projectPriorities) {
|
|
228
|
+
return [
|
|
229
|
+
projectPriorities[task.project] || 0,
|
|
230
|
+
task.done_when ? 1 : 0,
|
|
231
|
+
PRIORITY_ORDER[task.priority] || 0,
|
|
232
|
+
];
|
|
233
|
+
}
|
|
234
|
+
function compareSortKey(left, right) {
|
|
235
|
+
for (let i = 0; i < left.length; i++) {
|
|
236
|
+
if (left[i] !== right[i])
|
|
237
|
+
return right[i] - left[i];
|
|
238
|
+
}
|
|
239
|
+
return 0;
|
|
240
|
+
}
|
|
241
|
+
function scanAvailableTasks() {
|
|
242
|
+
const projectPriorities = parseProjectPriorities();
|
|
243
|
+
const allTasks = scanAllTasks();
|
|
244
|
+
const completed = completedHashSet(allTasks);
|
|
245
|
+
return allTasks
|
|
246
|
+
.filter((task) => isActionable(task, completed))
|
|
247
|
+
.sort((a, b) => compareSortKey(taskSortKey(a, projectPriorities), taskSortKey(b, projectPriorities)));
|
|
248
|
+
}
|
|
249
|
+
function getTaskStats() {
|
|
250
|
+
return getTaskStatsFromTasks(scanAllTasks());
|
|
251
|
+
}
|
|
252
|
+
const TASK_STATUS_CHECKS = [
|
|
253
|
+
['blocked', (t) => t.blocked_by],
|
|
254
|
+
['in-progress', (t) => t.claimed_by],
|
|
255
|
+
['paused', (t) => t.paused],
|
|
256
|
+
['approval-needed', (t) => t.approval_needed],
|
|
257
|
+
['approved', (t) => t.approved_at],
|
|
258
|
+
];
|
|
259
|
+
function taskStatuses(task, completedHashes = null) {
|
|
260
|
+
const statuses = new Set(task.status === 'done' ? ['completed'] : ['open']);
|
|
261
|
+
if (isActionable(task, completedHashes))
|
|
262
|
+
statuses.add('actionable');
|
|
263
|
+
for (const [name, check] of TASK_STATUS_CHECKS) {
|
|
264
|
+
if (check(task))
|
|
265
|
+
statuses.add(name);
|
|
266
|
+
}
|
|
267
|
+
return statuses;
|
|
268
|
+
}
|
|
269
|
+
function taskTags(task) {
|
|
270
|
+
const tags = new Set();
|
|
271
|
+
if (task.paused)
|
|
272
|
+
tags.add('paused');
|
|
273
|
+
if (task.approval_needed)
|
|
274
|
+
tags.add('approval-needed');
|
|
275
|
+
if (task.gpu) {
|
|
276
|
+
tags.add('gpu');
|
|
277
|
+
tags.add(`gpu:${task.gpu}`);
|
|
278
|
+
}
|
|
279
|
+
if (task.template)
|
|
280
|
+
tags.add(`template:${task.template}`);
|
|
281
|
+
return tags;
|
|
282
|
+
}
|
|
283
|
+
function filterTasks(tasks, args, completedHashes = null) {
|
|
284
|
+
let filtered = tasks;
|
|
285
|
+
if (args.project)
|
|
286
|
+
filtered = filtered.filter((t) => t.project === args.project);
|
|
287
|
+
if (args.taskId)
|
|
288
|
+
filtered = filtered.filter((t) => t.id === args.taskId);
|
|
289
|
+
if (args.status)
|
|
290
|
+
filtered = filtered.filter((t) => taskStatuses(t, completedHashes).has(args.status));
|
|
291
|
+
if (args.priority)
|
|
292
|
+
filtered = filtered.filter((t) => t.priority === args.priority);
|
|
293
|
+
if (args.text) {
|
|
294
|
+
const needle = args.text.toLowerCase();
|
|
295
|
+
filtered = filtered.filter((t) => t.text.toLowerCase().includes(needle));
|
|
296
|
+
}
|
|
297
|
+
if (args.tag && args.tag.length > 0)
|
|
298
|
+
filtered = filtered.filter((t) => args.tag.every((tag) => taskTags(t).has(tag)));
|
|
299
|
+
if (args.hasDeps)
|
|
300
|
+
filtered = filtered.filter((t) => t.depends_on.length > 0);
|
|
301
|
+
if (args.noDeps)
|
|
302
|
+
filtered = filtered.filter((t) => t.depends_on.length === 0);
|
|
303
|
+
return filtered;
|
|
304
|
+
}
|
|
305
|
+
// ── Stats ──
|
|
306
|
+
function computeProjectStats(projectTasks, completed) {
|
|
307
|
+
return {
|
|
308
|
+
actionable: projectTasks.filter((t) => isActionable(t, completed)).length,
|
|
309
|
+
blocked: projectTasks.filter((t) => t.blocked_by).length,
|
|
310
|
+
in_progress: projectTasks.filter((t) => t.claimed_by).length,
|
|
311
|
+
paused: projectTasks.filter((t) => t.paused).length,
|
|
312
|
+
completed: projectTasks.filter((t) => t.status === 'done').length,
|
|
313
|
+
total: projectTasks.length,
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
function getTaskStatsFromTasks(tasks) {
|
|
317
|
+
const completed = completedHashSet(tasks);
|
|
318
|
+
const stats = {
|
|
319
|
+
projects: {},
|
|
320
|
+
total: { actionable: 0, blocked: 0, in_progress: 0, paused: 0, completed: 0, total: 0 },
|
|
321
|
+
};
|
|
322
|
+
for (const project of [...new Set(tasks.map((t) => t.project))].sort()) {
|
|
323
|
+
const projectTasks = tasks.filter((t) => t.project === project);
|
|
324
|
+
const projectStats = computeProjectStats(projectTasks, completed);
|
|
325
|
+
stats.projects[project] = projectStats;
|
|
326
|
+
for (const key of Object.keys(stats.total))
|
|
327
|
+
stats.total[key] += projectStats[key];
|
|
328
|
+
}
|
|
329
|
+
return stats;
|
|
330
|
+
}
|
|
331
|
+
// ── Display ──
|
|
332
|
+
function taskDisplayTags(task) {
|
|
333
|
+
const tags = [];
|
|
334
|
+
if (task.claimed_by)
|
|
335
|
+
tags.push(`in-progress:${task.claimed_at || task.claimed_by}`);
|
|
336
|
+
if (task.paused)
|
|
337
|
+
tags.push('paused');
|
|
338
|
+
if (task.blocked_by)
|
|
339
|
+
tags.push(`blocked:${task.blocked_by}`);
|
|
340
|
+
if (task.depends_on.length > 0)
|
|
341
|
+
tags.push(`depends-on:${task.depends_on.join(',')}`);
|
|
342
|
+
if (task.gpu)
|
|
343
|
+
tags.push(`gpu:${task.gpu}`);
|
|
344
|
+
if (task.not_before)
|
|
345
|
+
tags.push(`not-before:${task.not_before}`);
|
|
346
|
+
return tags;
|
|
347
|
+
}
|
|
348
|
+
function formatTaskVerbose(task, index, tags) {
|
|
349
|
+
const idText = task.id ? ` #${task.id}` : '';
|
|
350
|
+
const tagText = tags.length > 0 ? ` [${tags.join(', ')}]` : '';
|
|
351
|
+
const lines = [`\n${index + 1}.${idText} [${task.project}] ${task.text}${tagText}`];
|
|
352
|
+
lines.push(` Priority: ${task.priority}`);
|
|
353
|
+
if (task.done_when)
|
|
354
|
+
lines.push(` Done when: ${task.done_when}`);
|
|
355
|
+
if (task.why)
|
|
356
|
+
lines.push(` Why: ${task.why}`);
|
|
357
|
+
return lines;
|
|
358
|
+
}
|
|
359
|
+
function formatTaskCompact(task, tags) {
|
|
360
|
+
const status = task.status === 'done' ? '[x]' : '[ ]';
|
|
361
|
+
const idText = task.id ? ` #${task.id}` : '';
|
|
362
|
+
const compactTags = tags.length > 0 ? ` (${tags.join(', ')})` : '';
|
|
363
|
+
return `${status}${idText} [${task.project}] ${task.text} [P:${task.priority}]${compactTags}`;
|
|
364
|
+
}
|
|
365
|
+
function printTaskListToString(tasks, actionableHeader = false) {
|
|
366
|
+
const out = [];
|
|
367
|
+
if (actionableHeader) {
|
|
368
|
+
out.push('Actionable Tasks (sorted by priority)');
|
|
369
|
+
out.push('='.repeat(50));
|
|
370
|
+
}
|
|
371
|
+
for (const [index, task] of tasks.entries()) {
|
|
372
|
+
const tags = taskDisplayTags(task);
|
|
373
|
+
if (actionableHeader)
|
|
374
|
+
out.push(...formatTaskVerbose(task, index, tags));
|
|
375
|
+
else
|
|
376
|
+
out.push(formatTaskCompact(task, tags));
|
|
377
|
+
}
|
|
378
|
+
return out.join('\n');
|
|
379
|
+
}
|
|
380
|
+
function printStatsText(stats) {
|
|
381
|
+
const lines = ['Task Supply Statistics', '='.repeat(40)];
|
|
382
|
+
for (const [project, projectStats] of Object.entries(stats.projects)) {
|
|
383
|
+
const s = projectStats;
|
|
384
|
+
lines.push(`\n${project}:`);
|
|
385
|
+
lines.push(` Actionable: ${s.actionable}`);
|
|
386
|
+
lines.push(` Blocked: ${s.blocked}`);
|
|
387
|
+
lines.push(` In-progress:${s.in_progress}`);
|
|
388
|
+
lines.push(` Paused: ${s.paused}`);
|
|
389
|
+
lines.push(` Completed: ${s.completed}`);
|
|
390
|
+
lines.push(` Total: ${s.total}`);
|
|
391
|
+
}
|
|
392
|
+
lines.push(`\nTotal actionable: ${stats.total.actionable}`);
|
|
393
|
+
return lines.join('\n');
|
|
394
|
+
}
|
|
395
|
+
function showPayload(task, tasks) {
|
|
396
|
+
const byId = Object.fromEntries(tasks.filter((t) => t.id).map((t) => [t.id, t]));
|
|
397
|
+
const completed = completedHashSet(tasks);
|
|
398
|
+
const depMap = {};
|
|
399
|
+
for (const t of tasks) {
|
|
400
|
+
for (const dep of t.depends_on) {
|
|
401
|
+
if (!depMap[dep])
|
|
402
|
+
depMap[dep] = [];
|
|
403
|
+
depMap[dep].push(t);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
const dependents = (depMap[task.id] || []).map((d) => d.id).filter(Boolean);
|
|
407
|
+
const dependsOn = task.depends_on.filter((d) => byId[d]).map((d) => byId[d]);
|
|
408
|
+
return { task, actionable: isActionable(task, completed), dependents, depends_on: dependsOn };
|
|
409
|
+
}
|
|
410
|
+
function depsPayload(task, tasks) {
|
|
411
|
+
const payload = showPayload(task, tasks);
|
|
412
|
+
const depMap = {};
|
|
413
|
+
for (const t of tasks) {
|
|
414
|
+
for (const dep of t.depends_on) {
|
|
415
|
+
if (!depMap[dep])
|
|
416
|
+
depMap[dep] = [];
|
|
417
|
+
depMap[dep].push(t);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
payload.dependents = depMap[task.id] || [];
|
|
421
|
+
return payload;
|
|
422
|
+
}
|
|
423
|
+
export { PRIORITY_ORDER, VALID_STATUSES, completedHashSet, depsPayload, filterTasks, getTaskStats, getTaskStatsFromTasks, getTasksYamlPath, isActionable, parseTasksFile, parseTasksFileWithLock, printStatsText, printTaskListToString, rawToTask, scanAllTasks, scanAvailableTasks, serializeTasksFile, serializeTasksFileWithLock, showPayload, taskToYamlObj, taskStatuses, taskTags, };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface AskUserQuestionInfo {
|
|
2
|
+
toolUseId: string | null;
|
|
3
|
+
questions: string[];
|
|
4
|
+
sessionId: string;
|
|
5
|
+
}
|
|
6
|
+
export interface AgentResult {
|
|
7
|
+
sessionId: string | null;
|
|
8
|
+
total_cost_usd: number | null;
|
|
9
|
+
num_turns: number | null;
|
|
10
|
+
rateLimited: boolean;
|
|
11
|
+
rateLimitMessage: string | null;
|
|
12
|
+
planFilePath: string | null;
|
|
13
|
+
enteredPlanMode: boolean;
|
|
14
|
+
exitedPlanMode: boolean;
|
|
15
|
+
askUserQuestions?: AskUserQuestionInfo[];
|
|
16
|
+
finalOutput: string | null;
|
|
17
|
+
codexRateLimits?: Record<string, unknown>;
|
|
18
|
+
codexRawLogPath?: string | null;
|
|
19
|
+
}
|
|
20
|
+
export interface AgentHandle {
|
|
21
|
+
promise: Promise<AgentResult>;
|
|
22
|
+
kill: () => boolean;
|
|
23
|
+
sessionId?: string | null;
|
|
24
|
+
/** Opaque reference to the underlying agent process. Used by PI backend for sendExtensionUiResponse. */
|
|
25
|
+
agentProcess?: unknown;
|
|
26
|
+
}
|
|
27
|
+
export interface AgentProgress {
|
|
28
|
+
num_turns: number | null;
|
|
29
|
+
total_cost_usd: number | null;
|
|
30
|
+
duration_ms: number | null;
|
|
31
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// input: nothing (leaf type-only module)
|
|
2
|
+
// output: AgentResult / AgentHandle / AgentProgress types
|
|
3
|
+
// pos: Shared type definitions for agent run results and progress
|
|
4
|
+
// >>> If I am updated, update my header comment and the parent folder's CORTEX.md <<<
|
|
5
|
+
export {};
|