@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,93 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
3
|
-
import { dirname as __pathDirname } from 'path';
|
|
4
|
-
const __filename = __fileURLToPath(import.meta.url);
|
|
5
|
-
const __dirname = __pathDirname(__filename);
|
|
6
|
-
import { existsSync, readFileSync, watchFile, writeFileSync } from "fs";
|
|
7
|
-
import { join } from "path";
|
|
8
|
-
import { homedir } from "os";
|
|
9
|
-
import { execSync } from "child_process";
|
|
10
|
-
const RESPONSE_PATH = join(
|
|
11
|
-
homedir(),
|
|
12
|
-
".stackmemory",
|
|
13
|
-
"sms-latest-response.json"
|
|
14
|
-
);
|
|
15
|
-
const SIGNAL_PATH = join(homedir(), ".stackmemory", "sms-signal.txt");
|
|
16
|
-
let lastProcessedTimestamp = "";
|
|
17
|
-
function checkForResponse() {
|
|
18
|
-
try {
|
|
19
|
-
if (existsSync(RESPONSE_PATH)) {
|
|
20
|
-
const data = JSON.parse(
|
|
21
|
-
readFileSync(RESPONSE_PATH, "utf8")
|
|
22
|
-
);
|
|
23
|
-
if (data.timestamp !== lastProcessedTimestamp) {
|
|
24
|
-
lastProcessedTimestamp = data.timestamp;
|
|
25
|
-
return data;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
} catch {
|
|
29
|
-
}
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
function triggerNotification(response) {
|
|
33
|
-
const message = `SMS Response: "${response.response}"`;
|
|
34
|
-
try {
|
|
35
|
-
execSync(
|
|
36
|
-
`osascript -e 'display notification "${message}" with title "StackMemory"'`,
|
|
37
|
-
{
|
|
38
|
-
stdio: "ignore"
|
|
39
|
-
}
|
|
40
|
-
);
|
|
41
|
-
} catch {
|
|
42
|
-
}
|
|
43
|
-
process.stdout.write("\x07");
|
|
44
|
-
try {
|
|
45
|
-
writeFileSync(
|
|
46
|
-
SIGNAL_PATH,
|
|
47
|
-
JSON.stringify({
|
|
48
|
-
type: "sms_response",
|
|
49
|
-
response: response.response,
|
|
50
|
-
promptId: response.promptId,
|
|
51
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
52
|
-
})
|
|
53
|
-
);
|
|
54
|
-
} catch {
|
|
55
|
-
}
|
|
56
|
-
console.log(`
|
|
57
|
-
[SMS] User responded: "${response.response}"`);
|
|
58
|
-
console.log(`[SMS] Run: stackmemory notify run-actions
|
|
59
|
-
`);
|
|
60
|
-
}
|
|
61
|
-
function startResponseWatcher(intervalMs = 2e3) {
|
|
62
|
-
console.log("[SMS Watcher] Watching for responses...");
|
|
63
|
-
console.log("[SMS Watcher] Press Ctrl+C to stop\n");
|
|
64
|
-
const initial = checkForResponse();
|
|
65
|
-
if (initial) {
|
|
66
|
-
triggerNotification(initial);
|
|
67
|
-
}
|
|
68
|
-
setInterval(() => {
|
|
69
|
-
const response = checkForResponse();
|
|
70
|
-
if (response) {
|
|
71
|
-
triggerNotification(response);
|
|
72
|
-
}
|
|
73
|
-
}, intervalMs);
|
|
74
|
-
}
|
|
75
|
-
function startFileWatcher() {
|
|
76
|
-
console.log("[SMS Watcher] Watching for responses (file mode)...");
|
|
77
|
-
watchFile(RESPONSE_PATH, { interval: 1e3 }, () => {
|
|
78
|
-
const response = checkForResponse();
|
|
79
|
-
if (response) {
|
|
80
|
-
triggerNotification(response);
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
if (process.argv[1]?.includes("sms-watcher")) {
|
|
85
|
-
startResponseWatcher();
|
|
86
|
-
}
|
|
87
|
-
export {
|
|
88
|
-
checkForResponse,
|
|
89
|
-
startFileWatcher,
|
|
90
|
-
startResponseWatcher,
|
|
91
|
-
triggerNotification
|
|
92
|
-
};
|
|
93
|
-
//# sourceMappingURL=sms-watcher.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/hooks/sms-watcher.ts"],
|
|
4
|
-
"sourcesContent": ["#!/usr/bin/env node\n/**\n * SMS Response Watcher\n * Watches for incoming SMS/WhatsApp responses and triggers notifications\n *\n * Run in background: stackmemory notify watch-responses &\n */\n\nimport { existsSync, readFileSync, watchFile, writeFileSync } from 'fs';\nimport { join } from 'path';\nimport { homedir } from 'os';\nimport { execSync } from 'child_process';\n\nconst RESPONSE_PATH = join(\n homedir(),\n '.stackmemory',\n 'sms-latest-response.json'\n);\nconst SIGNAL_PATH = join(homedir(), '.stackmemory', 'sms-signal.txt');\n\ninterface SMSResponse {\n promptId: string;\n response: string;\n timestamp: string;\n}\n\nlet lastProcessedTimestamp = '';\n\nfunction checkForResponse(): SMSResponse | null {\n try {\n if (existsSync(RESPONSE_PATH)) {\n const data = JSON.parse(\n readFileSync(RESPONSE_PATH, 'utf8')\n ) as SMSResponse;\n\n // Only process new responses\n if (data.timestamp !== lastProcessedTimestamp) {\n lastProcessedTimestamp = data.timestamp;\n return data;\n }\n }\n } catch {\n // Ignore errors\n }\n return null;\n}\n\nfunction triggerNotification(response: SMSResponse): void {\n const message = `SMS Response: \"${response.response}\"`;\n\n // macOS notification\n try {\n execSync(\n `osascript -e 'display notification \"${message}\" with title \"StackMemory\"'`,\n {\n stdio: 'ignore',\n }\n );\n } catch {\n // Ignore if not on macOS\n }\n\n // Terminal bell\n process.stdout.write('\\x07');\n\n // Write to signal file (for other processes to detect)\n try {\n writeFileSync(\n SIGNAL_PATH,\n JSON.stringify({\n type: 'sms_response',\n response: response.response,\n promptId: response.promptId,\n timestamp: new Date().toISOString(),\n })\n );\n } catch {\n // Ignore\n }\n\n // Output to terminal\n console.log(`\\n[SMS] User responded: \"${response.response}\"`);\n console.log(`[SMS] Run: stackmemory notify run-actions\\n`);\n}\n\nexport function startResponseWatcher(intervalMs: number = 2000): void {\n console.log('[SMS Watcher] Watching for responses...');\n console.log('[SMS Watcher] Press Ctrl+C to stop\\n');\n\n // Initial check\n const initial = checkForResponse();\n if (initial) {\n triggerNotification(initial);\n }\n\n // Poll for changes\n setInterval(() => {\n const response = checkForResponse();\n if (response) {\n triggerNotification(response);\n }\n }, intervalMs);\n}\n\n// Also watch file for immediate notification\nexport function startFileWatcher(): void {\n console.log('[SMS Watcher] Watching for responses (file mode)...');\n\n watchFile(RESPONSE_PATH, { interval: 1000 }, () => {\n const response = checkForResponse();\n if (response) {\n triggerNotification(response);\n }\n });\n}\n\n// CLI entry\nif (process.argv[1]?.includes('sms-watcher')) {\n startResponseWatcher();\n}\n\nexport { checkForResponse, triggerNotification };\n"],
|
|
5
|
-
"mappings": ";;;;;AAQA,SAAS,YAAY,cAAc,WAAW,qBAAqB;AACnE,SAAS,YAAY;AACrB,SAAS,eAAe;AACxB,SAAS,gBAAgB;AAEzB,MAAM,gBAAgB;AAAA,EACpB,QAAQ;AAAA,EACR;AAAA,EACA;AACF;AACA,MAAM,cAAc,KAAK,QAAQ,GAAG,gBAAgB,gBAAgB;AAQpE,IAAI,yBAAyB;AAE7B,SAAS,mBAAuC;AAC9C,MAAI;AACF,QAAI,WAAW,aAAa,GAAG;AAC7B,YAAM,OAAO,KAAK;AAAA,QAChB,aAAa,eAAe,MAAM;AAAA,MACpC;AAGA,UAAI,KAAK,cAAc,wBAAwB;AAC7C,iCAAyB,KAAK;AAC9B,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF,QAAQ;AAAA,EAER;AACA,SAAO;AACT;AAEA,SAAS,oBAAoB,UAA6B;AACxD,QAAM,UAAU,kBAAkB,SAAS,QAAQ;AAGnD,MAAI;AACF;AAAA,MACE,uCAAuC,OAAO;AAAA,MAC9C;AAAA,QACE,OAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF,QAAQ;AAAA,EAER;AAGA,UAAQ,OAAO,MAAM,MAAM;AAG3B,MAAI;AACF;AAAA,MACE;AAAA,MACA,KAAK,UAAU;AAAA,QACb,MAAM;AAAA,QACN,UAAU,SAAS;AAAA,QACnB,UAAU,SAAS;AAAA,QACnB,YAAW,oBAAI,KAAK,GAAE,YAAY;AAAA,MACpC,CAAC;AAAA,IACH;AAAA,EACF,QAAQ;AAAA,EAER;AAGA,UAAQ,IAAI;AAAA,yBAA4B,SAAS,QAAQ,GAAG;AAC5D,UAAQ,IAAI;AAAA,CAA6C;AAC3D;AAEO,SAAS,qBAAqB,aAAqB,KAAY;AACpE,UAAQ,IAAI,yCAAyC;AACrD,UAAQ,IAAI,sCAAsC;AAGlD,QAAM,UAAU,iBAAiB;AACjC,MAAI,SAAS;AACX,wBAAoB,OAAO;AAAA,EAC7B;AAGA,cAAY,MAAM;AAChB,UAAM,WAAW,iBAAiB;AAClC,QAAI,UAAU;AACZ,0BAAoB,QAAQ;AAAA,IAC9B;AAAA,EACF,GAAG,UAAU;AACf;AAGO,SAAS,mBAAyB;AACvC,UAAQ,IAAI,qDAAqD;AAEjE,YAAU,eAAe,EAAE,UAAU,IAAK,GAAG,MAAM;AACjD,UAAM,WAAW,iBAAiB;AAClC,QAAI,UAAU;AACZ,0BAAoB,QAAQ;AAAA,IAC9B;AAAA,EACF,CAAC;AACH;AAGA,IAAI,QAAQ,KAAK,CAAC,GAAG,SAAS,aAAa,GAAG;AAC5C,uBAAqB;AACvB;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,555 +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 { createServer } from "http";
|
|
6
|
-
import { parse as parseUrl } from "url";
|
|
7
|
-
import { existsSync, readFileSync } from "fs";
|
|
8
|
-
import { join } from "path";
|
|
9
|
-
import { homedir } from "os";
|
|
10
|
-
import { createHmac } from "crypto";
|
|
11
|
-
import { execFileSync } from "child_process";
|
|
12
|
-
import {
|
|
13
|
-
processIncomingResponse,
|
|
14
|
-
loadSMSConfig,
|
|
15
|
-
cleanupExpiredPrompts,
|
|
16
|
-
sendNotification
|
|
17
|
-
} from "./sms-notify.js";
|
|
18
|
-
import {
|
|
19
|
-
queueAction,
|
|
20
|
-
executeActionSafe,
|
|
21
|
-
cleanupOldActions
|
|
22
|
-
} from "./sms-action-runner.js";
|
|
23
|
-
import {
|
|
24
|
-
isCommand,
|
|
25
|
-
processCommand,
|
|
26
|
-
sendCommandResponse
|
|
27
|
-
} from "./whatsapp-commands.js";
|
|
28
|
-
import { writeFileSecure, ensureSecureDir } from "./secure-fs.js";
|
|
29
|
-
import {
|
|
30
|
-
logWebhookRequest,
|
|
31
|
-
logRateLimit,
|
|
32
|
-
logSignatureInvalid,
|
|
33
|
-
logBodyTooLarge,
|
|
34
|
-
logContentTypeInvalid,
|
|
35
|
-
logActionAllowed,
|
|
36
|
-
logActionBlocked,
|
|
37
|
-
logCleanup
|
|
38
|
-
} from "./security-logger.js";
|
|
39
|
-
const CLEANUP_INTERVAL_MS = 5 * 60 * 1e3;
|
|
40
|
-
const MAX_SMS_BODY_LENGTH = 1e3;
|
|
41
|
-
const MAX_PHONE_LENGTH = 50;
|
|
42
|
-
const MAX_BODY_SIZE = 50 * 1024;
|
|
43
|
-
const RATE_LIMIT_WINDOW_MS = 60 * 1e3;
|
|
44
|
-
const RATE_LIMIT_MAX_REQUESTS = 30;
|
|
45
|
-
const ACTION_TIMEOUT_MS = 6e4;
|
|
46
|
-
async function executeActionWithTimeout(action, response) {
|
|
47
|
-
return Promise.race([
|
|
48
|
-
executeActionSafe(action, response),
|
|
49
|
-
new Promise(
|
|
50
|
-
(_, reject) => setTimeout(
|
|
51
|
-
() => reject(new Error(`Action timed out after ${ACTION_TIMEOUT_MS}ms`)),
|
|
52
|
-
ACTION_TIMEOUT_MS
|
|
53
|
-
)
|
|
54
|
-
)
|
|
55
|
-
]).catch((error) => ({
|
|
56
|
-
success: false,
|
|
57
|
-
error: error instanceof Error ? error.message : String(error)
|
|
58
|
-
}));
|
|
59
|
-
}
|
|
60
|
-
const RATE_LIMIT_PATH = join(homedir(), ".stackmemory", "rate-limits.json");
|
|
61
|
-
let rateLimitCache = {};
|
|
62
|
-
let rateLimitCacheDirty = false;
|
|
63
|
-
function loadRateLimits() {
|
|
64
|
-
try {
|
|
65
|
-
if (existsSync(RATE_LIMIT_PATH)) {
|
|
66
|
-
const data = JSON.parse(readFileSync(RATE_LIMIT_PATH, "utf8"));
|
|
67
|
-
const now = Date.now();
|
|
68
|
-
const cleaned = {};
|
|
69
|
-
for (const [ip, record] of Object.entries(data)) {
|
|
70
|
-
const r = record;
|
|
71
|
-
if (r.resetTime > now) {
|
|
72
|
-
cleaned[ip] = r;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return cleaned;
|
|
76
|
-
}
|
|
77
|
-
} catch {
|
|
78
|
-
}
|
|
79
|
-
return {};
|
|
80
|
-
}
|
|
81
|
-
function saveRateLimits() {
|
|
82
|
-
if (!rateLimitCacheDirty) return;
|
|
83
|
-
try {
|
|
84
|
-
ensureSecureDir(join(homedir(), ".stackmemory"));
|
|
85
|
-
writeFileSecure(RATE_LIMIT_PATH, JSON.stringify(rateLimitCache));
|
|
86
|
-
rateLimitCacheDirty = false;
|
|
87
|
-
} catch {
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
setInterval(saveRateLimits, 3e4);
|
|
91
|
-
rateLimitCache = loadRateLimits();
|
|
92
|
-
function checkRateLimit(ip) {
|
|
93
|
-
const now = Date.now();
|
|
94
|
-
const record = rateLimitCache[ip];
|
|
95
|
-
if (!record || now > record.resetTime) {
|
|
96
|
-
rateLimitCache[ip] = { count: 1, resetTime: now + RATE_LIMIT_WINDOW_MS };
|
|
97
|
-
rateLimitCacheDirty = true;
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
if (record.count >= RATE_LIMIT_MAX_REQUESTS) {
|
|
101
|
-
return false;
|
|
102
|
-
}
|
|
103
|
-
record.count++;
|
|
104
|
-
rateLimitCacheDirty = true;
|
|
105
|
-
return true;
|
|
106
|
-
}
|
|
107
|
-
function verifyTwilioSignature(url, params, signature) {
|
|
108
|
-
const authToken = process.env["TWILIO_AUTH_TOKEN"];
|
|
109
|
-
if (!authToken) {
|
|
110
|
-
const isDev = process.env["NODE_ENV"] === "development" || process.env["SKIP_TWILIO_VERIFICATION"] === "true";
|
|
111
|
-
if (isDev) {
|
|
112
|
-
console.warn(
|
|
113
|
-
"[sms-webhook] TWILIO_AUTH_TOKEN not set, skipping verification (dev mode)"
|
|
114
|
-
);
|
|
115
|
-
return true;
|
|
116
|
-
}
|
|
117
|
-
console.error(
|
|
118
|
-
"[sms-webhook] TWILIO_AUTH_TOKEN not set - rejecting request in production"
|
|
119
|
-
);
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
const sortedKeys = Object.keys(params).sort();
|
|
123
|
-
let data = url;
|
|
124
|
-
for (const key of sortedKeys) {
|
|
125
|
-
data += key + params[key];
|
|
126
|
-
}
|
|
127
|
-
const hmac = createHmac("sha1", authToken);
|
|
128
|
-
hmac.update(data);
|
|
129
|
-
const expectedSignature = hmac.digest("base64");
|
|
130
|
-
return signature === expectedSignature;
|
|
131
|
-
}
|
|
132
|
-
function parseFormData(body) {
|
|
133
|
-
const params = new URLSearchParams(body);
|
|
134
|
-
const result = {};
|
|
135
|
-
params.forEach((value, key) => {
|
|
136
|
-
result[key] = value;
|
|
137
|
-
});
|
|
138
|
-
return result;
|
|
139
|
-
}
|
|
140
|
-
function storeLatestResponse(promptId, response, action) {
|
|
141
|
-
ensureSecureDir(join(homedir(), ".stackmemory"));
|
|
142
|
-
const responsePath = join(
|
|
143
|
-
homedir(),
|
|
144
|
-
".stackmemory",
|
|
145
|
-
"sms-latest-response.json"
|
|
146
|
-
);
|
|
147
|
-
writeFileSecure(
|
|
148
|
-
responsePath,
|
|
149
|
-
JSON.stringify({
|
|
150
|
-
promptId,
|
|
151
|
-
response,
|
|
152
|
-
action,
|
|
153
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
154
|
-
})
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
function storeIncomingRequest(from, message) {
|
|
158
|
-
ensureSecureDir(join(homedir(), ".stackmemory"));
|
|
159
|
-
const requestPath = join(
|
|
160
|
-
homedir(),
|
|
161
|
-
".stackmemory",
|
|
162
|
-
"sms-incoming-request.json"
|
|
163
|
-
);
|
|
164
|
-
writeFileSecure(
|
|
165
|
-
requestPath,
|
|
166
|
-
JSON.stringify({
|
|
167
|
-
from,
|
|
168
|
-
message,
|
|
169
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
170
|
-
processed: false
|
|
171
|
-
})
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
function getIncomingRequest() {
|
|
175
|
-
const requestPath = join(
|
|
176
|
-
homedir(),
|
|
177
|
-
".stackmemory",
|
|
178
|
-
"sms-incoming-request.json"
|
|
179
|
-
);
|
|
180
|
-
if (!existsSync(requestPath)) {
|
|
181
|
-
return null;
|
|
182
|
-
}
|
|
183
|
-
try {
|
|
184
|
-
const data = JSON.parse(readFileSync(requestPath, "utf-8"));
|
|
185
|
-
if (data.processed) {
|
|
186
|
-
return null;
|
|
187
|
-
}
|
|
188
|
-
return data;
|
|
189
|
-
} catch {
|
|
190
|
-
return null;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
function markRequestProcessed() {
|
|
194
|
-
const requestPath = join(
|
|
195
|
-
homedir(),
|
|
196
|
-
".stackmemory",
|
|
197
|
-
"sms-incoming-request.json"
|
|
198
|
-
);
|
|
199
|
-
if (!existsSync(requestPath)) {
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
try {
|
|
203
|
-
const data = JSON.parse(readFileSync(requestPath, "utf-8"));
|
|
204
|
-
data.processed = true;
|
|
205
|
-
writeFileSecure(requestPath, JSON.stringify(data));
|
|
206
|
-
} catch {
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
async function handleSMSWebhook(payload) {
|
|
210
|
-
const { From, Body } = payload;
|
|
211
|
-
if (Body && Body.length > MAX_SMS_BODY_LENGTH) {
|
|
212
|
-
console.log(`[sms-webhook] Body too long: ${Body.length} chars`);
|
|
213
|
-
return { response: "Message too long. Max 1000 characters." };
|
|
214
|
-
}
|
|
215
|
-
if (From && From.length > MAX_PHONE_LENGTH) {
|
|
216
|
-
console.log(
|
|
217
|
-
`[sms-webhook] Phone number too long: ${From.length} chars (max ${MAX_PHONE_LENGTH}): ${From.substring(0, 30)}...`
|
|
218
|
-
);
|
|
219
|
-
return { response: "Invalid phone number." };
|
|
220
|
-
}
|
|
221
|
-
console.log(`[sms-webhook] Received from ${From}: ${Body}`);
|
|
222
|
-
if (isCommand(Body)) {
|
|
223
|
-
console.log(`[sms-webhook] Processing command: ${Body}`);
|
|
224
|
-
const cmdResult = await processCommand(From, Body);
|
|
225
|
-
if (cmdResult.handled) {
|
|
226
|
-
if (cmdResult.response) {
|
|
227
|
-
sendCommandResponse(cmdResult.response).catch(console.error);
|
|
228
|
-
}
|
|
229
|
-
return {
|
|
230
|
-
response: cmdResult.response || "Command processed",
|
|
231
|
-
action: cmdResult.action,
|
|
232
|
-
queued: false
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
const result = processIncomingResponse(From, Body);
|
|
237
|
-
if (!result.matched) {
|
|
238
|
-
if (result.prompt) {
|
|
239
|
-
return {
|
|
240
|
-
response: `Invalid response. Expected: ${result.prompt.options.map((o) => o.key).join(", ")}`
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
storeIncomingRequest(From, Body);
|
|
244
|
-
console.log(
|
|
245
|
-
`[sms-webhook] Stored new request from ${From}: ${Body.substring(0, 50)}...`
|
|
246
|
-
);
|
|
247
|
-
return { response: "Got it! Your request has been queued." };
|
|
248
|
-
}
|
|
249
|
-
storeLatestResponse(
|
|
250
|
-
result.prompt?.id || "unknown",
|
|
251
|
-
result.response || Body,
|
|
252
|
-
result.action
|
|
253
|
-
);
|
|
254
|
-
triggerResponseNotification(result.response || Body);
|
|
255
|
-
if (result.action) {
|
|
256
|
-
console.log(`[sms-webhook] Executing action: ${result.action}`);
|
|
257
|
-
const actionResult = await executeActionWithTimeout(
|
|
258
|
-
result.action,
|
|
259
|
-
result.response || Body
|
|
260
|
-
);
|
|
261
|
-
if (actionResult.success) {
|
|
262
|
-
logActionAllowed("sms-webhook", result.action);
|
|
263
|
-
console.log(
|
|
264
|
-
`[sms-webhook] Action completed: ${(actionResult.output || "").substring(0, 200)}`
|
|
265
|
-
);
|
|
266
|
-
return {
|
|
267
|
-
response: `Done! Action executed successfully.`,
|
|
268
|
-
action: result.action,
|
|
269
|
-
queued: false
|
|
270
|
-
};
|
|
271
|
-
} else {
|
|
272
|
-
logActionBlocked(
|
|
273
|
-
"sms-webhook",
|
|
274
|
-
result.action,
|
|
275
|
-
actionResult.error || "unknown"
|
|
276
|
-
);
|
|
277
|
-
console.log(`[sms-webhook] Action failed: ${actionResult.error}`);
|
|
278
|
-
queueAction(
|
|
279
|
-
result.prompt?.id || "unknown",
|
|
280
|
-
result.response || Body,
|
|
281
|
-
result.action
|
|
282
|
-
);
|
|
283
|
-
return {
|
|
284
|
-
response: `Action failed, queued for retry: ${(actionResult.error || "").substring(0, 50)}`,
|
|
285
|
-
action: result.action,
|
|
286
|
-
queued: true
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
return {
|
|
291
|
-
response: `Received: ${result.response}. Next action will be triggered.`
|
|
292
|
-
};
|
|
293
|
-
}
|
|
294
|
-
function escapeAppleScript(str) {
|
|
295
|
-
return str.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\n").replace(/\r/g, "\\r").substring(0, 200);
|
|
296
|
-
}
|
|
297
|
-
function triggerResponseNotification(response) {
|
|
298
|
-
const safeMessage = escapeAppleScript(`SMS Response: ${response}`);
|
|
299
|
-
try {
|
|
300
|
-
execFileSync(
|
|
301
|
-
"osascript",
|
|
302
|
-
[
|
|
303
|
-
"-e",
|
|
304
|
-
`display notification "${safeMessage}" with title "StackMemory" sound name "Glass"`
|
|
305
|
-
],
|
|
306
|
-
{ stdio: "ignore", timeout: 5e3 }
|
|
307
|
-
);
|
|
308
|
-
} catch {
|
|
309
|
-
}
|
|
310
|
-
try {
|
|
311
|
-
const signalPath = join(homedir(), ".stackmemory", "sms-signal.txt");
|
|
312
|
-
writeFileSecure(
|
|
313
|
-
signalPath,
|
|
314
|
-
JSON.stringify({
|
|
315
|
-
type: "sms_response",
|
|
316
|
-
response,
|
|
317
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
318
|
-
})
|
|
319
|
-
);
|
|
320
|
-
} catch {
|
|
321
|
-
}
|
|
322
|
-
console.log(`
|
|
323
|
-
*** SMS RESPONSE RECEIVED: "${response}" ***`);
|
|
324
|
-
console.log(`*** Run: stackmemory notify run-actions ***
|
|
325
|
-
`);
|
|
326
|
-
}
|
|
327
|
-
function twimlResponse(message) {
|
|
328
|
-
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
329
|
-
<Response>
|
|
330
|
-
<Message>${escapeXml(message)}</Message>
|
|
331
|
-
</Response>`;
|
|
332
|
-
}
|
|
333
|
-
function escapeXml(str) {
|
|
334
|
-
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
335
|
-
}
|
|
336
|
-
function startWebhookServer(port = 3456) {
|
|
337
|
-
const server = createServer(
|
|
338
|
-
async (req, res) => {
|
|
339
|
-
const url = parseUrl(req.url || "/", true);
|
|
340
|
-
if (url.pathname === "/health") {
|
|
341
|
-
res.writeHead(200, { "Content-Type": "application/json" });
|
|
342
|
-
res.end(JSON.stringify({ status: "ok" }));
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
if ((url.pathname === "/sms" || url.pathname === "/sms/incoming" || url.pathname === "/webhook") && req.method === "POST") {
|
|
346
|
-
const clientIp = req.socket.remoteAddress || "unknown";
|
|
347
|
-
logWebhookRequest(
|
|
348
|
-
"sms-webhook",
|
|
349
|
-
req.method || "POST",
|
|
350
|
-
url.pathname || "/sms",
|
|
351
|
-
clientIp
|
|
352
|
-
);
|
|
353
|
-
if (!checkRateLimit(clientIp)) {
|
|
354
|
-
logRateLimit("sms-webhook", clientIp);
|
|
355
|
-
res.writeHead(429, {
|
|
356
|
-
"Content-Type": "text/xml",
|
|
357
|
-
"Retry-After": "60"
|
|
358
|
-
});
|
|
359
|
-
res.end(twimlResponse("Too many requests. Please try again later."));
|
|
360
|
-
return;
|
|
361
|
-
}
|
|
362
|
-
const contentType = req.headers["content-type"] || "";
|
|
363
|
-
if (!contentType.includes("application/x-www-form-urlencoded")) {
|
|
364
|
-
logContentTypeInvalid("sms-webhook", contentType, clientIp);
|
|
365
|
-
res.writeHead(400, { "Content-Type": "text/xml" });
|
|
366
|
-
res.end(twimlResponse("Invalid content type"));
|
|
367
|
-
return;
|
|
368
|
-
}
|
|
369
|
-
let body = "";
|
|
370
|
-
let bodyTooLarge = false;
|
|
371
|
-
req.on("data", (chunk) => {
|
|
372
|
-
body += chunk;
|
|
373
|
-
if (body.length > MAX_BODY_SIZE) {
|
|
374
|
-
bodyTooLarge = true;
|
|
375
|
-
logBodyTooLarge("sms-webhook", body.length, clientIp);
|
|
376
|
-
req.destroy();
|
|
377
|
-
}
|
|
378
|
-
});
|
|
379
|
-
req.on("end", async () => {
|
|
380
|
-
if (bodyTooLarge) {
|
|
381
|
-
res.writeHead(413, { "Content-Type": "text/xml" });
|
|
382
|
-
res.end(twimlResponse("Request too large"));
|
|
383
|
-
return;
|
|
384
|
-
}
|
|
385
|
-
try {
|
|
386
|
-
const payload = parseFormData(
|
|
387
|
-
body
|
|
388
|
-
);
|
|
389
|
-
const twilioSignature = req.headers["x-twilio-signature"];
|
|
390
|
-
const webhookUrl = `${req.headers["x-forwarded-proto"] || "http"}://${req.headers.host}${req.url}`;
|
|
391
|
-
if (twilioSignature && !verifyTwilioSignature(
|
|
392
|
-
webhookUrl,
|
|
393
|
-
payload,
|
|
394
|
-
twilioSignature
|
|
395
|
-
)) {
|
|
396
|
-
logSignatureInvalid("sms-webhook", clientIp);
|
|
397
|
-
console.error("[sms-webhook] Invalid Twilio signature");
|
|
398
|
-
res.writeHead(401, { "Content-Type": "text/xml" });
|
|
399
|
-
res.end(twimlResponse("Unauthorized"));
|
|
400
|
-
return;
|
|
401
|
-
}
|
|
402
|
-
const result = await handleSMSWebhook(payload);
|
|
403
|
-
res.writeHead(200, { "Content-Type": "text/xml" });
|
|
404
|
-
res.end(twimlResponse(result.response));
|
|
405
|
-
} catch (err) {
|
|
406
|
-
console.error("[sms-webhook] Error:", err);
|
|
407
|
-
res.writeHead(500, { "Content-Type": "text/xml" });
|
|
408
|
-
res.end(twimlResponse("Error processing message"));
|
|
409
|
-
}
|
|
410
|
-
});
|
|
411
|
-
return;
|
|
412
|
-
}
|
|
413
|
-
if (url.pathname === "/sms/status" && req.method === "POST") {
|
|
414
|
-
let body = "";
|
|
415
|
-
req.on("data", (chunk) => {
|
|
416
|
-
body += chunk;
|
|
417
|
-
});
|
|
418
|
-
req.on("end", () => {
|
|
419
|
-
try {
|
|
420
|
-
const payload = parseFormData(body);
|
|
421
|
-
console.log(
|
|
422
|
-
`[sms-webhook] Status update: ${payload["MessageSid"]} -> ${payload["MessageStatus"]}`
|
|
423
|
-
);
|
|
424
|
-
const statusPath = join(
|
|
425
|
-
homedir(),
|
|
426
|
-
".stackmemory",
|
|
427
|
-
"sms-status.json"
|
|
428
|
-
);
|
|
429
|
-
const statuses = existsSync(statusPath) ? JSON.parse(readFileSync(statusPath, "utf8")) : {};
|
|
430
|
-
statuses[payload["MessageSid"]] = payload["MessageStatus"];
|
|
431
|
-
writeFileSecure(statusPath, JSON.stringify(statuses, null, 2));
|
|
432
|
-
res.writeHead(200, { "Content-Type": "text/plain" });
|
|
433
|
-
res.end("OK");
|
|
434
|
-
} catch (err) {
|
|
435
|
-
console.error("[sms-webhook] Status error:", err);
|
|
436
|
-
res.writeHead(500);
|
|
437
|
-
res.end("Error");
|
|
438
|
-
}
|
|
439
|
-
});
|
|
440
|
-
return;
|
|
441
|
-
}
|
|
442
|
-
if (url.pathname === "/status") {
|
|
443
|
-
const config = loadSMSConfig();
|
|
444
|
-
res.writeHead(200, { "Content-Type": "application/json" });
|
|
445
|
-
res.end(
|
|
446
|
-
JSON.stringify({
|
|
447
|
-
enabled: config.enabled,
|
|
448
|
-
pendingPrompts: config.pendingPrompts.length
|
|
449
|
-
})
|
|
450
|
-
);
|
|
451
|
-
return;
|
|
452
|
-
}
|
|
453
|
-
if (url.pathname === "/request" && req.method === "GET") {
|
|
454
|
-
const request = getIncomingRequest();
|
|
455
|
-
res.writeHead(200, { "Content-Type": "application/json" });
|
|
456
|
-
res.end(JSON.stringify({ request }));
|
|
457
|
-
return;
|
|
458
|
-
}
|
|
459
|
-
if (url.pathname === "/request/ack" && req.method === "POST") {
|
|
460
|
-
markRequestProcessed();
|
|
461
|
-
res.writeHead(200, { "Content-Type": "application/json" });
|
|
462
|
-
res.end(JSON.stringify({ success: true }));
|
|
463
|
-
return;
|
|
464
|
-
}
|
|
465
|
-
if (url.pathname === "/send" && req.method === "POST") {
|
|
466
|
-
let body = "";
|
|
467
|
-
req.on("data", (chunk) => {
|
|
468
|
-
body += chunk;
|
|
469
|
-
if (body.length > MAX_BODY_SIZE) {
|
|
470
|
-
req.destroy();
|
|
471
|
-
}
|
|
472
|
-
});
|
|
473
|
-
req.on("end", async () => {
|
|
474
|
-
try {
|
|
475
|
-
const payload = JSON.parse(body);
|
|
476
|
-
const message = payload.message || payload.body || "";
|
|
477
|
-
const title = payload.title || "Notification";
|
|
478
|
-
const type = payload.type || "custom";
|
|
479
|
-
if (!message) {
|
|
480
|
-
res.writeHead(400, { "Content-Type": "application/json" });
|
|
481
|
-
res.end(
|
|
482
|
-
JSON.stringify({ success: false, error: "Message required" })
|
|
483
|
-
);
|
|
484
|
-
return;
|
|
485
|
-
}
|
|
486
|
-
const result = await sendNotification({
|
|
487
|
-
type,
|
|
488
|
-
title,
|
|
489
|
-
message
|
|
490
|
-
});
|
|
491
|
-
res.writeHead(result.success ? 200 : 500, {
|
|
492
|
-
"Content-Type": "application/json"
|
|
493
|
-
});
|
|
494
|
-
res.end(JSON.stringify(result));
|
|
495
|
-
} catch (err) {
|
|
496
|
-
console.error("[sms-webhook] Send error:", err);
|
|
497
|
-
res.writeHead(500, { "Content-Type": "application/json" });
|
|
498
|
-
res.end(
|
|
499
|
-
JSON.stringify({
|
|
500
|
-
success: false,
|
|
501
|
-
error: err instanceof Error ? err.message : "Send failed"
|
|
502
|
-
})
|
|
503
|
-
);
|
|
504
|
-
}
|
|
505
|
-
});
|
|
506
|
-
return;
|
|
507
|
-
}
|
|
508
|
-
res.writeHead(404);
|
|
509
|
-
res.end("Not found");
|
|
510
|
-
}
|
|
511
|
-
);
|
|
512
|
-
server.listen(port, () => {
|
|
513
|
-
console.log(`[sms-webhook] Server listening on port ${port}`);
|
|
514
|
-
console.log(
|
|
515
|
-
`[sms-webhook] Incoming messages: http://localhost:${port}/sms/incoming`
|
|
516
|
-
);
|
|
517
|
-
console.log(
|
|
518
|
-
`[sms-webhook] Status callback: http://localhost:${port}/sms/status`
|
|
519
|
-
);
|
|
520
|
-
console.log(`[sms-webhook] Configure these URLs in Twilio console`);
|
|
521
|
-
setInterval(() => {
|
|
522
|
-
try {
|
|
523
|
-
const expiredPrompts = cleanupExpiredPrompts();
|
|
524
|
-
const oldActions = cleanupOldActions();
|
|
525
|
-
if (expiredPrompts > 0 || oldActions > 0) {
|
|
526
|
-
logCleanup("sms-webhook", expiredPrompts, oldActions);
|
|
527
|
-
console.log(
|
|
528
|
-
`[sms-webhook] Cleanup: ${expiredPrompts} expired prompts, ${oldActions} old actions`
|
|
529
|
-
);
|
|
530
|
-
}
|
|
531
|
-
} catch {
|
|
532
|
-
}
|
|
533
|
-
}, CLEANUP_INTERVAL_MS);
|
|
534
|
-
console.log(
|
|
535
|
-
`[sms-webhook] Cleanup interval: every ${CLEANUP_INTERVAL_MS / 1e3}s`
|
|
536
|
-
);
|
|
537
|
-
});
|
|
538
|
-
}
|
|
539
|
-
async function smsWebhookMiddleware(req, res) {
|
|
540
|
-
const result = await handleSMSWebhook(req.body);
|
|
541
|
-
res.type("text/xml");
|
|
542
|
-
res.send(twimlResponse(result.response));
|
|
543
|
-
}
|
|
544
|
-
if (process.argv[1]?.endsWith("sms-webhook.js")) {
|
|
545
|
-
const port = parseInt(process.env["SMS_WEBHOOK_PORT"] || "3456", 10);
|
|
546
|
-
startWebhookServer(port);
|
|
547
|
-
}
|
|
548
|
-
export {
|
|
549
|
-
getIncomingRequest,
|
|
550
|
-
handleSMSWebhook,
|
|
551
|
-
markRequestProcessed,
|
|
552
|
-
smsWebhookMiddleware,
|
|
553
|
-
startWebhookServer
|
|
554
|
-
};
|
|
555
|
-
//# sourceMappingURL=sms-webhook.js.map
|