@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,176 @@
|
|
|
1
|
+
// Prompt assembly and agent slot config resolution.
|
|
2
|
+
// input: template-loader, artifact-io, thread-store, thread-types
|
|
3
|
+
// output: buildStepPrompt / resolveSystemVars / resolveAgentSlotConfig / resolveTemplateAgents / formatEndpoint / pickStepTemplate
|
|
4
|
+
import { threadStore } from '../../store/thread-repo.js';
|
|
5
|
+
import { getAgent, resolveFileRef } from './template-loader.js';
|
|
6
|
+
import { getModifiedFilesFromSession, getSessionFileChanges, renderModifiedFilesWithDiff } from './artifact-io.js';
|
|
7
|
+
import { getDefaultAgent } from '../agents/index.js';
|
|
8
|
+
import { loadUserContext } from '../memory/user-context.js';
|
|
9
|
+
/** Resolve the `__active__` agent ref placeholder to the currently active default agent
|
|
10
|
+
* (set by `!agent`). Falls back to `'main'` when no default is configured. Other names
|
|
11
|
+
* pass through unchanged. */
|
|
12
|
+
export function resolveActiveAgentName(name) {
|
|
13
|
+
return name === '__active__' ? (getDefaultAgent() || 'main') : name;
|
|
14
|
+
}
|
|
15
|
+
// --- System variable resolution ---
|
|
16
|
+
// System variables are resolved at step execution time (not config load time).
|
|
17
|
+
function getSystemVars() {
|
|
18
|
+
const now = new Date();
|
|
19
|
+
return {
|
|
20
|
+
currentDateTime: now.toLocaleString('en-US', {
|
|
21
|
+
timeZone: 'Asia/Shanghai',
|
|
22
|
+
year: 'numeric', month: '2-digit', day: '2-digit',
|
|
23
|
+
hour: '2-digit', minute: '2-digit', second: '2-digit',
|
|
24
|
+
hour12: false,
|
|
25
|
+
}),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/** Replace {{systemVar}} placeholders with system variable values. Unknown vars are left as-is. */
|
|
29
|
+
export function resolveSystemVars(text) {
|
|
30
|
+
const vars = getSystemVars();
|
|
31
|
+
return text.replace(/\{\{(\w+)\}\}/g, (match, key) => key in vars ? vars[key] : match);
|
|
32
|
+
}
|
|
33
|
+
function collectRefOverrides(ref) {
|
|
34
|
+
if (typeof ref === 'string')
|
|
35
|
+
return {};
|
|
36
|
+
const o = {};
|
|
37
|
+
if (ref.promptTemplate != null)
|
|
38
|
+
o.promptTemplate = resolveFileRef('promptTemplate', ref.promptTemplate) ?? ref.promptTemplate;
|
|
39
|
+
if (ref.directive != null)
|
|
40
|
+
o.directive = resolveFileRef('directive', ref.directive) ?? ref.directive;
|
|
41
|
+
if (ref.systemPrompt != null)
|
|
42
|
+
o.systemPrompt = resolveFileRef('systemPrompt', ref.systemPrompt) ?? ref.systemPrompt;
|
|
43
|
+
if (ref.persistSession != null)
|
|
44
|
+
o.persistSession = ref.persistSession;
|
|
45
|
+
if (ref.claudeAgent != null)
|
|
46
|
+
o.claudeAgent = ref.claudeAgent;
|
|
47
|
+
if (ref.outputStyle != null)
|
|
48
|
+
o.outputStyle = ref.outputStyle;
|
|
49
|
+
if (ref.tools != null)
|
|
50
|
+
o.tools = ref.tools;
|
|
51
|
+
if (ref.pluginDirs != null)
|
|
52
|
+
o.pluginDirs = ref.pluginDirs;
|
|
53
|
+
return o;
|
|
54
|
+
}
|
|
55
|
+
/** Resolve a TemplateAgentRef to a full AgentSlotConfig by merging agent definition with optional overrides. */
|
|
56
|
+
export function resolveAgentSlotConfig(ref) {
|
|
57
|
+
const rawName = typeof ref === 'string' ? ref : ref.ref;
|
|
58
|
+
const agentName = resolveActiveAgentName(rawName);
|
|
59
|
+
const agentDef = getAgent(agentName);
|
|
60
|
+
if (!agentDef)
|
|
61
|
+
return null;
|
|
62
|
+
const overrides = collectRefOverrides(ref);
|
|
63
|
+
return {
|
|
64
|
+
slotId: agentName,
|
|
65
|
+
profile: agentDef.profile,
|
|
66
|
+
persistSession: overrides.persistSession ?? agentDef.persistSession,
|
|
67
|
+
directive: overrides.directive ?? agentDef.directive,
|
|
68
|
+
systemPrompt: overrides.systemPrompt ?? agentDef.systemPrompt,
|
|
69
|
+
promptTemplate: overrides.promptTemplate ?? agentDef.promptTemplate,
|
|
70
|
+
claudeAgent: overrides.claudeAgent ?? agentDef.claudeAgent,
|
|
71
|
+
outputStyle: overrides.outputStyle ?? agentDef.outputStyle,
|
|
72
|
+
tools: overrides.tools ?? agentDef.tools,
|
|
73
|
+
pluginDirs: overrides.pluginDirs ?? agentDef.pluginDirs,
|
|
74
|
+
stages: agentDef.stages,
|
|
75
|
+
entryStage: agentDef.entryStage,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/** Resolve a single agent name to AgentSlotConfig (for ad-hoc threads) */
|
|
79
|
+
export function resolveAgentSlotConfigByName(agentName) {
|
|
80
|
+
return resolveAgentSlotConfig(agentName);
|
|
81
|
+
}
|
|
82
|
+
/** Resolve all agent refs in a template to AgentSlotConfigs */
|
|
83
|
+
export function resolveTemplateAgents(template) {
|
|
84
|
+
const configs = [];
|
|
85
|
+
for (const ref of template.agents) {
|
|
86
|
+
const config = resolveAgentSlotConfig(ref);
|
|
87
|
+
if (config)
|
|
88
|
+
configs.push(config);
|
|
89
|
+
}
|
|
90
|
+
return configs;
|
|
91
|
+
}
|
|
92
|
+
/** Render an `(agent, stage)` pair as the canonical endpoint string used for iterationCounts keys
|
|
93
|
+
* and transition-rule matching. Stages that are null render as bare agent names. */
|
|
94
|
+
export function formatEndpoint(agent, stage) {
|
|
95
|
+
return stage ? `${agent}:${stage}` : agent;
|
|
96
|
+
}
|
|
97
|
+
/** Pick the prompt template for this step. For stage-aware agents, use `stages[stage]`;
|
|
98
|
+
* otherwise fall back to the agent-level `promptTemplate` (single-stage legacy path). */
|
|
99
|
+
export function pickStepTemplate(agentConfig, stage) {
|
|
100
|
+
if (stage && agentConfig.stages && agentConfig.stages[stage]) {
|
|
101
|
+
const s = agentConfig.stages[stage];
|
|
102
|
+
return { template: s.promptTemplate, continuesSession: s.continuesSession === true };
|
|
103
|
+
}
|
|
104
|
+
return { template: agentConfig.promptTemplate || '{{input}}', continuesSession: false };
|
|
105
|
+
}
|
|
106
|
+
/** System-level protocol preamble injected into every step prompt of threads that own a workspace artifact. */
|
|
107
|
+
export const THREAD_PROTOCOL_PREAMBLE = [
|
|
108
|
+
'[Cortex Thread Protocol]',
|
|
109
|
+
'You are executing inside a Cortex thread. If the task cannot be completed (missing dependencies,',
|
|
110
|
+
'contradictory requirements, or repeated unrecoverable failures), append `[ABORT: <reason>]` to the',
|
|
111
|
+
'artifact to terminate the thread — terminal state `aborted`, distinct from `failed`. Use this only',
|
|
112
|
+
'when truly blocked: normal retries, minor issues, or disagreements with the plan are not abort cases.',
|
|
113
|
+
].join('\n');
|
|
114
|
+
// --- Prompt assembly ---
|
|
115
|
+
function buildPromptVars(thread, lastStep) {
|
|
116
|
+
const prevModifiedFiles = getModifiedFilesFromSession(lastStep?.sessionId);
|
|
117
|
+
const prevFileChanges = getSessionFileChanges(lastStep?.sessionId);
|
|
118
|
+
return {
|
|
119
|
+
input: thread.userMessage,
|
|
120
|
+
artifactPath: thread.artifactPath,
|
|
121
|
+
previousOutput: lastStep?.output || '',
|
|
122
|
+
modifiedFiles: prevModifiedFiles.length > 0 ? prevModifiedFiles.map(f => `- ${f}`).join('\n') : '',
|
|
123
|
+
modifiedFilesWithDiff: renderModifiedFilesWithDiff(prevFileChanges),
|
|
124
|
+
...getSystemVars(),
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function applyPromptTemplate(templateStr, vars) {
|
|
128
|
+
const withBlocks = templateStr.replace(/\{\{#if (\w+)\}\}([\s\S]*?)\{\{\/if\}\}/g, (_, varName, content) => vars[varName] ? content : '');
|
|
129
|
+
return withBlocks.replace(/\{\{(\w+)\}\}/g, (_, key) => vars[key] || '');
|
|
130
|
+
}
|
|
131
|
+
export function buildStepPrompt(threadId, agentConfig, stage = null, isUserInitiated) {
|
|
132
|
+
const thread = threadStore.get(threadId);
|
|
133
|
+
if (!thread)
|
|
134
|
+
return '';
|
|
135
|
+
const { template: templateStr, continuesSession } = pickStepTemplate(agentConfig, stage);
|
|
136
|
+
const lastStep = [...thread.steps].reverse().find(s => s.output != null);
|
|
137
|
+
const vars = buildPromptVars(thread, lastStep);
|
|
138
|
+
let prompt = applyPromptTemplate(templateStr, vars);
|
|
139
|
+
const slot = thread.agents[agentConfig.slotId];
|
|
140
|
+
const resumingPersistentSession = agentConfig.persistSession && !!slot?.sessionId;
|
|
141
|
+
const incremental = continuesSession && resumingPersistentSession;
|
|
142
|
+
if (!incremental && !thread.templateName && lastStep?.output && !templateStr.includes('{{previousOutput}}')) {
|
|
143
|
+
prompt = `Previous agent output:\n\n${lastStep.output}\n\n---\n\n${prompt}`;
|
|
144
|
+
}
|
|
145
|
+
if (!resumingPersistentSession) {
|
|
146
|
+
const prefixes = [];
|
|
147
|
+
const userCtx = loadUserContext(thread);
|
|
148
|
+
if (userCtx)
|
|
149
|
+
prefixes.push(userCtx);
|
|
150
|
+
if (agentConfig.directive)
|
|
151
|
+
prefixes.push(resolveSystemVars(agentConfig.directive));
|
|
152
|
+
if (thread.artifactPath && !isUserInitiated)
|
|
153
|
+
prefixes.push(THREAD_PROTOCOL_PREAMBLE);
|
|
154
|
+
if (prefixes.length > 0)
|
|
155
|
+
prompt = prefixes.join('\n\n') + '\n\n' + prompt;
|
|
156
|
+
}
|
|
157
|
+
// Phase 6: include buffered user messages in the next step's prompt.
|
|
158
|
+
// Messages accumulated while the previous step was executing are appended
|
|
159
|
+
// so the agent sees the user's reply.
|
|
160
|
+
if (thread.metadata?.pendingMessages?.length) {
|
|
161
|
+
// Take the last 10 messages to cap prompt growth
|
|
162
|
+
const messages = thread.metadata.pendingMessages.slice(-10);
|
|
163
|
+
const count = thread.metadata.pendingMessages.length;
|
|
164
|
+
const dropped = count > 10 ? count - 10 : 0;
|
|
165
|
+
const header = dropped > 0
|
|
166
|
+
? `User replies (last ${messages.length}, ${dropped} earlier dropped):`
|
|
167
|
+
: `User replies (${count} buffered):`;
|
|
168
|
+
prompt += `\n\n---\n\n${header}\n\n${messages.join('\n\n')}`;
|
|
169
|
+
// Clear buffer synchronously on in-memory object
|
|
170
|
+
thread.metadata.pendingMessages = [];
|
|
171
|
+
// Fire-and-forget persist — see thread-executor.ts bufferUserMessage for
|
|
172
|
+
// rationale on why set() is used instead of mutate() here.
|
|
173
|
+
threadStore.set(thread).catch(() => { });
|
|
174
|
+
}
|
|
175
|
+
return prompt.trim();
|
|
176
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { VirtualMessage } from '../../platform/index.js';
|
|
2
|
+
import type { RunningExecution } from '../../core/running-executions.js';
|
|
3
|
+
import type { ThreadRecord, AgentSlotId, AgentSlotConfig, ThreadTemplate, RunThreadOptions } from '../../core/types/thread-types.js';
|
|
4
|
+
interface ThreadRunResult {
|
|
5
|
+
thread: ThreadRecord;
|
|
6
|
+
/** Final output from the last completed step (for Slack display) */
|
|
7
|
+
finalOutput: string | null;
|
|
8
|
+
/** Aggregated cost across all steps */
|
|
9
|
+
totalCostUsd: number;
|
|
10
|
+
/** Total number of turns across all steps */
|
|
11
|
+
totalNumTurns: number;
|
|
12
|
+
/** Was this a default (single-agent) thread? */
|
|
13
|
+
isDefault: boolean;
|
|
14
|
+
/** The result object from the last agent call (for backward compat with handleAgentSuccess) */
|
|
15
|
+
lastAgentResult: any;
|
|
16
|
+
/** The execution ID from the last completed step — used by handleAgentSuccess in the wrapper. */
|
|
17
|
+
executionId: string | null;
|
|
18
|
+
}
|
|
19
|
+
/** Outer-scope state shared across the whole runThread() lifecycle. */
|
|
20
|
+
interface ThreadContext {
|
|
21
|
+
thread: ThreadRecord;
|
|
22
|
+
isDefault: boolean;
|
|
23
|
+
template: ThreadTemplate | null;
|
|
24
|
+
meta: ThreadRecord['metadata'];
|
|
25
|
+
vm: VirtualMessage | null;
|
|
26
|
+
lastAgentResult: any;
|
|
27
|
+
totalNumTurns: number;
|
|
28
|
+
}
|
|
29
|
+
/** Per-step config built once by buildStepConfig — fully populated, no placeholders. */
|
|
30
|
+
interface StepContext {
|
|
31
|
+
agentSlotId: AgentSlotId;
|
|
32
|
+
agentConfig: AgentSlotConfig;
|
|
33
|
+
isFirstStep: boolean;
|
|
34
|
+
multiAgent: boolean;
|
|
35
|
+
/** Stage this step runs. Null for single-stage agents (no `stages` map declared). */
|
|
36
|
+
stage: string | null;
|
|
37
|
+
prompt: string;
|
|
38
|
+
sessionId: string | null;
|
|
39
|
+
sessionKey: string | null;
|
|
40
|
+
sessionName: string;
|
|
41
|
+
profileName: string;
|
|
42
|
+
execution: {
|
|
43
|
+
id: string;
|
|
44
|
+
[k: string]: any;
|
|
45
|
+
};
|
|
46
|
+
/** Always set in buildStepConfig — never an empty placeholder. */
|
|
47
|
+
stepStartTime: string;
|
|
48
|
+
}
|
|
49
|
+
/** Per-step callbacks resolved from opts/vm by setupStepCallbacks. */
|
|
50
|
+
interface StepCallbacks {
|
|
51
|
+
onAssistantMessage: ((text: string) => void) | null | undefined;
|
|
52
|
+
onProgress: ((progress: any) => void) | null;
|
|
53
|
+
onToolUse: ((name: string, input: any) => void) | null;
|
|
54
|
+
}
|
|
55
|
+
type StepInfo = Pick<StepContext, 'agentSlotId' | 'agentConfig' | 'isFirstStep' | 'multiAgent' | 'stage'>;
|
|
56
|
+
/** Validate thread, load template/metadata, init the aggregating VirtualMessage. */
|
|
57
|
+
declare function initThreadContext(threadId: string, opts: RunThreadOptions): ThreadContext;
|
|
58
|
+
/** Resolve next step, post boundary notifications, update the status message.
|
|
59
|
+
* Returns null if the loop should break (cancelled, no next step). */
|
|
60
|
+
declare function resolveAndNotifyStep(threadId: string, ctx: ThreadContext, opts: RunThreadOptions): Promise<StepInfo | null>;
|
|
61
|
+
/** Build prompt, resolve session config, profile, register execution, generate session name + start time.
|
|
62
|
+
* Returns a fully-populated StepContext — no placeholder fields. */
|
|
63
|
+
declare function buildStepConfig(threadId: string, stepInfo: StepInfo, ctx: ThreadContext, opts: RunThreadOptions): Promise<StepContext>;
|
|
64
|
+
/** Resolve onAssistantMessage/onProgress callbacks and mark slot as running.
|
|
65
|
+
* Returns the callbacks instead of mutating the StepContext. */
|
|
66
|
+
declare function setupStepCallbacks(threadId: string, stepCtx: StepContext, ctx: ThreadContext, opts: RunThreadOptions): StepCallbacks;
|
|
67
|
+
/** Run the agent, manage handle, await result; fail execution + rethrow on error.
|
|
68
|
+
* Returns the agent result. */
|
|
69
|
+
declare function executeAndAwaitAgent(threadId: string, stepCtx: StepContext, callbacks: StepCallbacks, ctx: ThreadContext, opts: RunThreadOptions): Promise<any>;
|
|
70
|
+
/** Record step result, register session, finalize execution; update aggregate counters. */
|
|
71
|
+
declare function recordStepOutcome(threadId: string, stepCtx: StepContext, result: any, ctx: ThreadContext, opts: RunThreadOptions): Promise<void>;
|
|
72
|
+
/** Decide whether the loop continues; run onTransition hook when transitioning.
|
|
73
|
+
* Returns false to break the loop. */
|
|
74
|
+
declare function evaluateAndTransition(threadId: string, stepCtx: StepContext, ctx: ThreadContext, opts: RunThreadOptions): Promise<boolean>;
|
|
75
|
+
/** Read final artifact, flush VM, build the run result. */
|
|
76
|
+
declare function finalizeThread(threadId: string, ctx: ThreadContext): Promise<ThreadRunResult>;
|
|
77
|
+
declare function runThread(threadId: string, opts: RunThreadOptions): Promise<ThreadRunResult>;
|
|
78
|
+
declare function continueThread(threadId: string, userMessage: string, opts: RunThreadOptions): Promise<ThreadRunResult>;
|
|
79
|
+
declare function buildThreadSummary(result: ThreadRunResult): string;
|
|
80
|
+
declare function cancelActiveThread(channel: string): boolean;
|
|
81
|
+
declare function getActiveHandle(channel: string): RunningExecution | null;
|
|
82
|
+
export { runThread, continueThread, buildThreadSummary, cancelActiveThread, getActiveHandle, initThreadContext, resolveAndNotifyStep, buildStepConfig, setupStepCallbacks, executeAndAwaitAgent, recordStepOutcome, evaluateAndTransition, finalizeThread, };
|
|
83
|
+
export type { ThreadRunResult, ThreadContext, StepContext, StepCallbacks, StepInfo };
|