vgxness 1.20.5 → 1.20.7
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 -246
- 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 +364 -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/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 -1132
- package/dist/mcp/stdio-server.js +1 -116
- package/dist/mcp/validation.js +1 -2383
- 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/policy-evaluator.js +12 -5
- 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 -1470
- 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 -217
- 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/sdd/manager-prompt-autonomy/apply-progress.md +28 -0
- package/docs/sdd/manager-prompt-autonomy/design.md +63 -0
- package/docs/sdd/manager-prompt-autonomy/proposal.md +57 -0
- package/docs/sdd/manager-prompt-autonomy/tasks.md +19 -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,67 +1 @@
|
|
|
1
|
-
|
|
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
|
-
}
|
|
1
|
+
export * from '../../storage/memory/repositories/artifacts.js';
|
|
@@ -1,217 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { normalizeLimit, toFtsMatchQuery } from '../search.js';
|
|
3
|
-
export class ObservationRepository {
|
|
4
|
-
db;
|
|
5
|
-
constructor(db) {
|
|
6
|
-
this.db = db;
|
|
7
|
-
}
|
|
8
|
-
save(input) {
|
|
9
|
-
const result = this.db.transaction(() => {
|
|
10
|
-
const existing = input.topicKey ? this.topic(input) : undefined;
|
|
11
|
-
const id = existing?.id ?? randomUUID();
|
|
12
|
-
const now = new Date().toISOString();
|
|
13
|
-
if (existing)
|
|
14
|
-
this.db.connection
|
|
15
|
-
.prepare('UPDATE observations SET title=@title, content=@content, updated_at=@updatedAt WHERE id=@id')
|
|
16
|
-
.run({ id, title: input.title, content: input.content, updatedAt: now });
|
|
17
|
-
else
|
|
18
|
-
this.db.connection
|
|
19
|
-
.prepare(`INSERT INTO observations(id, project, scope, type, title, content, topic_key, created_at, updated_at)
|
|
20
|
-
VALUES (@id, @project, @scope, @type, @title, @content, @topicKey, @createdAt, @updatedAt)`)
|
|
21
|
-
.run({ ...input, id, topicKey: input.topicKey ?? null, createdAt: now, updatedAt: now });
|
|
22
|
-
this.appendRevision(id, input.topicKey === undefined
|
|
23
|
-
? { type: input.type, title: input.title, content: input.content, createdAt: now }
|
|
24
|
-
: { type: input.type, title: input.title, content: input.content, topicKey: input.topicKey, createdAt: now });
|
|
25
|
-
const found = this.getById(id);
|
|
26
|
-
if (!found.ok)
|
|
27
|
-
throw new Error(found.error.message);
|
|
28
|
-
return found.value;
|
|
29
|
-
});
|
|
30
|
-
return result.ok ? result : fail(result.error.message, result.error.cause);
|
|
31
|
-
}
|
|
32
|
-
getById(id) {
|
|
33
|
-
try {
|
|
34
|
-
const row = this.db.connection.prepare('SELECT * FROM observations WHERE id=?').get(id);
|
|
35
|
-
return row ? ok(map(row)) : missing(`Observation not found: ${id}`);
|
|
36
|
-
}
|
|
37
|
-
catch (cause) {
|
|
38
|
-
return fail('Failed to read observation', cause);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
update(input) {
|
|
42
|
-
const existing = this.getById(input.id);
|
|
43
|
-
if (!existing.ok)
|
|
44
|
-
return existing;
|
|
45
|
-
const result = this.db.transaction(() => {
|
|
46
|
-
const next = { ...existing.value, ...input, updatedAt: new Date().toISOString() };
|
|
47
|
-
this.db.connection
|
|
48
|
-
.prepare(`UPDATE observations SET type=@type, title=@title, content=@content, topic_key=@topicKey, updated_at=@updatedAt WHERE id=@id`)
|
|
49
|
-
.run({
|
|
50
|
-
id: input.id,
|
|
51
|
-
type: next.type,
|
|
52
|
-
title: next.title,
|
|
53
|
-
content: next.content,
|
|
54
|
-
topicKey: next.topicKey ?? null,
|
|
55
|
-
updatedAt: next.updatedAt,
|
|
56
|
-
});
|
|
57
|
-
const found = this.getById(input.id);
|
|
58
|
-
if (!found.ok)
|
|
59
|
-
throw new Error(found.error.message);
|
|
60
|
-
return found.value;
|
|
61
|
-
});
|
|
62
|
-
return result.ok ? result : fail(result.error.message, result.error.cause);
|
|
63
|
-
}
|
|
64
|
-
getByTopic(input) {
|
|
65
|
-
try {
|
|
66
|
-
const row = input.topicKey ? this.topic(input) : undefined;
|
|
67
|
-
return row ? ok(map(row)) : missing(`Observation topic not found: ${input.topicKey ?? ''}`);
|
|
68
|
-
}
|
|
69
|
-
catch (cause) {
|
|
70
|
-
return fail('Failed to read observation by topic', cause);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
search(filters) {
|
|
74
|
-
try {
|
|
75
|
-
const params = { limit: normalizeLimit(filters.limit) };
|
|
76
|
-
const where = [];
|
|
77
|
-
let from = 'observations o';
|
|
78
|
-
if (filters.query?.trim()) {
|
|
79
|
-
from = 'observations o JOIN observations_fts fts ON fts.rowid=o.rowid';
|
|
80
|
-
where.push('observations_fts MATCH @query');
|
|
81
|
-
params.query = toFtsMatchQuery(filters.query);
|
|
82
|
-
}
|
|
83
|
-
for (const [key, column] of [
|
|
84
|
-
['project', 'project'],
|
|
85
|
-
['scope', 'scope'],
|
|
86
|
-
['type', 'type'],
|
|
87
|
-
]) {
|
|
88
|
-
const value = filters[key];
|
|
89
|
-
if (value) {
|
|
90
|
-
where.push(`o.${column}=@${key}`);
|
|
91
|
-
params[key] = value;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
if (filters.topicKey) {
|
|
95
|
-
const topicKeyFilter = normalizeTopicKeySearchFilter(filters.topicKey);
|
|
96
|
-
if (topicKeyFilter.kind === 'exact') {
|
|
97
|
-
where.push('o.topic_key=@topicKey');
|
|
98
|
-
params.topicKey = topicKeyFilter.value;
|
|
99
|
-
}
|
|
100
|
-
else if (topicKeyFilter.kind === 'prefix') {
|
|
101
|
-
where.push(`(o.topic_key=@topicKey OR o.topic_key LIKE @topicKeyPrefix ESCAPE '\\')`);
|
|
102
|
-
params.topicKey = topicKeyFilter.value;
|
|
103
|
-
params.topicKeyPrefix = `${escapeLike(topicKeyFilter.value)}/%`;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
const rows = this.db.connection
|
|
107
|
-
.prepare(`SELECT o.* FROM ${from} ${where.length ? `WHERE ${where.join(' AND ')}` : ''} ORDER BY o.updated_at DESC LIMIT @limit`)
|
|
108
|
-
.all(params);
|
|
109
|
-
return ok(rows.map(map));
|
|
110
|
-
}
|
|
111
|
-
catch (cause) {
|
|
112
|
-
return fail('Failed to search observations', cause);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
searchPreviews(filters) {
|
|
116
|
-
const result = this.search(filters);
|
|
117
|
-
if (!result.ok)
|
|
118
|
-
return result;
|
|
119
|
-
return ok(result.value.map(toSearchResult));
|
|
120
|
-
}
|
|
121
|
-
listRevisions(observationId) {
|
|
122
|
-
try {
|
|
123
|
-
const rows = this.db.connection.prepare('SELECT * FROM observation_revisions WHERE observation_id=? ORDER BY revision ASC').all(observationId);
|
|
124
|
-
return ok(rows.map(mapRevision));
|
|
125
|
-
}
|
|
126
|
-
catch (cause) {
|
|
127
|
-
return fail('Failed to read observation revisions', cause);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
topic(input) {
|
|
131
|
-
return this.db.connection.prepare('SELECT * FROM observations WHERE project=@project AND scope=@scope AND type=@type AND topic_key=@topicKey').get(input);
|
|
132
|
-
}
|
|
133
|
-
appendRevision(observationId, input) {
|
|
134
|
-
const current = this.db.connection
|
|
135
|
-
.prepare('SELECT COALESCE(MAX(revision), 0) AS revision FROM observation_revisions WHERE observation_id=?')
|
|
136
|
-
.get(observationId);
|
|
137
|
-
this.db.connection
|
|
138
|
-
.prepare(`INSERT INTO observation_revisions(id, observation_id, revision, type, title, content, topic_key, created_at)
|
|
139
|
-
VALUES (@id, @observationId, @revision, @type, @title, @content, @topicKey, @createdAt)`)
|
|
140
|
-
.run({
|
|
141
|
-
id: randomUUID(),
|
|
142
|
-
observationId,
|
|
143
|
-
revision: Number(current?.revision ?? 0) + 1,
|
|
144
|
-
type: input.type,
|
|
145
|
-
title: input.title,
|
|
146
|
-
content: input.content,
|
|
147
|
-
topicKey: input.topicKey ?? null,
|
|
148
|
-
createdAt: input.createdAt,
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
function normalizeTopicKeySearchFilter(topicKey) {
|
|
153
|
-
if (topicKey === '*')
|
|
154
|
-
return { kind: 'all' };
|
|
155
|
-
if (!topicKey.includes('/'))
|
|
156
|
-
return { kind: 'prefix', value: topicKey };
|
|
157
|
-
return { kind: 'exact', value: topicKey };
|
|
158
|
-
}
|
|
159
|
-
function escapeLike(value) {
|
|
160
|
-
return value.replace(/[\\%_]/g, (match) => `\\${match}`);
|
|
161
|
-
}
|
|
162
|
-
function map(row) {
|
|
163
|
-
const value = {
|
|
164
|
-
id: row.id,
|
|
165
|
-
project: row.project,
|
|
166
|
-
scope: row.scope,
|
|
167
|
-
type: row.type,
|
|
168
|
-
title: row.title,
|
|
169
|
-
content: row.content,
|
|
170
|
-
createdAt: row.created_at,
|
|
171
|
-
updatedAt: row.updated_at,
|
|
172
|
-
};
|
|
173
|
-
if (row.topic_key !== null)
|
|
174
|
-
value.topicKey = row.topic_key;
|
|
175
|
-
return value;
|
|
176
|
-
}
|
|
177
|
-
function mapRevision(row) {
|
|
178
|
-
const value = {
|
|
179
|
-
id: row.id,
|
|
180
|
-
observationId: row.observation_id,
|
|
181
|
-
revision: row.revision,
|
|
182
|
-
type: row.type,
|
|
183
|
-
title: row.title,
|
|
184
|
-
content: row.content,
|
|
185
|
-
createdAt: row.created_at,
|
|
186
|
-
};
|
|
187
|
-
if (row.topic_key !== null)
|
|
188
|
-
value.topicKey = row.topic_key;
|
|
189
|
-
return value;
|
|
190
|
-
}
|
|
191
|
-
function toSearchResult(observation) {
|
|
192
|
-
const value = {
|
|
193
|
-
id: observation.id,
|
|
194
|
-
project: observation.project,
|
|
195
|
-
scope: observation.scope,
|
|
196
|
-
type: observation.type,
|
|
197
|
-
title: observation.title,
|
|
198
|
-
preview: preview(observation.content),
|
|
199
|
-
createdAt: observation.createdAt,
|
|
200
|
-
updatedAt: observation.updatedAt,
|
|
201
|
-
};
|
|
202
|
-
if (observation.topicKey !== undefined)
|
|
203
|
-
value.topicKey = observation.topicKey;
|
|
204
|
-
return value;
|
|
205
|
-
}
|
|
206
|
-
function preview(content) {
|
|
207
|
-
return content.length <= 160 ? content : `${content.slice(0, 157)}...`;
|
|
208
|
-
}
|
|
209
|
-
function ok(value) {
|
|
210
|
-
return { ok: true, value };
|
|
211
|
-
}
|
|
212
|
-
function missing(message) {
|
|
213
|
-
return { ok: false, error: { code: 'not_found', message } };
|
|
214
|
-
}
|
|
215
|
-
function fail(message, cause) {
|
|
216
|
-
return { ok: false, error: { code: 'validation_failed', message, cause } };
|
|
217
|
-
}
|
|
1
|
+
export * from '../../storage/memory/repositories/observations.js';
|
|
@@ -1,125 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export class SessionRepository {
|
|
3
|
-
db;
|
|
4
|
-
constructor(db) {
|
|
5
|
-
this.db = db;
|
|
6
|
-
}
|
|
7
|
-
save(input) {
|
|
8
|
-
const result = this.db.transaction(() => {
|
|
9
|
-
const id = input.id ?? randomUUID();
|
|
10
|
-
this.db.connection
|
|
11
|
-
.prepare(`INSERT INTO sessions(id, project, directory, started_at) VALUES (@id, @project, @directory, @startedAt)
|
|
12
|
-
ON CONFLICT(id) DO UPDATE SET project=excluded.project, directory=excluded.directory`)
|
|
13
|
-
.run({ id, project: input.project, directory: input.directory ?? null, startedAt: new Date().toISOString() });
|
|
14
|
-
const session = this.getById(id);
|
|
15
|
-
if (!session.ok)
|
|
16
|
-
throw new Error(session.error.message);
|
|
17
|
-
return session.value;
|
|
18
|
-
});
|
|
19
|
-
return result.ok ? result : fail(result.error.message, result.error.cause);
|
|
20
|
-
}
|
|
21
|
-
getById(id) {
|
|
22
|
-
try {
|
|
23
|
-
const row = this.db.connection.prepare('SELECT * FROM sessions WHERE id=?').get(id);
|
|
24
|
-
if (!row)
|
|
25
|
-
return { ok: false, error: { code: 'not_found', message: `Session not found: ${id}` } };
|
|
26
|
-
return { ok: true, value: mapSession(row) };
|
|
27
|
-
}
|
|
28
|
-
catch (cause) {
|
|
29
|
-
return fail('Failed to read session', cause);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
restoreLatest(input) {
|
|
33
|
-
try {
|
|
34
|
-
const row = this.db.connection
|
|
35
|
-
.prepare(`
|
|
36
|
-
SELECT * FROM sessions
|
|
37
|
-
WHERE project = @project
|
|
38
|
-
AND ended_at IS NOT NULL
|
|
39
|
-
AND summary IS NOT NULL
|
|
40
|
-
AND TRIM(summary) <> ''
|
|
41
|
-
AND (@directory IS NULL OR directory = @directory)
|
|
42
|
-
ORDER BY ended_at DESC, started_at DESC, id DESC
|
|
43
|
-
LIMIT 1
|
|
44
|
-
`)
|
|
45
|
-
.get({ project: input.project, directory: input.directory ?? null });
|
|
46
|
-
if (!row)
|
|
47
|
-
return missing(`No closed session summary found for project: ${input.project}`);
|
|
48
|
-
return { ok: true, value: mapSession(row) };
|
|
49
|
-
}
|
|
50
|
-
catch (cause) {
|
|
51
|
-
return fail('Failed to restore session', cause);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
appendActivity(input) {
|
|
55
|
-
const session = this.getById(input.sessionId);
|
|
56
|
-
if (!session.ok)
|
|
57
|
-
return session;
|
|
58
|
-
const result = this.db.transaction(() => {
|
|
59
|
-
const next = this.db.connection
|
|
60
|
-
.prepare('SELECT COALESCE(MAX(sequence), 0) + 1 AS sequence FROM session_activity WHERE session_id=?')
|
|
61
|
-
.get(input.sessionId);
|
|
62
|
-
const activity = { id: randomUUID(), sequence: next.sequence, createdAt: new Date().toISOString(), ...input };
|
|
63
|
-
this.db.connection
|
|
64
|
-
.prepare(`INSERT INTO session_activity(id, session_id, sequence, actor, kind, payload_json, created_at)
|
|
65
|
-
VALUES (@id, @sessionId, @sequence, @actor, @kind, @payloadJson, @createdAt)`)
|
|
66
|
-
.run(activity);
|
|
67
|
-
return activity;
|
|
68
|
-
});
|
|
69
|
-
return result.ok ? result : fail(result.error.message, result.error.cause);
|
|
70
|
-
}
|
|
71
|
-
closeSession(input) {
|
|
72
|
-
const summary = input.summary.trim();
|
|
73
|
-
if (summary.length === 0)
|
|
74
|
-
return fail('summary must not be empty');
|
|
75
|
-
const result = this.db.transaction(() => {
|
|
76
|
-
const existing = this.db.connection.prepare('SELECT 1 FROM sessions WHERE id=?').get(input.sessionId);
|
|
77
|
-
if (!existing)
|
|
78
|
-
throw new SessionValidationError(`Session not found: ${input.sessionId}`);
|
|
79
|
-
const endedAt = new Date().toISOString();
|
|
80
|
-
this.db.connection
|
|
81
|
-
.prepare('UPDATE sessions SET summary=@summary, ended_at=@endedAt WHERE id=@sessionId')
|
|
82
|
-
.run({ sessionId: input.sessionId, summary, endedAt });
|
|
83
|
-
const next = this.db.connection
|
|
84
|
-
.prepare('SELECT COALESCE(MAX(sequence), 0) + 1 AS sequence FROM session_activity WHERE session_id=?')
|
|
85
|
-
.get(input.sessionId);
|
|
86
|
-
this.db.connection
|
|
87
|
-
.prepare(`INSERT INTO session_activity(id, session_id, sequence, actor, kind, payload_json, created_at)
|
|
88
|
-
VALUES (@id, @sessionId, @sequence, @actor, 'summary', @payloadJson, @createdAt)`)
|
|
89
|
-
.run({
|
|
90
|
-
id: randomUUID(),
|
|
91
|
-
sessionId: input.sessionId,
|
|
92
|
-
sequence: next.sequence,
|
|
93
|
-
actor: input.actor,
|
|
94
|
-
payloadJson: JSON.stringify({ summary }),
|
|
95
|
-
createdAt: endedAt,
|
|
96
|
-
});
|
|
97
|
-
const session = this.getById(input.sessionId);
|
|
98
|
-
if (!session.ok)
|
|
99
|
-
throw new SessionValidationError(session.error.message);
|
|
100
|
-
return session.value;
|
|
101
|
-
});
|
|
102
|
-
return result.ok ? result : fail(errorMessage(result.error.cause) ?? result.error.message, result.error.cause);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
function fail(message, cause) {
|
|
106
|
-
return { ok: false, error: { code: 'validation_failed', message, cause } };
|
|
107
|
-
}
|
|
108
|
-
function missing(message) {
|
|
109
|
-
return { ok: false, error: { code: 'not_found', message } };
|
|
110
|
-
}
|
|
111
|
-
function mapSession(row) {
|
|
112
|
-
const session = { id: row.id, project: row.project, startedAt: row.started_at };
|
|
113
|
-
if (row.directory !== null)
|
|
114
|
-
session.directory = row.directory;
|
|
115
|
-
if (row.ended_at !== null)
|
|
116
|
-
session.endedAt = row.ended_at;
|
|
117
|
-
if (row.summary !== null)
|
|
118
|
-
session.summary = row.summary;
|
|
119
|
-
return session;
|
|
120
|
-
}
|
|
121
|
-
class SessionValidationError extends Error {
|
|
122
|
-
}
|
|
123
|
-
function errorMessage(cause) {
|
|
124
|
-
return cause instanceof SessionValidationError ? cause.message : undefined;
|
|
125
|
-
}
|
|
1
|
+
export * from '../../storage/memory/repositories/sessions.js';
|
|
@@ -1,78 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export class TraceRepository {
|
|
3
|
-
db;
|
|
4
|
-
constructor(db) {
|
|
5
|
-
this.db = db;
|
|
6
|
-
}
|
|
7
|
-
write(input) {
|
|
8
|
-
try {
|
|
9
|
-
const trace = toTrace(input);
|
|
10
|
-
this.db.connection
|
|
11
|
-
.prepare(`INSERT INTO traces(id, actor, session_id, operation, target_type, target_id, topic_key, status, error_code, error_message, created_at)
|
|
12
|
-
VALUES (@id, @actor, @sessionId, @operation, @targetType, @targetId, @topicKey, @status, @errorCode, @errorMessage, @createdAt)`)
|
|
13
|
-
.run({
|
|
14
|
-
id: trace.id,
|
|
15
|
-
actor: trace.actor,
|
|
16
|
-
sessionId: trace.sessionId ?? null,
|
|
17
|
-
operation: trace.operation,
|
|
18
|
-
targetType: trace.targetType,
|
|
19
|
-
targetId: trace.targetId ?? null,
|
|
20
|
-
topicKey: trace.topicKey ?? null,
|
|
21
|
-
status: trace.status,
|
|
22
|
-
errorCode: trace.errorCode ?? null,
|
|
23
|
-
errorMessage: trace.errorMessage ?? null,
|
|
24
|
-
createdAt: trace.createdAt,
|
|
25
|
-
});
|
|
26
|
-
return { ok: true, value: trace };
|
|
27
|
-
}
|
|
28
|
-
catch (cause) {
|
|
29
|
-
return fail('Failed to write trace', cause);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
list() {
|
|
33
|
-
try {
|
|
34
|
-
return { ok: true, value: this.db.connection.prepare('SELECT * FROM traces ORDER BY created_at ASC').all().map(map) };
|
|
35
|
-
}
|
|
36
|
-
catch (cause) {
|
|
37
|
-
return fail('Failed to list traces', cause);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
function toTrace(input) {
|
|
42
|
-
const trace = {
|
|
43
|
-
id: randomUUID(),
|
|
44
|
-
actor: input.actor,
|
|
45
|
-
operation: input.operation,
|
|
46
|
-
targetType: input.targetType,
|
|
47
|
-
status: input.status,
|
|
48
|
-
createdAt: new Date().toISOString(),
|
|
49
|
-
};
|
|
50
|
-
if (input.sessionId !== undefined)
|
|
51
|
-
trace.sessionId = input.sessionId;
|
|
52
|
-
if (input.targetId !== undefined)
|
|
53
|
-
trace.targetId = input.targetId;
|
|
54
|
-
if (input.topicKey !== undefined)
|
|
55
|
-
trace.topicKey = input.topicKey;
|
|
56
|
-
if (input.errorCode !== undefined)
|
|
57
|
-
trace.errorCode = input.errorCode;
|
|
58
|
-
if (input.errorMessage !== undefined)
|
|
59
|
-
trace.errorMessage = input.errorMessage;
|
|
60
|
-
return trace;
|
|
61
|
-
}
|
|
62
|
-
function map(row) {
|
|
63
|
-
const trace = { id: row.id, actor: row.actor, operation: row.operation, targetType: row.target_type, status: row.status, createdAt: row.created_at };
|
|
64
|
-
if (row.session_id !== null)
|
|
65
|
-
trace.sessionId = row.session_id;
|
|
66
|
-
if (row.target_id !== null)
|
|
67
|
-
trace.targetId = row.target_id;
|
|
68
|
-
if (row.topic_key !== null)
|
|
69
|
-
trace.topicKey = row.topic_key;
|
|
70
|
-
if (row.error_code !== null)
|
|
71
|
-
trace.errorCode = row.error_code;
|
|
72
|
-
if (row.error_message !== null)
|
|
73
|
-
trace.errorMessage = row.error_message;
|
|
74
|
-
return trace;
|
|
75
|
-
}
|
|
76
|
-
function fail(message, cause) {
|
|
77
|
-
return { ok: false, error: { code: 'validation_failed', message, cause } };
|
|
78
|
-
}
|
|
1
|
+
export * from '../../storage/memory/repositories/traces.js';
|
package/dist/memory/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from '../domain/memory/schema.js';
|
package/dist/memory/search.js
CHANGED
|
@@ -1,11 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
return query
|
|
3
|
-
.split(/\s+/)
|
|
4
|
-
.map((term) => term.trim())
|
|
5
|
-
.filter(Boolean)
|
|
6
|
-
.map((term) => `"${term.replaceAll('"', '""')}"`)
|
|
7
|
-
.join(' ');
|
|
8
|
-
}
|
|
9
|
-
export function normalizeLimit(limit, fallback = 20, max = 100) {
|
|
10
|
-
return limit === undefined || !Number.isInteger(limit) || limit < 1 ? fallback : Math.min(limit, max);
|
|
11
|
-
}
|
|
1
|
+
export * from '../application/memory/search.js';
|