@abloatai/ablo 0.28.0 → 0.29.1

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 (96) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/Database.js +9 -6
  3. package/dist/SyncClient.d.ts +2 -2
  4. package/dist/SyncClient.js +22 -10
  5. package/dist/adapters/inMemoryStorage.js +18 -14
  6. package/dist/ai-sdk/coordinatedTool.d.ts +15 -2
  7. package/dist/auth/schemas.d.ts +6 -0
  8. package/dist/auth/schemas.js +7 -0
  9. package/dist/cli.cjs +815 -400
  10. package/dist/client/Ablo.d.ts +29 -23
  11. package/dist/client/Ablo.js +8 -196
  12. package/dist/client/claimHeartbeatLoop.d.ts +1 -1
  13. package/dist/client/claimHeartbeatLoop.js +1 -1
  14. package/dist/client/createInternalComponents.d.ts +4 -2
  15. package/dist/client/createInternalComponents.js +3 -1
  16. package/dist/client/durableWrites.d.ts +21 -0
  17. package/dist/client/durableWrites.js +46 -0
  18. package/dist/client/httpClient.d.ts +19 -45
  19. package/dist/client/httpClient.js +104 -26
  20. package/dist/client/httpTransport.d.ts +8 -0
  21. package/dist/client/{ApiClient.js → httpTransport.js} +78 -291
  22. package/dist/client/options.d.ts +43 -19
  23. package/dist/client/options.js +3 -2
  24. package/dist/client/resourceTypes.d.ts +9 -85
  25. package/dist/client/resourceTypes.js +1 -1
  26. package/dist/client/sessionMint.d.ts +5 -6
  27. package/dist/client/sessionMint.js +4 -5
  28. package/dist/client/validateAbloOptions.js +3 -3
  29. package/dist/coordination/schema.d.ts +30 -0
  30. package/dist/coordination/schema.js +14 -0
  31. package/dist/core/index.d.ts +1 -1
  32. package/dist/errors.d.ts +4 -40
  33. package/dist/errors.js +5 -5
  34. package/dist/index.d.ts +14 -8
  35. package/dist/index.js +7 -5
  36. package/dist/interfaces/index.d.ts +3 -0
  37. package/dist/mutators/defineMutators.d.ts +18 -0
  38. package/dist/mutators/defineMutators.js +4 -8
  39. package/dist/react/index.d.ts +1 -1
  40. package/dist/schema/index.d.ts +1 -1
  41. package/dist/schema/index.js +1 -1
  42. package/dist/schema/select.d.ts +15 -0
  43. package/dist/schema/select.js +27 -3
  44. package/dist/source/connector.d.ts +3 -3
  45. package/dist/source/factory.d.ts +4 -6
  46. package/dist/source/factory.js +4 -7
  47. package/dist/source/index.d.ts +4 -4
  48. package/dist/source/index.js +2 -2
  49. package/dist/source/signing.d.ts +0 -3
  50. package/dist/source/types.d.ts +0 -26
  51. package/dist/stores/ObjectStore.js +8 -8
  52. package/dist/surface.d.ts +1 -1
  53. package/dist/surface.js +1 -0
  54. package/dist/sync/BootstrapFetcher.d.ts +10 -0
  55. package/dist/sync/BootstrapFetcher.js +27 -4
  56. package/dist/sync/createClaimStream.d.ts +11 -2
  57. package/dist/sync/createClaimStream.js +4 -3
  58. package/dist/testing/mocks/FakeDatabase.d.ts +1 -1
  59. package/dist/transactions/TransactionQueue.d.ts +2 -2
  60. package/dist/transactions/TransactionQueue.js +3 -3
  61. package/dist/transactions/commitEnvelope.d.ts +1 -1
  62. package/dist/transactions/commitEnvelope.js +2 -2
  63. package/dist/transactions/commitOutboxStore.d.ts +19 -19
  64. package/dist/transactions/durableWriteStore.d.ts +123 -0
  65. package/dist/transactions/durableWriteStore.js +30 -0
  66. package/dist/transactions/httpCommitEnvelope.d.ts +1 -0
  67. package/dist/transactions/httpCommitEnvelope.js +14 -12
  68. package/dist/transactions/idempotencyKey.d.ts +10 -0
  69. package/dist/transactions/idempotencyKey.js +9 -0
  70. package/dist/types/global.d.ts +10 -29
  71. package/dist/types/global.js +4 -7
  72. package/dist/types/streams.d.ts +2 -28
  73. package/dist/wire/frames.d.ts +6 -257
  74. package/dist/wire/frames.js +4 -25
  75. package/dist/wire/index.d.ts +4 -3
  76. package/dist/wire/index.js +2 -2
  77. package/dist/wire/protocolVersion.d.ts +30 -17
  78. package/dist/wire/protocolVersion.js +34 -18
  79. package/docs/agents.md +8 -3
  80. package/docs/api.md +6 -4
  81. package/docs/client-behavior.md +6 -3
  82. package/docs/coordination.md +2 -3
  83. package/docs/data-sources.md +5 -8
  84. package/docs/guarantees.md +21 -0
  85. package/docs/integration-guide.md +1 -0
  86. package/docs/migration.md +21 -1
  87. package/docs/quickstart.md +11 -0
  88. package/docs/react.md +0 -46
  89. package/examples/README.md +6 -5
  90. package/llms.txt +15 -15
  91. package/package.json +2 -7
  92. package/dist/client/ApiClient.d.ts +0 -177
  93. package/dist/commit/contract.d.ts +0 -493
  94. package/dist/commit/contract.js +0 -187
  95. package/dist/commit/index.d.ts +0 -6
  96. package/dist/commit/index.js +0 -5
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * The write-path message shapes for the sync protocol. These cover the frames
3
- * a client sends to commit work — {@link CommitMessage} (a batch of raw
4
- * operations) and {@link MutationMessage} (a single named mutation) — and the
5
- * server's {@link MutationResultMessage} acknowledgement. The same frames flow
6
- * over a WebSocket connection and over the HTTP commit endpoint.
3
+ * a client sends to commit work — {@link CommitMessage}, a batch of raw
4
+ * operations and the server's {@link MutationResultMessage}
5
+ * acknowledgement. The same frames flow over a WebSocket connection and over
6
+ * the HTTP commit endpoint.
7
7
  *
