@cortex-agent/server 2026.10.2 → 2026.10.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -31
- package/defaults/AGENTS.md +3 -3
- package/defaults/config/{thread-templates/agents/direct.json → environments/main.json} +2 -2
- package/defaults/context/AGENTS.md +0 -2
- package/defaults/context/projects/AGENTS.md +0 -2
- package/defaults/context/user/AGENTS.md +1 -1
- package/defaults/hooks/cortex-hook-api.mjs +1 -3
- package/defaults/hooks/new-session-hook.mjs +2 -3
- package/defaults/hooks/status-md-guard.mjs +5 -5
- package/defaults/plugins/cortex-system/.claude-plugin/plugin.json +2 -2
- package/defaults/plugins/cortex-system/plugin.json +2 -2
- package/defaults/plugins/cortex-system/skills/project-init/SKILL.md +4 -4
- package/defaults/plugins/cortex-system/skills/schedule/SKILL.md +11 -13
- package/defaults/plugins/cortex-system/skills/user-learn/SKILL.md +1 -1
- package/defaults/prompts/systemPrompts/web-opus-4-6.md +2 -2
- package/defaults/prompts/systemPrompts/web-sonnet-4-6.md +2 -2
- package/defaults/rules/issues-md.md +2 -2
- package/defaults/rules/meta-conventions.md +1 -2
- package/defaults/rules/mission-md.md +1 -1
- package/defaults/rules/overview-md.md +1 -1
- package/defaults/rules/roadmap-md.md +1 -1
- package/defaults/rules/status-md.md +4 -4
- package/dist/agent-adapter/claude/adapter.d.ts +6 -1
- package/dist/agent-adapter/claude/adapter.js +15 -4
- package/dist/agent-adapter/claude/compact-window.d.ts +11 -3
- package/dist/agent-adapter/claude/compact-window.js +12 -3
- package/dist/agent-adapter/claude/defaults.d.ts +0 -1
- package/dist/agent-adapter/claude/defaults.js +0 -1
- package/dist/agent-adapter/claude/event-translator.d.ts +2 -2
- package/dist/agent-adapter/claude/event-translator.js +2 -1
- package/dist/agent-adapter/claude/hooks-builder.d.ts +0 -5
- package/dist/agent-adapter/claude/hooks-builder.js +0 -13
- package/dist/agent-adapter/claude/spawn-args.d.ts +5 -12
- package/dist/agent-adapter/claude/spawn-args.js +45 -38
- package/dist/agent-adapter/claude/turn-machine.d.ts +2 -2
- package/dist/agent-adapter/claude/turn-machine.js +6 -3
- package/dist/agent-adapter/continuation-phase.js +2 -1
- package/dist/agent-adapter/normalize/event-types.d.ts +4 -1
- package/dist/agent-adapter/normalize/tool-result-images.d.ts +11 -0
- package/dist/agent-adapter/normalize/tool-result-images.js +32 -0
- package/dist/agent-adapter/pi/child-events.js +3 -0
- package/dist/agent-adapter/pi/child-runner.d.ts +1 -2
- package/dist/agent-adapter/pi/child-runner.js +6 -6
- package/dist/agent-adapter/pi/child-session.d.ts +1 -1
- package/dist/agent-adapter/pi/event-parser.d.ts +13 -2
- package/dist/agent-adapter/pi/event-parser.js +38 -11
- package/dist/agent-adapter/pi/mcp-bridge-logic.d.ts +0 -1
- package/dist/agent-adapter/pi/mcp-bridge-logic.js +0 -3
- package/dist/agent-adapter/pi/mcp-bridge.js +4 -4
- package/dist/agent-adapter/pi/pi-session.d.ts +4 -2
- package/dist/agent-adapter/pi/pi-session.js +18 -9
- package/dist/agent-adapter/pi/runtime-settings.d.ts +7 -0
- package/dist/agent-adapter/pi/runtime-settings.js +23 -0
- package/dist/agent-adapter/pi/runtime.d.ts +2 -3
- package/dist/agent-adapter/pi/session-options.d.ts +4 -1
- package/dist/agent-adapter/pi/session-options.js +13 -21
- package/dist/agent-adapter/pi/session-support.d.ts +2 -0
- package/dist/agent-adapter/run-events.d.ts +3 -1
- package/dist/agent-adapter/types.d.ts +6 -12
- package/dist/agent-adapter/types.js +2 -4
- package/dist/core/agents/roles.d.ts +1 -1
- package/dist/core/agents/subagent/attribution.js +1 -0
- package/dist/core/agents/subagent/catalog.d.ts +8 -0
- package/dist/core/agents/subagent/catalog.js +21 -10
- package/dist/core/agents/subagent/types.d.ts +4 -1
- package/dist/core/config-generator.d.ts +0 -6
- package/dist/core/config-generator.js +1 -35
- package/dist/core/icons.d.ts +33 -33
- package/dist/core/locales/en.d.ts +863 -1030
- package/dist/core/locales/slices/commands.d.ts +282 -349
- package/dist/core/locales/slices/commands.js +20 -160
- package/dist/core/locales/slices/init.d.ts +152 -152
- package/dist/core/locales/slices/interactions.d.ts +44 -45
- package/dist/core/locales/slices/interactions.js +0 -4
- package/dist/core/locales/slices/lang.d.ts +5 -5
- package/dist/core/locales/slices/notices.d.ts +75 -118
- package/dist/core/locales/slices/notices.js +13 -99
- package/dist/core/locales/slices/scheduling.d.ts +31 -31
- package/dist/core/locales/slices/startup.d.ts +5 -5
- package/dist/core/locales/slices/status.d.ts +43 -43
- package/dist/core/locales/slices/tui.d.ts +91 -114
- package/dist/core/locales/slices/tui.js +0 -46
- package/dist/core/locales/slices/uiextra.d.ts +41 -61
- package/dist/core/locales/slices/uiextra.js +11 -51
- package/dist/core/locales/slices/uimsg.d.ts +86 -99
- package/dist/core/locales/slices/uimsg.js +6 -32
- package/dist/core/mcp-bundles.d.ts +1 -1
- package/dist/core/mcp-bundles.js +7 -5
- package/dist/core/mcp-tool-gate.js +8 -5
- package/dist/core/platform-settings-spec.d.ts +3 -3
- package/dist/core/production-benchmark-evidence.d.ts +1 -9
- package/dist/core/production-benchmark-evidence.js +0 -22
- package/dist/core/rebuild-progress.d.ts +3 -2
- package/dist/core/rebuild-progress.js +5 -2
- package/dist/core/run-registry.d.ts +7 -28
- package/dist/core/run-registry.js +6 -51
- package/dist/core/session-retention-liveness.d.ts +0 -2
- package/dist/core/session-retention-liveness.js +0 -13
- package/dist/core/session-state.d.ts +1 -2
- package/dist/core/session-state.js +2 -3
- package/dist/core/settings-spec.d.ts +19 -60
- package/dist/core/settings-spec.js +30 -60
- package/dist/core/status-format.d.ts +0 -14
- package/dist/core/status-format.js +2 -24
- package/dist/core/types/agent-types.d.ts +26 -9
- package/dist/core/types/benchmark-types.d.ts +17 -0
- package/dist/core/types/environment-types.d.ts +64 -0
- package/dist/core/types/environment-types.js +1 -0
- package/dist/core/utils.d.ts +14 -4
- package/dist/core/utils.js +32 -6
- package/dist/domain/agents/agent-switch.js +2 -4
- package/dist/domain/agents/config.js +1 -1
- package/dist/domain/agents/environments/entities.d.ts +49 -0
- package/dist/domain/agents/environments/entities.js +94 -0
- package/dist/domain/agents/environments/file-refs.d.ts +19 -0
- package/dist/domain/agents/environments/file-refs.js +48 -0
- package/dist/domain/agents/environments/index.d.ts +6 -0
- package/dist/domain/agents/environments/index.js +8 -0
- package/dist/domain/agents/environments/paths.d.ts +7 -0
- package/dist/domain/agents/environments/paths.js +9 -0
- package/dist/domain/{threads/template-resolver.js → agents/environments/prompt-includes.js} +2 -2
- package/dist/domain/agents/environments/registry.d.ts +17 -0
- package/dist/domain/agents/environments/registry.js +159 -0
- package/dist/domain/agents/environments/schema.d.ts +68 -0
- package/dist/domain/agents/environments/schema.js +111 -0
- package/dist/domain/agents/environments/schema.parity.d.ts +1 -0
- package/dist/domain/agents/environments/schema.parity.js +7 -0
- package/dist/domain/agents/environments/slot-config.d.ts +14 -0
- package/dist/domain/agents/environments/slot-config.js +78 -0
- package/dist/domain/agents/model-selection.d.ts +3 -0
- package/dist/domain/agents/model-selection.js +1 -1
- package/dist/domain/agents/subagent/runner.js +3 -2
- package/dist/domain/benchmark/accounting-reconciliation.d.ts +1 -1
- package/dist/domain/benchmark/atif.d.ts +4 -4
- package/dist/domain/benchmark/atif.js +7 -7
- package/dist/domain/benchmark/attempt-record.d.ts +16 -55
- package/dist/domain/benchmark/attempt-record.js +3 -17
- package/dist/domain/benchmark/composite-manifest.d.ts +4 -4
- package/dist/domain/benchmark/composite-manifest.js +5 -11
- package/dist/domain/benchmark/journal.d.ts +6 -4
- package/dist/domain/benchmark/journal.js +6 -4
- package/dist/domain/benchmark/manifest-contract.d.ts +1 -1
- package/dist/domain/benchmark/production-attempt-identity.d.ts +11 -16
- package/dist/domain/benchmark/production-attempt-identity.js +31 -94
- package/dist/domain/benchmark/production-attempt-journal.js +14 -7
- package/dist/domain/benchmark/production-evidence-journal.js +8 -6
- package/dist/domain/benchmark/production-evidence-projection.d.ts +1 -11
- package/dist/domain/benchmark/production-evidence-projection.js +32 -143
- package/dist/domain/benchmark/session-evidence.d.ts +6 -0
- package/dist/domain/benchmark/session-evidence.js +27 -0
- package/dist/domain/costs/cost-tracker.d.ts +1 -7
- package/dist/domain/costs/cost-tracker.js +0 -4
- package/dist/domain/costs/resume-registry.d.ts +9 -20
- package/dist/domain/costs/resume-registry.js +24 -39
- package/dist/domain/executions/registry.d.ts +3 -18
- package/dist/domain/executions/registry.js +4 -158
- package/dist/domain/mcp/bundled-server.js +20 -27
- package/dist/domain/mcp/tools/commission-tools.js +0 -1
- package/dist/domain/mcp/tools/context.d.ts +2 -9
- package/dist/domain/mcp/tools/context.js +2 -7
- package/dist/domain/mcp/tools/executions.js +6 -19
- package/dist/domain/mcp/tools/interaction-ask.js +0 -1
- package/dist/domain/mcp/tools/interaction-plan.d.ts +0 -1
- package/dist/domain/mcp/tools/interaction-plan.js +0 -2
- package/dist/domain/mcp/tools/{task-ops.d.ts → remote-ops.d.ts} +1 -1
- package/dist/domain/mcp/tools/{task-ops.js → remote-ops.js} +1 -1
- package/dist/domain/mcp/tools/schedule.d.ts +3 -3
- package/dist/domain/mcp/tools/schedule.js +10 -32
- package/dist/domain/mcp/tools/subagent.d.ts +4 -0
- package/dist/domain/mcp/tools/subagent.js +10 -8
- package/dist/domain/mcp/tools/ui-view.js +3 -2
- package/dist/domain/mcp/tools/waitpoint.js +2 -3
- package/dist/domain/mcp/tools/{thread-ops.d.ts → workers.d.ts} +1 -1
- package/dist/domain/mcp/tools/workers.js +84 -0
- package/dist/domain/memory/user-context.d.ts +2 -3
- package/dist/domain/memory/user-context.js +2 -3
- package/dist/domain/monitor/gpu-monitor.js +1 -1
- package/dist/domain/pi-providers/custom-provider-model.d.ts +1 -1
- package/dist/domain/projects/project-store.d.ts +1 -2
- package/dist/domain/projects/project-store.js +1 -9
- package/dist/domain/remote/client-manager.d.ts +1 -1
- package/dist/domain/remote/client-manager.js +1 -1
- package/dist/domain/remote/client-remove.d.ts +1 -1
- package/dist/domain/remote/machine-registry.d.ts +54 -0
- package/dist/domain/{tasks/dispatch-utils.js → remote/machine-registry.js} +1 -61
- package/dist/domain/runs/attempt.js +3 -8
- package/dist/domain/runs/builders.d.ts +2 -3
- package/dist/domain/runs/builders.js +2 -3
- package/dist/domain/runs/engine-spec.js +3 -10
- package/dist/domain/runs/fallback.d.ts +1 -3
- package/dist/domain/runs/fallback.js +1 -3
- package/dist/domain/runs/observers/resume-recorder.d.ts +0 -15
- package/dist/domain/runs/observers/resume-recorder.js +0 -17
- package/dist/domain/runs/prompt.d.ts +23 -8
- package/dist/domain/runs/prompt.js +31 -5
- package/dist/domain/runs/request.d.ts +6 -15
- package/dist/domain/runs/run.js +0 -2
- package/dist/domain/runs/service.js +0 -2
- package/dist/domain/runs/spec-loader.d.ts +4 -6
- package/dist/domain/runs/spec-loader.js +3 -5
- package/dist/domain/scheduling/builtin-job-migration.js +3 -3
- package/dist/domain/scheduling/builtin-jobs.js +0 -13
- package/dist/domain/scheduling/job-registry.d.ts +12 -27
- package/dist/domain/scheduling/job-registry.js +2 -3
- package/dist/domain/scheduling/jobs/scheduled-task.d.ts +18 -6
- package/dist/domain/scheduling/jobs/scheduled-task.js +66 -125
- package/dist/domain/scheduling/run-guards.d.ts +6 -0
- package/dist/domain/scheduling/run-guards.js +18 -0
- package/dist/domain/scheduling/runner.d.ts +0 -1
- package/dist/domain/scheduling/runner.js +0 -1
- package/dist/domain/scheduling/schedule-cli.js +1 -1
- package/dist/domain/scheduling/scheduler.d.ts +0 -4
- package/dist/domain/scheduling/scheduler.js +2 -6
- package/dist/domain/sessions/session-hooks.d.ts +2 -2
- package/dist/domain/sessions/session-lifecycle.d.ts +23 -9
- package/dist/domain/sessions/session-lifecycle.js +27 -15
- package/dist/domain/sessions/session-retention.d.ts +8 -0
- package/dist/domain/sessions/session-retention.js +139 -34
- package/dist/domain/sessions/team.d.ts +18 -0
- package/dist/domain/sessions/team.js +21 -0
- package/dist/domain/system/install-cli.js +5 -5
- package/dist/domain/system/rebuild-hold.d.ts +1 -1
- package/dist/domain/system/server-update-check.js +2 -1
- package/dist/domain/ui-service/app-router.d.ts +41 -154
- package/dist/domain/ui-service/app-router.js +9 -30
- package/dist/domain/ui-service/input-schemas.d.ts +64 -205
- package/dist/domain/ui-service/input-schemas.js +26 -71
- package/dist/domain/ui-service/mutate/environments.d.ts +23 -0
- package/dist/domain/ui-service/mutate/environments.js +51 -0
- package/dist/domain/ui-service/mutate/plugin-packages.js +3 -9
- package/dist/domain/ui-service/mutate/plugins.js +7 -109
- package/dist/domain/ui-service/mutate/schedules.js +1 -2
- package/dist/domain/ui-service/plugins-shared.d.ts +0 -3
- package/dist/domain/ui-service/plugins-shared.js +0 -14
- package/dist/domain/ui-service/query/config.js +10 -13
- package/dist/domain/ui-service/query/environments.d.ts +12 -0
- package/dist/domain/ui-service/query/environments.js +72 -0
- package/dist/domain/ui-service/query/executions.js +1 -1
- package/dist/domain/ui-service/query/hooks.d.ts +1 -1
- package/dist/domain/ui-service/query/hooks.js +13 -24
- package/dist/domain/ui-service/query/memory.js +1 -1
- package/dist/domain/ui-service/query/plugins.js +6 -82
- package/dist/domain/ui-service/query/schedules.js +0 -1
- package/dist/domain/ui-service/query/sessions.js +23 -5
- package/dist/domain/ui-service/query/system.js +0 -1
- package/dist/domain/ui-service/query-input-schemas.d.ts +5 -26
- package/dist/domain/ui-service/query-input-schemas.js +0 -18
- package/dist/domain/ui-service/types.d.ts +68 -330
- package/dist/domain/ui-service/ui-service.js +7 -23
- package/dist/domain/waitpoints/notices.d.ts +1 -1
- package/dist/domain/waitpoints/notices.js +1 -1
- package/dist/entry/app.js +70 -146
- package/dist/entry/cli-help.js +0 -1
- package/dist/entry/cli.js +1 -6
- package/dist/entry/daemon.d.ts +27 -23
- package/dist/entry/daemon.js +61 -49
- package/dist/entry/fast-install.d.ts +13 -2
- package/dist/entry/fast-install.js +43 -11
- package/dist/entry/hook-cli.d.ts +0 -1
- package/dist/entry/hook-cli.js +20 -49
- package/dist/entry/init.js +8 -11
- package/dist/entry/local-ui.d.ts +1 -1
- package/dist/entry/platform-connect.d.ts +23 -0
- package/dist/entry/platform-connect.js +94 -0
- package/dist/entry/production-evidence-export-cli.js +0 -2
- package/dist/events/event-logger.js +1 -0
- package/dist/events/event-types.d.ts +13 -62
- package/dist/hooks/cortex-hook-api.mjs +1 -3
- package/dist/hooks/new-session-hook.mjs +2 -3
- package/dist/hooks/status-md-guard.mjs +5 -5
- package/dist/orchestration/agent-runner.d.ts +3 -0
- package/dist/orchestration/agent-runner.js +21 -19
- package/dist/orchestration/agent-view-send.d.ts +7 -0
- package/dist/orchestration/agent-view-send.js +12 -0
- package/dist/orchestration/benchmark-session-webhook.d.ts +19 -0
- package/dist/orchestration/benchmark-session-webhook.js +130 -0
- package/dist/orchestration/conversation-request.d.ts +39 -1
- package/dist/orchestration/conversation-request.js +71 -15
- package/dist/orchestration/interactions/answer-question.d.ts +16 -0
- package/dist/orchestration/interactions/answer-question.js +38 -0
- package/dist/orchestration/interactions/ask-user-question.d.ts +2 -3
- package/dist/orchestration/interactions/ask-user-question.js +1 -3
- package/dist/orchestration/interactions/ask-user-resume.d.ts +1 -3
- package/dist/orchestration/interactions/ask-user-resume.js +2 -14
- package/dist/orchestration/interactions/interaction-handlers.js +6 -35
- package/dist/orchestration/interactions/plan-response.d.ts +2 -1
- package/dist/orchestration/interactions/plan-response.js +2 -2
- package/dist/orchestration/orchestrator.d.ts +1 -7
- package/dist/orchestration/orchestrator.js +2 -11
- package/dist/orchestration/resume-dispatcher.d.ts +0 -22
- package/dist/orchestration/resume-dispatcher.js +8 -72
- package/dist/orchestration/routing/commands/cancel.d.ts +1 -7
- package/dist/orchestration/routing/commands/cancel.js +17 -37
- package/dist/orchestration/routing/commands/channel.js +1 -1
- package/dist/orchestration/routing/commands/device.js +1 -1
- package/dist/orchestration/routing/commands/index.d.ts +0 -7
- package/dist/orchestration/routing/commands/index.js +1 -9
- package/dist/orchestration/routing/commands/mode.js +7 -7
- package/dist/orchestration/routing/commands/nvtop.js +1 -1
- package/dist/orchestration/routing/commands/sendfile.js +1 -1
- package/dist/orchestration/routing/commands/status.js +8 -14
- package/dist/orchestration/routing/hook-bridge-subscribers.d.ts +4 -1
- package/dist/orchestration/routing/hook-bridge-subscribers.js +19 -12
- package/dist/orchestration/routing/hook-bridge.d.ts +3 -3
- package/dist/orchestration/routing/hook-bridge.js +9 -9
- package/dist/orchestration/routing/message-router.js +2 -25
- package/dist/orchestration/routing/webhook.js +24 -350
- package/dist/orchestration/session-events.d.ts +13 -0
- package/dist/orchestration/session-events.js +8 -0
- package/dist/orchestration/session-gateway.d.ts +4 -2
- package/dist/orchestration/session-gateway.js +17 -12
- package/dist/orchestration/session-retention-controller.d.ts +5 -2
- package/dist/orchestration/session-retention-controller.js +7 -4
- package/dist/orchestration/status-helpers.d.ts +1 -4
- package/dist/orchestration/status-helpers.js +3 -5
- package/dist/orchestration/team-delivery.d.ts +64 -0
- package/dist/orchestration/team-delivery.js +224 -0
- package/dist/orchestration/team-state.d.ts +48 -0
- package/dist/orchestration/team-state.js +146 -0
- package/dist/orchestration/team-webhook.d.ts +48 -0
- package/dist/orchestration/team-webhook.js +295 -0
- package/dist/orchestration/transcript-sink.d.ts +18 -4
- package/dist/orchestration/transcript-sink.js +31 -3
- package/dist/orchestration/turn/background-hold.d.ts +2 -2
- package/dist/orchestration/turn/background-hold.js +1 -1
- package/dist/orchestration/turn/hold-render-platform.d.ts +2 -2
- package/dist/orchestration/turn/hold-render-platform.js +2 -2
- package/dist/orchestration/turn/hold-render-web.d.ts +3 -3
- package/dist/orchestration/turn/hold-render-web.js +2 -2
- package/dist/orchestration/turn/terminal.d.ts +5 -2
- package/dist/orchestration/turn/terminal.js +11 -10
- package/dist/orchestration/turn/turn.d.ts +13 -1
- package/dist/orchestration/turn/turn.js +58 -15
- package/dist/platform/adapters/composite-adapter.d.ts +2 -0
- package/dist/platform/adapters/composite-adapter.js +7 -4
- package/dist/platform/adapters/feishu.d.ts +6 -0
- package/dist/platform/adapters/feishu.js +50 -4
- package/dist/platform/index.d.ts +1 -1
- package/dist/platform/index.js +1 -1
- package/dist/platform/tui/protocol.d.ts +2 -2
- package/dist/platform/types.d.ts +3 -3
- package/dist/platform/types.js +3 -3
- package/dist/store/conversation-history-reader.js +17 -3
- package/dist/store/conversation-history-repo.d.ts +18 -4
- package/dist/store/conversation-history-repo.js +14 -5
- package/dist/store/conversation-ledger-repo.js +1 -16
- package/dist/store/execution-repo.d.ts +17 -40
- package/dist/store/execution-repo.js +46 -116
- package/dist/store/hook-registry.d.ts +4 -16
- package/dist/store/hook-registry.js +5 -65
- package/dist/store/plugin-sync.js +4 -0
- package/dist/store/profile-repo.js +1 -1
- package/dist/store/prompt-migration-replacements.d.ts +0 -1
- package/dist/store/prompt-migration-replacements.js +0 -49
- package/dist/store/retention-candidate-repo.d.ts +2 -0
- package/dist/store/retention-candidate-repo.js +5 -0
- package/dist/store/schedule-repo.d.ts +3 -15
- package/dist/store/schedule-repo.js +18 -4
- package/dist/store/session-registry-journal.d.ts +15 -0
- package/dist/store/session-registry-journal.js +68 -10
- package/dist/store/session-registry-repo.d.ts +13 -0
- package/dist/store/session-registry-repo.js +74 -21
- package/dist/store/session-totals.d.ts +3 -3
- package/dist/store/session-totals.js +3 -3
- package/dist/store/team-outbox-repo.d.ts +20 -0
- package/dist/store/team-outbox-repo.js +39 -0
- package/dist/store/tool-image-files.d.ts +12 -0
- package/dist/store/tool-image-files.js +40 -0
- package/dist/store/version-migrations.d.ts +31 -8
- package/dist/store/version-migrations.js +307 -87
- package/dist/store/waitpoint-repo.d.ts +0 -2
- package/dist/tui/App.js +1 -1
- package/dist/tui/components/Dashboard.js +0 -8
- package/dist/tui/components/InputBox.js +1 -7
- package/dist/tui/components/StatusLine.js +1 -1
- package/dist/tui/hooks/useDashboardData.d.ts +1 -1
- package/dist/tui/hooks/useDashboardData.js +0 -4
- package/dist/tui/hooks/useNotifications.d.ts +1 -1
- package/dist/tui/slash-commands.js +1 -4
- package/package.json +4 -5
- package/web/dist/assets/index-BU_kY1rV.js +449 -0
- package/web/dist/assets/{index-zvUjPRjt.js → index-CDjsmgsy.js} +1 -1
- package/web/dist/assets/index-DzPDbcY1.css +1 -0
- package/web/dist/index.html +2 -2
- package/defaults/config/hooks/02-tasks-yaml-guard.json +0 -11
- package/defaults/config/hooks/11-task-status-check.json +0 -14
- package/defaults/config/thread-templates/agents/coder-reviewer.json +0 -17
- package/defaults/config/thread-templates/agents/coder.json +0 -17
- package/defaults/config/thread-templates/agents/direct-review.json +0 -14
- package/defaults/config/thread-templates/agents/direct-web.json +0 -14
- package/defaults/config/thread-templates/agents/director.json +0 -11
- package/defaults/config/thread-templates/agents/doc-reviewer.json +0 -13
- package/defaults/config/thread-templates/agents/doc-writer.json +0 -24
- package/defaults/config/thread-templates/agents/executor-reviewer.json +0 -13
- package/defaults/config/thread-templates/agents/executor.json +0 -24
- package/defaults/config/thread-templates/agents/main.json +0 -14
- package/defaults/config/thread-templates/agents/manager.json +0 -14
- package/defaults/config/thread-templates/agents/scheduler-main.json +0 -13
- package/defaults/config/thread-templates/shells/worker-review.json +0 -12
- package/defaults/config/thread-templates/templates/coder-review.json +0 -20
- package/defaults/config/thread-templates/templates/default.json +0 -10
- package/defaults/config/thread-templates/templates/doc-review.json +0 -6
- package/defaults/config/thread-templates/templates/execute-review.json +0 -6
- package/defaults/config/thread-templates/templates/manager.json +0 -11
- package/defaults/config/thread-templates/templates/scheduler.json +0 -10
- package/defaults/hooks/task-status-check.mjs +0 -166
- package/defaults/hooks/tasks-yaml-guard.mjs +0 -225
- package/defaults/plugins/cortex-system/skills/task/SKILL.md +0 -547
- package/defaults/plugins/cortex-system/skills/thread/SKILL.md +0 -505
- package/defaults/prompts/directives/coder-reviewer.md +0 -7
- package/defaults/prompts/directives/coder.md +0 -7
- package/defaults/prompts/directives/director.md +0 -7
- package/defaults/prompts/directives/doc-reviewer.md +0 -6
- package/defaults/prompts/directives/doc-writer.md +0 -7
- package/defaults/prompts/directives/executor-reviewer.md +0 -6
- package/defaults/prompts/directives/executor.md +0 -7
- package/defaults/prompts/directives/manager.md +0 -24
- package/defaults/prompts/systemPrompts/coder.md +0 -10
- package/defaults/prompts/systemPrompts/worker.md +0 -10
- package/defaults/rules/task-system.md +0 -53
- package/dist/core/task-node.d.ts +0 -7
- package/dist/core/task-node.js +0 -21
- package/dist/core/task-parser.d.ts +0 -86
- package/dist/core/task-parser.js +0 -436
- package/dist/core/types/thread-types.d.ts +0 -506
- package/dist/domain/benchmark/production-evidence-topology.d.ts +0 -14
- package/dist/domain/benchmark/production-evidence-topology.js +0 -257
- package/dist/domain/mcp/tools/manager-qa.d.ts +0 -4
- package/dist/domain/mcp/tools/manager-qa.js +0 -63
- package/dist/domain/mcp/tools/task-monitor.d.ts +0 -3
- package/dist/domain/mcp/tools/task-monitor.js +0 -92
- package/dist/domain/mcp/tools/thread-ops.js +0 -73
- package/dist/domain/scheduling/jobs/register-thread-session.d.ts +0 -15
- package/dist/domain/scheduling/jobs/register-thread-session.js +0 -32
- package/dist/domain/scheduling/jobs/target-dispatch.d.ts +0 -30
- package/dist/domain/scheduling/jobs/target-dispatch.js +0 -33
- package/dist/domain/scheduling/jobs/task-archive.d.ts +0 -2
- package/dist/domain/scheduling/jobs/task-archive.js +0 -16
- package/dist/domain/scheduling/jobs/task-dispatch.d.ts +0 -12
- package/dist/domain/scheduling/jobs/task-dispatch.js +0 -402
- package/dist/domain/tasks/acceptance-ledger.d.ts +0 -39
- package/dist/domain/tasks/acceptance-ledger.js +0 -133
- package/dist/domain/tasks/archiver.d.ts +0 -10
- package/dist/domain/tasks/archiver.js +0 -133
- package/dist/domain/tasks/claim-recovery.d.ts +0 -9
- package/dist/domain/tasks/claim-recovery.js +0 -54
- package/dist/domain/tasks/dispatch-utils.d.ts +0 -117
- package/dist/domain/tasks/dispatcher.d.ts +0 -49
- package/dist/domain/tasks/dispatcher.js +0 -305
- package/dist/domain/tasks/lint.d.ts +0 -12
- package/dist/domain/tasks/lint.js +0 -130
- package/dist/domain/tasks/mutator.d.ts +0 -39
- package/dist/domain/tasks/mutator.js +0 -176
- package/dist/domain/tasks/production-topology-ledger.d.ts +0 -106
- package/dist/domain/tasks/production-topology-ledger.js +0 -161
- package/dist/domain/tasks/system/task-cli.d.ts +0 -7
- package/dist/domain/tasks/system/task-cli.js +0 -991
- package/dist/domain/tasks/system/task-completion.d.ts +0 -44
- package/dist/domain/tasks/system/task-completion.js +0 -262
- package/dist/domain/tasks/system/task-file-input.d.ts +0 -10
- package/dist/domain/tasks/system/task-file-input.js +0 -53
- package/dist/domain/tasks/system/task-id-utils.d.ts +0 -24
- package/dist/domain/tasks/system/task-id-utils.js +0 -90
- package/dist/domain/tasks/system/task-lifecycle-edit.d.ts +0 -40
- package/dist/domain/tasks/system/task-lifecycle-edit.js +0 -419
- package/dist/domain/tasks/system/task-lock.d.ts +0 -44
- package/dist/domain/tasks/system/task-lock.js +0 -137
- package/dist/domain/tasks/system/task-mutations.d.ts +0 -86
- package/dist/domain/tasks/system/task-mutations.js +0 -336
- package/dist/domain/tasks/system/task-state.d.ts +0 -140
- package/dist/domain/tasks/system/task-state.js +0 -287
- package/dist/domain/threads/artifact-io.d.ts +0 -4
- package/dist/domain/threads/artifact-io.js +0 -57
- package/dist/domain/threads/contract.d.ts +0 -17
- package/dist/domain/threads/contract.js +0 -54
- package/dist/domain/threads/evidence-context.d.ts +0 -2
- package/dist/domain/threads/evidence-context.js +0 -40
- package/dist/domain/threads/hook-runner.d.ts +0 -7
- package/dist/domain/threads/hook-runner.js +0 -237
- package/dist/domain/threads/index.d.ts +0 -7
- package/dist/domain/threads/index.js +0 -13
- package/dist/domain/threads/pending-user-inputs.d.ts +0 -3
- package/dist/domain/threads/pending-user-inputs.js +0 -33
- package/dist/domain/threads/prompt-builder.d.ts +0 -55
- package/dist/domain/threads/prompt-builder.js +0 -245
- package/dist/domain/threads/runner.d.ts +0 -150
- package/dist/domain/threads/runner.js +0 -832
- package/dist/domain/threads/shell-templates.d.ts +0 -9
- package/dist/domain/threads/shell-templates.js +0 -108
- package/dist/domain/threads/state-machine.d.ts +0 -96
- package/dist/domain/threads/state-machine.js +0 -646
- package/dist/domain/threads/template-loader.d.ts +0 -37
- package/dist/domain/threads/template-loader.js +0 -487
- package/dist/domain/threads/template-validate.d.ts +0 -287
- package/dist/domain/threads/template-validate.js +0 -575
- package/dist/domain/threads/template-validate.parity.d.ts +0 -1
- package/dist/domain/threads/template-validate.parity.js +0 -39
- package/dist/domain/threads/template-writer.d.ts +0 -57
- package/dist/domain/threads/template-writer.js +0 -126
- package/dist/domain/threads/thread-transcript.d.ts +0 -60
- package/dist/domain/threads/thread-transcript.js +0 -117
- package/dist/domain/threads/tree.d.ts +0 -46
- package/dist/domain/threads/tree.js +0 -196
- package/dist/domain/threads/utils.d.ts +0 -24
- package/dist/domain/threads/utils.js +0 -55
- package/dist/domain/ui-service/mutate/tasks.d.ts +0 -23
- package/dist/domain/ui-service/mutate/tasks.js +0 -58
- package/dist/domain/ui-service/mutate/thread-templates.d.ts +0 -4
- package/dist/domain/ui-service/mutate/thread-templates.js +0 -46
- package/dist/domain/ui-service/mutate/threads.d.ts +0 -4
- package/dist/domain/ui-service/mutate/threads.js +0 -19
- package/dist/domain/ui-service/query/task-verification.d.ts +0 -2
- package/dist/domain/ui-service/query/task-verification.js +0 -58
- package/dist/domain/ui-service/query/tasks.d.ts +0 -3
- package/dist/domain/ui-service/query/tasks.js +0 -73
- package/dist/domain/ui-service/query/thread-template-detail.d.ts +0 -2
- package/dist/domain/ui-service/query/thread-template-detail.js +0 -57
- package/dist/domain/ui-service/query/thread-templates.d.ts +0 -15
- package/dist/domain/ui-service/query/thread-templates.js +0 -79
- package/dist/domain/ui-service/query/threads.d.ts +0 -3
- package/dist/domain/ui-service/query/threads.js +0 -180
- package/dist/hooks/task-status-check.mjs +0 -166
- package/dist/hooks/tasks-yaml-guard.mjs +0 -225
- package/dist/orchestration/dispatch-reconciler.d.ts +0 -1
- package/dist/orchestration/dispatch-reconciler.js +0 -19
- package/dist/orchestration/human-answer-backstop.d.ts +0 -36
- package/dist/orchestration/human-answer-backstop.js +0 -69
- package/dist/orchestration/manager-qa.d.ts +0 -66
- package/dist/orchestration/manager-qa.js +0 -356
- package/dist/orchestration/routing/commands/dispatch.d.ts +0 -2
- package/dist/orchestration/routing/commands/dispatch.js +0 -48
- package/dist/orchestration/routing/commands/task.d.ts +0 -4
- package/dist/orchestration/routing/commands/task.js +0 -140
- package/dist/orchestration/routing/commands/thread-handlers.d.ts +0 -2
- package/dist/orchestration/routing/commands/thread-handlers.js +0 -152
- package/dist/orchestration/thread-callback.d.ts +0 -107
- package/dist/orchestration/thread-callback.js +0 -555
- package/dist/orchestration/thread-delivery.d.ts +0 -40
- package/dist/orchestration/thread-delivery.js +0 -76
- package/dist/orchestration/thread-executor.d.ts +0 -25
- package/dist/orchestration/thread-executor.js +0 -180
- package/dist/orchestration/thread-input.d.ts +0 -15
- package/dist/orchestration/thread-input.js +0 -50
- package/dist/orchestration/thread-notices.d.ts +0 -43
- package/dist/orchestration/thread-notices.js +0 -195
- package/dist/orchestration/thread-run/index.d.ts +0 -3
- package/dist/orchestration/thread-run/index.js +0 -2
- package/dist/orchestration/thread-run/render-summary.d.ts +0 -57
- package/dist/orchestration/thread-run/render-summary.js +0 -109
- package/dist/orchestration/thread-run/render-task.d.ts +0 -94
- package/dist/orchestration/thread-run/render-task.js +0 -154
- package/dist/orchestration/thread-run/settle.d.ts +0 -11
- package/dist/orchestration/thread-run/settle.js +0 -18
- package/dist/orchestration/thread-run/thread-run.d.ts +0 -114
- package/dist/orchestration/thread-run/thread-run.js +0 -181
- package/dist/orchestration/thread-run/thread-surface.d.ts +0 -41
- package/dist/orchestration/thread-run/thread-surface.js +0 -23
- package/dist/orchestration/thread-run/verdict.d.ts +0 -11
- package/dist/orchestration/thread-run/verdict.js +0 -20
- package/dist/store/plugin-retirement.d.ts +0 -37
- package/dist/store/plugin-retirement.js +0 -144
- package/dist/store/task-repo.d.ts +0 -43
- package/dist/store/task-repo.js +0 -143
- package/dist/store/thread-repo.d.ts +0 -65
- package/dist/store/thread-repo.js +0 -294
- package/dist/tui/components/DashboardTasksTab.d.ts +0 -12
- package/dist/tui/components/DashboardTasksTab.js +0 -196
- package/dist/tui/components/DashboardThreadsTab.d.ts +0 -11
- package/dist/tui/components/DashboardThreadsTab.js +0 -96
- package/web/dist/assets/index-C9sEss8T.css +0 -1
- package/web/dist/assets/index-fVf_wSMQ.js +0 -447
- /package/defaults/config/{thread-templates/agents → environments}/creative.json +0 -0
- /package/dist/core/types/{thread-types.js → benchmark-types.js} +0 -0
- /package/dist/domain/{threads/template-resolver.d.ts → agents/environments/prompt-includes.d.ts} +0 -0
|
@@ -53,17 +53,19 @@ function buildAgentShape(described) {
|
|
|
53
53
|
+ 'blocking this tool call. Use for long work you can carry on without.'),
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
|
+
/** The models this session's host can run a child on: the claude catalog plus the PI pairs the
|
|
57
|
+
* daemon handed down. Shared with every tool that lets the agent pick a backend and model. */
|
|
58
|
+
export function hostModelOptions(ctx) {
|
|
59
|
+
return [
|
|
60
|
+
...claudeModelOptions(ctx.claudeModel, (ctx.subagentClaudeModels ?? []).map((model) => model.id)),
|
|
61
|
+
...ctx.subagentPiModels,
|
|
62
|
+
];
|
|
63
|
+
}
|
|
56
64
|
/** Read the live catalog once per registration. Guarded end to end: a filesystem or parsing
|
|
57
65
|
* surprise must degrade to the static descriptions rather than kill tool registration. */
|
|
58
66
|
function describeHostCatalog(ctx) {
|
|
59
67
|
try {
|
|
60
|
-
return describeSubagent({
|
|
61
|
-
roles: roleOptionsFrom(loadRoles()),
|
|
62
|
-
models: [
|
|
63
|
-
...claudeModelOptions(ctx.claudeModel, (ctx.subagentClaudeModels ?? []).map((model) => model.id)),
|
|
64
|
-
...ctx.subagentPiModels,
|
|
65
|
-
],
|
|
66
|
-
});
|
|
68
|
+
return describeSubagent({ roles: roleOptionsFrom(loadRoles()), models: hostModelOptions(ctx) });
|
|
67
69
|
}
|
|
68
70
|
catch {
|
|
69
71
|
return describeSubagent({});
|
|
@@ -156,7 +158,7 @@ export function registerSubagentTools(server, ctx) {
|
|
|
156
158
|
cwd: process.cwd(),
|
|
157
159
|
// The parent's own scope: it decides where children run and what routing they inherit.
|
|
158
160
|
profile: ctx.profile,
|
|
159
|
-
project: ctx.
|
|
161
|
+
project: ctx.project,
|
|
160
162
|
channel: ctx.channel,
|
|
161
163
|
backend: ctx.backend,
|
|
162
164
|
});
|
|
@@ -23,7 +23,8 @@ export function registerUiViewTools(server, ctx) {
|
|
|
23
23
|
file_path: z.string().optional().describe('Path to an .html file you already wrote. Mutually exclusive with html.'),
|
|
24
24
|
caption: z.string().optional().describe('Optional one-line note shown above the view.'),
|
|
25
25
|
height: z.number().optional().describe('First-paint height in px (160-900, default 360). The view auto-resizes after load.'),
|
|
26
|
-
|
|
26
|
+
width: z.enum(['narrow', 'wide', 'full']).optional().describe('Card width in the chat. "narrow" (default) fits the text column; "wide" is about 1.5x that, for dashboards and side-by-side charts; "full" spans the whole chat pane, for wide tables and timelines.'),
|
|
27
|
+
}, async ({ title, html, file_path, caption, height, width }) => {
|
|
27
28
|
try {
|
|
28
29
|
const sessionId = webSessionId(ctx);
|
|
29
30
|
if (!sessionId)
|
|
@@ -40,7 +41,7 @@ export function registerUiViewTools(server, ctx) {
|
|
|
40
41
|
if (!fs.statSync(resolved).isFile())
|
|
41
42
|
throw new Error(`Not a file: ${resolved}`);
|
|
42
43
|
}
|
|
43
|
-
const { body } = await requestLoopbackJson('POST', `${ctx.webhookBaseUrl}/webhook/ui-view`, { sessionId, title, html, filePath: resolved, caption, height }, webhookAuthHeaders(ctx));
|
|
44
|
+
const { body } = await requestLoopbackJson('POST', `${ctx.webhookBaseUrl}/webhook/ui-view`, { sessionId, title, html, filePath: resolved, caption, height, width }, webhookAuthHeaders(ctx));
|
|
44
45
|
if (!body.success)
|
|
45
46
|
throw new Error(body.error || 'send_view failed');
|
|
46
47
|
const meta = body.data;
|
|
@@ -2,7 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
import { requestLoopbackJson } from '../../../core/loopback-http.js';
|
|
3
3
|
import { webhookAuthHeaders } from './context.js';
|
|
4
4
|
async function proxy(ctx, action, payload) {
|
|
5
|
-
const { body } = await requestLoopbackJson('POST', `${ctx.webhookBaseUrl}/webhook/waitpoint`, { action, sessionId: ctx.sessionId, channel: ctx.channel,
|
|
5
|
+
const { body } = await requestLoopbackJson('POST', `${ctx.webhookBaseUrl}/webhook/waitpoint`, { action, sessionId: ctx.sessionId, channel: ctx.channel, project: ctx.project, ...payload }, webhookAuthHeaders(ctx));
|
|
6
6
|
if (!body.success)
|
|
7
7
|
throw new Error(body.error || `waitpoint ${action} failed`);
|
|
8
8
|
return body.data;
|
|
@@ -58,8 +58,7 @@ export function registerWaitpointTools(server, ctx) {
|
|
|
58
58
|
'is woken with the result and the intent you recorded here.',
|
|
59
59
|
].join('\n'), {
|
|
60
60
|
label: z.string().describe('Short human name, e.g. "arm2 training". Appears in the wake message.'),
|
|
61
|
-
intent: z.string().describe('
|
|
62
|
-
+ 'this hours later in a fresh turn with none of the current context, so write it for a stranger.'),
|
|
61
|
+
intent: z.string().describe('Briefly state what you are waiting for and what to do next.'),
|
|
63
62
|
members: z.array(z.string()).optional().describe('Names of the jobs you expect to report, e.g. ["arm2","arm6","arm8"]. Each one signals with its own name.'),
|
|
64
63
|
quorum: z.union([z.number(), z.literal('all')]).optional().describe('How many terminal signals resolve this waitpoint. Defaults to "all" when members are given, else 1.'),
|
|
65
64
|
fail_fast: z.boolean().optional().describe('Wake on the first failure even if the quorum is unmet. Default true.'),
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { type CortexToolContext } from './context.js';
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function registerWorkerTools(server: McpServer, ctx: CortexToolContext): void;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { requestLoopbackJson } from '../../../core/loopback-http.js';
|
|
3
|
+
import { describeModelFields } from '../../../core/agents/subagent/catalog.js';
|
|
4
|
+
import { webhookAuthHeaders } from './context.js';
|
|
5
|
+
import { hostModelOptions } from './subagent.js';
|
|
6
|
+
/** Every worker tool returns at once; the daemon answers within this bound. */
|
|
7
|
+
const TEAM_REQUEST_TIMEOUT_MS = 30 * 1000;
|
|
8
|
+
async function proxyTeam(ctx, action, payload) {
|
|
9
|
+
const { body } = await requestLoopbackJson('POST', `${ctx.webhookBaseUrl}/webhook/team`, { action, sessionId: ctx.sessionId, ...payload }, webhookAuthHeaders(ctx), TEAM_REQUEST_TIMEOUT_MS);
|
|
10
|
+
if (!body?.success)
|
|
11
|
+
throw new Error(body?.error || `${action} failed`);
|
|
12
|
+
return body.data;
|
|
13
|
+
}
|
|
14
|
+
function textResult(text, isError = false) {
|
|
15
|
+
return { content: [{ type: 'text', text }], ...(isError ? { isError: true } : {}) };
|
|
16
|
+
}
|
|
17
|
+
const NON_BLOCKING = 'Returns immediately. Worker reports and questions arrive later as new messages '
|
|
18
|
+
+ 'in this conversation; after dispatching work, end your turn instead of waiting or polling.';
|
|
19
|
+
const WORKER_MODEL_FIELD_BASES = {
|
|
20
|
+
model: 'Optional model: provider/model[:thinking] for a pi worker, a bare model id for a claude '
|
|
21
|
+
+ 'worker. Omit to keep your own current model (same backend) or use that backend\'s default.',
|
|
22
|
+
backend: 'Optional backend: "claude" or "pi". Omit to use your own.',
|
|
23
|
+
};
|
|
24
|
+
/** The backend/model field text, listing the same host catalog the `agent` tool offers. A catalog
|
|
25
|
+
* that cannot be read degrades to the bare lead-ins rather than failing registration. */
|
|
26
|
+
function describeWorkerModelFields(ctx) {
|
|
27
|
+
try {
|
|
28
|
+
return describeModelFields(hostModelOptions(ctx), WORKER_MODEL_FIELD_BASES);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return WORKER_MODEL_FIELD_BASES;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** One handler shape for all five tools: proxy, then render the daemon's text or the error. */
|
|
35
|
+
function handler(ctx, action) {
|
|
36
|
+
return async (params) => {
|
|
37
|
+
try {
|
|
38
|
+
const data = await proxyTeam(ctx, action, params);
|
|
39
|
+
return textResult(typeof data?.text === 'string' ? data.text : JSON.stringify(data, null, 2));
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
return textResult(`${action} error: ${error.message}`, true);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export function registerWorkerTools(server, ctx) {
|
|
47
|
+
const described = describeWorkerModelFields(ctx);
|
|
48
|
+
server.tool('worker_spawn', 'Start a persistent worker: a separate session with its own context and full tool surface, '
|
|
49
|
+
+ 'which you can continue later with worker_send. Use a worker for work that may need follow-up, '
|
|
50
|
+
+ 'runs long, or may need back-and-forth. For bounded reconnaissance or verification whose result '
|
|
51
|
+
+ 'you consume immediately, use the one-shot `agent` tool instead. Write a self-contained prompt: '
|
|
52
|
+
+ 'the worker does not see this conversation. The worker keeps your current model unless you pass '
|
|
53
|
+
+ 'backend or model. The user can open the worker and talk to it directly. '
|
|
54
|
+
+ 'Each worker turn reports back to you with its final reply; its questions and plan approvals are '
|
|
55
|
+
+ `routed to you (answer with worker_answer). ${NON_BLOCKING}`, {
|
|
56
|
+
name: z.string().describe('Short unique slug for this worker, e.g. "api-refactor" (lowercase letters, digits, hyphens; max 32).'),
|
|
57
|
+
prompt: z.string().describe('Complete, self-contained task for the worker.'),
|
|
58
|
+
backend: z.enum(['claude', 'pi']).optional().describe(described.backend),
|
|
59
|
+
model: z.string().optional().describe(described.model),
|
|
60
|
+
}, handler(ctx, 'spawn'));
|
|
61
|
+
server.tool('worker_send', 'Send a message to one of your workers: continue its work, redirect it, or give it more context. '
|
|
62
|
+
+ 'Injected into its current turn if it is running, otherwise starts a new turn. Revives a retired '
|
|
63
|
+
+ `worker. Prefer this over spawning when the topic and code area are the same and the worker's `
|
|
64
|
+
+ `context is still relevant. ${NON_BLOCKING}`, {
|
|
65
|
+
worker: z.string().describe('The worker name.'),
|
|
66
|
+
message: z.string().describe('The message to deliver.'),
|
|
67
|
+
}, handler(ctx, 'send'));
|
|
68
|
+
server.tool('worker_list', 'Without arguments: your workers with status, brief, last report time and context usage. With a '
|
|
69
|
+
+ 'worker name: that worker in detail, including its full last report. You do not need this to '
|
|
70
|
+
+ 'learn that a worker finished; reports arrive on their own.', { worker: z.string().optional().describe('A worker name for its detail view.') }, handler(ctx, 'list'));
|
|
71
|
+
server.tool('worker_stop', 'Stop a worker\'s current turn. With retire=true it also leaves the roster (worker_send revives it).', {
|
|
72
|
+
worker: z.string().describe('The worker name.'),
|
|
73
|
+
retire: z.boolean().optional().describe('Also retire the worker.'),
|
|
74
|
+
}, handler(ctx, 'stop'));
|
|
75
|
+
server.tool('worker_answer', 'Resolve a pending question or plan approval a worker raised, by its request_id. For a question, '
|
|
76
|
+
+ 'pass answers keyed by the exact question text. For a plan or commission submission, pass approved '
|
|
77
|
+
+ '(and feedback when rejecting or adjusting). If you are unsure what the user would want, ask them '
|
|
78
|
+
+ 'with cortex_ask_user first. The user may also answer on the worker\'s own card; the first answer wins.', {
|
|
79
|
+
request_id: z.string().describe('The request_id from the worker notice.'),
|
|
80
|
+
answers: z.record(z.string(), z.string()).optional().describe('Question text → answer, for a question.'),
|
|
81
|
+
approved: z.boolean().optional().describe('Approve (true) or reject (false), for a plan.'),
|
|
82
|
+
feedback: z.string().optional().describe('Feedback for the worker, mainly when rejecting a plan.'),
|
|
83
|
+
}, handler(ctx, 'answer'));
|
|
84
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The user profile for
|
|
3
|
-
*
|
|
4
|
-
* do NOT inject this — only the direct conversation path calls it.
|
|
2
|
+
* The user profile for conversation turns. Injected by default; set
|
|
3
|
+
* CORTEX_DISABLE_USER_CONTEXT=1 to opt out. Only the direct conversation path calls it.
|
|
5
4
|
*/
|
|
6
5
|
export declare function loadUserContext(): string | null;
|
|
@@ -19,9 +19,8 @@ function readUserMd() {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
* The user profile for
|
|
23
|
-
*
|
|
24
|
-
* do NOT inject this — only the direct conversation path calls it.
|
|
22
|
+
* The user profile for conversation turns. Injected by default; set
|
|
23
|
+
* CORTEX_DISABLE_USER_CONTEXT=1 to opt out. Only the direct conversation path calls it.
|
|
25
24
|
*/
|
|
26
25
|
export function loadUserContext() {
|
|
27
26
|
if (getSettings().disableUserContext)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getMachineRegistry } from '../
|
|
1
|
+
import { getMachineRegistry } from '../remote/machine-registry.js';
|
|
2
2
|
import { sendCommand, isDeviceOnline } from '../remote/client-manager.js';
|
|
3
3
|
import { Icons } from '../../core/icons.js';
|
|
4
4
|
const GPU_QUERY = 'nvidia-smi --query-gpu=index,uuid,name,utilization.gpu,memory.used,memory.total,temperature.gpu,power.draw --format=csv,noheader,nounits 2>/dev/null';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** PI request protocols a custom provider may speak (PI docs/models.md §Supported APIs). */
|
|
2
|
-
export declare const CUSTOM_PROVIDER_APIS: readonly [
|
|
2
|
+
export declare const CUSTOM_PROVIDER_APIS: readonly ['anthropic-messages', 'openai-completions', 'openai-responses', 'google-generative-ai'];
|
|
3
3
|
export type CustomProviderApi = typeof CUSTOM_PROVIDER_APIS[number];
|
|
4
4
|
/** aistatus auth styles (node_modules/aistatus AUTH_STYLES): how the gateway presents the key. */
|
|
5
5
|
export type GatewayAuthStyle = 'anthropic' | 'openai' | 'google';
|
|
@@ -51,7 +51,7 @@ export declare class ProjectStore {
|
|
|
51
51
|
refresh(): void;
|
|
52
52
|
/**
|
|
53
53
|
* Create a new user project directory under PROJECTS_DIR with a standard scaffold
|
|
54
|
-
* (STATUS.md + AGENTS.md
|
|
54
|
+
* (STATUS.md + AGENTS.md). Validates the name (rejects path traversal, separators,
|
|
55
55
|
* empty/whitespace, leading-dot, and the reserved 'general'). Never overwrites an
|
|
56
56
|
* existing project directory — returns an `already-exists` error instead.
|
|
57
57
|
*/
|
|
@@ -62,7 +62,6 @@ export declare class ProjectStore {
|
|
|
62
62
|
private scaffoldGeneral;
|
|
63
63
|
/** Create a project directory and write the standard scaffold files. */
|
|
64
64
|
private scaffoldProject;
|
|
65
|
-
private ensureTasksFile;
|
|
66
65
|
/** Read PROJECTS_DIR and rebuild the in-memory cache. */
|
|
67
66
|
private scan;
|
|
68
67
|
private makeGeneralProject;
|
|
@@ -115,7 +115,7 @@ export class ProjectStore {
|
|
|
115
115
|
}
|
|
116
116
|
/**
|
|
117
117
|
* Create a new user project directory under PROJECTS_DIR with a standard scaffold
|
|
118
|
-
* (STATUS.md + AGENTS.md
|
|
118
|
+
* (STATUS.md + AGENTS.md). Validates the name (rejects path traversal, separators,
|
|
119
119
|
* empty/whitespace, leading-dot, and the reserved 'general'). Never overwrites an
|
|
120
120
|
* existing project directory — returns an `already-exists` error instead.
|
|
121
121
|
*/
|
|
@@ -162,19 +162,12 @@ export class ProjectStore {
|
|
|
162
162
|
this.scaffoldProject(generalDir, GENERAL_SCAFFOLD_STATUS, GENERAL_SCAFFOLD_CORTEX);
|
|
163
163
|
log.info(`Scaffolded general project at ${generalDir}`);
|
|
164
164
|
}
|
|
165
|
-
this.ensureTasksFile(generalDir);
|
|
166
165
|
}
|
|
167
166
|
/** Create a project directory and write the standard scaffold files. */
|
|
168
167
|
scaffoldProject(dir, statusContent, indexContent) {
|
|
169
168
|
fs.mkdirSync(dir, { recursive: true });
|
|
170
169
|
fs.writeFileSync(path.join(dir, 'STATUS.md'), statusContent, 'utf8');
|
|
171
170
|
fs.writeFileSync(path.join(dir, 'AGENTS.md'), indexContent, 'utf8');
|
|
172
|
-
this.ensureTasksFile(dir);
|
|
173
|
-
}
|
|
174
|
-
ensureTasksFile(dir) {
|
|
175
|
-
const tasksPath = path.join(dir, 'TASKS.yaml');
|
|
176
|
-
if (!fs.existsSync(tasksPath))
|
|
177
|
-
fs.writeFileSync(tasksPath, 'tasks: []\n', 'utf8');
|
|
178
171
|
}
|
|
179
172
|
/** Read PROJECTS_DIR and rebuild the in-memory cache. */
|
|
180
173
|
scan() {
|
|
@@ -191,7 +184,6 @@ export class ProjectStore {
|
|
|
191
184
|
continue;
|
|
192
185
|
if (entry.name === 'general')
|
|
193
186
|
continue; // already added
|
|
194
|
-
this.ensureTasksFile(path.join(this.projectsDir, entry.name));
|
|
195
187
|
result.push({
|
|
196
188
|
id: entry.name,
|
|
197
189
|
name: entry.name,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type MachineEntry, type MachineRegistry } from '
|
|
1
|
+
import { type MachineEntry, type MachineRegistry } from './machine-registry.js';
|
|
2
2
|
import { SshTunnelSupervisor } from './client-ssh-tunnel.js';
|
|
3
3
|
/** Client self-update wiring (set by client-hot-reload at boot). */
|
|
4
4
|
interface ClientUpdateHooks {
|
|
@@ -3,7 +3,7 @@ import * as crypto from 'crypto';
|
|
|
3
3
|
import * as fs from 'fs';
|
|
4
4
|
import * as path from 'path';
|
|
5
5
|
import { execFile, spawn } from 'child_process';
|
|
6
|
-
import { getMachineRegistry, applyReportedGpuCount } from '
|
|
6
|
+
import { getMachineRegistry, applyReportedGpuCount } from './machine-registry.js';
|
|
7
7
|
import { STORE_DIR, DATA_DIR } from '../../core/paths.js';
|
|
8
8
|
import { AUTH_HEADER, getClientToken, timingSafeEqualStr } from '../../core/auth.js';
|
|
9
9
|
import { createLogger } from '../../core/log.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MachineEntry } from '
|
|
1
|
+
import type { MachineEntry } from './machine-registry.js';
|
|
2
2
|
/** Runs a shell command on a remote host and resolves with its stdout. */
|
|
3
3
|
export type RemoteExec = (host: string, command: string) => Promise<string>;
|
|
4
4
|
export interface RemoveClientRequest {
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export interface MachineEntry {
|
|
2
|
+
cortexPath: string;
|
|
3
|
+
gpuCount: number;
|
|
4
|
+
ssh?: string;
|
|
5
|
+
win?: boolean;
|
|
6
|
+
/** Route used by cortex-client to reach the server. Defaults to direct. */
|
|
7
|
+
clientConnection?: 'direct' | 'ssh-reverse';
|
|
8
|
+
/** Remote loopback port for an SSH reverse route. Defaults to the server client port. */
|
|
9
|
+
clientReversePort?: number;
|
|
10
|
+
/**
|
|
11
|
+
* Command the server runs (over SSH) to launch cortex-client on this machine.
|
|
12
|
+
* Defaults to `node` on the managed bundle at `<CORTEX_HOME>/client/current/client.mjs`.
|
|
13
|
+
* Override for machines where `node` isn't on the non-login SSH PATH (absolute
|
|
14
|
+
* nvm bin path) or where CORTEX_HOME is relocated. The token-injection and
|
|
15
|
+
* nohup/echo-$! (Linux) / cmd.exe-wrap WMI (Windows) machinery wraps this command.
|
|
16
|
+
*/
|
|
17
|
+
clientCommand?: string;
|
|
18
|
+
}
|
|
19
|
+
export type MachineRegistry = Record<string, MachineEntry>;
|
|
20
|
+
export declare function validateMachineEntry(name: string, entry: MachineEntry): void;
|
|
21
|
+
export declare function setAdminNotifier(fn: (text: string) => void): void;
|
|
22
|
+
export declare function setMachineReloadListener(fn: () => void): void;
|
|
23
|
+
/**
|
|
24
|
+
* Load machines.json from disk into memory.
|
|
25
|
+
* On first call (startup), throws if file is missing or malformed.
|
|
26
|
+
* On subsequent calls (hot-reload), logs errors and keeps old config.
|
|
27
|
+
*/
|
|
28
|
+
declare function loadMachinesFromFile(failOnError?: boolean): void;
|
|
29
|
+
/**
|
|
30
|
+
* Return the current in-memory machine registry.
|
|
31
|
+
*/
|
|
32
|
+
declare function getMachineRegistry(): MachineRegistry;
|
|
33
|
+
export type GpuCountUpdate = 'updated' | 'unchanged' | 'skipped';
|
|
34
|
+
/**
|
|
35
|
+
* Reconcile a GPU count a client reported about itself into the registry and machines.json.
|
|
36
|
+
*
|
|
37
|
+
* `null` means the client could not probe (no nvidia-smi, driver down) — that is "unknown", not
|
|
38
|
+
* "zero GPUs", so the configured value stands and the machine is never silently dropped from GPU
|
|
39
|
+
* dispatch. Only machines already in the registry are touched: a client cannot register itself.
|
|
40
|
+
*/
|
|
41
|
+
declare function applyReportedGpuCount(machine: string, reported: number | null): GpuCountUpdate;
|
|
42
|
+
/**
|
|
43
|
+
* Return the first machine key in the registry as the local/default machine.
|
|
44
|
+
* Falls back to 'local' if no machines are registered.
|
|
45
|
+
*/
|
|
46
|
+
declare function getLocalMachine(): string;
|
|
47
|
+
declare function startMachineRegistryWatcher(): void;
|
|
48
|
+
/**
|
|
49
|
+
* Stop watching machines.json (for tests / graceful shutdown).
|
|
50
|
+
*/
|
|
51
|
+
declare function stopMachineRegistryWatcher(): void;
|
|
52
|
+
/** Test-only: directly set the in-memory machine registry. */
|
|
53
|
+
declare function _testSetRegistry(registry: MachineRegistry): void;
|
|
54
|
+
export { getMachineRegistry, getLocalMachine, applyReportedGpuCount, loadMachinesFromFile, startMachineRegistryWatcher, stopMachineRegistryWatcher, _testSetRegistry, };
|
|
@@ -181,64 +181,4 @@ function _testSetRegistry(registry) {
|
|
|
181
181
|
_registry = { ...registry };
|
|
182
182
|
_loaded = true;
|
|
183
183
|
}
|
|
184
|
-
|
|
185
|
-
if (!args.taskId) {
|
|
186
|
-
log.warn(`[SPLIT] marker in thread ${args.threadId} but no associated task — ignoring`);
|
|
187
|
-
return { handled: false };
|
|
188
|
-
}
|
|
189
|
-
if (!detection.error && detection.subtasks)
|
|
190
|
-
return null;
|
|
191
|
-
await deps.unclaim(args.taskId);
|
|
192
|
-
return { handled: true, error: detection.error || '[SPLIT] proposal empty' };
|
|
193
|
-
}
|
|
194
|
-
/** Process a worker thread's [SPLIT] proposal and preserve dispatch ownership. */
|
|
195
|
-
async function processSplitOutcome(args, deps) {
|
|
196
|
-
const detection = deps.detect(args.threadId);
|
|
197
|
-
if (!detection.split)
|
|
198
|
-
return { handled: false };
|
|
199
|
-
const invalid = await invalidSplitOutcome(args, detection, deps);
|
|
200
|
-
if (invalid)
|
|
201
|
-
return invalid;
|
|
202
|
-
const ownershipOption = args.ownership ? { ownership: args.ownership } : {};
|
|
203
|
-
const result = await deps.decompose(args.project, null, detection.subtasks, args.taskId, {
|
|
204
|
-
keepParent: true,
|
|
205
|
-
...ownershipOption,
|
|
206
|
-
});
|
|
207
|
-
if (!result.success) {
|
|
208
|
-
await deps.unclaim(args.taskId);
|
|
209
|
-
return { handled: true, error: result.message };
|
|
210
|
-
}
|
|
211
|
-
await deps.unclaim(args.taskId);
|
|
212
|
-
return { handled: true, note: `split into ${detection.subtasks.length} subtask(s) — parent kept as join node` };
|
|
213
|
-
}
|
|
214
|
-
/** Canonical block reason for a worker-aborted task. Single source so the runner's
|
|
215
|
-
* pre-onEnd block (DR-0015 problem 2) and processAbortOutcome produce byte-identical
|
|
216
|
-
* reasons — a second block with the same reason is a no-op commit (git porcelain sees no
|
|
217
|
-
* change), so blocking in both places is safe. */
|
|
218
|
-
export function formatWorkerAbortReason(raw) {
|
|
219
|
-
const r = (raw || 'no reason given').replace(/\s+/g, ' ').trim() || 'no reason given';
|
|
220
|
-
return `worker-abort: ${r}`.slice(0, 280);
|
|
221
|
-
}
|
|
222
|
-
/** Process an aborted dispatch thread: the worker said "I can't" ([ABORT: <reason>]) —
|
|
223
|
-
* block the task with the abort reason. taskMutator.block publishes task.blocked, which
|
|
224
|
-
* wakes a manager thread waiting on this task (its parent re-plans); with no manager the
|
|
225
|
-
* block surfaces to humans/stage-gate as usual. Also fixes the pre-existing bug where
|
|
226
|
-
* aborted dispatch threads were finalized as successes (publishing a bogus task.completed).
|
|
227
|
-
* Not counted as a dispatch failure — abort is a judgment, not a fault. */
|
|
228
|
-
async function processAbortOutcome(args, deps) {
|
|
229
|
-
const thread = deps.getThread(args.threadId);
|
|
230
|
-
if (!thread || thread.status !== 'aborted')
|
|
231
|
-
return { handled: false };
|
|
232
|
-
if (!args.taskId) {
|
|
233
|
-
log.warn(`aborted thread ${args.threadId} has no associated task — ignoring`);
|
|
234
|
-
return { handled: false };
|
|
235
|
-
}
|
|
236
|
-
const rawReason = (thread.abortReason || 'no reason given').replace(/\s+/g, ' ').trim();
|
|
237
|
-
const reason = formatWorkerAbortReason(thread.abortReason);
|
|
238
|
-
const result = await deps.block(args.taskId, reason);
|
|
239
|
-
if (!result.success) {
|
|
240
|
-
return { handled: true, error: result.message };
|
|
241
|
-
}
|
|
242
|
-
return { handled: true, note: `worker aborted — task blocked (${rawReason.slice(0, 120)})` };
|
|
243
|
-
}
|
|
244
|
-
export { getMachineRegistry, getLocalMachine, applyReportedGpuCount, loadMachinesFromFile, startMachineRegistryWatcher, stopMachineRegistryWatcher, processSplitOutcome, processAbortOutcome, _testSetRegistry, };
|
|
184
|
+
export { getMachineRegistry, getLocalMachine, applyReportedGpuCount, loadMachinesFromFile, startMachineRegistryWatcher, stopMachineRegistryWatcher, _testSetRegistry, };
|
|
@@ -19,17 +19,12 @@ import { freezeProductionAttemptIdentity, } from '../benchmark/production-attemp
|
|
|
19
19
|
import { createProductionAttemptJournalSink } from '../benchmark/production-attempt-journal.js';
|
|
20
20
|
const log = createLogger('run-attempt');
|
|
21
21
|
/** The cost columns every row of this attempt carries. Frozen once: an attempt cannot change
|
|
22
|
-
* which
|
|
22
|
+
* which session/trial it belongs to halfway through. */
|
|
23
23
|
function costAttribution(request, executionId, identity) {
|
|
24
24
|
return Object.freeze({
|
|
25
|
-
session_id:
|
|
25
|
+
session_id: identity?.session_id
|
|
26
|
+
?? request.session.sessionId ?? request.session.backendSessionId ?? null,
|
|
26
27
|
execution_id: identity?.execution_id ?? executionId ?? null,
|
|
27
|
-
thread_id: identity?.thread_id ?? request.context.threadId ?? null,
|
|
28
|
-
parent_thread_id: identity?.parent_thread_id ?? request.benchmark?.parentThreadId ?? null,
|
|
29
|
-
root_thread_id: identity?.root_thread_id ?? request.benchmark?.rootThreadId ?? null,
|
|
30
|
-
task_id: identity?.task_id ?? request.context.taskId ?? null,
|
|
31
|
-
task_project: identity?.task_project ?? request.context.taskProject ?? null,
|
|
32
|
-
dispatch_generation: identity?.dispatch_generation ?? request.context.taskGeneration ?? null,
|
|
33
28
|
attempt_id: identity?.attempt_id ?? null,
|
|
34
29
|
root_attempt_id: identity?.root_attempt_id ?? null,
|
|
35
30
|
trial_id: identity?.trial_id ?? null,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { ResolvedProfileConfig } from '../agents/profile-manager.js';
|
|
2
2
|
import type { RunRequest } from './request.js';
|
|
3
|
-
/** The policy every
|
|
4
|
-
*
|
|
5
|
-
* `awaitBackground` + no threadId resolved to), cost recorded, hooks and ambient rules on, the
|
|
3
|
+
/** The policy every direct run opens under: the engine runs the turn and returns, with no inline
|
|
4
|
+
* wait for background work (`background: 'none'`), cost recorded, hooks and ambient rules on, the
|
|
6
5
|
* direct MCP surface, and no browser attached.
|
|
7
6
|
*
|
|
8
7
|
* `captureTranscripts` must stay true: Claude writes a per-turn transcript file unless told not
|
|
@@ -9,9 +9,8 @@
|
|
|
9
9
|
// builder — the point is that every field NOT spread is provably the shared value.
|
|
10
10
|
import { randomUUID } from 'node:crypto';
|
|
11
11
|
import { bareSpec } from './spec-loader.js';
|
|
12
|
-
/** The policy every
|
|
13
|
-
*
|
|
14
|
-
* `awaitBackground` + no threadId resolved to), cost recorded, hooks and ambient rules on, the
|
|
12
|
+
/** The policy every direct run opens under: the engine runs the turn and returns, with no inline
|
|
13
|
+
* wait for background work (`background: 'none'`), cost recorded, hooks and ambient rules on, the
|
|
15
14
|
* direct MCP surface, and no browser attached.
|
|
16
15
|
*
|
|
17
16
|
* `captureTranscripts` must stay true: Claude writes a per-turn transcript file unless told not
|
|
@@ -60,7 +60,6 @@ export function buildPiGatewaySubPath(mode, provider) {
|
|
|
60
60
|
// --- Spec helpers ---
|
|
61
61
|
function spawnContext(request, executionId) {
|
|
62
62
|
return {
|
|
63
|
-
threadId: request.context.threadId ?? null,
|
|
64
63
|
// `|| null`, not `?? null`: a synthesized profile (a subagent child, a fixture) carries an
|
|
65
64
|
// empty name because it was never looked up by name, and the child env must stay as it was
|
|
66
65
|
// before the run model — CORTEX_PROFILE absent, not set to an invented profile name.
|
|
@@ -69,17 +68,10 @@ function spawnContext(request, executionId) {
|
|
|
69
68
|
sessionName: request.session.sessionName ?? null,
|
|
70
69
|
trackSessionId: request.session.sessionId ?? request.session.backendSessionId ?? null,
|
|
71
70
|
executionId: executionId ?? null,
|
|
72
|
-
useCoreMcp: request.policy.useCoreMcp ?? undefined,
|
|
73
|
-
threadDepth: request.context.threadDepth ?? null,
|
|
74
|
-
taskId: request.context.taskId ?? null,
|
|
75
|
-
taskProject: request.context.taskProject ?? null,
|
|
76
|
-
taskGeneration: request.context.taskGeneration ?? null,
|
|
77
71
|
};
|
|
78
72
|
}
|
|
79
73
|
function hasSpawnContext(context) {
|
|
80
|
-
return Object.
|
|
81
|
-
return key === 'threadDepth' ? value != null : Boolean(value);
|
|
82
|
-
});
|
|
74
|
+
return Object.values(context).some(Boolean);
|
|
83
75
|
}
|
|
84
76
|
/** A spec's tool surface is either a canonical list or Claude's raw `--tools` string. */
|
|
85
77
|
function canonicalToolList(request) {
|
|
@@ -111,6 +103,7 @@ function spawnPolicy(request) {
|
|
|
111
103
|
captureTranscripts: request.policy.captureTranscripts,
|
|
112
104
|
preserveUnreportedAccounting: request.benchmark?.preserveUnreportedAccounting,
|
|
113
105
|
isUserInitiated: !!request.context.isUserInitiated,
|
|
106
|
+
...(request.context.teamLead ? { teamLead: true } : {}),
|
|
114
107
|
},
|
|
115
108
|
process: {
|
|
116
109
|
spawner: request.isolation?.spawner,
|
|
@@ -184,7 +177,7 @@ function backendField(request, attempt) {
|
|
|
184
177
|
*/
|
|
185
178
|
export function buildEngineSpec(request, attempt, opts = {}) {
|
|
186
179
|
const { route, executionId = null } = opts;
|
|
187
|
-
const mcpComposition = resolveMcpComposition(request.policy.mcpComposition
|
|
180
|
+
const mcpComposition = resolveMcpComposition(request.policy.mcpComposition);
|
|
188
181
|
const context = spawnContext(request, executionId);
|
|
189
182
|
const appendSystemPrompt = composeSystemPrompt(request.spec, {
|
|
190
183
|
rules: globalRuleBodies(request.policy.loadRules !== false),
|
|
@@ -35,8 +35,6 @@ export declare function attemptProvider(attempt: Parameters<typeof resolveRateLi
|
|
|
35
35
|
* An unknown profile name deliberately resolves to a synthetic config with an empty model
|
|
36
36
|
* (`config-resolver.syntheticProfile`) so the execution record can be opened with a truthful
|
|
37
37
|
* backend and the run itself rejects the name. Attributing that attempt's failure to a provider
|
|
38
|
-
* would open an outage window against a provider that was never called
|
|
39
|
-
* "don't invent one" rule the thread runner already applies when it reports `provider: null` for
|
|
40
|
-
* a step whose profile does not resolve.
|
|
38
|
+
* would open an outage window against a provider that was never called.
|
|
41
39
|
*/
|
|
42
40
|
export declare function attemptProviderOrNull(attempt: RunAttemptConfig): string | null;
|
|
@@ -67,9 +67,7 @@ export function attemptProvider(attempt) {
|
|
|
67
67
|
* An unknown profile name deliberately resolves to a synthetic config with an empty model
|
|
68
68
|
* (`config-resolver.syntheticProfile`) so the execution record can be opened with a truthful
|
|
69
69
|
* backend and the run itself rejects the name. Attributing that attempt's failure to a provider
|
|
70
|
-
* would open an outage window against a provider that was never called
|
|
71
|
-
* "don't invent one" rule the thread runner already applies when it reports `provider: null` for
|
|
72
|
-
* a step whose profile does not resolve.
|
|
70
|
+
* would open an outage window against a provider that was never called.
|
|
73
71
|
*/
|
|
74
72
|
export function attemptProviderOrNull(attempt) {
|
|
75
73
|
return attempt.model ? resolveRateLimitProvider(attempt) : null;
|
|
@@ -24,18 +24,3 @@ export interface DirectResumeInput {
|
|
|
24
24
|
* and "failed" wording without asking the throttle a second time.
|
|
25
25
|
*/
|
|
26
26
|
export declare function recordDirectResume(input: DirectResumeInput): boolean;
|
|
27
|
-
/** A thread-pipeline resume candidate. */
|
|
28
|
-
export interface ThreadResumeInput {
|
|
29
|
-
provider: string | null;
|
|
30
|
-
threadId: string;
|
|
31
|
-
channel: string;
|
|
32
|
-
userMessage: string;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Record an interrupted thread for auto-resume. Unconditional by design, unlike the direct path:
|
|
36
|
-
* the thread callers have already committed to the pause (`markThreadRateLimited` moved the thread
|
|
37
|
-
* to `rate_limited`, or boot found it already there), so a thread left out of the queue would be
|
|
38
|
-
* stranded in a paused state with nothing able to restart it. The queue tolerates an entry whose
|
|
39
|
-
* provider is not throttled — `takeReadyResumes` simply releases it on the next drain.
|
|
40
|
-
*/
|
|
41
|
-
export declare function recordThreadResume(input: ThreadResumeInput): void;
|
|
@@ -25,20 +25,3 @@ export function recordDirectResume(input) {
|
|
|
25
25
|
});
|
|
26
26
|
return true;
|
|
27
27
|
}
|
|
28
|
-
/**
|
|
29
|
-
* Record an interrupted thread for auto-resume. Unconditional by design, unlike the direct path:
|
|
30
|
-
* the thread callers have already committed to the pause (`markThreadRateLimited` moved the thread
|
|
31
|
-
* to `rate_limited`, or boot found it already there), so a thread left out of the queue would be
|
|
32
|
-
* stranded in a paused state with nothing able to restart it. The queue tolerates an entry whose
|
|
33
|
-
* provider is not throttled — `takeReadyResumes` simply releases it on the next drain.
|
|
34
|
-
*/
|
|
35
|
-
export function recordThreadResume(input) {
|
|
36
|
-
recordResume({
|
|
37
|
-
kind: 'thread',
|
|
38
|
-
provider: input.provider,
|
|
39
|
-
threadId: input.threadId,
|
|
40
|
-
channel: input.channel,
|
|
41
|
-
userMessage: input.userMessage,
|
|
42
|
-
recordedAt: Date.now(),
|
|
43
|
-
});
|
|
44
|
-
}
|
|
@@ -17,9 +17,7 @@ export declare function composeSystemPrompt(spec: SystemPromptSpec, sources?: {
|
|
|
17
17
|
}): string | undefined;
|
|
18
18
|
/** The ambient global rule bodies, or none when the run opts out (a frozen subagent role). */
|
|
19
19
|
export declare function globalRuleBodies(load: boolean): string[];
|
|
20
|
-
/** The user-prompt-bearing half of an {@link import('./request.js').AgentSpec}.
|
|
21
|
-
* passes the stage's template here rather than the agent-level one — stage selection is thread
|
|
22
|
-
* policy, and by the time composition runs the template has already been chosen. */
|
|
20
|
+
/** The user-prompt-bearing half of an {@link import('./request.js').AgentSpec}. */
|
|
23
21
|
export interface UserPromptSpec {
|
|
24
22
|
/** Role/identity text prepended to the rendered body. */
|
|
25
23
|
directive?: string | null;
|
|
@@ -36,8 +34,19 @@ export interface UserPromptOptions {
|
|
|
36
34
|
id: string;
|
|
37
35
|
contextDir: string;
|
|
38
36
|
} | null;
|
|
37
|
+
/** The conversation-history directory, so the agent can find any session's transcript. */
|
|
38
|
+
transcriptDir?: string | null;
|
|
39
39
|
/** Index + protocol for a commission-bound session (DR-0037). */
|
|
40
40
|
commission?: CommissionPromptContext | null;
|
|
41
|
+
/** Team mode, lead side: one roster line per active worker. */
|
|
42
|
+
team?: {
|
|
43
|
+
roster: string[];
|
|
44
|
+
} | null;
|
|
45
|
+
/** Team mode, worker side: its own name and its lead's title. */
|
|
46
|
+
worker?: {
|
|
47
|
+
name: string;
|
|
48
|
+
lead: string;
|
|
49
|
+
} | null;
|
|
41
50
|
/** A control-plane preamble (the thread protocol) — the last prefix before the body. */
|
|
42
51
|
preamble?: string | null;
|
|
43
52
|
/** Text spliced between the prefixes and the rendered body, separated by a `---` rule. The
|
|
@@ -56,14 +65,20 @@ export interface UserPromptOptions {
|
|
|
56
65
|
* Assemble one turn's user prompt: the agent's template rendered over the turn's variables, with
|
|
57
66
|
* the ambient blocks the session needs in front of it.
|
|
58
67
|
*
|
|
59
|
-
* Prefix order is fixed — user profile, agent directive, session project,
|
|
60
|
-
* preamble — and every block is optional. A caller that passes none (and no lead/appendix) gets the
|
|
68
|
+
* Prefix order is fixed — user profile, agent directive, session project, transcript location,
|
|
69
|
+
* commission, team or worker, control-plane preamble — and every block is optional. A caller that passes none (and no lead/appendix) gets the
|
|
61
70
|
* rendered template alone, trimmed.
|
|
62
71
|
*/
|
|
63
72
|
export declare function composeUserPrompt(spec: UserPromptSpec, input: string, opts?: UserPromptOptions): string;
|
|
64
73
|
/**
|
|
65
|
-
* The user profile for
|
|
66
|
-
*
|
|
67
|
-
* session's FIRST turn; resume keeps the block in backend history thereafter.
|
|
74
|
+
* The user profile for conversation turns — the ONLY path that injects USER.md. Callers gate it
|
|
75
|
+
* to a session's FIRST turn; resume keeps the block in backend history thereafter.
|
|
68
76
|
*/
|
|
69
77
|
export declare function userProfileBlock(include: boolean): string | null;
|
|
78
|
+
/** The lead's standing rules plus its live roster, re-sent every turn while it has workers. */
|
|
79
|
+
export declare function buildTeamBlock(roster: readonly string[]): string;
|
|
80
|
+
/** A worker's first-turn orientation. */
|
|
81
|
+
export declare function buildWorkerBlock(worker: {
|
|
82
|
+
name: string;
|
|
83
|
+
lead: string;
|
|
84
|
+
}): string;
|