@abloatai/ablo 0.34.0 → 0.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/AGENTS.md +4 -1
- package/CHANGELOG.md +684 -5
- package/README.md +39 -22
- package/dist/BaseSyncedStore.d.ts +152 -44
- package/dist/BaseSyncedStore.js +300 -184
- package/dist/Database.d.ts +9 -24
- package/dist/Database.js +37 -22
- package/dist/InstanceCache.d.ts +25 -4
- package/dist/InstanceCache.js +48 -15
- package/dist/LazyReferenceCollection.d.ts +3 -3
- package/dist/LazyReferenceCollection.js +4 -4
- package/dist/Model.d.ts +6 -6
- package/dist/Model.js +10 -10
- package/dist/ModelRegistry.d.ts +4 -4
- package/dist/ModelRegistry.js +3 -3
- package/dist/{SyncEngineContext.d.ts → RuntimeContext.d.ts} +20 -13
- package/dist/{SyncEngineContext.js → RuntimeContext.js} +11 -12
- package/dist/SyncClient.d.ts +42 -32
- package/dist/SyncClient.js +166 -110
- package/dist/ai-sdk/coordinatedTool.d.ts +2 -2
- package/dist/ai-sdk/coordinatedTool.js +1 -1
- package/dist/ai-sdk/coordinationContext.d.ts +2 -2
- package/dist/ai-sdk/coordinationContext.js +1 -1
- package/dist/ai-sdk/wrap.d.ts +3 -3
- package/dist/ai-sdk/wrap.js +2 -2
- package/dist/auth/index.d.ts +1 -156
- package/dist/auth/index.js +8 -301
- package/dist/cli.cjs +3459 -1126
- package/dist/client/Ablo.d.ts +42 -287
- package/dist/client/Ablo.js +118 -963
- package/dist/client/abloClient.d.ts +309 -0
- package/dist/client/abloClient.js +13 -0
- package/dist/client/clientPrelude.d.ts +52 -0
- package/dist/client/clientPrelude.js +60 -0
- package/dist/client/consoleLogger.d.ts +2 -2
- package/dist/client/coreClient.d.ts +60 -0
- package/dist/client/coreClient.js +118 -0
- package/dist/client/createInternalComponents.d.ts +4 -4
- package/dist/client/createInternalComponents.js +9 -8
- package/dist/client/createModelProxy.d.ts +78 -373
- package/dist/client/createModelProxy.js +114 -86
- package/dist/client/humans.d.ts +48 -0
- package/dist/client/humans.js +52 -0
- package/dist/client/modelRegistration.d.ts +1 -1
- package/dist/client/modelRegistration.js +9 -9
- package/dist/client/options.d.ts +73 -17
- package/dist/client/reactiveEngine.d.ts +48 -0
- package/dist/client/reactiveEngine.js +910 -0
- package/dist/client/resourceTypes.d.ts +9 -250
- package/dist/client/resourceTypes.js +8 -5
- package/dist/client/schemaConfig.d.ts +4 -4
- package/dist/client/schemaConfig.js +6 -2
- package/dist/client/validateAbloOptions.d.ts +3 -2
- package/dist/client/validateAbloOptions.js +1 -1
- package/dist/client/wsMutationExecutor.d.ts +3 -3
- package/dist/client/wsMutationExecutor.js +3 -3
- package/dist/context.d.ts +9 -9
- package/dist/context.js +10 -9
- package/dist/coordination/ClaimLog.d.ts +26 -0
- package/dist/coordination/ClaimLog.js +32 -0
- package/dist/coordination/index.d.ts +1 -15
- package/dist/coordination/index.js +8 -31
- package/dist/core/DatabaseManager.js +1 -1
- package/dist/core/QueryView.d.ts +1 -1
- package/dist/core/QueryView.js +1 -1
- package/dist/core/StoreManager.d.ts +4 -23
- package/dist/core/StoreManager.js +5 -55
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +2 -2
- package/dist/core/storeContract.d.ts +2 -2
- package/dist/docs/catalog.d.ts +72 -0
- package/dist/docs/catalog.js +227 -0
- package/dist/docs/index.d.ts +10 -0
- package/dist/docs/index.js +10 -0
- package/dist/environment.d.ts +1 -40
- package/dist/environment.js +8 -37
- package/dist/index.d.ts +40 -34
- package/dist/index.js +26 -20
- package/dist/interfaces/index.d.ts +44 -134
- package/dist/keys/index.d.ts +1 -77
- package/dist/keys/index.js +8 -190
- package/dist/mutators/{RecordingTransaction.d.ts → RecordingMutation.d.ts} +4 -4
- package/dist/mutators/{RecordingTransaction.js → RecordingMutation.js} +2 -2
- package/dist/mutators/Transaction.d.ts +1 -1
- package/dist/mutators/Transaction.js +1 -1
- package/dist/mutators/UndoManager.d.ts +6 -6
- package/dist/mutators/UndoManager.js +5 -5
- package/dist/mutators/defineMutators.d.ts +3 -3
- package/dist/mutators/defineMutators.js +1 -1
- package/dist/mutators/inverseOp.js +2 -2
- package/dist/mutators/mutateActions.d.ts +3 -3
- package/dist/mutators/mutateActions.js +1 -1
- package/dist/mutators/readerActions.d.ts +1 -1
- package/dist/mutators/undoApply.d.ts +1 -1
- package/dist/mutators/undoApply.js +1 -1
- package/dist/policy/index.d.ts +2 -2
- package/dist/policy/index.js +1 -1
- package/dist/query/client.d.ts +2 -2
- package/dist/query/client.js +4 -4
- package/dist/query/types.d.ts +6 -41
- package/dist/query/types.js +2 -2
- package/dist/react/AbloProvider.d.ts +6 -8
- package/dist/react/AbloProvider.js +5 -7
- package/dist/react/context.d.ts +1 -1
- package/dist/react/context.js +1 -1
- package/dist/react/index.d.ts +5 -5
- package/dist/react/index.js +3 -3
- package/dist/react/internalContext.d.ts +1 -1
- package/dist/react/useAblo.d.ts +3 -3
- package/dist/react/useAblo.js +1 -1
- package/dist/react/useCurrentUserId.js +1 -1
- package/dist/react/useErrorListener.js +1 -1
- package/dist/react/useMutationFailureListener.d.ts +2 -2
- package/dist/react/useMutationFailureListener.js +1 -1
- package/dist/react/useMutators.d.ts +3 -3
- package/dist/react/useMutators.js +3 -3
- package/dist/react/useUndoScope.d.ts +5 -5
- package/dist/react/useUndoScope.js +1 -1
- package/dist/schema/coordination.d.ts +69 -10
- package/dist/schema/coordination.js +86 -9
- package/dist/schema/ddl.js +2 -2
- package/dist/schema/diff.d.ts +1 -1
- package/dist/schema/generate.js +1 -1
- package/dist/schema/index.d.ts +10 -10
- package/dist/schema/index.js +18 -18
- package/dist/schema/queries.d.ts +27 -27
- package/dist/schema/queries.js +23 -23
- package/dist/schema/select.d.ts +3 -3
- package/dist/schema/select.js +3 -3
- package/dist/schema/serialize.d.ts +15 -6
- package/dist/schema/serialize.js +17 -3
- package/dist/schema/sugar.d.ts +6 -7
- package/dist/schema/sugar.js +9 -12
- package/dist/schema/syncDeltaRow.d.ts +4 -152
- package/dist/schema/syncDeltaRow.js +4 -105
- package/dist/server/adapter.d.ts +18 -1
- package/dist/server/commit.d.ts +10 -16
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/readConfig.d.ts +1 -1
- package/dist/source/adapters/drizzle.d.ts +1 -1
- package/dist/source/adapters/drizzle.js +2 -2
- package/dist/source/adapters/kysely.d.ts +1 -1
- package/dist/source/adapters/kysely.js +1 -1
- package/dist/source/adapters/kyselyMutationCore.d.ts +1 -1
- package/dist/source/adapters/kyselyMutationCore.js +2 -2
- package/dist/source/adapters/memory.js +1 -1
- package/dist/source/adapters/prisma.d.ts +8 -3
- package/dist/source/adapters/prisma.js +1 -1
- package/dist/source/connector.js +1 -1
- package/dist/source/connectorProtocol.d.ts +2 -8
- package/dist/source/connectorProtocol.js +3 -2
- package/dist/source/contract.d.ts +29 -17
- package/dist/source/contract.js +27 -22
- package/dist/source/factory.d.ts +1 -1
- package/dist/source/footprint.d.ts +111 -0
- package/dist/source/footprint.js +0 -0
- package/dist/source/idempotency.js +2 -2
- package/dist/source/index.d.ts +1 -0
- package/dist/source/index.js +3 -0
- package/dist/source/next.d.ts +1 -1
- package/dist/source/signing.d.ts +9 -2
- package/dist/source/signing.js +4 -1
- package/dist/source/types.d.ts +6 -4
- package/dist/source/types.js +1 -1
- package/dist/stores/ObjectStore.d.ts +1 -1
- package/dist/stores/SyncActionStore.d.ts +1 -1
- package/dist/stores/SyncActionStore.js +2 -10
- package/dist/stores/syncAction.d.ts +26 -0
- package/dist/stores/syncAction.js +16 -0
- package/dist/surface.d.ts +3 -3
- package/dist/surface.js +6 -4
- package/dist/sync/BootstrapFetcher.d.ts +123 -6
- package/dist/sync/BootstrapFetcher.js +492 -66
- package/dist/sync/ConnectionManager.d.ts +6 -198
- package/dist/sync/ConnectionManager.js +6 -677
- package/dist/sync/OnDemandLoader.d.ts +2 -2
- package/dist/sync/OnDemandLoader.js +60 -21
- package/dist/sync/SubscriptionManager.d.ts +13 -2
- package/dist/sync/SubscriptionManager.js +23 -5
- package/dist/sync/SyncWebSocket.d.ts +27 -510
- package/dist/sync/SyncWebSocket.js +76 -954
- package/dist/sync/awaitClaimGrant.d.ts +4 -44
- package/dist/sync/awaitClaimGrant.js +4 -109
- package/dist/sync/commitFrames.d.ts +6 -40
- package/dist/sync/commitFrames.js +6 -97
- package/dist/sync/contextPorts.d.ts +18 -0
- package/dist/sync/contextPorts.js +31 -0
- package/dist/sync/createClaimStream.d.ts +5 -49
- package/dist/sync/createClaimStream.js +5 -469
- package/dist/sync/createPresenceStream.d.ts +26 -4
- package/dist/sync/createPresenceStream.js +28 -20
- package/dist/sync/createSnapshot.d.ts +2 -2
- package/dist/sync/createSnapshot.js +1 -1
- package/dist/sync/credentialLifecycle.d.ts +5 -173
- package/dist/sync/credentialLifecycle.js +5 -320
- package/dist/sync/deltaPipeline.d.ts +1 -1
- package/dist/sync/participants.d.ts +5 -4
- package/dist/sync/participants.js +29 -22
- package/dist/sync/schemaDrift.d.ts +55 -0
- package/dist/sync/schemaDrift.js +53 -0
- package/dist/sync/schemas.d.ts +21 -32
- package/dist/sync/schemas.js +26 -17
- package/dist/sync/syncPlan.d.ts +3 -3
- package/dist/sync/wsFrameHandlers.d.ts +6 -114
- package/dist/sync/wsFrameHandlers.js +6 -392
- package/dist/testing/fixtures/bootstrap.d.ts +1 -1
- package/dist/testing/fixtures/deltas.d.ts +1 -1
- package/dist/testing/fixtures/httpResponses.d.ts +70 -0
- package/dist/testing/fixtures/httpResponses.js +90 -0
- package/dist/testing/fixtures/models.js +1 -1
- package/dist/testing/helpers/wait.js +1 -1
- package/dist/testing/mocks/MockMutationExecutor.d.ts +2 -2
- package/dist/testing/mocks/MockMutationExecutor.js +8 -14
- package/dist/testing/mocks/MockSyncContext.d.ts +11 -11
- package/dist/testing/mocks/MockSyncContext.js +10 -9
- package/dist/testing/mocks/MockSyncStore.js +1 -1
- package/dist/testing/mocks/MockWebSocket.d.ts +2 -2
- package/dist/transaction/ablo.d.ts +88 -0
- package/dist/transaction/ablo.js +33 -0
- package/dist/{client/auth.d.ts → transaction/auth/apiKey.d.ts} +43 -8
- package/dist/{client/auth.js → transaction/auth/apiKey.js} +19 -0
- package/dist/transaction/auth/bootstrapScope.d.ts +15 -0
- package/dist/transaction/auth/bootstrapScope.js +1 -0
- package/dist/transaction/auth/capability.d.ts +177 -0
- package/dist/transaction/auth/capability.js +199 -0
- package/dist/{auth → transaction/auth}/credentialSource.d.ts +8 -1
- package/dist/{client → transaction/auth}/identity.d.ts +8 -7
- package/dist/{client → transaction/auth}/identity.js +1 -1
- package/dist/transaction/auth/index.d.ts +162 -0
- package/dist/transaction/auth/index.js +304 -0
- package/dist/{auth → transaction/auth}/schemas.d.ts +1 -1
- package/dist/{auth → transaction/auth}/schemas.js +13 -13
- package/dist/{client → transaction/auth}/sessionMint.d.ts +8 -8
- package/dist/{client → transaction/auth}/sessionMint.js +4 -7
- package/dist/transaction/coordination/awaitClaimGrant.d.ts +49 -0
- package/dist/transaction/coordination/awaitClaimGrant.js +112 -0
- package/dist/transaction/coordination/claimMeta.d.ts +49 -0
- package/dist/transaction/coordination/claimMeta.js +52 -0
- package/dist/transaction/coordination/createClaimStream.d.ts +64 -0
- package/dist/transaction/coordination/createClaimStream.js +475 -0
- package/dist/transaction/coordination/events.d.ts +74 -0
- package/dist/transaction/coordination/events.js +7 -0
- package/dist/transaction/coordination/index.d.ts +19 -0
- package/dist/transaction/coordination/index.js +44 -0
- package/dist/transaction/coordination/locator.d.ts +83 -0
- package/dist/transaction/coordination/locator.js +82 -0
- package/dist/transaction/coordination/schema.d.ts +1473 -0
- package/dist/{coordination → transaction/coordination}/schema.js +490 -55
- package/dist/transaction/coordination/targetConflict.d.ts +2 -0
- package/dist/transaction/coordination/targetConflict.js +103 -0
- package/dist/{coordination → transaction/coordination}/trace.d.ts +7 -18
- package/dist/{coordination → transaction/coordination}/trace.js +18 -25
- package/dist/transaction/durableWrites.d.ts +62 -0
- package/dist/{client → transaction}/durableWrites.js +28 -3
- package/dist/transaction/environment.d.ts +105 -0
- package/dist/transaction/environment.js +108 -0
- package/dist/{errorCodes.d.ts → transaction/errorCodes.d.ts} +11 -11
- package/dist/{errorCodes.js → transaction/errorCodes.js} +35 -12
- package/dist/{errors.d.ts → transaction/errors.d.ts} +37 -13
- package/dist/{errors.js → transaction/errors.js} +85 -16
- package/dist/transaction/index.d.ts +20 -0
- package/dist/transaction/index.js +20 -0
- package/dist/transaction/keys/index.d.ts +87 -0
- package/dist/transaction/keys/index.js +207 -0
- package/dist/transaction/log/syncDeltaRow.d.ts +158 -0
- package/dist/transaction/log/syncDeltaRow.js +95 -0
- package/dist/{sync/syncPosition.d.ts → transaction/logPosition.d.ts} +22 -8
- package/dist/{sync/syncPosition.js → transaction/logPosition.js} +15 -6
- package/dist/transaction/logger.d.ts +16 -0
- package/dist/transaction/logger.js +7 -0
- package/dist/transaction/observability.d.ts +53 -0
- package/dist/transaction/observability.js +19 -0
- package/dist/transaction/plugin.d.ts +192 -0
- package/dist/transaction/plugin.js +87 -0
- package/dist/{policy → transaction/policy}/types.d.ts +3 -3
- package/dist/{policy → transaction/policy}/types.js +2 -0
- package/dist/transaction/resources/httpResources.d.ts +266 -0
- package/dist/transaction/resources/httpResources.js +7 -0
- package/dist/transaction/resources/modelOperations.d.ts +319 -0
- package/dist/transaction/resources/modelOperations.js +12 -0
- package/dist/transaction/resources/mutationOptions.d.ts +66 -0
- package/dist/transaction/resources/mutationOptions.js +9 -0
- package/dist/transaction/resources/where.d.ts +85 -0
- package/dist/transaction/resources/where.js +70 -0
- package/dist/{client → transaction/resources}/writeOptionsSchema.d.ts +2 -6
- package/dist/{client → transaction/resources}/writeOptionsSchema.js +9 -5
- package/dist/{schema → transaction/schema}/field.d.ts +5 -5
- package/dist/{schema → transaction/schema}/field.js +5 -5
- package/dist/transaction/schema/loadStrategy.d.ts +45 -0
- package/dist/transaction/schema/loadStrategy.js +46 -0
- package/dist/{schema → transaction/schema}/model.d.ts +50 -35
- package/dist/{schema → transaction/schema}/model.js +30 -20
- package/dist/transaction/schema/openapi.d.ts +57 -0
- package/dist/transaction/schema/openapi.js +340 -0
- package/dist/{schema → transaction/schema}/relation.d.ts +14 -14
- package/dist/{schema → transaction/schema}/relation.js +7 -7
- package/dist/{schema → transaction/schema}/residency.d.ts +0 -9
- package/dist/{schema → transaction/schema}/residency.js +0 -5
- package/dist/{schema → transaction/schema}/roles.d.ts +5 -5
- package/dist/{schema → transaction/schema}/roles.js +5 -5
- package/dist/{schema → transaction/schema}/schema.d.ts +12 -10
- package/dist/{schema → transaction/schema}/schema.js +4 -3
- package/dist/{schema → transaction/schema}/tenancy.d.ts +1 -1
- package/dist/{schema → transaction/schema}/tenancy.js +7 -4
- package/dist/transaction/transactionLayer.d.ts +82 -0
- package/dist/transaction/transactionLayer.js +24 -0
- package/dist/{transactions → transaction/transactions/settlement}/commitEnvelope.d.ts +4 -5
- package/dist/{transactions → transaction/transactions/settlement}/commitEnvelope.js +9 -13
- package/dist/{transactions → transaction/transactions/settlement}/httpCommitEnvelope.d.ts +9 -2
- package/dist/{transactions → transaction/transactions/settlement}/httpCommitEnvelope.js +5 -9
- package/dist/{transactions/durableWriteStore.d.ts → transaction/transactions/settlement/pendingWrite.d.ts} +10 -36
- package/dist/transaction/transactions/settlement/pendingWrite.js +20 -0
- package/dist/transaction/transport/commitFrames.d.ts +90 -0
- package/dist/transaction/transport/commitFrames.js +134 -0
- package/dist/transaction/transport/connectionManager.d.ts +215 -0
- package/dist/transaction/transport/connectionManager.js +673 -0
- package/dist/transaction/transport/credentialLifecycle.d.ts +177 -0
- package/dist/transaction/transport/credentialLifecycle.js +324 -0
- package/dist/{sync → transaction/transport}/heartbeat.d.ts +3 -1
- package/dist/{sync → transaction/transport}/heartbeat.js +6 -4
- package/dist/{client → transaction/transport}/httpClient.d.ts +59 -16
- package/dist/{client → transaction/transport}/httpClient.js +5 -5
- package/dist/transaction/transport/httpOptions.d.ts +33 -0
- package/dist/transaction/transport/httpOptions.js +12 -0
- package/dist/{client → transaction/transport}/httpTransport.js +171 -85
- package/dist/{sync/NetworkProbe.d.ts → transaction/transport/networkProbe.d.ts} +7 -4
- package/dist/{sync/NetworkProbe.js → transaction/transport/networkProbe.js} +14 -13
- package/dist/transaction/transport/wsFrameHandlers.d.ts +128 -0
- package/dist/transaction/transport/wsFrameHandlers.js +429 -0
- package/dist/transaction/transport/wsTransport.d.ts +576 -0
- package/dist/transaction/transport/wsTransport.js +1017 -0
- package/dist/transaction/types/assertExact.d.ts +17 -0
- package/dist/transaction/types/assertExact.js +1 -0
- package/dist/{types → transaction/types}/global.d.ts +17 -2
- package/dist/{types → transaction/types}/global.js +2 -1
- package/dist/{types → transaction/types}/index.d.ts +14 -46
- package/dist/{types → transaction/types}/index.js +7 -16
- package/dist/{types → transaction/types}/streams.d.ts +63 -45
- package/dist/{utils → transaction/utils}/json.d.ts +18 -0
- package/dist/transaction/utils/json.js +276 -0
- package/dist/transaction/wire/accountResponses.d.ts +351 -0
- package/dist/transaction/wire/accountResponses.js +255 -0
- package/dist/transaction/wire/auth.d.ts +49 -0
- package/dist/transaction/wire/auth.js +57 -0
- package/dist/transaction/wire/claimEvent.d.ts +76 -0
- package/dist/transaction/wire/claimEvent.js +73 -0
- package/dist/transaction/wire/claims.d.ts +463 -0
- package/dist/transaction/wire/claims.js +229 -0
- package/dist/{wire → transaction/wire}/commit.d.ts +125 -193
- package/dist/{wire → transaction/wire}/commit.js +68 -47
- package/dist/{wire → transaction/wire}/delta.d.ts +66 -17
- package/dist/{wire → transaction/wire}/delta.js +37 -13
- package/dist/transaction/wire/errorEnvelope.d.ts +72 -0
- package/dist/{wire → transaction/wire}/errorEnvelope.js +36 -5
- package/dist/transaction/wire/feedCursor.d.ts +60 -0
- package/dist/transaction/wire/feedCursor.js +82 -0
- package/dist/transaction/wire/feedEvent.d.ts +177 -0
- package/dist/transaction/wire/feedEvent.js +39 -0
- package/dist/transaction/wire/frames.d.ts +194 -0
- package/dist/transaction/wire/frames.js +50 -0
- package/dist/transaction/wire/inboundFrames.d.ts +552 -0
- package/dist/transaction/wire/inboundFrames.js +116 -0
- package/dist/transaction/wire/index.d.ts +50 -0
- package/dist/transaction/wire/index.js +74 -0
- package/dist/{wire → transaction/wire}/listEnvelope.d.ts +13 -14
- package/dist/transaction/wire/listEnvelope.js +42 -0
- package/dist/transaction/wire/modelResponses.d.ts +85 -0
- package/dist/transaction/wire/modelResponses.js +43 -0
- package/dist/transactions/{TransactionQueue.d.ts → mutations/MutationQueue.d.ts} +79 -38
- package/dist/transactions/{TransactionQueue.js → mutations/MutationQueue.js} +110 -59
- package/dist/transactions/{TransactionStore.d.ts → mutations/MutationStore.d.ts} +8 -8
- package/dist/transactions/{TransactionStore.js → mutations/MutationStore.js} +2 -2
- package/dist/transactions/{coalesceRules.d.ts → mutations/coalesceRules.d.ts} +10 -10
- package/dist/transactions/{coalesceRules.js → mutations/coalesceRules.js} +1 -1
- package/dist/transactions/mutations/commitLatency.d.ts +52 -0
- package/dist/transactions/mutations/commitLatency.js +130 -0
- package/dist/transactions/{commitOutboxStore.d.ts → mutations/commitOutboxStore.d.ts} +1 -5
- package/dist/transactions/{commitOutboxStore.js → mutations/commitOutboxStore.js} +1 -1
- package/dist/transactions/{commitPayload.d.ts → mutations/commitPayload.d.ts} +16 -15
- package/dist/transactions/{commitPayload.js → mutations/commitPayload.js} +12 -12
- package/dist/transactions/{deltaConfirmation.d.ts → mutations/deltaConfirmation.d.ts} +11 -11
- package/dist/transactions/{deltaConfirmation.js → mutations/deltaConfirmation.js} +7 -7
- package/dist/transactions/mutations/durableWriteStore.d.ts +14 -0
- package/dist/transactions/mutations/durableWriteStore.js +12 -0
- package/dist/transactions/{optimisticApply.d.ts → mutations/optimisticApply.d.ts} +7 -7
- package/dist/transactions/{replayValidation.d.ts → mutations/replayValidation.d.ts} +3 -3
- package/dist/transactions/{replayValidation.js → mutations/replayValidation.js} +4 -3
- package/dist/utils/mobxSetup.d.ts +1 -1
- package/dist/utils/mobxSetup.js +5 -2
- package/dist/webhooks/events.d.ts +2 -2
- package/dist/wire/index.d.ts +1 -34
- package/dist/wire/index.js +8 -49
- package/docs/agent-messaging.md +3 -3
- package/docs/agents.md +19 -12
- package/docs/api-keys.md +8 -4
- package/docs/api.md +22 -18
- package/docs/audit.md +2 -0
- package/docs/cli.md +31 -3
- package/docs/client-behavior.md +8 -6
- package/docs/concurrency-convention.md +30 -24
- package/docs/coordination.md +48 -38
- package/docs/data-sources.md +3 -1
- package/docs/debugging.md +5 -3
- package/docs/deployment.md +267 -0
- package/docs/examples/agent-human.md +49 -42
- package/docs/examples/ai-sdk-tool.md +69 -44
- package/docs/examples/existing-python-backend.md +8 -6
- package/docs/examples/nextjs.md +129 -47
- package/docs/examples/scoped-agent.md +45 -44
- package/docs/examples/server-agent.md +46 -26
- package/docs/groups.md +32 -29
- package/docs/guarantees.md +4 -2
- package/docs/how-it-works.md +9 -7
- package/docs/idempotency.md +126 -0
- package/docs/identity.md +58 -54
- package/docs/index.md +172 -84
- package/docs/integration-guide.md +17 -16
- package/docs/interaction-model.md +6 -4
- package/docs/mcp.md +41 -16
- package/docs/migration.md +63 -5
- package/docs/operating-on-your-database.md +111 -0
- package/docs/projects.md +2 -0
- package/docs/quickstart.md +22 -5
- package/docs/react.md +12 -10
- package/docs/schema-contract.md +5 -3
- package/docs/session-settings.md +108 -0
- package/docs/sessions.md +3 -1
- package/docs/webhooks.md +3 -1
- package/llms.txt +47 -17
- package/package.json +10 -8
- package/dist/agent/Agent.d.ts +0 -366
- package/dist/agent/Agent.js +0 -514
- package/dist/agent/index.d.ts +0 -115
- package/dist/agent/index.js +0 -128
- package/dist/agent/session.d.ts +0 -93
- package/dist/agent/session.js +0 -149
- package/dist/agent/types.d.ts +0 -68
- package/dist/agent/types.js +0 -9
- package/dist/client/durableWrites.d.ts +0 -21
- package/dist/coordination/schema.d.ts +0 -722
- package/dist/schema/openapi.d.ts +0 -29
- package/dist/schema/openapi.js +0 -124
- package/dist/transactions/durableWriteStore.js +0 -30
- package/dist/utils/json.js +0 -88
- package/dist/wire/errorEnvelope.d.ts +0 -55
- package/dist/wire/frames.d.ts +0 -197
- package/dist/wire/frames.js +0 -49
- package/dist/wire/listEnvelope.js +0 -18
- /package/dist/{client → transaction/auth}/credentialEndpoint.d.ts +0 -0
- /package/dist/{client → transaction/auth}/credentialEndpoint.js +0 -0
- /package/dist/{auth → transaction/auth}/credentialPolicy.d.ts +0 -0
- /package/dist/{auth → transaction/auth}/credentialPolicy.js +0 -0
- /package/dist/{auth → transaction/auth}/credentialSource.js +0 -0
- /package/dist/{client → transaction/auth}/hostedEndpoints.d.ts +0 -0
- /package/dist/{client → transaction/auth}/hostedEndpoints.js +0 -0
- /package/dist/{client → transaction/coordination}/claimHeartbeatLoop.d.ts +0 -0
- /package/dist/{client → transaction/coordination}/claimHeartbeatLoop.js +0 -0
- /package/dist/{client → transaction}/persistence.d.ts +0 -0
- /package/dist/{client → transaction}/persistence.js +0 -0
- /package/dist/{client → transaction/resources}/functionalUpdate.d.ts +0 -0
- /package/dist/{client → transaction/resources}/functionalUpdate.js +0 -0
- /package/dist/{transactions → transaction/transactions/settlement}/idempotencyKey.d.ts +0 -0
- /package/dist/{transactions → transaction/transactions/settlement}/idempotencyKey.js +0 -0
- /package/dist/{client → transaction/transport}/httpTransport.d.ts +0 -0
- /package/dist/{types → transaction/types}/modelData.d.ts +0 -0
- /package/dist/{types → transaction/types}/modelData.js +0 -0
- /package/dist/{types → transaction/types}/participant.d.ts +0 -0
- /package/dist/{types → transaction/types}/participant.js +0 -0
- /package/dist/{types → transaction/types}/streams.js +0 -0
- /package/dist/{utils → transaction/utils}/asyncIterator.d.ts +0 -0
- /package/dist/{utils → transaction/utils}/asyncIterator.js +0 -0
- /package/dist/{utils → transaction/utils}/duration.d.ts +0 -0
- /package/dist/{utils → transaction/utils}/duration.js +0 -0
- /package/dist/{wire → transaction/wire}/bootstrapReason.d.ts +0 -0
- /package/dist/{wire → transaction/wire}/bootstrapReason.js +0 -0
- /package/dist/{wire → transaction/wire}/protocol.d.ts +0 -0
- /package/dist/{wire → transaction/wire}/protocol.js +0 -0
- /package/dist/{wire → transaction/wire}/protocolVersion.d.ts +0 -0
- /package/dist/{wire → transaction/wire}/protocolVersion.js +0 -0
- /package/dist/transactions/{UnconfirmedWrites.d.ts → mutations/UnconfirmedWrites.d.ts} +0 -0
- /package/dist/transactions/{UnconfirmedWrites.js → mutations/UnconfirmedWrites.js} +0 -0
- /package/dist/transactions/{optimisticApply.js → mutations/optimisticApply.js} +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The observability the settlement core reports on its own behalf.
|
|
3
|
+
*
|
|
4
|
+
* Coordination outcomes — a claim changing state, a stale-write collision that
|
|
5
|
+
* notified instead of aborting — happen with no UI and no local store anywhere,
|
|
6
|
+
* so the core must be able to report them without depending on the consumer's
|
|
7
|
+
* full provider (ADR 0016).
|
|
8
|
+
*
|
|
9
|
+
* This is deliberately the narrow set the core actually calls today. Widening it
|
|
10
|
+
* later is non-breaking; the reactive engine's `ObservabilityProvider` extends
|
|
11
|
+
* this interface, so a single implementation still satisfies both.
|
|
12
|
+
*/
|
|
13
|
+
/** The no-op default — what the transport reports through when nothing is wired. */
|
|
14
|
+
export const noopSocketObservability = {
|
|
15
|
+
breadcrumb() { },
|
|
16
|
+
captureWebSocketError() { },
|
|
17
|
+
captureClaim() { },
|
|
18
|
+
captureConflict() { },
|
|
19
|
+
};
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The plugin contract (ADR 0016).
|
|
3
|
+
*
|
|
4
|
+
* The core is `commit` · `get`/`list` · `observe` · `claim` · auth. Everything
|
|
5
|
+
* else a caller might want — a local materialised copy, presence rendering,
|
|
6
|
+
* batching, framework bindings — is a plugin declared in one list, so a server
|
|
7
|
+
* or an agent installs only what it asked for.
|
|
8
|
+
*
|
|
9
|
+
* Every plugin has the same shape on purpose. Uniformity is what makes the list
|
|
10
|
+
* composable and the types inferable; bespoke plugins would reproduce today's
|
|
11
|
+
* nineteen export subpaths with extra ceremony.
|
|
12
|
+
*
|
|
13
|
+
* Where this shape came from, and the field-by-field reasoning behind it, is
|
|
14
|
+
* recorded in ADR 0016 — the contract itself only states what each field does.
|
|
15
|
+
*/
|
|
16
|
+
import type { ParticipantKind } from './types/participant.js';
|
|
17
|
+
import type { ErrorCodeSpec } from './errorCodes.js';
|
|
18
|
+
import type { Logger } from './logger.js';
|
|
19
|
+
import type { CoordinationObservability } from './observability.js';
|
|
20
|
+
import type { WsTransport } from './transport/wsTransport.js';
|
|
21
|
+
/**
|
|
22
|
+
* A string type that keeps literal inference alive: `id: 'humans'` stays the
|
|
23
|
+
* literal `'humans'` through object-literal inference instead of widening to
|
|
24
|
+
* `string`, which is what lets {@link InstalledSurface} key a plugin list's
|
|
25
|
+
* surface by id.
|
|
26
|
+
*/
|
|
27
|
+
export type LiteralString = '' | (string & Record<never, never>);
|
|
28
|
+
/**
|
|
29
|
+
* The ordered stages a delta passes through on its way from the feed into
|
|
30
|
+
* whatever is watching. A plugin names the one it attaches to.
|
|
31
|
+
*
|
|
32
|
+
* The order is not a convention — it is a correctness constraint. `acknowledge`
|
|
33
|
+
* must follow `persist`, because acknowledging the input range rather than the
|
|
34
|
+
* persisted high-water mark advances the server's cursor past deltas that never
|
|
35
|
+
* committed, and the next catch-up then answers "you're up to date" for a delta
|
|
36
|
+
* that was lost. Declaring the stage keeps that ordering out of array position,
|
|
37
|
+
* where it would be load-bearing and undocumented.
|
|
38
|
+
*/
|
|
39
|
+
export type PipelineStage =
|
|
40
|
+
/** Deltas arrive from `observe()` and are queued. */
|
|
41
|
+
'receive'
|
|
42
|
+
/** Per-entity collapse of the queued batch. */
|
|
43
|
+
| 'dedupe'
|
|
44
|
+
/** The batch is written to durable local storage. */
|
|
45
|
+
| 'persist'
|
|
46
|
+
/** Persisted results land in the in-memory graph. */
|
|
47
|
+
| 'apply'
|
|
48
|
+
/** The cursor advances — gated on `persist`, never on the input range. */
|
|
49
|
+
| 'acknowledge'
|
|
50
|
+
/** Anything downstream reacts: re-render, presence, subscribers. */
|
|
51
|
+
| 'notify';
|
|
52
|
+
/** Canonical order. A plugin runner must run stages in this sequence. */
|
|
53
|
+
export declare const PIPELINE_STAGES: readonly PipelineStage[];
|
|
54
|
+
/**
|
|
55
|
+
* What a capability needs from whatever transport was selected.
|
|
56
|
+
*
|
|
57
|
+
* Transport is a slot the caller fills, not a packaging axis, so a capability
|
|
58
|
+
* states its requirement and an incompatible pairing fails when the client is
|
|
59
|
+
* configured — with a typed error naming the plugin — rather than at runtime
|
|
60
|
+
* with a subscription that silently never delivers.
|
|
61
|
+
*/
|
|
62
|
+
export interface TransportCapabilities {
|
|
63
|
+
/**
|
|
64
|
+
* Requires a transport the server can initiate frames on. Live subscriptions,
|
|
65
|
+
* presence, and claim grants need this; commit and point-in-time reads do not.
|
|
66
|
+
*/
|
|
67
|
+
readonly duplex?: boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The core surface a plugin is handed at construction.
|
|
71
|
+
*
|
|
72
|
+
* Generic over the client's options type: the host instantiates it with its
|
|
73
|
+
* own options bag, so a plugin reads configuration without this package
|
|
74
|
+
* naming any consumer's types. Alongside the raw options, the context
|
|
75
|
+
* carries the values the host has already resolved (`participant`,
|
|
76
|
+
* `syncGroups`), so a plugin never re-derives identity.
|
|
77
|
+
*/
|
|
78
|
+
export interface PluginContext<Options = unknown> {
|
|
79
|
+
readonly logger: Logger;
|
|
80
|
+
readonly observability?: CoordinationObservability;
|
|
81
|
+
/** The client's own options bag, as the host received it. */
|
|
82
|
+
readonly options?: Options;
|
|
83
|
+
/**
|
|
84
|
+
* The live duplex connection. The host builds it during construction, so a
|
|
85
|
+
* plugin holds the thing rather than a function that fetches it: the
|
|
86
|
+
* connection object is stable for the client's lifetime — identity and
|
|
87
|
+
* read scope are seeded into it when they resolve, and reconnects replace
|
|
88
|
+
* only the socket inside it, never the object. Absent on a
|
|
89
|
+
* request-response client, which is what `requires: { duplex: true }`
|
|
90
|
+
* guards.
|
|
91
|
+
*/
|
|
92
|
+
readonly transport?: WsTransport;
|
|
93
|
+
/** The participant this client runs as, when known at construction. */
|
|
94
|
+
readonly participant?: {
|
|
95
|
+
readonly id: string;
|
|
96
|
+
readonly kind: ParticipantKind;
|
|
97
|
+
};
|
|
98
|
+
/** The connection's initial read scope (sync groups). */
|
|
99
|
+
readonly syncGroups?: readonly string[];
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* One installed capability.
|
|
103
|
+
*
|
|
104
|
+
* @typeParam Surface - what `init` contributes to the client. The plugin list's
|
|
105
|
+
* element types are what let the installed surface be inferred rather than
|
|
106
|
+
* declared.
|
|
107
|
+
*/
|
|
108
|
+
export interface AbloPlugin<Surface = unknown> {
|
|
109
|
+
/** Stable identity — deduplication, diagnostics, and error attribution.
|
|
110
|
+
* Literal-typed so a list's installed surface can be keyed by it. */
|
|
111
|
+
readonly id: LiteralString;
|
|
112
|
+
/** The plugin's own version, for diagnostics. */
|
|
113
|
+
readonly version?: string;
|
|
114
|
+
/** What this plugin needs from the transport. Checked at configuration time. */
|
|
115
|
+
readonly requires?: TransportCapabilities;
|
|
116
|
+
/**
|
|
117
|
+
* Whether this plugin keeps a local copy of rows.
|
|
118
|
+
*
|
|
119
|
+
* This is ADR 0013 §4's membership test as a declared, checkable property
|
|
120
|
+
* rather than a rule someone has to remember: a stateless caller can assert
|
|
121
|
+
* that nothing in its list materialises, and CI can assert the core's own
|
|
122
|
+
* list is uniformly `false`.
|
|
123
|
+
*/
|
|
124
|
+
readonly materialises: boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Error codes this plugin may raise, folded into the registry.
|
|
127
|
+
*
|
|
128
|
+
* Registration is part of the contract because the error catalog is
|
|
129
|
+
* generated — a plugin that invents untyped errors would silently punch a
|
|
130
|
+
* hole in the published reference.
|
|
131
|
+
*/
|
|
132
|
+
readonly errorCodes?: Readonly<Record<string, ErrorCodeSpec>>;
|
|
133
|
+
/** Which pipeline stage this plugin attaches to, if it observes deltas. */
|
|
134
|
+
readonly stage?: PipelineStage;
|
|
135
|
+
/** Build the plugin's contribution to the client surface. */
|
|
136
|
+
init(context: PluginContext): Surface;
|
|
137
|
+
}
|
|
138
|
+
/** The surface a plugin list contributes, keyed by plugin id. */
|
|
139
|
+
export type InstalledSurface<Plugins extends readonly AbloPlugin[]> = {
|
|
140
|
+
[P in Plugins[number] as P['id']]: P extends AbloPlugin<infer S> ? S : never;
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* The plugin with the given id in a list, or `never` when absent. Sound
|
|
144
|
+
* because ids are literal ({@link LiteralString}); a list typed only as
|
|
145
|
+
* `AbloPlugin[]` has widened ids and resolves to `never`, so write plugin
|
|
146
|
+
* lists inline for the client type to follow them.
|
|
147
|
+
*/
|
|
148
|
+
export type PluginById<Plugins extends readonly AbloPlugin[], Id extends string> = Extract<Plugins[number], {
|
|
149
|
+
id: Id;
|
|
150
|
+
}>;
|
|
151
|
+
/** Collapses a union into an intersection, member by member. */
|
|
152
|
+
type UnionToIntersection<U> = (U extends unknown ? (member: U) => void : never) extends (member: infer I) => void ? I : never;
|
|
153
|
+
/**
|
|
154
|
+
* Every surface in a plugin list, folded into the one shape that merges onto
|
|
155
|
+
* the client: `[a(), b()]` contributes `ASurface & BSurface`. An empty list
|
|
156
|
+
* contributes nothing (`unknown`), so intersecting it changes no type.
|
|
157
|
+
*/
|
|
158
|
+
export type MergedSurface<Plugins extends readonly AbloPlugin[]> = [
|
|
159
|
+
Plugins[number]
|
|
160
|
+
] extends [never] ? unknown : UnionToIntersection<Plugins[number] extends AbloPlugin<infer Surface> ? Surface : never>;
|
|
161
|
+
/** What the selected transport can actually do, for checking `requires`. */
|
|
162
|
+
export interface TransportProfile {
|
|
163
|
+
readonly duplex: boolean;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Check a plugin list against the selected transport and build its surface.
|
|
167
|
+
*
|
|
168
|
+
* Both failures are configuration mistakes, so they surface here — while the
|
|
169
|
+
* client is being constructed and the stack still points at the caller's own
|
|
170
|
+
* setup — rather than later as a subscription that never delivers.
|
|
171
|
+
*/
|
|
172
|
+
export declare function resolvePlugins<const Plugins extends readonly AbloPlugin[], Options = unknown>(plugins: Plugins, transport: TransportProfile, context: PluginContext<Options>): InstalledSurface<Plugins>;
|
|
173
|
+
/**
|
|
174
|
+
* Lays every installed plugin surface over a built client, so a plugin's
|
|
175
|
+
* contributions are reachable as client members. The base always wins — a
|
|
176
|
+
* plugin cannot shadow `dispose`, a model accessor, or any other member the
|
|
177
|
+
* client itself defines; contributions only fill what the base leaves
|
|
178
|
+
* undefined. With nothing installed the base is returned untouched.
|
|
179
|
+
*
|
|
180
|
+
* The second half of {@link resolvePlugins}: that call turns a list into a
|
|
181
|
+
* surface, this one merges the surface onto the client the host built.
|
|
182
|
+
*/
|
|
183
|
+
export declare function layerPluginSurface<T extends object>(base: T, installed: Record<string, unknown>): T;
|
|
184
|
+
/**
|
|
185
|
+
* The plugins attached to one pipeline stage, in declaration order.
|
|
186
|
+
*
|
|
187
|
+
* Stage order across the pipeline is fixed by {@link PIPELINE_STAGES}; this
|
|
188
|
+
* returns the members of a single stage, where declaration order is the caller's
|
|
189
|
+
* to choose and carries no correctness weight.
|
|
190
|
+
*/
|
|
191
|
+
export declare function pluginsForStage(plugins: readonly AbloPlugin[], stage: PipelineStage): readonly AbloPlugin[];
|
|
192
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The plugin contract (ADR 0016).
|
|
3
|
+
*
|
|
4
|
+
* The core is `commit` · `get`/`list` · `observe` · `claim` · auth. Everything
|
|
5
|
+
* else a caller might want — a local materialised copy, presence rendering,
|
|
6
|
+
* batching, framework bindings — is a plugin declared in one list, so a server
|
|
7
|
+
* or an agent installs only what it asked for.
|
|
8
|
+
*
|
|
9
|
+
* Every plugin has the same shape on purpose. Uniformity is what makes the list
|
|
10
|
+
* composable and the types inferable; bespoke plugins would reproduce today's
|
|
11
|
+
* nineteen export subpaths with extra ceremony.
|
|
12
|
+
*
|
|
13
|
+
* Where this shape came from, and the field-by-field reasoning behind it, is
|
|
14
|
+
* recorded in ADR 0016 — the contract itself only states what each field does.
|
|
15
|
+
*/
|
|
16
|
+
import { AbloValidationError } from './errors.js';
|
|
17
|
+
/** Canonical order. A plugin runner must run stages in this sequence. */
|
|
18
|
+
export const PIPELINE_STAGES = [
|
|
19
|
+
'receive',
|
|
20
|
+
'dedupe',
|
|
21
|
+
'persist',
|
|
22
|
+
'apply',
|
|
23
|
+
'acknowledge',
|
|
24
|
+
'notify',
|
|
25
|
+
];
|
|
26
|
+
/**
|
|
27
|
+
* Check a plugin list against the selected transport and build its surface.
|
|
28
|
+
*
|
|
29
|
+
* Both failures are configuration mistakes, so they surface here — while the
|
|
30
|
+
* client is being constructed and the stack still points at the caller's own
|
|
31
|
+
* setup — rather than later as a subscription that never delivers.
|
|
32
|
+
*/
|
|
33
|
+
export function resolvePlugins(plugins, transport, context) {
|
|
34
|
+
const surface = {};
|
|
35
|
+
const seen = new Set();
|
|
36
|
+
for (const plugin of plugins) {
|
|
37
|
+
if (seen.has(plugin.id)) {
|
|
38
|
+
throw new AbloValidationError(`The ${plugin.id} plugin is listed twice. Remove the duplicate; a plugin is installed once per client.`, { code: 'invalid_options', param: 'plugins' });
|
|
39
|
+
}
|
|
40
|
+
seen.add(plugin.id);
|
|
41
|
+
if (plugin.requires?.duplex && !transport.duplex) {
|
|
42
|
+
throw new AbloValidationError(`The ${plugin.id} plugin needs a connection the server can send on, and this client is set up for request-response only. Switch the transport to 'websocket', or drop the plugin.`, { code: 'invalid_options', param: 'plugins' });
|
|
43
|
+
}
|
|
44
|
+
surface[plugin.id] = plugin.init(context);
|
|
45
|
+
}
|
|
46
|
+
return surface;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Lays every installed plugin surface over a built client, so a plugin's
|
|
50
|
+
* contributions are reachable as client members. The base always wins — a
|
|
51
|
+
* plugin cannot shadow `dispose`, a model accessor, or any other member the
|
|
52
|
+
* client itself defines; contributions only fill what the base leaves
|
|
53
|
+
* undefined. With nothing installed the base is returned untouched.
|
|
54
|
+
*
|
|
55
|
+
* The second half of {@link resolvePlugins}: that call turns a list into a
|
|
56
|
+
* surface, this one merges the surface onto the client the host built.
|
|
57
|
+
*/
|
|
58
|
+
export function layerPluginSurface(base, installed) {
|
|
59
|
+
const contributions = {};
|
|
60
|
+
for (const surface of Object.values(installed)) {
|
|
61
|
+
if (surface && typeof surface === 'object') {
|
|
62
|
+
Object.assign(contributions, surface);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (Object.keys(contributions).length === 0)
|
|
66
|
+
return base;
|
|
67
|
+
return new Proxy(base, {
|
|
68
|
+
get(target, prop, receiver) {
|
|
69
|
+
const own = Reflect.get(target, prop, receiver);
|
|
70
|
+
if (own !== undefined)
|
|
71
|
+
return own;
|
|
72
|
+
return typeof prop === 'string' && prop in contributions
|
|
73
|
+
? contributions[prop]
|
|
74
|
+
: own;
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The plugins attached to one pipeline stage, in declaration order.
|
|
80
|
+
*
|
|
81
|
+
* Stage order across the pipeline is fixed by {@link PIPELINE_STAGES}; this
|
|
82
|
+
* returns the members of a single stage, where declaration order is the caller's
|
|
83
|
+
* to choose and carries no correctness weight.
|
|
84
|
+
*/
|
|
85
|
+
export function pluginsForStage(plugins, stage) {
|
|
86
|
+
return plugins.filter((plugin) => plugin.stage === stage);
|
|
87
|
+
}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* the two; switch on `kind` to narrow it.
|
|
11
11
|
*/
|
|
12
12
|
import type { ParticipantRef } from '../types/participant.js';
|
|
13
|
-
import type { OnStaleMode } from '../coordination/schema.js';
|
|
13
|
+
import type { CommitOperationType, OnStaleMode } from '../coordination/schema.js';
|
|
14
14
|
export type ConflictKind = 'stale_context' | 'claim_held';
|
|
15
15
|
/** Fields shared by every conflict shape. */
|
|
16
16
|
interface ConflictBase {
|
|
@@ -23,7 +23,7 @@ interface ConflictBase {
|
|
|
23
23
|
export interface ConflictOperation {
|
|
24
24
|
readonly model: string;
|
|
25
25
|
readonly id: string;
|
|
26
|
-
readonly type:
|
|
26
|
+
readonly type: CommitOperationType;
|
|
27
27
|
readonly input?: Readonly<Record<string, unknown>>;
|
|
28
28
|
}
|
|
29
29
|
export interface StaleContextConflict extends ConflictBase {
|
|
@@ -48,7 +48,7 @@ export interface StaleContextConflict extends ConflictBase {
|
|
|
48
48
|
* else rejects. A custom policy may override this. When absent, it is treated
|
|
49
49
|
* as `'reject'`, the default for an unguarded write.
|
|
50
50
|
*/
|
|
51
|
-
readonly requestedMode?:
|
|
51
|
+
readonly requestedMode?: OnStaleMode;
|
|
52
52
|
}
|
|
53
53
|
export interface ClaimHeldConflict extends ConflictBase {
|
|
54
54
|
readonly kind: 'claim_held';
|
|
@@ -77,6 +77,8 @@ export const capabilityPreemptPolicy = (conflict) => {
|
|
|
77
77
|
}
|
|
78
78
|
return defaultPolicy(conflict);
|
|
79
79
|
};
|
|
80
|
+
const _conflictAxisPinned = [true, true];
|
|
81
|
+
void _conflictAxisPinned;
|
|
80
82
|
/**
|
|
81
83
|
* Resolves a declared {@link ConflictAxis} into a {@link ConflictDecision} for
|
|
82
84
|
* one concrete conflict. It is pure and synchronous, doing no I/O, so it can
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared resource types for the typed clients and private HTTP transport.
|
|
3
|
+
* the commit and claim shapes, the session-mint params and resource, and the
|
|
4
|
+
* {@link HttpClaimApi} derivation. This module holds only types and has no runtime
|
|
5
|
+
* imports.
|
|
6
|
+
*/
|
|
7
|
+
import type { OnStaleMode, ReadDependency, TrackDependency } from '../coordination/schema.js';
|
|
8
|
+
import type { ClientCommitReceipt, CommitWait } from '../wire/commit.js';
|
|
9
|
+
export type { CommitWait };
|
|
10
|
+
import type { ModelTarget, ModelClaim } from '../coordination/schema.js';
|
|
11
|
+
export type { ModelTarget, ModelClaim };
|
|
12
|
+
import type { ResolveClaimMeta } from '../types/global.js';
|
|
13
|
+
import type { SchemaRecord } from '../schema/schema.js';
|
|
14
|
+
import type { SyncGroupInput } from '../schema/roles.js';
|
|
15
|
+
import type { CapabilityCan, CapabilityOperation, CapabilityScope } from '../auth/capability.js';
|
|
16
|
+
import type { Claim, ClaimStream, ClaimWaitOptions, Duration, HeldClaim } from '../types/streams.js';
|
|
17
|
+
import type { ClaimOptions, ClaimParams, ClaimReadApi, AwaitedClaimMethod } from './modelOperations.js';
|
|
18
|
+
/**
|
|
19
|
+
* The operations available on each model in the sync engine:
|
|
20
|
+
* `retrieve({ id })` — an async single-row server read
|
|
21
|
+
* `list({ where })` — an async collection server read
|
|
22
|
+
* `local.retrieve(id)` / `local.list(...)` / `local.count(...)` — synchronous local reads
|
|
23
|
+
* `create({ data })` / `update({ id, data })` / `delete({ id })` — writes
|
|
24
|
+
* `claim({ id })` — a durable claim handle for coordinated writes
|
|
25
|
+
*/
|
|
26
|
+
export type ModelOperationAction = 'create' | 'update' | 'delete' | 'archive' | 'unarchive';
|
|
27
|
+
export type IfClaimedPolicy = 'return' | 'fail';
|
|
28
|
+
export interface ClaimedOptions {
|
|
29
|
+
/**
|
|
30
|
+
* What to do when another participant has claimed the target: `return` lets
|
|
31
|
+
* the read proceed; `fail` throws `AbloClaimedError`. Inspect claim state via
|
|
32
|
+
* `ablo.<model>.claim.state({ id })`. Waiting is a claim-side concern — take
|
|
33
|
+
* `ablo.<model>.claim({ id })` (it queues fairly); reads never block.
|
|
34
|
+
*/
|
|
35
|
+
readonly ifClaimed?: IfClaimedPolicy;
|
|
36
|
+
}
|
|
37
|
+
export type { ClaimWaitOptions } from '../types/streams.js';
|
|
38
|
+
export interface ModelReadOptions extends ClaimedOptions {
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The target a caller names when creating a claim: {@link ModelTarget} with its
|
|
42
|
+
* one caller-authored member typed — `meta` is the shape declared on
|
|
43
|
+
* `Register`'s `ClaimMeta` slot, the same declaration every reader of the claim
|
|
44
|
+
* is given back.
|
|
45
|
+
*
|
|
46
|
+
* Derived rather than restated, and narrowed only here: `modelTargetSchema`
|
|
47
|
+
* keeps parsing `meta` as an open record, because a peer on a newer build must
|
|
48
|
+
* still be understood. The wire stays permissive; the DTO the caller writes
|
|
49
|
+
* does not.
|
|
50
|
+
*/
|
|
51
|
+
export type ModelTargetInput = Omit<ModelTarget, 'meta'> & {
|
|
52
|
+
readonly meta?: ResolveClaimMeta;
|
|
53
|
+
};
|
|
54
|
+
export interface ClaimCreateOptions {
|
|
55
|
+
readonly target: ModelTargetInput;
|
|
56
|
+
/** Peer-visible description of the work — the same field on every claim
|
|
57
|
+
* surface. Defaults to `'editing'` when omitted. */
|
|
58
|
+
readonly description?: string;
|
|
59
|
+
readonly ttl?: Duration;
|
|
60
|
+
/**
|
|
61
|
+
* Join the server's fair FIFO queue when the target is already claimed,
|
|
62
|
+
* rather than failing immediately. `create` then resolves only once the
|
|
63
|
+
* lease is actually ours (the server pushes `claim_acquired` if the target
|
|
64
|
+
* was free, or `claim_granted` when we reach the head of the line). Without
|
|
65
|
+
* this, a contended claim throws. Used by `ablo.<model>.claim` so writers
|
|
66
|
+
* serialize instead of racing.
|
|
67
|
+
*/
|
|
68
|
+
readonly queue?: boolean;
|
|
69
|
+
/** Cap on how long to wait for a queued grant before rejecting. */
|
|
70
|
+
readonly waitTimeoutMs?: number;
|
|
71
|
+
/**
|
|
72
|
+
* Backpressure: reject with `AbloClaimedError('queue_too_deep')` instead of
|
|
73
|
+
* waiting if the queue is already `>= maxQueueDepth` when we join.
|
|
74
|
+
*/
|
|
75
|
+
readonly maxQueueDepth?: number;
|
|
76
|
+
}
|
|
77
|
+
export interface CommitOperationInput {
|
|
78
|
+
readonly action: ModelOperationAction;
|
|
79
|
+
/** The model name — matches `ablo.<model>` and the schema's `model()`. */
|
|
80
|
+
readonly model: string;
|
|
81
|
+
readonly id?: string | null;
|
|
82
|
+
readonly data?: Record<string, unknown> | null;
|
|
83
|
+
readonly transactionId?: string | null;
|
|
84
|
+
readonly readAt?: number | null;
|
|
85
|
+
readonly onStale?: OnStaleMode | null;
|
|
86
|
+
/** Fencing token (Option B) from the batch's claim handle; server-validated. */
|
|
87
|
+
readonly fenceToken?: number | null;
|
|
88
|
+
}
|
|
89
|
+
export interface CommitCreateOptions {
|
|
90
|
+
readonly idempotencyKey?: string | null;
|
|
91
|
+
readonly readAt?: number | null;
|
|
92
|
+
readonly onStale?: OnStaleMode | null;
|
|
93
|
+
/**
|
|
94
|
+
* A claim handle from `ablo.<model>.claim({ id })` (or the HTTP claim
|
|
95
|
+
* surface). Same vocabulary as the per-model writes: the handle's
|
|
96
|
+
* snapshot watermark becomes the batch `readAt` default and `onStale`
|
|
97
|
+
* defaults to `'reject'`, so a commit that follows a claim is guarded
|
|
98
|
+
* against concurrent edits without re-stating the watermark by hand.
|
|
99
|
+
* Explicit `readAt`/`onStale` on the options win.
|
|
100
|
+
*/
|
|
101
|
+
readonly claim?: Claim | null;
|
|
102
|
+
/** One atomic batch. Use a one-element array for a single operation. */
|
|
103
|
+
readonly operations: readonly CommitOperationInput[];
|
|
104
|
+
readonly wait?: CommitWait;
|
|
105
|
+
/**
|
|
106
|
+
* The batch premise — the "did anything I looked at change?" guard.
|
|
107
|
+
* Declare the rows (`{ model, id, readAt, fields? }`) or sync groups
|
|
108
|
+
* (`{ group, readAt }`, for example `report:abc`) this batch was premised on; the
|
|
109
|
+
* server checks that none moved since `readAt` and fires the entry's `onStale`
|
|
110
|
+
* over the batch. This is distinct from the write-target `readAt`: it guards what
|
|
111
|
+
* you read, not what you write.
|
|
112
|
+
*/
|
|
113
|
+
readonly reads?: readonly ReadDependency[] | null;
|
|
114
|
+
/**
|
|
115
|
+
* Durable premises to register as part of this batch — the persisted
|
|
116
|
+
* sibling of `reads`. Where `reads` guards only this commit, a `track` entry
|
|
117
|
+
* (`{ model, id, readAt? }` for a row or `{ group, readAt? }` for a sync group)
|
|
118
|
+
* lives on past it: a later matching change rides back on a future receipt's
|
|
119
|
+
* `notifications`. A track-only batch (just `track`, an empty `operations`) is
|
|
120
|
+
* the batch form of `ablo.<model>.track()`.
|
|
121
|
+
*/
|
|
122
|
+
readonly track?: readonly TrackDependency[] | null;
|
|
123
|
+
}
|
|
124
|
+
/** Public projection inferred from the canonical runtime schema. */
|
|
125
|
+
export type CommitReceipt = ClientCommitReceipt;
|
|
126
|
+
export interface CommitResource {
|
|
127
|
+
create(options: CommitCreateOptions): Promise<CommitReceipt>;
|
|
128
|
+
}
|
|
129
|
+
export interface ClaimResource extends ClaimStream {
|
|
130
|
+
create(options: ClaimCreateOptions): Promise<Claim>;
|
|
131
|
+
list(target?: Partial<ModelTarget>): readonly ModelClaim[];
|
|
132
|
+
waitFor(target: Partial<ModelTarget>, options?: ClaimWaitOptions): Promise<void>;
|
|
133
|
+
}
|
|
134
|
+
export interface ModelMutationOptions extends ClaimedOptions {
|
|
135
|
+
readonly claimRef?: string | {
|
|
136
|
+
readonly id: string;
|
|
137
|
+
} | null;
|
|
138
|
+
readonly idempotencyKey?: string | null;
|
|
139
|
+
readonly readAt?: number | null;
|
|
140
|
+
readonly onStale?: OnStaleMode | null;
|
|
141
|
+
readonly wait?: CommitWait;
|
|
142
|
+
readonly claim?: Claim | ClaimOptions | null;
|
|
143
|
+
/** Fencing token (Option B) from the claim; server-validated at commit. */
|
|
144
|
+
readonly fenceToken?: number | null;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* The stateless HTTP claim surface. Most code puts a `claim` directly on the write
|
|
148
|
+
* (`update({ id, data, claim })`) and lets the SDK release it; reach for this
|
|
149
|
+
* namespace for multi-step handles and coordination screens.
|
|
150
|
+
*
|
|
151
|
+
* It is the same surface as the reactive claim API, but because every read is a
|
|
152
|
+
* server round-trip, `state`, `queue`, and `reorder` are awaited here. The
|
|
153
|
+
* WebSocket client resolves those synchronously from its local cache, which is what
|
|
154
|
+
* lets it read a claim's state inside a React render; a stateless client has no
|
|
155
|
+
* cache to read, so the promise is unavoidable.
|
|
156
|
+
*
|
|
157
|
+
* It is derived from `ClaimReadApi` through {@link AwaitedClaimMethod} so the two
|
|
158
|
+
* transports cannot drift: the only difference is the promise wrapper that
|
|
159
|
+
* statelessness forces. `claim({ id })` is identical on both (already async);
|
|
160
|
+
* `state`, `queue`, `reorder`, and `release` are the awaited form.
|
|
161
|
+
*/
|
|
162
|
+
export type HttpClaimApi<T = Record<string, unknown>> = ((params: ClaimParams<T>) => Promise<HeldClaim<T>>) & {
|
|
163
|
+
[K in keyof ClaimReadApi<T>]: AwaitedClaimMethod<ClaimReadApi<T>[K]>;
|
|
164
|
+
};
|
|
165
|
+
/** A single data operation a scoped **agent** session may perform on a model.
|
|
166
|
+
* The SDK-facing name for {@link CapabilityOperation}; the vocabulary itself is
|
|
167
|
+
* declared once, as a schema, in `auth/capability.ts`. */
|
|
168
|
+
export type SessionOperation = CapabilityOperation;
|
|
169
|
+
/** Parameters for minting an end-user session — full data authority within the
|
|
170
|
+
* organization. Mints an `ek_` token. `user.id` is your end user's id from your
|
|
171
|
+
* own identity provider and becomes the session's `participantId`; Ablo does not
|
|
172
|
+
* model your users, so it is treated as an opaque string at the trust boundary. */
|
|
173
|
+
export interface CreateUserSessionParams {
|
|
174
|
+
/** Your end user. `id` becomes the token's `participantId`. */
|
|
175
|
+
user: {
|
|
176
|
+
id: string;
|
|
177
|
+
};
|
|
178
|
+
/** Mint the session into this organization instead of the key's own — for a
|
|
179
|
+
* platform that serves many tenants from one backend. Requires the `sk_` key to
|
|
180
|
+
* carry the `ephemeral:mint-any-org` scope; omit it for the normal
|
|
181
|
+
* single-tenant case. */
|
|
182
|
+
organizationId?: string;
|
|
183
|
+
/** Sync groups this session may subscribe to — typed (`'default'` or
|
|
184
|
+
* `<namespace>:<id>`; build with `syncGroup(kind, id)` from
|
|
185
|
+
* `@abloatai/ablo/schema`). Omit for the server default:
|
|
186
|
+
* `[org:<your org>, user:<user.id>]`. */
|
|
187
|
+
syncGroups?: readonly SyncGroupInput[];
|
|
188
|
+
/** Token lifetime in seconds. Defaults to 900 (15 minutes). */
|
|
189
|
+
ttlSeconds?: number;
|
|
190
|
+
/** Opaque identity blob echoed back to the client as `ablo.user`. */
|
|
191
|
+
userMeta?: Record<string, unknown>;
|
|
192
|
+
agent?: never;
|
|
193
|
+
can?: never;
|
|
194
|
+
}
|
|
195
|
+
/** Mint params for a scoped **agent** session — mints a restricted `rk_` token
|
|
196
|
+
* gated to exactly the operations named in `can`. `can` is typed off your
|
|
197
|
+
* schema (no magic `'task.update'` strings): `{ Task: ['update'], Report: ['read'] }`
|
|
198
|
+
* — the SDK serializes each entry to the wire allowlist (`task.update`). */
|
|
199
|
+
export interface CreateAgentSessionParams<S extends SchemaRecord> {
|
|
200
|
+
/** Your agent. `id` becomes the token's `participantId`. */
|
|
201
|
+
agent: {
|
|
202
|
+
id: string;
|
|
203
|
+
};
|
|
204
|
+
/** Per-model operation allowlist, typed against the schema's model names. */
|
|
205
|
+
can: CapabilityCan<S>;
|
|
206
|
+
/** Sync groups this session may subscribe to — typed (`'default'` or
|
|
207
|
+
* `<namespace>:<id>`; build with `syncGroup(kind, id)` from
|
|
208
|
+
* `@abloatai/ablo/schema`). Omit for the server default: the org
|
|
209
|
+
* anchor (`org:<your org>`) + the agent's own anchor. */
|
|
210
|
+
syncGroups?: readonly SyncGroupInput[];
|
|
211
|
+
/** Token lifetime in seconds. Defaults to 900 (15 minutes). */
|
|
212
|
+
ttlSeconds?: number;
|
|
213
|
+
/** Opaque identity blob echoed back to the client as `ablo.agent`. */
|
|
214
|
+
userMeta?: Record<string, unknown>;
|
|
215
|
+
user?: never;
|
|
216
|
+
}
|
|
217
|
+
/** Params for {@link Ablo.sessions}.create — a discriminated union: pass
|
|
218
|
+
* `{ user }` for a full-authority end-user session (`ek_`) or `{ agent, can }`
|
|
219
|
+
* for a scoped agent session (`rk_`). */
|
|
220
|
+
export type CreateSessionParams<S extends SchemaRecord> = CreateUserSessionParams | CreateAgentSessionParams<S>;
|
|
221
|
+
/** Params for {@link Ablo.agents}.create — a flattened agent descriptor (no
|
|
222
|
+
* `{ agent }` discriminator: `agents.create` only ever mints an agent). Unlike
|
|
223
|
+
* {@link CreateSessionParams} it resolves to a connected, scoped {@link Ablo}
|
|
224
|
+
* client rather than a raw token. */
|
|
225
|
+
export interface CreateAgentClientParams<S extends SchemaRecord> {
|
|
226
|
+
/** The wire participant identity (`agent:<id>`) that claim exclusion and the
|
|
227
|
+
* FIFO queue gate on. Omit it to get a fresh random id — a distinct, independent
|
|
228
|
+
* participant, which is the default and what you want for concurrent agents.
|
|
229
|
+
* Pass a stable string only when one logical agent must re-attach to its own
|
|
230
|
+
* held claims across reconnects or restarts. */
|
|
231
|
+
id?: string;
|
|
232
|
+
/** A human-readable label for logs and attribution (carried in `userMeta.name`).
|
|
233
|
+
* It is independent of `id`: two agents that share a `name` still receive
|
|
234
|
+
* distinct ids and coordinate as separate participants — `name` never derives or
|
|
235
|
+
* collapses identity. */
|
|
236
|
+
name?: string;
|
|
237
|
+
/** Per-model operation allowlist, typed against the schema's model names. */
|
|
238
|
+
can: CapabilityCan<S>;
|
|
239
|
+
/** Sync groups this agent may subscribe to — typed (`'default'` or
|
|
240
|
+
* `<namespace>:<id>`). Omit for the server default (org anchor + the
|
|
241
|
+
* agent's own anchor). */
|
|
242
|
+
syncGroups?: readonly SyncGroupInput[];
|
|
243
|
+
/** Token lifetime in seconds. Defaults to 900 (15 minutes); the returned client
|
|
244
|
+
* re-mints before expiry, so a long-running agent never handles rotation
|
|
245
|
+
* itself. */
|
|
246
|
+
ttlSeconds?: number;
|
|
247
|
+
/** Extra opaque identity blob echoed on the session scope. Merged with
|
|
248
|
+
* `name` (the `name` param wins if you also set `userMeta.name`). */
|
|
249
|
+
userMeta?: Record<string, unknown>;
|
|
250
|
+
}
|
|
251
|
+
/** A minted session. `token` is the secret the holder presents as its bearer. */
|
|
252
|
+
export interface AbloSession {
|
|
253
|
+
object: 'session';
|
|
254
|
+
/** Stable id of the minted credential (for revocation). */
|
|
255
|
+
id: string;
|
|
256
|
+
/** The short-lived session token — `ek_` for a `{ user }` session, `rk_`
|
|
257
|
+
* for an `{ agent }` session. Hand this to the participant's runtime. */
|
|
258
|
+
token: string;
|
|
259
|
+
/** ISO-8601 expiry. */
|
|
260
|
+
expiresAt: string;
|
|
261
|
+
organizationId: string;
|
|
262
|
+
/** The grant this token carries, on both axes — the same shape the key row
|
|
263
|
+
* stores and the gates enforce. */
|
|
264
|
+
scope: CapabilityScope;
|
|
265
|
+
userMeta: Record<string, unknown>;
|
|
266
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared resource types for the typed clients and private HTTP transport.
|
|
3
|
+
* the commit and claim shapes, the session-mint params and resource, and the
|
|
4
|
+
* {@link HttpClaimApi} derivation. This module holds only types and has no runtime
|
|
5
|
+
* imports.
|
|
6
|
+
*/
|
|
7
|
+
export {};
|