8
8
  * Both the client and the server import these definitions from here, so the two
9
9
  * sides cannot drift. Each interface is paired with a Zod validator
@@ -85,25 +85,10 @@ export declare const commitOperationSchema: z.ZodObject<{
85
85
  transactionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
86
86
  bypass: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
87
87
  }, z.core.$strip>;
88
- /**
89
- * A client-to-server frame that invokes a single named mutation by name and
90
- * arguments, as opposed to the raw operation batch in {@link CommitMessage}.
91
- * The server resolves `mutatorName` against the set of mutations registered on
92
- * it and runs the matching one.
93
- */
94
- export interface MutationMessage {
95
- type: 'mutation';
96
- payload: {
97
- mutatorName: string;
98
- input: unknown;
99
- clientTxId: string;
100
- };
101
- }
102
88
  /**
103
89
  * A client-to-server frame that asks the server to commit a batch of operations
104
- * atomically. This is the raw-operation counterpart to {@link MutationMessage};
105
- * it carries a list of {@link CommitOperation} entries plus the batch metadata
106
- * below.
90
+ * atomically. It carries a list of {@link CommitOperation} entries plus the
91
+ * batch metadata below.
107
92
  */
108
93
  export interface CommitMessage {
109
94
  type: 'commit';
@@ -222,239 +207,3 @@ export interface MutationResultMessage {
222
207
  };
223
208
  };
224
209
  }
