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,90 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export class ManagerProfileOverlayRepository {
|
|
3
|
-
db;
|
|
4
|
-
constructor(db) {
|
|
5
|
-
this.db = db;
|
|
6
|
-
}
|
|
7
|
-
save(input) {
|
|
8
|
-
const validation = validate(input);
|
|
9
|
-
if (!validation.ok)
|
|
10
|
-
return validation;
|
|
11
|
-
try {
|
|
12
|
-
const existing = this.find(input.project, input.scope, input.managerName);
|
|
13
|
-
const id = existing?.id ?? randomUUID();
|
|
14
|
-
const now = new Date().toISOString();
|
|
15
|
-
this.db.connection
|
|
16
|
-
.prepare(`
|
|
17
|
-
INSERT INTO manager_profile_overlays(id, project, scope, manager_name, instructions, created_at, updated_at)
|
|
18
|
-
VALUES (@id, @project, @scope, @managerName, @instructions, @createdAt, @updatedAt)
|
|
19
|
-
ON CONFLICT(project, scope, manager_name) DO UPDATE SET
|
|
20
|
-
instructions=excluded.instructions,
|
|
21
|
-
updated_at=excluded.updated_at
|
|
22
|
-
`)
|
|
23
|
-
.run({
|
|
24
|
-
id,
|
|
25
|
-
project: input.project.trim(),
|
|
26
|
-
scope: input.scope,
|
|
27
|
-
managerName: input.managerName.trim(),
|
|
28
|
-
instructions: input.instructions.trim(),
|
|
29
|
-
createdAt: existing?.created_at ?? now,
|
|
30
|
-
updatedAt: now,
|
|
31
|
-
});
|
|
32
|
-
const saved = this.get(input.project, input.scope, input.managerName);
|
|
33
|
-
if (!saved.ok)
|
|
34
|
-
return saved;
|
|
35
|
-
return saved;
|
|
36
|
-
}
|
|
37
|
-
catch (cause) {
|
|
38
|
-
return fail('Failed to save manager profile overlay', cause);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
get(project, scope, managerName) {
|
|
42
|
-
try {
|
|
43
|
-
const row = this.find(project, scope, managerName);
|
|
44
|
-
return row === undefined ? missing(`Manager profile overlay not found: ${project}/${scope}/${managerName}`) : ok(map(row));
|
|
45
|
-
}
|
|
46
|
-
catch (cause) {
|
|
47
|
-
return fail('Failed to read manager profile overlay', cause);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
find(project, scope, managerName) {
|
|
51
|
-
return this.db.connection
|
|
52
|
-
.prepare('SELECT * FROM manager_profile_overlays WHERE project=? AND scope=? AND manager_name=?')
|
|
53
|
-
.get(project.trim(), scope, managerName.trim());
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
function validate(input) {
|
|
57
|
-
if (!input.project.trim())
|
|
58
|
-
return validationFailure('Project is required');
|
|
59
|
-
if (!input.managerName.trim())
|
|
60
|
-
return validationFailure('managerName is required');
|
|
61
|
-
if (!input.instructions.trim())
|
|
62
|
-
return validationFailure('instructions are required');
|
|
63
|
-
return ok(undefined);
|
|
64
|
-
}
|
|
65
|
-
function map(row) {
|
|
66
|
-
return {
|
|
67
|
-
id: row.id,
|
|
68
|
-
project: row.project,
|
|
69
|
-
scope: row.scope,
|
|
70
|
-
managerName: row.manager_name,
|
|
71
|
-
instructions: row.instructions,
|
|
72
|
-
createdAt: row.created_at,
|
|
73
|
-
updatedAt: row.updated_at,
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
function ok(value) {
|
|
77
|
-
return { ok: true, value };
|
|
78
|
-
}
|
|
79
|
-
function missing(message) {
|
|
80
|
-
return { ok: false, error: { code: 'not_found', message } };
|
|
81
|
-
}
|
|
82
|
-
function validationFailure(message) {
|
|
83
|
-
return { ok: false, error: { code: 'validation_failed', message } };
|
|
84
|
-
}
|
|
85
|
-
function fail(message, cause) {
|
|
86
|
-
const error = { code: 'validation_failed', message };
|
|
87
|
-
if (cause !== undefined)
|
|
88
|
-
error.cause = cause;
|
|
89
|
-
return { ok: false, error };
|
|
90
|
-
}
|
|
1
|
+
export * from '../../storage/agents/repositories/manager-profile-overlays.js';
|
package/dist/agents/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from '../domain/agents/schema.js';
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { responseByteAccounting, summarizePayloadContent } from '../../payload/payload-summary.js';
|
|
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 ? { ok: false, error: { code, message } } : { ok: false, error: { code, message, cause: { nestedFailures } } };
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function validateActivationInput(input) {
|
|
119
|
+
if (input.project.trim().length === 0)
|
|
120
|
+
return validationFailure('Project is required');
|
|
121
|
+
if (input.userIntent.trim().length === 0)
|
|
122
|
+
return validationFailure('userIntent is required');
|
|
123
|
+
if (input.agentId !== undefined && input.agentId.trim().length === 0)
|
|
124
|
+
return validationFailure('agentId must not be empty');
|
|
125
|
+
if (input.payloadMode !== undefined && input.payloadMode !== 'compact' && input.payloadMode !== 'verbose')
|
|
126
|
+
return validationFailure('payloadMode must be compact or verbose');
|
|
127
|
+
const validated = {
|
|
128
|
+
project: input.project.trim(),
|
|
129
|
+
scope: input.scope ?? 'project',
|
|
130
|
+
userIntent: input.userIntent.trim(),
|
|
131
|
+
workflow: input.workflow?.trim() || 'agent-activation',
|
|
132
|
+
phase: input.phase?.trim() || 'activation',
|
|
133
|
+
};
|
|
134
|
+
if (input.agentId !== undefined)
|
|
135
|
+
validated.agentId = input.agentId.trim();
|
|
136
|
+
if (input.workspaceRoot !== undefined)
|
|
137
|
+
validated.workspaceRoot = input.workspaceRoot;
|
|
138
|
+
if (input.maxSourceBytes !== undefined)
|
|
139
|
+
validated.maxSourceBytes = input.maxSourceBytes;
|
|
140
|
+
if (input.providerAdapter !== undefined) {
|
|
141
|
+
if (input.providerAdapter.trim().length === 0)
|
|
142
|
+
return validationFailure('providerAdapter must not be empty');
|
|
143
|
+
validated.providerAdapter = input.providerAdapter.trim();
|
|
144
|
+
}
|
|
145
|
+
if (input.payloadMode !== undefined)
|
|
146
|
+
validated.payloadMode = input.payloadMode;
|
|
147
|
+
return ok(validated);
|
|
148
|
+
}
|
|
149
|
+
function resolvePayloadMode(input) {
|
|
150
|
+
return input.payloadMode ?? 'compact';
|
|
151
|
+
}
|
|
152
|
+
function toPayloadInput(input, agentId, payloadMode) {
|
|
153
|
+
const payload = { project: input.project, scope: input.scope };
|
|
154
|
+
if (input.agentId !== undefined)
|
|
155
|
+
payload.agentId = agentId;
|
|
156
|
+
else
|
|
157
|
+
payload.useManagerOverlay = true;
|
|
158
|
+
if (input.workspaceRoot !== undefined)
|
|
159
|
+
payload.workspaceRoot = input.workspaceRoot;
|
|
160
|
+
if (input.maxSourceBytes !== undefined)
|
|
161
|
+
payload.maxSourceBytes = input.maxSourceBytes;
|
|
162
|
+
payload.payloadMode = payloadMode;
|
|
163
|
+
return payload;
|
|
164
|
+
}
|
|
165
|
+
function checkpointState(envelopeWithoutRun, runId, mode) {
|
|
166
|
+
const base = { ...envelopeWithoutRun, run: { id: runId, status: 'created', checkpointId: null } };
|
|
167
|
+
if (mode === 'verbose')
|
|
168
|
+
return toJson(base);
|
|
169
|
+
return toJson({
|
|
170
|
+
version: base.version,
|
|
171
|
+
run: base.run,
|
|
172
|
+
agent: base.agent,
|
|
173
|
+
provider: base.provider,
|
|
174
|
+
modelSelection: base.modelSelection,
|
|
175
|
+
providerPayload: {
|
|
176
|
+
version: base.providerPayload.version,
|
|
177
|
+
provider: base.providerPayload.provider,
|
|
178
|
+
payloadMode: base.providerPayload.payloadMode,
|
|
179
|
+
selection: base.providerPayload.selection,
|
|
180
|
+
providerArtifacts: base.providerPayload.providerArtifacts,
|
|
181
|
+
skillDiagnostics: base.providerPayload.skillDiagnostics,
|
|
182
|
+
safety: base.providerPayload.safety,
|
|
183
|
+
warnings: base.providerPayload.warnings,
|
|
184
|
+
},
|
|
185
|
+
skillsContext: base.skillsContext === undefined
|
|
186
|
+
? undefined
|
|
187
|
+
: {
|
|
188
|
+
version: base.skillsContext.version,
|
|
189
|
+
providerAgnostic: base.skillsContext.providerAgnostic,
|
|
190
|
+
context: base.skillsContext.context,
|
|
191
|
+
itemCount: base.skillsContext.items.length,
|
|
192
|
+
skipped: base.skillsContext.skipped,
|
|
193
|
+
skillDiagnostics: base.skillsContext.skillDiagnostics,
|
|
194
|
+
warnings: base.skillsContext.warnings,
|
|
195
|
+
},
|
|
196
|
+
nextSafeAction: base.nextSafeAction,
|
|
197
|
+
safety: base.safety,
|
|
198
|
+
warnings: base.warnings,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
function compactActivationEnvelope(verbose, input) {
|
|
202
|
+
const compactProviderPayload = {
|
|
203
|
+
version: verbose.providerPayload.version,
|
|
204
|
+
provider: verbose.providerPayload.provider,
|
|
205
|
+
payloadMode: 'compact',
|
|
206
|
+
installable: verbose.providerPayload.installable,
|
|
207
|
+
selection: verbose.providerPayload.selection,
|
|
208
|
+
providerArtifacts: verbose.providerPayload.providerArtifacts,
|
|
209
|
+
...(verbose.providerPayload.skillDiagnostics === undefined ? {} : { skillDiagnostics: verbose.providerPayload.skillDiagnostics }),
|
|
210
|
+
safety: verbose.providerPayload.safety,
|
|
211
|
+
warnings: verbose.providerPayload.warnings,
|
|
212
|
+
};
|
|
213
|
+
const fullRetrieval = {
|
|
214
|
+
tool: 'vgxness_agent_activate',
|
|
215
|
+
payloadMode: 'verbose',
|
|
216
|
+
input: {
|
|
217
|
+
project: input.project,
|
|
218
|
+
scope: input.scope,
|
|
219
|
+
agentId: verbose.agent.id,
|
|
220
|
+
userIntent: input.userIntent,
|
|
221
|
+
workflow: input.workflow,
|
|
222
|
+
phase: input.phase,
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
const omittedSections = [];
|
|
226
|
+
if (verbose.providerPayload.skillPayload !== undefined)
|
|
227
|
+
omittedSections.push(omittedSection('providerPayload.skillPayload', 'Duplicate of skillsContext; omitted from compact activation response.', fullRetrieval, verbose.providerPayload.skillPayload));
|
|
228
|
+
if (verbose.skillsContext !== undefined)
|
|
229
|
+
omittedSections.push(omittedSection('skillsContext', 'Skill details remain durably retrievable through verbose activation or skill payload calls.', fullRetrieval, verbose.skillsContext));
|
|
230
|
+
const compact = {
|
|
231
|
+
version: verbose.version,
|
|
232
|
+
agent: verbose.agent,
|
|
233
|
+
provider: verbose.provider,
|
|
234
|
+
modelSelection: verbose.modelSelection,
|
|
235
|
+
providerPayload: compactProviderPayload,
|
|
236
|
+
omittedSections,
|
|
237
|
+
governanceConstraints: [
|
|
238
|
+
'Activation is preview-only and does not execute providers.',
|
|
239
|
+
'No provider configuration, background worker, autonomous step, or secrets expansion is performed.',
|
|
240
|
+
'Request payloadMode=verbose when full provider payload or skills context is needed.',
|
|
241
|
+
],
|
|
242
|
+
nextSafeAction: verbose.nextSafeAction,
|
|
243
|
+
safety: verbose.safety,
|
|
244
|
+
warnings: verbose.warnings,
|
|
245
|
+
};
|
|
246
|
+
compact.responseByteAccounting = responseByteAccounting(verbose, compact);
|
|
247
|
+
return compact;
|
|
248
|
+
}
|
|
249
|
+
function omittedSection(path, reason, retrieval, value) {
|
|
250
|
+
const summary = summarizePayloadContent(JSON.stringify(value));
|
|
251
|
+
return { path, reason, hash: summary.contentHash, bytes: summary.contentBytes, retrieval };
|
|
252
|
+
}
|
|
253
|
+
function toJson(value) {
|
|
254
|
+
return JSON.parse(JSON.stringify(value));
|
|
255
|
+
}
|
|
256
|
+
function ok(value) {
|
|
257
|
+
return { ok: true, value };
|
|
258
|
+
}
|
|
259
|
+
function validationFailure(message) {
|
|
260
|
+
return { ok: false, error: { code: 'validation_failed', message } };
|
|
261
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const GLOBAL_PERSONAL_AGENTS_PROJECT = '__personal__';
|
|
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
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { AgentRepository } from '../../storage/agents/repositories/agents.js';
|
|
2
|
+
import { agentLookupContexts } from './agent-lookup-contexts.js';
|
|
3
|
+
import { AgentResolver } from './agent-resolver.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
|
+
}
|