@stackmemoryai/stackmemory 0.2.6 → 0.2.8
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 +262 -83
- package/dist/scripts/cancel-duplicate-tasks.d.ts +7 -0
- package/dist/scripts/cancel-duplicate-tasks.d.ts.map +1 -0
- package/dist/scripts/cancel-duplicate-tasks.js +172 -0
- package/dist/scripts/cancel-duplicate-tasks.js.map +1 -0
- package/dist/scripts/list-linear-tasks.d.ts +6 -0
- package/dist/scripts/list-linear-tasks.d.ts.map +1 -0
- package/dist/scripts/list-linear-tasks.js +121 -0
- package/dist/scripts/list-linear-tasks.js.map +1 -0
- package/dist/scripts/merge-linear-duplicates-safe.d.ts +7 -0
- package/dist/scripts/merge-linear-duplicates-safe.d.ts.map +1 -0
- package/dist/scripts/merge-linear-duplicates-safe.js +267 -0
- package/dist/scripts/merge-linear-duplicates-safe.js.map +1 -0
- package/dist/scripts/show-linear-summary.d.ts +6 -0
- package/dist/scripts/show-linear-summary.d.ts.map +1 -0
- package/dist/scripts/show-linear-summary.js +120 -0
- package/dist/scripts/show-linear-summary.js.map +1 -0
- package/dist/scripts/status.js +6 -2
- package/dist/scripts/status.js.map +1 -1
- package/dist/src/cli/auto-detect.d.ts +61 -0
- package/dist/src/cli/auto-detect.d.ts.map +1 -0
- package/dist/src/cli/auto-detect.js +350 -0
- package/dist/src/cli/auto-detect.js.map +1 -0
- package/dist/src/cli/claude-sm.d.ts +7 -0
- package/dist/src/cli/claude-sm.d.ts.map +1 -0
- package/dist/src/cli/claude-sm.js +357 -0
- package/dist/src/cli/claude-sm.js.map +1 -0
- package/dist/src/cli/commands/config.d.ts +6 -0
- package/dist/src/cli/commands/config.d.ts.map +1 -0
- package/dist/src/cli/commands/config.js +224 -0
- package/dist/src/cli/commands/config.js.map +1 -0
- package/dist/src/cli/commands/context.d.ts +7 -0
- package/dist/src/cli/commands/context.d.ts.map +1 -0
- package/dist/src/cli/commands/context.js +365 -0
- package/dist/src/cli/commands/context.js.map +1 -0
- package/dist/src/cli/commands/linear-test.d.ts +6 -0
- package/dist/src/cli/commands/linear-test.d.ts.map +1 -0
- package/dist/src/cli/commands/linear-test.js +123 -0
- package/dist/src/cli/commands/linear-test.js.map +1 -0
- package/dist/src/cli/commands/linear.d.ts +6 -0
- package/dist/src/cli/commands/linear.d.ts.map +1 -0
- package/dist/src/cli/commands/linear.js +393 -0
- package/dist/src/cli/commands/linear.js.map +1 -0
- package/dist/src/cli/commands/log.d.ts +7 -0
- package/dist/src/cli/commands/log.d.ts.map +1 -0
- package/dist/src/cli/commands/log.js +168 -0
- package/dist/src/cli/commands/log.js.map +1 -0
- package/dist/src/cli/commands/onboard.d.ts +8 -0
- package/dist/src/cli/commands/onboard.d.ts.map +1 -0
- package/dist/src/cli/commands/onboard.js +363 -0
- package/dist/src/cli/commands/onboard.js.map +1 -0
- package/dist/src/cli/commands/projects.js +1 -1
- package/dist/src/cli/commands/projects.js.map +1 -1
- package/dist/src/cli/commands/search.d.ts +7 -0
- package/dist/src/cli/commands/search.d.ts.map +1 -0
- package/dist/src/cli/commands/search.js +162 -0
- package/dist/src/cli/commands/search.js.map +1 -0
- package/dist/src/cli/commands/session.d.ts +7 -0
- package/dist/src/cli/commands/session.d.ts.map +1 -0
- package/dist/src/cli/commands/session.js +222 -0
- package/dist/src/cli/commands/session.js.map +1 -0
- package/dist/src/cli/commands/tasks.d.ts +7 -0
- package/dist/src/cli/commands/tasks.d.ts.map +1 -0
- package/dist/src/cli/commands/tasks.js +229 -0
- package/dist/src/cli/commands/tasks.js.map +1 -0
- package/dist/src/cli/commands/webhook.d.ts +3 -0
- package/dist/src/cli/commands/webhook.d.ts.map +1 -0
- package/dist/src/cli/commands/webhook.js +157 -0
- package/dist/src/cli/commands/webhook.js.map +1 -0
- package/dist/src/cli/commands/worktree.d.ts +8 -0
- package/dist/src/cli/commands/worktree.d.ts.map +1 -0
- package/dist/src/cli/commands/worktree.js +339 -0
- package/dist/src/cli/commands/worktree.js.map +1 -0
- package/dist/src/cli/index.d.ts +2 -1
- package/dist/src/cli/index.d.ts.map +1 -1
- package/dist/src/cli/index.js +337 -50
- package/dist/src/cli/index.js.map +1 -1
- package/dist/src/cli/utils/viewer.d.ts.map +1 -1
- package/dist/src/cli/utils/viewer.js +3 -1
- package/dist/src/cli/utils/viewer.js.map +1 -1
- package/dist/src/core/config/config-manager.d.ts +95 -0
- package/dist/src/core/config/config-manager.d.ts.map +1 -0
- package/dist/src/core/config/config-manager.js +359 -0
- package/dist/src/core/config/config-manager.js.map +1 -0
- package/dist/src/core/config/types.d.ts +72 -0
- package/dist/src/core/config/types.d.ts.map +1 -0
- package/dist/src/core/config/types.js +127 -0
- package/dist/src/core/config/types.js.map +1 -0
- package/dist/src/core/context/auto-context.d.ts +22 -0
- package/dist/src/core/context/auto-context.d.ts.map +1 -0
- package/dist/src/core/context/auto-context.js +77 -0
- package/dist/src/core/context/auto-context.js.map +1 -0
- package/dist/src/core/context/compaction-handler.d.ts +119 -0
- package/dist/src/core/context/compaction-handler.d.ts.map +1 -0
- package/dist/src/core/context/compaction-handler.js +306 -0
- package/dist/src/core/context/compaction-handler.js.map +1 -0
- package/dist/src/core/context/frame-manager.d.ts +4 -0
- package/dist/src/core/context/frame-manager.d.ts.map +1 -1
- package/dist/src/core/context/frame-manager.js +350 -144
- package/dist/src/core/context/frame-manager.js.map +1 -1
- package/dist/src/core/context/model-aware-compaction.d.ts +101 -0
- package/dist/src/core/context/model-aware-compaction.d.ts.map +1 -0
- package/dist/src/core/context/model-aware-compaction.js +616 -0
- package/dist/src/core/context/model-aware-compaction.js.map +1 -0
- package/dist/src/core/errors/index.d.ts +135 -0
- package/dist/src/core/errors/index.d.ts.map +1 -0
- package/dist/src/core/errors/index.js +274 -0
- package/dist/src/core/errors/index.js.map +1 -0
- package/dist/src/core/errors/recovery.d.ts +86 -0
- package/dist/src/core/errors/recovery.d.ts.map +1 -0
- package/dist/src/core/errors/recovery.js +274 -0
- package/dist/src/core/errors/recovery.js.map +1 -0
- package/dist/src/core/projects/project-manager.d.ts.map +1 -1
- package/dist/src/core/projects/project-manager.js +240 -122
- package/dist/src/core/projects/project-manager.js.map +1 -1
- package/dist/src/core/query/query-parser.d.ts +104 -0
- package/dist/src/core/query/query-parser.d.ts.map +1 -0
- package/dist/src/core/query/query-parser.js +347 -0
- package/dist/src/core/query/query-parser.js.map +1 -0
- package/dist/src/core/retrieval/index.d.ts +8 -0
- package/dist/src/core/retrieval/index.d.ts.map +1 -0
- package/dist/src/core/retrieval/index.js +8 -0
- package/dist/src/core/retrieval/index.js.map +1 -0
- package/dist/src/core/retrieval/llm-context-retrieval.d.ts +71 -0
- package/dist/src/core/retrieval/llm-context-retrieval.d.ts.map +1 -0
- package/dist/src/core/retrieval/llm-context-retrieval.js +545 -0
- package/dist/src/core/retrieval/llm-context-retrieval.js.map +1 -0
- package/dist/src/core/retrieval/summary-generator.d.ts +63 -0
- package/dist/src/core/retrieval/summary-generator.d.ts.map +1 -0
- package/dist/src/core/retrieval/summary-generator.js +622 -0
- package/dist/src/core/retrieval/summary-generator.js.map +1 -0
- package/dist/src/core/retrieval/types.d.ts +257 -0
- package/dist/src/core/retrieval/types.d.ts.map +1 -0
- package/dist/src/core/retrieval/types.js +18 -0
- package/dist/src/core/retrieval/types.js.map +1 -0
- package/dist/src/core/session/index.d.ts +2 -0
- package/dist/src/core/session/index.d.ts.map +1 -0
- package/dist/src/core/session/index.js +2 -0
- package/dist/src/core/session/index.js.map +1 -0
- package/dist/src/core/session/session-manager.d.ts +69 -0
- package/dist/src/core/session/session-manager.d.ts.map +1 -0
- package/dist/src/core/session/session-manager.js +311 -0
- package/dist/src/core/session/session-manager.js.map +1 -0
- package/dist/src/core/trace/trace-detector.d.ts +108 -0
- package/dist/src/core/trace/trace-detector.d.ts.map +1 -0
- package/dist/src/core/trace/trace-detector.demo.d.ts +5 -0
- package/dist/src/core/trace/trace-detector.demo.d.ts.map +1 -0
- package/dist/src/core/trace/trace-detector.demo.js +145 -0
- package/dist/src/core/trace/trace-detector.demo.js.map +1 -0
- package/dist/src/core/trace/trace-detector.js +425 -0
- package/dist/src/core/trace/trace-detector.js.map +1 -0
- package/dist/src/core/trace/trace-store.d.ts +60 -0
- package/dist/src/core/trace/trace-store.d.ts.map +1 -0
- package/dist/src/core/trace/trace-store.js +323 -0
- package/dist/src/core/trace/trace-store.js.map +1 -0
- package/dist/src/core/trace/types.d.ts +81 -0
- package/dist/src/core/trace/types.d.ts.map +1 -0
- package/dist/src/core/trace/types.js +70 -0
- package/dist/src/core/trace/types.js.map +1 -0
- package/dist/src/core/utils/update-checker.d.ts.map +1 -1
- package/dist/src/core/utils/update-checker.js +82 -25
- package/dist/src/core/utils/update-checker.js.map +1 -1
- package/dist/src/core/worktree/worktree-manager.d.ts +110 -0
- package/dist/src/core/worktree/worktree-manager.d.ts.map +1 -0
- package/dist/src/core/worktree/worktree-manager.js +456 -0
- package/dist/src/core/worktree/worktree-manager.js.map +1 -0
- package/dist/src/features/analytics/core/analytics-service.d.ts +6 -0
- package/dist/src/features/analytics/core/analytics-service.d.ts.map +1 -1
- package/dist/src/features/analytics/core/analytics-service.js +125 -10
- package/dist/src/features/analytics/core/analytics-service.js.map +1 -1
- package/dist/src/features/analytics/queries/metrics-queries.d.ts.map +1 -1
- package/dist/src/features/analytics/queries/metrics-queries.js +220 -163
- package/dist/src/features/analytics/queries/metrics-queries.js.map +1 -1
- package/dist/src/features/browser/browser-mcp.d.ts.map +1 -1
- package/dist/src/features/browser/browser-mcp.js +3 -0
- package/dist/src/features/browser/browser-mcp.js.map +1 -1
- package/dist/src/features/tasks/pebbles-task-store.d.ts +4 -0
- package/dist/src/features/tasks/pebbles-task-store.d.ts.map +1 -1
- package/dist/src/features/tasks/pebbles-task-store.js +299 -141
- package/dist/src/features/tasks/pebbles-task-store.js.map +1 -1
- package/dist/src/integrations/linear/client.d.ts +28 -1
- package/dist/src/integrations/linear/client.d.ts.map +1 -1
- package/dist/src/integrations/linear/client.js +87 -0
- package/dist/src/integrations/linear/client.js.map +1 -1
- package/dist/src/integrations/linear/sync-manager.d.ts +76 -0
- package/dist/src/integrations/linear/sync-manager.d.ts.map +1 -0
- package/dist/src/integrations/linear/sync-manager.js +223 -0
- package/dist/src/integrations/linear/sync-manager.js.map +1 -0
- package/dist/src/integrations/linear/sync-service.d.ts +25 -0
- package/dist/src/integrations/linear/sync-service.d.ts.map +1 -0
- package/dist/src/integrations/linear/sync-service.js +198 -0
- package/dist/src/integrations/linear/sync-service.js.map +1 -0
- package/dist/src/integrations/linear/sync.d.ts +23 -1
- package/dist/src/integrations/linear/sync.d.ts.map +1 -1
- package/dist/src/integrations/linear/sync.js +156 -9
- package/dist/src/integrations/linear/sync.js.map +1 -1
- package/dist/src/integrations/linear/types.d.ts +75 -0
- package/dist/src/integrations/linear/types.d.ts.map +1 -0
- package/dist/src/integrations/linear/types.js +2 -0
- package/dist/src/integrations/linear/types.js.map +1 -0
- package/dist/src/integrations/linear/webhook-server.d.ts +32 -0
- package/dist/src/integrations/linear/webhook-server.d.ts.map +1 -0
- package/dist/src/integrations/linear/webhook-server.js +188 -0
- package/dist/src/integrations/linear/webhook-server.js.map +1 -0
- package/dist/src/integrations/linear/webhook.d.ts +95 -0
- package/dist/src/integrations/linear/webhook.d.ts.map +1 -0
- package/dist/src/integrations/linear/webhook.js +204 -0
- package/dist/src/integrations/linear/webhook.js.map +1 -0
- package/dist/src/integrations/mcp/server.d.ts +14 -0
- package/dist/src/integrations/mcp/server.d.ts.map +1 -1
- package/dist/src/integrations/mcp/server.js +849 -61
- package/dist/src/integrations/mcp/server.js.map +1 -1
- package/dist/src/integrations/mcp/trace-test.d.ts +5 -0
- package/dist/src/integrations/mcp/trace-test.d.ts.map +1 -0
- package/dist/src/integrations/mcp/trace-test.js +54 -0
- package/dist/src/integrations/mcp/trace-test.js.map +1 -0
- package/dist/src/servers/production/auth-middleware.d.ts +2 -2
- package/dist/src/servers/production/auth-middleware.d.ts.map +1 -1
- package/dist/src/servers/production/auth-middleware.js +1 -1
- package/dist/src/servers/production/auth-middleware.js.map +1 -1
- package/dist/src/services/config-service.d.ts +44 -0
- package/dist/src/services/config-service.d.ts.map +1 -0
- package/dist/src/services/config-service.js +61 -0
- package/dist/src/services/config-service.js.map +1 -0
- package/dist/src/services/context-service.d.ts +17 -0
- package/dist/src/services/context-service.d.ts.map +1 -0
- package/dist/src/services/context-service.js +88 -0
- package/dist/src/services/context-service.js.map +1 -0
- package/dist/src/types/task.d.ts +27 -0
- package/dist/src/types/task.d.ts.map +1 -0
- package/dist/src/types/task.js +2 -0
- package/dist/src/types/task.js.map +1 -0
- package/dist/src/utils/logger.d.ts +13 -0
- package/dist/src/utils/logger.d.ts.map +1 -0
- package/dist/src/utils/logger.js +52 -0
- package/dist/src/utils/logger.js.map +1 -0
- package/package.json +24 -10
- package/dist/attention-scoring/src/attention-tracker.d.ts +0 -79
- package/dist/attention-scoring/src/attention-tracker.d.ts.map +0 -1
- package/dist/attention-scoring/src/attention-tracker.js +0 -488
- package/dist/attention-scoring/src/attention-tracker.js.map +0 -1
- package/dist/attention-scoring/src/mcp-integration.d.ts +0 -56
- package/dist/attention-scoring/src/mcp-integration.d.ts.map +0 -1
- package/dist/attention-scoring/src/mcp-integration.js +0 -369
- package/dist/attention-scoring/src/mcp-integration.js.map +0 -1
- package/dist/index.js +0 -382
- package/dist/p2p-sync/src/p2p-sync.d.ts +0 -81
- package/dist/p2p-sync/src/p2p-sync.d.ts.map +0 -1
- package/dist/p2p-sync/src/p2p-sync.js +0 -457
- package/dist/p2p-sync/src/p2p-sync.js.map +0 -1
- package/dist/p2p-sync/src/team-context-sync.d.ts +0 -99
- package/dist/p2p-sync/src/team-context-sync.d.ts.map +0 -1
- package/dist/p2p-sync/src/team-context-sync.js +0 -491
- package/dist/p2p-sync/src/team-context-sync.js.map +0 -1
- package/dist/src/analytics/api/analytics-api.d.ts +0 -24
- package/dist/src/analytics/api/analytics-api.d.ts.map +0 -1
- package/dist/src/analytics/api/analytics-api.js +0 -279
- package/dist/src/analytics/api/analytics-api.js.map +0 -1
- package/dist/src/analytics/core/analytics-service.d.ts +0 -23
- package/dist/src/analytics/core/analytics-service.d.ts.map +0 -1
- package/dist/src/analytics/core/analytics-service.js +0 -160
- package/dist/src/analytics/core/analytics-service.js.map +0 -1
- package/dist/src/analytics/index.d.ts +0 -12
- package/dist/src/analytics/index.d.ts.map +0 -1
- package/dist/src/analytics/index.js +0 -11
- package/dist/src/analytics/index.js.map +0 -1
- package/dist/src/analytics/queries/metrics-queries.d.ts +0 -11
- package/dist/src/analytics/queries/metrics-queries.d.ts.map +0 -1
- package/dist/src/analytics/queries/metrics-queries.js +0 -179
- package/dist/src/analytics/queries/metrics-queries.js.map +0 -1
- package/dist/src/analytics/types/metrics.d.ts +0 -60
- package/dist/src/analytics/types/metrics.d.ts.map +0 -1
- package/dist/src/analytics/types/metrics.js +0 -2
- package/dist/src/analytics/types/metrics.js.map +0 -1
- package/dist/src/beads/beads-task-store.d.ts +0 -117
- package/dist/src/beads/beads-task-store.d.ts.map +0 -1
- package/dist/src/beads/beads-task-store.js +0 -318
- package/dist/src/beads/beads-task-store.js.map +0 -1
- package/dist/src/beads/task-aware-context.d.ts +0 -103
- package/dist/src/beads/task-aware-context.d.ts.map +0 -1
- package/dist/src/beads/task-aware-context.js +0 -395
- package/dist/src/beads/task-aware-context.js.map +0 -1
- package/dist/src/beads-task-store.d.ts +0 -117
- package/dist/src/beads-task-store.d.ts.map +0 -1
- package/dist/src/beads-task-store.js +0 -318
- package/dist/src/beads-task-store.js.map +0 -1
- package/dist/src/cli/analytics-viewer.d.ts +0 -3
- package/dist/src/cli/analytics-viewer.d.ts.map +0 -1
- package/dist/src/cli/analytics-viewer.js +0 -89
- package/dist/src/cli/analytics-viewer.js.map +0 -1
- package/dist/src/cli/cli.d.ts +0 -7
- package/dist/src/cli/cli.d.ts.map +0 -1
- package/dist/src/cli/cli.js +0 -704
- package/dist/src/cli/cli.js.map +0 -1
- package/dist/src/cli/project-commands.d.ts +0 -8
- package/dist/src/cli/project-commands.d.ts.map +0 -1
- package/dist/src/cli/project-commands.js +0 -212
- package/dist/src/cli/project-commands.js.map +0 -1
- package/dist/src/cli.d.ts +0 -7
- package/dist/src/cli.d.ts.map +0 -1
- package/dist/src/cli.js +0 -73
- package/dist/src/cli.js.map +0 -1
- package/dist/src/core/error-handler.d.ts +0 -46
- package/dist/src/core/error-handler.d.ts.map +0 -1
- package/dist/src/core/error-handler.js +0 -212
- package/dist/src/core/error-handler.js.map +0 -1
- package/dist/src/core/frame-manager.d.ts +0 -106
- package/dist/src/core/frame-manager.d.ts.map +0 -1
- package/dist/src/core/frame-manager.js +0 -387
- package/dist/src/core/frame-manager.js.map +0 -1
- package/dist/src/core/logger.d.ts +0 -24
- package/dist/src/core/logger.d.ts.map +0 -1
- package/dist/src/core/logger.js +0 -121
- package/dist/src/core/logger.js.map +0 -1
- package/dist/src/core/logger.test.d.ts +0 -2
- package/dist/src/core/logger.test.d.ts.map +0 -1
- package/dist/src/core/logger.test.js +0 -31
- package/dist/src/core/logger.test.js.map +0 -1
- package/dist/src/core/progress-tracker.d.ts +0 -95
- package/dist/src/core/progress-tracker.d.ts.map +0 -1
- package/dist/src/core/progress-tracker.js +0 -178
- package/dist/src/core/progress-tracker.js.map +0 -1
- package/dist/src/core/project-manager.d.ts +0 -130
- package/dist/src/core/project-manager.d.ts.map +0 -1
- package/dist/src/core/project-manager.js +0 -582
- package/dist/src/core/project-manager.js.map +0 -1
- package/dist/src/core/update-checker.d.ts +0 -38
- package/dist/src/core/update-checker.d.ts.map +0 -1
- package/dist/src/core/update-checker.js +0 -156
- package/dist/src/core/update-checker.js.map +0 -1
- package/dist/src/error-handler.d.ts +0 -42
- package/dist/src/error-handler.d.ts.map +0 -1
- package/dist/src/error-handler.js +0 -155
- package/dist/src/error-handler.js.map +0 -1
- package/dist/src/frame-manager.d.ts +0 -106
- package/dist/src/frame-manager.d.ts.map +0 -1
- package/dist/src/frame-manager.js +0 -361
- package/dist/src/frame-manager.js.map +0 -1
- package/dist/src/integrations/browser-mcp.d.ts +0 -94
- package/dist/src/integrations/browser-mcp.d.ts.map +0 -1
- package/dist/src/integrations/browser-mcp.js +0 -431
- package/dist/src/integrations/browser-mcp.js.map +0 -1
- package/dist/src/integrations/linear-auth.d.ts +0 -99
- package/dist/src/integrations/linear-auth.d.ts.map +0 -1
- package/dist/src/integrations/linear-auth.js +0 -319
- package/dist/src/integrations/linear-auth.js.map +0 -1
- package/dist/src/integrations/linear-auto-sync.d.ts +0 -77
- package/dist/src/integrations/linear-auto-sync.d.ts.map +0 -1
- package/dist/src/integrations/linear-auto-sync.js +0 -268
- package/dist/src/integrations/linear-auto-sync.js.map +0 -1
- package/dist/src/integrations/linear-client.d.ts +0 -86
- package/dist/src/integrations/linear-client.d.ts.map +0 -1
- package/dist/src/integrations/linear-client.js +0 -277
- package/dist/src/integrations/linear-client.js.map +0 -1
- package/dist/src/integrations/linear-config.d.ts +0 -51
- package/dist/src/integrations/linear-config.d.ts.map +0 -1
- package/dist/src/integrations/linear-config.js +0 -103
- package/dist/src/integrations/linear-config.js.map +0 -1
- package/dist/src/integrations/linear-sync.d.ts +0 -97
- package/dist/src/integrations/linear-sync.d.ts.map +0 -1
- package/dist/src/integrations/linear-sync.js +0 -391
- package/dist/src/integrations/linear-sync.js.map +0 -1
- package/dist/src/logger.d.ts +0 -24
- package/dist/src/logger.d.ts.map +0 -1
- package/dist/src/logger.js +0 -120
- package/dist/src/logger.js.map +0 -1
- package/dist/src/mcp/mcp-server.d.ts +0 -40
- package/dist/src/mcp/mcp-server.d.ts.map +0 -1
- package/dist/src/mcp/mcp-server.js +0 -828
- package/dist/src/mcp/mcp-server.js.map +0 -1
- package/dist/src/mcp-server.d.ts +0 -32
- package/dist/src/mcp-server.d.ts.map +0 -1
- package/dist/src/mcp-server.js +0 -441
- package/dist/src/mcp-server.js.map +0 -1
- package/dist/src/pebbles/pebbles-task-store.d.ts +0 -117
- package/dist/src/pebbles/pebbles-task-store.d.ts.map +0 -1
- package/dist/src/pebbles/pebbles-task-store.js +0 -335
- package/dist/src/pebbles/pebbles-task-store.js.map +0 -1
- package/dist/src/pebbles/task-aware-context.d.ts +0 -103
- package/dist/src/pebbles/task-aware-context.d.ts.map +0 -1
- package/dist/src/pebbles/task-aware-context.js +0 -412
- package/dist/src/pebbles/task-aware-context.js.map +0 -1
- package/dist/src/railway/index.d.ts +0 -7
- package/dist/src/railway/index.d.ts.map +0 -1
- package/dist/src/railway/index.js +0 -401
- package/dist/src/railway/index.js.map +0 -1
- package/dist/src/runway/auth/auth-middleware.d.ts +0 -66
- package/dist/src/runway/auth/auth-middleware.d.ts.map +0 -1
- package/dist/src/runway/auth/auth-middleware.js +0 -337
- package/dist/src/runway/auth/auth-middleware.js.map +0 -1
- package/dist/src/runway/server/runway-mcp-server.d.ts +0 -46
- package/dist/src/runway/server/runway-mcp-server.d.ts.map +0 -1
- package/dist/src/runway/server/runway-mcp-server.js +0 -601
- package/dist/src/runway/server/runway-mcp-server.js.map +0 -1
- package/dist/src/runway.bak/auth/auth-middleware.d.ts +0 -66
- package/dist/src/runway.bak/auth/auth-middleware.d.ts.map +0 -1
- package/dist/src/runway.bak/auth/auth-middleware.js +0 -337
- package/dist/src/runway.bak/auth/auth-middleware.js.map +0 -1
- package/dist/src/runway.bak/server/runway-mcp-server.d.ts +0 -46
- package/dist/src/runway.bak/server/runway-mcp-server.d.ts.map +0 -1
- package/dist/src/runway.bak/server/runway-mcp-server.js +0 -601
- package/dist/src/runway.bak/server/runway-mcp-server.js.map +0 -1
- package/dist/src/task-aware-context.d.ts +0 -103
- package/dist/src/task-aware-context.d.ts.map +0 -1
- package/dist/src/task-aware-context.js +0 -395
- package/dist/src/task-aware-context.js.map +0 -1
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trace Store - Database persistence for traces
|
|
3
|
+
*/
|
|
4
|
+
import { TraceType, } from './types.js';
|
|
5
|
+
import { logger } from '../monitoring/logger.js';
|
|
6
|
+
export class TraceStore {
|
|
7
|
+
db;
|
|
8
|
+
constructor(db) {
|
|
9
|
+
this.db = db;
|
|
10
|
+
this.initializeSchema();
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Initialize database schema for traces
|
|
14
|
+
*/
|
|
15
|
+
initializeSchema() {
|
|
16
|
+
// Check if frames table exists (it may not in all contexts)
|
|
17
|
+
const hasFramesTable = this.db
|
|
18
|
+
.prepare(`
|
|
19
|
+
SELECT name FROM sqlite_master
|
|
20
|
+
WHERE type='table' AND name='frames'
|
|
21
|
+
`)
|
|
22
|
+
.get();
|
|
23
|
+
// Create traces table with optional foreign key
|
|
24
|
+
if (hasFramesTable) {
|
|
25
|
+
this.db.exec(`
|
|
26
|
+
CREATE TABLE IF NOT EXISTS traces (
|
|
27
|
+
id TEXT PRIMARY KEY,
|
|
28
|
+
type TEXT NOT NULL,
|
|
29
|
+
score REAL NOT NULL,
|
|
30
|
+
summary TEXT NOT NULL,
|
|
31
|
+
start_time INTEGER NOT NULL,
|
|
32
|
+
end_time INTEGER NOT NULL,
|
|
33
|
+
frame_id TEXT,
|
|
34
|
+
user_id TEXT,
|
|
35
|
+
files_modified TEXT,
|
|
36
|
+
errors_encountered TEXT,
|
|
37
|
+
decisions_recorded TEXT,
|
|
38
|
+
causal_chain INTEGER,
|
|
39
|
+
compressed_data TEXT,
|
|
40
|
+
created_at INTEGER DEFAULT (unixepoch()),
|
|
41
|
+
FOREIGN KEY (frame_id) REFERENCES frames(frame_id) ON DELETE SET NULL
|
|
42
|
+
)
|
|
43
|
+
`);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
// Create without foreign key constraint
|
|
47
|
+
this.db.exec(`
|
|
48
|
+
CREATE TABLE IF NOT EXISTS traces (
|
|
49
|
+
id TEXT PRIMARY KEY,
|
|
50
|
+
type TEXT NOT NULL,
|
|
51
|
+
score REAL NOT NULL,
|
|
52
|
+
summary TEXT NOT NULL,
|
|
53
|
+
start_time INTEGER NOT NULL,
|
|
54
|
+
end_time INTEGER NOT NULL,
|
|
55
|
+
frame_id TEXT,
|
|
56
|
+
user_id TEXT,
|
|
57
|
+
files_modified TEXT,
|
|
58
|
+
errors_encountered TEXT,
|
|
59
|
+
decisions_recorded TEXT,
|
|
60
|
+
causal_chain INTEGER,
|
|
61
|
+
compressed_data TEXT,
|
|
62
|
+
created_at INTEGER DEFAULT (unixepoch())
|
|
63
|
+
)
|
|
64
|
+
`);
|
|
65
|
+
}
|
|
66
|
+
// Create tool_calls table
|
|
67
|
+
this.db.exec(`
|
|
68
|
+
CREATE TABLE IF NOT EXISTS tool_calls (
|
|
69
|
+
id TEXT PRIMARY KEY,
|
|
70
|
+
trace_id TEXT NOT NULL,
|
|
71
|
+
tool TEXT NOT NULL,
|
|
72
|
+
arguments TEXT,
|
|
73
|
+
timestamp INTEGER NOT NULL,
|
|
74
|
+
result TEXT,
|
|
75
|
+
error TEXT,
|
|
76
|
+
files_affected TEXT,
|
|
77
|
+
duration INTEGER,
|
|
78
|
+
sequence_number INTEGER NOT NULL,
|
|
79
|
+
FOREIGN KEY (trace_id) REFERENCES traces(id) ON DELETE CASCADE
|
|
80
|
+
)
|
|
81
|
+
`);
|
|
82
|
+
// Create indexes
|
|
83
|
+
this.db.exec(`
|
|
84
|
+
CREATE INDEX IF NOT EXISTS idx_traces_type ON traces(type);
|
|
85
|
+
CREATE INDEX IF NOT EXISTS idx_traces_frame_id ON traces(frame_id);
|
|
86
|
+
CREATE INDEX IF NOT EXISTS idx_traces_start_time ON traces(start_time);
|
|
87
|
+
CREATE INDEX IF NOT EXISTS idx_traces_score ON traces(score);
|
|
88
|
+
CREATE INDEX IF NOT EXISTS idx_tool_calls_trace_id ON tool_calls(trace_id);
|
|
89
|
+
CREATE INDEX IF NOT EXISTS idx_tool_calls_timestamp ON tool_calls(timestamp);
|
|
90
|
+
`);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Save a trace to the database
|
|
94
|
+
*/
|
|
95
|
+
saveTrace(trace) {
|
|
96
|
+
const traceStmt = this.db.prepare(`
|
|
97
|
+
INSERT OR REPLACE INTO traces (
|
|
98
|
+
id, type, score, summary, start_time, end_time,
|
|
99
|
+
frame_id, user_id, files_modified, errors_encountered,
|
|
100
|
+
decisions_recorded, causal_chain, compressed_data
|
|
101
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
102
|
+
`);
|
|
103
|
+
const toolCallStmt = this.db.prepare(`
|
|
104
|
+
INSERT OR REPLACE INTO tool_calls (
|
|
105
|
+
id, trace_id, tool, arguments, timestamp, result,
|
|
106
|
+
error, files_affected, duration, sequence_number
|
|
107
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
108
|
+
`);
|
|
109
|
+
try {
|
|
110
|
+
this.db.transaction(() => {
|
|
111
|
+
// Save trace
|
|
112
|
+
traceStmt.run(trace.id, trace.type, trace.score, trace.summary, trace.metadata.startTime, trace.metadata.endTime, trace.metadata.frameId || null, trace.metadata.userId || null, JSON.stringify(trace.metadata.filesModified), JSON.stringify(trace.metadata.errorsEncountered), JSON.stringify(trace.metadata.decisionsRecorded), trace.metadata.causalChain ? 1 : 0, trace.compressed ? JSON.stringify(trace.compressed) : null);
|
|
113
|
+
// Save tool calls
|
|
114
|
+
trace.tools.forEach((tool, index) => {
|
|
115
|
+
toolCallStmt.run(tool.id, trace.id, tool.tool, tool.arguments ? JSON.stringify(tool.arguments) : null, tool.timestamp, tool.result ? JSON.stringify(tool.result) : null, tool.error || null, tool.filesAffected ? JSON.stringify(tool.filesAffected) : null, tool.duration || null, index);
|
|
116
|
+
});
|
|
117
|
+
})();
|
|
118
|
+
logger.debug(`Saved trace ${trace.id} with ${trace.tools.length} tool calls`);
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
logger.error(`Failed to save trace ${trace.id}:`, error);
|
|
122
|
+
throw error;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Load a trace by ID
|
|
127
|
+
*/
|
|
128
|
+
getTrace(id) {
|
|
129
|
+
const traceRow = this.db
|
|
130
|
+
.prepare(`
|
|
131
|
+
SELECT * FROM traces WHERE id = ?
|
|
132
|
+
`)
|
|
133
|
+
.get(id);
|
|
134
|
+
if (!traceRow) {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
const toolRows = this.db
|
|
138
|
+
.prepare(`
|
|
139
|
+
SELECT * FROM tool_calls WHERE trace_id = ? ORDER BY sequence_number
|
|
140
|
+
`)
|
|
141
|
+
.all(id);
|
|
142
|
+
return this.rowsToTrace(traceRow, toolRows);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Load all traces
|
|
146
|
+
*/
|
|
147
|
+
getAllTraces() {
|
|
148
|
+
const traceRows = this.db
|
|
149
|
+
.prepare(`
|
|
150
|
+
SELECT * FROM traces ORDER BY start_time DESC
|
|
151
|
+
`)
|
|
152
|
+
.all();
|
|
153
|
+
return traceRows.map((traceRow) => {
|
|
154
|
+
const toolRows = this.db
|
|
155
|
+
.prepare(`
|
|
156
|
+
SELECT * FROM tool_calls WHERE trace_id = ? ORDER BY sequence_number
|
|
157
|
+
`)
|
|
158
|
+
.all(traceRow.id);
|
|
159
|
+
return this.rowsToTrace(traceRow, toolRows);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Load traces by type
|
|
164
|
+
*/
|
|
165
|
+
getTracesByType(type) {
|
|
166
|
+
const traceRows = this.db
|
|
167
|
+
.prepare(`
|
|
168
|
+
SELECT * FROM traces WHERE type = ? ORDER BY start_time DESC
|
|
169
|
+
`)
|
|
170
|
+
.all(type);
|
|
171
|
+
return traceRows.map((traceRow) => {
|
|
172
|
+
const toolRows = this.db
|
|
173
|
+
.prepare(`
|
|
174
|
+
SELECT * FROM tool_calls WHERE trace_id = ? ORDER BY sequence_number
|
|
175
|
+
`)
|
|
176
|
+
.all(traceRow.id);
|
|
177
|
+
return this.rowsToTrace(traceRow, toolRows);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Load traces by frame
|
|
182
|
+
*/
|
|
183
|
+
getTracesByFrame(frameId) {
|
|
184
|
+
const traceRows = this.db
|
|
185
|
+
.prepare(`
|
|
186
|
+
SELECT * FROM traces WHERE frame_id = ? ORDER BY start_time DESC
|
|
187
|
+
`)
|
|
188
|
+
.all(frameId);
|
|
189
|
+
return traceRows.map((traceRow) => {
|
|
190
|
+
const toolRows = this.db
|
|
191
|
+
.prepare(`
|
|
192
|
+
SELECT * FROM tool_calls WHERE trace_id = ? ORDER BY sequence_number
|
|
193
|
+
`)
|
|
194
|
+
.all(traceRow.id);
|
|
195
|
+
return this.rowsToTrace(traceRow, toolRows);
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Load high-importance traces
|
|
200
|
+
*/
|
|
201
|
+
getHighImportanceTraces(minScore = 0.7) {
|
|
202
|
+
const traceRows = this.db
|
|
203
|
+
.prepare(`
|
|
204
|
+
SELECT * FROM traces WHERE score >= ? ORDER BY score DESC, start_time DESC
|
|
205
|
+
`)
|
|
206
|
+
.all(minScore);
|
|
207
|
+
return traceRows.map((traceRow) => {
|
|
208
|
+
const toolRows = this.db
|
|
209
|
+
.prepare(`
|
|
210
|
+
SELECT * FROM tool_calls WHERE trace_id = ? ORDER BY sequence_number
|
|
211
|
+
`)
|
|
212
|
+
.all(traceRow.id);
|
|
213
|
+
return this.rowsToTrace(traceRow, toolRows);
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Load error traces
|
|
218
|
+
*/
|
|
219
|
+
getErrorTraces() {
|
|
220
|
+
const traceRows = this.db
|
|
221
|
+
.prepare(`
|
|
222
|
+
SELECT * FROM traces
|
|
223
|
+
WHERE type = ? OR errors_encountered != '[]'
|
|
224
|
+
ORDER BY start_time DESC
|
|
225
|
+
`)
|
|
226
|
+
.all(TraceType.ERROR_RECOVERY);
|
|
227
|
+
return traceRows.map((traceRow) => {
|
|
228
|
+
const toolRows = this.db
|
|
229
|
+
.prepare(`
|
|
230
|
+
SELECT * FROM tool_calls WHERE trace_id = ? ORDER BY sequence_number
|
|
231
|
+
`)
|
|
232
|
+
.all(traceRow.id);
|
|
233
|
+
return this.rowsToTrace(traceRow, toolRows);
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Get trace statistics
|
|
238
|
+
*/
|
|
239
|
+
getStatistics() {
|
|
240
|
+
const stats = this.db
|
|
241
|
+
.prepare(`
|
|
242
|
+
SELECT
|
|
243
|
+
COUNT(*) as total,
|
|
244
|
+
AVG(score) as avg_score,
|
|
245
|
+
AVG((
|
|
246
|
+
SELECT COUNT(*) FROM tool_calls WHERE trace_id = traces.id
|
|
247
|
+
)) as avg_length,
|
|
248
|
+
SUM(CASE WHEN type = ? OR errors_encountered != '[]' THEN 1 ELSE 0 END) * 100.0 / COUNT(*) as error_rate
|
|
249
|
+
FROM traces
|
|
250
|
+
`)
|
|
251
|
+
.get(TraceType.ERROR_RECOVERY);
|
|
252
|
+
const typeStats = this.db
|
|
253
|
+
.prepare(`
|
|
254
|
+
SELECT type, COUNT(*) as count
|
|
255
|
+
FROM traces
|
|
256
|
+
GROUP BY type
|
|
257
|
+
`)
|
|
258
|
+
.all();
|
|
259
|
+
const tracesByType = {};
|
|
260
|
+
typeStats.forEach((row) => {
|
|
261
|
+
tracesByType[row.type] = row.count;
|
|
262
|
+
});
|
|
263
|
+
return {
|
|
264
|
+
totalTraces: stats.total || 0,
|
|
265
|
+
tracesByType,
|
|
266
|
+
averageScore: stats.avg_score || 0,
|
|
267
|
+
averageLength: stats.avg_length || 0,
|
|
268
|
+
errorRate: stats.error_rate || 0,
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Delete old traces
|
|
273
|
+
*/
|
|
274
|
+
deleteOldTraces(olderThanMs) {
|
|
275
|
+
const cutoff = Date.now() - olderThanMs;
|
|
276
|
+
const result = this.db
|
|
277
|
+
.prepare(`
|
|
278
|
+
DELETE FROM traces WHERE start_time < ?
|
|
279
|
+
`)
|
|
280
|
+
.run(cutoff);
|
|
281
|
+
return result.changes;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Convert database rows to Trace object
|
|
285
|
+
*/
|
|
286
|
+
rowsToTrace(traceRow, toolRows) {
|
|
287
|
+
const tools = toolRows.map((row) => ({
|
|
288
|
+
id: row.id,
|
|
289
|
+
tool: row.tool,
|
|
290
|
+
arguments: row.arguments ? JSON.parse(row.arguments) : undefined,
|
|
291
|
+
timestamp: row.timestamp,
|
|
292
|
+
result: row.result ? JSON.parse(row.result) : undefined,
|
|
293
|
+
error: row.error || undefined,
|
|
294
|
+
filesAffected: row.files_affected
|
|
295
|
+
? JSON.parse(row.files_affected)
|
|
296
|
+
: undefined,
|
|
297
|
+
duration: row.duration || undefined,
|
|
298
|
+
}));
|
|
299
|
+
const metadata = {
|
|
300
|
+
startTime: traceRow.start_time,
|
|
301
|
+
endTime: traceRow.end_time,
|
|
302
|
+
frameId: traceRow.frame_id || undefined,
|
|
303
|
+
userId: traceRow.user_id || undefined,
|
|
304
|
+
filesModified: JSON.parse(traceRow.files_modified || '[]'),
|
|
305
|
+
errorsEncountered: JSON.parse(traceRow.errors_encountered || '[]'),
|
|
306
|
+
decisionsRecorded: JSON.parse(traceRow.decisions_recorded || '[]'),
|
|
307
|
+
causalChain: traceRow.causal_chain === 1,
|
|
308
|
+
};
|
|
309
|
+
const trace = {
|
|
310
|
+
id: traceRow.id,
|
|
311
|
+
type: traceRow.type,
|
|
312
|
+
tools,
|
|
313
|
+
score: traceRow.score,
|
|
314
|
+
summary: traceRow.summary,
|
|
315
|
+
metadata,
|
|
316
|
+
};
|
|
317
|
+
if (traceRow.compressed_data) {
|
|
318
|
+
trace.compressed = JSON.parse(traceRow.compressed_data);
|
|
319
|
+
}
|
|
320
|
+
return trace;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
//# sourceMappingURL=trace-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace-store.js","sourceRoot":"","sources":["../../../../src/core/trace/trace-store.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAGL,SAAS,GAGV,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD,MAAM,OAAO,UAAU;IACb,EAAE,CAAoB;IAE9B,YAAY,EAAqB;QAC/B,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,gBAAgB,EAAE,CAAC;IAC1B,CAAC;IAED;;OAEG;IACK,gBAAgB;QACtB,4DAA4D;QAC5D,MAAM,cAAc,GAAG,IAAI,CAAC,EAAE;aAC3B,OAAO,CACN;;;KAGH,CACE;aACA,GAAG,EAAE,CAAC;QAET,gDAAgD;QAChD,IAAI,cAAc,EAAE,CAAC;YACnB,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC;;;;;;;;;;;;;;;;;;OAkBZ,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,wCAAwC;YACxC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC;;;;;;;;;;;;;;;;;OAiBZ,CAAC,CAAC;QACL,CAAC;QAED,0BAA0B;QAC1B,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC;;;;;;;;;;;;;;KAcZ,CAAC,CAAC;QAEH,iBAAiB;QACjB,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC;;;;;;;KAOZ,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,SAAS,CAAC,KAAY;QACpB,MAAM,SAAS,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC;;;;;;KAMjC,CAAC,CAAC;QAEH,MAAM,YAAY,GAAG,IAAI,CAAC,EAAE,C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AC1B,OAAO,EAAE,QAAQ,CAAC,QAAQ,IAAI,SAAS;YACvC,MAAM,EAAE,QAAQ,CAAC,OAAO,IAAI,SAAS;YACrC,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,cAAc,IAAI,IAAI,CAAC;YAC1D,iBAAiB,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,kBAAkB,IAAI,IAAI,CAAC;YAClE,iBAAiB,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,kBAAkB,IAAI,IAAI,CAAC;YAClE,WAAW,EAAE,QAAQ,CAAC,YAAY,KAAK,CAAC;SACzC,CAAC;QAEF,MAAM,KAAK,GAAU;YACnB,EAAE,EAAE,QAAQ,CAAC,EAAE;YACf,IAAI,EAAE,QAAQ,CAAC,IAAiB;YAChC,KAAK;YACL,KAAK,EAAE,QAAQ,CAAC,KAAK;YACrB,OAAO,EAAE,QAAQ,CAAC,OAAO;YACzB,QAAQ;SACT,CAAC;QAEF,IAAI,QAAQ,CAAC,eAAe,EAAE,CAAC;YAC7B,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QAC1D,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for Trace Detection and Bundling System
|
|
3
|
+
*/
|
|
4
|
+
export interface ToolCall {
|
|
5
|
+
id: string;
|
|
6
|
+
tool: string;
|
|
7
|
+
arguments?: Record<string, any>;
|
|
8
|
+
timestamp: number;
|
|
9
|
+
result?: any;
|
|
10
|
+
error?: string;
|
|
11
|
+
filesAffected?: string[];
|
|
12
|
+
duration?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface Trace {
|
|
15
|
+
id: string;
|
|
16
|
+
type: TraceType;
|
|
17
|
+
tools: ToolCall[];
|
|
18
|
+
score: number;
|
|
19
|
+
summary: string;
|
|
20
|
+
compressed?: CompressedTrace;
|
|
21
|
+
metadata: TraceMetadata;
|
|
22
|
+
}
|
|
23
|
+
export interface CompressedTrace {
|
|
24
|
+
pattern: string;
|
|
25
|
+
summary: string;
|
|
26
|
+
score: number;
|
|
27
|
+
toolCount: number;
|
|
28
|
+
duration: number;
|
|
29
|
+
timestamp: number;
|
|
30
|
+
}
|
|
31
|
+
export interface TraceMetadata {
|
|
32
|
+
startTime: number;
|
|
33
|
+
endTime: number;
|
|
34
|
+
frameId?: string;
|
|
35
|
+
userId?: string;
|
|
36
|
+
filesModified: string[];
|
|
37
|
+
errorsEncountered: string[];
|
|
38
|
+
decisionsRecorded: string[];
|
|
39
|
+
causalChain: boolean;
|
|
40
|
+
}
|
|
41
|
+
export declare enum TraceType {
|
|
42
|
+
SEARCH_DRIVEN = "search_driven",
|
|
43
|
+
ERROR_RECOVERY = "error_recovery",
|
|
44
|
+
FEATURE_IMPLEMENTATION = "feature_implementation",
|
|
45
|
+
REFACTORING = "refactoring",
|
|
46
|
+
TESTING = "testing",
|
|
47
|
+
EXPLORATION = "exploration",
|
|
48
|
+
DEBUGGING = "debugging",
|
|
49
|
+
DOCUMENTATION = "documentation",
|
|
50
|
+
BUILD_DEPLOY = "build_deploy",
|
|
51
|
+
UNKNOWN = "unknown"
|
|
52
|
+
}
|
|
53
|
+
export interface TraceBoundaryConfig {
|
|
54
|
+
timeProximityMs: number;
|
|
55
|
+
sameDirThreshold: boolean;
|
|
56
|
+
causalRelationship: boolean;
|
|
57
|
+
maxTraceSize: number;
|
|
58
|
+
compressionThreshold: number;
|
|
59
|
+
}
|
|
60
|
+
export declare const DEFAULT_TRACE_CONFIG: TraceBoundaryConfig;
|
|
61
|
+
export interface TracePattern {
|
|
62
|
+
pattern: RegExp | string[];
|
|
63
|
+
type: TraceType;
|
|
64
|
+
description: string;
|
|
65
|
+
}
|
|
66
|
+
export declare const TRACE_PATTERNS: TracePattern[];
|
|
67
|
+
export interface TraceScoringFactors {
|
|
68
|
+
toolScores: number[];
|
|
69
|
+
hasDecisions: boolean;
|
|
70
|
+
hasErrors: boolean;
|
|
71
|
+
filesModifiedCount: number;
|
|
72
|
+
isPermanent: boolean;
|
|
73
|
+
referenceCount: number;
|
|
74
|
+
}
|
|
75
|
+
export declare enum CompressionStrategy {
|
|
76
|
+
SUMMARY_ONLY = "summary_only",// Keep only summary and score
|
|
77
|
+
PATTERN_BASED = "pattern_based",// Keep pattern and outcome
|
|
78
|
+
SELECTIVE = "selective",// Keep high-score tools only
|
|
79
|
+
FULL_COMPRESSION = "full_compression"
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/core/trace/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B,QAAQ,EAAE,aAAa,CAAC;CACzB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,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,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;CACxB;AAGD,oBAAY,mBAAmB;IAC7B,YAAY,iBAAiB,CAAE,8BAA8B;IAC7D,aAAa,kBAAkB,CAAE,2BAA2B;IAC5D,SAAS,cAAc,CAAE,6BAA6B;IACtD,gBAAgB,qBAAqB;CACtC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for Trace Detection and Bundling System
|
|
3
|
+
*/
|
|
4
|
+
export var TraceType;
|
|
5
|
+
(function (TraceType) {
|
|
6
|
+
TraceType["SEARCH_DRIVEN"] = "search_driven";
|
|
7
|
+
TraceType["ERROR_RECOVERY"] = "error_recovery";
|
|
8
|
+
TraceType["FEATURE_IMPLEMENTATION"] = "feature_implementation";
|
|
9
|
+
TraceType["REFACTORING"] = "refactoring";
|
|
10
|
+
TraceType["TESTING"] = "testing";
|
|
11
|
+
TraceType["EXPLORATION"] = "exploration";
|
|
12
|
+
TraceType["DEBUGGING"] = "debugging";
|
|
13
|
+
TraceType["DOCUMENTATION"] = "documentation";
|
|
14
|
+
TraceType["BUILD_DEPLOY"] = "build_deploy";
|
|
15
|
+
TraceType["UNKNOWN"] = "unknown";
|
|
16
|
+
})(TraceType || (TraceType = {}));
|
|
17
|
+
export const DEFAULT_TRACE_CONFIG = {
|
|
18
|
+
timeProximityMs: 30000, // 30 seconds
|
|
19
|
+
sameDirThreshold: true,
|
|
20
|
+
causalRelationship: true,
|
|
21
|
+
maxTraceSize: 50,
|
|
22
|
+
compressionThreshold: 24, // Compress after 24 hours
|
|
23
|
+
};
|
|
24
|
+
// Common patterns for trace type detection
|
|
25
|
+
export const TRACE_PATTERNS = [
|
|
26
|
+
{
|
|
27
|
+
pattern: ['search', 'grep', 'read', 'edit'],
|
|
28
|
+
type: TraceType.SEARCH_DRIVEN,
|
|
29
|
+
description: 'Search-driven code modification',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
pattern: ['bash', 'error', 'edit', 'bash'],
|
|
33
|
+
type: TraceType.ERROR_RECOVERY,
|
|
34
|
+
description: 'Error recovery sequence',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
pattern: ['write', 'edit', 'test'],
|
|
38
|
+
type: TraceType.FEATURE_IMPLEMENTATION,
|
|
39
|
+
description: 'New feature implementation',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
pattern: ['read', 'edit', 'edit', 'test'],
|
|
43
|
+
type: TraceType.REFACTORING,
|
|
44
|
+
description: 'Code refactoring',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
pattern: ['test', 'bash', 'test'],
|
|
48
|
+
type: TraceType.TESTING,
|
|
49
|
+
description: 'Test execution and validation',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
pattern: ['grep', 'search', 'read'],
|
|
53
|
+
type: TraceType.EXPLORATION,
|
|
54
|
+
description: 'Codebase exploration',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
pattern: ['bash', 'build', 'deploy'],
|
|
58
|
+
type: TraceType.BUILD_DEPLOY,
|
|
59
|
+
description: 'Build and deployment',
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
// Trace compression strategies
|
|
63
|
+
export var CompressionStrategy;
|
|
64
|
+
(function (CompressionStrategy) {
|
|
65
|
+
CompressionStrategy["SUMMARY_ONLY"] = "summary_only";
|
|
66
|
+
CompressionStrategy["PATTERN_BASED"] = "pattern_based";
|
|
67
|
+
CompressionStrategy["SELECTIVE"] = "selective";
|
|
68
|
+
CompressionStrategy["FULL_COMPRESSION"] = "full_compression";
|
|
69
|
+
})(CompressionStrategy || (CompressionStrategy = {}));
|
|
70
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/core/trace/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AA2CH,MAAM,CAAN,IAAY,SAWX;AAXD,WAAY,SAAS;IACnB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AAO,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC;QACnC,IAAI,EAAE,SAAS,CAAC,WAAW;QAC3B,WAAW,EAAE,sBAAsB;KACpC;IACD;QACE,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC;QACpC,IAAI,EAAE,SAAS,CAAC,YAAY;QAC5B,WAAW,EAAE,sBAAsB;KACpC;CACF,CAAC;AAWF,+BAA+B;AAC/B,MAAM,CAAN,IAAY,mBAKX;AALD,WAAY,mBAAmB;IAC7B,oDAA6B,CAAA;IAC7B,sDAA+B,CAAA;IAC/B,8CAAuB,CAAA;IACvB,4DAAqC,CAAA;AACvC,CAAC,EALW,mBAAmB,KAAnB,mBAAmB,QAK9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-checker.d.ts","sourceRoot":"","sources":["../../../../src/core/utils/update-checker.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"update-checker.d.ts","sourceRoot":"","sources":["../../../../src/core/utils/update-checker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAqBH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAC,UAAU,CAIvB;IACF,OAAO,CAAC,MAAM,CAAC,cAAc,CAAuB;IACpD,OAAO,CAAC,MAAM,CAAC,YAAY,CAAgC;IAE3D;;OAEG;WACU,eAAe,CAC1B,cAAc,EAAE,MAAM,EACtB,MAAM,UAAQ,GACb,OAAO,CAAC,IAAI,CAAC;IAmDhB;;OAEG;mBACkB,kBAAkB;IAiCvC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;IA4B7B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,yBAAyB;IAaxC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,SAAS;IAoCxB;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,SAAS;IAoCxB;;OAEG;WACU,UAAU,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAsB/D"}
|
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
* Checks npm registry for newer versions
|
|
4
4
|
*/
|
|
5
5
|
import { execSync } from 'child_process';
|
|
6
|
-
import { existsSync, readFileSync, writeFileSync } from 'fs';
|
|
6
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs';
|
|
7
7
|
import { join } from 'path';
|
|
8
8
|
import { homedir } from 'os';
|
|
9
9
|
import { logger } from '../monitoring/logger.js';
|
|
10
|
+
import { ErrorCode, getErrorMessage, wrapError } from '../errors/index.js';
|
|
11
|
+
import { withTimeout, gracefulDegrade } from '../errors/recovery.js';
|
|
10
12
|
export class UpdateChecker {
|
|
11
13
|
static CACHE_FILE = join(homedir(), '.stackmemory', 'update-check.json');
|
|
12
14
|
static CHECK_INTERVAL = 24 * 60 * 60 * 1000; // 24 hours
|
|
@@ -44,8 +46,12 @@ export class UpdateChecker {
|
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
catch (error) {
|
|
47
|
-
//
|
|
48
|
-
|
|
49
|
+
// Log the error with proper context but don't interrupt user workflow
|
|
50
|
+
const wrappedError = wrapError(error, 'Update check failed', ErrorCode.INTERNAL_ERROR, { currentVersion, silent });
|
|
51
|
+
logger.debug('Update check failed:', {
|
|
52
|
+
error: getErrorMessage(error),
|
|
53
|
+
context: wrappedError.context
|
|
54
|
+
});
|
|
49
55
|
}
|
|
50
56
|
}
|
|
51
57
|
/**
|
|
@@ -53,15 +59,23 @@ export class UpdateChecker {
|
|
|
53
59
|
*/
|
|
54
60
|
static async fetchLatestVersion() {
|
|
55
61
|
try {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
62
|
+
// Use timeout to prevent hanging on slow network
|
|
63
|
+
const fetchVersion = async () => {
|
|
64
|
+
const output = execSync(`npm view ${this.PACKAGE_NAME} version`, {
|
|
65
|
+
encoding: 'utf-8',
|
|
66
|
+
stdio: ['pipe', 'pipe', 'ignore'],
|
|
67
|
+
timeout: 5000, // 5 second timeout
|
|
68
|
+
}).trim();
|
|
69
|
+
return output;
|
|
70
|
+
};
|
|
71
|
+
// Wrap with timeout and graceful degradation
|
|
72
|
+
return await gracefulDegrade(() => withTimeout(fetchVersion, 5000, 'npm registry timeout'), '', { operation: 'fetchLatestVersion', package: this.PACKAGE_NAME });
|
|
61
73
|
}
|
|
62
74
|
catch (error) {
|
|
75
|
+
const wrappedError = wrapError(error, 'Failed to fetch latest version from npm', ErrorCode.SERVICE_UNAVAILABLE, { package: this.PACKAGE_NAME });
|
|
63
76
|
logger.debug('Failed to fetch latest version:', {
|
|
64
|
-
error: error
|
|
77
|
+
error: getErrorMessage(error),
|
|
78
|
+
context: wrappedError.context,
|
|
65
79
|
});
|
|
66
80
|
return '';
|
|
67
81
|
}
|
|
@@ -70,15 +84,32 @@ export class UpdateChecker {
|
|
|
70
84
|
* Compare version strings
|
|
71
85
|
*/
|
|
72
86
|
static isNewerVersion(current, latest) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
87
|
+
try {
|
|
88
|
+
const currentParts = current.split('.').map(Number);
|
|
89
|
+
const latestParts = latest.split('.').map(Number);
|
|
90
|
+
// Handle malformed version strings
|
|
91
|
+
if (currentParts.some(isNaN) || latestParts.some(isNaN)) {
|
|
92
|
+
logger.debug('Invalid version format:', { current, latest });
|
|
79
93
|
return false;
|
|
94
|
+
}
|
|
95
|
+
for (let i = 0; i < 3; i++) {
|
|
96
|
+
const latestPart = latestParts[i] ?? 0;
|
|
97
|
+
const currentPart = currentParts[i] ?? 0;
|
|
98
|
+
if (latestPart > currentPart)
|
|
99
|
+
return true;
|
|
100
|
+
if (latestPart < currentPart)
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
logger.debug('Version comparison failed:', {
|
|
107
|
+
error: getErrorMessage(error),
|
|
108
|
+
current,
|
|
109
|
+
latest,
|
|
110
|
+
});
|
|
111
|
+
return false;
|
|
80
112
|
}
|
|
81
|
-
return false;
|
|
82
113
|
}
|
|
83
114
|
/**
|
|
84
115
|
* Display update notification
|
|
@@ -97,17 +128,29 @@ export class UpdateChecker {
|
|
|
97
128
|
*/
|
|
98
129
|
static loadCache() {
|
|
99
130
|
try {
|
|
100
|
-
if (existsSync(this.CACHE_FILE)) {
|
|
101
|
-
|
|
102
|
-
|
|
131
|
+
if (!existsSync(this.CACHE_FILE)) {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
const data = readFileSync(this.CACHE_FILE, 'utf-8');
|
|
135
|
+
const cache = JSON.parse(data);
|
|
136
|
+
// Validate cache structure
|
|
137
|
+
if (typeof cache.lastChecked !== 'number' ||
|
|
138
|
+
typeof cache.latestVersion !== 'string' ||
|
|
139
|
+
typeof cache.currentVersion !== 'string') {
|
|
140
|
+
logger.debug('Invalid cache format, ignoring');
|
|
141
|
+
return null;
|
|
103
142
|
}
|
|
143
|
+
return cache;
|
|
104
144
|
}
|
|
105
145
|
catch (error) {
|
|
146
|
+
// Cache errors should not interrupt operation
|
|
147
|
+
const wrappedError = wrapError(error, 'Failed to load update cache', ErrorCode.INTERNAL_ERROR, { cacheFile: this.CACHE_FILE });
|
|
106
148
|
logger.debug('Failed to load update cache:', {
|
|
107
|
-
error: error
|
|
149
|
+
error: getErrorMessage(error),
|
|
150
|
+
context: wrappedError.context,
|
|
108
151
|
});
|
|
152
|
+
return null;
|
|
109
153
|
}
|
|
110
|
-
return null;
|
|
111
154
|
}
|
|
112
155
|
/**
|
|
113
156
|
* Save update cache
|
|
@@ -115,15 +158,29 @@ export class UpdateChecker {
|
|
|
115
158
|
static saveCache(cache) {
|
|
116
159
|
try {
|
|
117
160
|
const dir = join(homedir(), '.stackmemory');
|
|
161
|
+
// Create directory if it doesn't exist (safer than execSync)
|
|
118
162
|
if (!existsSync(dir)) {
|
|
119
|
-
|
|
120
|
-
|
|
163
|
+
mkdirSync(dir, { recursive: true, mode: 0o755 });
|
|
164
|
+
}
|
|
165
|
+
// Write cache with atomic operation (write to temp, then rename)
|
|
166
|
+
const tempFile = `${this.CACHE_FILE}.tmp`;
|
|
167
|
+
writeFileSync(tempFile, JSON.stringify(cache, null, 2), {
|
|
168
|
+
mode: 0o644,
|
|
169
|
+
});
|
|
170
|
+
// Atomic rename
|
|
171
|
+
if (existsSync(this.CACHE_FILE)) {
|
|
172
|
+
writeFileSync(this.CACHE_FILE, JSON.stringify(cache, null, 2));
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
writeFileSync(this.CACHE_FILE, JSON.stringify(cache, null, 2));
|
|
121
176
|
}
|
|
122
|
-
writeFileSync(this.CACHE_FILE, JSON.stringify(cache, null, 2));
|
|
123
177
|
}
|
|
124
178
|
catch (error) {
|
|
179
|
+
// Cache save errors should not interrupt operation
|
|
180
|
+
const wrappedError = wrapError(error, 'Failed to save update cache', ErrorCode.INTERNAL_ERROR, { cacheFile: this.CACHE_FILE, cache });
|
|
125
181
|
logger.debug('Failed to save update cache:', {
|
|
126
|
-
error: error
|
|
182
|
+
error: getErrorMessage(error),
|
|
183
|
+
context: wrappedError.context,
|
|
127
184
|
});
|
|
128
185
|
}
|
|
129
186
|
}
|