@abloatai/humans 0.56.0 → 0.58.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.
Files changed (130) hide show
  1. package/dist/Ablo.d.ts +8 -18
  2. package/dist/client.d.ts +6 -19
  3. package/dist/core.d.ts +1 -1
  4. package/dist/core.js +1 -1
  5. package/dist/local/Database.d.ts +1 -1
  6. package/dist/local/Model.js +1 -1
  7. package/dist/local/SyncClient.d.ts +3 -34
  8. package/dist/local/SyncClient.js +6 -16
  9. package/dist/local/client/createInternalComponents.d.ts +1 -1
  10. package/dist/local/client/createInternalComponents.js +1 -1
  11. package/dist/local/client/{createModelProxy.d.ts → createModelOperations.d.ts} +22 -9
  12. package/dist/local/client/{createModelProxy.js → createModelOperations.js} +341 -335
  13. package/dist/local/client/options.d.ts +2 -2
  14. package/dist/local/client/reactiveEngine.js +38 -45
  15. package/dist/local/client/resourceTypes.d.ts +3 -3
  16. package/dist/local/client/resourceTypes.js +1 -1
  17. package/dist/local/client/wsMutationExecutor.d.ts +4 -4
  18. package/dist/local/client/wsMutationExecutor.js +4 -5
  19. package/dist/local/coordination/ClaimLog.d.ts +3 -3
  20. package/dist/local/coordination/ClaimLog.js +2 -2
  21. package/dist/local/interfaces/index.d.ts +5 -7
  22. package/dist/local/mutators/mutateActions.d.ts +3 -2
  23. package/dist/local/query/types.d.ts +2 -2
  24. package/dist/local/stores/syncAction.d.ts +1 -1
  25. package/dist/local/stores/syncAction.js +1 -1
  26. package/dist/local/sync/ConnectionManager.d.ts +1 -1
  27. package/dist/local/sync/ConnectionManager.js +1 -1
  28. package/dist/local/sync/OnDemandLoader.d.ts +1 -1
  29. package/dist/local/sync/OnDemandLoader.js +1 -1
  30. package/dist/local/sync/SyncWebSocket.d.ts +3 -3
  31. package/dist/local/sync/SyncWebSocket.js +2 -2
  32. package/dist/local/sync/commitFrames.d.ts +1 -1
  33. package/dist/local/sync/commitFrames.js +1 -1
  34. package/dist/local/sync/contextOnChange.d.ts +8 -0
  35. package/dist/local/sync/contextOnChange.js +65 -0
  36. package/dist/local/sync/createClaimStream.d.ts +1 -1
  37. package/dist/local/sync/createClaimStream.js +47 -28
  38. package/dist/local/sync/credentialLifecycle.d.ts +1 -1
  39. package/dist/local/sync/credentialLifecycle.js +1 -1
  40. package/dist/local/sync/participants.d.ts +1 -1
  41. package/dist/local/sync/schemas.d.ts +2 -2
  42. package/dist/local/sync/schemas.js +1 -1
  43. package/dist/local/sync/wsFrameHandlers.d.ts +1 -1
  44. package/dist/local/sync/wsFrameHandlers.js +1 -1
  45. package/dist/local/syncClientTypes.d.ts +41 -0
  46. package/dist/local/syncClientTypes.js +11 -0
  47. package/dist/local/transactions/databaseCommitOutbox.d.ts +2 -2
  48. package/dist/local/transactions/mutations/MutationQueue.d.ts +5 -18
  49. package/dist/local/transactions/mutations/MutationQueue.js +57 -137
  50. package/dist/local/transactions/mutations/batchProcessing.d.ts +2 -13
  51. package/dist/local/transactions/mutations/batchProcessing.js +0 -20
  52. package/dist/local/transactions/mutations/commitApi.d.ts +2 -3
  53. package/dist/local/transactions/mutations/commitApi.js +0 -4
  54. package/dist/local/transactions/mutations/commitLane.d.ts +6 -8
  55. package/dist/local/transactions/mutations/commitLane.js +12 -14
  56. package/dist/local/transactions/mutations/commitPayload.d.ts +2 -4
  57. package/dist/local/transactions/mutations/commitPayload.js +2 -6
  58. package/dist/local/transactions/mutations/commitTransport.d.ts +3 -4
  59. package/dist/local/transactions/mutations/commitTransport.js +2 -5
  60. package/dist/local/transactions/mutations/durableCommitRestore.d.ts +1 -1
  61. package/dist/local/transactions/mutations/durableCommitRestore.js +1 -4
  62. package/dist/local/transactions/mutations/durableWriteStore.d.ts +5 -5
  63. package/dist/local/transactions/mutations/durableWriteStore.js +3 -3
  64. package/dist/local/transactions/mutations/failurePolicy.d.ts +2 -2
  65. package/dist/local/transactions/mutations/mutationInput.d.ts +40 -0
  66. package/dist/local/transactions/mutations/mutationInput.js +53 -0
  67. package/dist/local/transactions/mutations/mutationPersistence.d.ts +1 -1
  68. package/dist/local/transactions/mutations/pendingDrain.d.ts +2 -2
  69. package/dist/local/transactions/mutations/replayValidation.d.ts +0 -20
  70. package/dist/local/transactions/mutations/replayValidation.js +1 -3
  71. package/dist/local/transactions/persistedTransaction.d.ts +0 -2
  72. package/dist/plugin.d.ts +2 -2
  73. package/dist/presenceStream.d.ts +1 -1
  74. package/dist/react/createAbloReact.d.ts +1 -1
  75. package/dist/react/useAblo.d.ts +2 -2
  76. package/dist/react/useAblo.js +1 -1
  77. package/dist/surface.d.ts +1 -1
  78. package/dist/surface.js +2 -2
  79. package/package.json +2 -2
  80. package/src/Ablo.ts +9 -27
  81. package/src/client.ts +6 -22
  82. package/src/core.ts +1 -1
  83. package/src/local/Database.ts +1 -2
  84. package/src/local/Model.ts +1 -1
  85. package/src/local/SyncClient.ts +17 -72
  86. package/src/local/client/createInternalComponents.ts +2 -2
  87. package/src/local/client/{createModelProxy.ts → createModelOperations.ts} +396 -320
  88. package/src/local/client/options.ts +2 -2
  89. package/src/local/client/reactiveEngine.ts +67 -55
  90. package/src/local/client/resourceTypes.ts +4 -4
  91. package/src/local/client/wsMutationExecutor.ts +4 -9
  92. package/src/local/coordination/ClaimLog.ts +3 -3
  93. package/src/local/interfaces/index.ts +5 -7
  94. package/src/local/mutators/mutateActions.ts +3 -2
  95. package/src/local/query/types.ts +2 -2
  96. package/src/local/stores/syncAction.ts +1 -1
  97. package/src/local/sync/ConnectionManager.ts +1 -1
  98. package/src/local/sync/OnDemandLoader.ts +1 -1
  99. package/src/local/sync/SyncWebSocket.ts +3 -3
  100. package/src/local/sync/commitFrames.ts +1 -2
  101. package/src/local/sync/contextOnChange.ts +92 -0
  102. package/src/local/sync/createClaimStream.ts +77 -39
  103. package/src/local/sync/credentialLifecycle.ts +1 -1
  104. package/src/local/sync/participants.ts +1 -1
  105. package/src/local/sync/schemas.ts +1 -1
  106. package/src/local/sync/wsFrameHandlers.ts +1 -1
  107. package/src/local/syncClientTypes.ts +59 -0
  108. package/src/local/transactions/databaseCommitOutbox.ts +2 -2
  109. package/src/local/transactions/mutations/MutationQueue.ts +69 -183
  110. package/src/local/transactions/mutations/batchProcessing.ts +2 -38
  111. package/src/local/transactions/mutations/commitApi.ts +3 -7
  112. package/src/local/transactions/mutations/commitLane.ts +24 -20
  113. package/src/local/transactions/mutations/commitPayload.ts +3 -11
  114. package/src/local/transactions/mutations/commitTransport.ts +3 -7
  115. package/src/local/transactions/mutations/durableCommitRestore.ts +2 -5
  116. package/src/local/transactions/mutations/durableWriteStore.ts +5 -5
  117. package/src/local/transactions/mutations/failurePolicy.ts +2 -2
  118. package/src/local/transactions/mutations/mutationInput.ts +69 -0
  119. package/src/local/transactions/mutations/mutationPersistence.ts +1 -1
  120. package/src/local/transactions/mutations/pendingDrain.ts +2 -2
  121. package/src/local/transactions/mutations/replayValidation.ts +1 -3
  122. package/src/local/transactions/persistedTransaction.ts +0 -3
  123. package/src/plugin.ts +2 -2
  124. package/src/presenceStream.ts +2 -2
  125. package/src/react/createAbloReact.ts +1 -1
  126. package/src/react/useAblo.ts +2 -2
  127. package/src/surface.ts +3 -3
  128. package/dist/local/sync/createSnapshot.d.ts +0 -29
  129. package/dist/local/sync/createSnapshot.js +0 -116
  130. package/src/local/sync/createSnapshot.ts +0 -160