225
- /**
226
- * A transport frame carrying the Zod-first v2 commit request. The payload's
227
- * `schemaVersion` distinguishes it from the legacy `commit` payload during the
228
- * migration window; the transport does not duplicate the commit contract.
229
- */
230
- export declare const commitRequestMessageSchema: z.ZodObject<{
231
- type: z.ZodLiteral<"commit">;
232
- payload: z.ZodObject<{
233
- idempotencyKey: z.core.$ZodBranded<z.ZodString, "IdempotencyKey", "out">;
234
- schemaVersion: z.ZodLiteral<2>;
235
- operations: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
236
- type: z.ZodLiteral<"create">;
237
- value: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
238
- operationId: z.core.$ZodBranded<z.ZodString, "OperationId", "out">;
239
- target: z.ZodObject<{
240
- model: z.ZodString;
241
- id: z.ZodString;
242
- }, z.core.$strict>;
243
- preconditions: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
244
- type: z.ZodLiteral<"unchanged_since">;
245
- cursor: z.core.$ZodBranded<z.ZodString, "SyncOffset", "out">;
246
- fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
247
- }, z.core.$strict>, z.ZodObject<{
248
- type: z.ZodLiteral<"version_matches">;
249
- version: z.ZodNumber;
250
- }, z.core.$strict>, z.ZodObject<{
251
- type: z.ZodLiteral<"claim_fence">;
252
- claimId: z.core.$ZodBranded<z.ZodString, "ClaimId", "out">;
253
- generation: z.ZodNumber;
254
- }, z.core.$strict>], "type">>>;
255
- }, z.core.$strict>, z.ZodObject<{
256
- type: z.ZodLiteral<"patch">;
257
- changes: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
258
- operationId: z.core.$ZodBranded<z.ZodString, "OperationId", "out">;
259
- target: z.ZodObject<{
260
- model: z.ZodString;
261
- id: z.ZodString;
262
- }, z.core.$strict>;
263
- preconditions: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
264
- type: z.ZodLiteral<"unchanged_since">;
265
- cursor: z.core.$ZodBranded<z.ZodString, "SyncOffset", "out">;
266
- fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
267
- }, z.core.$strict>, z.ZodObject<{
268
- type: z.ZodLiteral<"version_matches">;
269
- version: z.ZodNumber;
270
- }, z.core.$strict>, z.ZodObject<{
271
- type: z.ZodLiteral<"claim_fence">;
272
- claimId: z.core.$ZodBranded<z.ZodString, "ClaimId", "out">;
273
- generation: z.ZodNumber;
274
- }, z.core.$strict>], "type">>>;
275
- }, z.core.$strict>, z.ZodObject<{
276
- type: z.ZodLiteral<"delete">;
277
- operationId: z.core.$ZodBranded<z.ZodString, "OperationId", "out">;
278
- target: z.ZodObject<{
279
- model: z.ZodString;
280
- id: z.ZodString;
281
- }, z.core.$strict>;
282
- preconditions: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
283
- type: z.ZodLiteral<"unchanged_since">;
284
- cursor: z.core.$ZodBranded<z.ZodString, "SyncOffset", "out">;
285
- fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
286
- }, z.core.$strict>, z.ZodObject<{
287
- type: z.ZodLiteral<"version_matches">;
288
- version: z.ZodNumber;
289
- }, z.core.$strict>, z.ZodObject<{
290
- type: z.ZodLiteral<"claim_fence">;
291
- claimId: z.core.$ZodBranded<z.ZodString, "ClaimId", "out">;
292
- generation: z.ZodNumber;
293
- }, z.core.$strict>], "type">>>;
294
- }, z.core.$strict>, z.ZodObject<{
295
- type: z.ZodLiteral<"archive">;
296
- operationId: z.core.$ZodBranded<z.ZodString, "OperationId", "out">;
297
- target: z.ZodObject<{
298
- model: z.ZodString;
299
- id: z.ZodString;
300
- }, z.core.$strict>;
301
- preconditions: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
302
- type: z.ZodLiteral<"unchanged_since">;
303
- cursor: z.core.$ZodBranded<z.ZodString, "SyncOffset", "out">;
304
- fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
305
- }, z.core.$strict>, z.ZodObject<{
306
- type: z.ZodLiteral<"version_matches">;
307
- version: z.ZodNumber;
308
- }, z.core.$strict>, z.ZodObject<{
309
- type: z.ZodLiteral<"claim_fence">;
310
- claimId: z.core.$ZodBranded<z.ZodString, "ClaimId", "out">;
311
- generation: z.ZodNumber;
312
- }, z.core.$strict>], "type">>>;
313
- }, z.core.$strict>, z.ZodObject<{
314
- type: z.ZodLiteral<"unarchive">;
315
- operationId: z.core.$ZodBranded<z.ZodString, "OperationId", "out">;
316
- target: z.ZodObject<{
317
- model: z.ZodString;
318
- id: z.ZodString;
319
- }, z.core.$strict>;
320
- preconditions: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
321
- type: z.ZodLiteral<"unchanged_since">;
322
- cursor: z.core.$ZodBranded<z.ZodString, "SyncOffset", "out">;
323
- fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
324
- }, z.core.$strict>, z.ZodObject<{
325
- type: z.ZodLiteral<"version_matches">;
326
- version: z.ZodNumber;
327
- }, z.core.$strict>, z.ZodObject<{
328
- type: z.ZodLiteral<"claim_fence">;
329
- claimId: z.core.$ZodBranded<z.ZodString, "ClaimId", "out">;
330
- generation: z.ZodNumber;
331
- }, z.core.$strict>], "type">>>;
332
- }, z.core.$strict>], "type">>;
333
- metadata: z.ZodOptional<z.ZodObject<{
334
- label: z.ZodOptional<z.ZodString>;
335
- causedByTaskId: z.ZodOptional<z.ZodString>;
336
- }, z.core.$strict>>;
337
- }, z.core.$strict>;
338
- }, z.core.$strict>;
339
- export type CommitRequestMessage = z.output<typeof commitRequestMessageSchema>;
340
- /** A transport frame carrying one terminal, status-discriminated v2 receipt. */
341
- export declare const commitResultMessageSchema: z.ZodObject<{
342
- type: z.ZodLiteral<"commit_result">;
343
- payload: z.ZodDiscriminatedUnion<[z.ZodObject<{
344
- status: z.ZodLiteral<"committed">;
345
- syncCursor: z.core.$ZodBranded<z.ZodString, "SyncCursor", "out">;
346
- operationCount: z.ZodNumber;
347
- object: z.ZodLiteral<"commit_receipt">;
348
- schemaVersion: z.ZodLiteral<2>;
349
- idempotencyKey: z.core.$ZodBranded<z.ZodString, "IdempotencyKey", "out">;
350
- commitId: z.core.$ZodBranded<z.ZodUUID, "CommitId", "out">;
351
- }, z.core.$strict>, z.ZodObject<{
352
- status: z.ZodLiteral<"conflicted">;
353
- syncCursor: z.core.$ZodBranded<z.ZodString, "SyncCursor", "out">;
354
- conflicts: z.ZodArray<z.ZodObject<{
355
- operationId: z.core.$ZodBranded<z.ZodString, "OperationId", "out">;
356
- target: z.ZodObject<{
357
- model: z.ZodString;
358
- id: z.ZodString;
359
- }, z.core.$strict>;
360
- fields: z.ZodArray<z.ZodString>;
361
- currentValues: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
362
- observedAt: z.core.$ZodBranded<z.ZodString, "SyncOffset", "out">;
363
- }, z.core.$strict>>;
364
- object: z.ZodLiteral<"commit_receipt">;
365
- schemaVersion: z.ZodLiteral<2>;
366
- idempotencyKey: z.core.$ZodBranded<z.ZodString, "IdempotencyKey", "out">;
367
- commitId: z.core.$ZodBranded<z.ZodUUID, "CommitId", "out">;
368
- }, z.core.$strict>, z.ZodObject<{
369
- status: z.ZodLiteral<"rejected">;
370
- error: z.ZodObject<{
371
- code: z.ZodUnion<readonly [z.ZodEnum<{}>, z.ZodCustom<`policy:${string}`, `policy:${string}`>]>;
372
- message: z.ZodString;
373
- field: z.ZodOptional<z.ZodString>;
374
- requiredCapability: z.ZodOptional<z.ZodObject<{
375
- scope: z.ZodString;
376
- constraints: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>>;
377
- issuer: z.ZodOptional<z.ZodString>;
378
- ttlSeconds: z.ZodOptional<z.ZodNumber>;
379
- nonce: z.ZodOptional<z.ZodString>;
380
- }, z.core.$strict>>;
381
- details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
382
- }, z.core.$strict>;
383
- object: z.ZodLiteral<"commit_receipt">;
384
- schemaVersion: z.ZodLiteral<2>;
385
- idempotencyKey: z.core.$ZodBranded<z.ZodString, "IdempotencyKey", "out">;
386
- commitId: z.core.$ZodBranded<z.ZodUUID, "CommitId", "out">;
387
- }, z.core.$strict>], "status">;
388
- }, z.core.$strict>;
389
- export type CommitResultMessage = z.output<typeof commitResultMessageSchema>;
390
- /** Explicit compatibility name for the v1 uppercase operation schema. */
391
- export declare const legacyCommitOperationSchema: z.ZodObject<{
392
- readAt: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
393
- onStale: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
394
- reject: "reject";
395
- overwrite: "overwrite";
396
- notify: "notify";
397
- }>>>;
398
- type: z.ZodEnum<{
399
- CREATE: "CREATE";
400
- UPDATE: "UPDATE";
401
- DELETE: "DELETE";
402
- ARCHIVE: "ARCHIVE";
403
- UNARCHIVE: "UNARCHIVE";
404
- }>;
405
- model: z.ZodString;
406
- id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
407
- input: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
408
- transactionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
409
- bypass: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
410
- }, z.core.$strip>;
411
- /** Explicit compatibility name for the v1 `clientTxId` payload schema. */
412
- export declare const legacyCommitPayloadSchema: z.ZodObject<{
413
- operations: z.ZodArray<z.ZodObject<{
414
- readAt: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
415
- onStale: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
416
- reject: "reject";
417
- overwrite: "overwrite";
418
- notify: "notify";
419
- }>>>;
420
- type: z.ZodEnum<{
421
- CREATE: "CREATE";
422
- UPDATE: "UPDATE";
423
- DELETE: "DELETE";
424
- ARCHIVE: "ARCHIVE";
425
- UNARCHIVE: "UNARCHIVE";
426
- }>;
427
- model: z.ZodString;
428
- id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
429
- input: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
430
- transactionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
431
- bypass: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
432
- }, z.core.$strip>>;
433
- clientTxId: z.ZodString;
434
- causedByTaskId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
435
- reads: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
436
- model: z.ZodString;
437
- id: z.ZodString;
438
- readAt: z.ZodNumber;
439
- fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
440
- onStale: z.ZodOptional<z.ZodEnum<{
441
- reject: "reject";
442
- overwrite: "overwrite";
443
- notify: "notify";
444
- }>>;
445
- }, z.core.$strip>, z.ZodObject<{
446
- group: z.ZodString;
447
- readAt: z.ZodNumber;
448
- onStale: z.ZodOptional<z.ZodEnum<{
449
- reject: "reject";
450
- overwrite: "overwrite";
451
- notify: "notify";
452
- }>>;
453
- }, z.core.$strip>]>>>>;
454
- }, z.core.$strip>;
455
- /** Explicit compatibility alias for the v1 uppercase operation shape. */
456
- export type LegacyCommitOperation = CommitOperation;
457
- /** Explicit compatibility alias for the v1 `clientTxId` commit frame. */
458
- export type LegacyCommitMessage = CommitMessage;
459
- /** Explicit compatibility alias for the v1 boolean-style mutation receipt. */
460
- export type LegacyMutationResultMessage = MutationResultMessage;
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * The write-path message shapes for the sync protocol. These cover the frames
3
- * a client sends to commit work — {@link CommitMessage} (a batch of raw
4
- * operations) and {@link MutationMessage} (a single named mutation) — and the
5
- * server's {@link MutationResultMessage} acknowledgement. The same frames flow
6
- * over a WebSocket connection and over the HTTP commit endpoint.
3
+ * a client sends to commit work — {@link CommitMessage}, a batch of raw
4
+ * operations and the server's {@link MutationResultMessage}
5
+ * acknowledgement. The same frames flow over a WebSocket connection and over
6
+ * the HTTP commit endpoint.
7
7
  *
