@stackmemoryai/stackmemory 0.5.57 → 0.5.59
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/bin/codex-smd +6 -0
- package/dist/cli/codex-sm-danger.js +21 -0
- package/dist/cli/codex-sm-danger.js.map +7 -0
- package/dist/cli/commands/handoff.js +33 -3
- package/dist/cli/commands/handoff.js.map +2 -2
- package/dist/cli/commands/search.js +20 -3
- package/dist/cli/commands/search.js.map +2 -2
- package/dist/core/database/sqlite-adapter.js +13 -3
- package/dist/core/database/sqlite-adapter.js.map +2 -2
- package/dist/core/errors/error-utils.js +208 -0
- package/dist/core/errors/error-utils.js.map +7 -0
- package/dist/core/errors/index.js +13 -4
- package/dist/core/errors/index.js.map +2 -2
- package/dist/core/merge/unified-merge-resolver.js +303 -0
- package/dist/core/merge/unified-merge-resolver.js.map +7 -0
- package/dist/core/monitoring/logger.js +61 -9
- package/dist/core/monitoring/logger.js.map +2 -2
- package/dist/core/security/index.js +35 -0
- package/dist/core/security/index.js.map +7 -0
- package/dist/core/security/input-sanitizer.js +321 -0
- package/dist/core/security/input-sanitizer.js.map +7 -0
- package/dist/core/session/enhanced-handoff.js +136 -2
- package/dist/core/session/enhanced-handoff.js.map +3 -3
- package/dist/integrations/linear/client.js +5 -1
- package/dist/integrations/linear/client.js.map +2 -2
- package/dist/integrations/mcp/remote-server.js +27 -36
- package/dist/integrations/mcp/remote-server.js.map +2 -2
- package/dist/integrations/mcp/server.js +44 -29
- package/dist/integrations/mcp/server.js.map +3 -3
- package/dist/scripts/benchmark-performance.js +48 -0
- package/dist/scripts/benchmark-performance.js.map +7 -0
- package/dist/scripts/check-redis.js +42 -0
- package/dist/scripts/check-redis.js.map +7 -0
- package/dist/scripts/initialize.js +116 -0
- package/dist/scripts/initialize.js.map +7 -0
- package/dist/scripts/list-linear-tasks.js +124 -0
- package/dist/scripts/list-linear-tasks.js.map +7 -0
- package/dist/scripts/measure-handoff-impact.js +340 -0
- package/dist/scripts/measure-handoff-impact.js.map +7 -0
- package/dist/scripts/query-chromadb.js +160 -0
- package/dist/scripts/query-chromadb.js.map +7 -0
- package/dist/scripts/show-linear-summary.js +119 -0
- package/dist/scripts/show-linear-summary.js.map +7 -0
- package/dist/scripts/simple-swarm-demo.js +90 -0
- package/dist/scripts/simple-swarm-demo.js.map +7 -0
- package/dist/scripts/status.js +155 -0
- package/dist/scripts/status.js.map +7 -0
- package/dist/scripts/test-chromadb-sync.js +192 -0
- package/dist/scripts/test-chromadb-sync.js.map +7 -0
- package/dist/scripts/test-ralph-iteration-fix.js +86 -0
- package/dist/scripts/test-ralph-iteration-fix.js.map +7 -0
- package/dist/scripts/test-ralph-iterations.js +121 -0
- package/dist/scripts/test-ralph-iterations.js.map +7 -0
- package/dist/scripts/test-redis-storage.js +389 -0
- package/dist/scripts/test-redis-storage.js.map +7 -0
- package/dist/scripts/test-simple-ralph-state-sync.js +115 -0
- package/dist/scripts/test-simple-ralph-state-sync.js.map +7 -0
- package/dist/scripts/test-swarm-fixes.js +125 -0
- package/dist/scripts/test-swarm-fixes.js.map +7 -0
- package/dist/scripts/test-swarm-tui.js +23 -0
- package/dist/scripts/test-swarm-tui.js.map +7 -0
- package/dist/scripts/test-tui-shortcuts.js +52 -0
- package/dist/scripts/test-tui-shortcuts.js.map +7 -0
- package/dist/scripts/validate-tui-shortcuts.js +60 -0
- package/dist/scripts/validate-tui-shortcuts.js.map +7 -0
- package/dist/src/agents/core/agent-task-manager.js +527 -0
- package/dist/src/agents/core/agent-task-manager.js.map +7 -0
- package/dist/src/agents/verifiers/base-verifier.js +133 -0
- package/dist/src/agents/verifiers/base-verifier.js.map +7 -0
- package/dist/src/agents/verifiers/formatter-verifier.js +130 -0
- package/dist/src/agents/verifiers/formatter-verifier.js.map +7 -0
- package/dist/src/agents/verifiers/llm-judge.js +252 -0
- package/dist/src/agents/verifiers/llm-judge.js.map +7 -0
- package/dist/src/cli/auto-detect.js +321 -0
- package/dist/src/cli/auto-detect.js.map +7 -0
- package/dist/src/cli/claude-sm-danger.js +21 -0
- package/dist/src/cli/claude-sm-danger.js.map +7 -0
- package/dist/src/cli/claude-sm.js +1156 -0
- package/dist/src/cli/claude-sm.js.map +7 -0
- package/dist/src/cli/codex-sm-danger.js +21 -0
- package/dist/src/cli/codex-sm-danger.js.map +7 -0
- package/dist/src/cli/codex-sm.js +349 -0
- package/dist/src/cli/codex-sm.js.map +7 -0
- package/dist/src/cli/commands/api.js +232 -0
- package/dist/src/cli/commands/api.js.map +7 -0
- package/dist/src/cli/commands/auto-background.js +180 -0
- package/dist/src/cli/commands/auto-background.js.map +7 -0
- package/dist/src/cli/commands/cleanup-processes.js +68 -0
- package/dist/src/cli/commands/cleanup-processes.js.map +7 -0
- package/dist/src/cli/commands/clear.js +202 -0
- package/dist/src/cli/commands/clear.js.map +7 -0
- package/dist/src/cli/commands/config.js +445 -0
- package/dist/src/cli/commands/config.js.map +7 -0
- package/dist/src/cli/commands/context-rehydrate.js +751 -0
- package/dist/src/cli/commands/context-rehydrate.js.map +7 -0
- package/dist/src/cli/commands/context.js +343 -0
- package/dist/src/cli/commands/context.js.map +7 -0
- package/dist/src/cli/commands/daemon.js +392 -0
- package/dist/src/cli/commands/daemon.js.map +7 -0
- package/dist/src/cli/commands/dashboard.js +210 -0
- package/dist/src/cli/commands/dashboard.js.map +7 -0
- package/dist/src/cli/commands/db.js +147 -0
- package/dist/src/cli/commands/db.js.map +7 -0
- package/dist/src/cli/commands/decision.js +266 -0
- package/dist/src/cli/commands/decision.js.map +7 -0
- package/dist/src/cli/commands/discovery.js +279 -0
- package/dist/src/cli/commands/discovery.js.map +7 -0
- package/dist/src/cli/commands/handoff.js +624 -0
- package/dist/src/cli/commands/handoff.js.map +7 -0
- package/dist/src/cli/commands/hooks.js +298 -0
- package/dist/src/cli/commands/hooks.js.map +7 -0
- package/dist/src/cli/commands/linear.js +529 -0
- package/dist/src/cli/commands/linear.js.map +7 -0
- package/dist/src/cli/commands/log.js +169 -0
- package/dist/src/cli/commands/log.js.map +7 -0
- package/dist/src/cli/commands/login.js +172 -0
- package/dist/src/cli/commands/login.js.map +7 -0
- package/dist/src/cli/commands/migrate.js +240 -0
- package/dist/src/cli/commands/migrate.js.map +7 -0
- package/dist/src/cli/commands/model.js +533 -0
- package/dist/src/cli/commands/model.js.map +7 -0
- package/dist/src/cli/commands/onboard.js +536 -0
- package/dist/src/cli/commands/onboard.js.map +7 -0
- package/dist/src/cli/commands/projects.js +199 -0
- package/dist/src/cli/commands/projects.js.map +7 -0
- package/dist/src/cli/commands/ralph.js +909 -0
- package/dist/src/cli/commands/ralph.js.map +7 -0
- package/dist/src/cli/commands/retrieval.js +248 -0
- package/dist/src/cli/commands/retrieval.js.map +7 -0
- package/dist/src/cli/commands/search.js +173 -0
- package/dist/src/cli/commands/search.js.map +7 -0
- package/dist/src/cli/commands/service.js +749 -0
- package/dist/src/cli/commands/service.js.map +7 -0
- package/dist/src/cli/commands/session.js +200 -0
- package/dist/src/cli/commands/session.js.map +7 -0
- package/dist/src/cli/commands/settings.js +306 -0
- package/dist/src/cli/commands/settings.js.map +7 -0
- package/dist/src/cli/commands/setup.js +701 -0
- package/dist/src/cli/commands/setup.js.map +7 -0
- package/dist/src/cli/commands/shell.js +249 -0
- package/dist/src/cli/commands/shell.js.map +7 -0
- package/dist/src/cli/commands/signup.js +50 -0
- package/dist/src/cli/commands/signup.js.map +7 -0
- package/dist/src/cli/commands/skills.js +470 -0
- package/dist/src/cli/commands/skills.js.map +7 -0
- package/dist/src/cli/commands/sms-notify.js +795 -0
- package/dist/src/cli/commands/sms-notify.js.map +7 -0
- package/dist/src/cli/commands/storage-tier.js +183 -0
- package/dist/src/cli/commands/storage-tier.js.map +7 -0
- package/dist/src/cli/commands/sweep.js +249 -0
- package/dist/src/cli/commands/sweep.js.map +7 -0
- package/dist/src/cli/commands/tasks.js +213 -0
- package/dist/src/cli/commands/tasks.js.map +7 -0
- package/dist/src/cli/commands/worktree.js +319 -0
- package/dist/src/cli/commands/worktree.js.map +7 -0
- package/dist/src/cli/index.js +594 -0
- package/dist/src/cli/index.js.map +7 -0
- package/dist/src/cli/opencode-sm.js +448 -0
- package/dist/src/cli/opencode-sm.js.map +7 -0
- package/dist/src/cli/utils/viewer.js +96 -0
- package/dist/src/cli/utils/viewer.js.map +7 -0
- package/dist/src/core/config/config-manager.js +398 -0
- package/dist/src/core/config/config-manager.js.map +7 -0
- package/dist/src/core/config/feature-flags.js +76 -0
- package/dist/src/core/config/feature-flags.js.map +7 -0
- package/dist/src/core/config/storage-config.js +115 -0
- package/dist/src/core/config/storage-config.js.map +7 -0
- package/dist/src/core/config/types.js +144 -0
- package/dist/src/core/config/types.js.map +7 -0
- package/dist/src/core/context/auto-context.js +80 -0
- package/dist/src/core/context/auto-context.js.map +7 -0
- package/dist/src/core/context/dual-stack-manager.js +870 -0
- package/dist/src/core/context/dual-stack-manager.js.map +7 -0
- package/dist/src/core/context/enhanced-rehydration.js +994 -0
- package/dist/src/core/context/enhanced-rehydration.js.map +7 -0
- package/dist/src/core/context/frame-database.js +479 -0
- package/dist/src/core/context/frame-database.js.map +7 -0
- package/dist/src/core/context/frame-digest.js +250 -0
- package/dist/src/core/context/frame-digest.js.map +7 -0
- package/dist/src/core/context/frame-handoff-manager.js +778 -0
- package/dist/src/core/context/frame-handoff-manager.js.map +7 -0
- package/dist/src/core/context/frame-lifecycle-hooks.js +119 -0
- package/dist/src/core/context/frame-lifecycle-hooks.js.map +7 -0
- package/dist/src/core/context/frame-recovery.js +302 -0
- package/dist/src/core/context/frame-recovery.js.map +7 -0
- package/dist/src/core/context/frame-stack.js +314 -0
- package/dist/src/core/context/frame-stack.js.map +7 -0
- package/dist/src/core/context/frame-types.js +5 -0
- package/dist/src/core/context/frame-types.js.map +7 -0
- package/dist/src/core/context/index.js +25 -0
- package/dist/src/core/context/index.js.map +7 -0
- package/dist/src/core/context/permission-manager.js +185 -0
- package/dist/src/core/context/permission-manager.js.map +7 -0
- package/dist/src/core/context/recursive-context-manager.js +592 -0
- package/dist/src/core/context/recursive-context-manager.js.map +7 -0
- package/dist/src/core/context/refactored-frame-manager.js +754 -0
- package/dist/src/core/context/refactored-frame-manager.js.map +7 -0
- package/dist/src/core/context/shared-context-layer.js +621 -0
- package/dist/src/core/context/shared-context-layer.js.map +7 -0
- package/dist/src/core/context/stack-merge-resolver.js +749 -0
- package/dist/src/core/context/stack-merge-resolver.js.map +7 -0
- package/dist/src/core/context/validation.js +130 -0
- package/dist/src/core/context/validation.js.map +7 -0
- package/dist/src/core/database/batch-operations.js +384 -0
- package/dist/src/core/database/batch-operations.js.map +7 -0
- package/dist/src/core/database/connection-pool.js +330 -0
- package/dist/src/core/database/connection-pool.js.map +7 -0
- package/dist/src/core/database/database-adapter.js +60 -0
- package/dist/src/core/database/database-adapter.js.map +7 -0
- package/dist/src/core/database/migration-manager.js +614 -0
- package/dist/src/core/database/migration-manager.js.map +7 -0
- package/dist/src/core/database/query-cache.js +298 -0
- package/dist/src/core/database/query-cache.js.map +7 -0
- package/dist/src/core/database/query-router.js +430 -0
- package/dist/src/core/database/query-router.js.map +7 -0
- package/dist/src/core/database/sqlite-adapter.js +738 -0
- package/dist/src/core/database/sqlite-adapter.js.map +7 -0
- package/dist/src/core/digest/enhanced-hybrid-digest.js +277 -0
- package/dist/src/core/digest/enhanced-hybrid-digest.js.map +7 -0
- package/dist/src/core/digest/frame-digest-integration.js +176 -0
- package/dist/src/core/digest/frame-digest-integration.js.map +7 -0
- package/dist/src/core/digest/hybrid-digest-generator.js +553 -0
- package/dist/src/core/digest/hybrid-digest-generator.js.map +7 -0
- package/dist/src/core/digest/index.js +9 -0
- package/dist/src/core/digest/index.js.map +7 -0
- package/dist/src/core/digest/types.js +25 -0
- package/dist/src/core/digest/types.js.map +7 -0
- package/dist/src/core/errors/error-utils.js +208 -0
- package/dist/src/core/errors/error-utils.js.map +7 -0
- package/dist/src/core/errors/index.js +521 -0
- package/dist/src/core/errors/index.js.map +7 -0
- package/dist/src/core/errors/recovery.js +269 -0
- package/dist/src/core/errors/recovery.js.map +7 -0
- package/dist/src/core/execution/parallel-executor.js +258 -0
- package/dist/src/core/execution/parallel-executor.js.map +7 -0
- package/dist/src/core/frame/workflow-templates.js +319 -0
- package/dist/src/core/frame/workflow-templates.js.map +7 -0
- package/dist/src/core/merge/conflict-detector.js +431 -0
- package/dist/src/core/merge/conflict-detector.js.map +7 -0
- package/dist/src/core/merge/index.js +9 -0
- package/dist/src/core/merge/index.js.map +7 -0
- package/dist/src/core/merge/resolution-engine.js +558 -0
- package/dist/src/core/merge/resolution-engine.js.map +7 -0
- package/dist/src/core/merge/stack-diff.js +532 -0
- package/dist/src/core/merge/stack-diff.js.map +7 -0
- package/dist/src/core/merge/types.js +5 -0
- package/dist/src/core/merge/types.js.map +7 -0
- package/dist/src/core/merge/unified-merge-resolver.js +303 -0
- package/dist/src/core/merge/unified-merge-resolver.js.map +7 -0
- package/dist/src/core/models/fallback-monitor.js +232 -0
- package/dist/src/core/models/fallback-monitor.js.map +7 -0
- package/dist/src/core/models/model-router.js +340 -0
- package/dist/src/core/models/model-router.js.map +7 -0
- package/dist/src/core/monitoring/error-handler.js +49 -0
- package/dist/src/core/monitoring/error-handler.js.map +7 -0
- package/dist/src/core/monitoring/logger.js +202 -0
- package/dist/src/core/monitoring/logger.js.map +7 -0
- package/dist/src/core/monitoring/metrics.js +172 -0
- package/dist/src/core/monitoring/metrics.js.map +7 -0
- package/dist/src/core/monitoring/progress-tracker.js +189 -0
- package/dist/src/core/monitoring/progress-tracker.js.map +7 -0
- package/dist/src/core/monitoring/session-monitor.js +300 -0
- package/dist/src/core/monitoring/session-monitor.js.map +7 -0
- package/dist/src/core/performance/context-cache.js +273 -0
- package/dist/src/core/performance/context-cache.js.map +7 -0
- package/dist/src/core/performance/index.js +11 -0
- package/dist/src/core/performance/index.js.map +7 -0
- package/dist/src/core/performance/lazy-context-loader.js +327 -0
- package/dist/src/core/performance/lazy-context-loader.js.map +7 -0
- package/dist/src/core/performance/monitor.js +221 -0
- package/dist/src/core/performance/monitor.js.map +7 -0
- package/dist/src/core/performance/optimized-frame-context.js +345 -0
- package/dist/src/core/performance/optimized-frame-context.js.map +7 -0
- package/dist/src/core/performance/performance-benchmark.js +277 -0
- package/dist/src/core/performance/performance-benchmark.js.map +7 -0
- package/dist/src/core/performance/performance-profiler.js +370 -0
- package/dist/src/core/performance/performance-profiler.js.map +7 -0
- package/dist/src/core/performance/streaming-jsonl-parser.js +195 -0
- package/dist/src/core/performance/streaming-jsonl-parser.js.map +7 -0
- package/dist/src/core/persistence/postgres-adapter.js +349 -0
- package/dist/src/core/persistence/postgres-adapter.js.map +7 -0
- package/dist/src/core/projects/project-isolation.js +201 -0
- package/dist/src/core/projects/project-isolation.js.map +7 -0
- package/dist/src/core/projects/project-manager.js +697 -0
- package/dist/src/core/projects/project-manager.js.map +7 -0
- package/dist/src/core/query/query-parser.js +370 -0
- package/dist/src/core/query/query-parser.js.map +7 -0
- package/dist/src/core/query/query-templates.js +321 -0
- package/dist/src/core/query/query-templates.js.map +7 -0
- package/dist/src/core/retrieval/context-retriever.js +479 -0
- package/dist/src/core/retrieval/context-retriever.js.map +7 -0
- package/dist/src/core/retrieval/index.js +8 -0
- package/dist/src/core/retrieval/index.js.map +7 -0
- package/dist/src/core/retrieval/llm-context-retrieval.js +613 -0
- package/dist/src/core/retrieval/llm-context-retrieval.js.map +7 -0
- package/dist/src/core/retrieval/llm-provider.js +151 -0
- package/dist/src/core/retrieval/llm-provider.js.map +7 -0
- package/dist/src/core/retrieval/retrieval-audit.js +236 -0
- package/dist/src/core/retrieval/retrieval-audit.js.map +7 -0
- package/dist/src/core/retrieval/summary-generator.js +589 -0
- package/dist/src/core/retrieval/summary-generator.js.map +7 -0
- package/dist/src/core/retrieval/types.js +21 -0
- package/dist/src/core/retrieval/types.js.map +7 -0
- package/dist/src/core/security/index.js +35 -0
- package/dist/src/core/security/index.js.map +7 -0
- package/dist/src/core/security/input-sanitizer.js +321 -0
- package/dist/src/core/security/input-sanitizer.js.map +7 -0
- package/dist/src/core/session/clear-survival.js +465 -0
- package/dist/src/core/session/clear-survival.js.map +7 -0
- package/dist/src/core/session/enhanced-handoff.js +792 -0
- package/dist/src/core/session/enhanced-handoff.js.map +7 -0
- package/dist/src/core/session/handoff-generator.js +343 -0
- package/dist/src/core/session/handoff-generator.js.map +7 -0
- package/dist/src/core/session/index.js +15 -0
- package/dist/src/core/session/index.js.map +7 -0
- package/dist/src/core/session/session-manager.js +347 -0
- package/dist/src/core/session/session-manager.js.map +7 -0
- package/dist/src/core/skills/index.js +7 -0
- package/dist/src/core/skills/index.js.map +7 -0
- package/dist/src/core/skills/skill-storage.js +764 -0
- package/dist/src/core/skills/skill-storage.js.map +7 -0
- package/dist/src/core/skills/types.js +193 -0
- package/dist/src/core/skills/types.js.map +7 -0
- package/dist/src/core/storage/chromadb-adapter.js +354 -0
- package/dist/src/core/storage/chromadb-adapter.js.map +7 -0
- package/dist/src/core/storage/infinite-storage.js +510 -0
- package/dist/src/core/storage/infinite-storage.js.map +7 -0
- package/dist/src/core/storage/remote-storage.js +489 -0
- package/dist/src/core/storage/remote-storage.js.map +7 -0
- package/dist/src/core/storage/two-tier-storage.js +766 -0
- package/dist/src/core/storage/two-tier-storage.js.map +7 -0
- package/dist/src/core/trace/cli-trace-wrapper.js +132 -0
- package/dist/src/core/trace/cli-trace-wrapper.js.map +7 -0
- package/dist/src/core/trace/db-trace-wrapper.js +247 -0
- package/dist/src/core/trace/db-trace-wrapper.js.map +7 -0
- package/dist/src/core/trace/debug-trace.js +417 -0
- package/dist/src/core/trace/debug-trace.js.map +7 -0
- package/dist/src/core/trace/index.js +109 -0
- package/dist/src/core/trace/index.js.map +7 -0
- package/dist/src/core/trace/linear-api-wrapper.js +178 -0
- package/dist/src/core/trace/linear-api-wrapper.js.map +7 -0
- package/dist/src/core/trace/trace-detector.js +528 -0
- package/dist/src/core/trace/trace-detector.js.map +7 -0
- package/dist/src/core/trace/trace-store.js +345 -0
- package/dist/src/core/trace/trace-store.js.map +7 -0
- package/dist/src/core/trace/types.js +77 -0
- package/dist/src/core/trace/types.js.map +7 -0
- package/dist/src/core/types.js +5 -0
- package/dist/src/core/types.js.map +7 -0
- package/dist/src/core/utils/async-mutex.js +114 -0
- package/dist/src/core/utils/async-mutex.js.map +7 -0
- package/dist/src/core/utils/compression.js +83 -0
- package/dist/src/core/utils/compression.js.map +7 -0
- package/dist/src/core/utils/update-checker.js +218 -0
- package/dist/src/core/utils/update-checker.js.map +7 -0
- package/dist/src/core/worktree/worktree-manager.js +465 -0
- package/dist/src/core/worktree/worktree-manager.js.map +7 -0
- package/dist/src/daemon/daemon-config.js +149 -0
- package/dist/src/daemon/daemon-config.js.map +7 -0
- package/dist/src/daemon/services/context-service.js +122 -0
- package/dist/src/daemon/services/context-service.js.map +7 -0
- package/dist/src/daemon/services/linear-service.js +136 -0
- package/dist/src/daemon/services/linear-service.js.map +7 -0
- package/dist/src/daemon/session-daemon.js +312 -0
- package/dist/src/daemon/session-daemon.js.map +7 -0
- package/dist/src/daemon/unified-daemon.js +276 -0
- package/dist/src/daemon/unified-daemon.js.map +7 -0
- package/dist/src/features/analytics/api/analytics-api.js +287 -0
- package/dist/src/features/analytics/api/analytics-api.js.map +7 -0
- package/dist/src/features/analytics/core/analytics-service.js +282 -0
- package/dist/src/features/analytics/core/analytics-service.js.map +7 -0
- package/dist/src/features/analytics/index.js +18 -0
- package/dist/src/features/analytics/index.js.map +7 -0
- package/dist/src/features/analytics/queries/metrics-queries.js +277 -0
- package/dist/src/features/analytics/queries/metrics-queries.js.map +7 -0
- package/dist/src/features/analytics/types/metrics.js +5 -0
- package/dist/src/features/analytics/types/metrics.js.map +7 -0
- package/dist/src/features/browser/browser-mcp.js +492 -0
- package/dist/src/features/browser/browser-mcp.js.map +7 -0
- package/dist/src/features/sweep/index.js +20 -0
- package/dist/src/features/sweep/index.js.map +7 -0
- package/dist/src/features/sweep/prediction-client.js +155 -0
- package/dist/src/features/sweep/prediction-client.js.map +7 -0
- package/dist/src/features/sweep/prompt-builder.js +85 -0
- package/dist/src/features/sweep/prompt-builder.js.map +7 -0
- package/dist/src/features/sweep/pty-wrapper.js +171 -0
- package/dist/src/features/sweep/pty-wrapper.js.map +7 -0
- package/dist/src/features/sweep/state-watcher.js +87 -0
- package/dist/src/features/sweep/state-watcher.js.map +7 -0
- package/dist/src/features/sweep/status-bar.js +88 -0
- package/dist/src/features/sweep/status-bar.js.map +7 -0
- package/dist/src/features/sweep/sweep-server-manager.js +226 -0
- package/dist/src/features/sweep/sweep-server-manager.js.map +7 -0
- package/dist/src/features/sweep/tab-interceptor.js +38 -0
- package/dist/src/features/sweep/tab-interceptor.js.map +7 -0
- package/dist/src/features/sweep/types.js +18 -0
- package/dist/src/features/sweep/types.js.map +7 -0
- package/dist/src/features/tasks/linear-task-manager.js +487 -0
- package/dist/src/features/tasks/linear-task-manager.js.map +7 -0
- package/dist/src/features/tasks/task-aware-context.js +410 -0
- package/dist/src/features/tasks/task-aware-context.js.map +7 -0
- package/dist/src/features/tui/simple-monitor.js +116 -0
- package/dist/src/features/tui/simple-monitor.js.map +7 -0
- package/dist/src/features/tui/swarm-monitor.js +648 -0
- package/dist/src/features/tui/swarm-monitor.js.map +7 -0
- package/dist/src/features/web/client/stores/task-store.js +26 -0
- package/dist/src/features/web/client/stores/task-store.js.map +7 -0
- package/dist/src/features/web/server/index.js +194 -0
- package/dist/src/features/web/server/index.js.map +7 -0
- package/dist/src/hooks/auto-background.js +151 -0
- package/dist/src/hooks/auto-background.js.map +7 -0
- package/dist/src/hooks/claude-code-whatsapp-hook.js +197 -0
- package/dist/src/hooks/claude-code-whatsapp-hook.js.map +7 -0
- package/dist/src/hooks/config.js +150 -0
- package/dist/src/hooks/config.js.map +7 -0
- package/dist/src/hooks/daemon.js +364 -0
- package/dist/src/hooks/daemon.js.map +7 -0
- package/dist/src/hooks/events.js +58 -0
- package/dist/src/hooks/events.js.map +7 -0
- package/dist/src/hooks/index.js +12 -0
- package/dist/src/hooks/index.js.map +7 -0
- package/dist/src/hooks/linear-task-picker.js +186 -0
- package/dist/src/hooks/linear-task-picker.js.map +7 -0
- package/dist/src/hooks/schemas.js +197 -0
- package/dist/src/hooks/schemas.js.map +7 -0
- package/dist/src/hooks/secure-fs.js +49 -0
- package/dist/src/hooks/secure-fs.js.map +7 -0
- package/dist/src/hooks/security-logger.js +155 -0
- package/dist/src/hooks/security-logger.js.map +7 -0
- package/dist/src/hooks/session-summary.js +222 -0
- package/dist/src/hooks/session-summary.js.map +7 -0
- package/dist/src/hooks/sms-action-runner.js +371 -0
- package/dist/src/hooks/sms-action-runner.js.map +7 -0
- package/dist/src/hooks/sms-notify.js +506 -0
- package/dist/src/hooks/sms-notify.js.map +7 -0
- package/dist/src/hooks/sms-watcher.js +93 -0
- package/dist/src/hooks/sms-watcher.js.map +7 -0
- package/dist/src/hooks/sms-webhook.js +555 -0
- package/dist/src/hooks/sms-webhook.js.map +7 -0
- package/dist/src/hooks/whatsapp-commands.js +479 -0
- package/dist/src/hooks/whatsapp-commands.js.map +7 -0
- package/dist/src/hooks/whatsapp-scheduler.js +317 -0
- package/dist/src/hooks/whatsapp-scheduler.js.map +7 -0
- package/dist/src/hooks/whatsapp-sync.js +409 -0
- package/dist/src/hooks/whatsapp-sync.js.map +7 -0
- package/dist/src/index.js +25 -0
- package/dist/src/index.js.map +7 -0
- package/dist/src/integrations/anthropic/client.js +263 -0
- package/dist/src/integrations/anthropic/client.js.map +7 -0
- package/dist/src/integrations/claude-code/agent-bridge.js +768 -0
- package/dist/src/integrations/claude-code/agent-bridge.js.map +7 -0
- package/dist/src/integrations/claude-code/enhanced-pre-clear-hooks.js +459 -0
- package/dist/src/integrations/claude-code/enhanced-pre-clear-hooks.js.map +7 -0
- package/dist/src/integrations/claude-code/lifecycle-hooks.js +254 -0
- package/dist/src/integrations/claude-code/lifecycle-hooks.js.map +7 -0
- package/dist/src/integrations/claude-code/post-task-hooks.js +545 -0
- package/dist/src/integrations/claude-code/post-task-hooks.js.map +7 -0
- package/dist/src/integrations/claude-code/subagent-client-stub.js +20 -0
- package/dist/src/integrations/claude-code/subagent-client-stub.js.map +7 -0
- package/dist/src/integrations/claude-code/subagent-client.js +511 -0
- package/dist/src/integrations/claude-code/subagent-client.js.map +7 -0
- package/dist/src/integrations/claude-code/task-coordinator.js +360 -0
- package/dist/src/integrations/claude-code/task-coordinator.js.map +7 -0
- package/dist/src/integrations/linear/auth.js +337 -0
- package/dist/src/integrations/linear/auth.js.map +7 -0
- package/dist/src/integrations/linear/auto-sync.js +258 -0
- package/dist/src/integrations/linear/auto-sync.js.map +7 -0
- package/dist/src/integrations/linear/client.js +634 -0
- package/dist/src/integrations/linear/client.js.map +7 -0
- package/dist/src/integrations/linear/config.js +130 -0
- package/dist/src/integrations/linear/config.js.map +7 -0
- package/dist/src/integrations/linear/migration.js +361 -0
- package/dist/src/integrations/linear/migration.js.map +7 -0
- package/dist/src/integrations/linear/oauth-server.js +454 -0
- package/dist/src/integrations/linear/oauth-server.js.map +7 -0
- package/dist/src/integrations/linear/rest-client.js +213 -0
- package/dist/src/integrations/linear/rest-client.js.map +7 -0
- package/dist/src/integrations/linear/sync-manager.js +236 -0
- package/dist/src/integrations/linear/sync-manager.js.map +7 -0
- package/dist/src/integrations/linear/sync-service.js +231 -0
- package/dist/src/integrations/linear/sync-service.js.map +7 -0
- package/dist/src/integrations/linear/sync.js +782 -0
- package/dist/src/integrations/linear/sync.js.map +7 -0
- package/dist/src/integrations/linear/types.js +5 -0
- package/dist/src/integrations/linear/types.js.map +7 -0
- package/dist/src/integrations/linear/unified-sync.js +589 -0
- package/dist/src/integrations/linear/unified-sync.js.map +7 -0
- package/dist/src/integrations/linear/webhook-handler.js +219 -0
- package/dist/src/integrations/linear/webhook-handler.js.map +7 -0
- package/dist/src/integrations/linear/webhook-server.js +218 -0
- package/dist/src/integrations/linear/webhook-server.js.map +7 -0
- package/dist/src/integrations/linear/webhook.js +291 -0
- package/dist/src/integrations/linear/webhook.js.map +7 -0
- package/dist/src/integrations/mcp/handlers/code-execution-handlers.js +266 -0
- package/dist/src/integrations/mcp/handlers/code-execution-handlers.js.map +7 -0
- package/dist/src/integrations/mcp/handlers/context-handlers.js +257 -0
- package/dist/src/integrations/mcp/handlers/context-handlers.js.map +7 -0
- package/dist/src/integrations/mcp/handlers/discovery-handlers.js +497 -0
- package/dist/src/integrations/mcp/handlers/discovery-handlers.js.map +7 -0
- package/dist/src/integrations/mcp/handlers/index.js +166 -0
- package/dist/src/integrations/mcp/handlers/index.js.map +7 -0
- package/dist/src/integrations/mcp/handlers/linear-handlers.js +247 -0
- package/dist/src/integrations/mcp/handlers/linear-handlers.js.map +7 -0
- package/dist/src/integrations/mcp/handlers/skill-handlers.js +529 -0
- package/dist/src/integrations/mcp/handlers/skill-handlers.js.map +7 -0
- package/dist/src/integrations/mcp/handlers/task-handlers.js +239 -0
- package/dist/src/integrations/mcp/handlers/task-handlers.js.map +7 -0
- package/dist/src/integrations/mcp/handlers/trace-handlers.js +308 -0
- package/dist/src/integrations/mcp/handlers/trace-handlers.js.map +7 -0
- package/dist/src/integrations/mcp/index.js +23 -0
- package/dist/src/integrations/mcp/index.js.map +7 -0
- package/dist/src/integrations/mcp/middleware/tool-scoring.js +356 -0
- package/dist/src/integrations/mcp/middleware/tool-scoring.js.map +7 -0
- package/dist/src/integrations/mcp/refactored-server.js +374 -0
- package/dist/src/integrations/mcp/refactored-server.js.map +7 -0
- package/dist/src/integrations/mcp/remote-server.js +682 -0
- package/dist/src/integrations/mcp/remote-server.js.map +7 -0
- package/dist/src/integrations/mcp/schemas.js +147 -0
- package/dist/src/integrations/mcp/schemas.js.map +7 -0
- package/dist/src/integrations/mcp/server.js +1975 -0
- package/dist/src/integrations/mcp/server.js.map +7 -0
- package/dist/src/integrations/mcp/tool-definitions-code.js +125 -0
- package/dist/src/integrations/mcp/tool-definitions-code.js.map +7 -0
- package/dist/src/integrations/mcp/tool-definitions.js +702 -0
- package/dist/src/integrations/mcp/tool-definitions.js.map +7 -0
- package/dist/src/integrations/ralph/bridge/ralph-stackmemory-bridge.js +860 -0
- package/dist/src/integrations/ralph/bridge/ralph-stackmemory-bridge.js.map +7 -0
- package/dist/src/integrations/ralph/context/context-budget-manager.js +301 -0
- package/dist/src/integrations/ralph/context/context-budget-manager.js.map +7 -0
- package/dist/src/integrations/ralph/context/stackmemory-context-loader.js +360 -0
- package/dist/src/integrations/ralph/context/stackmemory-context-loader.js.map +7 -0
- package/dist/src/integrations/ralph/coordination/enhanced-coordination.js +410 -0
- package/dist/src/integrations/ralph/coordination/enhanced-coordination.js.map +7 -0
- package/dist/src/integrations/ralph/index.js +18 -0
- package/dist/src/integrations/ralph/index.js.map +7 -0
- package/dist/src/integrations/ralph/learning/pattern-learner.js +401 -0
- package/dist/src/integrations/ralph/learning/pattern-learner.js.map +7 -0
- package/dist/src/integrations/ralph/lifecycle/iteration-lifecycle.js +448 -0
- package/dist/src/integrations/ralph/lifecycle/iteration-lifecycle.js.map +7 -0
- package/dist/src/integrations/ralph/monitoring/swarm-dashboard.js +294 -0
- package/dist/src/integrations/ralph/monitoring/swarm-dashboard.js.map +7 -0
- package/dist/src/integrations/ralph/monitoring/swarm-registry.js +108 -0
- package/dist/src/integrations/ralph/monitoring/swarm-registry.js.map +7 -0
- package/dist/src/integrations/ralph/orchestration/multi-loop-orchestrator.js +463 -0
- package/dist/src/integrations/ralph/orchestration/multi-loop-orchestrator.js.map +7 -0
- package/dist/src/integrations/ralph/patterns/compounding-engineering-pattern.js +400 -0
- package/dist/src/integrations/ralph/patterns/compounding-engineering-pattern.js.map +7 -0
- package/dist/src/integrations/ralph/patterns/extended-coherence-sessions.js +473 -0
- package/dist/src/integrations/ralph/patterns/extended-coherence-sessions.js.map +7 -0
- package/dist/src/integrations/ralph/patterns/oracle-worker-pattern.js +388 -0
- package/dist/src/integrations/ralph/patterns/oracle-worker-pattern.js.map +7 -0
- package/dist/src/integrations/ralph/performance/performance-optimizer.js +358 -0
- package/dist/src/integrations/ralph/performance/performance-optimizer.js.map +7 -0
- package/dist/src/integrations/ralph/recovery/crash-recovery.js +462 -0
- package/dist/src/integrations/ralph/recovery/crash-recovery.js.map +7 -0
- package/dist/src/integrations/ralph/state/state-reconciler.js +404 -0
- package/dist/src/integrations/ralph/state/state-reconciler.js.map +7 -0
- package/dist/src/integrations/ralph/swarm/git-workflow-manager.js +428 -0
- package/dist/src/integrations/ralph/swarm/git-workflow-manager.js.map +7 -0
- package/dist/src/integrations/ralph/swarm/swarm-coordinator.js +996 -0
- package/dist/src/integrations/ralph/swarm/swarm-coordinator.js.map +7 -0
- package/dist/src/integrations/ralph/types.js +5 -0
- package/dist/src/integrations/ralph/types.js.map +7 -0
- package/dist/src/integrations/ralph/visualization/ralph-debugger.js +585 -0
- package/dist/src/integrations/ralph/visualization/ralph-debugger.js.map +7 -0
- package/dist/src/mcp/stackmemory-mcp-server.js +554 -0
- package/dist/src/mcp/stackmemory-mcp-server.js.map +7 -0
- package/dist/src/middleware/exponential-rate-limiter.js +289 -0
- package/dist/src/middleware/exponential-rate-limiter.js.map +7 -0
- package/dist/src/models/user.model.js +358 -0
- package/dist/src/models/user.model.js.map +7 -0
- package/dist/src/servers/production/auth-middleware.js +528 -0
- package/dist/src/servers/production/auth-middleware.js.map +7 -0
- package/dist/src/services/config-service.js +65 -0
- package/dist/src/services/config-service.js.map +7 -0
- package/dist/src/services/context-service.js +194 -0
- package/dist/src/services/context-service.js.map +7 -0
- package/dist/src/skills/api-discovery.js +354 -0
- package/dist/src/skills/api-discovery.js.map +7 -0
- package/dist/src/skills/api-skill.js +475 -0
- package/dist/src/skills/api-skill.js.map +7 -0
- package/dist/src/skills/claude-skills.js +1061 -0
- package/dist/src/skills/claude-skills.js.map +7 -0
- package/dist/src/skills/dashboard-launcher.js +216 -0
- package/dist/src/skills/dashboard-launcher.js.map +7 -0
- package/dist/src/skills/recursive-agent-orchestrator.js +575 -0
- package/dist/src/skills/recursive-agent-orchestrator.js.map +7 -0
- package/dist/src/skills/repo-ingestion-skill.js +609 -0
- package/dist/src/skills/repo-ingestion-skill.js.map +7 -0
- package/dist/src/skills/unified-rlm-orchestrator.js +404 -0
- package/dist/src/skills/unified-rlm-orchestrator.js.map +7 -0
- package/dist/src/types/task.js +5 -0
- package/dist/src/types/task.js.map +7 -0
- package/dist/src/utils/env.js +50 -0
- package/dist/src/utils/env.js.map +7 -0
- package/dist/src/utils/formatting.js +62 -0
- package/dist/src/utils/formatting.js.map +7 -0
- package/dist/src/utils/process-cleanup.js +136 -0
- package/dist/src/utils/process-cleanup.js.map +7 -0
- package/package.json +4 -3
- package/scripts/create-cleanup-issues.js +302 -0
- package/scripts/demos/browser-test.ts +39 -0
- package/scripts/demos/ralph-integration-demo.ts +244 -0
- package/scripts/demos/trace-demo.ts +214 -0
- package/scripts/demos/trace-detector.demo.ts +171 -0
- package/scripts/demos/trace-test.ts +67 -0
- package/scripts/initialize.ts +16 -7
- package/scripts/install.sh +14 -62
- package/scripts/status.ts +111 -46
- package/scripts/test-claude-config.sh +123 -0
- package/scripts/validate-claude-config.sh +155 -0
|
@@ -0,0 +1,614 @@
|
|
|
1
|
+
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
2
|
+
import { dirname as __pathDirname } from 'path';
|
|
3
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
4
|
+
const __dirname = __pathDirname(__filename);
|
|
5
|
+
import { EventEmitter } from "events";
|
|
6
|
+
import { logger } from "../monitoring/logger.js";
|
|
7
|
+
import { DatabaseError, ErrorCode, wrapError } from "../errors/index.js";
|
|
8
|
+
class MigrationManager extends EventEmitter {
|
|
9
|
+
config;
|
|
10
|
+
progress;
|
|
11
|
+
isRunning = false;
|
|
12
|
+
isPaused = false;
|
|
13
|
+
abortController;
|
|
14
|
+
constructor(config) {
|
|
15
|
+
super();
|
|
16
|
+
this.validateConfig(config);
|
|
17
|
+
this.config = this.normalizeConfig(config);
|
|
18
|
+
this.progress = this.initializeProgress();
|
|
19
|
+
}
|
|
20
|
+
validateConfig(config) {
|
|
21
|
+
if (!config.sourceAdapter || !config.targetAdapter) {
|
|
22
|
+
throw new DatabaseError(
|
|
23
|
+
"Source and target adapters are required",
|
|
24
|
+
ErrorCode.DB_MIGRATION_FAILED,
|
|
25
|
+
{ reason: "missing_adapters" }
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
if (config.batchSize && (config.batchSize < 1 || config.batchSize > 1e4)) {
|
|
29
|
+
throw new DatabaseError(
|
|
30
|
+
"Batch size must be between 1 and 10000",
|
|
31
|
+
ErrorCode.DB_MIGRATION_FAILED,
|
|
32
|
+
{ batchSize: config.batchSize }
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
if (config.retryAttempts && (config.retryAttempts < 0 || config.retryAttempts > 10)) {
|
|
36
|
+
throw new DatabaseError(
|
|
37
|
+
"Retry attempts must be between 0 and 10",
|
|
38
|
+
ErrorCode.DB_MIGRATION_FAILED,
|
|
39
|
+
{ retryAttempts: config.retryAttempts }
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
if (config.retryDelayMs && (config.retryDelayMs < 0 || config.retryDelayMs > 3e4)) {
|
|
43
|
+
throw new DatabaseError(
|
|
44
|
+
"Retry delay must be between 0 and 30000ms",
|
|
45
|
+
ErrorCode.DB_MIGRATION_FAILED,
|
|
46
|
+
{ retryDelayMs: config.retryDelayMs }
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
normalizeConfig(config) {
|
|
51
|
+
return {
|
|
52
|
+
...config,
|
|
53
|
+
batchSize: config.batchSize ?? 1e3,
|
|
54
|
+
retryAttempts: config.retryAttempts ?? 3,
|
|
55
|
+
retryDelayMs: config.retryDelayMs ?? 1e3,
|
|
56
|
+
verifyData: config.verifyData ?? true,
|
|
57
|
+
enableDualWrite: config.enableDualWrite ?? true,
|
|
58
|
+
progressCallback: config.progressCallback ?? (() => {
|
|
59
|
+
})
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
initializeProgress() {
|
|
63
|
+
return {
|
|
64
|
+
phase: "initializing",
|
|
65
|
+
totalRecords: 0,
|
|
66
|
+
processedRecords: 0,
|
|
67
|
+
percentage: 0,
|
|
68
|
+
startTime: /* @__PURE__ */ new Date(),
|
|
69
|
+
errors: [],
|
|
70
|
+
warnings: []
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
async planMigration() {
|
|
74
|
+
logger.info("Planning migration strategy");
|
|
75
|
+
const plan = [];
|
|
76
|
+
const tables = ["frames", "events", "anchors"];
|
|
77
|
+
for (const table of tables) {
|
|
78
|
+
try {
|
|
79
|
+
const stats = await this.config.sourceAdapter.getStats();
|
|
80
|
+
const estimatedRows = this.estimateTableRows(table, stats);
|
|
81
|
+
plan.push({
|
|
82
|
+
table,
|
|
83
|
+
priority: this.getTablePriority(table),
|
|
84
|
+
estimatedRows,
|
|
85
|
+
dependencies: this.getTableDependencies(table),
|
|
86
|
+
strategy: "full"
|
|
87
|
+
});
|
|
88
|
+
} catch (error) {
|
|
89
|
+
logger.warn(`Failed to estimate rows for table ${table}:`, error);
|
|
90
|
+
plan.push({
|
|
91
|
+
table,
|
|
92
|
+
priority: this.getTablePriority(table),
|
|
93
|
+
estimatedRows: 0,
|
|
94
|
+
dependencies: this.getTableDependencies(table),
|
|
95
|
+
strategy: "skip"
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
plan.sort((a, b) => a.priority - b.priority);
|
|
100
|
+
const totalRecords = plan.reduce((sum, p) => sum + p.estimatedRows, 0);
|
|
101
|
+
this.progress.totalRecords = totalRecords;
|
|
102
|
+
logger.info(
|
|
103
|
+
`Migration plan: ${plan.length} tables, ~${totalRecords} records`
|
|
104
|
+
);
|
|
105
|
+
return plan;
|
|
106
|
+
}
|
|
107
|
+
estimateTableRows(table, stats) {
|
|
108
|
+
switch (table) {
|
|
109
|
+
case "frames":
|
|
110
|
+
return stats.totalFrames || 0;
|
|
111
|
+
case "events":
|
|
112
|
+
return stats.totalEvents || 0;
|
|
113
|
+
case "anchors":
|
|
114
|
+
return stats.totalAnchors || 0;
|
|
115
|
+
default:
|
|
116
|
+
return 0;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
getTablePriority(table) {
|
|
120
|
+
const priorities = { frames: 1, events: 2, anchors: 3 };
|
|
121
|
+
return priorities[table] || 99;
|
|
122
|
+
}
|
|
123
|
+
getTableDependencies(table) {
|
|
124
|
+
const dependencies = {
|
|
125
|
+
frames: [],
|
|
126
|
+
events: ["frames"],
|
|
127
|
+
anchors: ["frames"]
|
|
128
|
+
};
|
|
129
|
+
return dependencies[table] || [];
|
|
130
|
+
}
|
|
131
|
+
async migrate(strategy = {
|
|
132
|
+
type: "online",
|
|
133
|
+
allowWrites: true,
|
|
134
|
+
verifyIntegrity: true,
|
|
135
|
+
fallbackOnError: true
|
|
136
|
+
}) {
|
|
137
|
+
if (this.isRunning) {
|
|
138
|
+
throw new DatabaseError(
|
|
139
|
+
"Migration already in progress",
|
|
140
|
+
ErrorCode.DB_MIGRATION_FAILED,
|
|
141
|
+
{ reason: "already_running" }
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
this.isRunning = true;
|
|
145
|
+
this.abortController = new AbortController();
|
|
146
|
+
try {
|
|
147
|
+
logger.info("Starting database migration", strategy);
|
|
148
|
+
this.updateProgress({ phase: "initializing" });
|
|
149
|
+
await this.validateAdapters();
|
|
150
|
+
const plan = await this.planMigration();
|
|
151
|
+
await this.initializeTargetSchema();
|
|
152
|
+
if (strategy.type === "dual-write" && this.config.enableDualWrite) {
|
|
153
|
+
await this.enableDualWrite();
|
|
154
|
+
}
|
|
155
|
+
this.updateProgress({ phase: "migrating" });
|
|
156
|
+
await this.executeMigrationPlan(plan, strategy);
|
|
157
|
+
if (strategy.verifyIntegrity) {
|
|
158
|
+
this.updateProgress({ phase: "verifying" });
|
|
159
|
+
await this.verifyDataIntegrity(plan);
|
|
160
|
+
}
|
|
161
|
+
this.updateProgress({ phase: "completing" });
|
|
162
|
+
await this.completeMigration(strategy);
|
|
163
|
+
this.updateProgress({ phase: "completed", percentage: 100 });
|
|
164
|
+
logger.info("Migration completed successfully");
|
|
165
|
+
this.emit("completed", this.progress);
|
|
166
|
+
} catch (error) {
|
|
167
|
+
this.updateProgress({ phase: "failed" });
|
|
168
|
+
const sanitizedError = this.sanitizeError(error);
|
|
169
|
+
logger.error("Migration failed:", sanitizedError);
|
|
170
|
+
if (strategy.fallbackOnError) {
|
|
171
|
+
try {
|
|
172
|
+
await this.rollbackMigration();
|
|
173
|
+
} catch (rollbackError) {
|
|
174
|
+
logger.error("Rollback failed:", this.sanitizeError(rollbackError));
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
const userError = new DatabaseError(
|
|
178
|
+
"Migration failed. Check logs for details.",
|
|
179
|
+
ErrorCode.DB_MIGRATION_FAILED,
|
|
180
|
+
{ phase: this.progress.phase },
|
|
181
|
+
error instanceof Error ? error : void 0
|
|
182
|
+
);
|
|
183
|
+
this.emit("failed", userError);
|
|
184
|
+
throw userError;
|
|
185
|
+
} finally {
|
|
186
|
+
this.isRunning = false;
|
|
187
|
+
this.abortController = void 0;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
async validateAdapters() {
|
|
191
|
+
logger.debug("Validating database adapters");
|
|
192
|
+
if (!this.config.sourceAdapter.isConnected()) {
|
|
193
|
+
await this.config.sourceAdapter.connect();
|
|
194
|
+
}
|
|
195
|
+
if (!await this.config.sourceAdapter.ping()) {
|
|
196
|
+
throw new DatabaseError(
|
|
197
|
+
"Source adapter is not responding",
|
|
198
|
+
ErrorCode.DB_CONNECTION_FAILED,
|
|
199
|
+
{ adapter: "source" }
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
if (!this.config.targetAdapter.isConnected()) {
|
|
203
|
+
await this.config.targetAdapter.connect();
|
|
204
|
+
}
|
|
205
|
+
if (!await this.config.targetAdapter.ping()) {
|
|
206
|
+
throw new DatabaseError(
|
|
207
|
+
"Target adapter is not responding",
|
|
208
|
+
ErrorCode.DB_CONNECTION_FAILED,
|
|
209
|
+
{ adapter: "target" }
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
const sourceVersion = await this.config.sourceAdapter.getSchemaVersion();
|
|
213
|
+
const targetVersion = await this.config.targetAdapter.getSchemaVersion();
|
|
214
|
+
if (sourceVersion !== targetVersion) {
|
|
215
|
+
logger.warn(
|
|
216
|
+
`Schema version mismatch: source=${sourceVersion}, target=${targetVersion}`
|
|
217
|
+
);
|
|
218
|
+
this.addWarning("Schema version mismatch detected");
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
async initializeTargetSchema() {
|
|
222
|
+
logger.debug("Initializing target schema");
|
|
223
|
+
try {
|
|
224
|
+
await this.config.targetAdapter.initializeSchema();
|
|
225
|
+
} catch (error) {
|
|
226
|
+
logger.error("Failed to initialize target schema:", error);
|
|
227
|
+
throw new DatabaseError(
|
|
228
|
+
"Target schema initialization failed",
|
|
229
|
+
ErrorCode.DB_SCHEMA_ERROR,
|
|
230
|
+
{ operation: "initializeSchema" },
|
|
231
|
+
error instanceof Error ? error : void 0
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
async enableDualWrite() {
|
|
236
|
+
logger.info("Enabling dual-write mode");
|
|
237
|
+
this.addWarning(
|
|
238
|
+
"Dual-write mode enabled - ensure application routes writes to both adapters"
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
async executeMigrationPlan(plan, strategy) {
|
|
242
|
+
for (const tablePlan of plan) {
|
|
243
|
+
if (this.abortController?.signal.aborted) {
|
|
244
|
+
throw new DatabaseError(
|
|
245
|
+
"Migration aborted by user",
|
|
246
|
+
ErrorCode.DB_MIGRATION_FAILED,
|
|
247
|
+
{ reason: "user_abort" }
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
if (tablePlan.strategy === "skip") {
|
|
251
|
+
logger.info(`Skipping table: ${tablePlan.table}`);
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
this.updateProgress({ currentTable: tablePlan.table });
|
|
255
|
+
await this.migrateTable(tablePlan, strategy);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
async migrateTable(plan, _strategy) {
|
|
259
|
+
logger.info(`Migrating table: ${plan.table} (~${plan.estimatedRows} rows)`);
|
|
260
|
+
let offset = 0;
|
|
261
|
+
let migratedRows = 0;
|
|
262
|
+
while (true) {
|
|
263
|
+
if (this.abortController?.signal.aborted || this.isPaused) {
|
|
264
|
+
break;
|
|
265
|
+
}
|
|
266
|
+
try {
|
|
267
|
+
const batch = await this.getBatch(
|
|
268
|
+
plan.table,
|
|
269
|
+
offset,
|
|
270
|
+
this.config.batchSize
|
|
271
|
+
);
|
|
272
|
+
if (batch.length === 0) {
|
|
273
|
+
break;
|
|
274
|
+
}
|
|
275
|
+
await this.migrateBatch(plan.table, batch);
|
|
276
|
+
migratedRows += batch.length;
|
|
277
|
+
offset += this.config.batchSize;
|
|
278
|
+
this.progress.processedRecords += batch.length;
|
|
279
|
+
this.updateProgressPercentage();
|
|
280
|
+
await this.sleep(this.calculateAdaptiveDelay());
|
|
281
|
+
} catch (error) {
|
|
282
|
+
this.addError(plan.table, `Batch migration failed: ${error}`);
|
|
283
|
+
if (this.config.retryAttempts > 0) {
|
|
284
|
+
await this.retryBatch(plan.table, offset, this.config.batchSize);
|
|
285
|
+
} else {
|
|
286
|
+
throw wrapError(
|
|
287
|
+
error,
|
|
288
|
+
`Batch migration failed for table ${plan.table}`,
|
|
289
|
+
ErrorCode.DB_MIGRATION_FAILED,
|
|
290
|
+
{ table: plan.table, offset }
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
logger.info(
|
|
296
|
+
`Completed migrating table ${plan.table}: ${migratedRows} rows`
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
async getBatch(table, offset, limit) {
|
|
300
|
+
const allowedTables = ["frames", "events", "anchors"];
|
|
301
|
+
if (!allowedTables.includes(table)) {
|
|
302
|
+
throw new DatabaseError(
|
|
303
|
+
`Invalid table name: ${table}`,
|
|
304
|
+
ErrorCode.DB_QUERY_FAILED,
|
|
305
|
+
{ table, allowedTables }
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
const safeLimit = Math.max(1, Math.min(limit, 1e4));
|
|
309
|
+
const safeOffset = Math.max(0, offset);
|
|
310
|
+
void safeLimit;
|
|
311
|
+
void safeOffset;
|
|
312
|
+
switch (table) {
|
|
313
|
+
case "frames":
|
|
314
|
+
return [];
|
|
315
|
+
// Placeholder
|
|
316
|
+
case "events":
|
|
317
|
+
return [];
|
|
318
|
+
// Placeholder
|
|
319
|
+
case "anchors":
|
|
320
|
+
return [];
|
|
321
|
+
// Placeholder
|
|
322
|
+
default:
|
|
323
|
+
throw new DatabaseError(
|
|
324
|
+
`Unsupported table: ${table}`,
|
|
325
|
+
ErrorCode.DB_QUERY_FAILED,
|
|
326
|
+
{ table }
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
async migrateBatch(table, batch) {
|
|
331
|
+
const allowedTables = ["frames", "events", "anchors"];
|
|
332
|
+
if (!allowedTables.includes(table)) {
|
|
333
|
+
throw new DatabaseError(
|
|
334
|
+
`Invalid table name: ${table}`,
|
|
335
|
+
ErrorCode.DB_INSERT_FAILED,
|
|
336
|
+
{ table }
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
await this.config.targetAdapter.inTransaction(async (adapter) => {
|
|
340
|
+
const operations = batch.map((row) => ({
|
|
341
|
+
type: "insert",
|
|
342
|
+
table,
|
|
343
|
+
data: this.validateRowData(table, row)
|
|
344
|
+
}));
|
|
345
|
+
await adapter.executeBulk(operations);
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
validateRowData(table, row) {
|
|
349
|
+
if (!row || typeof row !== "object") {
|
|
350
|
+
throw new DatabaseError(
|
|
351
|
+
`Invalid row data for table ${table}`,
|
|
352
|
+
ErrorCode.DB_INSERT_FAILED,
|
|
353
|
+
{ table, rowType: typeof row }
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
switch (table) {
|
|
357
|
+
case "frames":
|
|
358
|
+
return this.validateFrameRow(row);
|
|
359
|
+
case "events":
|
|
360
|
+
return this.validateEventRow(row);
|
|
361
|
+
case "anchors":
|
|
362
|
+
return this.validateAnchorRow(row);
|
|
363
|
+
default:
|
|
364
|
+
throw new DatabaseError(
|
|
365
|
+
`Unknown table: ${table}`,
|
|
366
|
+
ErrorCode.DB_INSERT_FAILED,
|
|
367
|
+
{ table }
|
|
368
|
+
);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
validateFrameRow(row) {
|
|
372
|
+
const required = [
|
|
373
|
+
"frame_id",
|
|
374
|
+
"project_id",
|
|
375
|
+
"run_id",
|
|
376
|
+
"type",
|
|
377
|
+
"name",
|
|
378
|
+
"state",
|
|
379
|
+
"depth"
|
|
380
|
+
];
|
|
381
|
+
for (const field of required) {
|
|
382
|
+
if (!(field in row)) {
|
|
383
|
+
throw new DatabaseError(
|
|
384
|
+
`Missing required field ${field} in frame row`,
|
|
385
|
+
ErrorCode.DB_CONSTRAINT_VIOLATION,
|
|
386
|
+
{ table: "frames", missingField: field }
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
return row;
|
|
391
|
+
}
|
|
392
|
+
validateEventRow(row) {
|
|
393
|
+
const required = ["event_id", "frame_id", "seq", "type", "text"];
|
|
394
|
+
for (const field of required) {
|
|
395
|
+
if (!(field in row)) {
|
|
396
|
+
throw new DatabaseError(
|
|
397
|
+
`Missing required field ${field} in event row`,
|
|
398
|
+
ErrorCode.DB_CONSTRAINT_VIOLATION,
|
|
399
|
+
{ table: "events", missingField: field }
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
return row;
|
|
404
|
+
}
|
|
405
|
+
validateAnchorRow(row) {
|
|
406
|
+
const required = ["anchor_id", "frame_id", "type", "text", "priority"];
|
|
407
|
+
for (const field of required) {
|
|
408
|
+
if (!(field in row)) {
|
|
409
|
+
throw new DatabaseError(
|
|
410
|
+
`Missing required field ${field} in anchor row`,
|
|
411
|
+
ErrorCode.DB_CONSTRAINT_VIOLATION,
|
|
412
|
+
{ table: "anchors", missingField: field }
|
|
413
|
+
);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
return row;
|
|
417
|
+
}
|
|
418
|
+
async retryBatch(table, offset, batchSize) {
|
|
419
|
+
for (let attempt = 1; attempt <= this.config.retryAttempts; attempt++) {
|
|
420
|
+
try {
|
|
421
|
+
await this.sleep(this.config.retryDelayMs * attempt);
|
|
422
|
+
const batch = await this.getBatch(table, offset, batchSize);
|
|
423
|
+
await this.migrateBatch(table, batch);
|
|
424
|
+
logger.info(`Retry successful for table ${table} at offset ${offset}`);
|
|
425
|
+
return;
|
|
426
|
+
} catch (error) {
|
|
427
|
+
logger.warn(
|
|
428
|
+
`Retry ${attempt}/${this.config.retryAttempts} failed:`,
|
|
429
|
+
error
|
|
430
|
+
);
|
|
431
|
+
if (attempt === this.config.retryAttempts) {
|
|
432
|
+
throw new DatabaseError(
|
|
433
|
+
`Failed after ${this.config.retryAttempts} retries`,
|
|
434
|
+
ErrorCode.DB_MIGRATION_FAILED,
|
|
435
|
+
{ table, offset, attempts: this.config.retryAttempts },
|
|
436
|
+
error instanceof Error ? error : void 0
|
|
437
|
+
);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
async verifyDataIntegrity(plan) {
|
|
443
|
+
logger.info("Verifying data integrity");
|
|
444
|
+
for (const tablePlan of plan) {
|
|
445
|
+
if (tablePlan.strategy === "skip") continue;
|
|
446
|
+
try {
|
|
447
|
+
const sourceStats = await this.config.sourceAdapter.getStats();
|
|
448
|
+
const targetStats = await this.config.targetAdapter.getStats();
|
|
449
|
+
const sourceCount = this.estimateTableRows(
|
|
450
|
+
tablePlan.table,
|
|
451
|
+
sourceStats
|
|
452
|
+
);
|
|
453
|
+
const targetCount = this.estimateTableRows(
|
|
454
|
+
tablePlan.table,
|
|
455
|
+
targetStats
|
|
456
|
+
);
|
|
457
|
+
if (sourceCount !== targetCount) {
|
|
458
|
+
this.addError(
|
|
459
|
+
tablePlan.table,
|
|
460
|
+
`Row count mismatch: source=${sourceCount}, target=${targetCount}`
|
|
461
|
+
);
|
|
462
|
+
} else {
|
|
463
|
+
logger.debug(
|
|
464
|
+
`Table ${tablePlan.table} verified: ${sourceCount} rows`
|
|
465
|
+
);
|
|
466
|
+
}
|
|
467
|
+
} catch (error) {
|
|
468
|
+
this.addError(tablePlan.table, `Verification failed: ${error}`);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
if (this.progress.errors.length > 0) {
|
|
472
|
+
throw new DatabaseError(
|
|
473
|
+
`Data integrity verification failed with ${this.progress.errors.length} errors`,
|
|
474
|
+
ErrorCode.DB_MIGRATION_FAILED,
|
|
475
|
+
{
|
|
476
|
+
errorCount: this.progress.errors.length,
|
|
477
|
+
errors: this.progress.errors
|
|
478
|
+
}
|
|
479
|
+
);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
async completeMigration(_strategy) {
|
|
483
|
+
logger.info("Completing migration");
|
|
484
|
+
const sourceVersion = await this.config.sourceAdapter.getSchemaVersion();
|
|
485
|
+
await this.config.targetAdapter.migrateSchema(sourceVersion);
|
|
486
|
+
await this.config.targetAdapter.analyze();
|
|
487
|
+
logger.info("Migration completion tasks finished");
|
|
488
|
+
}
|
|
489
|
+
async rollbackMigration() {
|
|
490
|
+
logger.warn("Rolling back migration");
|
|
491
|
+
try {
|
|
492
|
+
logger.warn(
|
|
493
|
+
"Rollback would clean target database - implement based on strategy"
|
|
494
|
+
);
|
|
495
|
+
} catch (error) {
|
|
496
|
+
logger.error("Rollback failed:", error);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
updateProgress(updates) {
|
|
500
|
+
Object.assign(this.progress, updates);
|
|
501
|
+
this.updateProgressPercentage();
|
|
502
|
+
if (this.progress.totalRecords > 0) {
|
|
503
|
+
const elapsed = Date.now() - this.progress.startTime.getTime();
|
|
504
|
+
const rate = this.progress.processedRecords / (elapsed / 1e3);
|
|
505
|
+
const remaining = this.progress.totalRecords - this.progress.processedRecords;
|
|
506
|
+
if (rate > 0) {
|
|
507
|
+
this.progress.estimatedEndTime = new Date(
|
|
508
|
+
Date.now() + remaining / rate * 1e3
|
|
509
|
+
);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
this.config.progressCallback(this.progress);
|
|
513
|
+
this.emit("progress", this.progress);
|
|
514
|
+
}
|
|
515
|
+
updateProgressPercentage() {
|
|
516
|
+
if (this.progress.totalRecords > 0) {
|
|
517
|
+
this.progress.percentage = Math.min(
|
|
518
|
+
100,
|
|
519
|
+
this.progress.processedRecords / this.progress.totalRecords * 100
|
|
520
|
+
);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
addError(table, error) {
|
|
524
|
+
this.progress.errors.push({
|
|
525
|
+
table,
|
|
526
|
+
error,
|
|
527
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
528
|
+
});
|
|
529
|
+
logger.error(`Migration error for table ${table}: ${error}`);
|
|
530
|
+
}
|
|
531
|
+
addWarning(warning, table) {
|
|
532
|
+
this.progress.warnings.push({
|
|
533
|
+
table: table || "general",
|
|
534
|
+
warning,
|
|
535
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
536
|
+
});
|
|
537
|
+
logger.warn(`Migration warning: ${warning}`);
|
|
538
|
+
}
|
|
539
|
+
sanitizeError(error) {
|
|
540
|
+
if (error instanceof Error) {
|
|
541
|
+
return {
|
|
542
|
+
name: error.name,
|
|
543
|
+
message: error.message
|
|
544
|
+
// Exclude stack traces and sensitive data for security
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
return { message: "Unknown error occurred" };
|
|
548
|
+
}
|
|
549
|
+
calculateAdaptiveDelay() {
|
|
550
|
+
const memoryUsage = process.memoryUsage().heapUsed / 1024 / 1024;
|
|
551
|
+
if (memoryUsage > 400) return 100;
|
|
552
|
+
if (memoryUsage > 300) return 50;
|
|
553
|
+
return 10;
|
|
554
|
+
}
|
|
555
|
+
sleep(ms) {
|
|
556
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
557
|
+
}
|
|
558
|
+
pause() {
|
|
559
|
+
if (!this.isRunning) {
|
|
560
|
+
throw new DatabaseError(
|
|
561
|
+
"No migration in progress",
|
|
562
|
+
ErrorCode.DB_MIGRATION_FAILED,
|
|
563
|
+
{ reason: "not_running" }
|
|
564
|
+
);
|
|
565
|
+
}
|
|
566
|
+
this.isPaused = true;
|
|
567
|
+
logger.info("Migration paused");
|
|
568
|
+
this.emit("paused");
|
|
569
|
+
}
|
|
570
|
+
resume() {
|
|
571
|
+
if (!this.isRunning) {
|
|
572
|
+
throw new DatabaseError(
|
|
573
|
+
"No migration in progress",
|
|
574
|
+
ErrorCode.DB_MIGRATION_FAILED,
|
|
575
|
+
{ reason: "not_running" }
|
|
576
|
+
);
|
|
577
|
+
}
|
|
578
|
+
this.isPaused = false;
|
|
579
|
+
logger.info("Migration resumed");
|
|
580
|
+
this.emit("resumed");
|
|
581
|
+
}
|
|
582
|
+
abort() {
|
|
583
|
+
if (!this.isRunning) {
|
|
584
|
+
throw new DatabaseError(
|
|
585
|
+
"No migration in progress",
|
|
586
|
+
ErrorCode.DB_MIGRATION_FAILED,
|
|
587
|
+
{ reason: "not_running" }
|
|
588
|
+
);
|
|
589
|
+
}
|
|
590
|
+
this.abortController?.abort();
|
|
591
|
+
logger.info("Migration aborted");
|
|
592
|
+
this.emit("aborted");
|
|
593
|
+
}
|
|
594
|
+
getProgress() {
|
|
595
|
+
return { ...this.progress };
|
|
596
|
+
}
|
|
597
|
+
isActive() {
|
|
598
|
+
return this.isRunning;
|
|
599
|
+
}
|
|
600
|
+
async estimateDuration() {
|
|
601
|
+
const plan = await this.planMigration();
|
|
602
|
+
const totalRecords = plan.reduce((sum, p) => sum + p.estimatedRows, 0);
|
|
603
|
+
const estimatedSeconds = totalRecords / 1e3;
|
|
604
|
+
const estimatedMinutes = Math.ceil(estimatedSeconds / 60);
|
|
605
|
+
let confidence = "medium";
|
|
606
|
+
if (totalRecords < 1e4) confidence = "high";
|
|
607
|
+
if (totalRecords > 1e5) confidence = "low";
|
|
608
|
+
return { estimatedMinutes, confidence };
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
export {
|
|
612
|
+
MigrationManager
|
|
613
|
+
};
|
|
614
|
+
//# sourceMappingURL=migration-manager.js.map
|