package/dist/Ablo.d.ts CHANGED
@@ -65,7 +65,6 @@ export declare function Ablo<const S extends SchemaRecord, const P extends reado
65
65
  export declare function Ablo<const S extends SchemaRecord>(options: AbloOptions<S>): Ablo<S>;
66
66
  import type * as _Streams from '@abloatai/transaction/types/streams';
67
67
  import type * as _Participants from './local/sync/participants.js';
68
- import type * as _Policy from '@abloatai/transaction/policy/types';
69
68
  import type * as _Mutators from './local/mutators/defineMutators.js';
70
69
  import type * as _Tx from './local/mutators/Transaction.js';
71
70
  import type * as _Undo from './local/mutators/UndoManager.js';
@@ -108,7 +107,6 @@ export declare namespace Ablo {
108
107
  type ClaimLost = _Streams.ClaimLost;
109
108
  type ClaimHeartbeat = _Streams.ClaimHeartbeat;
110
109
  type ClaimHeartbeatOptions = _Streams.ClaimHeartbeatOptions;
111
- type Snapshot<TSchema extends _SchemaTypes.Schema = _SchemaTypes.Schema, K extends keyof TSchema['models'] = keyof TSchema['models']> = _Streams.Snapshot<TSchema, K>;
112
110
  namespace Auth {
113
111
  type Actor = _Streams.ParticipantRef;
114
112
  }
@@ -150,14 +148,6 @@ export declare namespace Ablo {
150
148
  type InferRow<S extends _SchemaTypes.Schema, K extends keyof S['models']> = _SchemaTypes.InferRow<S, K>;
151
149
  type InferModelNames<S extends _SchemaTypes.Schema> = _SchemaTypes.InferModelNames<S>;
152
150
  }
153
- type Conflict = _Policy.Conflict;
154
- namespace Conflict {
155
- type Kind = _Policy.ConflictKind;
156
- type Operation = _Policy.ConflictOperation;
157
- type Decision = _Policy.ConflictDecision;
158
- type Policy = _Policy.ConflictPolicy;
159
- type Axis = _Policy.ConflictAxis;
160
- }
161
151
  namespace Commit {
162
152
  type Wait = import('./local/client/resourceTypes.js').CommitWait;
163
153
  type OperationAction = import('./local/client/resourceTypes.js').ModelOperationAction;
@@ -171,19 +161,19 @@ export declare namespace Ablo {
171
161
  type Held<T = Record<string, unknown>> = import('@abloatai/transaction/types/streams').HeldClaim<T>;
172
162
  type CreateOptions = import('./local/client/resourceTypes.js').ClaimCreateOptions;
173
163
  type WaitOptions = import('./local/client/resourceTypes.js').ClaimWaitOptions;
174
- type ContentionOptions = import('@abloatai/transaction/resources/modelOperations').ClaimContentionOptions;
175
- type AttemptEvent = import('@abloatai/transaction/resources/modelOperations').ClaimAttemptEvent;
176
- type QueueView = import('@abloatai/transaction/resources/modelOperations').ClaimQueueView;
164
+ type ContentionOptions = import('@abloatai/transaction/client/resources/modelOperations').ClaimContentionOptions;
165
+ type AttemptEvent = import('@abloatai/transaction/client/resources/modelOperations').ClaimAttemptEvent;
166
+ type QueueView = import('@abloatai/transaction/client/resources/modelOperations').ClaimQueueView;
177
167
  type Client = import('./local/client/resourceTypes.js').ClaimResource;
178
168
  }
179
169
  namespace Model {
180
170
  type Target = import('./local/client/resourceTypes.js').ModelTarget;
181
171
  type Claim = import('./local/client/resourceTypes.js').ModelClaim;
182
- type Operations<T, CreateInput = T> = import('./local/client/createModelProxy.js').ModelOperations<T, CreateInput>;
183
- type ClaimOptions<T = Record<string, unknown>> = import('./local/client/createModelProxy.js').ClaimOptions<T>;
184
- type ClaimParams<T = Record<string, unknown>> = import('./local/client/createModelProxy.js').ClaimParams<T>;
185
- type ClaimLookupParams<T = Record<string, unknown>> = import('./local/client/createModelProxy.js').ClaimLookupParams<T>;
186
- type ClaimReorderParams<T = Record<string, unknown>> = import('./local/client/createModelProxy.js').ClaimReorderParams<T>;
172
+ type Operations<T, CreateInput = T> = import('./local/client/createModelOperations.js').ModelOperations<T, CreateInput>;
173
+ type ClaimOptions<T = Record<string, unknown>> = import('./local/client/createModelOperations.js').ClaimOptions<T>;
174
+ type ClaimParams<T = Record<string, unknown>> = import('./local/client/createModelOperations.js').ClaimParams<T>;
175
+ type ClaimLookupParams<T = Record<string, unknown>> = import('./local/client/createModelOperations.js').ClaimLookupParams<T>;
176
+ type ClaimReorderParams<T = Record<string, unknown>> = import('./local/client/createModelOperations.js').ClaimReorderParams<T>;
187
177
  type MutationOptions = import('./local/client/resourceTypes.js').ModelMutationOptions;
188
178
  }
189
179
  namespace Source {
package/dist/client.d.ts CHANGED
@@ -11,14 +11,16 @@
11
11
  * the factory back and creating a cycle.
12
12
  */
13
13
  import type { Schema, SchemaRecord, Model, InferCreate, InferRow } from '@abloatai/transaction/schema/schema';
14
- import type { PresenceStream, Snapshot } from '@abloatai/transaction/types/streams';
14
+ import type { PresenceStream } from '@abloatai/transaction/types/streams';
15
15
  import type { InstanceCache } from './local/InstanceCache.js';
16
16
  import type { SyncStoreContract } from './react/context.js';
17
17
  import type { SyncWebSocket, CoreSyncEventMap } from './local/sync/SyncWebSocket.js';
18
18
  import type { SyncStatus } from './local/BaseSyncedStore.js';
19
- import type { ModelOperations } from './local/client/createModelProxy.js';
20
- import type { ClaimResource, CommitResource, CreateAgentClientParams, SessionResource } from '@abloatai/transaction/resources/httpResources';
19
+ import type { ModelOperations } from './local/client/createModelOperations.js';
20
+ import type { ClaimResource, CommitResource, CreateAgentClientParams, SessionResource } from '@abloatai/transaction/client/resources/httpResources';
21
21
  import type { EffectiveAuthority } from '@abloatai/transaction/auth';
22
+ import type { ReadDependency } from '@abloatai/transaction/coordination';
23
+ import type { CapturedRow } from '@abloatai/transaction/transport/http';
22
24
  export type { LocalReadOptions } from './local/client/resourceTypes.js';
23
25
  /** The typed sync engine client — one property per model in the schema */
24
26
  export type AbloClient<S extends SchemaRecord> = {
@@ -268,22 +270,7 @@ export type AbloClient<S extends SchemaRecord> = {
268
270
  * Canonical low-level mutation API. Every untyped model write compiles
269
271
  * down to `commits.create(...)`.
270
272
  */
271
- readonly commits: CommitResource;
272
- /**
273
- * Capture a context-staleness watermark over a set of entities.
274
- * Returns a flat snapshot with `stamp` (thread into writes as
275
- * `readAt`), `signal` (aborts on any captured-entity delta), and
276
- * `onChange` (callback form). Reads from the engine's InstanceCache;
277
- * subscription is on the engine's existing transport.
278
- *
279
- * Use before an LLM call to prevent the model from completing
280
- * against now-stale data:
281
- * ```ts
282
- * const snap = engine.snapshot({ sections: report.sectionIds });
283
- * await streamText({ messages, signal: snap.signal });
284
- * ```
285
- */
286
- snapshot<ModelName extends keyof S & string>(entities: Readonly<Record<ModelName, string | readonly string[]>>): Snapshot<Schema<S>, ModelName>;
273
+ readonly commits: CommitResource<ReadDependency | CapturedRow>;
287
274
  /**
288
275
  * Subscribe to pushed frames — deltas, presence updates, claim grants and
289
276
  * losses, connection changes. Durable: the subscription survives the
package/dist/core.d.ts CHANGED
@@ -30,7 +30,7 @@ export { BootstrapFetcher } from './local/sync/BootstrapFetcher.js';
30
30
  * existing imports working and will be removed in a future major version. */
31
31
  export { BootstrapFetcher as BootstrapHelper } from './local/sync/BootstrapFetcher.js';
32
32
  export { createClaimStream, type AttachableClaimStream, type ClaimStreamConfig, } from './local/sync/createClaimStream.js';
33
- export { awaitClaimGrant, type GrantTransport, } from '@abloatai/transaction/coordination/awaitClaimGrant';
33
+ export { awaitClaimGrant, type GrantTransport, } from '@abloatai/transaction/claims';
34
34
  export { LoadStrategy } from '@abloatai/transaction/types';
35
35
  export type { InternalAbloOptions } from './local/client/options.js';
36
36
  export { drainProfileSnapshot, resetDrainProfile, drainProfilingEnabled, drainAcknowledgeStamps, type AcknowledgeStamp, type DrainProfile, type DrainBatchRow, type DrainStage, type DrainStageTotals, } from './local/sync/drainProfile.js';
package/dist/core.js CHANGED
@@ -42,7 +42,7 @@ export { BootstrapFetcher as BootstrapHelper } from './local/sync/BootstrapFetch
42
42
  // grants. These are for extension code and test harnesses; ordinary
43
43
  // application code should use `ablo.<model>.claim`.
44
44
  export { createClaimStream, } from './local/sync/createClaimStream.js';
45
- export { awaitClaimGrant, } from '@abloatai/transaction/coordination/awaitClaimGrant';
45
+ export { awaitClaimGrant, } from '@abloatai/transaction/claims';
46
46
  // An enum naming the strategies for loading a model's data. Referenced when
47
47
  // registering models in extension code.
48
48
  export { LoadStrategy } from '@abloatai/transaction/types';
@@ -13,7 +13,7 @@ import type { RuntimeContext } from './RuntimeContext.js';
13
13
  import type { AppliedChange } from '../plugin.js';
14
14
  import type { BootstrapFetcher, BootstrapData } from './sync/BootstrapFetcher.js';
15
15
  import { InMemoryObjectStore } from './adapters/inMemoryStorage.js';
16
- import type { SyncDeltaAction } from '@abloatai/transaction/wire/delta';
16
+ import type { SyncDeltaAction } from '@abloatai/transaction/observation';
17
17
  import type { BootstrapType } from '@abloatai/transaction/types';
18
18
  import { type PersistedTransaction } from './transactions/persistedTransaction.js';
19
19
  /** Generic record type for model data */
@@ -936,7 +936,7 @@ export class Model {
936
936
  throw new AbloValidationError('Model identifier (__typename, __class, or modelName) not found in data', { code: 'model_identifier_missing' });
937
937
  }
938
938
  // Try to get model class by identifier
939
- let ModelClass = getActiveRegistry().getModelByName(modelIdentifier);
939
+ const ModelClass = getActiveRegistry().getModelByName(modelIdentifier);
940
940
  if (!ModelClass) {
941
941
  throw new AbloValidationError(`Model class not found for: ${modelIdentifier}`, { code: 'model_class_not_registered' });
942
942
  }
@@ -17,41 +17,11 @@ import { type CommitLatencySample } from './transactions/mutations/commitLatency
17
17
  import { type UnconfirmedWritesMetrics } from './transactions/mutations/UnconfirmedWrites.js';
18
18
  import type { DurableWriteStore } from './transactions/mutations/durableWriteStore.js';
19
19
  import type { Database } from './Database.js';
20
- import type { BootstrapData } from './sync/BootstrapFetcher.js';
21
20
  import type { WriteOptions } from './interfaces/index.js';
22
21
  import { LogPosition } from './logPosition.js';
23
- interface SyncObserver {
24
- onSync?: (event: SyncEvent) => void;
25
- }
26
- interface SyncEvent {
27
- type: 'create' | 'update' | 'delete' | 'archive' | 'rollback';
28
- modelType: string;
29
- model?: Model;
30
- modelId?: string;
31
- transactionType?: string;
32
- }
33
- interface SyncState {
34
- connectionState: 'connected' | 'disconnected' | 'connecting';
35
- pendingMutations: number;
36
- lastSyncAt?: Date;
37
- error?: Error;
38
- }
39
- export interface RehydrationStats {
40
- added: number;
41
- updated: number;
42
- removed: number;
43
- skipped: number;
44
- healed: number;
45
- elapsedMs: number;
46
- }
47
- /**
48
- * The slice of a bootstrap answer the pool applies: its rows, the models whose
49
- * server query failed, and the log position the snapshot was taken at — the
50
- * position every row in it reflects. `lastSyncId` is optional only for callers
51
- * applying rows with no snapshot position to speak of; the fetcher always
52
- * names one.
53
- */
54
- export type BootstrapSnapshot = Pick<BootstrapData, 'models' | 'failedModels'> & Partial<Pick<BootstrapData, 'lastSyncId'>>;
22
+ import { type RehydrationStats, type SyncObserver, type SyncState } from './syncClientTypes.js';
23
+ import type { BootstrapSnapshot } from './syncClientTypes.js';
24
+ export type { BootstrapSnapshot, RehydrationStats } from './syncClientTypes.js';
55
25
  export declare class SyncClient extends EventEmitter {
56
26
  private readonly runtime;
57
27
  private objectPool;
@@ -533,4 +503,3 @@ export declare class SyncClient extends EventEmitter {
533
503
  healed: number;
534
504
  };
535
505
  }
536
- export {};
@@ -24,22 +24,7 @@ import { LogPosition } from './logPosition.js';
24
24
  import { createLocalMutationPort } from './transactions/localMutation.js';
25
25
  import { createReconnectDrain } from './transactions/reconnectDrain.js';
26
26
  import { DatabaseCommitOutboxStore } from './transactions/databaseCommitOutbox.js';
27
- /**
28
- * Converts an untyped server `updatedAt` value — an ISO string, epoch number,
29
- * or Date read off an untyped row — into epoch milliseconds for
30
- * last-write-wins comparison. Falsy or non-date values become 0, matching the
31
- * conflict resolver's rule that a missing timestamp sorts as the epoch.
32
- */
33
- function toEpochMs(value) {
34
- if (!value)
35
- return 0;
36
- if (value instanceof Date)
37
- return value.getTime();
38
- if (typeof value === 'string' || typeof value === 'number') {
39
- return new Date(value).getTime();
40
- }
41
- return 0;
42
- }
27
+ import { toEpochMs, } from './syncClientTypes.js';
43
28
  export class SyncClient extends EventEmitter {
44
29
  runtime;
45
30
  objectPool;
@@ -1244,6 +1229,11 @@ export class SyncClient extends EventEmitter {
1244
1229
  dispose() {
1245
1230
  this.isDisposed = true;
1246
1231
  this.disconnect();
1232
+ // The queue owns commit retry, replication-lag, offline-grace, and
1233
+ // per-mutation timers. A disposed client must release those resources too;
1234
+ // otherwise an atomic commit can keep a worker process alive after the
1235
+ // public client has been disposed.
1236
+ this.mutationQueue.dispose();
1247
1237
  this.networkMonitor.dispose();
1248
1238
  this.observers.clear();
1249
1239
  this.pendingStages.clear();
@@ -16,7 +16,7 @@ import { BootstrapFetcher } from '../sync/BootstrapFetcher.js';
16
16
  import type { AuthCredentialSource } from '@abloatai/transaction/auth/credentialSource';
17
17
  import type { Schema, SchemaRecord } from '@abloatai/transaction/schema/schema';
18
18
  import { type AbloPersistence } from '../persistence.js';
19
- import type { DurableWriteStore, DurableWritesConfig } from '@abloatai/transaction/durableWrites';
19
+ import type { DurableWriteStore, DurableWritesConfig } from '@abloatai/transaction/commit';
20
20
  import type { RuntimeContext } from '../RuntimeContext.js';
21
21
  export interface InternalComponentsInput<S extends SchemaRecord> {
22
22
  readonly schema: Schema<S>;
@@ -17,7 +17,7 @@ import { loadsAtBootstrap } from '@abloatai/transaction/schema/loadStrategy';
17
17
  import { resolveBootstrapBaseUrl } from '@abloatai/transaction/auth/apiKey';
18
18
  import { shouldUseInMemoryPersistence, } from '../persistence.js';
19
19
  import { globalRuntime } from '../context.js';
20
- import { resolveDurableWrites } from '@abloatai/transaction/durableWrites';
20
+ import { resolveDurableWrites } from '@abloatai/transaction/commit';
21
21
  export function createInternalComponents(input) {
22
22
  const { schema, url, options, auth } = input;
23
23
  const runtime = input.runtime ?? globalRuntime;
@@ -3,24 +3,25 @@
3
3
  * `ablo.<model>`.
4
4
  *
5
5
  * Each schema model gets one {@link ModelOperations}: the async server reads
6
- * `get` and `list`, with the same point lookup restricted to the local graph under
6
+ * `read` and `list`, with the same point lookup restricted to the local graph under
7
7
  * `local`, the writes `create`, `update`, and `delete`, the coordination
8
8
  * namespace `claim` (callable as `claim({ id })`, plus `claim.state`,
9
9
  * `claim.queue`, `claim.release`, and `claim.reorder`), `join`, and `onChange`.
10
10
  * The factory returns a plain object; the client assembles the `ablo.<model>`
11
11
  * lookup table from one of these per model.
12
12
  */
13
+ import type { CommitCreateOptions, CommitReceipt } from '@abloatai/transaction/client/resources/httpResources';
13
14
  import type { ModelTarget } from '@abloatai/transaction/coordination/schema';
14
15
  import type { ModelRegistry } from '../ModelRegistry.js';
15
16
  import type { InstanceCache } from '../InstanceCache.js';
16
17
  import type { SyncClient } from '../SyncClient.js';
17
18
  import type { OnDemandLoader } from '../sync/OnDemandLoader.js';
18
19
  import type { JoinedParticipant } from '../sync/participants.js';
19
- import type { Duration, Claim, ClaimHeartbeat, ClaimHeartbeatOptions, HeldClaim, HeldLease, ClaimWaitOptions, Snapshot } from '@abloatai/transaction/types/streams';
20
- export type { ModelListScope, ModelTrackParams, ModelTrackResult, LocalReadOptions, LocalCountOptions, ServerReadOptions, ServerGetOptions, ServerRetrieveOptions, ClaimTargetOptions, ClaimParams, ClaimContentionOptions, ClaimAttemptEvent, ClaimQueueView, ClaimSkipOptions, ClaimSkipParams, ClaimLookupParams, ClaimReorderParams, ClaimOptions, ClaimReadApi, AwaitedClaimMethod, ClaimApi, ModelRetrieveParams, ModelCreateParams, ModelUpdateParams, ModelDeleteParams, JoinOptions, } from '@abloatai/transaction/resources/modelOperations';
20
+ import type { Duration, Claim, ClaimHeartbeat, ClaimHeartbeatOptions, HeldClaim, HeldLease, ClaimWaitOptions } from '@abloatai/transaction/types/streams';
21
+ export type { ModelListScope, LocalReadOptions, LocalCountOptions, ServerReadOptions, ListAllOptions, ServerPointReadOptions, ClaimTargetOptions, ClaimParams, ClaimContentionOptions, ClaimAttemptEvent, ClaimQueueView, ClaimSkipOptions, ClaimSkipParams, ClaimLookupParams, ClaimReorderParams, ClaimOptions, ClaimReadApi, AwaitedClaimMethod, ClaimApi, ModelReadParams, ModelCreateParams, ModelUpdateParams, ModelDeleteParams, JoinOptions, } from '@abloatai/transaction/client/resources/modelOperations';
21
22
  export type { Claim, ClaimHeartbeat, ClaimHeartbeatOptions, HeldClaim, HeldLease };
22
- import type { ClaimApi, ClaimAttemptEvent, JoinOptions, LocalCountOptions, LocalReadOptions } from '@abloatai/transaction/resources/modelOperations';
23
- import type { HttpModelClient } from '@abloatai/transaction/transport/httpClient';
23
+ import type { ClaimApi, ClaimAttemptEvent, JoinOptions, LocalCountOptions, LocalReadOptions } from '@abloatai/transaction/client/resources/modelOperations';
24
+ import type { HttpModelClient } from '@abloatai/transaction/transport/http';
24
25
  import type { ParticipantKind } from '@abloatai/transaction/types/participant';
25
26
  import { type ReadSetContext } from '@abloatai/transaction/internal/read-set';
26
27
  export interface ModelClientMeta {
@@ -39,6 +40,17 @@ export interface ModelCollaboration {
39
40
  data: unknown;
40
41
  stamp: number;
41
42
  }>;
43
+ /**
44
+ * The batch commit lane, for a create handed a list of rows.
45
+ *
46
+ * A reactive client's single writes go through the mutation queue and land
47
+ * optimistically, because a rejected write rolls one row back. A batch
48
+ * cannot: it is atomic, so applying the rows one at a time would paint a
49
+ * half-written state the server may then decline whole. It goes down the
50
+ * same commit door the stateless client uses and the rows arrive on the
51
+ * ordinary stream, the way a teammate's would.
52
+ */
53
+ commitBatch(options: CommitCreateOptions): Promise<CommitReceipt>;
42
54
  createClaim(options: {
43
55
  /**
44
56
  * The locator, in the spelling the SDK surface and the HTTP routes use.
@@ -65,7 +77,8 @@ export interface ModelCollaboration {
65
77
  /** Request-scoped queued / granted / skipped / failed status events. */
66
78
  onStatus?: (event: ClaimAttemptEvent) => void;
67
79
  }): Promise<Claim>;
68
- createSnapshot(modelKey: string, id: string): Snapshot;
80
+ /** Current applied/acked watermark, captured after a claim's fresh read. */
81
+ currentReadAt(): number;
69
82
  /**
70
83
  * Current coordination state on a target — who (if anyone) holds it.
71
84
  * Synchronous reactive snapshot read off the presence/claim stream;
@@ -133,7 +146,7 @@ export interface ModelCollaboration {
133
146
  * Opens a presence and claim subscription on this model's sync group(s) and
134
147
  * returns the live participant handle. Backs `ablo.<model>.join(ids)`.
135
148
  * WebSocket only, since presence needs a live socket; it is absent on other
136
- * client constructions, where the proxy throws a clear error.
149
+ * client constructions, where the surface throws a clear error.
137
150
  */
138
151
  createJoin?(modelKey: string, ids: string | readonly string[], options?: JoinOptions): Promise<JoinedParticipant>;
139
152
  }
@@ -142,7 +155,7 @@ export interface ModelCollaboration {
142
155
  *
143
156
  * Every verb mirrors its asynchronous sibling on the base surface, and the one
144
157
  * word in front is the whole difference. It is a narrowing, not a claim about
145
- * the other side: `get` consults the local graph and then the network,
158
+ * the other side: `read` consults the local graph and then the network,
146
159
  * while `local.get` is restricted to what is already resident — which is
147
160
  * also why it can return a value instead of a promise. There is nothing to
148
161
  * await.
@@ -241,7 +254,7 @@ interface ReactiveModelSurface<T, Fields = T> {
241
254
  * See {@link ReactiveModelSurface}.
242
255
  */
243
256
  export type ModelOperations<T, CreateInput> = Omit<HttpModelClient<T, CreateInput>, 'claim'> & ReactiveModelSurface<T, CreateInput>;
244
- export declare function createModelProxy<T, C>(schemaKey: string, registeredModelName: string, objectPool: Pick<InstanceCache, 'get' | 'getByType' | 'getOfType'>, syncClient: Pick<SyncClient, 'add' | 'delete' | 'getMutationQueue' | 'getOrganizationId' | 'syncNow' | 'update' | 'waitForConfirmation'>, registry: Pick<ModelRegistry, 'getModelByName'>,
257
+ export declare function createModelOperations<T, C>(schemaKey: string, registeredModelName: string, objectPool: Pick<InstanceCache, 'get' | 'getByType' | 'getOfType'>, syncClient: Pick<SyncClient, 'add' | 'delete' | 'getOrganizationId' | 'syncNow' | 'update' | 'waitForConfirmation'>, registry: Pick<ModelRegistry, 'getModelByName'>,
245
258
  /**
246
259
  * The one thing this factory asks of the loader: fetch rows for a model.
247
260
  *