@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
|
@@ -8,8 +8,8 @@ import { SETTINGS_SPEC } from '../../core/settings-spec.js';
|
|
|
8
8
|
// Import the leaf model module, not the pi-providers barrel: this file is bundled for the browser
|
|
9
9
|
// through @cortex-agent/ui-contract, and that module is pure data with no imports of its own.
|
|
10
10
|
import { CUSTOM_PROVIDER_APIS, CUSTOM_PROVIDER_NAME_RE, } from '../pi-providers/custom-provider-model.js';
|
|
11
|
-
import { sessionsListInput, sessionsTranscriptInput, sessionsSubagentTranscriptInput, sessionsDebugDetailsInput, sessionsPendingInteractionInput,
|
|
12
|
-
export { sessionsListInput, sessionsTranscriptInput, sessionsSubagentTranscriptInput, sessionsDebugDetailsInput, sessionsPendingInteractionInput,
|
|
11
|
+
import { sessionsListInput, sessionsTranscriptInput, sessionsSubagentTranscriptInput, sessionsDebugDetailsInput, sessionsPendingInteractionInput, schedulesListInput, commissionsListInput, commissionsGetInput, commissionsDecisionsInput, executionsListInput, executionsGetInput, waitpointsListInput, memoryTreeInput, memoryFileInput, approvalsListInput, issuesListInput, notesListInput, } from './query-input-schemas.js';
|
|
12
|
+
export { sessionsListInput, sessionsTranscriptInput, sessionsSubagentTranscriptInput, sessionsDebugDetailsInput, sessionsPendingInteractionInput, schedulesListInput, commissionsListInput, commissionsGetInput, commissionsDecisionsInput, executionsListInput, executionsGetInput, waitpointsListInput, memoryTreeInput, memoryFileInput, approvalsListInput, issuesListInput, notesListInput, };
|
|
13
13
|
// ── Query input schemas ───────────────────────────────────────────
|
|
14
14
|
export const projectsListInput = z.object({});
|
|
15
15
|
export const costSummaryInput = z.object({
|
|
@@ -28,7 +28,7 @@ export const machineDetailInput = z.object({
|
|
|
28
28
|
});
|
|
29
29
|
export const skillsListInput = z.object({});
|
|
30
30
|
export const pluginsListInput = z.object({});
|
|
31
|
-
export const
|
|
31
|
+
export const environmentsListInput = z.object({});
|
|
32
32
|
export const systemDaemonStatusInput = z.object({});
|
|
33
33
|
export const systemRateLimitStatusInput = z.object({});
|
|
34
34
|
export const systemUsageStatusInput = z.object({});
|
|
@@ -210,9 +210,6 @@ export const sessionsCreateAndSendInput = z.object({
|
|
|
210
210
|
type: z.enum(['image', 'video', 'file']),
|
|
211
211
|
})).optional(),
|
|
212
212
|
});
|
|
213
|
-
export const threadsCancelInput = z.object({
|
|
214
|
-
threadId: z.string(),
|
|
215
|
-
});
|
|
216
213
|
export const waitpointsCancelInput = z.object({
|
|
217
214
|
waitpointId: z.string().min(1),
|
|
218
215
|
});
|
|
@@ -227,7 +224,6 @@ export const scheduleActionInput = z.object({
|
|
|
227
224
|
const scheduleTargetInput = z.union([
|
|
228
225
|
z.object({ kind: z.literal('fresh') }),
|
|
229
226
|
z.object({ kind: z.literal('project'), projectId: z.string() }),
|
|
230
|
-
z.object({ kind: z.literal('thread'), threadId: z.string(), channel: z.string() }),
|
|
231
227
|
]);
|
|
232
228
|
// schedules.add (DR-0018 §2.1 7c). Field-level zod + per-type required-field superRefine so the
|
|
233
229
|
// router rejects malformed input before the handler runs. intervalMs/delay are raw ms; dayOfWeek 0..6.
|
|
@@ -242,7 +238,6 @@ export const scheduleAddInput = z
|
|
|
242
238
|
dayOfWeek: z.number().int().min(0).max(6).optional(),
|
|
243
239
|
delay: z.number().int().positive().optional(),
|
|
244
240
|
target: scheduleTargetInput.optional(),
|
|
245
|
-
fallback: z.enum(['fresh', 'skip', 'wait']).optional(),
|
|
246
241
|
})
|
|
247
242
|
.superRefine((val, ctx) => {
|
|
248
243
|
if (val.type === 'interval' && val.intervalMs === undefined) {
|
|
@@ -275,20 +270,6 @@ export const scheduleUpdateInput = z.object({
|
|
|
275
270
|
time: z.string().regex(/^\d{2}:\d{2}$/).optional(),
|
|
276
271
|
dayOfWeek: z.number().int().min(0).max(6).optional(),
|
|
277
272
|
});
|
|
278
|
-
export const taskActionInput = z.object({
|
|
279
|
-
projectId: z.string(),
|
|
280
|
-
taskId: z.string(),
|
|
281
|
-
});
|
|
282
|
-
export const taskCompleteInput = z.object({
|
|
283
|
-
projectId: z.string(),
|
|
284
|
-
taskId: z.string(),
|
|
285
|
-
note: z.string().optional(),
|
|
286
|
-
});
|
|
287
|
-
export const taskBlockInput = z.object({
|
|
288
|
-
projectId: z.string(),
|
|
289
|
-
taskId: z.string(),
|
|
290
|
-
reason: z.string(),
|
|
291
|
-
});
|
|
292
273
|
const FORBIDDEN_PROVIDER_KEYS = new Set(['__proto__', 'prototype', 'constructor']);
|
|
293
274
|
const MAX_PROVIDER_KEY_LENGTH = 120;
|
|
294
275
|
const settingTypeSchemas = {
|
|
@@ -465,24 +446,13 @@ const componentByteLength = (value) => new TextEncoder().encode(value).byteLengt
|
|
|
465
446
|
const isSafeComponent = (value) => value !== '.' && value !== '..'
|
|
466
447
|
&& !value.includes('/') && !value.includes('\\') && !value.includes('\0');
|
|
467
448
|
const pluginTargetName = z.string().max(240).regex(/^[A-Za-z0-9][A-Za-z0-9_-]*$/);
|
|
468
|
-
const pluginSlotRef = z.string().max(240).regex(/^(?:__active__|[A-Za-z0-9][A-Za-z0-9_-]*)$/);
|
|
469
449
|
const pluginIdInput = z.string().min(1).refine(componentByteLength).refine(isSafeComponent);
|
|
470
450
|
const sha256HashInput = z.string().regex(/^[a-f0-9]{64}$/);
|
|
471
|
-
const pluginsAssignTargetInput = z.
|
|
472
|
-
z.
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
}),
|
|
477
|
-
z.object({
|
|
478
|
-
kind: z.literal('template-slot'),
|
|
479
|
-
templateName: pluginTargetName,
|
|
480
|
-
index: z.number().int().min(0),
|
|
481
|
-
ref: pluginSlotRef,
|
|
482
|
-
baseHash: sha256HashInput,
|
|
483
|
-
mode: z.enum(['inherit', 'custom']),
|
|
484
|
-
}),
|
|
485
|
-
]);
|
|
451
|
+
const pluginsAssignTargetInput = z.object({
|
|
452
|
+
kind: z.literal('agent'),
|
|
453
|
+
name: pluginTargetName,
|
|
454
|
+
baseHash: sha256HashInput,
|
|
455
|
+
});
|
|
486
456
|
export const pluginsAssignInput = z.object({
|
|
487
457
|
target: pluginsAssignTargetInput,
|
|
488
458
|
pluginIds: z.array(pluginIdInput),
|
|
@@ -531,29 +501,24 @@ export const pluginsMcpWriteInput = z.object({
|
|
|
531
501
|
headers: pluginSecretPatch.optional(),
|
|
532
502
|
})).max(32),
|
|
533
503
|
});
|
|
534
|
-
//
|
|
535
|
-
//
|
|
536
|
-
//
|
|
537
|
-
const
|
|
538
|
-
const
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
export const threadTemplatesValidateInput = z.object({
|
|
544
|
-
kind: threadTemplateKind,
|
|
545
|
-
name: threadTemplateName,
|
|
504
|
+
// environments.get / validate / save / delete — the environment editing surface. The name pattern
|
|
505
|
+
// mirrors the environment writer's: the filename IS the identity, so anything that could escape the
|
|
506
|
+
// config directory is rejected before it reaches the writer.
|
|
507
|
+
const environmentName = z.string().regex(/^[A-Za-z0-9][A-Za-z0-9_-]*$/);
|
|
508
|
+
export const environmentsGetInput = z.object({
|
|
509
|
+
name: environmentName,
|
|
510
|
+
});
|
|
511
|
+
export const environmentsValidateInput = z.object({
|
|
512
|
+
name: environmentName,
|
|
546
513
|
body: z.record(z.string(), z.unknown()),
|
|
547
514
|
});
|
|
548
|
-
export const
|
|
549
|
-
|
|
550
|
-
name: threadTemplateName,
|
|
515
|
+
export const environmentsSaveInput = z.object({
|
|
516
|
+
name: environmentName,
|
|
551
517
|
body: z.record(z.string(), z.unknown()),
|
|
552
518
|
baseHash: z.string().optional(),
|
|
553
519
|
});
|
|
554
|
-
export const
|
|
555
|
-
|
|
556
|
-
name: threadTemplateName,
|
|
520
|
+
export const environmentsDeleteInput = z.object({
|
|
521
|
+
name: environmentName,
|
|
557
522
|
});
|
|
558
523
|
export const approvalsApproveInput = z.object({
|
|
559
524
|
id: z.string(),
|
|
@@ -628,10 +593,6 @@ export const queryInputSchemas = {
|
|
|
628
593
|
'sessions.subagentTranscript': sessionsSubagentTranscriptInput,
|
|
629
594
|
'sessions.debugDetails': sessionsDebugDetailsInput,
|
|
630
595
|
'sessions.pendingInteraction': sessionsPendingInteractionInput,
|
|
631
|
-
'threads.list': threadsListInput,
|
|
632
|
-
'threads.get': threadsGetInput,
|
|
633
|
-
'tasks.list': tasksListInput,
|
|
634
|
-
'tasks.verification': taskVerificationInput,
|
|
635
596
|
'schedules.list': schedulesListInput,
|
|
636
597
|
'commissions.list': commissionsListInput,
|
|
637
598
|
'commissions.get': commissionsGetInput,
|
|
@@ -657,8 +618,8 @@ export const queryInputSchemas = {
|
|
|
657
618
|
'plugins.list': pluginsListInput,
|
|
658
619
|
'plugins.skillFile': pluginsSkillFileInput,
|
|
659
620
|
'plugins.mcpRead': pluginsMcpReadInput,
|
|
660
|
-
'
|
|
661
|
-
'
|
|
621
|
+
'environments.list': environmentsListInput,
|
|
622
|
+
'environments.get': environmentsGetInput,
|
|
662
623
|
'system.daemonStatus': systemDaemonStatusInput,
|
|
663
624
|
'system.rateLimitStatus': systemRateLimitStatusInput,
|
|
664
625
|
'system.usageStatus': systemUsageStatusInput,
|
|
@@ -685,7 +646,6 @@ export const mutateInputSchemas = {
|
|
|
685
646
|
'sessions.respondDecision': sessionsRespondDecisionInput,
|
|
686
647
|
'sessions.cancelResume': sessionsCancelResumeInput,
|
|
687
648
|
'sessions.rewind': sessionsRewindInput,
|
|
688
|
-
'threads.cancel': threadsCancelInput,
|
|
689
649
|
'executions.cancel': executionsCancelInput,
|
|
690
650
|
'waitpoints.cancel': waitpointsCancelInput,
|
|
691
651
|
'schedules.pause': scheduleActionInput,
|
|
@@ -694,11 +654,6 @@ export const mutateInputSchemas = {
|
|
|
694
654
|
'schedules.add': scheduleAddInput,
|
|
695
655
|
'schedules.update': scheduleUpdateInput,
|
|
696
656
|
'commissions.close': commissionCloseInput,
|
|
697
|
-
'tasks.claim': taskActionInput,
|
|
698
|
-
'tasks.unclaim': taskActionInput,
|
|
699
|
-
'tasks.complete': taskCompleteInput,
|
|
700
|
-
'tasks.block': taskBlockInput,
|
|
701
|
-
'tasks.unblock': taskActionInput,
|
|
702
657
|
'approvals.approve': approvalsApproveInput,
|
|
703
658
|
'approvals.reject': approvalsRejectInput,
|
|
704
659
|
'approvals.request': approvalsRequestInput,
|
|
@@ -736,9 +691,9 @@ export const mutateInputSchemas = {
|
|
|
736
691
|
'plugins.remove': pluginsRemoveInput,
|
|
737
692
|
'plugins.convertToPortable': pluginsConvertInput,
|
|
738
693
|
'plugins.mcpWrite': pluginsMcpWriteInput,
|
|
739
|
-
'
|
|
740
|
-
'
|
|
741
|
-
'
|
|
694
|
+
'environments.validate': environmentsValidateInput,
|
|
695
|
+
'environments.save': environmentsSaveInput,
|
|
696
|
+
'environments.delete': environmentsDeleteInput,
|
|
742
697
|
'system.restart': systemRestartInput,
|
|
743
698
|
'system.clearRateLimit': systemClearRateLimitInput,
|
|
744
699
|
'system.refreshUsage': systemRefreshUsageInput,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Issue } from '../../agents/environments/index.js';
|
|
2
|
+
import type { EnvironmentsDeleteArgs, EnvironmentsDeleteReturn, EnvironmentsSaveArgs, EnvironmentsSaveReturn, EnvironmentsValidateArgs, EnvironmentsValidateReturn, Result, UiServiceDeps } from '../types.js';
|
|
3
|
+
/** Validate an environment body without writing anything. */
|
|
4
|
+
export declare function validateEnvironmentBody(name: string, body: unknown): {
|
|
5
|
+
ok: boolean;
|
|
6
|
+
errors: Issue[];
|
|
7
|
+
warnings: Issue[];
|
|
8
|
+
};
|
|
9
|
+
/** Create or replace one environment, then reload the registry so the next turn already runs it
|
|
10
|
+
* (the directory watcher would get there too; a second load is idempotent). */
|
|
11
|
+
export declare function saveEnvironmentBody(name: string, body: unknown, baseHash: string | null, dir?: string): {
|
|
12
|
+
changed: boolean;
|
|
13
|
+
sha256: string;
|
|
14
|
+
warnings: Issue[];
|
|
15
|
+
};
|
|
16
|
+
/** Delete one environment. The fallback environment is what every conversation resolves to when
|
|
17
|
+
* nothing names another, so it is never deleted. */
|
|
18
|
+
export declare function removeEnvironmentFile(name: string, dir?: string): {
|
|
19
|
+
removed: boolean;
|
|
20
|
+
};
|
|
21
|
+
export declare function handleEnvironmentsValidate(_deps: UiServiceDeps, args: EnvironmentsValidateArgs): Promise<Result<EnvironmentsValidateReturn>>;
|
|
22
|
+
export declare function handleEnvironmentsSave(_deps: UiServiceDeps, args: EnvironmentsSaveArgs): Promise<Result<EnvironmentsSaveReturn>>;
|
|
23
|
+
export declare function handleEnvironmentsDelete(_deps: UiServiceDeps, args: EnvironmentsDeleteArgs): Promise<Result<EnvironmentsDeleteReturn>>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { t } from '../../../core/i18n.js';
|
|
2
|
+
import { ENVIRONMENTS_DIR, FALLBACK_ENVIRONMENT, fsRefResolver, loadEnvironments, removeEnvironment, saveEnvironment, validateEnvironment, } from '../../agents/environments/index.js';
|
|
3
|
+
import { fail, toErr } from './errors.js';
|
|
4
|
+
/** Validate an environment body without writing anything. */
|
|
5
|
+
export function validateEnvironmentBody(name, body) {
|
|
6
|
+
const { errors, warnings } = validateEnvironment(name, body, fsRefResolver());
|
|
7
|
+
return { ok: errors.length === 0, errors, warnings };
|
|
8
|
+
}
|
|
9
|
+
/** Create or replace one environment, then reload the registry so the next turn already runs it
|
|
10
|
+
* (the directory watcher would get there too; a second load is idempotent). */
|
|
11
|
+
export function saveEnvironmentBody(name, body, baseHash, dir = ENVIRONMENTS_DIR) {
|
|
12
|
+
const result = saveEnvironment(dir, { name, body, baseHash }, fsRefResolver());
|
|
13
|
+
if (result.changed)
|
|
14
|
+
loadEnvironments(dir);
|
|
15
|
+
return { changed: result.changed, sha256: result.sha256, warnings: result.warnings };
|
|
16
|
+
}
|
|
17
|
+
/** Delete one environment. The fallback environment is what every conversation resolves to when
|
|
18
|
+
* nothing names another, so it is never deleted. */
|
|
19
|
+
export function removeEnvironmentFile(name, dir = ENVIRONMENTS_DIR) {
|
|
20
|
+
if (name === FALLBACK_ENVIRONMENT) {
|
|
21
|
+
throw fail('invalid-args', t('ux.env.mainUndeletable', { name }));
|
|
22
|
+
}
|
|
23
|
+
const result = removeEnvironment(dir, name);
|
|
24
|
+
if (result.removed)
|
|
25
|
+
loadEnvironments(dir);
|
|
26
|
+
return { removed: result.removed };
|
|
27
|
+
}
|
|
28
|
+
export async function handleEnvironmentsValidate(_deps, args) {
|
|
29
|
+
try {
|
|
30
|
+
return { ok: true, data: validateEnvironmentBody(args.name, args.body) };
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
return toErr(error);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export async function handleEnvironmentsSave(_deps, args) {
|
|
37
|
+
try {
|
|
38
|
+
return { ok: true, data: saveEnvironmentBody(args.name, args.body, args.baseHash ?? null) };
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
return toErr(error);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export async function handleEnvironmentsDelete(_deps, args) {
|
|
45
|
+
try {
|
|
46
|
+
return { ok: true, data: removeEnvironmentFile(args.name) };
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
return toErr(error);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -39,17 +39,11 @@ export async function handlePluginsCreate(_deps, args) {
|
|
|
39
39
|
return { id: args.id };
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
/** Every
|
|
43
|
-
*
|
|
42
|
+
/** Every environment that still points at this plugin. Removing a referenced plugin would leave a
|
|
43
|
+
* dangling pluginDirs entry that only shows up as a missing skill at spawn time. */
|
|
44
44
|
async function pluginReferences(deps, id) {
|
|
45
45
|
const { targets } = await handlePluginsList(deps, {});
|
|
46
|
-
return targets.
|
|
47
|
-
if (target.kind === 'template-shell')
|
|
48
|
-
return [];
|
|
49
|
-
if (!target.managedPluginIds.includes(id))
|
|
50
|
-
return [];
|
|
51
|
-
return [target.kind === 'agent' ? target.name : `${target.templateName}[${target.index}]`];
|
|
52
|
-
});
|
|
46
|
+
return targets.filter((target) => target.managedPluginIds.includes(id)).map((target) => target.name);
|
|
53
47
|
}
|
|
54
48
|
export async function handlePluginsRemove(deps, args) {
|
|
55
49
|
return guarded(async () => {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { t } from '../../../core/i18n.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { addedInvalidPluginIds, addedMcpPluginIds, canonicalManagedPluginDirs, normalizePluginDirs, normalizedDesiredPluginIds, pluginDirsOf, readPluginCatalogSnapshot, refName, samePluginIds, } from '../plugins-shared.js';
|
|
2
|
+
import { ENVIRONMENTS_DIR, readEnvironment } from '../../agents/environments/index.js';
|
|
3
|
+
import { saveEnvironmentBody } from './environments.js';
|
|
4
|
+
import { addedInvalidPluginIds, addedMcpPluginIds, canonicalManagedPluginDirs, normalizePluginDirs, normalizedDesiredPluginIds, readPluginCatalogSnapshot, } from '../plugins-shared.js';
|
|
6
5
|
import { fail, toErr } from './errors.js';
|
|
7
6
|
function requireDesiredPluginIds(currentIds, pluginIds, snapshot) {
|
|
8
7
|
const desired = normalizedDesiredPluginIds(pluginIds);
|
|
@@ -17,17 +16,9 @@ function requireMcpAck(currentIds, desiredIds, acknowledgeMcp, snapshot) {
|
|
|
17
16
|
throw fail('invalid-args', `Adding MCP-bearing plugins requires acknowledgeMcp: true (${added.join(', ')})`);
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
|
-
function saveWithReload(kind, name, body, baseHash) {
|
|
21
|
-
const result = saveEntity(CONFIG_TEMPLATES_DIR, { kind, name, body, baseHash }, loaderRefResolver());
|
|
22
|
-
if (result.changed)
|
|
23
|
-
loadConfig();
|
|
24
|
-
return { changed: result.changed, baseHash: result.sha256 };
|
|
25
|
-
}
|
|
26
19
|
function assignAgentPlugins(args) {
|
|
27
|
-
if (args.target.kind !== 'agent')
|
|
28
|
-
throw fail('invalid-args', 'agent target required');
|
|
29
20
|
const snapshot = readPluginCatalogSnapshot();
|
|
30
|
-
const entity =
|
|
21
|
+
const entity = readEnvironment(ENVIRONMENTS_DIR, args.target.name);
|
|
31
22
|
if (!entity.body)
|
|
32
23
|
throw fail('invalid-args', `Agent '${args.target.name}' is not a JSON object`);
|
|
33
24
|
const current = normalizePluginDirs(entity.body.pluginDirs, snapshot);
|
|
@@ -39,105 +30,12 @@ function assignAgentPlugins(args) {
|
|
|
39
30
|
next.pluginDirs = pluginDirs;
|
|
40
31
|
else
|
|
41
32
|
delete next.pluginDirs;
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
function requireTemplateBody(entity, templateName) {
|
|
45
|
-
if (!entity.body)
|
|
46
|
-
throw fail('invalid-args', `Template '${templateName}' is not a JSON object`);
|
|
47
|
-
return entity.body;
|
|
48
|
-
}
|
|
49
|
-
function requireTemplateRefs(body, templateName) {
|
|
50
|
-
if (isShellBinding(body))
|
|
51
|
-
throw fail('invalid-args', t('ui.plugin.shellBinding', { name: templateName }));
|
|
52
|
-
const refs = Array.isArray(body.agents) ? body.agents : null;
|
|
53
|
-
if (!refs)
|
|
54
|
-
throw fail('invalid-args', `Template '${templateName}' has no agents array`);
|
|
55
|
-
return refs;
|
|
56
|
-
}
|
|
57
|
-
function requireSlotIndex(refs, target) {
|
|
58
|
-
if (target.index < 0 || target.index >= refs.length) {
|
|
59
|
-
throw fail('invalid-args', `Template '${target.templateName}' has no slot ${target.index}`);
|
|
60
|
-
}
|
|
61
|
-
return refs[target.index];
|
|
62
|
-
}
|
|
63
|
-
function templateSlot(entity, target) {
|
|
64
|
-
if (entity.sha256 !== target.baseHash)
|
|
65
|
-
throw fail('conflict', `template '${target.templateName}' changed on disk`);
|
|
66
|
-
const body = requireTemplateBody(entity, target.templateName);
|
|
67
|
-
const refs = requireTemplateRefs(body, target.templateName);
|
|
68
|
-
return { body, refs, current: requireSlotIndex(refs, target) };
|
|
69
|
-
}
|
|
70
|
-
function inheritedState(ref, snapshot) {
|
|
71
|
-
const registry = readRawRegistry(CONFIG_TEMPLATES_DIR);
|
|
72
|
-
return normalizePluginDirs(pluginDirsOf(registry.agents[ref]), snapshot);
|
|
73
|
-
}
|
|
74
|
-
function slotState(slot, ref, snapshot) {
|
|
75
|
-
if (Array.isArray(pluginDirsOf(slot)))
|
|
76
|
-
return normalizePluginDirs(pluginDirsOf(slot), snapshot);
|
|
77
|
-
return inheritedState(ref, snapshot);
|
|
78
|
-
}
|
|
79
|
-
function nextCustomSlot(slot, ref, managedIds, unmanaged) {
|
|
80
|
-
const pluginDirs = [...canonicalManagedPluginDirs(managedIds), ...unmanaged];
|
|
81
|
-
if (typeof slot === 'string')
|
|
82
|
-
return { ref, pluginDirs };
|
|
83
|
-
return { ...slot, ref, pluginDirs };
|
|
84
|
-
}
|
|
85
|
-
function nextInheritedSlot(slot) {
|
|
86
|
-
if (typeof slot === 'string')
|
|
87
|
-
return slot;
|
|
88
|
-
const next = { ...slot };
|
|
89
|
-
delete next.pluginDirs;
|
|
90
|
-
return next;
|
|
91
|
-
}
|
|
92
|
-
function writeInheritedSlot(current, ref, desired, inherited) {
|
|
93
|
-
if (!samePluginIds(desired, inherited.managedIds)) {
|
|
94
|
-
throw fail('invalid-args', `inherit mode for '${ref}' must match the agent's current managed plugins`);
|
|
95
|
-
}
|
|
96
|
-
return nextInheritedSlot(current);
|
|
97
|
-
}
|
|
98
|
-
function requireAssignableSlotRef(current, target) {
|
|
99
|
-
const ref = refName(current);
|
|
100
|
-
if (ref !== target.ref)
|
|
101
|
-
throw fail('invalid-args', t('ui.plugin.slotRefChanged', { index: target.index, ref: target.ref }));
|
|
102
|
-
if (ref === '__active__')
|
|
103
|
-
throw fail('invalid-args', t('ui.plugin.slotReadOnly', { index: target.index }));
|
|
104
|
-
if (!ref)
|
|
105
|
-
throw fail('invalid-args', t('ui.plugin.slotNotAssignable', { index: target.index }));
|
|
106
|
-
return ref;
|
|
107
|
-
}
|
|
108
|
-
function allowedSlotPluginIds(mode, current, inherited) {
|
|
109
|
-
return mode === 'inherit' ? inherited.managedIds : current.managedIds;
|
|
110
|
-
}
|
|
111
|
-
function nextSlotValue(mode, current, ref, desired, currentState, inherited) {
|
|
112
|
-
return mode === 'custom'
|
|
113
|
-
? nextCustomSlot(current, ref, desired, currentState.unmanaged)
|
|
114
|
-
: writeInheritedSlot(current, ref, desired, inherited);
|
|
115
|
-
}
|
|
116
|
-
function saveTemplateSlot(target, slot, next) {
|
|
117
|
-
const body = { ...slot.body, agents: [...slot.refs] };
|
|
118
|
-
body.agents[target.index] = next;
|
|
119
|
-
return saveWithReload('template', target.templateName, body, target.baseHash);
|
|
120
|
-
}
|
|
121
|
-
function assignTemplateSlotPlugins(args) {
|
|
122
|
-
if (args.target.kind !== 'template-slot')
|
|
123
|
-
throw fail('invalid-args', 'template-slot target required');
|
|
124
|
-
const snapshot = readPluginCatalogSnapshot();
|
|
125
|
-
const slot = templateSlot(readEntity(CONFIG_TEMPLATES_DIR, 'template', args.target.templateName), args.target);
|
|
126
|
-
const ref = requireAssignableSlotRef(slot.current, args.target);
|
|
127
|
-
const current = slotState(slot.current, ref, snapshot);
|
|
128
|
-
const inherited = inheritedState(ref, snapshot);
|
|
129
|
-
const desired = requireDesiredPluginIds(allowedSlotPluginIds(args.target.mode, current, inherited), args.pluginIds, snapshot);
|
|
130
|
-
requireMcpAck(current.managedIds, desired, args.acknowledgeMcp, snapshot);
|
|
131
|
-
return saveTemplateSlot(args.target, slot, nextSlotValue(args.target.mode, slot.current, ref, desired, current, inherited));
|
|
33
|
+
const saved = saveEnvironmentBody(args.target.name, next, args.target.baseHash);
|
|
34
|
+
return { changed: saved.changed, baseHash: saved.sha256 };
|
|
132
35
|
}
|
|
133
36
|
export async function handlePluginsAssign(_deps, args) {
|
|
134
37
|
try {
|
|
135
|
-
return {
|
|
136
|
-
ok: true,
|
|
137
|
-
data: args.target.kind === 'agent'
|
|
138
|
-
? assignAgentPlugins(args)
|
|
139
|
-
: assignTemplateSlotPlugins(args),
|
|
140
|
-
};
|
|
38
|
+
return { ok: true, data: assignAgentPlugins(args) };
|
|
141
39
|
}
|
|
142
40
|
catch (error) {
|
|
143
41
|
return toErr(error);
|
|
@@ -39,7 +39,7 @@ export async function handleRemoveSchedule(deps, args) {
|
|
|
39
39
|
// Create a schedule (DR-0018 §2.1 7c). Re-checks the per-type required fields (mirrors
|
|
40
40
|
// domain/mcp/tools/schedule.ts::runScheduleAdd) so a direct facade / unit call is rejected as an Err
|
|
41
41
|
// with nothing written; the zod router already rejects the same cases upstream. The injected
|
|
42
|
-
// deps.scheduler.add composes the real scheduler.add + schedule-repo backfill of target
|
|
42
|
+
// deps.scheduler.add composes the real scheduler.add + schedule-repo backfill of target.
|
|
43
43
|
export async function handleAddSchedule(deps, args) {
|
|
44
44
|
// Per-type required-field validation — return Err BEFORE calling add() so nothing is written.
|
|
45
45
|
if (args.type === 'interval' && args.intervalMs === undefined) {
|
|
@@ -68,7 +68,6 @@ export async function handleAddSchedule(deps, args) {
|
|
|
68
68
|
dayOfWeek: args.dayOfWeek,
|
|
69
69
|
delay: args.delay,
|
|
70
70
|
target: args.target,
|
|
71
|
-
fallback: args.fallback,
|
|
72
71
|
});
|
|
73
72
|
return { ok: true, data: toScheduleInfo(task) };
|
|
74
73
|
}
|
|
@@ -9,8 +9,6 @@ export interface NormalizedPluginDirs {
|
|
|
9
9
|
managedIds: string[];
|
|
10
10
|
unmanaged: string[];
|
|
11
11
|
}
|
|
12
|
-
/** The agent name a template slot points at: a bare string or a `{ ref }` object. */
|
|
13
|
-
export declare function refName(ref: unknown): string | null;
|
|
14
12
|
export declare function pluginDirsOf(value: unknown): unknown;
|
|
15
13
|
export declare function readPluginCatalogSnapshot(): PluginCatalogSnapshot;
|
|
16
14
|
/** Whether Cortex ships this plugin id. Shipped files are rewritten by plugin-sync on the next
|
|
@@ -26,4 +24,3 @@ export declare function canonicalManagedPluginDirs(pluginIds: readonly string[])
|
|
|
26
24
|
export declare function normalizedDesiredPluginIds(pluginIds: readonly string[]): string[];
|
|
27
25
|
export declare function addedInvalidPluginIds(currentIds: readonly string[], desiredIds: readonly string[], snapshot: PluginCatalogSnapshot): string[];
|
|
28
26
|
export declare function addedMcpPluginIds(currentIds: readonly string[], desiredIds: readonly string[], snapshot: PluginCatalogSnapshot): string[];
|
|
29
|
-
export declare function samePluginIds(left: readonly string[], right: readonly string[]): boolean;
|
|
@@ -24,15 +24,6 @@ function isAssignable(entry) {
|
|
|
24
24
|
function isNonEmptyString(value) {
|
|
25
25
|
return typeof value === 'string' && value.length > 0;
|
|
26
26
|
}
|
|
27
|
-
/** The agent name a template slot points at: a bare string or a `{ ref }` object. */
|
|
28
|
-
export function refName(ref) {
|
|
29
|
-
if (typeof ref === 'string' && ref.length > 0)
|
|
30
|
-
return ref;
|
|
31
|
-
if (ref && typeof ref === 'object' && typeof ref.ref === 'string') {
|
|
32
|
-
return ref.ref;
|
|
33
|
-
}
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
27
|
export function pluginDirsOf(value) {
|
|
37
28
|
return value && typeof value === 'object' ? value.pluginDirs : undefined;
|
|
38
29
|
}
|
|
@@ -157,8 +148,3 @@ export function addedMcpPluginIds(currentIds, desiredIds, snapshot) {
|
|
|
157
148
|
return (snapshot.byId.get(id)?.mcp.servers.length ?? 0) > 0;
|
|
158
149
|
});
|
|
159
150
|
}
|
|
160
|
-
export function samePluginIds(left, right) {
|
|
161
|
-
const a = normalizedDesiredPluginIds(left);
|
|
162
|
-
const b = normalizedDesiredPluginIds(right);
|
|
163
|
-
return a.length === b.length && a.every((id, index) => id === b[index]);
|
|
164
|
-
}
|
|
@@ -6,6 +6,7 @@ import { getSettingsSnapshot } from '../../../core/settings.js';
|
|
|
6
6
|
import { getLocale } from '../../../core/i18n.js';
|
|
7
7
|
import { langSource } from '../../system/preferences.js';
|
|
8
8
|
import { loadMountedHookSummaries } from '../../../store/hook-registry.js';
|
|
9
|
+
import { ENVIRONMENTS_DIRNAME } from '../../agents/environments/paths.js';
|
|
9
10
|
const MASK = '••••••••';
|
|
10
11
|
async function readJson(file) {
|
|
11
12
|
try {
|
|
@@ -15,10 +16,10 @@ async function readJson(file) {
|
|
|
15
16
|
return null;
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
|
-
/** The
|
|
19
|
-
* environment is for and which profile it pins. Read
|
|
20
|
-
*
|
|
21
|
-
*
|
|
19
|
+
/** The execution environments (`config/environments/`), read as documents rather than filenames: a
|
|
20
|
+
* picker has to say what each environment is for and which profile it pins. Read under
|
|
21
|
+
* `configDir`, so the snapshot stays hermetic; a malformed file is skipped rather than failing the
|
|
22
|
+
* whole snapshot. */
|
|
22
23
|
async function readAgentEntries(dir, names) {
|
|
23
24
|
const entries = await Promise.all(names.map(async (name) => {
|
|
24
25
|
const raw = await readJson(path.join(dir, `${name}.json`));
|
|
@@ -156,25 +157,21 @@ async function readEnv(file) {
|
|
|
156
157
|
* or malformed source affects only its own field.
|
|
157
158
|
*/
|
|
158
159
|
export async function readConfigSnapshot(configDir, liveSettings, lang) {
|
|
159
|
-
const
|
|
160
|
-
const hooks = loadMountedHookSummaries(path.join(configDir, 'hooks'), path.join(tt, 'templates'));
|
|
160
|
+
const hooks = loadMountedHookSummaries(path.join(configDir, 'hooks'));
|
|
161
161
|
const parts = await Promise.all([
|
|
162
162
|
readJson(path.join(configDir, 'budget.json')),
|
|
163
163
|
readJson(path.join(configDir, 'profiles.json')),
|
|
164
164
|
readJson(path.join(configDir, 'machines.json')),
|
|
165
165
|
readJson(path.join(configDir, 'mcp-config.json')),
|
|
166
|
-
listJsonBasenames(path.join(tt, 'agents')),
|
|
167
|
-
listJsonBasenames(path.join(tt, 'templates')),
|
|
168
|
-
listJsonBasenames(path.join(tt, 'shells')),
|
|
169
166
|
readEnv(path.join(configDir, '.env')),
|
|
167
|
+
listJsonBasenames(path.join(configDir, ENVIRONMENTS_DIRNAME)),
|
|
170
168
|
]);
|
|
171
|
-
const [budget, profiles, machines, mcp,
|
|
172
|
-
const threadTemplates = { agents, templates, shells };
|
|
169
|
+
const [budget, profiles, machines, mcp, env, environments] = parts;
|
|
173
170
|
return {
|
|
174
171
|
platforms: await readPlatformSettings(path.join(configDir, '.env')),
|
|
175
172
|
budget: parseBudget(budget), profiles: parseProfiles(profiles), machines: parseMachines(machines),
|
|
176
|
-
mcp: parseMcp(mcp),
|
|
177
|
-
agents: await readAgentEntries(path.join(
|
|
173
|
+
mcp: parseMcp(mcp),
|
|
174
|
+
agents: await readAgentEntries(path.join(configDir, ENVIRONMENTS_DIRNAME), environments),
|
|
178
175
|
hooks, env, settings: liveSettings, lang,
|
|
179
176
|
};
|
|
180
177
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { EnvironmentDetail, EnvironmentEntry, EnvironmentOrigin, EnvironmentsGetParams, EnvironmentsListParams, UiServiceDeps } from '../types.js';
|
|
2
|
+
/** Relationship to the shipped environment of the same name. Defaults are copy-if-missing and never
|
|
3
|
+
* overwrite, so a user file that differs has forked from upstream permanently. */
|
|
4
|
+
export declare function classifyEnvironmentOrigin(name: string, content: string | null): Promise<EnvironmentOrigin>;
|
|
5
|
+
/** Every environment under `<configDir>/environments/` as an editor list entry, sorted by name, each
|
|
6
|
+
* with its validation verdict. Pure over configDir. */
|
|
7
|
+
export declare function readEnvironmentEntries(configDir: string): Promise<EnvironmentEntry[]>;
|
|
8
|
+
/** One environment as the editor opens it: raw body (so `file:` refs survive a round trip), hash,
|
|
9
|
+
* and validation verdict. */
|
|
10
|
+
export declare function readEnvironmentDetail(name: string, dir?: string): Promise<EnvironmentDetail>;
|
|
11
|
+
export declare function handleEnvironmentsList(_deps: UiServiceDeps, _params: EnvironmentsListParams): Promise<EnvironmentEntry[]>;
|
|
12
|
+
export declare function handleEnvironmentsGet(_deps: UiServiceDeps, params: EnvironmentsGetParams): Promise<EnvironmentDetail>;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { CONFIG_DIR } from '../../../core/paths.js';
|
|
4
|
+
import { DEFAULT_ENVIRONMENTS_DIR, ENVIRONMENTS_DIR, ENVIRONMENTS_DIRNAME, fsRefResolver, readEnvironment, validateEnvironment, } from '../../agents/environments/index.js';
|
|
5
|
+
/** Relationship to the shipped environment of the same name. Defaults are copy-if-missing and never
|
|
6
|
+
* overwrite, so a user file that differs has forked from upstream permanently. */
|
|
7
|
+
export async function classifyEnvironmentOrigin(name, content) {
|
|
8
|
+
const stock = await fs.readFile(path.join(DEFAULT_ENVIRONMENTS_DIR, `${name}.json`), 'utf8').catch(() => null);
|
|
9
|
+
if (stock === null)
|
|
10
|
+
return 'custom';
|
|
11
|
+
return stock === content ? 'stock' : 'modified';
|
|
12
|
+
}
|
|
13
|
+
function descriptionOf(body) {
|
|
14
|
+
return body && typeof body.description === 'string' ? body.description : null;
|
|
15
|
+
}
|
|
16
|
+
/** Every environment under `<configDir>/environments/` as an editor list entry, sorted by name, each
|
|
17
|
+
* with its validation verdict. Pure over configDir. */
|
|
18
|
+
export async function readEnvironmentEntries(configDir) {
|
|
19
|
+
const dir = path.join(configDir, ENVIRONMENTS_DIRNAME);
|
|
20
|
+
let files;
|
|
21
|
+
try {
|
|
22
|
+
files = (await fs.readdir(dir)).filter((f) => f.endsWith('.json')).sort();
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
const refs = fsRefResolver();
|
|
28
|
+
return Promise.all(files.map(async (file) => {
|
|
29
|
+
const name = file.slice(0, -'.json'.length);
|
|
30
|
+
const content = await fs.readFile(path.join(dir, file), 'utf8').catch(() => null);
|
|
31
|
+
let body = null;
|
|
32
|
+
try {
|
|
33
|
+
const parsed = content === null ? null : JSON.parse(content);
|
|
34
|
+
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed))
|
|
35
|
+
body = parsed;
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
body = null;
|
|
39
|
+
}
|
|
40
|
+
const errorCount = validateEnvironment(name, body, refs).errors.length;
|
|
41
|
+
return {
|
|
42
|
+
name,
|
|
43
|
+
description: descriptionOf(body),
|
|
44
|
+
body,
|
|
45
|
+
valid: errorCount === 0,
|
|
46
|
+
errorCount,
|
|
47
|
+
origin: await classifyEnvironmentOrigin(name, content),
|
|
48
|
+
};
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
/** One environment as the editor opens it: raw body (so `file:` refs survive a round trip), hash,
|
|
52
|
+
* and validation verdict. */
|
|
53
|
+
export async function readEnvironmentDetail(name, dir = ENVIRONMENTS_DIR) {
|
|
54
|
+
const entity = readEnvironment(dir, name);
|
|
55
|
+
const { errors, warnings } = validateEnvironment(name, entity.body, fsRefResolver());
|
|
56
|
+
return {
|
|
57
|
+
name,
|
|
58
|
+
description: descriptionOf(entity.body),
|
|
59
|
+
body: entity.body,
|
|
60
|
+
filePath: entity.filePath,
|
|
61
|
+
origin: await classifyEnvironmentOrigin(name, entity.content),
|
|
62
|
+
sha256: entity.sha256,
|
|
63
|
+
errors,
|
|
64
|
+
warnings,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
export async function handleEnvironmentsList(_deps, _params) {
|
|
68
|
+
return readEnvironmentEntries(CONFIG_DIR);
|
|
69
|
+
}
|
|
70
|
+
export async function handleEnvironmentsGet(_deps, params) {
|
|
71
|
+
return readEnvironmentDetail(params.name);
|
|
72
|
+
}
|
|
@@ -45,7 +45,7 @@ export async function handleExecutionsGet(deps, params) {
|
|
|
45
45
|
status: e.status,
|
|
46
46
|
projectId: e.project ?? null,
|
|
47
47
|
sessionId: e.session?.sessionId ?? null,
|
|
48
|
-
threadId:
|
|
48
|
+
threadId: null,
|
|
49
49
|
runtime: {
|
|
50
50
|
startedAt: e.runtime?.startedAt ?? '',
|
|
51
51
|
updatedAt: e.runtime?.updatedAt ?? '',
|
|
@@ -3,5 +3,5 @@ import type { UiServiceDeps, HooksListParams, HooksOverview } from '../types.js'
|
|
|
3
3
|
* Build the hooks overview from explicit directories. Pure over its arguments (no global paths) so
|
|
4
4
|
* it is hermetically testable against fixtures, mirroring `readConfigSnapshot`.
|
|
5
5
|
*/
|
|
6
|
-
export declare function readHooksOverview(registryDir: string,
|
|
6
|
+
export declare function readHooksOverview(registryDir: string, scriptsDir: string): HooksOverview;
|
|
7
7
|
export declare function handleHooksList(_deps: UiServiceDeps, _params: HooksListParams): Promise<HooksOverview>;
|