8
8
  * Both the client and the server import these definitions from here, so the two
9
9
  * sides cannot drift. Each interface is paired with a Zod validator
@@ -16,7 +16,6 @@ import { z } from 'zod';
16
16
  // The runtime schema primitives are imported straight from the coordination
17
17
  // schema module to keep this file's runtime dependencies limited to Zod.
18
18
  import { commitOperationSchema as coordinationCommitOperationSchema, readDependencySchema, } from '../coordination/schema.js';
19
- import { commitReceiptSchema as commitReceiptV2Schema, commitRequestSchema as commitRequestV2Schema, } from '../commit/contract.js';
20
19
  /**
21
20
  * Runtime validator for {@link CommitOperation}. Both commit transports — the
22
21
  * WebSocket `commit` frame and the HTTP `/v1/commits` endpoint — run this check
@@ -47,23 +46,3 @@ export const commitPayloadSchema = z.object({
47
46
  // Pins the schema to the payload type: fails to compile if either side drifts.
48
47
  const _commitPayloadContract = true;
49
48
  void _commitPayloadContract;
50
- // ── Commit contract v2 ───────────────────────────────────────────────────
51
- /**
52
- * A transport frame carrying the Zod-first v2 commit request. The payload's
53
- * `schemaVersion` distinguishes it from the legacy `commit` payload during the
54
- * migration window; the transport does not duplicate the commit contract.
55
- */
56
- export const commitRequestMessageSchema = z.strictObject({
57
- type: z.literal('commit'),
58
- payload: commitRequestV2Schema,
59
- });
60
- /** A transport frame carrying one terminal, status-discriminated v2 receipt. */
61
- export const commitResultMessageSchema = z.strictObject({
62
- type: z.literal('commit_result'),
63
- payload: commitReceiptV2Schema,
64
- });
65
- // ── Explicit v1 compatibility names ─────────────────────────────────────
66
- /** Explicit compatibility name for the v1 uppercase operation schema. */
67
- export const legacyCommitOperationSchema = commitOperationSchema;
68
- /** Explicit compatibility name for the v1 `clientTxId` payload schema. */
69
- export const legacyCommitPayloadSchema = commitPayloadSchema;
@@ -21,9 +21,10 @@ export { listEnvelope } from './listEnvelope.js';
21
21
  export type { ListEnvelope } from './listEnvelope.js';
