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,147 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export class SkillStatusService {
|
|
3
|
-
skills;
|
|
4
|
-
agents;
|
|
5
|
-
constructor(skills, agents) {
|
|
6
|
-
this.skills = skills;
|
|
7
|
-
this.agents = agents;
|
|
8
|
-
}
|
|
9
|
-
getStatus(input) {
|
|
10
|
-
const scope = input.scope ?? 'project';
|
|
11
|
-
const provider = input.provider ?? 'opencode';
|
|
12
|
-
const modes = input.mode === undefined ? ['agent', 'subagent'] : [input.mode];
|
|
13
|
-
const diagnostics = [];
|
|
14
|
-
const registry = this.skillRegistry(input.project, scope);
|
|
15
|
-
if (!registry.ok)
|
|
16
|
-
return registry;
|
|
17
|
-
const selectedAgents = this.selectAgents(input.project, scope, modes, input.agent, diagnostics);
|
|
18
|
-
if (!selectedAgents.ok)
|
|
19
|
-
return selectedAgents;
|
|
20
|
-
const agentItems = [];
|
|
21
|
-
for (const agent of selectedAgents.value) {
|
|
22
|
-
const resolved = this.skills.resolveSkills({ agentId: agent.id, project: input.project, scope, providerAdapter: provider });
|
|
23
|
-
if (!resolved.ok)
|
|
24
|
-
return resolved;
|
|
25
|
-
const resolvedNames = resolved.value.skills.map((skill) => skill.name).sort(compareStrings);
|
|
26
|
-
const declared = [...agent.skills].sort(compareStrings);
|
|
27
|
-
const missing = declared.filter((name) => !resolvedNames.includes(name));
|
|
28
|
-
agentItems.push({
|
|
29
|
-
id: agent.id,
|
|
30
|
-
name: agent.name,
|
|
31
|
-
mode: agent.mode,
|
|
32
|
-
declaredSkills: declared,
|
|
33
|
-
resolvedSkills: resolvedNames,
|
|
34
|
-
missingSkills: missing,
|
|
35
|
-
diagnostics: resolved.value.skillDiagnostics.diagnostics,
|
|
36
|
-
});
|
|
37
|
-
diagnostics.push(...resolved.value.skillDiagnostics.diagnostics);
|
|
38
|
-
}
|
|
39
|
-
const declared = agentItems.reduce((sum, item) => sum + item.declaredSkills.length, 0);
|
|
40
|
-
const resolved = agentItems.reduce((sum, item) => sum + item.resolvedSkills.length, 0);
|
|
41
|
-
const missing = agentItems.reduce((sum, item) => sum + item.missingSkills.length, 0);
|
|
42
|
-
const v2Counts = this.skills.skills.getV2Counts(input.project, scope);
|
|
43
|
-
if (!v2Counts.ok)
|
|
44
|
-
return v2Counts;
|
|
45
|
-
return ok({
|
|
46
|
-
kind: 'skills-status',
|
|
47
|
-
version: 1,
|
|
48
|
-
project: input.project,
|
|
49
|
-
scope,
|
|
50
|
-
provider,
|
|
51
|
-
providerMode: 'preview-only',
|
|
52
|
-
providerState: 'preview-only',
|
|
53
|
-
mode: input.mode ?? 'all',
|
|
54
|
-
agent: input.agent ?? null,
|
|
55
|
-
context: {
|
|
56
|
-
project: input.project,
|
|
57
|
-
scope,
|
|
58
|
-
provider,
|
|
59
|
-
providerMode: 'preview-only',
|
|
60
|
-
providerState: 'preview-only',
|
|
61
|
-
...(input.mode !== undefined ? { mode: input.mode } : {}),
|
|
62
|
-
...(input.agent !== undefined ? { agent: input.agent } : {}),
|
|
63
|
-
},
|
|
64
|
-
skills: registry.value.items.map((skill) => ({
|
|
65
|
-
...skill,
|
|
66
|
-
registered: true,
|
|
67
|
-
active: skill.status === 'active',
|
|
68
|
-
current: skill.currentVersionId !== null && skill.currentVersion !== null,
|
|
69
|
-
providerAvailable: false,
|
|
70
|
-
})),
|
|
71
|
-
registry: { skills: registry.value, v2: v2Counts.value },
|
|
72
|
-
agents: { modes, declared, resolved, missing, items: agentItems },
|
|
73
|
-
diagnostics,
|
|
74
|
-
safety: {
|
|
75
|
-
readOnly: true,
|
|
76
|
-
previewOnly: true,
|
|
77
|
-
providerWrites: false,
|
|
78
|
-
usageRecorded: false,
|
|
79
|
-
repairAttempted: false,
|
|
80
|
-
installAttempted: false,
|
|
81
|
-
providerRepair: false,
|
|
82
|
-
providerInstall: false,
|
|
83
|
-
usageRecording: false,
|
|
84
|
-
},
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
skillRegistry(project, scope) {
|
|
88
|
-
const listedSkills = [];
|
|
89
|
-
for (const context of skillIndexContexts(project, scope)) {
|
|
90
|
-
const listed = this.skills.listSkills({ project: context.project, scope: context.scope });
|
|
91
|
-
if (!listed.ok)
|
|
92
|
-
return listed;
|
|
93
|
-
listedSkills.push(...listed.value);
|
|
94
|
-
}
|
|
95
|
-
const summaries = dedupeSkillSummariesByName(listedSkills);
|
|
96
|
-
const items = [];
|
|
97
|
-
for (const skill of summaries) {
|
|
98
|
-
const details = this.skills.getSkillDetails(skill.id);
|
|
99
|
-
if (!details.ok)
|
|
100
|
-
return details;
|
|
101
|
-
const currentVersion = details.value.currentVersion;
|
|
102
|
-
items.push({
|
|
103
|
-
id: skill.id,
|
|
104
|
-
name: skill.name,
|
|
105
|
-
description: skill.description,
|
|
106
|
-
source: currentVersion?.source ?? null,
|
|
107
|
-
currentVersionId: skill.currentVersionId ?? null,
|
|
108
|
-
currentVersion: currentVersion?.version ?? null,
|
|
109
|
-
status: currentVersion?.status ?? (skill.currentVersionId === undefined ? 'missing-current-version' : 'missing-current-version-record'),
|
|
110
|
-
attachments: details.value.attachments.length,
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
const active = items.filter((item) => item.status === 'active').length;
|
|
114
|
-
return ok({ total: items.length, active, inactive: items.length - active, items });
|
|
115
|
-
}
|
|
116
|
-
selectAgents(project, scope, modes, agentQuery, diagnostics) {
|
|
117
|
-
const selected = [];
|
|
118
|
-
for (const mode of modes) {
|
|
119
|
-
const listed = this.agents.listAgents({ project, scope, mode });
|
|
120
|
-
if (!listed.ok)
|
|
121
|
-
return listed;
|
|
122
|
-
for (const summary of listed.value) {
|
|
123
|
-
if (agentQuery !== undefined && summary.id !== agentQuery && summary.name !== agentQuery)
|
|
124
|
-
continue;
|
|
125
|
-
const agent = this.agents.getAgent(summary.id);
|
|
126
|
-
if (!agent.ok)
|
|
127
|
-
return agent;
|
|
128
|
-
selected.push(agent.value);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
if (agentQuery !== undefined && selected.length === 0) {
|
|
132
|
-
diagnostics.push({
|
|
133
|
-
code: 'SKILL_ATTACHMENT_MISSING',
|
|
134
|
-
severity: 'warning',
|
|
135
|
-
message: `No agent or subagent matched ${agentQuery} in ${project}/${scope}.`,
|
|
136
|
-
details: { agent: agentQuery, modes },
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
return ok(selected.sort((a, b) => compareStrings(`${a.mode}:${a.name}:${a.id}`, `${b.mode}:${b.name}:${b.id}`)));
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
function compareStrings(a, b) {
|
|
143
|
-
return a.localeCompare(b);
|
|
144
|
-
}
|
|
145
|
-
function ok(value) {
|
|
146
|
-
return { ok: true, value };
|
|
147
|
-
}
|
|
1
|
+
export * from '../application/skills/skill-status-service.js';
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
export class AgentSeedHistoryRepository {
|
|
3
|
+
db;
|
|
4
|
+
constructor(db) {
|
|
5
|
+
this.db = db;
|
|
6
|
+
}
|
|
7
|
+
append(input) {
|
|
8
|
+
const validation = validate(input);
|
|
9
|
+
if (!validation.ok)
|
|
10
|
+
return validation;
|
|
11
|
+
try {
|
|
12
|
+
const id = randomUUID();
|
|
13
|
+
const appliedAt = new Date().toISOString();
|
|
14
|
+
this.db.connection
|
|
15
|
+
.prepare(`
|
|
16
|
+
INSERT INTO agent_seed_history(id, applied_at, from_version, to_version, agent_name, project, scope, outcome, reason, source)
|
|
17
|
+
VALUES (@id, @appliedAt, @fromVersion, @toVersion, @agentName, @project, @scope, @outcome, @reason, @source)
|
|
18
|
+
`)
|
|
19
|
+
.run({
|
|
20
|
+
id,
|
|
21
|
+
appliedAt,
|
|
22
|
+
fromVersion: input.fromVersion,
|
|
23
|
+
toVersion: input.toVersion,
|
|
24
|
+
agentName: input.agentName,
|
|
25
|
+
project: input.project,
|
|
26
|
+
scope: input.scope,
|
|
27
|
+
outcome: input.outcome,
|
|
28
|
+
reason: input.reason ?? null,
|
|
29
|
+
source: input.source,
|
|
30
|
+
});
|
|
31
|
+
const entry = {
|
|
32
|
+
id,
|
|
33
|
+
appliedAt,
|
|
34
|
+
fromVersion: input.fromVersion,
|
|
35
|
+
toVersion: input.toVersion,
|
|
36
|
+
agentName: input.agentName,
|
|
37
|
+
project: input.project,
|
|
38
|
+
scope: input.scope,
|
|
39
|
+
outcome: input.outcome,
|
|
40
|
+
reason: input.reason ?? null,
|
|
41
|
+
source: input.source,
|
|
42
|
+
};
|
|
43
|
+
return ok(entry);
|
|
44
|
+
}
|
|
45
|
+
catch (cause) {
|
|
46
|
+
return fail('Failed to append agent_seed_history entry', cause);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
listRecent(filters = {}) {
|
|
50
|
+
try {
|
|
51
|
+
const where = [];
|
|
52
|
+
const parameters = {};
|
|
53
|
+
for (const [key, column] of [
|
|
54
|
+
['project', 'project'],
|
|
55
|
+
['scope', 'scope'],
|
|
56
|
+
['agentName', 'agent_name'],
|
|
57
|
+
]) {
|
|
58
|
+
const value = filters[key];
|
|
59
|
+
if (value !== undefined) {
|
|
60
|
+
where.push(`${column}=@${key}`);
|
|
61
|
+
parameters[key] = value;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const limit = Math.max(1, Math.min(filters.limit ?? 100, 1000));
|
|
65
|
+
const rows = this.db.connection
|
|
66
|
+
.prepare(`
|
|
67
|
+
SELECT * FROM agent_seed_history
|
|
68
|
+
${where.length ? `WHERE ${where.join(' AND ')}` : ''}
|
|
69
|
+
ORDER BY applied_at DESC
|
|
70
|
+
LIMIT ${limit}
|
|
71
|
+
`)
|
|
72
|
+
.all(parameters);
|
|
73
|
+
return ok(rows.map(map));
|
|
74
|
+
}
|
|
75
|
+
catch (cause) {
|
|
76
|
+
return fail('Failed to list agent_seed_history entries', cause);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function validate(input) {
|
|
81
|
+
if (!input.project.trim())
|
|
82
|
+
return validationFailure('agent_seed_history project is required');
|
|
83
|
+
if (input.scope !== 'project' && input.scope !== 'personal')
|
|
84
|
+
return validationFailure('agent_seed_history scope is invalid');
|
|
85
|
+
if (!input.agentName.trim())
|
|
86
|
+
return validationFailure('agent_seed_history agentName is required');
|
|
87
|
+
if (!Number.isInteger(input.toVersion) || input.toVersion <= 0)
|
|
88
|
+
return validationFailure('agent_seed_history toVersion must be a positive integer');
|
|
89
|
+
if (input.fromVersion !== null && (!Number.isInteger(input.fromVersion) || input.fromVersion < 0))
|
|
90
|
+
return validationFailure('agent_seed_history fromVersion must be null or non-negative integer');
|
|
91
|
+
if (!input.source.trim())
|
|
92
|
+
return validationFailure('agent_seed_history source is required');
|
|
93
|
+
if (input.outcome !== 'created' &&
|
|
94
|
+
input.outcome !== 'upgraded' &&
|
|
95
|
+
input.outcome !== 'noop' &&
|
|
96
|
+
input.outcome !== 'overwrote-custom-instructions' &&
|
|
97
|
+
input.outcome !== 'validation_failed' &&
|
|
98
|
+
input.outcome !== 'db_error') {
|
|
99
|
+
return validationFailure(`agent_seed_history outcome is invalid: ${input.outcome}`);
|
|
100
|
+
}
|
|
101
|
+
return ok(undefined);
|
|
102
|
+
}
|
|
103
|
+
function map(row) {
|
|
104
|
+
return {
|
|
105
|
+
id: String(row.id),
|
|
106
|
+
appliedAt: String(row.applied_at),
|
|
107
|
+
fromVersion: row.from_version === null || row.from_version === undefined ? null : Number(row.from_version),
|
|
108
|
+
toVersion: Number(row.to_version),
|
|
109
|
+
agentName: String(row.agent_name),
|
|
110
|
+
project: String(row.project),
|
|
111
|
+
scope: row.scope,
|
|
112
|
+
outcome: String(row.outcome),
|
|
113
|
+
reason: row.reason === null || row.reason === undefined ? null : String(row.reason),
|
|
114
|
+
source: String(row.source),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function ok(value) {
|
|
118
|
+
return { ok: true, value };
|
|
119
|
+
}
|
|
120
|
+
function validationFailure(message) {
|
|
121
|
+
return { ok: false, error: { code: 'validation_failed', message } };
|
|
122
|
+
}
|
|
123
|
+
function fail(message, cause) {
|
|
124
|
+
const error = { code: 'validation_failed', message };
|
|
125
|
+
if (cause !== undefined)
|
|
126
|
+
error.cause = cause;
|
|
127
|
+
return { ok: false, error };
|
|
128
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
export class AgentRepository {
|
|
3
|
+
db;
|
|
4
|
+
constructor(db) {
|
|
5
|
+
this.db = db;
|
|
6
|
+
}
|
|
7
|
+
register(input) {
|
|
8
|
+
const validation = validate(input);
|
|
9
|
+
if (!validation.ok)
|
|
10
|
+
return validation;
|
|
11
|
+
const parentValidation = input.mode === 'subagent' ? this.validateParent(input) : ok(undefined);
|
|
12
|
+
if (!parentValidation.ok)
|
|
13
|
+
return parentValidation;
|
|
14
|
+
const result = this.db.transaction(() => {
|
|
15
|
+
const existing = this.findByNaturalKey(input.project, input.scope, input.name);
|
|
16
|
+
if (existing !== undefined && existing.mode !== input.mode) {
|
|
17
|
+
throw new AgentRegistryValidationError(`Agent already exists as ${existing.mode}: ${input.project}/${input.scope}/${input.name}`);
|
|
18
|
+
}
|
|
19
|
+
const id = existing?.id ?? randomUUID();
|
|
20
|
+
const now = new Date().toISOString();
|
|
21
|
+
const parameters = toRowParameters(input, id, existing?.created_at ?? now, now);
|
|
22
|
+
this.db.connection
|
|
23
|
+
.prepare(`
|
|
24
|
+
INSERT INTO agents(id, project, scope, mode, name, description, instructions_json, capabilities_json, permissions_json, memory_json, workflows_json, skills_json, adapters_json, parent_agent_id, created_at, updated_at)
|
|
25
|
+
VALUES (@id, @project, @scope, @mode, @name, @description, @instructionsJson, @capabilitiesJson, @permissionsJson, @memoryJson, @workflowsJson, @skillsJson, @adaptersJson, @parentAgentId, @createdAt, @updatedAt)
|
|
26
|
+
ON CONFLICT(project, scope, name) DO UPDATE SET
|
|
27
|
+
mode=excluded.mode,
|
|
28
|
+
description=excluded.description,
|
|
29
|
+
instructions_json=excluded.instructions_json,
|
|
30
|
+
capabilities_json=excluded.capabilities_json,
|
|
31
|
+
permissions_json=excluded.permissions_json,
|
|
32
|
+
memory_json=excluded.memory_json,
|
|
33
|
+
workflows_json=excluded.workflows_json,
|
|
34
|
+
skills_json=excluded.skills_json,
|
|
35
|
+
adapters_json=excluded.adapters_json,
|
|
36
|
+
parent_agent_id=excluded.parent_agent_id,
|
|
37
|
+
updated_at=excluded.updated_at
|
|
38
|
+
`)
|
|
39
|
+
.run(parameters);
|
|
40
|
+
const found = this.getById(id);
|
|
41
|
+
if (!found.ok)
|
|
42
|
+
throw new Error(found.error.message);
|
|
43
|
+
return found.value;
|
|
44
|
+
});
|
|
45
|
+
if (!result.ok && result.error.cause instanceof AgentRegistryValidationError) {
|
|
46
|
+
return validationFailure(result.error.cause.message);
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
getById(id) {
|
|
51
|
+
try {
|
|
52
|
+
const row = this.db.connection.prepare('SELECT * FROM agents WHERE id=?').get(id);
|
|
53
|
+
return row ? ok(map(row)) : missing(`Agent not found: ${id}`);
|
|
54
|
+
}
|
|
55
|
+
catch (cause) {
|
|
56
|
+
return fail('Failed to read agent', cause);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
getByName(project, scope, name) {
|
|
60
|
+
try {
|
|
61
|
+
const row = this.findByNaturalKey(project, scope, name);
|
|
62
|
+
return row ? ok(map(row)) : missing(`Agent not found: ${project}/${scope}/${name}`);
|
|
63
|
+
}
|
|
64
|
+
catch (cause) {
|
|
65
|
+
return fail('Failed to read agent by name', cause);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
list(filters = {}) {
|
|
69
|
+
try {
|
|
70
|
+
const where = [];
|
|
71
|
+
const parameters = {};
|
|
72
|
+
for (const [key, column] of [
|
|
73
|
+
['project', 'project'],
|
|
74
|
+
['scope', 'scope'],
|
|
75
|
+
['mode', 'mode'],
|
|
76
|
+
['parentAgentId', 'parent_agent_id'],
|
|
77
|
+
]) {
|
|
78
|
+
const value = filters[key];
|
|
79
|
+
if (value !== undefined) {
|
|
80
|
+
where.push(`${column}=@${key}`);
|
|
81
|
+
parameters[key] = value;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const rows = this.db.connection
|
|
85
|
+
.prepare(`
|
|
86
|
+
SELECT * FROM agents
|
|
87
|
+
${where.length ? `WHERE ${where.join(' AND ')}` : ''}
|
|
88
|
+
ORDER BY name ASC
|
|
89
|
+
`)
|
|
90
|
+
.all(parameters);
|
|
91
|
+
return ok(rows.map((row) => toSummary(map(row))));
|
|
92
|
+
}
|
|
93
|
+
catch (cause) {
|
|
94
|
+
return fail('Failed to list agents', cause);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
findByNaturalKey(project, scope, name) {
|
|
98
|
+
return this.db.connection.prepare('SELECT * FROM agents WHERE project=? AND scope=? AND name=?').get(project, scope, name);
|
|
99
|
+
}
|
|
100
|
+
validateParent(input) {
|
|
101
|
+
if (input.parentAgentId === undefined)
|
|
102
|
+
return validationFailure('Subagents require parentAgentId');
|
|
103
|
+
const parent = this.getById(input.parentAgentId);
|
|
104
|
+
if (!parent.ok)
|
|
105
|
+
return validationFailure(parent.error.message);
|
|
106
|
+
if (parent.value.mode !== 'agent')
|
|
107
|
+
return validationFailure('Subagent parent must be an agent');
|
|
108
|
+
if (parent.value.project !== input.project || parent.value.scope !== input.scope)
|
|
109
|
+
return validationFailure('Subagent parent must share project and scope');
|
|
110
|
+
return ok(undefined);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function validate(input) {
|
|
114
|
+
if (!input.project.trim())
|
|
115
|
+
return validationFailure('Agent project is required');
|
|
116
|
+
if (!input.name.trim())
|
|
117
|
+
return validationFailure('Agent name is required');
|
|
118
|
+
if (!input.description.trim())
|
|
119
|
+
return validationFailure('Agent description is required');
|
|
120
|
+
if (!input.instructions.value.trim())
|
|
121
|
+
return validationFailure('Agent instructions are required');
|
|
122
|
+
if (input.mode === 'agent' && input.parentAgentId !== undefined)
|
|
123
|
+
return validationFailure('Top-level agents cannot have parentAgentId');
|
|
124
|
+
return ok(undefined);
|
|
125
|
+
}
|
|
126
|
+
function toRowParameters(input, id, createdAt, updatedAt) {
|
|
127
|
+
return {
|
|
128
|
+
id,
|
|
129
|
+
project: input.project,
|
|
130
|
+
scope: input.scope,
|
|
131
|
+
mode: input.mode,
|
|
132
|
+
name: input.name,
|
|
133
|
+
description: input.description,
|
|
134
|
+
instructionsJson: JSON.stringify(input.instructions),
|
|
135
|
+
capabilitiesJson: JSON.stringify(input.capabilities ?? []),
|
|
136
|
+
permissionsJson: JSON.stringify(input.permissions ?? {}),
|
|
137
|
+
memoryJson: JSON.stringify(input.memory ?? { scopes: [] }),
|
|
138
|
+
workflowsJson: JSON.stringify(input.workflows ?? []),
|
|
139
|
+
skillsJson: JSON.stringify(input.skills ?? []),
|
|
140
|
+
adaptersJson: JSON.stringify(input.adapters ?? {}),
|
|
141
|
+
parentAgentId: input.parentAgentId ?? null,
|
|
142
|
+
createdAt,
|
|
143
|
+
updatedAt,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
function map(row) {
|
|
147
|
+
const value = {
|
|
148
|
+
id: row.id,
|
|
149
|
+
project: row.project,
|
|
150
|
+
scope: row.scope,
|
|
151
|
+
mode: row.mode,
|
|
152
|
+
name: row.name,
|
|
153
|
+
description: row.description,
|
|
154
|
+
instructions: JSON.parse(row.instructions_json),
|
|
155
|
+
capabilities: JSON.parse(row.capabilities_json),
|
|
156
|
+
permissions: JSON.parse(row.permissions_json),
|
|
157
|
+
memory: JSON.parse(row.memory_json),
|
|
158
|
+
workflows: JSON.parse(row.workflows_json),
|
|
159
|
+
skills: JSON.parse(row.skills_json),
|
|
160
|
+
adapters: JSON.parse(row.adapters_json),
|
|
161
|
+
createdAt: row.created_at,
|
|
162
|
+
updatedAt: row.updated_at,
|
|
163
|
+
};
|
|
164
|
+
if (row.parent_agent_id !== null)
|
|
165
|
+
value.parentAgentId = row.parent_agent_id;
|
|
166
|
+
return value;
|
|
167
|
+
}
|
|
168
|
+
function toSummary(agent) {
|
|
169
|
+
const value = {
|
|
170
|
+
id: agent.id,
|
|
171
|
+
project: agent.project,
|
|
172
|
+
scope: agent.scope,
|
|
173
|
+
mode: agent.mode,
|
|
174
|
+
name: agent.name,
|
|
175
|
+
description: agent.description,
|
|
176
|
+
capabilities: agent.capabilities,
|
|
177
|
+
createdAt: agent.createdAt,
|
|
178
|
+
updatedAt: agent.updatedAt,
|
|
179
|
+
};
|
|
180
|
+
if (agent.parentAgentId !== undefined)
|
|
181
|
+
value.parentAgentId = agent.parentAgentId;
|
|
182
|
+
return value;
|
|
183
|
+
}
|
|
184
|
+
function ok(value) {
|
|
185
|
+
return { ok: true, value };
|
|
186
|
+
}
|
|
187
|
+
function missing(message) {
|
|
188
|
+
return { ok: false, error: { code: 'not_found', message } };
|
|
189
|
+
}
|
|
190
|
+
function validationFailure(message) {
|
|
191
|
+
return { ok: false, error: { code: 'validation_failed', message } };
|
|
192
|
+
}
|
|
193
|
+
function fail(message, cause) {
|
|
194
|
+
const error = { code: 'validation_failed', message };
|
|
195
|
+
if (cause !== undefined)
|
|
196
|
+
error.cause = cause;
|
|
197
|
+
return { ok: false, error };
|
|
198
|
+
}
|
|
199
|
+
class AgentRegistryValidationError extends Error {
|
|
200
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
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
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
export class ArtifactRepository {
|
|
3
|
+
db;
|
|
4
|
+
constructor(db) {
|
|
5
|
+
this.db = db;
|
|
6
|
+
}
|
|
7
|
+
save(input) {
|
|
8
|
+
const result = this.db.transaction(() => {
|
|
9
|
+
const existing = this.db.connection.prepare('SELECT * FROM artifacts WHERE project=@project AND topic_key=@topicKey').get(input);
|
|
10
|
+
const now = new Date().toISOString();
|
|
11
|
+
this.db.connection
|
|
12
|
+
.prepare(`INSERT INTO artifacts(id, project, topic_key, phase, content, metadata_json, observation_id, created_at, updated_at)
|
|
13
|
+
VALUES (@id, @project, @topicKey, @phase, @content, @metadataJson, @observationId, @createdAt, @updatedAt)
|
|
14
|
+
ON CONFLICT(project, topic_key) DO UPDATE SET phase=excluded.phase, content=excluded.content, metadata_json=excluded.metadata_json, observation_id=excluded.observation_id, updated_at=excluded.updated_at`)
|
|
15
|
+
.run({
|
|
16
|
+
...input,
|
|
17
|
+
metadataJson: input.metadata === undefined ? null : JSON.stringify(input.metadata),
|
|
18
|
+
id: existing?.id ?? randomUUID(),
|
|
19
|
+
createdAt: existing?.created_at ?? now,
|
|
20
|
+
updatedAt: now,
|
|
21
|
+
});
|
|
22
|
+
const artifact = this.getByTopic(input.project, input.topicKey);
|
|
23
|
+
if (!artifact.ok)
|
|
24
|
+
throw new Error(artifact.error.message);
|
|
25
|
+
return artifact.value;
|
|
26
|
+
});
|
|
27
|
+
return result.ok ? result : fail(result.error.message, result.error.cause);
|
|
28
|
+
}
|
|
29
|
+
getByTopic(project, topicKey) {
|
|
30
|
+
try {
|
|
31
|
+
const row = this.db.connection.prepare('SELECT * FROM artifacts WHERE project=? AND topic_key=?').get(project, topicKey);
|
|
32
|
+
return row ? { ok: true, value: map(row) } : { ok: false, error: { code: 'not_found', message: `Artifact not found: ${topicKey}` } };
|
|
33
|
+
}
|
|
34
|
+
catch (cause) {
|
|
35
|
+
return fail('Failed to read artifact', cause);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
listByTopicPrefix(project, topicPrefix) {
|
|
39
|
+
try {
|
|
40
|
+
const rows = this.db.connection
|
|
41
|
+
.prepare('SELECT * FROM artifacts WHERE project=? AND topic_key LIKE ? ORDER BY topic_key ASC')
|
|
42
|
+
.all(project, `${topicPrefix}%`);
|
|
43
|
+
return { ok: true, value: rows.map(map).filter((artifact) => artifact.topicKey.startsWith(topicPrefix)) };
|
|
44
|
+
}
|
|
45
|
+
catch (cause) {
|
|
46
|
+
return fail('Failed to list artifacts', cause);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function map(row) {
|
|
51
|
+
const artifact = {
|
|
52
|
+
id: row.id,
|
|
53
|
+
project: row.project,
|
|
54
|
+
topicKey: row.topic_key,
|
|
55
|
+
phase: row.phase,
|
|
56
|
+
content: row.content,
|
|
57
|
+
observationId: row.observation_id,
|
|
58
|
+
createdAt: row.created_at,
|
|
59
|
+
updatedAt: row.updated_at,
|
|
60
|
+
};
|
|
61
|
+
if (row.metadata_json !== null && row.metadata_json !== undefined)
|
|
62
|
+
artifact.metadata = JSON.parse(row.metadata_json);
|
|
63
|
+
return artifact;
|
|
64
|
+
}
|
|
65
|
+
function fail(message, cause) {
|
|
66
|
+
return { ok: false, error: { code: 'validation_failed', message, cause } };
|
|
67
|
+
}
|