vgxness 1.20.4 → 1.20.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/dist/adapters/claude/agent-renderer.js +82 -0
- package/dist/{mcp → adapters/claude/install}/claude-code-agent-config.js +64 -9
- package/dist/{mcp → adapters/claude/install}/claude-code-config.js +28 -6
- package/dist/{mcp → adapters/claude/install}/claude-code-project-memory.js +35 -5
- package/dist/{mcp → adapters/claude/install}/claude-code-scope.js +12 -3
- package/dist/{mcp → adapters/claude/install}/claude-code-user-config.js +26 -5
- package/dist/{mcp → adapters/claude/install}/claude-code-user-memory.js +47 -7
- package/dist/{mcp → adapters/claude/install}/client-install-claude-code-contract.js +45 -8
- package/dist/{mcp → adapters/claude/install}/client-install-claude-code.js +98 -14
- package/dist/adapters/json/agent-renderer.js +104 -0
- package/dist/adapters/opencode/agent-renderer.js +113 -0
- package/dist/{mcp → adapters/opencode/install}/client-install-opencode-contract.js +2 -2
- package/dist/{mcp → adapters/opencode/install}/client-install-opencode.js +1 -1
- package/dist/{mcp → adapters/opencode/install}/opencode-default-agent-config.js +2 -2
- package/dist/{mcp → adapters/opencode/install}/opencode-handoff-preview.js +60 -7
- package/dist/{mcp → adapters/opencode/install}/opencode-visibility.js +1 -1
- package/dist/adapters/provider-renderer.js +6 -0
- package/dist/agents/agent-activation-service.js +1 -263
- package/dist/agents/agent-lookup-contexts.js +1 -28
- package/dist/agents/agent-registry-service.js +1 -81
- package/dist/agents/agent-resolver.js +1 -287
- package/dist/agents/agent-seed-service.js +1 -157
- package/dist/agents/agent-seed-upgrade-service.js +1 -231
- package/dist/agents/agent-selector-resolver.js +1 -28
- package/dist/agents/boot-upgrade.js +1 -59
- package/dist/agents/canonical-agent-manifest.js +1 -245
- package/dist/agents/canonical-agent-projection.js +1 -236
- package/dist/agents/manager-profile-overlay-service.js +1 -60
- package/dist/agents/profile-model-routing.js +1 -30
- package/dist/agents/renderers/claude-renderer.js +1 -82
- package/dist/agents/renderers/index.js +1 -14
- package/dist/agents/renderers/json-renderer.js +1 -104
- package/dist/agents/renderers/opencode-renderer.js +1 -113
- package/dist/agents/renderers/provider-adapter.js +1 -6
- package/dist/agents/repositories/agent-seed-history.js +1 -128
- package/dist/agents/repositories/agents.js +1 -200
- package/dist/agents/repositories/manager-profile-overlays.js +1 -90
- package/dist/agents/schema.js +1 -1
- package/dist/application/agents/agent-activation-service.js +261 -0
- package/dist/application/agents/agent-lookup-contexts.js +28 -0
- package/dist/application/agents/agent-registry-service.js +81 -0
- package/dist/application/agents/agent-resolver.js +287 -0
- package/dist/application/agents/agent-seed-service.js +157 -0
- package/dist/application/agents/agent-seed-upgrade-service.js +231 -0
- package/dist/application/agents/agent-selector-resolver.js +28 -0
- package/dist/application/agents/boot-upgrade.js +59 -0
- package/dist/application/agents/canonical-agent-projection.js +236 -0
- package/dist/application/agents/manager-profile-overlay-service.js +68 -0
- package/dist/application/agents/profile-model-routing.js +30 -0
- package/dist/application/agents/renderers/claude-renderer.js +1 -0
- package/dist/application/agents/renderers/index.js +14 -0
- package/dist/application/agents/renderers/json-renderer.js +1 -0
- package/dist/application/agents/renderers/opencode-renderer.js +1 -0
- package/dist/application/agents/renderers/provider-adapter.js +1 -0
- package/dist/application/memory/active-work-preview.js +75 -0
- package/dist/application/memory/agent-memory-capture-service.js +498 -0
- package/dist/application/memory/import/dry-run-planner.js +58 -0
- package/dist/application/memory/import/index.js +3 -0
- package/dist/application/memory/import/observation-writer.js +226 -0
- package/dist/application/memory/import/package.js +179 -0
- package/dist/application/memory/memory-service.js +202 -0
- package/dist/application/memory/search.js +11 -0
- package/dist/{mcp → application/provider-setup}/provider-change-plan.js +74 -13
- package/dist/{mcp → application/provider-setup}/provider-doctor.js +201 -31
- package/dist/{mcp → application/provider-setup}/provider-health-types.js +1 -1
- package/dist/{mcp → application/provider-setup}/provider-status.js +170 -33
- package/dist/application/runs/execution-planning.js +180 -0
- package/dist/application/runs/operation-execution.js +1 -0
- package/dist/application/runs/operation-retry.js +129 -0
- package/dist/application/runs/resume-after-approval-result.js +88 -0
- package/dist/application/runs/run-insights.js +270 -0
- package/dist/application/runs/run-service.js +1480 -0
- package/dist/application/runs/run-snapshot-export-service.js +31 -0
- package/dist/application/runs/sandbox-process-execution.js +244 -0
- package/dist/application/runs/sandbox-worktree-planning.js +59 -0
- package/dist/application/runs/task-scoped-command-grant-service.js +224 -0
- package/dist/application/sdd/artifact-portability-service.js +137 -0
- package/dist/application/sdd/cockpit-read-model.js +195 -0
- package/dist/application/sdd/sdd-continuation-plan.js +265 -0
- package/dist/application/sdd/sdd-workflow-service.js +892 -0
- package/dist/application/skills/boot-seed.js +42 -0
- package/dist/application/skills/personal-skills.js +41 -0
- package/dist/application/skills/skill-export-service.js +34 -0
- package/dist/application/skills/skill-index-service.js +126 -0
- package/dist/application/skills/skill-payload.js +186 -0
- package/dist/application/skills/skill-registry-service.js +648 -0
- package/dist/application/skills/skill-resolver.js +368 -0
- package/dist/application/skills/skill-seed-service.js +242 -0
- package/dist/application/skills/skill-status-service.js +147 -0
- package/dist/cli/bun-bin.js +0 -0
- package/dist/cli/cli-flags.js +1 -387
- package/dist/cli/cli-help.js +1 -173
- package/dist/cli/cli-helpers.js +1 -77
- package/dist/cli/cli-types.js +1 -1
- package/dist/cli/commands/agent-skill-dispatcher.js +1 -700
- package/dist/cli/commands/index.js +1 -9
- package/dist/cli/commands/interactive-entrypoint-dispatcher.js +1 -14
- package/dist/cli/commands/mcp-dispatcher.js +1 -232
- package/dist/cli/commands/memory-sdd-dispatcher.js +1 -367
- package/dist/cli/commands/run-permission-dispatcher.js +1 -455
- package/dist/cli/commands/setup-dispatcher.js +1 -496
- package/dist/cli/commands/status-dispatcher.js +1 -130
- package/dist/cli/commands/verification-dispatcher.js +1 -47
- package/dist/cli/commands/workflow-dispatcher.js +1 -566
- package/dist/cli/dispatcher.js +1 -247
- package/dist/cli/doctor-renderer.js +1 -26
- package/dist/cli/home-tui-app.js +1 -411
- package/dist/cli/home-tui-controller.js +1 -314
- package/dist/cli/mcp-start-path.js +1 -21
- package/dist/cli/product-resume-renderer.js +1 -32
- package/dist/cli/product-status-renderer.js +1 -81
- package/dist/cli/sdd-renderer.js +1 -247
- package/dist/cli/setup-plan-renderer.js +1 -79
- package/dist/cli/setup-status-renderer.js +1 -50
- package/dist/cli/setup-tui-app.js +1 -130
- package/dist/cli/setup-tui-controller.js +1 -89
- package/dist/cli/tui/focus-reducer.js +1 -0
- package/dist/cli/tui/focus-types.js +1 -0
- package/dist/cli/tui/ink/app-shell.js +1 -0
- package/dist/cli/tui/ink/components.js +1 -38
- package/dist/cli/tui/ink/help-overlay.js +1 -0
- package/dist/cli/tui/ink/state-components.js +1 -0
- package/dist/cli/tui/ink/theme.js +1 -36
- package/dist/cli/tui/key-intents.js +1 -0
- package/dist/cli/tui/keymap.js +1 -20
- package/dist/cli/tui/navigation.js +1 -10
- package/dist/cli/tui/screen-registry.js +1 -0
- package/dist/cli/tui/terminal-capabilities.js +1 -12
- package/dist/cli/tui/tui-types.js +1 -1
- package/dist/cli/tui/visual/badges.js +1 -19
- package/dist/cli/tui/visual/footer.js +1 -27
- package/dist/cli/tui/visual/index.js +1 -3
- package/dist/cli/tui/visual/viewport.js +1 -11
- package/dist/cli/tui-render-helpers.js +1 -200
- package/dist/cli/verification-plan-renderer.js +1 -25
- package/dist/cli/verification-report-renderer.js +1 -19
- package/dist/domain/agents/canonical-agent-manifest.js +355 -0
- package/dist/domain/agents/schema.js +1 -0
- package/dist/domain/memory/active-work-topics.js +64 -0
- package/dist/domain/memory/memory-capture-schema.js +1 -0
- package/dist/domain/memory/schema.js +1 -0
- package/dist/domain/runs/schema.js +5 -0
- package/dist/domain/sdd/cockpit-types.js +1 -0
- package/dist/domain/sdd/schema.js +111 -0
- package/dist/domain/skills/schema.js +1 -0
- package/dist/governance/risk-classifier.js +2 -0
- package/dist/interfaces/cli/bun-bin.js +46 -0
- package/dist/interfaces/cli/cli-flags.js +391 -0
- package/dist/interfaces/cli/cli-help.js +173 -0
- package/dist/interfaces/cli/cli-helpers.js +77 -0
- package/dist/interfaces/cli/cli-types.js +1 -0
- package/dist/interfaces/cli/commands/agent-skill-dispatcher.js +700 -0
- package/dist/interfaces/cli/commands/index.js +9 -0
- package/dist/interfaces/cli/commands/interactive-entrypoint-dispatcher.js +14 -0
- package/dist/interfaces/cli/commands/mcp-dispatcher.js +252 -0
- package/dist/interfaces/cli/commands/memory-sdd-dispatcher.js +367 -0
- package/dist/interfaces/cli/commands/run-permission-dispatcher.js +460 -0
- package/dist/interfaces/cli/commands/setup-dispatcher.js +496 -0
- package/dist/interfaces/cli/commands/status-dispatcher.js +130 -0
- package/dist/interfaces/cli/commands/verification-dispatcher.js +47 -0
- package/dist/interfaces/cli/commands/workflow-dispatcher.js +566 -0
- package/dist/interfaces/cli/dispatcher.js +247 -0
- package/dist/interfaces/cli/doctor-renderer.js +26 -0
- package/dist/interfaces/cli/home-tui-app.js +462 -0
- package/dist/interfaces/cli/home-tui-controller.js +341 -0
- package/dist/interfaces/cli/index.js +27 -0
- package/dist/interfaces/cli/mcp-start-path.js +21 -0
- package/dist/interfaces/cli/product-resume-renderer.js +32 -0
- package/dist/interfaces/cli/product-status-renderer.js +81 -0
- package/dist/interfaces/cli/sdd-renderer.js +247 -0
- package/dist/interfaces/cli/setup-plan-renderer.js +79 -0
- package/dist/interfaces/cli/setup-status-renderer.js +50 -0
- package/dist/interfaces/cli/setup-tui-app.js +135 -0
- package/dist/interfaces/cli/setup-tui-controller.js +89 -0
- package/dist/interfaces/cli/tui/focus-reducer.js +60 -0
- package/dist/interfaces/cli/tui/focus-types.js +10 -0
- package/dist/interfaces/cli/tui/ink/app-shell.js +16 -0
- package/dist/interfaces/cli/tui/ink/components.js +38 -0
- package/dist/interfaces/cli/tui/ink/help-overlay.js +6 -0
- package/dist/interfaces/cli/tui/ink/state-components.js +22 -0
- package/dist/interfaces/cli/tui/ink/theme.js +36 -0
- package/dist/interfaces/cli/tui/key-intents.js +33 -0
- package/dist/interfaces/cli/tui/keymap.js +20 -0
- package/dist/interfaces/cli/tui/navigation.js +10 -0
- package/dist/interfaces/cli/tui/screen-registry.js +43 -0
- package/dist/interfaces/cli/tui/terminal-capabilities.js +12 -0
- package/dist/interfaces/cli/tui/tui-types.js +1 -0
- package/dist/interfaces/cli/tui/visual/badges.js +19 -0
- package/dist/interfaces/cli/tui/visual/footer.js +27 -0
- package/dist/interfaces/cli/tui/visual/index.js +3 -0
- package/dist/interfaces/cli/tui/visual/viewport.js +11 -0
- package/dist/interfaces/cli/tui-render-helpers.js +200 -0
- package/dist/interfaces/cli/verification-plan-renderer.js +25 -0
- package/dist/interfaces/cli/verification-report-renderer.js +19 -0
- package/dist/interfaces/mcp/contracts/agents.js +1 -0
- package/dist/interfaces/mcp/contracts/context.js +1 -0
- package/dist/interfaces/mcp/contracts/governance.js +1 -0
- package/dist/interfaces/mcp/contracts/index.js +1 -0
- package/dist/interfaces/mcp/contracts/memory.js +1 -0
- package/dist/interfaces/mcp/contracts/providers.js +1 -0
- package/dist/interfaces/mcp/contracts/runs.js +1 -0
- package/dist/interfaces/mcp/contracts/sdd.js +1 -0
- package/dist/interfaces/mcp/contracts/sessions.js +1 -0
- package/dist/interfaces/mcp/contracts/skills.js +1 -0
- package/dist/interfaces/mcp/contracts/verification.js +1 -0
- package/dist/interfaces/mcp/control-plane/handlers/agents.js +38 -0
- package/dist/interfaces/mcp/control-plane/handlers/context.js +12 -0
- package/dist/interfaces/mcp/control-plane/handlers/memory.js +95 -0
- package/dist/interfaces/mcp/control-plane/handlers/providers.js +19 -0
- package/dist/interfaces/mcp/control-plane/handlers/runs.js +134 -0
- package/dist/interfaces/mcp/control-plane/handlers/sdd.js +225 -0
- package/dist/interfaces/mcp/control-plane/handlers/sessions.js +39 -0
- package/dist/interfaces/mcp/control-plane/handlers/skills.js +82 -0
- package/dist/interfaces/mcp/control-plane/handlers/verification.js +11 -0
- package/dist/interfaces/mcp/control-plane/types.js +1 -0
- package/dist/interfaces/mcp/control-plane.js +235 -0
- package/dist/interfaces/mcp/schema.js +174 -0
- package/dist/interfaces/mcp/schemas/common.js +121 -0
- package/dist/interfaces/mcp/schemas/inputs/agents.js +69 -0
- package/dist/interfaces/mcp/schemas/inputs/context.js +32 -0
- package/dist/interfaces/mcp/schemas/inputs/governance.js +23 -0
- package/dist/interfaces/mcp/schemas/inputs/index.js +10 -0
- package/dist/interfaces/mcp/schemas/inputs/memory.js +50 -0
- package/dist/interfaces/mcp/schemas/inputs/providers.js +35 -0
- package/dist/interfaces/mcp/schemas/inputs/runs.js +146 -0
- package/dist/interfaces/mcp/schemas/inputs/sdd.js +102 -0
- package/dist/interfaces/mcp/schemas/inputs/sessions.js +32 -0
- package/dist/interfaces/mcp/schemas/inputs/skills.js +231 -0
- package/dist/interfaces/mcp/schemas/inputs/verification.js +9 -0
- package/dist/interfaces/mcp/schemas/outputs/index.js +2 -0
- package/dist/interfaces/mcp/schemas/outputs/providers.js +28 -0
- package/dist/interfaces/mcp/schemas/outputs/sdd.js +166 -0
- package/dist/interfaces/mcp/stdio-server.js +116 -0
- package/dist/interfaces/mcp/validation/agents.js +189 -0
- package/dist/interfaces/mcp/validation/common.js +415 -0
- package/dist/interfaces/mcp/validation/governance.js +50 -0
- package/dist/interfaces/mcp/validation/memory.js +133 -0
- package/dist/interfaces/mcp/validation/providers.js +94 -0
- package/dist/interfaces/mcp/validation/runs.js +514 -0
- package/dist/interfaces/mcp/validation/sdd.js +247 -0
- package/dist/interfaces/mcp/validation/sessions.js +51 -0
- package/dist/interfaces/mcp/validation/skills.js +685 -0
- package/dist/interfaces/mcp/validation/verification.js +24 -0
- package/dist/interfaces/mcp/validation.js +149 -0
- package/dist/mcp/control-plane-snapshot-service.js +65 -2
- package/dist/mcp/control-plane.js +1 -646
- package/dist/mcp/doctor.js +1 -1
- package/dist/mcp/index.js +17 -17
- package/dist/mcp/schema.js +1 -1072
- package/dist/mcp/stdio-server.js +1 -116
- package/dist/mcp/validation.js +1 -2239
- package/dist/memory/active-work-preview.js +1 -75
- package/dist/memory/active-work-topics.js +1 -64
- package/dist/memory/agent-memory-capture-service.js +1 -497
- package/dist/memory/import/dry-run-planner.js +1 -58
- package/dist/memory/import/index.js +1 -3
- package/dist/memory/import/observation-writer.js +1 -226
- package/dist/memory/import/package.js +1 -179
- package/dist/memory/memory-capture-schema.js +1 -1
- package/dist/memory/memory-service.js +1 -201
- package/dist/memory/repositories/artifacts.js +1 -67
- package/dist/memory/repositories/observations.js +1 -217
- package/dist/memory/repositories/sessions.js +1 -125
- package/dist/memory/repositories/traces.js +1 -78
- package/dist/memory/schema.js +1 -1
- package/dist/memory/search.js +1 -11
- package/dist/memory/sqlite/database.js +1 -228
- package/dist/memory/storage-paths.js +1 -72
- package/dist/payload/context-budget-policy.js +10 -0
- package/dist/payload/context-budget-service.js +26 -0
- package/dist/payload/payload-diagnostics.js +50 -0
- package/dist/permissions/explicit-request-authorization.js +126 -0
- package/dist/permissions/policy-evaluator.js +54 -14
- package/dist/runs/execution-planning.js +1 -178
- package/dist/runs/operation-execution.js +1 -1
- package/dist/runs/operation-retry.js +1 -129
- package/dist/runs/repositories/runs.js +1 -676
- package/dist/runs/repositories/task-scoped-command-grants.js +1 -462
- package/dist/runs/resume-after-approval-result.js +1 -84
- package/dist/runs/run-insights.js +1 -270
- package/dist/runs/run-service.js +1 -1439
- package/dist/runs/run-snapshot-export-service.js +1 -31
- package/dist/runs/sandbox-process-execution.js +1 -240
- package/dist/runs/sandbox-worktree-planning.js +1 -59
- package/dist/runs/schema.js +1 -5
- package/dist/runs/task-scoped-command-grant-service.js +1 -216
- package/dist/sdd/artifact-portability-service.js +1 -137
- package/dist/sdd/cockpit-read-model.js +1 -195
- package/dist/sdd/cockpit-types.js +1 -1
- package/dist/sdd/schema.js +1 -111
- package/dist/sdd/sdd-continuation-plan.js +1 -265
- package/dist/sdd/sdd-workflow-service.js +1 -822
- package/dist/setup/providers/claude-setup-adapter.js +11 -4
- package/dist/setup/providers/opencode-setup-adapter.js +10 -7
- package/dist/setup/setup-plan.js +20 -7
- package/dist/skills/boot-seed.js +1 -42
- package/dist/skills/personal-skills.js +1 -41
- package/dist/skills/repositories/skill-evaluation-requests.js +1 -190
- package/dist/skills/repositories/skill-evaluation-scenarios.js +1 -305
- package/dist/skills/repositories/skill-improvement-proposals.js +1 -355
- package/dist/skills/repositories/skills.js +1 -1077
- package/dist/skills/schema.js +1 -1
- package/dist/skills/skill-export-service.js +1 -34
- package/dist/skills/skill-index-service.js +1 -126
- package/dist/skills/skill-payload.js +1 -186
- package/dist/skills/skill-registry-service.js +1 -644
- package/dist/skills/skill-resolver.js +1 -368
- package/dist/skills/skill-seed-service.js +1 -242
- package/dist/skills/skill-status-service.js +1 -147
- package/dist/storage/agents/repositories/agent-seed-history.js +128 -0
- package/dist/storage/agents/repositories/agents.js +200 -0
- package/dist/storage/agents/repositories/manager-profile-overlays.js +90 -0
- package/dist/storage/memory/repositories/artifacts.js +67 -0
- package/dist/storage/memory/repositories/observations.js +217 -0
- package/dist/storage/memory/repositories/sessions.js +125 -0
- package/dist/storage/memory/repositories/traces.js +78 -0
- package/dist/storage/memory/sqlite/database.js +228 -0
- package/dist/storage/memory/storage-paths.js +72 -0
- package/dist/storage/runs/repositories/runs.js +676 -0
- package/dist/storage/runs/repositories/task-scoped-command-grants.js +464 -0
- package/dist/storage/skills/repositories/skill-evaluation-requests.js +190 -0
- package/dist/storage/skills/repositories/skill-evaluation-scenarios.js +305 -0
- package/dist/storage/skills/repositories/skill-improvement-proposals.js +355 -0
- package/dist/storage/skills/repositories/skills.js +1084 -0
- package/docs/architecture.md +2 -2
- package/docs/glossary.md +1 -1
- package/docs/mcp.md +1 -1
- package/docs/module-boundaries.md +114 -0
- package/docs/prd.md +1 -1
- package/docs/project-health-audit-v1.10.x.md +1 -1
- package/docs/providers.md +2 -2
- package/docs/safety.md +3 -3
- package/docs/sdd/archive/2026-06-26-ambitious-structure-reorganization/apply-progress.md +122 -0
- package/docs/sdd/archive/2026-06-26-ambitious-structure-reorganization/archive-report.md +61 -0
- package/docs/sdd/archive/2026-06-26-ambitious-structure-reorganization/design.md +66 -0
- package/docs/sdd/archive/2026-06-26-ambitious-structure-reorganization/proposal.md +79 -0
- package/docs/sdd/archive/2026-06-26-ambitious-structure-reorganization/spec.md +67 -0
- package/docs/sdd/archive/2026-06-26-ambitious-structure-reorganization/tasks.md +63 -0
- package/docs/sdd/archive/2026-06-26-ambitious-structure-reorganization/verify-report.md +71 -0
- package/docs/sdd/archive/2026-06-26-legacy-facade-cleanup/apply-progress.md +68 -0
- package/docs/sdd/archive/2026-06-26-legacy-facade-cleanup/archive-report.md +61 -0
- package/docs/sdd/archive/2026-06-26-legacy-facade-cleanup/design.md +43 -0
- package/docs/sdd/archive/2026-06-26-legacy-facade-cleanup/proposal.md +61 -0
- package/docs/sdd/archive/2026-06-26-legacy-facade-cleanup/spec.md +31 -0
- package/docs/sdd/archive/2026-06-26-legacy-facade-cleanup/tasks.md +27 -0
- package/docs/sdd/archive/2026-06-26-legacy-facade-cleanup/verify-report.md +58 -0
- package/docs/sdd/archive/2026-06-26-provider-install-adapter-boundary/apply-progress.md +65 -0
- package/docs/sdd/archive/2026-06-26-provider-install-adapter-boundary/archive-report.md +53 -0
- package/docs/sdd/archive/2026-06-26-provider-install-adapter-boundary/design.md +64 -0
- package/docs/sdd/archive/2026-06-26-provider-install-adapter-boundary/proposal.md +62 -0
- package/docs/sdd/archive/2026-06-26-provider-install-adapter-boundary/spec.md +51 -0
- package/docs/sdd/archive/2026-06-26-provider-install-adapter-boundary/tasks.md +50 -0
- package/docs/sdd/archive/2026-06-26-provider-install-adapter-boundary/verify-report.md +66 -0
- package/docs/storage.md +2 -2
- package/package.json +2 -2
- /package/dist/{mcp → adapters/claude/install}/claude-code-cli.js +0 -0
- /package/dist/{memory → storage/memory}/sqlite/migrations/001_initial.sql +0 -0
- /package/dist/{memory → storage/memory}/sqlite/migrations/002_observation_revisions.sql +0 -0
- /package/dist/{memory → storage/memory}/sqlite/migrations/003_agent_registry.sql +0 -0
- /package/dist/{memory → storage/memory}/sqlite/migrations/004_run_runtime.sql +0 -0
- /package/dist/{memory → storage/memory}/sqlite/migrations/005_run_approvals.sql +0 -0
- /package/dist/{memory → storage/memory}/sqlite/migrations/006_run_operation_attempts.sql +0 -0
- /package/dist/{memory → storage/memory}/sqlite/migrations/007_abandoned_operation_attempts.sql +0 -0
- /package/dist/{memory → storage/memory}/sqlite/migrations/008_run_execution_plan_events.sql +0 -0
- /package/dist/{memory → storage/memory}/sqlite/migrations/009_multiple_operation_attempts.sql +0 -0
- /package/dist/{memory → storage/memory}/sqlite/migrations/010_skill_registry.sql +0 -0
- /package/dist/{memory → storage/memory}/sqlite/migrations/011_skill_usage_resolution_outcomes.sql +0 -0
- /package/dist/{memory → storage/memory}/sqlite/migrations/012_skill_improvement_proposals.sql +0 -0
- /package/dist/{memory → storage/memory}/sqlite/migrations/013_skill_evaluation_scenarios.sql +0 -0
- /package/dist/{memory → storage/memory}/sqlite/migrations/014_manager_profile_overlays.sql +0 -0
- /package/dist/{memory → storage/memory}/sqlite/migrations/015_artifact_metadata.sql +0 -0
- /package/dist/{memory → storage/memory}/sqlite/migrations/016_agent_seed_history.sql +0 -0
- /package/dist/{memory → storage/memory}/sqlite/migrations/017_intent_signal_skill_targets.sql +0 -0
- /package/dist/{memory → storage/memory}/sqlite/migrations/018_skill_system_v2.sql +0 -0
- /package/dist/{memory → storage/memory}/sqlite/migrations/019_task_scoped_command_grants.sql +0 -0
|
@@ -1,263 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { resolveAgentProfileModel } from './profile-model-routing.js';
|
|
3
|
-
const defaultAgentName = 'vgxness-manager';
|
|
4
|
-
const provider = 'opencode';
|
|
5
|
-
const nextSafeAction = 'review_provider_payload_and_choose_manual_handoff';
|
|
6
|
-
const safety = { executesProvider: false, writesProviderConfig: false, backgroundWorker: false, autonomy: false };
|
|
7
|
-
export class AgentActivationService {
|
|
8
|
-
dependencies;
|
|
9
|
-
constructor(dependencies) {
|
|
10
|
-
this.dependencies = dependencies;
|
|
11
|
-
}
|
|
12
|
-
activate(input) {
|
|
13
|
-
const validated = validateActivationInput(input);
|
|
14
|
-
if (!validated.ok)
|
|
15
|
-
return validated;
|
|
16
|
-
const agent = this.resolveAgent(validated.value);
|
|
17
|
-
if (!agent.ok)
|
|
18
|
-
return agent;
|
|
19
|
-
if (agent.value.mode !== 'agent')
|
|
20
|
-
return validationFailure('Agent activation requires a top-level agent');
|
|
21
|
-
const selection = resolveAgentProfileModel({
|
|
22
|
-
agent: agent.value,
|
|
23
|
-
...(validated.value.providerAdapter === undefined ? {} : { providerAdapter: validated.value.providerAdapter }),
|
|
24
|
-
});
|
|
25
|
-
if (!selection.ok)
|
|
26
|
-
return selection;
|
|
27
|
-
if (selection.value.providerAdapter !== provider)
|
|
28
|
-
return validationFailure(`Provider adapter is not supported for activation: ${selection.value.providerAdapter}`);
|
|
29
|
-
const run = this.dependencies.runs.createRun({
|
|
30
|
-
project: validated.value.project,
|
|
31
|
-
userIntent: validated.value.userIntent,
|
|
32
|
-
workflow: validated.value.workflow,
|
|
33
|
-
phase: validated.value.phase,
|
|
34
|
-
selectedAgentId: agent.value.id,
|
|
35
|
-
providerAdapter: selection.value.providerAdapter,
|
|
36
|
-
model: selection.value.model,
|
|
37
|
-
});
|
|
38
|
-
if (!run.ok)
|
|
39
|
-
return run;
|
|
40
|
-
const payloadMode = resolvePayloadMode(validated.value);
|
|
41
|
-
const payload = this.dependencies.opencodeManagerPayload.build(toPayloadInput(validated.value, agent.value.id, payloadMode));
|
|
42
|
-
if (!payload.ok)
|
|
43
|
-
return this.failAfterRun(run.value.id, payload.error.code, payload.error.message);
|
|
44
|
-
const verboseEnvelopeWithoutRun = {
|
|
45
|
-
version: 1,
|
|
46
|
-
agent: { id: agent.value.id, name: agent.value.name, scope: agent.value.scope, mode: 'agent' },
|
|
47
|
-
provider,
|
|
48
|
-
modelSelection: selection.value,
|
|
49
|
-
providerPayload: payload.value,
|
|
50
|
-
...(payload.value.skillPayload !== undefined ? { skillsContext: payload.value.skillPayload } : {}),
|
|
51
|
-
nextSafeAction,
|
|
52
|
-
safety,
|
|
53
|
-
warnings: [
|
|
54
|
-
'Agent activation prepared a provider-ready payload but does not execute providers.',
|
|
55
|
-
'No provider configuration, background worker, autonomous step, or secrets expansion was performed.',
|
|
56
|
-
...selection.value.warnings,
|
|
57
|
-
...payload.value.warnings,
|
|
58
|
-
],
|
|
59
|
-
};
|
|
60
|
-
const envelopeWithoutRun = payloadMode === 'compact' ? compactActivationEnvelope(verboseEnvelopeWithoutRun, validated.value) : verboseEnvelopeWithoutRun;
|
|
61
|
-
const checkpoint = this.dependencies.runs.appendCheckpoint({
|
|
62
|
-
runId: run.value.id,
|
|
63
|
-
label: 'agent-activation-initial',
|
|
64
|
-
state: toJson(checkpointState(envelopeWithoutRun, run.value.id, payloadMode)),
|
|
65
|
-
});
|
|
66
|
-
if (!checkpoint.ok)
|
|
67
|
-
return this.failAfterRun(run.value.id, checkpoint.error.code, checkpoint.error.message);
|
|
68
|
-
const event = this.dependencies.runs.appendEvent({
|
|
69
|
-
runId: run.value.id,
|
|
70
|
-
kind: 'timeline',
|
|
71
|
-
title: 'Agent activation prepared',
|
|
72
|
-
payload: toJson({
|
|
73
|
-
agent: envelopeWithoutRun.agent,
|
|
74
|
-
provider,
|
|
75
|
-
modelSelection: selection.value,
|
|
76
|
-
nextSafeAction,
|
|
77
|
-
safety,
|
|
78
|
-
checkpointId: checkpoint.value.id,
|
|
79
|
-
}),
|
|
80
|
-
relatedType: 'run-checkpoint',
|
|
81
|
-
relatedId: checkpoint.value.id,
|
|
82
|
-
});
|
|
83
|
-
if (!event.ok)
|
|
84
|
-
return this.failAfterRun(run.value.id, event.error.code, event.error.message);
|
|
85
|
-
return ok({ ...envelopeWithoutRun, run: { id: run.value.id, status: 'created', checkpointId: checkpoint.value.id } });
|
|
86
|
-
}
|
|
87
|
-
resolveAgent(input) {
|
|
88
|
-
if (input.agentId !== undefined)
|
|
89
|
-
return this.dependencies.agents.getAgent(input.agentId);
|
|
90
|
-
if (this.dependencies.managerProfiles !== undefined) {
|
|
91
|
-
const effective = this.dependencies.managerProfiles.resolveEffectiveManager({
|
|
92
|
-
project: input.project,
|
|
93
|
-
scope: input.scope,
|
|
94
|
-
managerName: defaultAgentName,
|
|
95
|
-
});
|
|
96
|
-
return effective.ok ? ok(effective.value.manager) : effective;
|
|
97
|
-
}
|
|
98
|
-
return this.dependencies.agents.getAgentByName(input.project, input.scope, defaultAgentName);
|
|
99
|
-
}
|
|
100
|
-
failAfterRun(runId, code, message) {
|
|
101
|
-
const nestedFailures = [];
|
|
102
|
-
const eventResult = this.dependencies.runs.appendEvent({
|
|
103
|
-
runId,
|
|
104
|
-
kind: 'timeline',
|
|
105
|
-
title: 'Agent activation failed',
|
|
106
|
-
payload: toJson({ error: { code: String(code), message }, nextSafeActionReturned: false }),
|
|
107
|
-
});
|
|
108
|
-
if (!eventResult.ok) {
|
|
109
|
-
nestedFailures.push({ step: 'append-event', code: String(eventResult.error.code), message: eventResult.error.message });
|
|
110
|
-
}
|
|
111
|
-
const finalStatusResult = this.dependencies.runs.updateFinalStatus({ runId, status: 'failed', outcome: 'failure', outcomeReason: message });
|
|
112
|
-
if (!finalStatusResult.ok) {
|
|
113
|
-
nestedFailures.push({ step: 'update-final-status', code: String(finalStatusResult.error.code), message: finalStatusResult.error.message });
|
|
114
|
-
}
|
|
115
|
-
return nestedFailures.length === 0
|
|
116
|
-
? { ok: false, error: { code, message } }
|
|
117
|
-
: { ok: false, error: { code, message, cause: { nestedFailures } } };
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
function validateActivationInput(input) {
|
|
121
|
-
if (input.project.trim().length === 0)
|
|
122
|
-
return validationFailure('Project is required');
|
|
123
|
-
if (input.userIntent.trim().length === 0)
|
|
124
|
-
return validationFailure('userIntent is required');
|
|
125
|
-
if (input.agentId !== undefined && input.agentId.trim().length === 0)
|
|
126
|
-
return validationFailure('agentId must not be empty');
|
|
127
|
-
if (input.payloadMode !== undefined && input.payloadMode !== 'compact' && input.payloadMode !== 'verbose')
|
|
128
|
-
return validationFailure('payloadMode must be compact or verbose');
|
|
129
|
-
const validated = {
|
|
130
|
-
project: input.project.trim(),
|
|
131
|
-
scope: input.scope ?? 'project',
|
|
132
|
-
userIntent: input.userIntent.trim(),
|
|
133
|
-
workflow: input.workflow?.trim() || 'agent-activation',
|
|
134
|
-
phase: input.phase?.trim() || 'activation',
|
|
135
|
-
};
|
|
136
|
-
if (input.agentId !== undefined)
|
|
137
|
-
validated.agentId = input.agentId.trim();
|
|
138
|
-
if (input.workspaceRoot !== undefined)
|
|
139
|
-
validated.workspaceRoot = input.workspaceRoot;
|
|
140
|
-
if (input.maxSourceBytes !== undefined)
|
|
141
|
-
validated.maxSourceBytes = input.maxSourceBytes;
|
|
142
|
-
if (input.providerAdapter !== undefined) {
|
|
143
|
-
if (input.providerAdapter.trim().length === 0)
|
|
144
|
-
return validationFailure('providerAdapter must not be empty');
|
|
145
|
-
validated.providerAdapter = input.providerAdapter.trim();
|
|
146
|
-
}
|
|
147
|
-
if (input.payloadMode !== undefined)
|
|
148
|
-
validated.payloadMode = input.payloadMode;
|
|
149
|
-
return ok(validated);
|
|
150
|
-
}
|
|
151
|
-
function resolvePayloadMode(input) {
|
|
152
|
-
return input.payloadMode ?? 'compact';
|
|
153
|
-
}
|
|
154
|
-
function toPayloadInput(input, agentId, payloadMode) {
|
|
155
|
-
const payload = { project: input.project, scope: input.scope };
|
|
156
|
-
if (input.agentId !== undefined)
|
|
157
|
-
payload.agentId = agentId;
|
|
158
|
-
else
|
|
159
|
-
payload.useManagerOverlay = true;
|
|
160
|
-
if (input.workspaceRoot !== undefined)
|
|
161
|
-
payload.workspaceRoot = input.workspaceRoot;
|
|
162
|
-
if (input.maxSourceBytes !== undefined)
|
|
163
|
-
payload.maxSourceBytes = input.maxSourceBytes;
|
|
164
|
-
payload.payloadMode = payloadMode;
|
|
165
|
-
return payload;
|
|
166
|
-
}
|
|
167
|
-
function checkpointState(envelopeWithoutRun, runId, mode) {
|
|
168
|
-
const base = { ...envelopeWithoutRun, run: { id: runId, status: 'created', checkpointId: null } };
|
|
169
|
-
if (mode === 'verbose')
|
|
170
|
-
return toJson(base);
|
|
171
|
-
return toJson({
|
|
172
|
-
version: base.version,
|
|
173
|
-
run: base.run,
|
|
174
|
-
agent: base.agent,
|
|
175
|
-
provider: base.provider,
|
|
176
|
-
modelSelection: base.modelSelection,
|
|
177
|
-
providerPayload: {
|
|
178
|
-
version: base.providerPayload.version,
|
|
179
|
-
provider: base.providerPayload.provider,
|
|
180
|
-
payloadMode: base.providerPayload.payloadMode,
|
|
181
|
-
selection: base.providerPayload.selection,
|
|
182
|
-
providerArtifacts: base.providerPayload.providerArtifacts,
|
|
183
|
-
skillDiagnostics: base.providerPayload.skillDiagnostics,
|
|
184
|
-
safety: base.providerPayload.safety,
|
|
185
|
-
warnings: base.providerPayload.warnings,
|
|
186
|
-
},
|
|
187
|
-
skillsContext: base.skillsContext === undefined
|
|
188
|
-
? undefined
|
|
189
|
-
: {
|
|
190
|
-
version: base.skillsContext.version,
|
|
191
|
-
providerAgnostic: base.skillsContext.providerAgnostic,
|
|
192
|
-
context: base.skillsContext.context,
|
|
193
|
-
itemCount: base.skillsContext.items.length,
|
|
194
|
-
skipped: base.skillsContext.skipped,
|
|
195
|
-
skillDiagnostics: base.skillsContext.skillDiagnostics,
|
|
196
|
-
warnings: base.skillsContext.warnings,
|
|
197
|
-
},
|
|
198
|
-
nextSafeAction: base.nextSafeAction,
|
|
199
|
-
safety: base.safety,
|
|
200
|
-
warnings: base.warnings,
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
function compactActivationEnvelope(verbose, input) {
|
|
204
|
-
const compactProviderPayload = {
|
|
205
|
-
version: verbose.providerPayload.version,
|
|
206
|
-
provider: verbose.providerPayload.provider,
|
|
207
|
-
payloadMode: 'compact',
|
|
208
|
-
installable: verbose.providerPayload.installable,
|
|
209
|
-
selection: verbose.providerPayload.selection,
|
|
210
|
-
providerArtifacts: verbose.providerPayload.providerArtifacts,
|
|
211
|
-
...(verbose.providerPayload.skillDiagnostics === undefined ? {} : { skillDiagnostics: verbose.providerPayload.skillDiagnostics }),
|
|
212
|
-
safety: verbose.providerPayload.safety,
|
|
213
|
-
warnings: verbose.providerPayload.warnings,
|
|
214
|
-
};
|
|
215
|
-
const fullRetrieval = {
|
|
216
|
-
tool: 'vgxness_agent_activate',
|
|
217
|
-
payloadMode: 'verbose',
|
|
218
|
-
input: {
|
|
219
|
-
project: input.project,
|
|
220
|
-
scope: input.scope,
|
|
221
|
-
agentId: verbose.agent.id,
|
|
222
|
-
userIntent: input.userIntent,
|
|
223
|
-
workflow: input.workflow,
|
|
224
|
-
phase: input.phase,
|
|
225
|
-
},
|
|
226
|
-
};
|
|
227
|
-
const omittedSections = [];
|
|
228
|
-
if (verbose.providerPayload.skillPayload !== undefined)
|
|
229
|
-
omittedSections.push(omittedSection('providerPayload.skillPayload', 'Duplicate of skillsContext; omitted from compact activation response.', fullRetrieval, verbose.providerPayload.skillPayload));
|
|
230
|
-
if (verbose.skillsContext !== undefined)
|
|
231
|
-
omittedSections.push(omittedSection('skillsContext', 'Skill details remain durably retrievable through verbose activation or skill payload calls.', fullRetrieval, verbose.skillsContext));
|
|
232
|
-
const compact = {
|
|
233
|
-
version: verbose.version,
|
|
234
|
-
agent: verbose.agent,
|
|
235
|
-
provider: verbose.provider,
|
|
236
|
-
modelSelection: verbose.modelSelection,
|
|
237
|
-
providerPayload: compactProviderPayload,
|
|
238
|
-
omittedSections,
|
|
239
|
-
governanceConstraints: [
|
|
240
|
-
'Activation is preview-only and does not execute providers.',
|
|
241
|
-
'No provider configuration, background worker, autonomous step, or secrets expansion is performed.',
|
|
242
|
-
'Request payloadMode=verbose when full provider payload or skills context is needed.',
|
|
243
|
-
],
|
|
244
|
-
nextSafeAction: verbose.nextSafeAction,
|
|
245
|
-
safety: verbose.safety,
|
|
246
|
-
warnings: verbose.warnings,
|
|
247
|
-
};
|
|
248
|
-
compact.responseByteAccounting = responseByteAccounting(verbose, compact);
|
|
249
|
-
return compact;
|
|
250
|
-
}
|
|
251
|
-
function omittedSection(path, reason, retrieval, value) {
|
|
252
|
-
const summary = summarizePayloadContent(JSON.stringify(value));
|
|
253
|
-
return { path, reason, hash: summary.contentHash, bytes: summary.contentBytes, retrieval };
|
|
254
|
-
}
|
|
255
|
-
function toJson(value) {
|
|
256
|
-
return JSON.parse(JSON.stringify(value));
|
|
257
|
-
}
|
|
258
|
-
function ok(value) {
|
|
259
|
-
return { ok: true, value };
|
|
260
|
-
}
|
|
261
|
-
function validationFailure(message) {
|
|
262
|
-
return { ok: false, error: { code: 'validation_failed', message } };
|
|
263
|
-
}
|
|
1
|
+
export * from '../application/agents/agent-activation-service.js';
|
|
@@ -1,28 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export const GLOBAL_VGXNESS_AGENTS_PROJECT = '__vgxness__';
|
|
3
|
-
export const LEGACY_VGXNESS_AGENTS_PROJECT = 'vgxness';
|
|
4
|
-
export const agentLookupContexts = (project, scope) => {
|
|
5
|
-
const contexts = [{ project, scope }];
|
|
6
|
-
if (scope !== 'personal')
|
|
7
|
-
contexts.push({ project, scope: 'personal' });
|
|
8
|
-
if (project !== GLOBAL_PERSONAL_AGENTS_PROJECT)
|
|
9
|
-
contexts.push({ project: GLOBAL_PERSONAL_AGENTS_PROJECT, scope: 'personal' });
|
|
10
|
-
if (project !== GLOBAL_VGXNESS_AGENTS_PROJECT)
|
|
11
|
-
contexts.push({ project: GLOBAL_VGXNESS_AGENTS_PROJECT, scope: 'project' });
|
|
12
|
-
if (project !== LEGACY_VGXNESS_AGENTS_PROJECT)
|
|
13
|
-
contexts.push({ project: LEGACY_VGXNESS_AGENTS_PROJECT, scope: 'project' });
|
|
14
|
-
return dedupeContexts(contexts);
|
|
15
|
-
};
|
|
16
|
-
export const dedupeAgentLookupContexts = (contexts) => {
|
|
17
|
-
return dedupeContexts(contexts);
|
|
18
|
-
};
|
|
19
|
-
function dedupeContexts(contexts) {
|
|
20
|
-
const seen = new Set();
|
|
21
|
-
return contexts.filter((context) => {
|
|
22
|
-
const key = `${context.project}:${context.scope}`;
|
|
23
|
-
if (seen.has(key))
|
|
24
|
-
return false;
|
|
25
|
-
seen.add(key);
|
|
26
|
-
return true;
|
|
27
|
-
});
|
|
28
|
-
}
|
|
1
|
+
export * from '../application/agents/agent-lookup-contexts.js';
|
|
@@ -1,81 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { AgentResolver } from './agent-resolver.js';
|
|
3
|
-
import { AgentRepository } from './repositories/agents.js';
|
|
4
|
-
export class AgentRegistryService {
|
|
5
|
-
database;
|
|
6
|
-
agents;
|
|
7
|
-
constructor(database) {
|
|
8
|
-
this.database = database;
|
|
9
|
-
this.agents = new AgentRepository(database);
|
|
10
|
-
}
|
|
11
|
-
registerAgent(input) {
|
|
12
|
-
return this.agents.register({ ...input, mode: 'agent' });
|
|
13
|
-
}
|
|
14
|
-
registerSubagent(input) {
|
|
15
|
-
return this.agents.register({ ...input, mode: 'subagent' });
|
|
16
|
-
}
|
|
17
|
-
getAgent(id) {
|
|
18
|
-
return this.agents.getById(id);
|
|
19
|
-
}
|
|
20
|
-
getAgentByName(project, scope, name) {
|
|
21
|
-
return this.agents.getByName(project, scope, name);
|
|
22
|
-
}
|
|
23
|
-
listAgents(filters = {}) {
|
|
24
|
-
return this.agents.list(filters);
|
|
25
|
-
}
|
|
26
|
-
listSubagents(parentAgentId) {
|
|
27
|
-
return this.agents.list({ mode: 'subagent', parentAgentId });
|
|
28
|
-
}
|
|
29
|
-
resolveAgents(input) {
|
|
30
|
-
return new AgentResolver(() => this.listAgentDefinitions(input)).resolve(input);
|
|
31
|
-
}
|
|
32
|
-
close() {
|
|
33
|
-
this.database.close();
|
|
34
|
-
}
|
|
35
|
-
listAgentDefinitions(input) {
|
|
36
|
-
if (input.project !== undefined)
|
|
37
|
-
return this.listAgentDefinitionsForContexts(input);
|
|
38
|
-
const filters = {};
|
|
39
|
-
if (input.scope !== undefined)
|
|
40
|
-
filters.scope = input.scope;
|
|
41
|
-
if (input.mode !== undefined)
|
|
42
|
-
filters.mode = input.mode;
|
|
43
|
-
const summaries = this.agents.list(filters);
|
|
44
|
-
if (!summaries.ok)
|
|
45
|
-
return summaries;
|
|
46
|
-
const definitions = [];
|
|
47
|
-
for (const summary of summaries.value) {
|
|
48
|
-
const agent = this.agents.getById(summary.id);
|
|
49
|
-
if (!agent.ok)
|
|
50
|
-
return agent;
|
|
51
|
-
definitions.push(agent.value);
|
|
52
|
-
}
|
|
53
|
-
return { ok: true, value: definitions };
|
|
54
|
-
}
|
|
55
|
-
listAgentDefinitionsForContexts(input) {
|
|
56
|
-
const project = input.project;
|
|
57
|
-
if (project === undefined)
|
|
58
|
-
return { ok: true, value: [] };
|
|
59
|
-
const summariesByName = new Map();
|
|
60
|
-
for (const context of agentLookupContexts(project, input.scope ?? 'project')) {
|
|
61
|
-
const filters = { project: context.project, scope: context.scope };
|
|
62
|
-
if (input.mode !== undefined)
|
|
63
|
-
filters.mode = input.mode;
|
|
64
|
-
const summaries = this.agents.list(filters);
|
|
65
|
-
if (!summaries.ok)
|
|
66
|
-
return summaries;
|
|
67
|
-
for (const summary of summaries.value) {
|
|
68
|
-
if (!summariesByName.has(summary.name))
|
|
69
|
-
summariesByName.set(summary.name, summary);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
const definitions = [];
|
|
73
|
-
for (const summary of summariesByName.values()) {
|
|
74
|
-
const agent = this.agents.getById(summary.id);
|
|
75
|
-
if (!agent.ok)
|
|
76
|
-
return agent;
|
|
77
|
-
definitions.push(agent.value);
|
|
78
|
-
}
|
|
79
|
-
return { ok: true, value: definitions };
|
|
80
|
-
}
|
|
81
|
-
}
|
|
1
|
+
export * from '../application/agents/agent-registry-service.js';
|
|
@@ -1,287 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { agentLookupContexts } from './agent-lookup-contexts.js';
|
|
3
|
-
export class AgentResolver {
|
|
4
|
-
loadAgents;
|
|
5
|
-
constructor(loadAgents) {
|
|
6
|
-
this.loadAgents = loadAgents;
|
|
7
|
-
}
|
|
8
|
-
resolve(input) {
|
|
9
|
-
const agents = this.loadAgents();
|
|
10
|
-
if (!agents.ok)
|
|
11
|
-
return agents;
|
|
12
|
-
const normalized = normalizeInput(input);
|
|
13
|
-
const candidates = [];
|
|
14
|
-
const skipped = [];
|
|
15
|
-
for (const agent of agents.value) {
|
|
16
|
-
const skipReasons = hardSkipReasons(agent, normalized);
|
|
17
|
-
if (skipReasons.length > 0) {
|
|
18
|
-
skipped.push(toSkipped(agent, skipReasons));
|
|
19
|
-
continue;
|
|
20
|
-
}
|
|
21
|
-
const scored = scoreAgent(agent, normalized);
|
|
22
|
-
if (scored.score <= 0) {
|
|
23
|
-
skipped.push(toSkipped(agent, ['no matching resolution signals']));
|
|
24
|
-
continue;
|
|
25
|
-
}
|
|
26
|
-
candidates.push(scored);
|
|
27
|
-
}
|
|
28
|
-
candidates.sort(compareCandidates);
|
|
29
|
-
skipped.sort(compareSkipped);
|
|
30
|
-
return ok({
|
|
31
|
-
context: {
|
|
32
|
-
...(normalized.project !== undefined ? { project: normalized.project } : {}),
|
|
33
|
-
...(normalized.scope !== undefined ? { scope: normalized.scope } : {}),
|
|
34
|
-
...(normalized.taskDescription !== undefined ? { taskDescription: normalized.taskDescription } : {}),
|
|
35
|
-
...(normalized.intent !== undefined ? { intent: normalized.intent } : {}),
|
|
36
|
-
desiredCapabilities: normalized.desiredCapabilities,
|
|
37
|
-
...(normalized.workflow !== undefined ? { workflow: normalized.workflow } : {}),
|
|
38
|
-
...(normalized.phase !== undefined ? { phase: normalized.phase } : {}),
|
|
39
|
-
...(normalized.providerAdapter !== undefined ? { providerAdapter: normalized.providerAdapter } : {}),
|
|
40
|
-
...(normalized.mode !== undefined ? { mode: normalized.mode } : {}),
|
|
41
|
-
},
|
|
42
|
-
candidates,
|
|
43
|
-
skipped,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
const SDD_PHASE_SEMANTICS = [
|
|
48
|
-
{
|
|
49
|
-
name: 'sdd-planning',
|
|
50
|
-
phases: ['proposal', 'design', 'tasks'],
|
|
51
|
-
terms: ['plan', 'planning', 'proposal', 'propose', 'design', 'task', 'tasks', 'breakdown', 'slice', 'slicing'],
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
name: 'sdd-verification',
|
|
55
|
-
phases: ['verify'],
|
|
56
|
-
terms: ['verify', 'verification', 'test', 'testing', 'review', 'risk', 'evidence'],
|
|
57
|
-
},
|
|
58
|
-
];
|
|
59
|
-
function normalizeInput(input) {
|
|
60
|
-
const desiredCapabilities = normalizeList(input.desiredCapabilities ?? []);
|
|
61
|
-
const taskDescription = normalizeText(input.taskDescription);
|
|
62
|
-
const intent = normalizeText(input.intent);
|
|
63
|
-
const metaWorkflow = isMetaWorkflow(input.workflow);
|
|
64
|
-
const workflow = normalizeMetaWorkflow(input.workflow);
|
|
65
|
-
const phase = metaWorkflow || input.phase === undefined ? undefined : (isSddWorkflow(workflow) ? (normalizeSddPhaseInput(input.phase) ?? input.phase) : input.phase);
|
|
66
|
-
const { workflow: _workflow, phase: _phase, ...rest } = input;
|
|
67
|
-
return {
|
|
68
|
-
...rest,
|
|
69
|
-
...(workflow !== undefined ? { workflow } : {}),
|
|
70
|
-
...(phase !== undefined ? { phase } : {}),
|
|
71
|
-
...(taskDescription !== undefined ? { taskDescription } : {}),
|
|
72
|
-
...(intent !== undefined ? { intent } : {}),
|
|
73
|
-
desiredCapabilities,
|
|
74
|
-
terms: tokenize([taskDescription, intent].filter((value) => value !== undefined).join(' ')),
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
function normalizeMetaWorkflow(workflow) {
|
|
78
|
-
if (isMetaWorkflow(workflow))
|
|
79
|
-
return undefined;
|
|
80
|
-
return workflow;
|
|
81
|
-
}
|
|
82
|
-
function isMetaWorkflow(workflow) {
|
|
83
|
-
return workflow?.trim().toLowerCase() === 'workflow-selection';
|
|
84
|
-
}
|
|
85
|
-
function hardSkipReasons(agent, input) {
|
|
86
|
-
const reasons = [];
|
|
87
|
-
if (input.project !== undefined && !agentMatchesRequestedContext(agent, input))
|
|
88
|
-
reasons.push(`context mismatch: ${agent.project}/${agent.scope}`);
|
|
89
|
-
else if (input.project === undefined && input.scope !== undefined && agent.scope !== input.scope)
|
|
90
|
-
reasons.push(`scope mismatch: ${agent.scope}`);
|
|
91
|
-
if (input.mode !== undefined && agent.mode !== input.mode)
|
|
92
|
-
reasons.push(`mode mismatch: ${agent.mode}`);
|
|
93
|
-
if (input.providerAdapter !== undefined && Object.keys(agent.adapters).length > 0 && agent.adapters[input.providerAdapter] === undefined)
|
|
94
|
-
reasons.push(`provider adapter mismatch: ${input.providerAdapter}`);
|
|
95
|
-
if ((input.workflow !== undefined || input.phase !== undefined) && agent.workflows.length > 0 && workflowMatches(agent, input).length === 0)
|
|
96
|
-
reasons.push('workflow mismatch');
|
|
97
|
-
if (input.desiredCapabilities.length > 0 && matchingValues(agent.capabilities, input.desiredCapabilities).length === 0)
|
|
98
|
-
reasons.push('capability mismatch');
|
|
99
|
-
return reasons;
|
|
100
|
-
}
|
|
101
|
-
function agentMatchesRequestedContext(agent, input) {
|
|
102
|
-
if (input.project === undefined)
|
|
103
|
-
return true;
|
|
104
|
-
const contexts = agentLookupContexts(input.project, input.scope ?? 'project');
|
|
105
|
-
return contexts.some((context) => agent.project === context.project && agent.scope === context.scope);
|
|
106
|
-
}
|
|
107
|
-
function scoreAgent(agent, input) {
|
|
108
|
-
const reasons = [];
|
|
109
|
-
let score = 0;
|
|
110
|
-
const capabilityMatches = matchingValues(agent.capabilities, input.desiredCapabilities);
|
|
111
|
-
if (capabilityMatches.length > 0) {
|
|
112
|
-
score += capabilityMatches.length * 30;
|
|
113
|
-
reasons.push(`capabilities matched: ${capabilityMatches.join(', ')}`);
|
|
114
|
-
}
|
|
115
|
-
const workflowMatchesValue = workflowSignalMatches(agent, input);
|
|
116
|
-
if (workflowMatchesValue.exactPhase.length > 0) {
|
|
117
|
-
score += workflowMatchesValue.exactPhase.length * 25;
|
|
118
|
-
reasons.push(`workflow phase matched: ${workflowMatchesValue.exactPhase.join(', ')}`);
|
|
119
|
-
}
|
|
120
|
-
if (workflowMatchesValue.phaseOnly.length > 0) {
|
|
121
|
-
score += workflowMatchesValue.phaseOnly.length * 22;
|
|
122
|
-
reasons.push(`workflow phase-only matched: ${workflowMatchesValue.phaseOnly.join(', ')}`);
|
|
123
|
-
}
|
|
124
|
-
if (workflowMatchesValue.broad.length > 0) {
|
|
125
|
-
score += workflowMatchesValue.broad.length * 20;
|
|
126
|
-
reasons.push(`workflow matched: ${workflowMatchesValue.broad.join(', ')}`);
|
|
127
|
-
}
|
|
128
|
-
if (input.providerAdapter !== undefined) {
|
|
129
|
-
if (agent.adapters[input.providerAdapter] !== undefined) {
|
|
130
|
-
score += 20;
|
|
131
|
-
reasons.push(`provider adapter matched: ${input.providerAdapter}`);
|
|
132
|
-
}
|
|
133
|
-
else if (Object.keys(agent.adapters).length === 0) {
|
|
134
|
-
score += 5;
|
|
135
|
-
reasons.push(`provider neutral: no adapter restrictions for ${input.providerAdapter}`);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
const skillMatches = matchingValues(agent.skills, [...input.desiredCapabilities, ...input.terms]);
|
|
139
|
-
if (skillMatches.length > 0) {
|
|
140
|
-
score += skillMatches.length * 10;
|
|
141
|
-
reasons.push(`skills matched: ${skillMatches.join(', ')}`);
|
|
142
|
-
}
|
|
143
|
-
const textMatches = textSignalMatches(agent, input.terms);
|
|
144
|
-
if (textMatches.length > 0) {
|
|
145
|
-
score += Math.min(textMatches.length, 5) * 4;
|
|
146
|
-
reasons.push(`task text matched: ${textMatches.join(', ')}`);
|
|
147
|
-
}
|
|
148
|
-
const phaseSemanticMatches = phaseSemanticMatchesFor(agent, input);
|
|
149
|
-
for (const match of phaseSemanticMatches) {
|
|
150
|
-
score += 8;
|
|
151
|
-
reasons.push(`phase semantics matched: ${match}`);
|
|
152
|
-
}
|
|
153
|
-
if (input.mode !== undefined) {
|
|
154
|
-
score += 3;
|
|
155
|
-
reasons.push(`mode matched: ${agent.mode}`);
|
|
156
|
-
}
|
|
157
|
-
if (agent.mode === 'subagent') {
|
|
158
|
-
score += 2;
|
|
159
|
-
reasons.push(`parent constraint satisfied: ${agent.parentAgentId}`);
|
|
160
|
-
}
|
|
161
|
-
return { agent, score, reasons };
|
|
162
|
-
}
|
|
163
|
-
function workflowMatches(agent, input) {
|
|
164
|
-
const matches = workflowSignalMatches(agent, input);
|
|
165
|
-
return [...matches.broad, ...matches.phaseOnly, ...matches.exactPhase];
|
|
166
|
-
}
|
|
167
|
-
function workflowSignalMatches(agent, input) {
|
|
168
|
-
const requested = workflowRequestedSignals(input)
|
|
169
|
-
.filter((value) => value !== undefined)
|
|
170
|
-
.map(normalizeKey);
|
|
171
|
-
if (requested.length === 0)
|
|
172
|
-
return { broad: [], phaseOnly: [], exactPhase: [] };
|
|
173
|
-
const workflow = input.workflow !== undefined ? normalizeKey(input.workflow) : undefined;
|
|
174
|
-
const phase = input.phase !== undefined ? normalizeKey(input.phase) : undefined;
|
|
175
|
-
const exact = workflow !== undefined && phase !== undefined ? `${workflow}:${phase}` : undefined;
|
|
176
|
-
const matches = { broad: [], phaseOnly: [], exactPhase: [] };
|
|
177
|
-
for (const agentWorkflow of agent.workflows) {
|
|
178
|
-
const normalizedWorkflow = normalizeKey(agentWorkflow);
|
|
179
|
-
const comparableWorkflow = canonicalSddWorkflowTargetKey(agentWorkflow);
|
|
180
|
-
if (!requested.includes(normalizedWorkflow) && !requested.includes(comparableWorkflow) && !sddApplyAliasMatches(agentWorkflow, input))
|
|
181
|
-
continue;
|
|
182
|
-
if (exact !== undefined && (normalizedWorkflow === exact || comparableWorkflow === exact))
|
|
183
|
-
matches.exactPhase.push(agentWorkflow);
|
|
184
|
-
else if (phase !== undefined && normalizedWorkflow === phase)
|
|
185
|
-
matches.phaseOnly.push(agentWorkflow);
|
|
186
|
-
else if (sddApplyAliasMatches(agentWorkflow, input))
|
|
187
|
-
matches.exactPhase.push(agentWorkflow);
|
|
188
|
-
else
|
|
189
|
-
matches.broad.push(agentWorkflow);
|
|
190
|
-
}
|
|
191
|
-
return matches;
|
|
192
|
-
}
|
|
193
|
-
function canonicalSddWorkflowTargetKey(workflow) {
|
|
194
|
-
const normalized = normalizeKey(workflow);
|
|
195
|
-
const separator = normalized.indexOf(':');
|
|
196
|
-
if (separator <= 0)
|
|
197
|
-
return normalized;
|
|
198
|
-
const workflowName = normalized.slice(0, separator);
|
|
199
|
-
const phase = normalized.slice(separator + 1);
|
|
200
|
-
if (workflowName !== 'sdd')
|
|
201
|
-
return normalized;
|
|
202
|
-
return `${workflowName}:${normalizeSddPhaseInput(phase) ?? phase}`;
|
|
203
|
-
}
|
|
204
|
-
function workflowRequestedSignals(input) {
|
|
205
|
-
return [input.workflow, input.phase, input.workflow !== undefined && input.phase !== undefined ? `${input.workflow}:${input.phase}` : undefined];
|
|
206
|
-
}
|
|
207
|
-
function sddApplyAliasMatches(agentWorkflow, input) {
|
|
208
|
-
if (input.phase === undefined || normalizeKey(input.phase) !== 'apply')
|
|
209
|
-
return false;
|
|
210
|
-
if (input.workflow !== undefined && !isSddWorkflow(input.workflow))
|
|
211
|
-
return false;
|
|
212
|
-
return normalizeKey(agentWorkflow) === 'sdd:apply-progress';
|
|
213
|
-
}
|
|
214
|
-
function phaseSemanticMatchesFor(agent, input) {
|
|
215
|
-
const workflow = input.workflow !== undefined ? normalizeKey(input.workflow) : undefined;
|
|
216
|
-
if (workflow !== undefined && workflow !== 'sdd')
|
|
217
|
-
return [];
|
|
218
|
-
const inputPhase = input.phase !== undefined ? normalizeKey(input.phase) : undefined;
|
|
219
|
-
const agentTerms = tokenize([agent.name, agent.description, ...agent.capabilities, ...agent.skills, ...agent.workflows].join(' '));
|
|
220
|
-
const requestTerms = new Set(input.terms);
|
|
221
|
-
const matches = [];
|
|
222
|
-
for (const semantic of SDD_PHASE_SEMANTICS) {
|
|
223
|
-
const phaseMatches = inputPhase !== undefined && semantic.phases.includes(inputPhase);
|
|
224
|
-
const termMatches = semantic.terms.some((term) => requestTerms.has(term));
|
|
225
|
-
const agentMatches = semantic.terms.some((term) => agentTerms.includes(term));
|
|
226
|
-
if ((phaseMatches || termMatches) && agentMatches)
|
|
227
|
-
matches.push(semantic.name);
|
|
228
|
-
}
|
|
229
|
-
return matches;
|
|
230
|
-
}
|
|
231
|
-
function textSignalMatches(agent, terms) {
|
|
232
|
-
if (terms.length === 0)
|
|
233
|
-
return [];
|
|
234
|
-
const searchable = tokenize([agent.name, agent.description, ...agent.capabilities, ...agent.skills, ...agent.workflows].join(' '));
|
|
235
|
-
return terms.filter((term) => searchable.includes(term));
|
|
236
|
-
}
|
|
237
|
-
function matchingValues(values, requested) {
|
|
238
|
-
const normalizedValues = new Map(values.map((value) => [normalizeKey(value), value]));
|
|
239
|
-
const matches = [];
|
|
240
|
-
for (const requestedValue of requested) {
|
|
241
|
-
const match = normalizedValues.get(normalizeKey(requestedValue));
|
|
242
|
-
if (match !== undefined && !matches.includes(match))
|
|
243
|
-
matches.push(match);
|
|
244
|
-
}
|
|
245
|
-
return matches;
|
|
246
|
-
}
|
|
247
|
-
function compareCandidates(a, b) {
|
|
248
|
-
return (b.score - a.score || modeRank(a.agent.mode) - modeRank(b.agent.mode) || a.agent.name.localeCompare(b.agent.name) || a.agent.id.localeCompare(b.agent.id));
|
|
249
|
-
}
|
|
250
|
-
function compareSkipped(a, b) {
|
|
251
|
-
return a.agent.name.localeCompare(b.agent.name) || a.agent.id.localeCompare(b.agent.id);
|
|
252
|
-
}
|
|
253
|
-
function modeRank(mode) {
|
|
254
|
-
return mode === 'agent' ? 0 : 1;
|
|
255
|
-
}
|
|
256
|
-
function toSkipped(agent, reasons) {
|
|
257
|
-
return { agent: { id: agent.id, name: agent.name, mode: agent.mode, project: agent.project, scope: agent.scope }, reasons };
|
|
258
|
-
}
|
|
259
|
-
function normalizeList(values) {
|
|
260
|
-
return values.map(normalizeText).filter((value) => value !== undefined);
|
|
261
|
-
}
|
|
262
|
-
function normalizeText(value) {
|
|
263
|
-
const normalized = value?.trim();
|
|
264
|
-
return normalized ? normalized : undefined;
|
|
265
|
-
}
|
|
266
|
-
function normalizeKey(value) {
|
|
267
|
-
return value.trim().toLowerCase();
|
|
268
|
-
}
|
|
269
|
-
function isSddWorkflow(workflow) {
|
|
270
|
-
return workflow?.trim().toLowerCase() === 'sdd';
|
|
271
|
-
}
|
|
272
|
-
function tokenize(value) {
|
|
273
|
-
const seen = new Set();
|
|
274
|
-
return value
|
|
275
|
-
.toLowerCase()
|
|
276
|
-
.split(/[^a-z0-9-]+/)
|
|
277
|
-
.filter(Boolean)
|
|
278
|
-
.filter((term) => {
|
|
279
|
-
if (term.length < 3 || seen.has(term))
|
|
280
|
-
return false;
|
|
281
|
-
seen.add(term);
|
|
282
|
-
return true;
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
function ok(value) {
|
|
286
|
-
return { ok: true, value };
|
|
287
|
-
}
|
|
1
|
+
export * from '../application/agents/agent-resolver.js';
|