22
22
  export { bootstrapReasonSchema } from './bootstrapReason.js';
23
23
  export type { BootstrapReason } from './bootstrapReason.js';
24
- export { commitOperationSchema, commitPayloadSchema, commitRequestMessageSchema, commitResultMessageSchema, legacyCommitOperationSchema, legacyCommitPayloadSchema, } from './frames.js';
25
- export { PROTOCOL_VERSION, MIN_SUPPORTED_PROTOCOL_VERSION, WS_CLOSE_PROTOCOL_VERSION, PROTOCOL_VERSION_HEADER, protocolVersionProblem, } from './protocolVersion.js';
26
- export type { CommitOperation, MutationMessage, CommitMessage, MutationResultMessage, CommitRequestMessage, CommitResultMessage, LegacyCommitOperation, LegacyCommitMessage, LegacyMutationResultMessage, } from './frames.js';
24
+ export { commitOperationSchema, commitPayloadSchema, } from './frames.js';
25
+ export { PROTOCOL_VERSION, MIN_SUPPORTED_PROTOCOL_VERSION, DEFAULT_PROTOCOL_VERSION, SUPPORTED_PROTOCOL_VERSIONS, WS_CLOSE_PROTOCOL_VERSION, PROTOCOL_VERSION_HEADER, protocolVersionProblem, resolveProtocolVersion, } from './protocolVersion.js';
26
+ export type { SupportedProtocolVersion, ProtocolVersionProblem, } from './protocolVersion.js';
27
+ export type { CommitOperation, CommitMessage, MutationResultMessage, } from './frames.js';
27
28
  export { participantKindSchema, confirmationStateSchema, syncDeltaActionSchema, wireDeltaDataSchema, participantRefSchema, syncDeltaWireCoreSchema, clientSyncDeltaSchema, serverSyncDeltaSchema, } from './delta.js';
28
29
  export type { ParticipantKind, ConfirmationState, SyncDeltaAction, WireDeltaData, ParticipantRef, SyncDeltaWireCore, ClientSyncDelta, ServerSyncDelta, } from './delta.js';
29
30
  export { AbloError, AbloAuthenticationError, AbloPermissionError, AbloValidationError, AbloRateLimitError, AbloIdempotencyError, AbloConnectionError, AbloServerError, AbloStaleContextError, AbloClaimedError, CapabilityError, SyncSessionError, docUrlForCode, translateHttpError, errorFromWire, toAbloError, ERROR_CONTRACT_VERSION, errorCodeSpec, } from '../errors.js';
@@ -22,11 +22,11 @@ export { bootstrapReasonSchema } from './bootstrapReason.js';
22
22
  // the server. The runtime Zod validators sit beside the interfaces and are
23
23
  // pinned to them, and they gate every operation and payload on both commit
24
24
  // transports.
25
- export { commitOperationSchema, commitPayloadSchema, commitRequestMessageSchema, commitResultMessageSchema, legacyCommitOperationSchema, legacyCommitPayloadSchema, } from './frames.js';
25
+ export { commitOperationSchema, commitPayloadSchema, } from './frames.js';
26
26
  // Protocol versioning: the single integer the client and server compare to
27
27
  // confirm they can speak to each other, plus the WebSocket close code used to
28
28
  // reject a mismatch. See protocolVersion.ts for the changelog and deploy rules.
29
- export { PROTOCOL_VERSION, MIN_SUPPORTED_PROTOCOL_VERSION, WS_CLOSE_PROTOCOL_VERSION, PROTOCOL_VERSION_HEADER, protocolVersionProblem, } from './protocolVersion.js';
29
+ export { PROTOCOL_VERSION, MIN_SUPPORTED_PROTOCOL_VERSION, DEFAULT_PROTOCOL_VERSION, SUPPORTED_PROTOCOL_VERSIONS, WS_CLOSE_PROTOCOL_VERSION, PROTOCOL_VERSION_HEADER, protocolVersionProblem, resolveProtocolVersion, } from './protocolVersion.js';
30
30
  // The read-path delta contract: the shape the server broadcasts to clients as the
31
31
  // payload of a `delta` or `sync_response` frame, together with the shared
32
32
  // participant vocabulary it carries. Both ends derive their delta type from these
@@ -2,31 +2,30 @@
2
2
  * The sync protocol version — a single integer, increasing over time, that
3
3
  * covers everything the client and server must agree on to talk to each other:
4
4
  * the WebSocket frame shapes, the HTTP request and response envelopes, and the
5
- * delta encodings a client replays. It is separate from the app-schema hash
6
- * (WebSocket close code 4009), which detects drift in your data model; this
7
- * detects drift in the protocol itself.
5
+ * delta encodings a client replays. It is separate from the advisory
6
+ * app-schema hash, which diagnoses data-model drift; this version selects a
7
+ * concrete transport codec.
8
8
  *
9
9
  * Deploy ordering: the server is deployed first. It accepts every version in
10
- * the inclusive range from {@link MIN_SUPPORTED_PROTOCOL_VERSION} to
11
- * {@link PROTOCOL_VERSION}, and a client is never expected to connect to a
12
- * server older than itself. If that does happen for example a partial server
13
- * rollback {@link protocolVersionProblem} reports it as `too_new` so the
14
- * mismatch is visible rather than undefined.
10
+ * {@link SUPPORTED_PROTOCOL_VERSIONS}, and a client is never expected to connect
11
+ * to a server older than itself. If that does happen for example a partial
12
+ * server rollback {@link protocolVersionProblem} reports it as `too_new` so
13
+ * the mismatch is visible rather than undefined.
15
14
  *
