@opendatalabs/personal-server-ts-core 1.34.2 → 1.35.0
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/dist/additions/durable.d.ts +32 -2
- package/dist/additions/durable.d.ts.map +1 -1
- package/dist/additions/durable.js +237 -88
- package/dist/additions/durable.js.map +1 -1
- package/dist/additions/version-inventory.d.ts +4 -0
- package/dist/additions/version-inventory.d.ts.map +1 -1
- package/dist/additions/version-inventory.js +11 -1
- package/dist/additions/version-inventory.js.map +1 -1
- package/dist/api/index.d.ts +18 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +172 -4
- package/dist/api/index.js.map +1 -1
- package/dist/api/oura-collection-requirements.d.ts +16 -0
- package/dist/api/oura-collection-requirements.d.ts.map +1 -0
- package/dist/api/oura-collection-requirements.js +70 -0
- package/dist/api/oura-collection-requirements.js.map +1 -0
- package/dist/api/scope-upload-batches.d.ts +18 -0
- package/dist/api/scope-upload-batches.d.ts.map +1 -0
- package/dist/api/scope-upload-batches.js +71 -0
- package/dist/api/scope-upload-batches.js.map +1 -0
- package/dist/api/scope-uploads.d.ts +112 -0
- package/dist/api/scope-uploads.d.ts.map +1 -0
- package/dist/api/scope-uploads.js +369 -0
- package/dist/api/scope-uploads.js.map +1 -0
- package/dist/client.d.ts +70 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1 -0
- package/dist/client.js.map +1 -1
- package/dist/contracts/data.d.ts +8 -0
- package/dist/contracts/data.d.ts.map +1 -1
- package/dist/contracts/data.js +31 -1
- package/dist/contracts/data.js.map +1 -1
- package/dist/contracts/grants.d.ts.map +1 -1
- package/dist/contracts/grants.js +3 -0
- package/dist/contracts/grants.js.map +1 -1
- package/dist/contracts/index.d.ts +3 -1
- package/dist/contracts/index.d.ts.map +1 -1
- package/dist/contracts/index.js +3 -1
- package/dist/contracts/index.js.map +1 -1
- package/dist/contracts/oura-collection-requirements.d.ts +17 -0
- package/dist/contracts/oura-collection-requirements.d.ts.map +1 -0
- package/dist/contracts/oura-collection-requirements.js +49 -0
- package/dist/contracts/oura-collection-requirements.js.map +1 -0
- package/dist/legacy-projection/bindings.d.ts +1 -7
- package/dist/legacy-projection/bindings.d.ts.map +1 -1
- package/dist/legacy-projection/bindings.js +162 -28
- package/dist/legacy-projection/bindings.js.map +1 -1
- package/dist/legacy-projection/index.d.ts +6 -5
- package/dist/legacy-projection/index.d.ts.map +1 -1
- package/dist/legacy-projection/index.js +9 -21
- package/dist/legacy-projection/index.js.map +1 -1
- package/dist/legacy-projection/oura-browser-bindings.d.ts +2 -0
- package/dist/legacy-projection/oura-browser-bindings.d.ts.map +1 -1
- package/dist/legacy-projection/oura-browser-bindings.js +2 -0
- package/dist/legacy-projection/oura-browser-bindings.js.map +1 -1
- package/dist/legacy-projection/strava-browser-bindings.d.ts +3 -0
- package/dist/legacy-projection/strava-browser-bindings.d.ts.map +1 -0
- package/dist/legacy-projection/strava-browser-bindings.js +32 -0
- package/dist/legacy-projection/strava-browser-bindings.js.map +1 -0
- package/dist/legacy-projection/types.d.ts +44 -12
- package/dist/legacy-projection/types.d.ts.map +1 -1
- package/dist/mcp/connection-api.d.ts +11 -1
- package/dist/mcp/connection-api.d.ts.map +1 -1
- package/dist/mcp/connection-api.js +94 -9
- package/dist/mcp/connection-api.js.map +1 -1
- package/dist/mcp/index.d.ts +1 -0
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +1 -0
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/server.d.ts +9 -0
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +19 -6
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/store.d.ts +10 -1
- package/dist/mcp/store.d.ts.map +1 -1
- package/dist/mcp/store.js +51 -0
- package/dist/mcp/store.js.map +1 -1
- package/dist/mcp/tools.d.ts +52 -2
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +395 -11
- package/dist/mcp/tools.js.map +1 -1
- package/dist/mcp/types.d.ts +36 -2
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/mcp/types.js +12 -0
- package/dist/mcp/types.js.map +1 -1
- package/dist/mcp/write-client.d.ts +81 -0
- package/dist/mcp/write-client.d.ts.map +1 -0
- package/dist/mcp/write-client.js +140 -0
- package/dist/mcp/write-client.js.map +1 -0
- package/dist/oura/history-policy.d.ts +12 -0
- package/dist/oura/history-policy.d.ts.map +1 -0
- package/dist/oura/history-policy.js +54 -0
- package/dist/oura/history-policy.js.map +1 -0
- package/dist/oura/index.d.ts +51 -0
- package/dist/oura/index.d.ts.map +1 -0
- package/dist/oura/index.js +315 -0
- package/dist/oura/index.js.map +1 -0
- package/dist/pdpp/approval.d.ts +1 -1
- package/dist/pdpp/approval.d.ts.map +1 -1
- package/dist/pdpp/approval.js +29 -10
- package/dist/pdpp/approval.js.map +1 -1
- package/dist/pdpp/declaration-limits.d.ts +7 -0
- package/dist/pdpp/declaration-limits.d.ts.map +1 -0
- package/dist/pdpp/declaration-limits.js +7 -0
- package/dist/pdpp/declaration-limits.js.map +1 -0
- package/dist/pdpp/declaration.d.ts +2 -1
- package/dist/pdpp/declaration.d.ts.map +1 -1
- package/dist/pdpp/declaration.js +2 -1
- package/dist/pdpp/declaration.js.map +1 -1
- package/dist/pdpp/index.d.ts +3 -2
- package/dist/pdpp/index.d.ts.map +1 -1
- package/dist/pdpp/index.js +3 -2
- package/dist/pdpp/index.js.map +1 -1
- package/dist/pdpp/issuance.d.ts.map +1 -1
- package/dist/pdpp/issuance.js +6 -2
- package/dist/pdpp/issuance.js.map +1 -1
- package/dist/pdpp/resolve.d.ts +12 -1
- package/dist/pdpp/resolve.d.ts.map +1 -1
- package/dist/pdpp/resolve.js +156 -58
- package/dist/pdpp/resolve.js.map +1 -1
- package/dist/pdpp/selection.d.ts +30 -1
- package/dist/pdpp/selection.d.ts.map +1 -1
- package/dist/pdpp/selection.js +77 -26
- package/dist/pdpp/selection.js.map +1 -1
- package/dist/pdpp/time.d.ts +39 -0
- package/dist/pdpp/time.d.ts.map +1 -0
- package/dist/pdpp/time.js +173 -0
- package/dist/pdpp/time.js.map +1 -0
- package/dist/pdpp/tokens.d.ts.map +1 -1
- package/dist/pdpp/tokens.js +4 -2
- package/dist/pdpp/tokens.js.map +1 -1
- package/dist/pdpp/types.d.ts +18 -2
- package/dist/pdpp/types.d.ts.map +1 -1
- package/dist/pdpp/types.js +7 -0
- package/dist/pdpp/types.js.map +1 -1
- package/dist/policy/reserved-scopes.d.ts +7 -0
- package/dist/policy/reserved-scopes.d.ts.map +1 -1
- package/dist/policy/reserved-scopes.js +12 -1
- package/dist/policy/reserved-scopes.js.map +1 -1
- package/dist/ports/index.d.ts +85 -1
- package/dist/ports/index.d.ts.map +1 -1
- package/dist/ports/index.js.map +1 -1
- package/dist/ports/pdpp-auth.d.ts +17 -27
- package/dist/ports/pdpp-auth.d.ts.map +1 -1
- package/dist/ports/pdpp-auth.js +14 -28
- package/dist/ports/pdpp-auth.js.map +1 -1
- package/dist/publication/publish.d.ts +96 -0
- package/dist/publication/publish.d.ts.map +1 -0
- package/dist/publication/publish.js +261 -0
- package/dist/publication/publish.js.map +1 -0
- package/dist/replication/completion.d.ts +20 -0
- package/dist/replication/completion.d.ts.map +1 -0
- package/dist/replication/completion.js +73 -0
- package/dist/replication/completion.js.map +1 -0
- package/dist/replication/coordinator-state.d.ts +29 -0
- package/dist/replication/coordinator-state.d.ts.map +1 -0
- package/dist/replication/coordinator-state.js +88 -0
- package/dist/replication/coordinator-state.js.map +1 -0
- package/dist/replication/coordinator-state.test-utils.d.ts +32 -0
- package/dist/replication/coordinator-state.test-utils.d.ts.map +1 -0
- package/dist/replication/coordinator-state.test-utils.js +113 -0
- package/dist/replication/coordinator-state.test-utils.js.map +1 -0
- package/dist/replication/coordinator.d.ts +264 -0
- package/dist/replication/coordinator.d.ts.map +1 -0
- package/dist/replication/coordinator.js +499 -0
- package/dist/replication/coordinator.js.map +1 -0
- package/dist/replication/copies.d.ts +126 -0
- package/dist/replication/copies.d.ts.map +1 -0
- package/dist/replication/copies.js +437 -0
- package/dist/replication/copies.js.map +1 -0
- package/dist/replication/copy-promotion.d.ts +132 -0
- package/dist/replication/copy-promotion.d.ts.map +1 -0
- package/dist/replication/copy-promotion.js +126 -0
- package/dist/replication/copy-promotion.js.map +1 -0
- package/dist/replication/door.d.ts +33 -0
- package/dist/replication/door.d.ts.map +1 -0
- package/dist/replication/door.js +10 -0
- package/dist/replication/door.js.map +1 -0
- package/dist/replication/dpv2.d.ts +141 -0
- package/dist/replication/dpv2.d.ts.map +1 -0
- package/dist/replication/dpv2.js +320 -0
- package/dist/replication/dpv2.js.map +1 -0
- package/dist/replication/effects.d.ts +68 -0
- package/dist/replication/effects.d.ts.map +1 -0
- package/dist/replication/effects.js +89 -0
- package/dist/replication/effects.js.map +1 -0
- package/dist/replication/engine.d.ts +378 -0
- package/dist/replication/engine.d.ts.map +1 -0
- package/dist/replication/engine.js +3197 -0
- package/dist/replication/engine.js.map +1 -0
- package/dist/replication/envelope.d.ts +481 -0
- package/dist/replication/envelope.d.ts.map +1 -0
- package/dist/replication/envelope.js +192 -0
- package/dist/replication/envelope.js.map +1 -0
- package/dist/replication/evidence.d.ts +118 -0
- package/dist/replication/evidence.d.ts.map +1 -0
- package/dist/replication/evidence.js +198 -0
- package/dist/replication/evidence.js.map +1 -0
- package/dist/replication/finality.d.ts +16 -0
- package/dist/replication/finality.d.ts.map +1 -0
- package/dist/replication/finality.js +11 -0
- package/dist/replication/finality.js.map +1 -0
- package/dist/replication/fixtures.d.ts +16 -0
- package/dist/replication/fixtures.d.ts.map +1 -0
- package/dist/replication/fixtures.js +47 -0
- package/dist/replication/fixtures.js.map +1 -0
- package/dist/replication/host-config.d.ts +52 -0
- package/dist/replication/host-config.d.ts.map +1 -0
- package/dist/replication/host-config.js +111 -0
- package/dist/replication/host-config.js.map +1 -0
- package/dist/replication/host-driver.d.ts +95 -0
- package/dist/replication/host-driver.d.ts.map +1 -0
- package/dist/replication/host-driver.js +202 -0
- package/dist/replication/host-driver.js.map +1 -0
- package/dist/replication/host-ports.d.ts +48 -0
- package/dist/replication/host-ports.d.ts.map +1 -0
- package/dist/replication/host-ports.js +69 -0
- package/dist/replication/host-ports.js.map +1 -0
- package/dist/replication/identity.d.ts +13 -0
- package/dist/replication/identity.d.ts.map +1 -0
- package/dist/replication/identity.js +22 -0
- package/dist/replication/identity.js.map +1 -0
- package/dist/replication/limits.d.ts +124 -0
- package/dist/replication/limits.d.ts.map +1 -0
- package/dist/replication/limits.js +182 -0
- package/dist/replication/limits.js.map +1 -0
- package/dist/replication/merge-plan.d.ts +92 -0
- package/dist/replication/merge-plan.d.ts.map +1 -0
- package/dist/replication/merge-plan.js +229 -0
- package/dist/replication/merge-plan.js.map +1 -0
- package/dist/replication/namespace.d.ts +4 -0
- package/dist/replication/namespace.d.ts.map +1 -0
- package/dist/replication/namespace.js +7 -0
- package/dist/replication/namespace.js.map +1 -0
- package/dist/replication/outcome.d.ts +178 -0
- package/dist/replication/outcome.d.ts.map +1 -0
- package/dist/replication/outcome.js +83 -0
- package/dist/replication/outcome.js.map +1 -0
- package/dist/replication/payload.d.ts +39 -0
- package/dist/replication/payload.d.ts.map +1 -0
- package/dist/replication/payload.js +137 -0
- package/dist/replication/payload.js.map +1 -0
- package/dist/replication/preparation.d.ts +42 -0
- package/dist/replication/preparation.d.ts.map +1 -0
- package/dist/replication/preparation.js +118 -0
- package/dist/replication/preparation.js.map +1 -0
- package/dist/replication/rebaseline.d.ts +33 -0
- package/dist/replication/rebaseline.d.ts.map +1 -0
- package/dist/replication/rebaseline.js +40 -0
- package/dist/replication/rebaseline.js.map +1 -0
- package/dist/replication/rebinding.d.ts +43 -0
- package/dist/replication/rebinding.d.ts.map +1 -0
- package/dist/replication/rebinding.js +52 -0
- package/dist/replication/rebinding.js.map +1 -0
- package/dist/replication/receive.d.ts +57 -0
- package/dist/replication/receive.d.ts.map +1 -0
- package/dist/replication/receive.js +114 -0
- package/dist/replication/receive.js.map +1 -0
- package/dist/replication/record-reducer.d.ts +16 -0
- package/dist/replication/record-reducer.d.ts.map +1 -0
- package/dist/replication/record-reducer.js +52 -0
- package/dist/replication/record-reducer.js.map +1 -0
- package/dist/replication/revision.d.ts +24 -0
- package/dist/replication/revision.d.ts.map +1 -0
- package/dist/replication/revision.js +35 -0
- package/dist/replication/revision.js.map +1 -0
- package/dist/replication/roster.d.ts +53 -0
- package/dist/replication/roster.d.ts.map +1 -0
- package/dist/replication/roster.js +115 -0
- package/dist/replication/roster.js.map +1 -0
- package/dist/replication/schedule.d.ts +73 -0
- package/dist/replication/schedule.d.ts.map +1 -0
- package/dist/replication/schedule.js +182 -0
- package/dist/replication/schedule.js.map +1 -0
- package/dist/replication/stream.d.ts +73 -0
- package/dist/replication/stream.d.ts.map +1 -0
- package/dist/replication/stream.js +542 -0
- package/dist/replication/stream.js.map +1 -0
- package/dist/replication/transport.d.ts +236 -0
- package/dist/replication/transport.d.ts.map +1 -0
- package/dist/replication/transport.js +440 -0
- package/dist/replication/transport.js.map +1 -0
- package/dist/replication/visibility-engine.d.ts +337 -0
- package/dist/replication/visibility-engine.d.ts.map +1 -0
- package/dist/replication/visibility-engine.js +602 -0
- package/dist/replication/visibility-engine.js.map +1 -0
- package/dist/replication/visibility-policy.d.ts +26 -0
- package/dist/replication/visibility-policy.d.ts.map +1 -0
- package/dist/replication/visibility-policy.js +33 -0
- package/dist/replication/visibility-policy.js.map +1 -0
- package/dist/replication/writer-identity-store.d.ts +100 -0
- package/dist/replication/writer-identity-store.d.ts.map +1 -0
- package/dist/replication/writer-identity-store.js +218 -0
- package/dist/replication/writer-identity-store.js.map +1 -0
- package/dist/replication/writer-identity.d.ts +252 -0
- package/dist/replication/writer-identity.d.ts.map +1 -0
- package/dist/replication/writer-identity.js +281 -0
- package/dist/replication/writer-identity.js.map +1 -0
- package/dist/replication/writer-identity.test-utils.d.ts +24 -0
- package/dist/replication/writer-identity.test-utils.d.ts.map +1 -0
- package/dist/replication/writer-identity.test-utils.js +86 -0
- package/dist/replication/writer-identity.test-utils.js.map +1 -0
- package/dist/schemas/server-config.d.ts +13 -0
- package/dist/schemas/server-config.d.ts.map +1 -1
- package/dist/schemas/server-config.js +24 -0
- package/dist/schemas/server-config.js.map +1 -1
- package/dist/storage/adapters/index.d.ts +3 -1
- package/dist/storage/adapters/index.d.ts.map +1 -1
- package/dist/storage/adapters/index.js +2 -0
- package/dist/storage/adapters/index.js.map +1 -1
- package/dist/storage/adapters/interface.d.ts +18 -1
- package/dist/storage/adapters/interface.d.ts.map +1 -1
- package/dist/storage/adapters/interface.js +13 -1
- package/dist/storage/adapters/interface.js.map +1 -1
- package/dist/storage/adapters/sdk.d.ts +2 -1
- package/dist/storage/adapters/sdk.d.ts.map +1 -1
- package/dist/storage/adapters/sdk.js +21 -3
- package/dist/storage/adapters/sdk.js.map +1 -1
- package/dist/storage/adapters/vana-audience.d.ts +17 -5
- package/dist/storage/adapters/vana-audience.d.ts.map +1 -1
- package/dist/storage/adapters/vana-audience.js +24 -9
- package/dist/storage/adapters/vana-audience.js.map +1 -1
- package/dist/storage/adapters/vana.d.ts +2 -2
- package/dist/storage/adapters/vana.d.ts.map +1 -1
- package/dist/storage/adapters/vana.js +30 -22
- package/dist/storage/adapters/vana.js.map +1 -1
- package/dist/storage/canonical-legacy-projection.d.ts +1 -1
- package/dist/storage/canonical-legacy-projection.d.ts.map +1 -1
- package/dist/storage/canonical-legacy-projection.js +13 -15
- package/dist/storage/canonical-legacy-projection.js.map +1 -1
- package/dist/storage/legacy-projection.d.ts.map +1 -1
- package/dist/storage/legacy-projection.js +16 -1
- package/dist/storage/legacy-projection.js.map +1 -1
- package/dist/storage/legacy-scope-coverage-exceptions.d.ts +5 -0
- package/dist/storage/legacy-scope-coverage-exceptions.d.ts.map +1 -1
- package/dist/storage/legacy-scope-coverage-exceptions.js +4 -0
- package/dist/storage/legacy-scope-coverage-exceptions.js.map +1 -1
- package/dist/storage/legacy-scope-coverage.d.ts.map +1 -1
- package/dist/storage/legacy-scope-coverage.js +14 -1
- package/dist/storage/legacy-scope-coverage.js.map +1 -1
- package/dist/storage/legacy-scope-entity-keys.d.ts +14 -1
- package/dist/storage/legacy-scope-entity-keys.d.ts.map +1 -1
- package/dist/storage/legacy-scope-entity-keys.js +18 -1
- package/dist/storage/legacy-scope-entity-keys.js.map +1 -1
- package/dist/storage/legacy-scope-view.d.ts +57 -5
- package/dist/storage/legacy-scope-view.d.ts.map +1 -1
- package/dist/storage/legacy-scope-view.js +644 -318
- package/dist/storage/legacy-scope-view.js.map +1 -1
- package/dist/storage/pdpp-records/cursor.d.ts +47 -2
- package/dist/storage/pdpp-records/cursor.d.ts.map +1 -1
- package/dist/storage/pdpp-records/cursor.js +7 -0
- package/dist/storage/pdpp-records/cursor.js.map +1 -1
- package/dist/storage/pdpp-records/enforcement.d.ts +3 -16
- package/dist/storage/pdpp-records/enforcement.d.ts.map +1 -1
- package/dist/storage/pdpp-records/enforcement.js +40 -13
- package/dist/storage/pdpp-records/enforcement.js.map +1 -1
- package/dist/storage/pdpp-records/index.d.ts +2 -0
- package/dist/storage/pdpp-records/index.d.ts.map +1 -1
- package/dist/storage/pdpp-records/index.js +1 -0
- package/dist/storage/pdpp-records/index.js.map +1 -1
- package/dist/storage/pdpp-records/interface.d.ts +8 -1
- package/dist/storage/pdpp-records/interface.d.ts.map +1 -1
- package/dist/storage/pdpp-records/list-page.d.ts +35 -0
- package/dist/storage/pdpp-records/list-page.d.ts.map +1 -0
- package/dist/storage/pdpp-records/list-page.js +106 -0
- package/dist/storage/pdpp-records/list-page.js.map +1 -0
- package/dist/storage/pdpp-records/memory-store.d.ts.map +1 -1
- package/dist/storage/pdpp-records/memory-store.js +95 -99
- package/dist/storage/pdpp-records/memory-store.js.map +1 -1
- package/dist/storage/pdpp-records/portable.d.ts +3 -0
- package/dist/storage/pdpp-records/portable.d.ts.map +1 -1
- package/dist/storage/pdpp-records/portable.js +3 -0
- package/dist/storage/pdpp-records/portable.js.map +1 -1
- package/dist/storage/pdpp-records/replication-journal.d.ts +20 -0
- package/dist/storage/pdpp-records/replication-journal.d.ts.map +1 -0
- package/dist/storage/pdpp-records/replication-journal.js +2 -0
- package/dist/storage/pdpp-records/replication-journal.js.map +1 -0
- package/dist/storage/pdpp-records/stream-declaration.d.ts +0 -2
- package/dist/storage/pdpp-records/stream-declaration.d.ts.map +1 -1
- package/dist/storage/pdpp-records/stream-declaration.js +0 -9
- package/dist/storage/pdpp-records/stream-declaration.js.map +1 -1
- package/dist/storage/pdpp-records/sync-selection.d.ts +4 -0
- package/dist/storage/pdpp-records/sync-selection.d.ts.map +1 -0
- package/dist/storage/pdpp-records/sync-selection.js +37 -0
- package/dist/storage/pdpp-records/sync-selection.js.map +1 -0
- package/dist/storage/pdpp-records/types.d.ts +64 -0
- package/dist/storage/pdpp-records/types.d.ts.map +1 -1
- package/dist/storage/pdpp-records/types.js.map +1 -1
- package/dist/sync/delete-data-port.d.ts +15 -0
- package/dist/sync/delete-data-port.d.ts.map +1 -1
- package/dist/sync/delete-data-port.js +19 -7
- package/dist/sync/delete-data-port.js.map +1 -1
- package/dist/sync/index.d.ts +2 -1
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +2 -1
- package/dist/sync/index.js.map +1 -1
- package/dist/sync/pending-blob-deletions.d.ts +18 -2
- package/dist/sync/pending-blob-deletions.d.ts.map +1 -1
- package/dist/sync/pending-blob-deletions.js +69 -23
- package/dist/sync/pending-blob-deletions.js.map +1 -1
- package/dist/sync/workers/delete.d.ts.map +1 -1
- package/dist/sync/workers/delete.js +316 -142
- package/dist/sync/workers/delete.js.map +1 -1
- package/dist/sync/workers/download.d.ts.map +1 -1
- package/dist/sync/workers/download.js +53 -5
- package/dist/sync/workers/download.js.map +1 -1
- package/dist/sync/workers/upload.d.ts +24 -5
- package/dist/sync/workers/upload.d.ts.map +1 -1
- package/dist/sync/workers/upload.js +160 -275
- package/dist/sync/workers/upload.js.map +1 -1
- package/dist/test-utils/memory-storage.d.ts.map +1 -1
- package/dist/test-utils/memory-storage.js +17 -2
- package/dist/test-utils/memory-storage.js.map +1 -1
- package/package.json +24 -2
package/dist/mcp/tools.js
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
|
-
import { isSystemScope } from "../policy/reserved-scopes.js";
|
|
1
|
+
import { isMemoryScope, isSystemScope } from "../policy/reserved-scopes.js";
|
|
2
2
|
/**
|
|
3
3
|
* MCP tool surface. Phase 1 / §4 of 260604-PLAN-vana-mcp-personal-server.md.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Small, and only over scopes that the connection's grants cover. No
|
|
6
|
+
* grant-approval tools. No raw owner/admin status tools.
|
|
7
7
|
*
|
|
8
8
|
* Every tool that returns data first picks a covering grant from the
|
|
9
9
|
* connection's grant list, signs a Web3Signed request as the per-connection
|
|
10
10
|
* grantee, and uses the bounded sidecar read path — so reads are grant-gated,
|
|
11
11
|
* access-logged, and safe for large scopes.
|
|
12
|
+
*
|
|
13
|
+
* The one write tool, `remember`, saves only into a scope a `write:` grant
|
|
14
|
+
* entry covers, and goes through the delegated-write path a builder uses
|
|
15
|
+
* (see write-client.ts). A read grant never confers write access, and a
|
|
16
|
+
* `write:` entry never confers read access.
|
|
12
17
|
*/
|
|
13
18
|
import { z } from "zod";
|
|
14
19
|
import { MCP_SCOPE_ACCESS_REQUEST_LIMIT, } from "./types.js";
|
|
15
20
|
import { McpDataReadError } from "./read-client.js";
|
|
21
|
+
import { McpDataWriteError } from "./write-client.js";
|
|
22
|
+
import { isWriteScopeEntry, writeScopePatterns, WRITE_SCOPE_PREFIX, } from "../policy/data-write.js";
|
|
16
23
|
import { toMcpScopeAccessRequestView } from "./connection-api.js";
|
|
17
24
|
import { MiniSearchIndex } from "./search/index.js";
|
|
18
25
|
import { MAX_SELECTED_BLOCK_IDS } from "../storage/blocks/index.js";
|
|
@@ -47,20 +54,83 @@ function textResult(value, isError = false) {
|
|
|
47
54
|
...(isError ? { isError: true } : {}),
|
|
48
55
|
};
|
|
49
56
|
}
|
|
57
|
+
/** A grant entry that names readable data: not a system scope, not `write:`. */
|
|
58
|
+
function isReadableScopeEntry(scope) {
|
|
59
|
+
return !isSystemScope(scope) && !isWriteScopeEntry(scope);
|
|
60
|
+
}
|
|
50
61
|
function uniqueScopes(connection) {
|
|
51
62
|
const set = new Set();
|
|
52
63
|
for (const grant of connection.grants) {
|
|
53
64
|
for (const scope of grant.scopes) {
|
|
54
|
-
if (
|
|
65
|
+
if (isReadableScopeEntry(scope))
|
|
55
66
|
set.add(scope);
|
|
56
67
|
}
|
|
57
68
|
}
|
|
58
69
|
return Array.from(set).sort();
|
|
59
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* A scope `remember` may save into under these grant entries: an exact
|
|
73
|
+
* `write:<scope>` entry. MCP writes never honor a `write:` wildcard, even one
|
|
74
|
+
* an older grant still carries, although builder writes do: a memory grant
|
|
75
|
+
* names the one scope the agent saves into.
|
|
76
|
+
*/
|
|
77
|
+
function exactWriteScopes(grantScopes) {
|
|
78
|
+
return writeScopePatterns(grantScopes).filter((scope) => !scope.includes("*") && !isSystemScope(scope));
|
|
79
|
+
}
|
|
80
|
+
/** Scopes the connection may save into, `write:` prefix stripped. */
|
|
81
|
+
function uniqueWritableScopes(connection) {
|
|
82
|
+
const set = new Set();
|
|
83
|
+
for (const grant of connection.grants) {
|
|
84
|
+
for (const scope of exactWriteScopes(grant.scopes))
|
|
85
|
+
set.add(scope);
|
|
86
|
+
}
|
|
87
|
+
return Array.from(set).sort();
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Every data scope (or pattern) the connection may read or write, `write:`
|
|
91
|
+
* prefix stripped. A host that copies data in before serving a connection
|
|
92
|
+
* (the enclave) must copy write targets too: `remember` rewrites the whole
|
|
93
|
+
* memory list from the local copy, so a missing copy would drop memories.
|
|
94
|
+
*/
|
|
95
|
+
export function connectionDataScopes(connection) {
|
|
96
|
+
const set = new Set();
|
|
97
|
+
for (const grant of connection.grants) {
|
|
98
|
+
for (const scope of grant.scopes) {
|
|
99
|
+
const target = isWriteScopeEntry(scope)
|
|
100
|
+
? scope.slice(WRITE_SCOPE_PREFIX.length)
|
|
101
|
+
: scope;
|
|
102
|
+
if (target)
|
|
103
|
+
set.add(target);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return Array.from(set).sort();
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Resolve a scope to a grant with an exact `write:` entry for it (see
|
|
110
|
+
* exactWriteScopes). The server-side write policy still runs on every save;
|
|
111
|
+
* this only narrows what the tool will attempt.
|
|
112
|
+
*/
|
|
113
|
+
export function resolveWriteGrantForScope(connection, scope) {
|
|
114
|
+
for (const grant of connection.grants) {
|
|
115
|
+
if (exactWriteScopes(grant.scopes).includes(scope)) {
|
|
116
|
+
return { grantId: grant.grantId, scopes: grant.scopes };
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Whether the connection already holds `scope` as a scope request names it:
|
|
123
|
+
* a `write:` entry is covered only by write grants, anything else by reads.
|
|
124
|
+
*/
|
|
125
|
+
function connectionCoversRequestedScope(connection, scope) {
|
|
126
|
+
return isWriteScopeEntry(scope)
|
|
127
|
+
? Boolean(resolveWriteGrantForScope(connection, scope.slice(WRITE_SCOPE_PREFIX.length)))
|
|
128
|
+
: Boolean(resolveGrantForScope(connection, scope));
|
|
129
|
+
}
|
|
60
130
|
function uniqueSources(connection) {
|
|
61
131
|
const set = new Set();
|
|
62
132
|
for (const grant of connection.grants) {
|
|
63
|
-
if (!grant.scopes.some(
|
|
133
|
+
if (!grant.scopes.some(isReadableScopeEntry))
|
|
64
134
|
continue;
|
|
65
135
|
const sourceId = typeof grant.sourceId === "string" ? grant.sourceId.trim() : "";
|
|
66
136
|
if (sourceId) {
|
|
@@ -68,7 +138,7 @@ function uniqueSources(connection) {
|
|
|
68
138
|
continue;
|
|
69
139
|
}
|
|
70
140
|
for (const scope of grant.scopes) {
|
|
71
|
-
if (
|
|
141
|
+
if (!isReadableScopeEntry(scope))
|
|
72
142
|
continue;
|
|
73
143
|
const [scopeSourceId] = scope.split(".");
|
|
74
144
|
if (scopeSourceId && scopeSourceId !== "*") {
|
|
@@ -170,7 +240,7 @@ const scopeAccessRequestInputShape = {
|
|
|
170
240
|
.array(z.string().min(1).max(SEARCH_SCOPE_MAX_CHARS))
|
|
171
241
|
.min(1)
|
|
172
242
|
.max(MCP_SCOPE_ACCESS_REQUEST_LIMIT)
|
|
173
|
-
.describe("Exact scope ids
|
|
243
|
+
.describe("Exact scope ids to read, or write:<scope> to save into."),
|
|
174
244
|
reason: z
|
|
175
245
|
.string()
|
|
176
246
|
.max(500)
|
|
@@ -558,8 +628,10 @@ const listGrantedScopes = {
|
|
|
558
628
|
}));
|
|
559
629
|
// Lets an agent that asked for more scopes see whether the owner has
|
|
560
630
|
// answered yet without re-recording the request.
|
|
631
|
+
const writableScopes = uniqueWritableScopes(connection);
|
|
561
632
|
return textResult({
|
|
562
633
|
scopes: scopeEntries,
|
|
634
|
+
...(writableScopes.length > 0 ? { writableScopes } : {}),
|
|
563
635
|
...(connection.scopeAccessRequest
|
|
564
636
|
? {
|
|
565
637
|
pendingScopeRequest: toMcpScopeAccessRequestView(connection.scopeAccessRequest),
|
|
@@ -582,8 +654,8 @@ const requestScopeAccess = {
|
|
|
582
654
|
// answer from the agent that is checking back.
|
|
583
655
|
const previousDecision = connection.scopeAccessDecision;
|
|
584
656
|
let effectiveConnection = connection;
|
|
585
|
-
let grantedRequestedScopes = requestedScopes.filter((scope) =>
|
|
586
|
-
let missingScopes = requestedScopes.filter((scope) => !
|
|
657
|
+
let grantedRequestedScopes = requestedScopes.filter((scope) => connectionCoversRequestedScope(effectiveConnection, scope));
|
|
658
|
+
let missingScopes = requestedScopes.filter((scope) => !connectionCoversRequestedScope(connection, scope));
|
|
587
659
|
const reason = typeof args.reason === "string" ? args.reason.trim() : "";
|
|
588
660
|
const approvalRequired = missingScopes.length > 0;
|
|
589
661
|
const alreadyRecorded = approvalRequired &&
|
|
@@ -598,8 +670,8 @@ const requestScopeAccess = {
|
|
|
598
670
|
effectiveConnection = outcome.connection;
|
|
599
671
|
requestRecorded = outcome.requestRecorded;
|
|
600
672
|
readToken = outcome.readToken;
|
|
601
|
-
grantedRequestedScopes = requestedScopes.filter((scope) =>
|
|
602
|
-
missingScopes = requestedScopes.filter((scope) => !
|
|
673
|
+
grantedRequestedScopes = requestedScopes.filter((scope) => connectionCoversRequestedScope(effectiveConnection, scope));
|
|
674
|
+
missingScopes = requestedScopes.filter((scope) => !connectionCoversRequestedScope(effectiveConnection, scope));
|
|
603
675
|
}
|
|
604
676
|
const finalApprovalRequired = missingScopes.length > 0;
|
|
605
677
|
const recorded = finalApprovalRequired && requestRecorded;
|
|
@@ -1435,6 +1507,316 @@ const getScopeFile = {
|
|
|
1435
1507
|
}
|
|
1436
1508
|
},
|
|
1437
1509
|
};
|
|
1510
|
+
const REMEMBER_TOOL = "remember";
|
|
1511
|
+
const FORGET_TOOL = "forget";
|
|
1512
|
+
const REMEMBER_TEXT_MAX_CHARS = 4_000;
|
|
1513
|
+
const REMEMBER_KEY_MAX_CHARS = 128;
|
|
1514
|
+
const MEMORY_ID_MAX_CHARS = 64;
|
|
1515
|
+
/**
|
|
1516
|
+
* Every save stores a new snapshot of the scope's record list, so the list is
|
|
1517
|
+
* bounded by size rather than count. Sync publishes only the newest snapshot of
|
|
1518
|
+
* a memory scope (see `isCoalescedScope` in sync/workers/upload.ts).
|
|
1519
|
+
*/
|
|
1520
|
+
export const MEMORY_SCOPE_MAX_BYTES = 20 * 1024 * 1024;
|
|
1521
|
+
class RememberRefusal extends Error {
|
|
1522
|
+
body;
|
|
1523
|
+
constructor(body) {
|
|
1524
|
+
super(String(body.message));
|
|
1525
|
+
this.body = body;
|
|
1526
|
+
this.name = "RememberRefusal";
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
/** A save that would only repeat a memory the scope already holds. */
|
|
1530
|
+
class DuplicateMemory extends Error {
|
|
1531
|
+
record;
|
|
1532
|
+
constructor(record) {
|
|
1533
|
+
super("duplicate memory");
|
|
1534
|
+
this.record = record;
|
|
1535
|
+
this.name = "DuplicateMemory";
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
function isPlainRecord(value) {
|
|
1539
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1540
|
+
}
|
|
1541
|
+
/**
|
|
1542
|
+
* The memory records of a stored body. A memory scope holds exactly
|
|
1543
|
+
* `{ records: [...] }` of memory rows, or the earlier `{ memories: [...] }`
|
|
1544
|
+
* list, which is converted here (ids kept). Anything else was written by
|
|
1545
|
+
* someone else and is never overwritten.
|
|
1546
|
+
*/
|
|
1547
|
+
function storedMemoryRecords(scope, data) {
|
|
1548
|
+
const keys = Object.keys(data);
|
|
1549
|
+
if (keys.length === 1 &&
|
|
1550
|
+
Array.isArray(data.records) &&
|
|
1551
|
+
data.records.every((row) => isPlainRecord(row) &&
|
|
1552
|
+
typeof row.id === "string" &&
|
|
1553
|
+
typeof row.content === "string")) {
|
|
1554
|
+
return data.records;
|
|
1555
|
+
}
|
|
1556
|
+
if (keys.length === 1 &&
|
|
1557
|
+
Array.isArray(data.memories) &&
|
|
1558
|
+
data.memories.every((item) => isPlainRecord(item) &&
|
|
1559
|
+
typeof item.id === "string" &&
|
|
1560
|
+
typeof item.text === "string")) {
|
|
1561
|
+
return data.memories.map((item) => {
|
|
1562
|
+
const at = typeof item.savedAt === "string" ? item.savedAt : "";
|
|
1563
|
+
return {
|
|
1564
|
+
id: item.id,
|
|
1565
|
+
content: item.text,
|
|
1566
|
+
created_at: at,
|
|
1567
|
+
updated_at: at,
|
|
1568
|
+
...(typeof item.key === "string" ? { key: item.key } : {}),
|
|
1569
|
+
written_by: null,
|
|
1570
|
+
};
|
|
1571
|
+
});
|
|
1572
|
+
}
|
|
1573
|
+
throw new RememberRefusal({
|
|
1574
|
+
error: "scope_not_memory",
|
|
1575
|
+
scope,
|
|
1576
|
+
message: `Scope ${scope} holds data that is not a memory list; it will not be changed. Use another write scope.`,
|
|
1577
|
+
});
|
|
1578
|
+
}
|
|
1579
|
+
/**
|
|
1580
|
+
* The scope a memory tool acts on and the grant that covers it, or the error
|
|
1581
|
+
* result to return. A call may omit `scope` when the connection can write to
|
|
1582
|
+
* exactly one scope.
|
|
1583
|
+
*/
|
|
1584
|
+
function resolveMemoryTarget(args, connection) {
|
|
1585
|
+
const writableScopes = uniqueWritableScopes(connection);
|
|
1586
|
+
const namedScope = typeof args.scope === "string" ? args.scope.trim() : "";
|
|
1587
|
+
const onlyScope = writableScopes.length === 1 && !writableScopes[0].includes("*")
|
|
1588
|
+
? writableScopes[0]
|
|
1589
|
+
: "";
|
|
1590
|
+
const scope = namedScope || onlyScope;
|
|
1591
|
+
if (!scope) {
|
|
1592
|
+
return {
|
|
1593
|
+
error: textResult({
|
|
1594
|
+
error: "scope_required",
|
|
1595
|
+
writableScopes,
|
|
1596
|
+
message: writableScopes.length === 0
|
|
1597
|
+
? 'This connection cannot save memories. Call request_scope_access with scopes ["write:memory.<app>"] and ask the user to approve it.'
|
|
1598
|
+
: "Name the scope; this connection can write to more than one.",
|
|
1599
|
+
}, true),
|
|
1600
|
+
};
|
|
1601
|
+
}
|
|
1602
|
+
if (!isMemoryScope(scope)) {
|
|
1603
|
+
return {
|
|
1604
|
+
error: textResult({
|
|
1605
|
+
error: "scope_not_memory",
|
|
1606
|
+
scope,
|
|
1607
|
+
message: `Memories live in memory.<app> scopes; ${scope} is not one.`,
|
|
1608
|
+
}, true),
|
|
1609
|
+
};
|
|
1610
|
+
}
|
|
1611
|
+
const grant = resolveWriteGrantForScope(connection, scope);
|
|
1612
|
+
if (!grant) {
|
|
1613
|
+
const requestScope = `${WRITE_SCOPE_PREFIX}${scope}`;
|
|
1614
|
+
return {
|
|
1615
|
+
error: textResult({
|
|
1616
|
+
error: "scope_not_granted",
|
|
1617
|
+
scope,
|
|
1618
|
+
requestScope,
|
|
1619
|
+
writableScopes,
|
|
1620
|
+
message: `This connection may not write to ${scope}. Call request_scope_access with scopes ["${requestScope}"] and ask the user to approve it.`,
|
|
1621
|
+
}, true),
|
|
1622
|
+
};
|
|
1623
|
+
}
|
|
1624
|
+
return { scope, grantId: grant.grantId };
|
|
1625
|
+
}
|
|
1626
|
+
const WRITE_UNAVAILABLE = textResult({
|
|
1627
|
+
error: "write_unavailable",
|
|
1628
|
+
message: "This Personal Server does not accept MCP writes.",
|
|
1629
|
+
}, true);
|
|
1630
|
+
/** Map a refused or failed memory write to the tool's error result. */
|
|
1631
|
+
function memoryWriteError(err, scope) {
|
|
1632
|
+
if (err instanceof RememberRefusal)
|
|
1633
|
+
return textResult(err.body, true);
|
|
1634
|
+
if (err instanceof McpDataWriteError) {
|
|
1635
|
+
const body = err.body;
|
|
1636
|
+
const detail = typeof body?.error === "object" && body.error !== null
|
|
1637
|
+
? body.error
|
|
1638
|
+
: { errorCode: body?.error, message: body?.message };
|
|
1639
|
+
return textResult({
|
|
1640
|
+
error: err.status === 401 || err.status === 403
|
|
1641
|
+
? "unauthorized"
|
|
1642
|
+
: err.status === 412
|
|
1643
|
+
? "write_conflict"
|
|
1644
|
+
: "write_failed",
|
|
1645
|
+
status: err.status,
|
|
1646
|
+
scope,
|
|
1647
|
+
...(detail.errorCode ? { errorCode: detail.errorCode } : {}),
|
|
1648
|
+
...(detail.message ? { message: detail.message } : {}),
|
|
1649
|
+
}, true);
|
|
1650
|
+
}
|
|
1651
|
+
throw err;
|
|
1652
|
+
}
|
|
1653
|
+
function memoryBody(records, scope) {
|
|
1654
|
+
const body = { records };
|
|
1655
|
+
if (new TextEncoder().encode(JSON.stringify(body)).byteLength >
|
|
1656
|
+
MEMORY_SCOPE_MAX_BYTES) {
|
|
1657
|
+
throw new RememberRefusal({
|
|
1658
|
+
error: "memory_full",
|
|
1659
|
+
scope,
|
|
1660
|
+
limitBytes: MEMORY_SCOPE_MAX_BYTES,
|
|
1661
|
+
message: `Scope ${scope} is full. Forget or replace memories to make room.`,
|
|
1662
|
+
});
|
|
1663
|
+
}
|
|
1664
|
+
return body;
|
|
1665
|
+
}
|
|
1666
|
+
const remember = {
|
|
1667
|
+
name: REMEMBER_TOOL,
|
|
1668
|
+
title: "Remember",
|
|
1669
|
+
description: "Save a fact, preference, goal or decision the user shares, without being asked, so any allowed agent can recall it. Tell the user briefly. Never save secrets, passwords, IDs or account numbers. Needs a write:<scope> grant (writableScopes).",
|
|
1670
|
+
inputSchema: {
|
|
1671
|
+
text: z
|
|
1672
|
+
.string()
|
|
1673
|
+
.min(1)
|
|
1674
|
+
.max(REMEMBER_TEXT_MAX_CHARS)
|
|
1675
|
+
.describe("Self-contained; readable without this chat."),
|
|
1676
|
+
scope: z
|
|
1677
|
+
.string()
|
|
1678
|
+
.min(1)
|
|
1679
|
+
.max(SEARCH_SCOPE_MAX_CHARS)
|
|
1680
|
+
.optional()
|
|
1681
|
+
.describe("e.g. memory.claude; optional with one writable scope."),
|
|
1682
|
+
key: z
|
|
1683
|
+
.string()
|
|
1684
|
+
.min(1)
|
|
1685
|
+
.max(REMEMBER_KEY_MAX_CHARS)
|
|
1686
|
+
.optional()
|
|
1687
|
+
.describe("Saving again with the same key replaces the memory."),
|
|
1688
|
+
},
|
|
1689
|
+
async handler(args, { connection, writeClient }) {
|
|
1690
|
+
const content = typeof args.text === "string" ? args.text.trim() : "";
|
|
1691
|
+
if (!content) {
|
|
1692
|
+
return textResult({ error: "invalid_arguments", message: "text must not be empty." }, true);
|
|
1693
|
+
}
|
|
1694
|
+
const key = typeof args.key === "string" && args.key.trim()
|
|
1695
|
+
? args.key.trim()
|
|
1696
|
+
: undefined;
|
|
1697
|
+
const target = resolveMemoryTarget(args, connection);
|
|
1698
|
+
if ("error" in target)
|
|
1699
|
+
return target.error;
|
|
1700
|
+
const { scope, grantId } = target;
|
|
1701
|
+
if (!writeClient)
|
|
1702
|
+
return WRITE_UNAVAILABLE;
|
|
1703
|
+
const now = new Date().toISOString();
|
|
1704
|
+
let saved;
|
|
1705
|
+
let replaced = false;
|
|
1706
|
+
let memoryCount = 0;
|
|
1707
|
+
try {
|
|
1708
|
+
await writeClient.updateScope({
|
|
1709
|
+
scope,
|
|
1710
|
+
grantId,
|
|
1711
|
+
update(current) {
|
|
1712
|
+
const records = current.data === null
|
|
1713
|
+
? []
|
|
1714
|
+
: storedMemoryRecords(scope, current.data);
|
|
1715
|
+
const previous = key
|
|
1716
|
+
? records.find((record) => record.key === key)
|
|
1717
|
+
: undefined;
|
|
1718
|
+
if (!key) {
|
|
1719
|
+
const same = records.find((record) => record.content === content);
|
|
1720
|
+
if (same)
|
|
1721
|
+
throw new DuplicateMemory(same);
|
|
1722
|
+
}
|
|
1723
|
+
replaced = previous !== undefined;
|
|
1724
|
+
saved = {
|
|
1725
|
+
id: previous?.id ?? crypto.randomUUID(),
|
|
1726
|
+
content,
|
|
1727
|
+
created_at: previous?.created_at ?? now,
|
|
1728
|
+
updated_at: now,
|
|
1729
|
+
...(key ? { key } : {}),
|
|
1730
|
+
written_by: connection.granteeAddress,
|
|
1731
|
+
};
|
|
1732
|
+
// Newest last: a replaced memory moves to the end, so list order is
|
|
1733
|
+
// the order the memories were last saved in.
|
|
1734
|
+
const next = [
|
|
1735
|
+
...records.filter((record) => record !== previous),
|
|
1736
|
+
saved,
|
|
1737
|
+
];
|
|
1738
|
+
memoryCount = next.length;
|
|
1739
|
+
return memoryBody(next, scope);
|
|
1740
|
+
},
|
|
1741
|
+
});
|
|
1742
|
+
}
|
|
1743
|
+
catch (err) {
|
|
1744
|
+
if (err instanceof DuplicateMemory) {
|
|
1745
|
+
return textResult({
|
|
1746
|
+
saved: false,
|
|
1747
|
+
duplicate: true,
|
|
1748
|
+
scope,
|
|
1749
|
+
id: err.record.id,
|
|
1750
|
+
message: "This memory is already saved.",
|
|
1751
|
+
});
|
|
1752
|
+
}
|
|
1753
|
+
return memoryWriteError(err, scope);
|
|
1754
|
+
}
|
|
1755
|
+
return textResult({
|
|
1756
|
+
saved: true,
|
|
1757
|
+
scope,
|
|
1758
|
+
id: saved.id,
|
|
1759
|
+
savedAt: saved.updated_at,
|
|
1760
|
+
...(key ? { key } : {}),
|
|
1761
|
+
replaced,
|
|
1762
|
+
memoryCount,
|
|
1763
|
+
});
|
|
1764
|
+
},
|
|
1765
|
+
};
|
|
1766
|
+
const forget = {
|
|
1767
|
+
name: FORGET_TOOL,
|
|
1768
|
+
title: "Forget",
|
|
1769
|
+
description: "Delete a saved memory by id or key. Needs a write:<scope> grant.",
|
|
1770
|
+
inputSchema: {
|
|
1771
|
+
id: z.string().min(1).max(MEMORY_ID_MAX_CHARS).optional(),
|
|
1772
|
+
key: z.string().min(1).max(REMEMBER_KEY_MAX_CHARS).optional(),
|
|
1773
|
+
scope: z.string().min(1).max(SEARCH_SCOPE_MAX_CHARS).optional(),
|
|
1774
|
+
},
|
|
1775
|
+
async handler(args, { connection, writeClient }) {
|
|
1776
|
+
const id = typeof args.id === "string" ? args.id.trim() : "";
|
|
1777
|
+
const key = typeof args.key === "string" ? args.key.trim() : "";
|
|
1778
|
+
if (!id && !key) {
|
|
1779
|
+
return textResult({ error: "invalid_arguments", message: "Pass id or key." }, true);
|
|
1780
|
+
}
|
|
1781
|
+
const target = resolveMemoryTarget(args, connection);
|
|
1782
|
+
if ("error" in target)
|
|
1783
|
+
return target.error;
|
|
1784
|
+
const { scope, grantId } = target;
|
|
1785
|
+
if (!writeClient)
|
|
1786
|
+
return WRITE_UNAVAILABLE;
|
|
1787
|
+
let forgotten = [];
|
|
1788
|
+
let memoryCount = 0;
|
|
1789
|
+
try {
|
|
1790
|
+
await writeClient.updateScope({
|
|
1791
|
+
scope,
|
|
1792
|
+
grantId,
|
|
1793
|
+
update(current) {
|
|
1794
|
+
const records = current.data === null
|
|
1795
|
+
? []
|
|
1796
|
+
: storedMemoryRecords(scope, current.data);
|
|
1797
|
+
// With both id and key, a record must match both.
|
|
1798
|
+
const matches = (record) => (!id || record.id === id) && (!key || record.key === key);
|
|
1799
|
+
const keep = records.filter((record) => !matches(record));
|
|
1800
|
+
if (keep.length === records.length) {
|
|
1801
|
+
throw new RememberRefusal({
|
|
1802
|
+
error: "not_found",
|
|
1803
|
+
scope,
|
|
1804
|
+
message: "No saved memory matches that id or key.",
|
|
1805
|
+
});
|
|
1806
|
+
}
|
|
1807
|
+
// Reset on every attempt: a 412 retry re-runs this callback.
|
|
1808
|
+
forgotten = records.filter(matches).map((record) => record.id);
|
|
1809
|
+
memoryCount = keep.length;
|
|
1810
|
+
return memoryBody(keep, scope);
|
|
1811
|
+
},
|
|
1812
|
+
});
|
|
1813
|
+
}
|
|
1814
|
+
catch (err) {
|
|
1815
|
+
return memoryWriteError(err, scope);
|
|
1816
|
+
}
|
|
1817
|
+
return textResult({ forgotten: true, scope, ids: forgotten, memoryCount });
|
|
1818
|
+
},
|
|
1819
|
+
};
|
|
1438
1820
|
export const MCP_TOOLS = [
|
|
1439
1821
|
listGrantedSources,
|
|
1440
1822
|
listGrantedScopes,
|
|
@@ -1443,5 +1825,7 @@ export const MCP_TOOLS = [
|
|
|
1443
1825
|
listScopeBlocks,
|
|
1444
1826
|
getScopeFile,
|
|
1445
1827
|
searchPersonalContext,
|
|
1828
|
+
remember,
|
|
1829
|
+
forget,
|
|
1446
1830
|
];
|
|
1447
1831
|
//# sourceMappingURL=tools.js.map
|