@hasna/mementos 0.14.85 → 0.14.86
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/bun.lock +63 -4
- package/dist/cli/index.js +419 -188
- package/dist/diagnostics/historical-project-registration-receipt.js +36 -17
- package/dist/index.js +139 -50
- package/dist/mcp/index.js +181 -60
- package/dist/pg-sync-worker.js +7 -5
- package/dist/project-registration.js +108 -36
- package/dist/sdk/index.js +1 -0
- package/dist/server/index.js +384 -280
- package/dist/storage.js +63 -26
- package/hasna.contract.json +5 -4
- package/package.json +4 -3
- package/dist/cli/__fixtures__/clean-fallback-stub-server.d.ts +0 -2
- package/dist/cli/__fixtures__/clean-fallback-stub-server.d.ts.map +0 -1
- package/dist/cli/brains.d.ts +0 -3
- package/dist/cli/brains.d.ts.map +0 -1
- package/dist/cli/commands/agent.d.ts +0 -3
- package/dist/cli/commands/agent.d.ts.map +0 -1
- package/dist/cli/commands/consolidation.d.ts +0 -3
- package/dist/cli/commands/consolidation.d.ts.map +0 -1
- package/dist/cli/commands/entity.d.ts +0 -3
- package/dist/cli/commands/entity.d.ts.map +0 -1
- package/dist/cli/commands/graph.d.ts +0 -3
- package/dist/cli/commands/graph.d.ts.map +0 -1
- package/dist/cli/commands/info-context.d.ts +0 -3
- package/dist/cli/commands/info-context.d.ts.map +0 -1
- package/dist/cli/commands/info-history.d.ts +0 -3
- package/dist/cli/commands/info-history.d.ts.map +0 -1
- package/dist/cli/commands/info-report.d.ts +0 -3
- package/dist/cli/commands/info-report.d.ts.map +0 -1
- package/dist/cli/commands/info-stale.d.ts +0 -3
- package/dist/cli/commands/info-stale.d.ts.map +0 -1
- package/dist/cli/commands/info-stats.d.ts +0 -3
- package/dist/cli/commands/info-stats.d.ts.map +0 -1
- package/dist/cli/commands/info.d.ts +0 -12
- package/dist/cli/commands/info.d.ts.map +0 -1
- package/dist/cli/commands/init.d.ts +0 -3
- package/dist/cli/commands/init.d.ts.map +0 -1
- package/dist/cli/commands/io-backup.d.ts +0 -3
- package/dist/cli/commands/io-backup.d.ts.map +0 -1
- package/dist/cli/commands/io-clean.d.ts +0 -3
- package/dist/cli/commands/io-clean.d.ts.map +0 -1
- package/dist/cli/commands/io-export.d.ts +0 -3
- package/dist/cli/commands/io-export.d.ts.map +0 -1
- package/dist/cli/commands/io-import.d.ts +0 -3
- package/dist/cli/commands/io-import.d.ts.map +0 -1
- package/dist/cli/commands/io-restore.d.ts +0 -3
- package/dist/cli/commands/io-restore.d.ts.map +0 -1
- package/dist/cli/commands/io.d.ts +0 -12
- package/dist/cli/commands/io.d.ts.map +0 -1
- package/dist/cli/commands/memory-cmd-bulk.d.ts +0 -3
- package/dist/cli/commands/memory-cmd-bulk.d.ts.map +0 -1
- package/dist/cli/commands/memory-cmd-chain.d.ts +0 -3
- package/dist/cli/commands/memory-cmd-chain.d.ts.map +0 -1
- package/dist/cli/commands/memory-cmd-crud.d.ts +0 -3
- package/dist/cli/commands/memory-cmd-crud.d.ts.map +0 -1
- package/dist/cli/commands/memory-cmd-diff.d.ts +0 -3
- package/dist/cli/commands/memory-cmd-diff.d.ts.map +0 -1
- package/dist/cli/commands/memory-cmd-list.d.ts +0 -3
- package/dist/cli/commands/memory-cmd-list.d.ts.map +0 -1
- package/dist/cli/commands/memory-cmd-recall-exit.d.ts +0 -3
- package/dist/cli/commands/memory-cmd-recall-exit.d.ts.map +0 -1
- package/dist/cli/commands/memory-cmd-recall.d.ts +0 -3
- package/dist/cli/commands/memory-cmd-recall.d.ts.map +0 -1
- package/dist/cli/commands/memory-cmd-remove.d.ts +0 -3
- package/dist/cli/commands/memory-cmd-remove.d.ts.map +0 -1
- package/dist/cli/commands/memory-cmd-search.d.ts +0 -3
- package/dist/cli/commands/memory-cmd-search.d.ts.map +0 -1
- package/dist/cli/commands/memory-cmd-tail.d.ts +0 -3
- package/dist/cli/commands/memory-cmd-tail.d.ts.map +0 -1
- package/dist/cli/commands/memory-cmd-util.d.ts +0 -3
- package/dist/cli/commands/memory-cmd-util.d.ts.map +0 -1
- package/dist/cli/commands/memory-cmd-view.d.ts +0 -3
- package/dist/cli/commands/memory-cmd-view.d.ts.map +0 -1
- package/dist/cli/commands/memory-cmd-watch.d.ts +0 -3
- package/dist/cli/commands/memory-cmd-watch.d.ts.map +0 -1
- package/dist/cli/commands/memory-cmd-when-to-use.d.ts +0 -3
- package/dist/cli/commands/memory-cmd-when-to-use.d.ts.map +0 -1
- package/dist/cli/commands/memory.d.ts +0 -3
- package/dist/cli/commands/memory.d.ts.map +0 -1
- package/dist/cli/commands/project-panel.d.ts +0 -3
- package/dist/cli/commands/project-panel.d.ts.map +0 -1
- package/dist/cli/commands/project.d.ts +0 -3
- package/dist/cli/commands/project.d.ts.map +0 -1
- package/dist/cli/commands/relation.d.ts +0 -3
- package/dist/cli/commands/relation.d.ts.map +0 -1
- package/dist/cli/commands/storage.d.ts +0 -3
- package/dist/cli/commands/storage.d.ts.map +0 -1
- package/dist/cli/commands/system-auto-memory.d.ts +0 -3
- package/dist/cli/commands/system-auto-memory.d.ts.map +0 -1
- package/dist/cli/commands/system-completions.d.ts +0 -13
- package/dist/cli/commands/system-completions.d.ts.map +0 -1
- package/dist/cli/commands/system-config.d.ts +0 -3
- package/dist/cli/commands/system-config.d.ts.map +0 -1
- package/dist/cli/commands/system-doctor.d.ts +0 -3
- package/dist/cli/commands/system-doctor.d.ts.map +0 -1
- package/dist/cli/commands/system-hooks.d.ts +0 -3
- package/dist/cli/commands/system-hooks.d.ts.map +0 -1
- package/dist/cli/commands/system-mcp.d.ts +0 -3
- package/dist/cli/commands/system-mcp.d.ts.map +0 -1
- package/dist/cli/commands/system-misc.d.ts +0 -3
- package/dist/cli/commands/system-misc.d.ts.map +0 -1
- package/dist/cli/commands/system-profile.d.ts +0 -3
- package/dist/cli/commands/system-profile.d.ts.map +0 -1
- package/dist/cli/commands/system-session.d.ts +0 -3
- package/dist/cli/commands/system-session.d.ts.map +0 -1
- package/dist/cli/commands/system-sessions.d.ts +0 -3
- package/dist/cli/commands/system-sessions.d.ts.map +0 -1
- package/dist/cli/commands/system-synthesis.d.ts +0 -3
- package/dist/cli/commands/system-synthesis.d.ts.map +0 -1
- package/dist/cli/commands/system-synthesized-profile.d.ts +0 -3
- package/dist/cli/commands/system-synthesized-profile.d.ts.map +0 -1
- package/dist/cli/commands/system-tools.d.ts +0 -3
- package/dist/cli/commands/system-tools.d.ts.map +0 -1
- package/dist/cli/commands/system-watch.d.ts +0 -3
- package/dist/cli/commands/system-watch.d.ts.map +0 -1
- package/dist/cli/commands/system.d.ts +0 -3
- package/dist/cli/commands/system.d.ts.map +0 -1
- package/dist/cli/exit-codes.d.ts +0 -13
- package/dist/cli/exit-codes.d.ts.map +0 -1
- package/dist/cli/global-options.d.ts +0 -27
- package/dist/cli/global-options.d.ts.map +0 -1
- package/dist/cli/helpers.d.ts +0 -150
- package/dist/cli/helpers.d.ts.map +0 -1
- package/dist/cli/index.d.ts +0 -3
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/register-all.d.ts +0 -17
- package/dist/cli/register-all.d.ts.map +0 -1
- package/dist/cli/startup-side-effects.d.ts +0 -9
- package/dist/cli/startup-side-effects.d.ts.map +0 -1
- package/dist/db/__fixtures__/fail-closed-stub-server.d.ts +0 -2
- package/dist/db/__fixtures__/fail-closed-stub-server.d.ts.map +0 -1
- package/dist/db/acl.d.ts +0 -34
- package/dist/db/acl.d.ts.map +0 -1
- package/dist/db/agents.d.ts +0 -21
- package/dist/db/agents.d.ts.map +0 -1
- package/dist/db/analytics.d.ts +0 -120
- package/dist/db/analytics.d.ts.map +0 -1
- package/dist/db/api-mode.d.ts +0 -127
- package/dist/db/api-mode.d.ts.map +0 -1
- package/dist/db/audit.d.ts +0 -53
- package/dist/db/audit.d.ts.map +0 -1
- package/dist/db/database.d.ts +0 -26
- package/dist/db/database.d.ts.map +0 -1
- package/dist/db/entities.d.ts +0 -62
- package/dist/db/entities.d.ts.map +0 -1
- package/dist/db/entity-memories.d.ts +0 -34
- package/dist/db/entity-memories.d.ts.map +0 -1
- package/dist/db/feedback.d.ts +0 -9
- package/dist/db/feedback.d.ts.map +0 -1
- package/dist/db/locks.d.ts +0 -63
- package/dist/db/locks.d.ts.map +0 -1
- package/dist/db/machines.d.ts +0 -23
- package/dist/db/machines.d.ts.map +0 -1
- package/dist/db/memories.d.ts +0 -193
- package/dist/db/memories.d.ts.map +0 -1
- package/dist/db/memory-links.d.ts +0 -21
- package/dist/db/memory-links.d.ts.map +0 -1
- package/dist/db/memory-project-link.d.ts +0 -13
- package/dist/db/memory-project-link.d.ts.map +0 -1
- package/dist/db/migrations.d.ts +0 -3
- package/dist/db/migrations.d.ts.map +0 -1
- package/dist/db/pg-migrate.d.ts +0 -27
- package/dist/db/pg-migrate.d.ts.map +0 -1
- package/dist/db/pg-migrations.d.ts +0 -2
- package/dist/db/pg-migrations.d.ts.map +0 -1
- package/dist/db/projects.d.ts +0 -27
- package/dist/db/projects.d.ts.map +0 -1
- package/dist/db/ratings.d.ts +0 -23
- package/dist/db/ratings.d.ts.map +0 -1
- package/dist/db/relations.d.ts +0 -49
- package/dist/db/relations.d.ts.map +0 -1
- package/dist/db/session-jobs.d.ts +0 -49
- package/dist/db/session-jobs.d.ts.map +0 -1
- package/dist/db/store-backend.d.ts +0 -42
- package/dist/db/store-backend.d.ts.map +0 -1
- package/dist/db/subscriptions.d.ts +0 -24
- package/dist/db/subscriptions.d.ts.map +0 -1
- package/dist/db/synthesis.d.ts +0 -101
- package/dist/db/synthesis.d.ts.map +0 -1
- package/dist/db/tasks.d.ts +0 -89
- package/dist/db/tasks.d.ts.map +0 -1
- package/dist/db/tool-events.d.ts +0 -27
- package/dist/db/tool-events.d.ts.map +0 -1
- package/dist/db/webhook_hooks.d.ts +0 -25
- package/dist/db/webhook_hooks.d.ts.map +0 -1
- package/dist/diagnostics/historical-project-registration-receipt.d.ts +0 -39
- package/dist/diagnostics/historical-project-registration-receipt.d.ts.map +0 -1
- package/dist/generated/storage-kit/backend.d.ts +0 -20
- package/dist/generated/storage-kit/backend.d.ts.map +0 -1
- package/dist/generated/storage-kit/health.d.ts +0 -20
- package/dist/generated/storage-kit/health.d.ts.map +0 -1
- package/dist/generated/storage-kit/index.d.ts +0 -8
- package/dist/generated/storage-kit/index.d.ts.map +0 -1
- package/dist/generated/storage-kit/migrations.d.ts +0 -48
- package/dist/generated/storage-kit/migrations.d.ts.map +0 -1
- package/dist/generated/storage-kit/own.d.ts +0 -11
- package/dist/generated/storage-kit/own.d.ts.map +0 -1
- package/dist/generated/storage-kit/pool.d.ts +0 -35
- package/dist/generated/storage-kit/pool.d.ts.map +0 -1
- package/dist/generated/storage-kit/query.d.ts +0 -36
- package/dist/generated/storage-kit/query.d.ts.map +0 -1
- package/dist/generated/storage-kit/tls.d.ts +0 -53
- package/dist/generated/storage-kit/tls.d.ts.map +0 -1
- package/dist/index.d.ts +0 -45
- package/dist/index.d.ts.map +0 -1
- package/dist/lib/activation-matcher.d.ts +0 -17
- package/dist/lib/activation-matcher.d.ts.map +0 -1
- package/dist/lib/asmr/categorizer.d.ts +0 -31
- package/dist/lib/asmr/categorizer.d.ts.map +0 -1
- package/dist/lib/asmr/context-agent.d.ts +0 -4
- package/dist/lib/asmr/context-agent.d.ts.map +0 -1
- package/dist/lib/asmr/ensemble.d.ts +0 -23
- package/dist/lib/asmr/ensemble.d.ts.map +0 -1
- package/dist/lib/asmr/fact-agent.d.ts +0 -4
- package/dist/lib/asmr/fact-agent.d.ts.map +0 -1
- package/dist/lib/asmr/index.d.ts +0 -7
- package/dist/lib/asmr/index.d.ts.map +0 -1
- package/dist/lib/asmr/orchestrator.d.ts +0 -4
- package/dist/lib/asmr/orchestrator.d.ts.map +0 -1
- package/dist/lib/asmr/recall.d.ts +0 -3
- package/dist/lib/asmr/recall.d.ts.map +0 -1
- package/dist/lib/asmr/temporal-agent.d.ts +0 -4
- package/dist/lib/asmr/temporal-agent.d.ts.map +0 -1
- package/dist/lib/asmr/types.d.ts +0 -27
- package/dist/lib/asmr/types.d.ts.map +0 -1
- package/dist/lib/auto-inject-orchestrator.d.ts +0 -57
- package/dist/lib/auto-inject-orchestrator.d.ts.map +0 -1
- package/dist/lib/auto-memory-queue.d.ts +0 -48
- package/dist/lib/auto-memory-queue.d.ts.map +0 -1
- package/dist/lib/auto-memory.d.ts +0 -19
- package/dist/lib/auto-memory.d.ts.map +0 -1
- package/dist/lib/bench.d.ts +0 -20
- package/dist/lib/bench.d.ts.map +0 -1
- package/dist/lib/built-in-hooks.d.ts +0 -12
- package/dist/lib/built-in-hooks.d.ts.map +0 -1
- package/dist/lib/channel-pusher.d.ts +0 -39
- package/dist/lib/channel-pusher.d.ts.map +0 -1
- package/dist/lib/config.d.ts +0 -9
- package/dist/lib/config.d.ts.map +0 -1
- package/dist/lib/connectors/files.d.ts +0 -8
- package/dist/lib/connectors/files.d.ts.map +0 -1
- package/dist/lib/connectors/github.d.ts +0 -7
- package/dist/lib/connectors/github.d.ts.map +0 -1
- package/dist/lib/connectors/index.d.ts +0 -12
- package/dist/lib/connectors/index.d.ts.map +0 -1
- package/dist/lib/connectors/notion.d.ts +0 -7
- package/dist/lib/connectors/notion.d.ts.map +0 -1
- package/dist/lib/connectors/types.d.ts +0 -27
- package/dist/lib/connectors/types.d.ts.map +0 -1
- package/dist/lib/consolidation.d.ts +0 -52
- package/dist/lib/consolidation.d.ts.map +0 -1
- package/dist/lib/context-extractor.d.ts +0 -14
- package/dist/lib/context-extractor.d.ts.map +0 -1
- package/dist/lib/context.d.ts +0 -36
- package/dist/lib/context.d.ts.map +0 -1
- package/dist/lib/contradiction.d.ts +0 -50
- package/dist/lib/contradiction.d.ts.map +0 -1
- package/dist/lib/decay.d.ts +0 -35
- package/dist/lib/decay.d.ts.map +0 -1
- package/dist/lib/dedup.d.ts +0 -33
- package/dist/lib/dedup.d.ts.map +0 -1
- package/dist/lib/duration.d.ts +0 -28
- package/dist/lib/duration.d.ts.map +0 -1
- package/dist/lib/embeddings.d.ts +0 -20
- package/dist/lib/embeddings.d.ts.map +0 -1
- package/dist/lib/enum-validation.d.ts +0 -20
- package/dist/lib/enum-validation.d.ts.map +0 -1
- package/dist/lib/export-v1.d.ts +0 -30
- package/dist/lib/export-v1.d.ts.map +0 -1
- package/dist/lib/extractor.d.ts +0 -9
- package/dist/lib/extractor.d.ts.map +0 -1
- package/dist/lib/extractors/audio.d.ts +0 -8
- package/dist/lib/extractors/audio.d.ts.map +0 -1
- package/dist/lib/extractors/index.d.ts +0 -12
- package/dist/lib/extractors/index.d.ts.map +0 -1
- package/dist/lib/extractors/ocr.d.ts +0 -7
- package/dist/lib/extractors/ocr.d.ts.map +0 -1
- package/dist/lib/extractors/pdf.d.ts +0 -7
- package/dist/lib/extractors/pdf.d.ts.map +0 -1
- package/dist/lib/extractors/types.d.ts +0 -12
- package/dist/lib/extractors/types.d.ts.map +0 -1
- package/dist/lib/file-deps.d.ts +0 -27
- package/dist/lib/file-deps.d.ts.map +0 -1
- package/dist/lib/focus.d.ts +0 -58
- package/dist/lib/focus.d.ts.map +0 -1
- package/dist/lib/gatherer.d.ts +0 -16
- package/dist/lib/gatherer.d.ts.map +0 -1
- package/dist/lib/gdpr.d.ts +0 -39
- package/dist/lib/gdpr.d.ts.map +0 -1
- package/dist/lib/hooks.d.ts +0 -50
- package/dist/lib/hooks.d.ts.map +0 -1
- package/dist/lib/importers/index.d.ts +0 -38
- package/dist/lib/importers/index.d.ts.map +0 -1
- package/dist/lib/injector.d.ts +0 -89
- package/dist/lib/injector.d.ts.map +0 -1
- package/dist/lib/machine-visibility.d.ts +0 -6
- package/dist/lib/machine-visibility.d.ts.map +0 -1
- package/dist/lib/matryoshka.d.ts +0 -50
- package/dist/lib/matryoshka.d.ts.map +0 -1
- package/dist/lib/memory-lock.d.ts +0 -58
- package/dist/lib/memory-lock.d.ts.map +0 -1
- package/dist/lib/model-config.d.ts +0 -14
- package/dist/lib/model-config.d.ts.map +0 -1
- package/dist/lib/open-sessions-connector.d.ts +0 -60
- package/dist/lib/open-sessions-connector.d.ts.map +0 -1
- package/dist/lib/package-version.d.ts +0 -3
- package/dist/lib/package-version.d.ts.map +0 -1
- package/dist/lib/poisoning.d.ts +0 -19
- package/dist/lib/poisoning.d.ts.map +0 -1
- package/dist/lib/poll.d.ts +0 -17
- package/dist/lib/poll.d.ts.map +0 -1
- package/dist/lib/procedural-extractor.d.ts +0 -21
- package/dist/lib/procedural-extractor.d.ts.map +0 -1
- package/dist/lib/profile-sync.d.ts +0 -20
- package/dist/lib/profile-sync.d.ts.map +0 -1
- package/dist/lib/profile-synthesizer.d.ts +0 -20
- package/dist/lib/profile-synthesizer.d.ts.map +0 -1
- package/dist/lib/project-detect.d.ts +0 -18
- package/dist/lib/project-detect.d.ts.map +0 -1
- package/dist/lib/project-panel.d.ts +0 -7
- package/dist/lib/project-panel.d.ts.map +0 -1
- package/dist/lib/providers/anthropic.d.ts +0 -21
- package/dist/lib/providers/anthropic.d.ts.map +0 -1
- package/dist/lib/providers/base.d.ts +0 -96
- package/dist/lib/providers/base.d.ts.map +0 -1
- package/dist/lib/providers/cerebras.d.ts +0 -20
- package/dist/lib/providers/cerebras.d.ts.map +0 -1
- package/dist/lib/providers/grok.d.ts +0 -19
- package/dist/lib/providers/grok.d.ts.map +0 -1
- package/dist/lib/providers/index.d.ts +0 -7
- package/dist/lib/providers/index.d.ts.map +0 -1
- package/dist/lib/providers/openai-compat.d.ts +0 -18
- package/dist/lib/providers/openai-compat.d.ts.map +0 -1
- package/dist/lib/providers/openai.d.ts +0 -20
- package/dist/lib/providers/openai.d.ts.map +0 -1
- package/dist/lib/providers/registry.d.ts +0 -38
- package/dist/lib/providers/registry.d.ts.map +0 -1
- package/dist/lib/quality.d.ts +0 -16
- package/dist/lib/quality.d.ts.map +0 -1
- package/dist/lib/redact.d.ts +0 -10
- package/dist/lib/redact.d.ts.map +0 -1
- package/dist/lib/reflection.d.ts +0 -83
- package/dist/lib/reflection.d.ts.map +0 -1
- package/dist/lib/retention.d.ts +0 -17
- package/dist/lib/retention.d.ts.map +0 -1
- package/dist/lib/retired-storage-mode.d.ts +0 -11
- package/dist/lib/retired-storage-mode.d.ts.map +0 -1
- package/dist/lib/search.d.ts +0 -52
- package/dist/lib/search.d.ts.map +0 -1
- package/dist/lib/session-auto-resolve.d.ts +0 -28
- package/dist/lib/session-auto-resolve.d.ts.map +0 -1
- package/dist/lib/session-processor.d.ts +0 -38
- package/dist/lib/session-processor.d.ts.map +0 -1
- package/dist/lib/session-queue.d.ts +0 -28
- package/dist/lib/session-queue.d.ts.map +0 -1
- package/dist/lib/session-registry.d.ts +0 -47
- package/dist/lib/session-registry.d.ts.map +0 -1
- package/dist/lib/session-start-briefing.d.ts +0 -10
- package/dist/lib/session-start-briefing.d.ts.map +0 -1
- package/dist/lib/session-watcher.d.ts +0 -30
- package/dist/lib/session-watcher.d.ts.map +0 -1
- package/dist/lib/storage-sync.d.ts +0 -45
- package/dist/lib/storage-sync.d.ts.map +0 -1
- package/dist/lib/sync.d.ts +0 -10
- package/dist/lib/sync.d.ts.map +0 -1
- package/dist/lib/synthesis/corpus-builder.d.ts +0 -30
- package/dist/lib/synthesis/corpus-builder.d.ts.map +0 -1
- package/dist/lib/synthesis/executor.d.ts +0 -14
- package/dist/lib/synthesis/executor.d.ts.map +0 -1
- package/dist/lib/synthesis/index.d.ts +0 -37
- package/dist/lib/synthesis/index.d.ts.map +0 -1
- package/dist/lib/synthesis/llm-analyzer.d.ts +0 -18
- package/dist/lib/synthesis/llm-analyzer.d.ts.map +0 -1
- package/dist/lib/synthesis/metrics.d.ts +0 -13
- package/dist/lib/synthesis/metrics.d.ts.map +0 -1
- package/dist/lib/synthesis/scheduler.d.ts +0 -18
- package/dist/lib/synthesis/scheduler.d.ts.map +0 -1
- package/dist/lib/synthesis/validator.d.ts +0 -19
- package/dist/lib/synthesis/validator.d.ts.map +0 -1
- package/dist/lib/task-runner.d.ts +0 -37
- package/dist/lib/task-runner.d.ts.map +0 -1
- package/dist/lib/tool-lesson-extractor.d.ts +0 -24
- package/dist/lib/tool-lesson-extractor.d.ts.map +0 -1
- package/dist/lib/tool-memory-synthesizer.d.ts +0 -28
- package/dist/lib/tool-memory-synthesizer.d.ts.map +0 -1
- package/dist/lib/topic-clusterer.d.ts +0 -21
- package/dist/lib/topic-clusterer.d.ts.map +0 -1
- package/dist/lib/when-to-use-generator.d.ts +0 -22
- package/dist/lib/when-to-use-generator.d.ts.map +0 -1
- package/dist/mcp/http.d.ts +0 -17
- package/dist/mcp/http.d.ts.map +0 -1
- package/dist/mcp/index.d.ts +0 -6
- package/dist/mcp/index.d.ts.map +0 -1
- package/dist/mcp/memory-broadcast.d.ts +0 -12
- package/dist/mcp/memory-broadcast.d.ts.map +0 -1
- package/dist/mcp/tools/agent-tools.d.ts +0 -3
- package/dist/mcp/tools/agent-tools.d.ts.map +0 -1
- package/dist/mcp/tools/auto-memory-tools.d.ts +0 -5
- package/dist/mcp/tools/auto-memory-tools.d.ts.map +0 -1
- package/dist/mcp/tools/bulk-tools.d.ts +0 -3
- package/dist/mcp/tools/bulk-tools.d.ts.map +0 -1
- package/dist/mcp/tools/consolidation-tools.d.ts +0 -3
- package/dist/mcp/tools/consolidation-tools.d.ts.map +0 -1
- package/dist/mcp/tools/focus-tools.d.ts +0 -3
- package/dist/mcp/tools/focus-tools.d.ts.map +0 -1
- package/dist/mcp/tools/graph-entity-tools.d.ts +0 -3
- package/dist/mcp/tools/graph-entity-tools.d.ts.map +0 -1
- package/dist/mcp/tools/graph-query-tools.d.ts +0 -3
- package/dist/mcp/tools/graph-query-tools.d.ts.map +0 -1
- package/dist/mcp/tools/graph-relation-tools.d.ts +0 -3
- package/dist/mcp/tools/graph-relation-tools.d.ts.map +0 -1
- package/dist/mcp/tools/graph-tools.d.ts +0 -3
- package/dist/mcp/tools/graph-tools.d.ts.map +0 -1
- package/dist/mcp/tools/graph-utils.d.ts +0 -5
- package/dist/mcp/tools/graph-utils.d.ts.map +0 -1
- package/dist/mcp/tools/hook-tools.d.ts +0 -3
- package/dist/mcp/tools/hook-tools.d.ts.map +0 -1
- package/dist/mcp/tools/lock-tools.d.ts +0 -3
- package/dist/mcp/tools/lock-tools.d.ts.map +0 -1
- package/dist/mcp/tools/memory-audit.d.ts +0 -3
- package/dist/mcp/tools/memory-audit.d.ts.map +0 -1
- package/dist/mcp/tools/memory-crud.d.ts +0 -3
- package/dist/mcp/tools/memory-crud.d.ts.map +0 -1
- package/dist/mcp/tools/memory-health.d.ts +0 -3
- package/dist/mcp/tools/memory-health.d.ts.map +0 -1
- package/dist/mcp/tools/memory-history.d.ts +0 -3
- package/dist/mcp/tools/memory-history.d.ts.map +0 -1
- package/dist/mcp/tools/memory-inject.d.ts +0 -3
- package/dist/mcp/tools/memory-inject.d.ts.map +0 -1
- package/dist/mcp/tools/memory-io.d.ts +0 -3
- package/dist/mcp/tools/memory-io.d.ts.map +0 -1
- package/dist/mcp/tools/memory-lifecycle.d.ts +0 -3
- package/dist/mcp/tools/memory-lifecycle.d.ts.map +0 -1
- package/dist/mcp/tools/memory-search.d.ts +0 -3
- package/dist/mcp/tools/memory-search.d.ts.map +0 -1
- package/dist/mcp/tools/memory-stats.d.ts +0 -3
- package/dist/mcp/tools/memory-stats.d.ts.map +0 -1
- package/dist/mcp/tools/memory-tools.d.ts +0 -17
- package/dist/mcp/tools/memory-tools.d.ts.map +0 -1
- package/dist/mcp/tools/memory-utils.d.ts +0 -27
- package/dist/mcp/tools/memory-utils.d.ts.map +0 -1
- package/dist/mcp/tools/memory-validation.d.ts +0 -3
- package/dist/mcp/tools/memory-validation.d.ts.map +0 -1
- package/dist/mcp/tools/project-tools.d.ts +0 -3
- package/dist/mcp/tools/project-tools.d.ts.map +0 -1
- package/dist/mcp/tools/session-tools.d.ts +0 -3
- package/dist/mcp/tools/session-tools.d.ts.map +0 -1
- package/dist/mcp/tools/storage-tools.d.ts +0 -3
- package/dist/mcp/tools/storage-tools.d.ts.map +0 -1
- package/dist/mcp/tools/synthesis-tools.d.ts +0 -3
- package/dist/mcp/tools/synthesis-tools.d.ts.map +0 -1
- package/dist/mcp/tools/system-tools-events.d.ts +0 -3
- package/dist/mcp/tools/system-tools-events.d.ts.map +0 -1
- package/dist/mcp/tools/system-tools-memory-admin.d.ts +0 -3
- package/dist/mcp/tools/system-tools-memory-admin.d.ts.map +0 -1
- package/dist/mcp/tools/system-tools-shared.d.ts +0 -23
- package/dist/mcp/tools/system-tools-shared.d.ts.map +0 -1
- package/dist/mcp/tools/system-tools.d.ts +0 -3
- package/dist/mcp/tools/system-tools.d.ts.map +0 -1
- package/dist/mcp/tools/tool-registry.d.ts +0 -30
- package/dist/mcp/tools/tool-registry.d.ts.map +0 -1
- package/dist/mcp/tools/utility-tools.d.ts +0 -3
- package/dist/mcp/tools/utility-tools.d.ts.map +0 -1
- package/dist/memory-project-link/index.d.ts +0 -2
- package/dist/memory-project-link/index.d.ts.map +0 -1
- package/dist/memory-project-link/schema.d.ts +0 -5
- package/dist/memory-project-link/schema.d.ts.map +0 -1
- package/dist/pg-sync-worker.d.ts +0 -2
- package/dist/pg-sync-worker.d.ts.map +0 -1
- package/dist/project-registration/authority.d.ts +0 -43
- package/dist/project-registration/authority.d.ts.map +0 -1
- package/dist/project-registration/historical-receipt.d.ts +0 -38
- package/dist/project-registration/historical-receipt.d.ts.map +0 -1
- package/dist/project-registration/http.d.ts +0 -32
- package/dist/project-registration/http.d.ts.map +0 -1
- package/dist/project-registration/identity.d.ts +0 -20
- package/dist/project-registration/identity.d.ts.map +0 -1
- package/dist/project-registration/index.d.ts +0 -11
- package/dist/project-registration/index.d.ts.map +0 -1
- package/dist/project-registration/project-references.d.ts +0 -71
- package/dist/project-registration/project-references.d.ts.map +0 -1
- package/dist/project-registration/project-resources.d.ts +0 -22
- package/dist/project-registration/project-resources.d.ts.map +0 -1
- package/dist/project-registration/schema.d.ts +0 -5
- package/dist/project-registration/schema.d.ts.map +0 -1
- package/dist/project-registration/types.d.ts +0 -319
- package/dist/project-registration/types.d.ts.map +0 -1
- package/dist/project-registration.d.ts +0 -2
- package/dist/project-registration.d.ts.map +0 -1
- package/dist/sdk/index.d.ts +0 -978
- package/dist/sdk/index.d.ts.map +0 -1
- package/dist/server/auth.d.ts +0 -11
- package/dist/server/auth.d.ts.map +0 -1
- package/dist/server/helpers.d.ts +0 -22
- package/dist/server/helpers.d.ts.map +0 -1
- package/dist/server/index.d.ts +0 -14
- package/dist/server/index.d.ts.map +0 -1
- package/dist/server/openapi.d.ts +0 -2
- package/dist/server/openapi.d.ts.map +0 -1
- package/dist/server/router.d.ts +0 -17
- package/dist/server/router.d.ts.map +0 -1
- package/dist/server/routes/agents.d.ts +0 -2
- package/dist/server/routes/agents.d.ts.map +0 -1
- package/dist/server/routes/entities.d.ts +0 -2
- package/dist/server/routes/entities.d.ts.map +0 -1
- package/dist/server/routes/memories-bulk.d.ts +0 -2
- package/dist/server/routes/memories-bulk.d.ts.map +0 -1
- package/dist/server/routes/memories-crud.d.ts +0 -2
- package/dist/server/routes/memories-crud.d.ts.map +0 -1
- package/dist/server/routes/memories-io.d.ts +0 -2
- package/dist/server/routes/memories-io.d.ts.map +0 -1
- package/dist/server/routes/memories-misc.d.ts +0 -2
- package/dist/server/routes/memories-misc.d.ts.map +0 -1
- package/dist/server/routes/memories-search.d.ts +0 -2
- package/dist/server/routes/memories-search.d.ts.map +0 -1
- package/dist/server/routes/memories-stats.d.ts +0 -2
- package/dist/server/routes/memories-stats.d.ts.map +0 -1
- package/dist/server/routes/memories.d.ts +0 -19
- package/dist/server/routes/memories.d.ts.map +0 -1
- package/dist/server/routes/memory-project-link.d.ts +0 -2
- package/dist/server/routes/memory-project-link.d.ts.map +0 -1
- package/dist/server/routes/project-registration.d.ts +0 -2
- package/dist/server/routes/project-registration.d.ts.map +0 -1
- package/dist/server/routes/projects.d.ts +0 -2
- package/dist/server/routes/projects.d.ts.map +0 -1
- package/dist/server/routes/system-auto-memory.d.ts +0 -2
- package/dist/server/routes/system-auto-memory.d.ts.map +0 -1
- package/dist/server/routes/system-chain.d.ts +0 -2
- package/dist/server/routes/system-chain.d.ts.map +0 -1
- package/dist/server/routes/system-consolidation.d.ts +0 -2
- package/dist/server/routes/system-consolidation.d.ts.map +0 -1
- package/dist/server/routes/system-hooks.d.ts +0 -2
- package/dist/server/routes/system-hooks.d.ts.map +0 -1
- package/dist/server/routes/system-sessions.d.ts +0 -2
- package/dist/server/routes/system-sessions.d.ts.map +0 -1
- package/dist/server/routes/system-subscriptions.d.ts +0 -2
- package/dist/server/routes/system-subscriptions.d.ts.map +0 -1
- package/dist/server/routes/system-synthesis.d.ts +0 -2
- package/dist/server/routes/system-synthesis.d.ts.map +0 -1
- package/dist/server/routes/system-tools.d.ts +0 -2
- package/dist/server/routes/system-tools.d.ts.map +0 -1
- package/dist/server/routes/system.d.ts +0 -2
- package/dist/server/routes/system.d.ts.map +0 -1
- package/dist/server/routes/tasks.d.ts +0 -2
- package/dist/server/routes/tasks.d.ts.map +0 -1
- package/dist/storage.d.ts +0 -266
- package/dist/storage.d.ts.map +0 -1
- package/dist/test-support/memories-page-stub-server.d.ts +0 -2
- package/dist/test-support/memories-page-stub-server.d.ts.map +0 -1
- package/dist/test-support/memories-page-stub.d.ts +0 -28
- package/dist/test-support/memories-page-stub.d.ts.map +0 -1
- package/dist/test-support/preload-local-store.d.ts +0 -2
- package/dist/test-support/preload-local-store.d.ts.map +0 -1
- package/dist/test-support/project-authority-identity.d.ts +0 -8
- package/dist/test-support/project-authority-identity.d.ts.map +0 -1
- package/dist/test-support/store-isolation.d.ts +0 -108
- package/dist/test-support/store-isolation.d.ts.map +0 -1
- package/dist/test-support/strip-ansi.d.ts +0 -3
- package/dist/test-support/strip-ansi.d.ts.map +0 -1
- package/dist/types/hooks.d.ts +0 -136
- package/dist/types/hooks.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -472
- package/dist/types/index.d.ts.map +0 -1
|
@@ -54,8 +54,13 @@ class PgSyncPool {
|
|
|
54
54
|
data;
|
|
55
55
|
closed = false;
|
|
56
56
|
lastError = null;
|
|
57
|
+
generation = 0;
|
|
57
58
|
static DATA_BYTES = 128 * 1024 * 1024;
|
|
58
|
-
static
|
|
59
|
+
static queryTimeoutMs() {
|
|
60
|
+
const raw = process.env["MEMENTOS_PGSYNC_QUERY_TIMEOUT_MS"]?.trim();
|
|
61
|
+
const parsed = raw ? Number(raw) : Number.NaN;
|
|
62
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : 60000;
|
|
63
|
+
}
|
|
59
64
|
static resolveWorkerPath() {
|
|
60
65
|
const ext = import.meta.url.endsWith(".ts") ? ".ts" : ".js";
|
|
61
66
|
const here = fileURLToPath(new URL(".", import.meta.url));
|
|
@@ -70,12 +75,12 @@ class PgSyncPool {
|
|
|
70
75
|
}
|
|
71
76
|
return candidates[0];
|
|
72
77
|
}
|
|
73
|
-
constructor(connectionString) {
|
|
74
|
-
const control = new SharedArrayBuffer(
|
|
78
|
+
constructor(connectionString, workerPath) {
|
|
79
|
+
const control = new SharedArrayBuffer(12);
|
|
75
80
|
const dataSab = new SharedArrayBuffer(PgSyncPool.DATA_BYTES);
|
|
76
81
|
this.status = new Int32Array(control);
|
|
77
82
|
this.data = new Uint8Array(dataSab);
|
|
78
|
-
this.worker = new Worker(PgSyncPool.resolveWorkerPath(), {
|
|
83
|
+
this.worker = new Worker(workerPath ?? PgSyncPool.resolveWorkerPath(), {
|
|
79
84
|
workerData: {
|
|
80
85
|
dsn: stripSslParams(connectionString),
|
|
81
86
|
ssl: sslConfigFor(connectionString),
|
|
@@ -93,21 +98,35 @@ class PgSyncPool {
|
|
|
93
98
|
throw new Error("PgSyncPool is closed");
|
|
94
99
|
if (this.lastError)
|
|
95
100
|
throw this.lastError;
|
|
101
|
+
const timeoutMs = PgSyncPool.queryTimeoutMs();
|
|
102
|
+
const gen = ++this.generation;
|
|
96
103
|
Atomics.store(this.status, 0, 0);
|
|
97
|
-
this.
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
104
|
+
Atomics.store(this.status, 2, 0);
|
|
105
|
+
this.worker.postMessage({ sql, params, gen });
|
|
106
|
+
const deadline = Date.now() + timeoutMs;
|
|
107
|
+
for (;; ) {
|
|
108
|
+
const remaining = deadline - Date.now();
|
|
109
|
+
const responding = Atomics.load(this.status, 0);
|
|
110
|
+
if (responding === gen) {
|
|
111
|
+
const code = Atomics.load(this.status, 2);
|
|
112
|
+
const len = Atomics.load(this.status, 1);
|
|
113
|
+
const payload = JSON.parse(new TextDecoder().decode(this.data.subarray(0, len)));
|
|
114
|
+
if (code === 2) {
|
|
115
|
+
throw new Error(payload.message ?? "PostgreSQL error");
|
|
116
|
+
}
|
|
117
|
+
return payload;
|
|
118
|
+
}
|
|
119
|
+
if (responding !== 0) {
|
|
120
|
+
Atomics.compareExchange(this.status, 0, responding, 0);
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
if (remaining <= 0) {
|
|
124
|
+
if (this.lastError)
|
|
125
|
+
throw this.lastError;
|
|
126
|
+
throw new Error(`PostgreSQL query timed out after ${timeoutMs}ms`);
|
|
127
|
+
}
|
|
128
|
+
Atomics.wait(this.status, 0, 0, remaining);
|
|
109
129
|
}
|
|
110
|
-
return payload;
|
|
111
130
|
}
|
|
112
131
|
end() {
|
|
113
132
|
if (this.closed)
|
package/dist/index.js
CHANGED
|
@@ -235,6 +235,7 @@ function translateSql(sql) {
|
|
|
235
235
|
let translated = sql.replace(/\?/g, () => `$${++parameterIndex}`);
|
|
236
236
|
const ISO_FMT = `'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"'`;
|
|
237
237
|
translated = translated.replace(/datetime\s*\(\s*'now'\s*\)/gi, `to_char(now() AT TIME ZONE 'UTC', ${ISO_FMT})`);
|
|
238
|
+
translated = translated.replace(/strftime\s*\(\s*'%Y-%m-%dT%H:%M:%fZ'\s*,\s*'now'\s*\)/gi, `to_char(now() AT TIME ZONE 'UTC', ${ISO_FMT})`);
|
|
238
239
|
translated = translated.replace(/datetime\s*\(\s*'now'\s*,\s*'(-?\d+)\s+(minutes?|hours?|days?|seconds?)'\s*\)/gi, (_match, amount, unit) => {
|
|
239
240
|
const parsed = parseInt(String(amount), 10);
|
|
240
241
|
const absolute = Math.abs(parsed);
|
|
@@ -736,16 +737,24 @@ function transferRows(target, table, rows, options) {
|
|
|
736
737
|
const conflictColumn = options.conflictColumn ?? "updated_at";
|
|
737
738
|
let written = 0;
|
|
738
739
|
let skipped = 0;
|
|
740
|
+
let maxSyncedAt = null;
|
|
739
741
|
const errors = [];
|
|
742
|
+
const bumpMaxSyncedAt = (row) => {
|
|
743
|
+
const value = row[conflictColumn];
|
|
744
|
+
if (typeof value === "string" && (maxSyncedAt === null || value > maxSyncedAt)) {
|
|
745
|
+
maxSyncedAt = value;
|
|
746
|
+
}
|
|
747
|
+
};
|
|
740
748
|
if (rows.length === 0) {
|
|
741
|
-
return { written, skipped, errors };
|
|
749
|
+
return { written, skipped, errors, maxSyncedAt };
|
|
742
750
|
}
|
|
743
751
|
const columns = Object.keys(rows[0] ?? {});
|
|
744
752
|
if (!columns.includes(primaryKey)) {
|
|
745
753
|
return {
|
|
746
754
|
written,
|
|
747
755
|
skipped,
|
|
748
|
-
errors: [`Table "${table}" has no "${primaryKey}" column; skipping`]
|
|
756
|
+
errors: [`Table "${table}" has no "${primaryKey}" column; skipping`],
|
|
757
|
+
maxSyncedAt
|
|
749
758
|
};
|
|
750
759
|
}
|
|
751
760
|
const hasConflictColumn = columns.includes(conflictColumn);
|
|
@@ -758,6 +767,7 @@ function transferRows(target, table, rows, options) {
|
|
|
758
767
|
const incomingTime = Date.parse(String(row[conflictColumn]));
|
|
759
768
|
if (Number.isFinite(existingTime) && Number.isFinite(incomingTime) && existingTime >= incomingTime) {
|
|
760
769
|
skipped++;
|
|
770
|
+
bumpMaxSyncedAt(row);
|
|
761
771
|
continue;
|
|
762
772
|
}
|
|
763
773
|
}
|
|
@@ -770,11 +780,12 @@ function transferRows(target, table, rows, options) {
|
|
|
770
780
|
target.run(`INSERT INTO "${table}" (${columnList}) VALUES (${placeholders})`, ...columns.map((column) => row[column]));
|
|
771
781
|
}
|
|
772
782
|
written++;
|
|
783
|
+
bumpMaxSyncedAt(row);
|
|
773
784
|
} catch (error) {
|
|
774
785
|
errors.push(`Row ${String(row[primaryKey] ?? "unknown")}: ${error instanceof Error ? error.message : String(error)}`);
|
|
775
786
|
}
|
|
776
787
|
}
|
|
777
|
-
return { written, skipped, errors };
|
|
788
|
+
return { written, skipped, errors, maxSyncedAt };
|
|
778
789
|
}
|
|
779
790
|
function incrementalSyncPush(local, remote, tables, options = {}) {
|
|
780
791
|
return runIncrementalSync("push", local, remote, local, tables, options);
|
|
@@ -812,22 +823,29 @@ function runIncrementalSync(direction, source, target, metaDb, tables, options)
|
|
|
812
823
|
rows = source.all(`SELECT * FROM "${table}"`);
|
|
813
824
|
stat.first_sync = true;
|
|
814
825
|
}
|
|
826
|
+
let maxSyncedAt = null;
|
|
815
827
|
for (let offset = 0;offset < rows.length; offset += batchSize) {
|
|
816
828
|
const batch = rows.slice(offset, offset + batchSize);
|
|
817
829
|
const result = transferRows(target, table, batch, options);
|
|
818
830
|
stat.synced_rows += result.written;
|
|
819
831
|
stat.skipped_rows += result.skipped;
|
|
820
832
|
stat.errors.push(...result.errors);
|
|
833
|
+
if (result.maxSyncedAt !== null && (maxSyncedAt === null || result.maxSyncedAt > maxSyncedAt)) {
|
|
834
|
+
maxSyncedAt = result.maxSyncedAt;
|
|
835
|
+
}
|
|
821
836
|
}
|
|
822
837
|
if (rows.length === 0) {
|
|
823
838
|
stat.skipped_rows = stat.total_rows;
|
|
824
839
|
}
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
840
|
+
const nextCursor = maxSyncedAt ?? meta?.last_synced_at ?? null;
|
|
841
|
+
if (rows.length > 0 && stat.errors.length === 0 && nextCursor !== null) {
|
|
842
|
+
upsertSyncMeta(metaDb, {
|
|
843
|
+
table_name: table,
|
|
844
|
+
last_synced_at: nextCursor,
|
|
845
|
+
last_synced_row_count: stat.synced_rows,
|
|
846
|
+
direction
|
|
847
|
+
});
|
|
848
|
+
}
|
|
831
849
|
} catch (error) {
|
|
832
850
|
stat.errors.push(`Table "${table}": ${error instanceof Error ? error.message : String(error)}`);
|
|
833
851
|
}
|
|
@@ -866,8 +884,13 @@ var init_storage = __esm(() => {
|
|
|
866
884
|
data;
|
|
867
885
|
closed = false;
|
|
868
886
|
lastError = null;
|
|
887
|
+
generation = 0;
|
|
869
888
|
static DATA_BYTES = 128 * 1024 * 1024;
|
|
870
|
-
static
|
|
889
|
+
static queryTimeoutMs() {
|
|
890
|
+
const raw = process.env["MEMENTOS_PGSYNC_QUERY_TIMEOUT_MS"]?.trim();
|
|
891
|
+
const parsed = raw ? Number(raw) : Number.NaN;
|
|
892
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : 60000;
|
|
893
|
+
}
|
|
871
894
|
static resolveWorkerPath() {
|
|
872
895
|
const ext = import.meta.url.endsWith(".ts") ? ".ts" : ".js";
|
|
873
896
|
const here = fileURLToPath(new URL(".", import.meta.url));
|
|
@@ -882,12 +905,12 @@ var init_storage = __esm(() => {
|
|
|
882
905
|
}
|
|
883
906
|
return candidates[0];
|
|
884
907
|
}
|
|
885
|
-
constructor(connectionString) {
|
|
886
|
-
const control = new SharedArrayBuffer(
|
|
908
|
+
constructor(connectionString, workerPath) {
|
|
909
|
+
const control = new SharedArrayBuffer(12);
|
|
887
910
|
const dataSab = new SharedArrayBuffer(PgSyncPool.DATA_BYTES);
|
|
888
911
|
this.status = new Int32Array(control);
|
|
889
912
|
this.data = new Uint8Array(dataSab);
|
|
890
|
-
this.worker = new Worker(PgSyncPool.resolveWorkerPath(), {
|
|
913
|
+
this.worker = new Worker(workerPath ?? PgSyncPool.resolveWorkerPath(), {
|
|
891
914
|
workerData: {
|
|
892
915
|
dsn: stripSslParams(connectionString),
|
|
893
916
|
ssl: sslConfigFor(connectionString),
|
|
@@ -905,21 +928,35 @@ var init_storage = __esm(() => {
|
|
|
905
928
|
throw new Error("PgSyncPool is closed");
|
|
906
929
|
if (this.lastError)
|
|
907
930
|
throw this.lastError;
|
|
931
|
+
const timeoutMs = PgSyncPool.queryTimeoutMs();
|
|
932
|
+
const gen = ++this.generation;
|
|
908
933
|
Atomics.store(this.status, 0, 0);
|
|
909
|
-
this.
|
|
910
|
-
|
|
911
|
-
const
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
934
|
+
Atomics.store(this.status, 2, 0);
|
|
935
|
+
this.worker.postMessage({ sql, params, gen });
|
|
936
|
+
const deadline = Date.now() + timeoutMs;
|
|
937
|
+
for (;; ) {
|
|
938
|
+
const remaining = deadline - Date.now();
|
|
939
|
+
const responding = Atomics.load(this.status, 0);
|
|
940
|
+
if (responding === gen) {
|
|
941
|
+
const code = Atomics.load(this.status, 2);
|
|
942
|
+
const len = Atomics.load(this.status, 1);
|
|
943
|
+
const payload = JSON.parse(new TextDecoder().decode(this.data.subarray(0, len)));
|
|
944
|
+
if (code === 2) {
|
|
945
|
+
throw new Error(payload.message ?? "PostgreSQL error");
|
|
946
|
+
}
|
|
947
|
+
return payload;
|
|
948
|
+
}
|
|
949
|
+
if (responding !== 0) {
|
|
950
|
+
Atomics.compareExchange(this.status, 0, responding, 0);
|
|
951
|
+
continue;
|
|
952
|
+
}
|
|
953
|
+
if (remaining <= 0) {
|
|
954
|
+
if (this.lastError)
|
|
955
|
+
throw this.lastError;
|
|
956
|
+
throw new Error(`PostgreSQL query timed out after ${timeoutMs}ms`);
|
|
957
|
+
}
|
|
958
|
+
Atomics.wait(this.status, 0, 0, remaining);
|
|
921
959
|
}
|
|
922
|
-
return payload;
|
|
923
960
|
}
|
|
924
961
|
end() {
|
|
925
962
|
if (this.closed)
|
|
@@ -51894,7 +51931,26 @@ function parseMemoryRow(row) {
|
|
|
51894
51931
|
accessed_at: row["accessed_at"] || null
|
|
51895
51932
|
};
|
|
51896
51933
|
}
|
|
51934
|
+
var RESERVED_AGENT_IDS = new Set([
|
|
51935
|
+
"agent-a",
|
|
51936
|
+
"agent-x",
|
|
51937
|
+
"agent-z",
|
|
51938
|
+
"nonexistent-agent"
|
|
51939
|
+
]);
|
|
51940
|
+
function reservedAgentIdViolation(agentId) {
|
|
51941
|
+
if (!agentId)
|
|
51942
|
+
return null;
|
|
51943
|
+
const normalized = agentId.trim().toLowerCase();
|
|
51944
|
+
if (RESERVED_AGENT_IDS.has(normalized)) {
|
|
51945
|
+
return `Reserved placeholder agent id "${agentId}" cannot own a memory. ` + `Refusing to write: test harnesses must not write memories under placeholder agent ` + `identities. Register a real agent (mementos register-agent <name>) and pass its id.`;
|
|
51946
|
+
}
|
|
51947
|
+
return null;
|
|
51948
|
+
}
|
|
51897
51949
|
function createMemory(input, dedupeMode = "merge", db) {
|
|
51950
|
+
const reservedViolation = reservedAgentIdViolation(input.agent_id);
|
|
51951
|
+
if (reservedViolation) {
|
|
51952
|
+
throw new Error(reservedViolation);
|
|
51953
|
+
}
|
|
51898
51954
|
if (!db && isApiMode()) {
|
|
51899
51955
|
const { status, data } = apiJson("POST", "/memories", { ...input, dedupe: dedupeMode });
|
|
51900
51956
|
if (!data || !data.id) {
|
|
@@ -51944,7 +52000,8 @@ function createMemory(input, dedupeMode = "merge", db) {
|
|
|
51944
52000
|
importance = ?, metadata = ?, expires_at = ?,
|
|
51945
52001
|
when_to_use = ?,
|
|
51946
52002
|
pinned = COALESCE(pinned, 0),
|
|
51947
|
-
version = version + 1, updated_at =
|
|
52003
|
+
version = version + 1, updated_at = ?,
|
|
52004
|
+
updated_by_agent = ?
|
|
51948
52005
|
WHERE id = ?`, [
|
|
51949
52006
|
safeValue,
|
|
51950
52007
|
input.category || "knowledge",
|
|
@@ -51955,6 +52012,7 @@ function createMemory(input, dedupeMode = "merge", db) {
|
|
|
51955
52012
|
expiresAt,
|
|
51956
52013
|
input.when_to_use || null,
|
|
51957
52014
|
timestamp,
|
|
52015
|
+
input.agent_id || null,
|
|
51958
52016
|
existing.id
|
|
51959
52017
|
]);
|
|
51960
52018
|
d.run("DELETE FROM memory_tags WHERE memory_id = ?", [existing.id]);
|
|
@@ -52256,6 +52314,11 @@ function listMemoriesPage(filter, db) {
|
|
|
52256
52314
|
agent_id: f.agent_id,
|
|
52257
52315
|
project_id: f.project_id,
|
|
52258
52316
|
session_id: f.session_id,
|
|
52317
|
+
machine_id: f.machine_id,
|
|
52318
|
+
visible_to_machine_id: f.visible_to_machine_id,
|
|
52319
|
+
search: f.search,
|
|
52320
|
+
source: f.source,
|
|
52321
|
+
flag: f.flag,
|
|
52259
52322
|
namespace: f.namespace,
|
|
52260
52323
|
as_of: f.as_of,
|
|
52261
52324
|
limit: f.limit,
|
|
@@ -52398,20 +52461,29 @@ function updateMemory(id, input, db) {
|
|
|
52398
52461
|
sets.push("when_to_use = ?");
|
|
52399
52462
|
params.push(input.when_to_use ?? null);
|
|
52400
52463
|
}
|
|
52464
|
+
if (input.updated_by_agent !== undefined) {
|
|
52465
|
+
sets.push("updated_by_agent = ?");
|
|
52466
|
+
params.push(input.updated_by_agent ?? null);
|
|
52467
|
+
}
|
|
52401
52468
|
if (input.tags !== undefined) {
|
|
52402
52469
|
sets.push("tags = ?");
|
|
52403
52470
|
params.push(JSON.stringify(input.tags));
|
|
52404
|
-
d.run("DELETE FROM memory_tags WHERE memory_id = ?", [memoryId]);
|
|
52405
|
-
const insertTag = d.prepare("INSERT OR IGNORE INTO memory_tags (memory_id, tag) VALUES (?, ?)");
|
|
52406
|
-
for (const tag of input.tags) {
|
|
52407
|
-
insertTag.run(memoryId, tag);
|
|
52408
|
-
}
|
|
52409
52471
|
}
|
|
52410
52472
|
params.push(memoryId);
|
|
52411
|
-
|
|
52412
|
-
|
|
52413
|
-
|
|
52414
|
-
|
|
52473
|
+
d.transaction(() => {
|
|
52474
|
+
const res = d.run(`UPDATE memories SET ${sets.join(", ")} WHERE id = ?`, params);
|
|
52475
|
+
if (res.changes === 0) {
|
|
52476
|
+
throw new Error(`Update affected no rows for memory ${memoryId}: the record was read but not written. ` + `This is a bug in @hasna/mementos, not a bad argument \u2014 please report it.`);
|
|
52477
|
+
}
|
|
52478
|
+
if (input.tags !== undefined) {
|
|
52479
|
+
d.run("DELETE FROM memory_tags WHERE memory_id = ?", [memoryId]);
|
|
52480
|
+
const insertTag = d.prepare("INSERT OR IGNORE INTO memory_tags (memory_id, tag) VALUES (?, ?)");
|
|
52481
|
+
for (const tag of input.tags) {
|
|
52482
|
+
insertTag.run(memoryId, tag);
|
|
52483
|
+
}
|
|
52484
|
+
}
|
|
52485
|
+
return res;
|
|
52486
|
+
});
|
|
52415
52487
|
const updated = getMemory(memoryId, d);
|
|
52416
52488
|
if (input.value !== undefined) {
|
|
52417
52489
|
try {
|
|
@@ -53606,7 +53678,7 @@ function acquireLock(agentId, resourceType, resourceId, lockType = "exclusive",
|
|
|
53606
53678
|
}
|
|
53607
53679
|
const d = db || getDatabase();
|
|
53608
53680
|
cleanExpiredLocks(d);
|
|
53609
|
-
const ownLock = d.query("SELECT * FROM resource_locks WHERE resource_type = ? AND resource_id = ? AND agent_id = ? AND lock_type = ? AND expires_at >
|
|
53681
|
+
const ownLock = d.query("SELECT * FROM resource_locks WHERE resource_type = ? AND resource_id = ? AND agent_id = ? AND lock_type = ? AND expires_at > strftime('%Y-%m-%dT%H:%M:%fZ', 'now')").get(resourceType, resourceId, agentId, lockType);
|
|
53610
53682
|
if (ownLock) {
|
|
53611
53683
|
const newExpiry = new Date(Date.now() + ttlSeconds * 1000).toISOString();
|
|
53612
53684
|
d.run("UPDATE resource_locks SET expires_at = ? WHERE id = ?", [
|
|
@@ -53616,7 +53688,7 @@ function acquireLock(agentId, resourceType, resourceId, lockType = "exclusive",
|
|
|
53616
53688
|
return parseLockRow({ ...ownLock, expires_at: newExpiry });
|
|
53617
53689
|
}
|
|
53618
53690
|
if (lockType === "exclusive") {
|
|
53619
|
-
const existing = d.query("SELECT * FROM resource_locks WHERE resource_type = ? AND resource_id = ? AND lock_type = 'exclusive' AND agent_id != ? AND expires_at >
|
|
53691
|
+
const existing = d.query("SELECT * FROM resource_locks WHERE resource_type = ? AND resource_id = ? AND lock_type = 'exclusive' AND agent_id != ? AND expires_at > strftime('%Y-%m-%dT%H:%M:%fZ', 'now')").get(resourceType, resourceId, agentId);
|
|
53620
53692
|
if (existing) {
|
|
53621
53693
|
return null;
|
|
53622
53694
|
}
|
|
@@ -53666,13 +53738,13 @@ function checkLock(resourceType, resourceId, lockType, db) {
|
|
|
53666
53738
|
}
|
|
53667
53739
|
const d = db || getDatabase();
|
|
53668
53740
|
cleanExpiredLocks(d);
|
|
53669
|
-
const query = lockType ? "SELECT * FROM resource_locks WHERE resource_type = ? AND resource_id = ? AND lock_type = ? AND expires_at >
|
|
53741
|
+
const query = lockType ? "SELECT * FROM resource_locks WHERE resource_type = ? AND resource_id = ? AND lock_type = ? AND expires_at > strftime('%Y-%m-%dT%H:%M:%fZ', 'now')" : "SELECT * FROM resource_locks WHERE resource_type = ? AND resource_id = ? AND expires_at > strftime('%Y-%m-%dT%H:%M:%fZ', 'now')";
|
|
53670
53742
|
const rows = lockType ? d.query(query).all(resourceType, resourceId, lockType) : d.query(query).all(resourceType, resourceId);
|
|
53671
53743
|
return rows.map(parseLockRow);
|
|
53672
53744
|
}
|
|
53673
53745
|
function agentHoldsLock(agentId, resourceType, resourceId, lockType, db) {
|
|
53674
53746
|
const d = db || getDatabase();
|
|
53675
|
-
const query = lockType ? "SELECT * FROM resource_locks WHERE agent_id = ? AND resource_type = ? AND resource_id = ? AND lock_type = ? AND expires_at >
|
|
53747
|
+
const query = lockType ? "SELECT * FROM resource_locks WHERE agent_id = ? AND resource_type = ? AND resource_id = ? AND lock_type = ? AND expires_at > strftime('%Y-%m-%dT%H:%M:%fZ', 'now')" : "SELECT * FROM resource_locks WHERE agent_id = ? AND resource_type = ? AND resource_id = ? AND expires_at > strftime('%Y-%m-%dT%H:%M:%fZ', 'now')";
|
|
53676
53748
|
const row = lockType ? d.query(query).get(agentId, resourceType, resourceId, lockType) : d.query(query).get(agentId, resourceType, resourceId);
|
|
53677
53749
|
return row ? parseLockRow(row) : null;
|
|
53678
53750
|
}
|
|
@@ -53683,7 +53755,7 @@ function listAgentLocks(agentId, db) {
|
|
|
53683
53755
|
}
|
|
53684
53756
|
const d = db || getDatabase();
|
|
53685
53757
|
cleanExpiredLocks(d);
|
|
53686
|
-
const rows = d.query("SELECT * FROM resource_locks WHERE agent_id = ? AND expires_at >
|
|
53758
|
+
const rows = d.query("SELECT * FROM resource_locks WHERE agent_id = ? AND expires_at > strftime('%Y-%m-%dT%H:%M:%fZ', 'now') ORDER BY locked_at DESC").all(agentId);
|
|
53687
53759
|
return rows.map(parseLockRow);
|
|
53688
53760
|
}
|
|
53689
53761
|
function cleanExpiredLocks(db) {
|
|
@@ -53692,7 +53764,7 @@ function cleanExpiredLocks(db) {
|
|
|
53692
53764
|
return data?.cleaned ?? 0;
|
|
53693
53765
|
}
|
|
53694
53766
|
const d = db || getDatabase();
|
|
53695
|
-
const result = d.run("DELETE FROM resource_locks WHERE expires_at <=
|
|
53767
|
+
const result = d.run("DELETE FROM resource_locks WHERE expires_at <= strftime('%Y-%m-%dT%H:%M:%fZ', 'now')");
|
|
53696
53768
|
return result.changes;
|
|
53697
53769
|
}
|
|
53698
53770
|
// src/lib/memory-lock.ts
|
|
@@ -56607,7 +56679,7 @@ function buildFilterConditions(filter) {
|
|
|
56607
56679
|
const conditions = [];
|
|
56608
56680
|
const params = [];
|
|
56609
56681
|
conditions.push("m.status = 'active'");
|
|
56610
|
-
conditions.push("(m.expires_at IS NULL OR m.expires_at >=
|
|
56682
|
+
conditions.push("(m.expires_at IS NULL OR m.expires_at >= strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))");
|
|
56611
56683
|
if (!filter)
|
|
56612
56684
|
return { conditions, params };
|
|
56613
56685
|
if (filter.scope) {
|
|
@@ -58077,6 +58149,7 @@ function syncMemoriesTable(source, target, local, direction, currentMachineId) {
|
|
|
58077
58149
|
const countResult = source.get(`SELECT COUNT(*) as cnt FROM "${MEMORY_TABLE}"`);
|
|
58078
58150
|
stat.total_rows = countResult?.cnt ?? 0;
|
|
58079
58151
|
const rows = since ? source.all(`SELECT * FROM "${MEMORY_TABLE}" WHERE updated_at > ?`, since) : source.all(`SELECT * FROM "${MEMORY_TABLE}"`);
|
|
58152
|
+
const erroredRowIds = new Set;
|
|
58080
58153
|
for (const row of rows) {
|
|
58081
58154
|
try {
|
|
58082
58155
|
const sourceMachine = sourceMachineRef(row, currentMachineId);
|
|
@@ -58135,18 +58208,34 @@ function syncMemoriesTable(source, target, local, direction, currentMachineId) {
|
|
|
58135
58208
|
clearMemoryEmbedding(winnerDb, String(winner["id"]));
|
|
58136
58209
|
stat.synced_rows++;
|
|
58137
58210
|
} catch (error) {
|
|
58211
|
+
erroredRowIds.add(String(row["id"] ?? "unknown"));
|
|
58138
58212
|
stat.errors.push(`Memory ${String(row["id"] ?? "unknown")}: ${error instanceof Error ? error.message : String(error)}`);
|
|
58139
58213
|
}
|
|
58140
58214
|
}
|
|
58141
58215
|
if (rows.length === 0) {
|
|
58142
58216
|
stat.skipped_rows = stat.total_rows;
|
|
58143
58217
|
}
|
|
58144
|
-
|
|
58145
|
-
|
|
58146
|
-
|
|
58147
|
-
|
|
58148
|
-
|
|
58149
|
-
|
|
58218
|
+
if (rows.length > 0 && stat.errors.length === 0) {
|
|
58219
|
+
let maxSyncedAt = null;
|
|
58220
|
+
for (const row of rows) {
|
|
58221
|
+
if (erroredRowIds.has(String(row["id"] ?? "unknown"))) {
|
|
58222
|
+
continue;
|
|
58223
|
+
}
|
|
58224
|
+
const value = row["updated_at"];
|
|
58225
|
+
if (typeof value === "string" && (maxSyncedAt === null || value > maxSyncedAt)) {
|
|
58226
|
+
maxSyncedAt = value;
|
|
58227
|
+
}
|
|
58228
|
+
}
|
|
58229
|
+
const nextCursor = maxSyncedAt ?? syncMeta?.last_synced_at ?? null;
|
|
58230
|
+
if (nextCursor !== null) {
|
|
58231
|
+
upsertMemorySyncMeta(local, {
|
|
58232
|
+
table_name: MEMORY_TABLE,
|
|
58233
|
+
direction,
|
|
58234
|
+
last_synced_at: nextCursor,
|
|
58235
|
+
last_synced_row_count: stat.synced_rows
|
|
58236
|
+
});
|
|
58237
|
+
}
|
|
58238
|
+
}
|
|
58150
58239
|
} catch (error) {
|
|
58151
58240
|
stat.errors.push(error instanceof Error ? error.message : String(error));
|
|
58152
58241
|
}
|
|
@@ -60567,7 +60656,7 @@ function getTaskStats(db, filter2) {
|
|
|
60567
60656
|
const priorityRows = db.query(`SELECT priority, COUNT(*) as c FROM tasks ${where} GROUP BY priority`).all(...params);
|
|
60568
60657
|
for (const row of priorityRows)
|
|
60569
60658
|
byPriority[row.priority] = row.c;
|
|
60570
|
-
const overdue = db.query(`SELECT COUNT(*) as c FROM tasks ${where} AND status != 'completed' AND status != 'cancelled' AND due_at IS NOT NULL AND due_at <
|
|
60659
|
+
const overdue = db.query(`SELECT COUNT(*) as c FROM tasks ${where} AND status != 'completed' AND status != 'cancelled' AND due_at IS NOT NULL AND due_at < strftime('%Y-%m-%dT%H:%M:%fZ', 'now')`).get(...params).c;
|
|
60571
60660
|
return {
|
|
60572
60661
|
total,
|
|
60573
60662
|
by_status: {
|