16
15
  * To change the protocol:
17
16
  * 1. Make the change backward-tolerant where you can. The server ignores
18
17
  * unknown payload keys, so an additive field usually needs no version bump.
19
- * 2. For a breaking change, bump {@link PROTOCOL_VERSION}, add a changelog
20
- * entry below, and keep {@link MIN_SUPPORTED_PROTOCOL_VERSION} low enough
21
- * to cover every client still in use; raise it only after a deprecation
22
- * window.
23
- * 3. The protocol-version contract test fails on any bump update it in the
24
- * same change, deliberately.
18
+ * 2. For a breaking change, bump {@link PROTOCOL_VERSION}, add its codec to
19
+ * {@link SUPPORTED_PROTOCOL_VERSIONS}, and add a changelog entry below.
20
+ * 3. Keep {@link MIN_SUPPORTED_PROTOCOL_VERSION} low enough to cover every
21
+ * client still in use; raise it only after a deprecation window.
22
+ * 4. The protocol contract tests fail on a version without a codec and on any
23
+ * unreviewed bump — update them in the same change, deliberately.
25
24
  *
26
25
  * Changelog
27
26
  * v1 (2026-07-03) — the protocol as of this field's introduction: the
28
27
  * sync-request frame (`cursor`, `lastSyncId`, `capabilities`, optional
29
- * `protocolVersion`), the commit, mutation, claim, release, ack, and
28
+ * `protocolVersion`), the commit, claim, release, ack, and
30
29
  * presence-update frames, the bootstrap and delta batches, and the HTTP
31
30
  * error and list envelopes. A client that predates this field sends no
32
31
  * `protocolVersion` and is treated as v1, since introducing the field
@@ -39,10 +38,22 @@ export declare const PROTOCOL_VERSION = 1;
39
38
  * and with a changelog entry.
40
39
  */
41
40
  export declare const MIN_SUPPORTED_PROTOCOL_VERSION = 1;
41
+ /** The version used by clients from before the version field existed. */
42
+ export declare const DEFAULT_PROTOCOL_VERSION = 1;
43
+ /**
44
+ * Every wire version this build can actually decode. This is intentionally an
45
+ * explicit manifest rather than a computed numeric range: a version is not
46
+ * supported merely because its number falls between two constants. Server
47
+ * codec registries use {@link SupportedProtocolVersion} as their key type, so
48
+ * adding a version here makes a missing decoder a compile error.
49
+ */
50
+ export declare const SUPPORTED_PROTOCOL_VERSIONS: readonly [1];
51
+ export type SupportedProtocolVersion = (typeof SUPPORTED_PROTOCOL_VERSIONS)[number];
52
+ export type ProtocolVersionProblem = 'too_old' | 'too_new' | 'codec_missing';
42
53
  /**
43
54
  * The WebSocket close code the server sends to reject a protocol-version
44
55
  * mismatch. It sits alongside the other application close codes (4001 for a
45
- * credential problem, 4009 for app-schema drift), and its reason string is the
56
+ * credential problem), and its reason string is the
46
57
  * error code `protocol_version_unsupported`. A client should treat this close
47
58
  * as terminal: reconnecting cannot heal a version mismatch, but upgrading the
48
59
  * client or rolling the server forward can.
@@ -55,6 +66,8 @@ export declare const WS_CLOSE_PROTOCOL_VERSION = 4010;
55
66
  * — counts as v1. A non-integer value is treated as `'too_old'` so the check
56
67
  * fails closed and visibly.
57
68
  */
58
- export declare function protocolVersionProblem(announced: number | undefined): 'too_old' | 'too_new' | null;
69
+ export declare function protocolVersionProblem(announced: number | undefined): ProtocolVersionProblem | null;
70
+ /** Resolve an announced value to a version that has a concrete codec. */
71
+ export declare function resolveProtocolVersion(announced: number | undefined): SupportedProtocolVersion | null;
59
72
  /** The HTTP request header a client uses to announce its protocol version. */
60
73
  export declare const PROTOCOL_VERSION_HEADER = "Ablo-Protocol-Version";
@@ -2,31 +2,30 @@
2
2
  * The sync protocol version — a single integer, increasing over time, that
3
3
  * covers everything the client and server must agree on to talk to each other:
4
4
  * the WebSocket frame shapes, the HTTP request and response envelopes, and the
5
- * delta encodings a client replays. It is separate from the app-schema hash
6
- * (WebSocket close code 4009), which detects drift in your data model; this
7
- * detects drift in the protocol itself.
5
+ * delta encodings a client replays. It is separate from the advisory
6
+ * app-schema hash, which diagnoses data-model drift; this version selects a
7
+ * concrete transport codec.
8
8
  *
9
9
  * Deploy ordering: the server is deployed first. It accepts every version in
10
- * the inclusive range from {@link MIN_SUPPORTED_PROTOCOL_VERSION} to
11
- * {@link PROTOCOL_VERSION}, and a client is never expected to connect to a
12
- * server older than itself. If that does happen for example a partial server
13
- * rollback {@link protocolVersionProblem} reports it as `too_new` so the
14
- * mismatch is visible rather than undefined.
10
+ * {@link SUPPORTED_PROTOCOL_VERSIONS}, and a client is never expected to connect
11
+ * to a server older than itself. If that does happen for example a partial
12
+ * server rollback {@link protocolVersionProblem} reports it as `too_new` so
13
+ * the mismatch is visible rather than undefined.
15
14
  *
16
15
  * To change the protocol:
