@stackmemoryai/stackmemory 0.5.59 → 0.5.61
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/README.md +105 -1
- package/dist/src/cli/claude-sm.js +130 -50
- package/dist/src/cli/claude-sm.js.map +2 -2
- package/dist/src/cli/index.js +18 -3
- package/dist/src/cli/index.js.map +3 -3
- package/dist/src/core/extensions/custom-tools.js +567 -0
- package/dist/src/core/extensions/custom-tools.js.map +7 -0
- package/dist/src/core/extensions/index.js +55 -0
- package/dist/src/core/extensions/index.js.map +7 -0
- package/dist/src/core/extensions/loader.js +709 -0
- package/dist/src/core/extensions/loader.js.map +7 -0
- package/dist/src/core/extensions/plugin-system.js +506 -0
- package/dist/src/core/extensions/plugin-system.js.map +7 -0
- package/dist/src/core/extensions/provider-adapter.js +617 -0
- package/dist/src/core/extensions/provider-adapter.js.map +7 -0
- package/dist/src/core/extensions/sandbox-runtime.js +664 -0
- package/dist/src/core/extensions/sandbox-runtime.js.map +7 -0
- package/dist/src/core/storage/chromadb-adapter.js +32 -6
- package/dist/src/core/storage/chromadb-adapter.js.map +2 -2
- package/dist/src/skills/repo-ingestion-skill.js +35 -12
- package/dist/src/skills/repo-ingestion-skill.js.map +2 -2
- package/package.json +11 -7
- package/scripts/background-sync-manager.js +145 -83
- package/scripts/claude-sm-autostart.js +17 -12
- package/scripts/gepa/README.md +275 -0
- package/scripts/gepa/config.json +53 -0
- package/scripts/gepa/evals/coding-tasks.jsonl +5 -0
- package/scripts/gepa/evals/fixtures/buggy-loop.js +18 -0
- package/scripts/gepa/evals/fixtures/callback-hell.js +53 -0
- package/scripts/gepa/generations/gen-000/baseline.md +124 -0
- package/scripts/gepa/hooks/auto-optimize.js +494 -0
- package/scripts/gepa/hooks/eval-tracker.js +203 -0
- package/scripts/gepa/hooks/reflect.js +311 -0
- package/scripts/gepa/optimize.js +611 -0
- package/scripts/gepa/state.json +14 -0
- package/scripts/test-pre-publish-quick.sh +1 -1
- package/dist/agents/core/agent-task-manager.js +0 -527
- package/dist/agents/core/agent-task-manager.js.map +0 -7
- package/dist/agents/testing-agent.js +0 -614
- package/dist/agents/testing-agent.js.map +0 -7
- package/dist/agents/verifiers/base-verifier.js +0 -133
- package/dist/agents/verifiers/base-verifier.js.map +0 -7
- package/dist/agents/verifiers/formatter-verifier.js +0 -130
- package/dist/agents/verifiers/formatter-verifier.js.map +0 -7
- package/dist/agents/verifiers/llm-judge.js +0 -252
- package/dist/agents/verifiers/llm-judge.js.map +0 -7
- package/dist/cli/auto-detect.js +0 -321
- package/dist/cli/auto-detect.js.map +0 -7
- package/dist/cli/browser-test.js +0 -33
- package/dist/cli/browser-test.js.map +0 -7
- package/dist/cli/claude-sm-danger.js +0 -21
- package/dist/cli/claude-sm-danger.js.map +0 -7
- package/dist/cli/claude-sm.js +0 -1156
- package/dist/cli/claude-sm.js.map +0 -7
- package/dist/cli/codex-sm-danger.js +0 -21
- package/dist/cli/codex-sm-danger.js.map +0 -7
- package/dist/cli/codex-sm.js +0 -349
- package/dist/cli/codex-sm.js.map +0 -7
- package/dist/cli/commands/api.js +0 -232
- package/dist/cli/commands/api.js.map +0 -7
- package/dist/cli/commands/auto-background.js +0 -180
- package/dist/cli/commands/auto-background.js.map +0 -7
- package/dist/cli/commands/cleanup-processes.js +0 -68
- package/dist/cli/commands/cleanup-processes.js.map +0 -7
- package/dist/cli/commands/clear.js +0 -202
- package/dist/cli/commands/clear.js.map +0 -7
- package/dist/cli/commands/config.js +0 -445
- package/dist/cli/commands/config.js.map +0 -7
- package/dist/cli/commands/context-rehydrate.js +0 -751
- package/dist/cli/commands/context-rehydrate.js.map +0 -7
- package/dist/cli/commands/context.js +0 -343
- package/dist/cli/commands/context.js.map +0 -7
- package/dist/cli/commands/daemon.js +0 -392
- package/dist/cli/commands/daemon.js.map +0 -7
- package/dist/cli/commands/dashboard.js +0 -210
- package/dist/cli/commands/dashboard.js.map +0 -7
- package/dist/cli/commands/db.js +0 -147
- package/dist/cli/commands/db.js.map +0 -7
- package/dist/cli/commands/decision.js +0 -266
- package/dist/cli/commands/decision.js.map +0 -7
- package/dist/cli/commands/discovery.js +0 -279
- package/dist/cli/commands/discovery.js.map +0 -7
- package/dist/cli/commands/handoff.js +0 -624
- package/dist/cli/commands/handoff.js.map +0 -7
- package/dist/cli/commands/hooks.js +0 -298
- package/dist/cli/commands/hooks.js.map +0 -7
- package/dist/cli/commands/linear-unified.js +0 -353
- package/dist/cli/commands/linear-unified.js.map +0 -7
- package/dist/cli/commands/linear.js +0 -529
- package/dist/cli/commands/linear.js.map +0 -7
- package/dist/cli/commands/log.js +0 -169
- package/dist/cli/commands/log.js.map +0 -7
- package/dist/cli/commands/login.js +0 -172
- package/dist/cli/commands/login.js.map +0 -7
- package/dist/cli/commands/migrate.js +0 -240
- package/dist/cli/commands/migrate.js.map +0 -7
- package/dist/cli/commands/model.js +0 -533
- package/dist/cli/commands/model.js.map +0 -7
- package/dist/cli/commands/monitor.js +0 -313
- package/dist/cli/commands/monitor.js.map +0 -7
- package/dist/cli/commands/onboard.js +0 -536
- package/dist/cli/commands/onboard.js.map +0 -7
- package/dist/cli/commands/projects.js +0 -199
- package/dist/cli/commands/projects.js.map +0 -7
- package/dist/cli/commands/quality.js +0 -413
- package/dist/cli/commands/quality.js.map +0 -7
- package/dist/cli/commands/ralph.js +0 -909
- package/dist/cli/commands/ralph.js.map +0 -7
- package/dist/cli/commands/retrieval.js +0 -248
- package/dist/cli/commands/retrieval.js.map +0 -7
- package/dist/cli/commands/search.js +0 -173
- package/dist/cli/commands/search.js.map +0 -7
- package/dist/cli/commands/service.js +0 -749
- package/dist/cli/commands/service.js.map +0 -7
- package/dist/cli/commands/session.js +0 -200
- package/dist/cli/commands/session.js.map +0 -7
- package/dist/cli/commands/settings.js +0 -306
- package/dist/cli/commands/settings.js.map +0 -7
- package/dist/cli/commands/setup.js +0 -701
- package/dist/cli/commands/setup.js.map +0 -7
- package/dist/cli/commands/shell.js +0 -249
- package/dist/cli/commands/shell.js.map +0 -7
- package/dist/cli/commands/signup.js +0 -50
- package/dist/cli/commands/signup.js.map +0 -7
- package/dist/cli/commands/skills.js +0 -470
- package/dist/cli/commands/skills.js.map +0 -7
- package/dist/cli/commands/sms-notify.js +0 -795
- package/dist/cli/commands/sms-notify.js.map +0 -7
- package/dist/cli/commands/storage-tier.js +0 -183
- package/dist/cli/commands/storage-tier.js.map +0 -7
- package/dist/cli/commands/storage.js +0 -360
- package/dist/cli/commands/storage.js.map +0 -7
- package/dist/cli/commands/sweep.js +0 -249
- package/dist/cli/commands/sweep.js.map +0 -7
- package/dist/cli/commands/tasks.js +0 -213
- package/dist/cli/commands/tasks.js.map +0 -7
- package/dist/cli/commands/test.js +0 -286
- package/dist/cli/commands/test.js.map +0 -7
- package/dist/cli/commands/workflow.js +0 -142
- package/dist/cli/commands/workflow.js.map +0 -7
- package/dist/cli/commands/worktree.js +0 -319
- package/dist/cli/commands/worktree.js.map +0 -7
- package/dist/cli/index.js +0 -594
- package/dist/cli/index.js.map +0 -7
- package/dist/cli/opencode-sm.js +0 -448
- package/dist/cli/opencode-sm.js.map +0 -7
- package/dist/cli/utils/viewer.js +0 -96
- package/dist/cli/utils/viewer.js.map +0 -7
- package/dist/core/analytics/team-analytics.js +0 -378
- package/dist/core/analytics/team-analytics.js.map +0 -7
- package/dist/core/config/config-manager.js +0 -398
- package/dist/core/config/config-manager.js.map +0 -7
- package/dist/core/config/feature-flags.js +0 -76
- package/dist/core/config/feature-flags.js.map +0 -7
- package/dist/core/config/storage-config.js +0 -115
- package/dist/core/config/storage-config.js.map +0 -7
- package/dist/core/config/types.js +0 -144
- package/dist/core/config/types.js.map +0 -7
- package/dist/core/context/auto-context.js +0 -80
- package/dist/core/context/auto-context.js.map +0 -7
- package/dist/core/context/dual-stack-manager.js +0 -870
- package/dist/core/context/dual-stack-manager.js.map +0 -7
- package/dist/core/context/enhanced-rehydration.js +0 -994
- package/dist/core/context/enhanced-rehydration.js.map +0 -7
- package/dist/core/context/frame-database.js +0 -479
- package/dist/core/context/frame-database.js.map +0 -7
- package/dist/core/context/frame-digest.js +0 -250
- package/dist/core/context/frame-digest.js.map +0 -7
- package/dist/core/context/frame-handoff-manager.js +0 -778
- package/dist/core/context/frame-handoff-manager.js.map +0 -7
- package/dist/core/context/frame-lifecycle-hooks.js +0 -119
- package/dist/core/context/frame-lifecycle-hooks.js.map +0 -7
- package/dist/core/context/frame-manager.js +0 -1069
- package/dist/core/context/frame-manager.js.map +0 -7
- package/dist/core/context/frame-recovery.js +0 -302
- package/dist/core/context/frame-recovery.js.map +0 -7
- package/dist/core/context/frame-stack.js +0 -314
- package/dist/core/context/frame-stack.js.map +0 -7
- package/dist/core/context/frame-types.js +0 -5
- package/dist/core/context/frame-types.js.map +0 -7
- package/dist/core/context/incremental-gc.js +0 -290
- package/dist/core/context/incremental-gc.js.map +0 -7
- package/dist/core/context/index.js +0 -25
- package/dist/core/context/index.js.map +0 -7
- package/dist/core/context/model-aware-compaction.js +0 -623
- package/dist/core/context/model-aware-compaction.js.map +0 -7
- package/dist/core/context/permission-manager.js +0 -185
- package/dist/core/context/permission-manager.js.map +0 -7
- package/dist/core/context/recursive-context-manager.js +0 -592
- package/dist/core/context/recursive-context-manager.js.map +0 -7
- package/dist/core/context/refactored-frame-manager.js +0 -754
- package/dist/core/context/refactored-frame-manager.js.map +0 -7
- package/dist/core/context/shared-context-layer.js +0 -621
- package/dist/core/context/shared-context-layer.js.map +0 -7
- package/dist/core/context/stack-merge-resolver.js +0 -749
- package/dist/core/context/stack-merge-resolver.js.map +0 -7
- package/dist/core/context/validation.js +0 -130
- package/dist/core/context/validation.js.map +0 -7
- package/dist/core/database/batch-operations.js +0 -384
- package/dist/core/database/batch-operations.js.map +0 -7
- package/dist/core/database/connection-pool.js +0 -330
- package/dist/core/database/connection-pool.js.map +0 -7
- package/dist/core/database/database-adapter.js +0 -60
- package/dist/core/database/database-adapter.js.map +0 -7
- package/dist/core/database/migration-manager.js +0 -614
- package/dist/core/database/migration-manager.js.map +0 -7
- package/dist/core/database/paradedb-adapter.js +0 -990
- package/dist/core/database/paradedb-adapter.js.map +0 -7
- package/dist/core/database/query-cache.js +0 -298
- package/dist/core/database/query-cache.js.map +0 -7
- package/dist/core/database/query-router.js +0 -430
- package/dist/core/database/query-router.js.map +0 -7
- package/dist/core/database/sqlite-adapter.js +0 -738
- package/dist/core/database/sqlite-adapter.js.map +0 -7
- package/dist/core/digest/enhanced-hybrid-digest.js +0 -277
- package/dist/core/digest/enhanced-hybrid-digest.js.map +0 -7
- package/dist/core/digest/frame-digest-integration.js +0 -176
- package/dist/core/digest/frame-digest-integration.js.map +0 -7
- package/dist/core/digest/hybrid-digest-generator.js +0 -553
- package/dist/core/digest/hybrid-digest-generator.js.map +0 -7
- package/dist/core/digest/index.js +0 -9
- package/dist/core/digest/index.js.map +0 -7
- package/dist/core/digest/types.js +0 -25
- package/dist/core/digest/types.js.map +0 -7
- package/dist/core/errors/error-utils.js +0 -208
- package/dist/core/errors/error-utils.js.map +0 -7
- package/dist/core/errors/index.js +0 -521
- package/dist/core/errors/index.js.map +0 -7
- package/dist/core/errors/recovery.js +0 -269
- package/dist/core/errors/recovery.js.map +0 -7
- package/dist/core/execution/parallel-executor.js +0 -258
- package/dist/core/execution/parallel-executor.js.map +0 -7
- package/dist/core/frame/workflow-templates.js +0 -319
- package/dist/core/frame/workflow-templates.js.map +0 -7
- package/dist/core/merge/conflict-detector.js +0 -431
- package/dist/core/merge/conflict-detector.js.map +0 -7
- package/dist/core/merge/index.js +0 -9
- package/dist/core/merge/index.js.map +0 -7
- package/dist/core/merge/resolution-engine.js +0 -558
- package/dist/core/merge/resolution-engine.js.map +0 -7
- package/dist/core/merge/stack-diff.js +0 -532
- package/dist/core/merge/stack-diff.js.map +0 -7
- package/dist/core/merge/unified-merge-resolver.js +0 -303
- package/dist/core/merge/unified-merge-resolver.js.map +0 -7
- package/dist/core/models/fallback-monitor.js +0 -232
- package/dist/core/models/fallback-monitor.js.map +0 -7
- package/dist/core/models/model-router.js +0 -340
- package/dist/core/models/model-router.js.map +0 -7
- package/dist/core/monitoring/error-handler.js +0 -49
- package/dist/core/monitoring/error-handler.js.map +0 -7
- package/dist/core/monitoring/logger.js +0 -202
- package/dist/core/monitoring/logger.js.map +0 -7
- package/dist/core/monitoring/metrics.js +0 -172
- package/dist/core/monitoring/metrics.js.map +0 -7
- package/dist/core/monitoring/progress-tracker.js +0 -189
- package/dist/core/monitoring/progress-tracker.js.map +0 -7
- package/dist/core/monitoring/session-monitor.js +0 -300
- package/dist/core/monitoring/session-monitor.js.map +0 -7
- package/dist/core/performance/context-cache.js +0 -273
- package/dist/core/performance/context-cache.js.map +0 -7
- package/dist/core/performance/index.js +0 -11
- package/dist/core/performance/index.js.map +0 -7
- package/dist/core/performance/lazy-context-loader.js +0 -327
- package/dist/core/performance/lazy-context-loader.js.map +0 -7
- package/dist/core/performance/monitor.js +0 -221
- package/dist/core/performance/monitor.js.map +0 -7
- package/dist/core/performance/optimized-frame-context.js +0 -345
- package/dist/core/performance/optimized-frame-context.js.map +0 -7
- package/dist/core/performance/performance-benchmark.js +0 -277
- package/dist/core/performance/performance-benchmark.js.map +0 -7
- package/dist/core/performance/performance-profiler.js +0 -370
- package/dist/core/performance/performance-profiler.js.map +0 -7
- package/dist/core/performance/streaming-jsonl-parser.js +0 -195
- package/dist/core/performance/streaming-jsonl-parser.js.map +0 -7
- package/dist/core/persistence/postgres-adapter.js +0 -349
- package/dist/core/persistence/postgres-adapter.js.map +0 -7
- package/dist/core/projects/project-isolation.js +0 -201
- package/dist/core/projects/project-isolation.js.map +0 -7
- package/dist/core/projects/project-manager.js +0 -697
- package/dist/core/projects/project-manager.js.map +0 -7
- package/dist/core/query/query-parser.js +0 -370
- package/dist/core/query/query-parser.js.map +0 -7
- package/dist/core/query/query-templates.js +0 -321
- package/dist/core/query/query-templates.js.map +0 -7
- package/dist/core/retrieval/context-retriever.js +0 -479
- package/dist/core/retrieval/context-retriever.js.map +0 -7
- package/dist/core/retrieval/graph-retrieval.js +0 -662
- package/dist/core/retrieval/graph-retrieval.js.map +0 -7
- package/dist/core/retrieval/hierarchical-retrieval.js +0 -656
- package/dist/core/retrieval/hierarchical-retrieval.js.map +0 -7
- package/dist/core/retrieval/index.js +0 -8
- package/dist/core/retrieval/index.js.map +0 -7
- package/dist/core/retrieval/llm-context-retrieval.js +0 -613
- package/dist/core/retrieval/llm-context-retrieval.js.map +0 -7
- package/dist/core/retrieval/llm-provider.js +0 -151
- package/dist/core/retrieval/llm-provider.js.map +0 -7
- package/dist/core/retrieval/retrieval-audit.js +0 -236
- package/dist/core/retrieval/retrieval-audit.js.map +0 -7
- package/dist/core/retrieval/retrieval-benchmarks.js +0 -521
- package/dist/core/retrieval/retrieval-benchmarks.js.map +0 -7
- package/dist/core/retrieval/summary-generator.js +0 -589
- package/dist/core/retrieval/summary-generator.js.map +0 -7
- package/dist/core/retrieval/types.js +0 -21
- package/dist/core/retrieval/types.js.map +0 -7
- package/dist/core/security/index.js +0 -35
- package/dist/core/security/index.js.map +0 -7
- package/dist/core/security/input-sanitizer.js +0 -321
- package/dist/core/security/input-sanitizer.js.map +0 -7
- package/dist/core/session/clear-survival.js +0 -465
- package/dist/core/session/clear-survival.js.map +0 -7
- package/dist/core/session/enhanced-handoff.js +0 -792
- package/dist/core/session/enhanced-handoff.js.map +0 -7
- package/dist/core/session/handoff-generator.js +0 -343
- package/dist/core/session/handoff-generator.js.map +0 -7
- package/dist/core/session/index.js +0 -15
- package/dist/core/session/index.js.map +0 -7
- package/dist/core/session/session-manager.js +0 -347
- package/dist/core/session/session-manager.js.map +0 -7
- package/dist/core/skills/index.js +0 -7
- package/dist/core/skills/index.js.map +0 -7
- package/dist/core/skills/skill-storage.js +0 -764
- package/dist/core/skills/skill-storage.js.map +0 -7
- package/dist/core/skills/types.js +0 -193
- package/dist/core/skills/types.js.map +0 -7
- package/dist/core/storage/chromadb-adapter.js +0 -354
- package/dist/core/storage/chromadb-adapter.js.map +0 -7
- package/dist/core/storage/infinite-storage.js +0 -510
- package/dist/core/storage/infinite-storage.js.map +0 -7
- package/dist/core/storage/railway-optimized-storage.js +0 -591
- package/dist/core/storage/railway-optimized-storage.js.map +0 -7
- package/dist/core/storage/remote-storage.js +0 -489
- package/dist/core/storage/remote-storage.js.map +0 -7
- package/dist/core/storage/two-tier-storage.js +0 -766
- package/dist/core/storage/two-tier-storage.js.map +0 -7
- package/dist/core/trace/cli-trace-wrapper.js +0 -132
- package/dist/core/trace/cli-trace-wrapper.js.map +0 -7
- package/dist/core/trace/db-trace-wrapper.js +0 -247
- package/dist/core/trace/db-trace-wrapper.js.map +0 -7
- package/dist/core/trace/debug-trace.js +0 -417
- package/dist/core/trace/debug-trace.js.map +0 -7
- package/dist/core/trace/index.js +0 -109
- package/dist/core/trace/index.js.map +0 -7
- package/dist/core/trace/linear-api-wrapper.js +0 -178
- package/dist/core/trace/linear-api-wrapper.js.map +0 -7
- package/dist/core/trace/trace-demo.js +0 -154
- package/dist/core/trace/trace-demo.js.map +0 -7
- package/dist/core/trace/trace-detector.demo.js +0 -142
- package/dist/core/trace/trace-detector.demo.js.map +0 -7
- package/dist/core/trace/trace-detector.js +0 -528
- package/dist/core/trace/trace-detector.js.map +0 -7
- package/dist/core/trace/trace-store.js +0 -345
- package/dist/core/trace/trace-store.js.map +0 -7
- package/dist/core/trace/types.js +0 -77
- package/dist/core/trace/types.js.map +0 -7
- package/dist/core/types.js +0 -5
- package/dist/core/types.js.map +0 -7
- package/dist/core/utils/async-mutex.js +0 -114
- package/dist/core/utils/async-mutex.js.map +0 -7
- package/dist/core/utils/compression.js +0 -83
- package/dist/core/utils/compression.js.map +0 -7
- package/dist/core/utils/update-checker.js +0 -218
- package/dist/core/utils/update-checker.js.map +0 -7
- package/dist/core/worktree/worktree-manager.js +0 -465
- package/dist/core/worktree/worktree-manager.js.map +0 -7
- package/dist/daemon/daemon-config.js +0 -149
- package/dist/daemon/daemon-config.js.map +0 -7
- package/dist/daemon/services/context-service.js +0 -122
- package/dist/daemon/services/context-service.js.map +0 -7
- package/dist/daemon/services/linear-service.js +0 -136
- package/dist/daemon/services/linear-service.js.map +0 -7
- package/dist/daemon/session-daemon.js +0 -312
- package/dist/daemon/session-daemon.js.map +0 -7
- package/dist/daemon/unified-daemon.js +0 -276
- package/dist/daemon/unified-daemon.js.map +0 -7
- package/dist/features/analytics/api/analytics-api.js +0 -287
- package/dist/features/analytics/api/analytics-api.js.map +0 -7
- package/dist/features/analytics/core/analytics-service.js +0 -282
- package/dist/features/analytics/core/analytics-service.js.map +0 -7
- package/dist/features/analytics/index.js +0 -18
- package/dist/features/analytics/index.js.map +0 -7
- package/dist/features/analytics/queries/metrics-queries.js +0 -277
- package/dist/features/analytics/queries/metrics-queries.js.map +0 -7
- package/dist/features/analytics/types/metrics.js +0 -5
- package/dist/features/analytics/types/metrics.js.map +0 -7
- package/dist/features/browser/browser-mcp.js +0 -492
- package/dist/features/browser/browser-mcp.js.map +0 -7
- package/dist/features/sweep/index.js +0 -20
- package/dist/features/sweep/index.js.map +0 -7
- package/dist/features/sweep/prediction-client.js +0 -155
- package/dist/features/sweep/prediction-client.js.map +0 -7
- package/dist/features/sweep/prompt-builder.js +0 -85
- package/dist/features/sweep/prompt-builder.js.map +0 -7
- package/dist/features/sweep/pty-wrapper.js +0 -171
- package/dist/features/sweep/pty-wrapper.js.map +0 -7
- package/dist/features/sweep/state-watcher.js +0 -87
- package/dist/features/sweep/state-watcher.js.map +0 -7
- package/dist/features/sweep/status-bar.js +0 -88
- package/dist/features/sweep/status-bar.js.map +0 -7
- package/dist/features/sweep/sweep-server-manager.js +0 -226
- package/dist/features/sweep/sweep-server-manager.js.map +0 -7
- package/dist/features/sweep/tab-interceptor.js +0 -38
- package/dist/features/sweep/tab-interceptor.js.map +0 -7
- package/dist/features/sweep/types.js +0 -18
- package/dist/features/sweep/types.js.map +0 -7
- package/dist/features/tasks/linear-task-manager.js +0 -487
- package/dist/features/tasks/linear-task-manager.js.map +0 -7
- package/dist/features/tasks/task-aware-context.js +0 -410
- package/dist/features/tasks/task-aware-context.js.map +0 -7
- package/dist/features/tui/simple-monitor.js +0 -116
- package/dist/features/tui/simple-monitor.js.map +0 -7
- package/dist/features/tui/swarm-monitor.js +0 -648
- package/dist/features/tui/swarm-monitor.js.map +0 -7
- package/dist/features/web/client/stores/task-store.js +0 -26
- package/dist/features/web/client/stores/task-store.js.map +0 -7
- package/dist/features/web/server/index.js +0 -194
- package/dist/features/web/server/index.js.map +0 -7
- package/dist/hooks/auto-background.js +0 -151
- package/dist/hooks/auto-background.js.map +0 -7
- package/dist/hooks/claude-code-whatsapp-hook.js +0 -197
- package/dist/hooks/claude-code-whatsapp-hook.js.map +0 -7
- package/dist/hooks/config.js +0 -150
- package/dist/hooks/config.js.map +0 -7
- package/dist/hooks/daemon.js +0 -364
- package/dist/hooks/daemon.js.map +0 -7
- package/dist/hooks/events.js +0 -58
- package/dist/hooks/events.js.map +0 -7
- package/dist/hooks/index.js +0 -12
- package/dist/hooks/index.js.map +0 -7
- package/dist/hooks/linear-task-picker.js +0 -186
- package/dist/hooks/linear-task-picker.js.map +0 -7
- package/dist/hooks/schemas.js +0 -197
- package/dist/hooks/schemas.js.map +0 -7
- package/dist/hooks/secure-fs.js +0 -49
- package/dist/hooks/secure-fs.js.map +0 -7
- package/dist/hooks/security-logger.js +0 -155
- package/dist/hooks/security-logger.js.map +0 -7
- package/dist/hooks/session-summary.js +0 -222
- package/dist/hooks/session-summary.js.map +0 -7
- package/dist/hooks/sms-action-runner.js +0 -371
- package/dist/hooks/sms-action-runner.js.map +0 -7
- package/dist/hooks/sms-notify.js +0 -506
- package/dist/hooks/sms-notify.js.map +0 -7
- package/dist/hooks/sms-watcher.js +0 -93
- package/dist/hooks/sms-watcher.js.map +0 -7
- package/dist/hooks/sms-webhook.js +0 -555
- package/dist/hooks/sms-webhook.js.map +0 -7
- package/dist/hooks/whatsapp-commands.js +0 -479
- package/dist/hooks/whatsapp-commands.js.map +0 -7
- package/dist/hooks/whatsapp-scheduler.js +0 -317
- package/dist/hooks/whatsapp-scheduler.js.map +0 -7
- package/dist/hooks/whatsapp-sync.js +0 -409
- package/dist/hooks/whatsapp-sync.js.map +0 -7
- package/dist/index.js +0 -25
- package/dist/index.js.map +0 -7
- package/dist/integrations/anthropic/client.js +0 -263
- package/dist/integrations/anthropic/client.js.map +0 -7
- package/dist/integrations/claude-code/agent-bridge.js +0 -768
- package/dist/integrations/claude-code/agent-bridge.js.map +0 -7
- package/dist/integrations/claude-code/enhanced-pre-clear-hooks.js +0 -459
- package/dist/integrations/claude-code/enhanced-pre-clear-hooks.js.map +0 -7
- package/dist/integrations/claude-code/lifecycle-hooks.js +0 -254
- package/dist/integrations/claude-code/lifecycle-hooks.js.map +0 -7
- package/dist/integrations/claude-code/post-task-hooks.js +0 -545
- package/dist/integrations/claude-code/post-task-hooks.js.map +0 -7
- package/dist/integrations/claude-code/subagent-client-stub.js +0 -20
- package/dist/integrations/claude-code/subagent-client-stub.js.map +0 -7
- package/dist/integrations/claude-code/subagent-client.js +0 -511
- package/dist/integrations/claude-code/subagent-client.js.map +0 -7
- package/dist/integrations/claude-code/task-coordinator.js +0 -360
- package/dist/integrations/claude-code/task-coordinator.js.map +0 -7
- package/dist/integrations/linear/auth.js +0 -337
- package/dist/integrations/linear/auth.js.map +0 -7
- package/dist/integrations/linear/auto-sync.js +0 -258
- package/dist/integrations/linear/auto-sync.js.map +0 -7
- package/dist/integrations/linear/client.js +0 -634
- package/dist/integrations/linear/client.js.map +0 -7
- package/dist/integrations/linear/config.js +0 -130
- package/dist/integrations/linear/config.js.map +0 -7
- package/dist/integrations/linear/migration.js +0 -361
- package/dist/integrations/linear/migration.js.map +0 -7
- package/dist/integrations/linear/oauth-server.js +0 -454
- package/dist/integrations/linear/oauth-server.js.map +0 -7
- package/dist/integrations/linear/rest-client.js +0 -213
- package/dist/integrations/linear/rest-client.js.map +0 -7
- package/dist/integrations/linear/sync-manager.js +0 -236
- package/dist/integrations/linear/sync-manager.js.map +0 -7
- package/dist/integrations/linear/sync-service.js +0 -231
- package/dist/integrations/linear/sync-service.js.map +0 -7
- package/dist/integrations/linear/sync.js +0 -782
- package/dist/integrations/linear/sync.js.map +0 -7
- package/dist/integrations/linear/types.js +0 -5
- package/dist/integrations/linear/types.js.map +0 -7
- package/dist/integrations/linear/unified-sync.js +0 -589
- package/dist/integrations/linear/unified-sync.js.map +0 -7
- package/dist/integrations/linear/webhook-handler.js +0 -219
- package/dist/integrations/linear/webhook-handler.js.map +0 -7
- package/dist/integrations/linear/webhook-server.js +0 -218
- package/dist/integrations/linear/webhook-server.js.map +0 -7
- package/dist/integrations/linear/webhook.js +0 -291
- package/dist/integrations/linear/webhook.js.map +0 -7
- package/dist/integrations/mcp/handlers/code-execution-handlers.js +0 -266
- package/dist/integrations/mcp/handlers/code-execution-handlers.js.map +0 -7
- package/dist/integrations/mcp/handlers/context-handlers.js +0 -257
- package/dist/integrations/mcp/handlers/context-handlers.js.map +0 -7
- package/dist/integrations/mcp/handlers/discovery-handlers.js +0 -497
- package/dist/integrations/mcp/handlers/discovery-handlers.js.map +0 -7
- package/dist/integrations/mcp/handlers/index.js +0 -166
- package/dist/integrations/mcp/handlers/index.js.map +0 -7
- package/dist/integrations/mcp/handlers/linear-handlers.js +0 -247
- package/dist/integrations/mcp/handlers/linear-handlers.js.map +0 -7
- package/dist/integrations/mcp/handlers/skill-handlers.js +0 -529
- package/dist/integrations/mcp/handlers/skill-handlers.js.map +0 -7
- package/dist/integrations/mcp/handlers/task-handlers.js +0 -239
- package/dist/integrations/mcp/handlers/task-handlers.js.map +0 -7
- package/dist/integrations/mcp/handlers/trace-handlers.js +0 -308
- package/dist/integrations/mcp/handlers/trace-handlers.js.map +0 -7
- package/dist/integrations/mcp/index.js +0 -23
- package/dist/integrations/mcp/index.js.map +0 -7
- package/dist/integrations/mcp/middleware/tool-scoring.js +0 -356
- package/dist/integrations/mcp/middleware/tool-scoring.js.map +0 -7
- package/dist/integrations/mcp/refactored-server.js +0 -374
- package/dist/integrations/mcp/refactored-server.js.map +0 -7
- package/dist/integrations/mcp/remote-server.js +0 -682
- package/dist/integrations/mcp/remote-server.js.map +0 -7
- package/dist/integrations/mcp/schemas.js +0 -147
- package/dist/integrations/mcp/schemas.js.map +0 -7
- package/dist/integrations/mcp/server.js +0 -1975
- package/dist/integrations/mcp/server.js.map +0 -7
- package/dist/integrations/mcp/tool-definitions-code.js +0 -125
- package/dist/integrations/mcp/tool-definitions-code.js.map +0 -7
- package/dist/integrations/mcp/tool-definitions.js +0 -702
- package/dist/integrations/mcp/tool-definitions.js.map +0 -7
- package/dist/integrations/mcp/trace-test.js +0 -48
- package/dist/integrations/mcp/trace-test.js.map +0 -7
- package/dist/integrations/pg-aiguide/embedding-provider.js +0 -189
- package/dist/integrations/pg-aiguide/embedding-provider.js.map +0 -7
- package/dist/integrations/pg-aiguide/semantic-search.js +0 -187
- package/dist/integrations/pg-aiguide/semantic-search.js.map +0 -7
- package/dist/integrations/pg-aiguide/timescale-analytics.js +0 -224
- package/dist/integrations/pg-aiguide/timescale-analytics.js.map +0 -7
- package/dist/integrations/ralph/bridge/ralph-stackmemory-bridge.js +0 -860
- package/dist/integrations/ralph/bridge/ralph-stackmemory-bridge.js.map +0 -7
- package/dist/integrations/ralph/context/context-budget-manager.js +0 -301
- package/dist/integrations/ralph/context/context-budget-manager.js.map +0 -7
- package/dist/integrations/ralph/context/stackmemory-context-loader.js +0 -360
- package/dist/integrations/ralph/context/stackmemory-context-loader.js.map +0 -7
- package/dist/integrations/ralph/coordination/enhanced-coordination.js +0 -410
- package/dist/integrations/ralph/coordination/enhanced-coordination.js.map +0 -7
- package/dist/integrations/ralph/index.js +0 -18
- package/dist/integrations/ralph/index.js.map +0 -7
- package/dist/integrations/ralph/learning/pattern-learner.js +0 -401
- package/dist/integrations/ralph/learning/pattern-learner.js.map +0 -7
- package/dist/integrations/ralph/lifecycle/iteration-lifecycle.js +0 -448
- package/dist/integrations/ralph/lifecycle/iteration-lifecycle.js.map +0 -7
- package/dist/integrations/ralph/monitoring/swarm-dashboard.js +0 -294
- package/dist/integrations/ralph/monitoring/swarm-dashboard.js.map +0 -7
- package/dist/integrations/ralph/monitoring/swarm-registry.js +0 -108
- package/dist/integrations/ralph/monitoring/swarm-registry.js.map +0 -7
- package/dist/integrations/ralph/orchestration/multi-loop-orchestrator.js +0 -463
- package/dist/integrations/ralph/orchestration/multi-loop-orchestrator.js.map +0 -7
- package/dist/integrations/ralph/patterns/compounding-engineering-pattern.js +0 -400
- package/dist/integrations/ralph/patterns/compounding-engineering-pattern.js.map +0 -7
- package/dist/integrations/ralph/patterns/extended-coherence-sessions.js +0 -473
- package/dist/integrations/ralph/patterns/extended-coherence-sessions.js.map +0 -7
- package/dist/integrations/ralph/patterns/oracle-worker-pattern.js +0 -388
- package/dist/integrations/ralph/patterns/oracle-worker-pattern.js.map +0 -7
- package/dist/integrations/ralph/performance/performance-optimizer.js +0 -358
- package/dist/integrations/ralph/performance/performance-optimizer.js.map +0 -7
- package/dist/integrations/ralph/ralph-integration-demo.js +0 -182
- package/dist/integrations/ralph/ralph-integration-demo.js.map +0 -7
- package/dist/integrations/ralph/recovery/crash-recovery.js +0 -462
- package/dist/integrations/ralph/recovery/crash-recovery.js.map +0 -7
- package/dist/integrations/ralph/state/state-reconciler.js +0 -404
- package/dist/integrations/ralph/state/state-reconciler.js.map +0 -7
- package/dist/integrations/ralph/swarm/git-workflow-manager.js +0 -428
- package/dist/integrations/ralph/swarm/git-workflow-manager.js.map +0 -7
- package/dist/integrations/ralph/swarm/swarm-coordinator.js +0 -996
- package/dist/integrations/ralph/swarm/swarm-coordinator.js.map +0 -7
- package/dist/integrations/ralph/types.js +0 -5
- package/dist/integrations/ralph/types.js.map +0 -7
- package/dist/integrations/ralph/visualization/ralph-debugger.js +0 -585
- package/dist/integrations/ralph/visualization/ralph-debugger.js.map +0 -7
- package/dist/mcp/stackmemory-mcp-server.js +0 -554
- package/dist/mcp/stackmemory-mcp-server.js.map +0 -7
- package/dist/middleware/exponential-rate-limiter.js +0 -289
- package/dist/middleware/exponential-rate-limiter.js.map +0 -7
- package/dist/models/user.model.js +0 -358
- package/dist/models/user.model.js.map +0 -7
- package/dist/servers/production/auth-middleware.js +0 -528
- package/dist/servers/production/auth-middleware.js.map +0 -7
- package/dist/servers/railway/config.js +0 -55
- package/dist/servers/railway/config.js.map +0 -7
- package/dist/servers/railway/index-enhanced.js +0 -160
- package/dist/servers/railway/index-enhanced.js.map +0 -7
- package/dist/servers/railway/index.js +0 -1349
- package/dist/servers/railway/index.js.map +0 -7
- package/dist/servers/railway/simple.js +0 -64
- package/dist/servers/railway/simple.js.map +0 -7
- package/dist/servers/railway/storage-test.js +0 -459
- package/dist/servers/railway/storage-test.js.map +0 -7
- package/dist/services/config-service.js +0 -65
- package/dist/services/config-service.js.map +0 -7
- package/dist/services/context-service.js +0 -194
- package/dist/services/context-service.js.map +0 -7
- package/dist/skills/api-discovery.js +0 -354
- package/dist/skills/api-discovery.js.map +0 -7
- package/dist/skills/api-skill.js +0 -475
- package/dist/skills/api-skill.js.map +0 -7
- package/dist/skills/claude-skills.js +0 -1061
- package/dist/skills/claude-skills.js.map +0 -7
- package/dist/skills/dashboard-launcher.js +0 -216
- package/dist/skills/dashboard-launcher.js.map +0 -7
- package/dist/skills/recursive-agent-orchestrator.js +0 -575
- package/dist/skills/recursive-agent-orchestrator.js.map +0 -7
- package/dist/skills/repo-ingestion-skill.js +0 -609
- package/dist/skills/repo-ingestion-skill.js.map +0 -7
- package/dist/skills/security-secrets-scanner.js +0 -284
- package/dist/skills/security-secrets-scanner.js.map +0 -7
- package/dist/skills/unified-rlm-orchestrator.js +0 -404
- package/dist/skills/unified-rlm-orchestrator.js.map +0 -7
- package/dist/types/task.js +0 -5
- package/dist/types/task.js.map +0 -7
- package/dist/utils/env.js +0 -50
- package/dist/utils/env.js.map +0 -7
- package/dist/utils/formatting.js +0 -62
- package/dist/utils/formatting.js.map +0 -7
- package/dist/utils/process-cleanup.js +0 -136
- package/dist/utils/process-cleanup.js.map +0 -7
- package/dist/validation/schemas.js +0 -222
- package/dist/validation/schemas.js.map +0 -7
- /package/dist/{core/merge → src/core/extensions}/types.js +0 -0
- /package/dist/{core/merge → src/core/extensions}/types.js.map +0 -0
|
@@ -1,778 +0,0 @@
|
|
|
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 { logger } from "../monitoring/logger.js";
|
|
6
|
-
import { ValidationError, DatabaseError, ErrorCode } from "../errors/index.js";
|
|
7
|
-
import {
|
|
8
|
-
validateInput,
|
|
9
|
-
InitiateHandoffSchema,
|
|
10
|
-
HandoffApprovalSchema
|
|
11
|
-
} from "./validation.js";
|
|
12
|
-
class FrameHandoffManager {
|
|
13
|
-
dualStackManager;
|
|
14
|
-
activeHandoffs = /* @__PURE__ */ new Map();
|
|
15
|
-
pendingApprovals = /* @__PURE__ */ new Map();
|
|
16
|
-
notifications = /* @__PURE__ */ new Map();
|
|
17
|
-
constructor(dualStackManager) {
|
|
18
|
-
this.dualStackManager = dualStackManager;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Initiate a frame handoff with rich metadata and approval workflow
|
|
22
|
-
*/
|
|
23
|
-
async initiateHandoff(targetStackId, frameIds, metadata, targetUserId, message) {
|
|
24
|
-
const input = validateInput(InitiateHandoffSchema, {
|
|
25
|
-
targetStackId,
|
|
26
|
-
frameIds,
|
|
27
|
-
handoffRequest: metadata,
|
|
28
|
-
reviewerId: targetUserId,
|
|
29
|
-
description: message
|
|
30
|
-
});
|
|
31
|
-
try {
|
|
32
|
-
await this.dualStackManager.getPermissionManager().enforcePermission(
|
|
33
|
-
this.dualStackManager.getPermissionManager().createContext(
|
|
34
|
-
input.handoffRequest.initiatorId,
|
|
35
|
-
"handoff",
|
|
36
|
-
"handoff",
|
|
37
|
-
input.targetStackId
|
|
38
|
-
)
|
|
39
|
-
);
|
|
40
|
-
await this.validateFramesForHandoff(input.frameIds);
|
|
41
|
-
const requestId = await this.dualStackManager.initiateHandoff(
|
|
42
|
-
input.targetStackId,
|
|
43
|
-
input.frameIds,
|
|
44
|
-
input.reviewerId,
|
|
45
|
-
input.description
|
|
46
|
-
);
|
|
47
|
-
const progress = {
|
|
48
|
-
requestId,
|
|
49
|
-
status: "pending_review",
|
|
50
|
-
transferredFrames: 0,
|
|
51
|
-
totalFrames: input.frameIds.length,
|
|
52
|
-
currentStep: "Awaiting approval",
|
|
53
|
-
errors: []
|
|
54
|
-
};
|
|
55
|
-
this.activeHandoffs.set(requestId, progress);
|
|
56
|
-
await this.createHandoffNotifications(requestId, metadata, targetUserId);
|
|
57
|
-
await this.scheduleHandoffReminders(requestId, metadata);
|
|
58
|
-
logger.info(`Initiated enhanced handoff: ${requestId}`, {
|
|
59
|
-
frameCount: frameIds.length,
|
|
60
|
-
priority: metadata.businessContext?.priority,
|
|
61
|
-
targetUser: targetUserId
|
|
62
|
-
});
|
|
63
|
-
return requestId;
|
|
64
|
-
} catch (error) {
|
|
65
|
-
throw new DatabaseError(
|
|
66
|
-
"Failed to initiate handoff",
|
|
67
|
-
ErrorCode.OPERATION_FAILED,
|
|
68
|
-
{ targetStackId, frameIds },
|
|
69
|
-
error instanceof Error ? error : void 0
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Submit approval/rejection for handoff request
|
|
75
|
-
*/
|
|
76
|
-
async submitHandoffApproval(requestId, approval) {
|
|
77
|
-
const input = validateInput(HandoffApprovalSchema, {
|
|
78
|
-
...approval,
|
|
79
|
-
reviewerId: approval.reviewerId
|
|
80
|
-
});
|
|
81
|
-
const progress = this.activeHandoffs.get(requestId);
|
|
82
|
-
if (!progress) {
|
|
83
|
-
throw new ValidationError(
|
|
84
|
-
`Handoff request not found: ${requestId}`,
|
|
85
|
-
ErrorCode.HANDOFF_REQUEST_EXPIRED
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
const fullApproval = {
|
|
89
|
-
...input,
|
|
90
|
-
requestId,
|
|
91
|
-
reviewedAt: /* @__PURE__ */ new Date()
|
|
92
|
-
};
|
|
93
|
-
const existingApprovals = this.pendingApprovals.get(requestId) || [];
|
|
94
|
-
existingApprovals.push(fullApproval);
|
|
95
|
-
this.pendingApprovals.set(requestId, existingApprovals);
|
|
96
|
-
if (input.decision === "approved") {
|
|
97
|
-
progress.status = "approved";
|
|
98
|
-
progress.currentStep = "Ready for transfer";
|
|
99
|
-
await this.executeHandoffTransfer(requestId);
|
|
100
|
-
} else if (input.decision === "rejected") {
|
|
101
|
-
progress.status = "failed";
|
|
102
|
-
progress.currentStep = "Rejected by reviewer";
|
|
103
|
-
progress.errors.push({
|
|
104
|
-
step: "approval",
|
|
105
|
-
error: input.feedback || "Request rejected",
|
|
106
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
107
|
-
});
|
|
108
|
-
} else if (input.decision === "needs_changes") {
|
|
109
|
-
progress.status = "pending_review";
|
|
110
|
-
progress.currentStep = "Changes requested";
|
|
111
|
-
await this.notifyChangesRequested(requestId, approval);
|
|
112
|
-
}
|
|
113
|
-
this.activeHandoffs.set(requestId, progress);
|
|
114
|
-
logger.info(`Handoff approval submitted: ${requestId}`, {
|
|
115
|
-
decision: approval.decision,
|
|
116
|
-
reviewer: approval.reviewerId
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Execute the actual frame transfer after approval
|
|
121
|
-
*/
|
|
122
|
-
async executeHandoffTransfer(requestId) {
|
|
123
|
-
logger.debug("executeHandoffTransfer called", {
|
|
124
|
-
requestId,
|
|
125
|
-
availableHandoffs: Array.from(this.activeHandoffs.keys())
|
|
126
|
-
});
|
|
127
|
-
const progress = this.activeHandoffs.get(requestId);
|
|
128
|
-
if (!progress) {
|
|
129
|
-
logger.error("Handoff progress not found", {
|
|
130
|
-
requestId,
|
|
131
|
-
availableHandoffs: Array.from(this.activeHandoffs.keys())
|
|
132
|
-
});
|
|
133
|
-
throw new DatabaseError(
|
|
134
|
-
`Handoff progress not found: ${requestId}`,
|
|
135
|
-
ErrorCode.INVALID_STATE
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
try {
|
|
139
|
-
logger.debug("Setting progress status to in_transfer", { requestId });
|
|
140
|
-
progress.status = "in_transfer";
|
|
141
|
-
progress.currentStep = "Transferring frames";
|
|
142
|
-
progress.estimatedCompletion = new Date(Date.now() + 5 * 60 * 1e3);
|
|
143
|
-
logger.debug("About to call acceptHandoff", { requestId });
|
|
144
|
-
const result = await this.dualStackManager.acceptHandoff(requestId);
|
|
145
|
-
logger.debug("acceptHandoff returned", {
|
|
146
|
-
requestId,
|
|
147
|
-
success: result.success
|
|
148
|
-
});
|
|
149
|
-
if (result.success) {
|
|
150
|
-
progress.status = "completed";
|
|
151
|
-
progress.currentStep = "Transfer completed";
|
|
152
|
-
progress.transferredFrames = result.mergedFrames.length;
|
|
153
|
-
await this.notifyHandoffCompletion(requestId, result);
|
|
154
|
-
logger.info(`Handoff transfer completed: ${requestId}`, {
|
|
155
|
-
transferredFrames: progress.transferredFrames,
|
|
156
|
-
conflicts: result.conflictFrames.length
|
|
157
|
-
});
|
|
158
|
-
} else {
|
|
159
|
-
progress.status = "failed";
|
|
160
|
-
progress.currentStep = "Transfer failed";
|
|
161
|
-
result.errors.forEach((error) => {
|
|
162
|
-
progress.errors.push({
|
|
163
|
-
step: "transfer",
|
|
164
|
-
error: `Frame ${error.frameId}: ${error.error}`,
|
|
165
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
throw new DatabaseError(
|
|
169
|
-
"Handoff transfer failed",
|
|
170
|
-
ErrorCode.OPERATION_FAILED,
|
|
171
|
-
{ errors: result.errors }
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
} catch (error) {
|
|
175
|
-
progress.status = "failed";
|
|
176
|
-
progress.currentStep = "Transfer error";
|
|
177
|
-
progress.errors.push({
|
|
178
|
-
step: "transfer",
|
|
179
|
-
error: error instanceof Error ? error.message : String(error),
|
|
180
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
181
|
-
});
|
|
182
|
-
logger.error(`Handoff transfer failed: ${requestId}`, error);
|
|
183
|
-
throw error;
|
|
184
|
-
} finally {
|
|
185
|
-
this.activeHandoffs.set(requestId, progress);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Get handoff progress and status
|
|
190
|
-
*/
|
|
191
|
-
async getHandoffProgress(requestId) {
|
|
192
|
-
return this.activeHandoffs.get(requestId) || null;
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Cancel a pending handoff request
|
|
196
|
-
*/
|
|
197
|
-
async cancelHandoff(requestId, reason) {
|
|
198
|
-
const progress = this.activeHandoffs.get(requestId);
|
|
199
|
-
if (!progress) {
|
|
200
|
-
throw new DatabaseError(
|
|
201
|
-
`Handoff request not found: ${requestId}`,
|
|
202
|
-
ErrorCode.RESOURCE_NOT_FOUND
|
|
203
|
-
);
|
|
204
|
-
}
|
|
205
|
-
if (progress.status === "in_transfer") {
|
|
206
|
-
throw new DatabaseError(
|
|
207
|
-
"Cannot cancel handoff that is currently transferring",
|
|
208
|
-
ErrorCode.INVALID_STATE
|
|
209
|
-
);
|
|
210
|
-
}
|
|
211
|
-
progress.status = "cancelled";
|
|
212
|
-
progress.currentStep = "Cancelled by user";
|
|
213
|
-
progress.errors.push({
|
|
214
|
-
step: "cancellation",
|
|
215
|
-
error: reason,
|
|
216
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
217
|
-
});
|
|
218
|
-
this.activeHandoffs.set(requestId, progress);
|
|
219
|
-
await this.notifyHandoffCancellation(requestId, reason);
|
|
220
|
-
logger.info(`Handoff cancelled: ${requestId}`, { reason });
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Get all active handoffs for a user or team
|
|
224
|
-
*/
|
|
225
|
-
async getActiveHandoffs(userId, teamId) {
|
|
226
|
-
const handoffs = Array.from(this.activeHandoffs.values());
|
|
227
|
-
if (userId || teamId) {
|
|
228
|
-
return handoffs.filter(
|
|
229
|
-
(handoff) => handoff.status === "pending_review" || handoff.status === "approved" || handoff.status === "in_transfer"
|
|
230
|
-
);
|
|
231
|
-
}
|
|
232
|
-
return handoffs;
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Get notifications for a user
|
|
236
|
-
*/
|
|
237
|
-
async getUserNotifications(userId) {
|
|
238
|
-
return this.notifications.get(userId) || [];
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Mark notification as read
|
|
242
|
-
*/
|
|
243
|
-
async markNotificationRead(notificationId, userId) {
|
|
244
|
-
const userNotifications = this.notifications.get(userId) || [];
|
|
245
|
-
const updatedNotifications = userNotifications.filter(
|
|
246
|
-
(n) => n.id !== notificationId
|
|
247
|
-
);
|
|
248
|
-
this.notifications.set(userId, updatedNotifications);
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Validate frames are suitable for handoff
|
|
252
|
-
*/
|
|
253
|
-
async validateFramesForHandoff(frameIds) {
|
|
254
|
-
const activeStack = this.dualStackManager.getActiveStack();
|
|
255
|
-
for (const frameId of frameIds) {
|
|
256
|
-
const frame = await activeStack.getFrame(frameId);
|
|
257
|
-
if (!frame) {
|
|
258
|
-
throw new DatabaseError(
|
|
259
|
-
`Frame not found: ${frameId}`,
|
|
260
|
-
ErrorCode.RESOURCE_NOT_FOUND
|
|
261
|
-
);
|
|
262
|
-
}
|
|
263
|
-
if (frame.state === "active") {
|
|
264
|
-
logger.warn(`Transferring active frame: ${frameId}`, {
|
|
265
|
-
frameName: frame.name
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* Create notifications for handoff stakeholders
|
|
272
|
-
*/
|
|
273
|
-
async createHandoffNotifications(requestId, metadata, targetUserId) {
|
|
274
|
-
const notifications = [];
|
|
275
|
-
if (targetUserId) {
|
|
276
|
-
notifications.push({
|
|
277
|
-
id: `${requestId}-target`,
|
|
278
|
-
type: "request",
|
|
279
|
-
requestId,
|
|
280
|
-
recipientId: targetUserId,
|
|
281
|
-
title: "Frame Handoff Request",
|
|
282
|
-
message: `${metadata.initiatorId} wants to transfer ${metadata.frameContext.totalFrames} frames to you`,
|
|
283
|
-
actionRequired: true,
|
|
284
|
-
expiresAt: new Date(Date.now() + 24 * 60 * 60 * 1e3),
|
|
285
|
-
createdAt: /* @__PURE__ */ new Date()
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
if (metadata.businessContext?.stakeholders) {
|
|
289
|
-
for (const stakeholderId of metadata.businessContext.stakeholders) {
|
|
290
|
-
notifications.push({
|
|
291
|
-
id: `${requestId}-stakeholder-${stakeholderId}`,
|
|
292
|
-
type: "request",
|
|
293
|
-
requestId,
|
|
294
|
-
recipientId: stakeholderId,
|
|
295
|
-
title: "Frame Handoff Notification",
|
|
296
|
-
message: `Frame transfer initiated for ${metadata.businessContext?.milestone || "project milestone"}`,
|
|
297
|
-
actionRequired: false,
|
|
298
|
-
createdAt: /* @__PURE__ */ new Date()
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
for (const notification of notifications) {
|
|
303
|
-
const userNotifications = this.notifications.get(notification.recipientId) || [];
|
|
304
|
-
userNotifications.push(notification);
|
|
305
|
-
this.notifications.set(notification.recipientId, userNotifications);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* Schedule reminder notifications
|
|
310
|
-
*/
|
|
311
|
-
async scheduleHandoffReminders(requestId, metadata) {
|
|
312
|
-
if (metadata.businessContext?.priority === "high" || metadata.businessContext?.priority === "critical") {
|
|
313
|
-
setTimeout(
|
|
314
|
-
async () => {
|
|
315
|
-
const progress = this.activeHandoffs.get(requestId);
|
|
316
|
-
if (progress && progress.status === "pending_review") {
|
|
317
|
-
await this.sendHandoffReminder(requestId, metadata);
|
|
318
|
-
}
|
|
319
|
-
},
|
|
320
|
-
4 * 60 * 60 * 1e3
|
|
321
|
-
);
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* Send handoff reminder
|
|
326
|
-
*/
|
|
327
|
-
async sendHandoffReminder(requestId, metadata) {
|
|
328
|
-
const progress = this.activeHandoffs.get(requestId);
|
|
329
|
-
if (!progress || progress.status !== "pending_review") {
|
|
330
|
-
return;
|
|
331
|
-
}
|
|
332
|
-
const reminderNotification = {
|
|
333
|
-
id: `${requestId}-reminder-${Date.now()}`,
|
|
334
|
-
type: "reminder",
|
|
335
|
-
requestId,
|
|
336
|
-
recipientId: metadata.targetUserId || "unknown",
|
|
337
|
-
title: "\u23F0 Handoff Request Reminder",
|
|
338
|
-
message: `Reminder: ${metadata.initiatorId} is waiting for approval on ${metadata.frameContext.totalFrames} frames. Priority: ${metadata.businessContext?.priority || "medium"}`,
|
|
339
|
-
actionRequired: true,
|
|
340
|
-
expiresAt: new Date(Date.now() + 12 * 60 * 60 * 1e3),
|
|
341
|
-
// 12 hours
|
|
342
|
-
createdAt: /* @__PURE__ */ new Date()
|
|
343
|
-
};
|
|
344
|
-
if (metadata.targetUserId) {
|
|
345
|
-
const userNotifications = this.notifications.get(metadata.targetUserId) || [];
|
|
346
|
-
userNotifications.push(reminderNotification);
|
|
347
|
-
this.notifications.set(metadata.targetUserId, userNotifications);
|
|
348
|
-
logger.info(`Sent handoff reminder: ${requestId}`, {
|
|
349
|
-
priority: metadata.businessContext?.priority,
|
|
350
|
-
recipient: metadata.targetUserId
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
if (metadata.businessContext?.stakeholders) {
|
|
354
|
-
for (const stakeholderId of metadata.businessContext.stakeholders) {
|
|
355
|
-
const stakeholderNotification = {
|
|
356
|
-
...reminderNotification,
|
|
357
|
-
id: `${requestId}-reminder-stakeholder-${stakeholderId}-${Date.now()}`,
|
|
358
|
-
recipientId: stakeholderId,
|
|
359
|
-
title: "\u{1F4CB} Handoff Status Update",
|
|
360
|
-
message: `Pending handoff approval: ${metadata.businessContext?.milestone || "development work"} requires attention`,
|
|
361
|
-
actionRequired: false
|
|
362
|
-
};
|
|
363
|
-
const stakeholderNotifications = this.notifications.get(stakeholderId) || [];
|
|
364
|
-
stakeholderNotifications.push(stakeholderNotification);
|
|
365
|
-
this.notifications.set(stakeholderId, stakeholderNotifications);
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
/**
|
|
370
|
-
* Notify when changes are requested
|
|
371
|
-
*/
|
|
372
|
-
async notifyChangesRequested(requestId, approval) {
|
|
373
|
-
const progress = this.activeHandoffs.get(requestId);
|
|
374
|
-
if (!progress) return;
|
|
375
|
-
const changeRequestNotification = {
|
|
376
|
-
id: `${requestId}-changes-${Date.now()}`,
|
|
377
|
-
type: "request",
|
|
378
|
-
requestId,
|
|
379
|
-
recipientId: "requester",
|
|
380
|
-
// TODO: Get actual requester from handoff metadata
|
|
381
|
-
title: "Changes Requested for Handoff",
|
|
382
|
-
message: `${approval.reviewerId} has requested changes: ${approval.feedback || "See detailed suggestions"}`,
|
|
383
|
-
actionRequired: true,
|
|
384
|
-
expiresAt: new Date(Date.now() + 48 * 60 * 60 * 1e3),
|
|
385
|
-
// 48 hours
|
|
386
|
-
createdAt: /* @__PURE__ */ new Date()
|
|
387
|
-
};
|
|
388
|
-
const notifications = this.notifications.get("requester") || [];
|
|
389
|
-
notifications.push(changeRequestNotification);
|
|
390
|
-
this.notifications.set("requester", notifications);
|
|
391
|
-
logger.info(`Changes requested for handoff: ${requestId}`, {
|
|
392
|
-
reviewer: approval.reviewerId,
|
|
393
|
-
feedback: approval.feedback,
|
|
394
|
-
suggestedChangesCount: approval.suggestedChanges?.length || 0
|
|
395
|
-
});
|
|
396
|
-
if (approval.suggestedChanges && approval.suggestedChanges.length > 0) {
|
|
397
|
-
logger.info(`Detailed change suggestions:`, {
|
|
398
|
-
requestId,
|
|
399
|
-
suggestions: approval.suggestedChanges.map((change) => ({
|
|
400
|
-
frameId: change.frameId,
|
|
401
|
-
suggestion: change.suggestion,
|
|
402
|
-
reason: change.reason
|
|
403
|
-
}))
|
|
404
|
-
});
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
/**
|
|
408
|
-
* Notify handoff completion
|
|
409
|
-
*/
|
|
410
|
-
async notifyHandoffCompletion(requestId, result) {
|
|
411
|
-
const progress = this.activeHandoffs.get(requestId);
|
|
412
|
-
if (!progress) return;
|
|
413
|
-
const completionNotification = {
|
|
414
|
-
id: `${requestId}-completion-${Date.now()}`,
|
|
415
|
-
type: "completion",
|
|
416
|
-
requestId,
|
|
417
|
-
recipientId: "all",
|
|
418
|
-
// Will be distributed to all stakeholders
|
|
419
|
-
title: "Handoff Completed Successfully",
|
|
420
|
-
message: `Frame transfer completed: ${result.mergedFrames.length} frames transferred${result.conflictFrames.length > 0 ? `, ${result.conflictFrames.length} conflicts resolved` : ""}`,
|
|
421
|
-
actionRequired: false,
|
|
422
|
-
createdAt: /* @__PURE__ */ new Date()
|
|
423
|
-
};
|
|
424
|
-
const allUsers = Array.from(this.notifications.keys());
|
|
425
|
-
for (const userId of allUsers) {
|
|
426
|
-
const userSpecificNotification = {
|
|
427
|
-
...completionNotification,
|
|
428
|
-
id: `${requestId}-completion-${userId}-${Date.now()}`,
|
|
429
|
-
recipientId: userId
|
|
430
|
-
};
|
|
431
|
-
const userNotifications = this.notifications.get(userId) || [];
|
|
432
|
-
userNotifications.push(userSpecificNotification);
|
|
433
|
-
this.notifications.set(userId, userNotifications);
|
|
434
|
-
}
|
|
435
|
-
logger.info(`Handoff completed: ${requestId}`, {
|
|
436
|
-
mergedFrames: result.mergedFrames.length,
|
|
437
|
-
conflicts: result.conflictFrames.length,
|
|
438
|
-
notifiedUsers: allUsers.length
|
|
439
|
-
});
|
|
440
|
-
if (result.conflictFrames.length > 0) {
|
|
441
|
-
logger.info(`Handoff completion details:`, {
|
|
442
|
-
requestId,
|
|
443
|
-
transferredFrames: result.mergedFrames.map(
|
|
444
|
-
(f) => f.frameId || f.id
|
|
445
|
-
),
|
|
446
|
-
conflictFrames: result.conflictFrames.map(
|
|
447
|
-
(f) => f.frameId || f.id
|
|
448
|
-
)
|
|
449
|
-
});
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
/**
|
|
453
|
-
* Notify handoff cancellation
|
|
454
|
-
*/
|
|
455
|
-
async notifyHandoffCancellation(requestId, reason) {
|
|
456
|
-
const cancellationNotification = {
|
|
457
|
-
id: `${requestId}-cancellation-${Date.now()}`,
|
|
458
|
-
type: "request",
|
|
459
|
-
// Using 'request' type as it's informational
|
|
460
|
-
requestId,
|
|
461
|
-
recipientId: "all",
|
|
462
|
-
// Will be distributed to all stakeholders
|
|
463
|
-
title: "Handoff Cancelled",
|
|
464
|
-
message: `Handoff request has been cancelled. Reason: ${reason}`,
|
|
465
|
-
actionRequired: false,
|
|
466
|
-
createdAt: /* @__PURE__ */ new Date()
|
|
467
|
-
};
|
|
468
|
-
const allUsers = Array.from(this.notifications.keys());
|
|
469
|
-
for (const userId of allUsers) {
|
|
470
|
-
const userSpecificNotification = {
|
|
471
|
-
...cancellationNotification,
|
|
472
|
-
id: `${requestId}-cancellation-${userId}-${Date.now()}`,
|
|
473
|
-
recipientId: userId
|
|
474
|
-
};
|
|
475
|
-
const userNotifications = this.notifications.get(userId) || [];
|
|
476
|
-
userNotifications.push(userSpecificNotification);
|
|
477
|
-
this.notifications.set(userId, userNotifications);
|
|
478
|
-
}
|
|
479
|
-
logger.info(`Handoff cancelled: ${requestId}`, {
|
|
480
|
-
reason,
|
|
481
|
-
notifiedUsers: allUsers.length
|
|
482
|
-
});
|
|
483
|
-
}
|
|
484
|
-
/**
|
|
485
|
-
* Get handoff analytics and metrics
|
|
486
|
-
*/
|
|
487
|
-
async getHandoffMetrics(timeRange) {
|
|
488
|
-
const handoffs = Array.from(this.activeHandoffs.values());
|
|
489
|
-
const filteredHandoffs = timeRange ? handoffs.filter((h) => {
|
|
490
|
-
return true;
|
|
491
|
-
}) : handoffs;
|
|
492
|
-
const completedHandoffs = filteredHandoffs.filter(
|
|
493
|
-
(h) => h.status === "completed"
|
|
494
|
-
);
|
|
495
|
-
return {
|
|
496
|
-
totalHandoffs: filteredHandoffs.length,
|
|
497
|
-
completedHandoffs: completedHandoffs.length,
|
|
498
|
-
averageProcessingTime: this.calculateAverageProcessingTime(completedHandoffs),
|
|
499
|
-
topFrameTypes: this.analyzeFrameTypes(filteredHandoffs),
|
|
500
|
-
collaborationPatterns: this.analyzeCollaborationPatterns(filteredHandoffs)
|
|
501
|
-
};
|
|
502
|
-
}
|
|
503
|
-
calculateAverageProcessingTime(handoffs) {
|
|
504
|
-
if (handoffs.length === 0) return 0;
|
|
505
|
-
let totalProcessingTime = 0;
|
|
506
|
-
let validHandoffs = 0;
|
|
507
|
-
for (const handoff of handoffs) {
|
|
508
|
-
if (handoff.status === "completed" && handoff.estimatedCompletion) {
|
|
509
|
-
const frameComplexity = handoff.totalFrames * 0.5;
|
|
510
|
-
const errorPenalty = handoff.errors.length * 2;
|
|
511
|
-
const processingTime = Math.max(1, frameComplexity + errorPenalty);
|
|
512
|
-
totalProcessingTime += processingTime;
|
|
513
|
-
validHandoffs++;
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
return validHandoffs > 0 ? Math.round(totalProcessingTime / validHandoffs) : 0;
|
|
517
|
-
}
|
|
518
|
-
analyzeFrameTypes(handoffs) {
|
|
519
|
-
const frameTypeCount = /* @__PURE__ */ new Map();
|
|
520
|
-
for (const handoff of handoffs) {
|
|
521
|
-
const estimatedTypes = this.estimateFrameTypes(handoff);
|
|
522
|
-
for (const type of estimatedTypes) {
|
|
523
|
-
frameTypeCount.set(type, (frameTypeCount.get(type) || 0) + 1);
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
return Array.from(frameTypeCount.entries()).map(([type, count]) => ({ type, count })).sort((a, b) => b.count - a.count).slice(0, 10);
|
|
527
|
-
}
|
|
528
|
-
estimateFrameTypes(handoff) {
|
|
529
|
-
const types = [];
|
|
530
|
-
if (handoff.totalFrames > 10) {
|
|
531
|
-
types.push("bulk_transfer");
|
|
532
|
-
}
|
|
533
|
-
if (handoff.errors.length > 0) {
|
|
534
|
-
types.push("complex_handoff");
|
|
535
|
-
}
|
|
536
|
-
if (handoff.transferredFrames === handoff.totalFrames) {
|
|
537
|
-
types.push("complete_transfer");
|
|
538
|
-
} else {
|
|
539
|
-
types.push("partial_transfer");
|
|
540
|
-
}
|
|
541
|
-
types.push("development", "collaboration");
|
|
542
|
-
return types;
|
|
543
|
-
}
|
|
544
|
-
analyzeCollaborationPatterns(handoffs) {
|
|
545
|
-
const collaborationCount = /* @__PURE__ */ new Map();
|
|
546
|
-
for (const handoff of handoffs) {
|
|
547
|
-
const pattern = this.extractCollaborationPattern(handoff);
|
|
548
|
-
if (pattern) {
|
|
549
|
-
const key = `${pattern.sourceUser}->${pattern.targetUser}`;
|
|
550
|
-
collaborationCount.set(key, (collaborationCount.get(key) || 0) + 1);
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
return Array.from(collaborationCount.entries()).map(([pattern, count]) => {
|
|
554
|
-
const [sourceUser, targetUser] = pattern.split("->");
|
|
555
|
-
return { sourceUser, targetUser, count };
|
|
556
|
-
}).sort((a, b) => b.count - a.count).slice(0, 20);
|
|
557
|
-
}
|
|
558
|
-
extractCollaborationPattern(handoff) {
|
|
559
|
-
if (handoff.status === "completed") {
|
|
560
|
-
return {
|
|
561
|
-
sourceUser: "developer",
|
|
562
|
-
targetUser: "reviewer"
|
|
563
|
-
};
|
|
564
|
-
} else if (handoff.status === "failed") {
|
|
565
|
-
return {
|
|
566
|
-
sourceUser: "developer",
|
|
567
|
-
targetUser: "lead"
|
|
568
|
-
};
|
|
569
|
-
}
|
|
570
|
-
return null;
|
|
571
|
-
}
|
|
572
|
-
/**
|
|
573
|
-
* Real-time collaboration features
|
|
574
|
-
*/
|
|
575
|
-
/**
|
|
576
|
-
* Get real-time handoff status updates
|
|
577
|
-
*/
|
|
578
|
-
async getHandoffStatusStream(requestId) {
|
|
579
|
-
const progress = this.activeHandoffs.get(requestId);
|
|
580
|
-
if (!progress) {
|
|
581
|
-
throw new DatabaseError(
|
|
582
|
-
`Handoff request not found: ${requestId}`,
|
|
583
|
-
ErrorCode.RESOURCE_NOT_FOUND
|
|
584
|
-
);
|
|
585
|
-
}
|
|
586
|
-
const self = this;
|
|
587
|
-
return {
|
|
588
|
-
async *[Symbol.asyncIterator]() {
|
|
589
|
-
let lastStatus = progress.status;
|
|
590
|
-
while (lastStatus !== "completed" && lastStatus !== "failed" && lastStatus !== "cancelled") {
|
|
591
|
-
const currentProgress = self.activeHandoffs.get(requestId);
|
|
592
|
-
if (currentProgress && currentProgress.status !== lastStatus) {
|
|
593
|
-
lastStatus = currentProgress.status;
|
|
594
|
-
yield currentProgress;
|
|
595
|
-
}
|
|
596
|
-
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
};
|
|
600
|
-
}
|
|
601
|
-
/**
|
|
602
|
-
* Update handoff progress in real-time
|
|
603
|
-
*/
|
|
604
|
-
async updateHandoffProgress(requestId, update) {
|
|
605
|
-
let progress = this.activeHandoffs.get(requestId);
|
|
606
|
-
if (!progress && update.requestId && update.status && update.totalFrames !== void 0) {
|
|
607
|
-
progress = {
|
|
608
|
-
requestId: update.requestId,
|
|
609
|
-
status: update.status,
|
|
610
|
-
transferredFrames: 0,
|
|
611
|
-
totalFrames: update.totalFrames,
|
|
612
|
-
currentStep: "Initialized",
|
|
613
|
-
errors: [],
|
|
614
|
-
...update
|
|
615
|
-
};
|
|
616
|
-
} else if (!progress) {
|
|
617
|
-
throw new DatabaseError(
|
|
618
|
-
`Handoff request not found: ${requestId}`,
|
|
619
|
-
ErrorCode.RESOURCE_NOT_FOUND
|
|
620
|
-
);
|
|
621
|
-
} else {
|
|
622
|
-
progress = {
|
|
623
|
-
...progress,
|
|
624
|
-
...update
|
|
625
|
-
};
|
|
626
|
-
}
|
|
627
|
-
this.activeHandoffs.set(requestId, progress);
|
|
628
|
-
logger.info(`Handoff progress updated: ${requestId}`, {
|
|
629
|
-
status: progress.status,
|
|
630
|
-
currentStep: progress.currentStep,
|
|
631
|
-
transferredFrames: progress.transferredFrames
|
|
632
|
-
});
|
|
633
|
-
await this.notifyProgressUpdate(requestId, progress);
|
|
634
|
-
}
|
|
635
|
-
/**
|
|
636
|
-
* Notify stakeholders of progress updates
|
|
637
|
-
*/
|
|
638
|
-
async notifyProgressUpdate(requestId, progress) {
|
|
639
|
-
const updateNotification = {
|
|
640
|
-
id: `${requestId}-progress-${Date.now()}`,
|
|
641
|
-
type: "request",
|
|
642
|
-
requestId,
|
|
643
|
-
recipientId: "all",
|
|
644
|
-
title: "Handoff Progress Update",
|
|
645
|
-
message: `Status: ${progress.status} | Step: ${progress.currentStep} | Progress: ${progress.transferredFrames}/${progress.totalFrames} frames`,
|
|
646
|
-
actionRequired: false,
|
|
647
|
-
createdAt: /* @__PURE__ */ new Date()
|
|
648
|
-
};
|
|
649
|
-
const allUsers = Array.from(this.notifications.keys());
|
|
650
|
-
for (const userId of allUsers) {
|
|
651
|
-
const userNotifications = this.notifications.get(userId) || [];
|
|
652
|
-
userNotifications.push({
|
|
653
|
-
...updateNotification,
|
|
654
|
-
id: `${requestId}-progress-${userId}-${Date.now()}`,
|
|
655
|
-
recipientId: userId
|
|
656
|
-
});
|
|
657
|
-
this.notifications.set(userId, userNotifications);
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
/**
|
|
661
|
-
* Get active handoffs with real-time filtering
|
|
662
|
-
*/
|
|
663
|
-
async getActiveHandoffsRealTime(filters) {
|
|
664
|
-
let handoffs = Array.from(this.activeHandoffs.values());
|
|
665
|
-
if (filters?.status) {
|
|
666
|
-
handoffs = handoffs.filter((h) => h.status === filters.status);
|
|
667
|
-
}
|
|
668
|
-
if (filters?.userId) {
|
|
669
|
-
handoffs = handoffs.filter(
|
|
670
|
-
(h) => h.requestId.includes(filters.userId || "")
|
|
671
|
-
);
|
|
672
|
-
}
|
|
673
|
-
if (filters?.priority) {
|
|
674
|
-
handoffs = handoffs.filter((h) => {
|
|
675
|
-
const estimatedPriority = this.estimateHandoffPriority(h);
|
|
676
|
-
return estimatedPriority === filters.priority;
|
|
677
|
-
});
|
|
678
|
-
}
|
|
679
|
-
return handoffs.sort((a, b) => {
|
|
680
|
-
const statusPriority = {
|
|
681
|
-
in_transfer: 4,
|
|
682
|
-
approved: 3,
|
|
683
|
-
pending_review: 2,
|
|
684
|
-
completed: 1,
|
|
685
|
-
failed: 1,
|
|
686
|
-
cancelled: 0
|
|
687
|
-
};
|
|
688
|
-
return (statusPriority[b.status] || 0) - (statusPriority[a.status] || 0);
|
|
689
|
-
});
|
|
690
|
-
}
|
|
691
|
-
estimateHandoffPriority(handoff) {
|
|
692
|
-
if (handoff.errors.length > 2 || handoff.totalFrames > 50)
|
|
693
|
-
return "critical";
|
|
694
|
-
if (handoff.errors.length > 0 || handoff.totalFrames > 20) return "high";
|
|
695
|
-
if (handoff.totalFrames > 5) return "medium";
|
|
696
|
-
return "low";
|
|
697
|
-
}
|
|
698
|
-
/**
|
|
699
|
-
* Bulk handoff operations for team collaboration
|
|
700
|
-
*/
|
|
701
|
-
async bulkHandoffOperation(operation) {
|
|
702
|
-
const results = {
|
|
703
|
-
successful: [],
|
|
704
|
-
failed: []
|
|
705
|
-
};
|
|
706
|
-
for (const requestId of operation.requestIds) {
|
|
707
|
-
try {
|
|
708
|
-
switch (operation.action) {
|
|
709
|
-
case "approve":
|
|
710
|
-
await this.submitHandoffApproval(requestId, {
|
|
711
|
-
reviewerId: operation.reviewerId,
|
|
712
|
-
decision: "approved",
|
|
713
|
-
feedback: operation.feedback
|
|
714
|
-
});
|
|
715
|
-
results.successful.push(requestId);
|
|
716
|
-
break;
|
|
717
|
-
case "reject":
|
|
718
|
-
await this.submitHandoffApproval(requestId, {
|
|
719
|
-
reviewerId: operation.reviewerId,
|
|
720
|
-
decision: "rejected",
|
|
721
|
-
feedback: operation.feedback || "Bulk rejection"
|
|
722
|
-
});
|
|
723
|
-
results.successful.push(requestId);
|
|
724
|
-
break;
|
|
725
|
-
case "cancel":
|
|
726
|
-
await this.cancelHandoff(
|
|
727
|
-
requestId,
|
|
728
|
-
operation.feedback || "Bulk cancellation"
|
|
729
|
-
);
|
|
730
|
-
results.successful.push(requestId);
|
|
731
|
-
break;
|
|
732
|
-
}
|
|
733
|
-
} catch (error) {
|
|
734
|
-
results.failed.push({
|
|
735
|
-
requestId,
|
|
736
|
-
error: error instanceof Error ? error.message : String(error)
|
|
737
|
-
});
|
|
738
|
-
}
|
|
739
|
-
}
|
|
740
|
-
logger.info(`Bulk handoff operation completed`, {
|
|
741
|
-
action: operation.action,
|
|
742
|
-
successful: results.successful.length,
|
|
743
|
-
failed: results.failed.length,
|
|
744
|
-
reviewerId: operation.reviewerId
|
|
745
|
-
});
|
|
746
|
-
return results;
|
|
747
|
-
}
|
|
748
|
-
/**
|
|
749
|
-
* Enhanced notification management with cleanup
|
|
750
|
-
*/
|
|
751
|
-
async cleanupExpiredNotifications(userId) {
|
|
752
|
-
let cleanedCount = 0;
|
|
753
|
-
const now = /* @__PURE__ */ new Date();
|
|
754
|
-
const userIds = userId ? [userId] : Array.from(this.notifications.keys());
|
|
755
|
-
for (const uid of userIds) {
|
|
756
|
-
const userNotifications = this.notifications.get(uid) || [];
|
|
757
|
-
const activeNotifications = userNotifications.filter((notification) => {
|
|
758
|
-
if (notification.expiresAt && notification.expiresAt < now) {
|
|
759
|
-
cleanedCount++;
|
|
760
|
-
return false;
|
|
761
|
-
}
|
|
762
|
-
return true;
|
|
763
|
-
});
|
|
764
|
-
this.notifications.set(uid, activeNotifications);
|
|
765
|
-
}
|
|
766
|
-
if (cleanedCount > 0) {
|
|
767
|
-
logger.info(`Cleaned up expired notifications`, {
|
|
768
|
-
count: cleanedCount,
|
|
769
|
-
userId: userId || "all"
|
|
770
|
-
});
|
|
771
|
-
}
|
|
772
|
-
return cleanedCount;
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
export {
|
|
776
|
-
FrameHandoffManager
|
|
777
|
-
};
|
|
778
|
-
//# sourceMappingURL=frame-handoff-manager.js.map
|