17
16
  * 1. Make the change backward-tolerant where you can. The server ignores
18
17
  * unknown payload keys, so an additive field usually needs no version bump.
19
- * 2. For a breaking change, bump {@link PROTOCOL_VERSION}, add a changelog
20
- * entry below, and keep {@link MIN_SUPPORTED_PROTOCOL_VERSION} low enough
21
- * to cover every client still in use; raise it only after a deprecation
22
- * window.
23
- * 3. The protocol-version contract test fails on any bump update it in the
24
- * same change, deliberately.
18
+ * 2. For a breaking change, bump {@link PROTOCOL_VERSION}, add its codec to
19
+ * {@link SUPPORTED_PROTOCOL_VERSIONS}, and add a changelog entry below.
20
+ * 3. Keep {@link MIN_SUPPORTED_PROTOCOL_VERSION} low enough to cover every
21
+ * client still in use; raise it only after a deprecation window.
22
+ * 4. The protocol contract tests fail on a version without a codec and on any
23
+ * unreviewed bump — update them in the same change, deliberately.
25
24
  *
26
25
  * Changelog
27
26
  * v1 (2026-07-03) — the protocol as of this field's introduction: the
28
27
  * sync-request frame (`cursor`, `lastSyncId`, `capabilities`, optional
29
- * `protocolVersion`), the commit, mutation, claim, release, ack, and
28
+ * `protocolVersion`), the commit, claim, release, ack, and
30
29
  * presence-update frames, the bootstrap and delta batches, and the HTTP
31
30
  * error and list envelopes. A client that predates this field sends no
32
31
  * `protocolVersion` and is treated as v1, since introducing the field
@@ -39,10 +38,20 @@ export const PROTOCOL_VERSION = 1;
39
38
  * and with a changelog entry.
40
39
  */
41
40
  export const MIN_SUPPORTED_PROTOCOL_VERSION = 1;
41
+ /** The version used by clients from before the version field existed. */
42
+ export const DEFAULT_PROTOCOL_VERSION = 1;
43
+ /**
44
+ * Every wire version this build can actually decode. This is intentionally an
45
+ * explicit manifest rather than a computed numeric range: a version is not
46
+ * supported merely because its number falls between two constants. Server
47
+ * codec registries use {@link SupportedProtocolVersion} as their key type, so
48
+ * adding a version here makes a missing decoder a compile error.
49
+ */
50
+ export const SUPPORTED_PROTOCOL_VERSIONS = [1];
42
51
  /**
43
52
  * The WebSocket close code the server sends to reject a protocol-version
44
53
  * mismatch. It sits alongside the other application close codes (4001 for a
45
- * credential problem, 4009 for app-schema drift), and its reason string is the
54
+ * credential problem), and its reason string is the
46
55
  * error code `protocol_version_unsupported`. A client should treat this close
47
56
  * as terminal: reconnecting cannot heal a version mismatch, but upgrading the
48
57
  * client or rolling the server forward can.
@@ -56,12 +65,19 @@ export const WS_CLOSE_PROTOCOL_VERSION = 4010;
56
65
  * fails closed and visibly.
57
66
  */
58
67
  export function protocolVersionProblem(announced) {
59
- const v = announced ?? 1;
68
+ const v = announced ?? DEFAULT_PROTOCOL_VERSION;
60
69
  if (!Number.isInteger(v) || v < MIN_SUPPORTED_PROTOCOL_VERSION)
61
70
  return 'too_old';
62
71
  if (v > PROTOCOL_VERSION)
63
72
  return 'too_new';
64
- return null;
73
+ return SUPPORTED_PROTOCOL_VERSIONS.some((candidate) => candidate === v)
74
+ ? null
75
+ : 'codec_missing';
76
+ }
77
+ /** Resolve an announced value to a version that has a concrete codec. */
78
+ export function resolveProtocolVersion(announced) {
79
+ const version = announced ?? DEFAULT_PROTOCOL_VERSION;
80
+ return SUPPORTED_PROTOCOL_VERSIONS.find((candidate) => candidate === version) ?? null;
65
81
  }
66
82
  /** The HTTP request header a client uses to announce its protocol version. */
67
83
  export const PROTOCOL_VERSION_HEADER = 'Ablo-Protocol-Version';
package/docs/agents.md CHANGED
@@ -27,10 +27,15 @@ import { schema } from "./schema";
27
27
 
28
28
  const ablo = Ablo({ schema, apiKey: process.env.ABLO_API_KEY, transport: "http" });
29
29
 
30
- // Reads + writes, fully typed off your schema — each is one HTTP round-trip:
30
+ // Reads + writes, fully typed off your schema.
31
+ // `retrieve` resolves to the row, or `undefined` when none matches.
31
32
  const open = await ablo.tasks.list({ where: { status: "todo" } });
32
- const { data } = await ablo.tasks.retrieve({ id: open[0].id });
33
- await ablo.tasks.update({ id: open[0].id, data: { status: "done" } });
33
+
34
+ const task = await ablo.tasks.retrieve({ id: open[0].id });
35
+ if (!task) throw new Error("task not found");
36
+
37
+ console.log(task.title);
38
+ await ablo.tasks.update({ id: task.id, data: { status: "done" } });
34
39
  ```
35
40
 
36
41
  It exposes `retrieve` / `list` / `create` / `update` / `delete`, plus `commits`
package/docs/api.md CHANGED
@@ -221,10 +221,12 @@ endpoint documents that model's real field contract instead of a generic blob.
221
221
 
222
222
  Auth is a bearer API key: `Authorization: Bearer sk_…`. Mutations take an
223
223
  `Idempotency-Key` header — derive it from the business event, not a random
224
- value, so a retry never double-writes. Writes return a `CommitReceipt`; a
225
- rejected write carries an error `code` (e.g. `stale_context`, `intent_conflict`)
226
- to act on. `GET /api/v1/models/{model}` is cursor-paginated (`limit`, `order`,
227
- `order_by`, `starting_after`) and returns `{ data, has_more, next_cursor }`.
224
+ value, so a retry never double-writes. Direct HTTP writes return a protocol
225
+ receipt; the typed SDK turns single-model writes into their application result
226
+ (the created or updated row, or nothing for delete). A rejected write carries an
227
+ error `code` (e.g. `stale_context`, `intent_conflict`) to act on.
228
+ `GET /api/v1/models/{model}` is cursor-paginated (`limit`, `order`, `order_by`,
229
+ `starting_after`) and returns `{ data, has_more, next_cursor }`.
228
230
 
229
231
  `POST /api/v1/commits` remains the path for **atomic multi-op** writes (several
230
232
  operations across rows/models that must commit together) — the per-model routes
@@ -32,6 +32,7 @@ Common options:
32
32
  | `databaseUrl` | Optional, server-only. Registers your Postgres directly (the connection-string path). Pass it explicitly — it is **not** auto-read from the environment. Omit it for a signed Data Source endpoint or the hosted sandbox. The SDK throws if it sees this in a browser. |
33
33
  | `baseURL` | Override the hosted sync endpoint for staging or private deployments. |
34
34
  | `persistence` | `memory` by default. Use `indexeddb` for a durable browser cache that survives reloads. |
35
+ | `durableWrites` | Optional crash recovery for unacknowledged agent/worker writes. Independent of the default memory cache; accepts `{ store, namespace? }`. |
35
36
  | `transport` | `'websocket'` (default) is the live, stateful client — a persistent socket, a local synced pool, and `onChange` subscriptions. `'http'` returns the **stateless** client for server-side actors (agents, workers, serverless): the same `ablo.<model>` read/write/claim surface, but each call is one HTTP round-trip with no socket. Under `'http'` the return type narrows to `AbloHttpClient`, so stateful-only methods (`get`/`getAll`, `onChange`, `watch`) are compile errors rather than runtime gaps. |
36
37
  | `fetch` | Custom fetch implementation for tests or non-standard runtimes. |
37
38
  | `defaultHeaders` | Extra headers attached to every HTTP request. |
@@ -109,7 +110,6 @@ await ablo.weatherReports.update({
109
110
  readAt: snap.stamp,
110
111
  onStale: 'reject',
111
112
  idempotencyKey: 'report_stockholm:mark-ready:v1',
112
- timeout: 20_000,
113
113
  });
114
114
  ```
115
115
 
@@ -119,7 +119,6 @@ await ablo.weatherReports.update({
119
119
  | `readAt` | State cursor the write was based on. |
120
120
  | `onStale` | Policy when the target changed after `readAt`. Prefer `reject`. |
121
121
  | `idempotencyKey` | Stable key for retry-safe writes. The SDK generates one when omitted. |
122
- | `timeout` | Maximum time for the write call. |
123
122
 
124
123
  ## Claimed Behavior
125
124
 
@@ -136,7 +135,11 @@ if (active) {
136
135
  }
137
136
 
138
137
  const handle = await ablo.weatherReports.claim({ id: 'report_stockholm' });
139
- await ablo.weatherReports.update({ id: handle.data.id, data: { status: 'ready' } });
138
+ await ablo.weatherReports.update({
139
+ id: handle.data.id,
140
+ data: { status: 'ready' },
141
+ claim: handle,
142
+ });
140
143
  await handle.release();
141
144
  ```
142
145
 
@@ -631,9 +631,8 @@ guarantee can't drift): read the freshest row + its watermark → run your updat
631
631
  comes from the watermark, **not** from participant identity — so it's immune to
632
632
  the shared-credential clobber footgun and needs no `claim` and no per-agent `rk_`.
633
633
 
634
- Nothing about claims, identity, or conflict codes surfaces. The call either
635
- returns the reconciled row (a `CommitReceipt` on the HTTP client; the row on the
636
- WebSocket client) or, at the extreme, throws **one** error:
634
+ Nothing about claims, identity, or conflict codes surfaces. On both transports,
635
+ the call returns the reconciled row or, at the extreme, throws **one** error:
637
636
 
638
637
  ```ts
639
638
  import { AbloContentionError } from '@abloatai/ablo';
@@ -180,14 +180,11 @@ database, schema — the connection string itself is sealed and never echoed bac
180
180
  the replication slot position, and the commit log that drives sync. Never your
181
181
  rows.
182
182
 
183
- > **Logical-replication runtime status: Preview.** The setup path above
184
- > (`ablo connect` and `ablo connect --check`) is real and shipping. The
185
- > server-side component that consumes your WAL and turns it into sync deltas is in
186
- > **Preview** — it is implemented and tested but **not yet GA / boot-wired in the
187
- > hosted runtime**. Treat WAL consumption as not-yet-deployed until this note is
188
- > removed. Maintainers: see
189
- > [internal/byo-wal-consumer.md](./internal/byo-wal-consumer.md) for the
190
- > architecture and remaining slices.
183
+ > **Postgres replication status: Preview.** Registration, readiness checks, and
184
+ > the server replication fleet are implemented and boot-wired. Preview describes
185
+ > product rollout and support, not an inactive code path. Maintainers: see
186
+ > [internal/postgres-replication.md](./internal/postgres-replication.md) for the
187
+ > architecture and operational invariants.
191
188
 
192
189
  ## Next steps
193
190