@abloatai/ablo 0.27.0 → 0.29.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 (126) hide show
  1. package/CHANGELOG.md +59 -3
  2. package/README.md +1 -1
  3. package/dist/BaseSyncedStore.js +8 -9
  4. package/dist/Database.d.ts +14 -1
  5. package/dist/Database.js +228 -28
  6. package/dist/Model.d.ts +17 -0
  7. package/dist/Model.js +32 -1
  8. package/dist/SyncClient.d.ts +10 -6
  9. package/dist/SyncClient.js +390 -75
  10. package/dist/adapters/inMemoryStorage.d.ts +1 -0
  11. package/dist/adapters/inMemoryStorage.js +29 -13
  12. package/dist/ai-sdk/coordinatedTool.d.ts +15 -2
  13. package/dist/auth/schemas.d.ts +6 -0
  14. package/dist/auth/schemas.js +7 -0
  15. package/dist/cli.cjs +821 -402
  16. package/dist/client/Ablo.d.ts +53 -24
  17. package/dist/client/Ablo.js +12 -199
  18. package/dist/client/claimHeartbeatLoop.d.ts +1 -1
  19. package/dist/client/claimHeartbeatLoop.js +1 -1
  20. package/dist/client/createInternalComponents.d.ts +4 -0
  21. package/dist/client/createInternalComponents.js +3 -1
  22. package/dist/client/durableWrites.d.ts +21 -0
  23. package/dist/client/durableWrites.js +46 -0
  24. package/dist/client/httpClient.d.ts +21 -45
  25. package/dist/client/httpClient.js +104 -26
  26. package/dist/client/httpTransport.d.ts +8 -0
  27. package/dist/client/{ApiClient.js → httpTransport.js} +361 -308
  28. package/dist/client/modelRegistration.js +11 -0
  29. package/dist/client/options.d.ts +54 -7
  30. package/dist/client/options.js +3 -2
  31. package/dist/client/resourceTypes.d.ts +9 -85
  32. package/dist/client/resourceTypes.js +1 -1
  33. package/dist/client/sessionMint.d.ts +5 -6
  34. package/dist/client/sessionMint.js +4 -5
  35. package/dist/client/validateAbloOptions.js +3 -3
  36. package/dist/client/wsMutationExecutor.d.ts +3 -2
  37. package/dist/client/wsMutationExecutor.js +3 -2
  38. package/dist/coordination/schema.d.ts +30 -0
  39. package/dist/coordination/schema.js +14 -0
  40. package/dist/core/StoreManager.d.ts +2 -0
  41. package/dist/core/StoreManager.js +12 -0
  42. package/dist/core/index.d.ts +1 -1
  43. package/dist/errorCodes.js +6 -2
  44. package/dist/errors.d.ts +4 -40
  45. package/dist/errors.js +5 -5
  46. package/dist/index.d.ts +20 -8
  47. package/dist/index.js +9 -5
  48. package/dist/interfaces/index.d.ts +5 -2
  49. package/dist/mutators/UndoManager.d.ts +2 -0
  50. package/dist/mutators/UndoManager.js +32 -0
  51. package/dist/mutators/defineMutators.d.ts +18 -0
  52. package/dist/mutators/defineMutators.js +4 -8
  53. package/dist/react/index.d.ts +1 -1
  54. package/dist/react/useAblo.d.ts +6 -4
  55. package/dist/react/useAblo.js +25 -3
  56. package/dist/schema/index.d.ts +2 -2
  57. package/dist/schema/index.js +1 -1
  58. package/dist/schema/schema.d.ts +31 -1
  59. package/dist/schema/select.d.ts +15 -0
  60. package/dist/schema/select.js +27 -3
  61. package/dist/source/connector.d.ts +3 -3
  62. package/dist/source/factory.d.ts +4 -6
  63. package/dist/source/factory.js +4 -7
  64. package/dist/source/index.d.ts +4 -4
  65. package/dist/source/index.js +2 -2
  66. package/dist/source/signing.d.ts +0 -3
  67. package/dist/source/types.d.ts +0 -26
  68. package/dist/stores/ObjectStore.d.ts +14 -1
  69. package/dist/stores/ObjectStore.js +33 -10
  70. package/dist/stores/ObjectStoreContract.d.ts +2 -0
  71. package/dist/surface.d.ts +1 -1
  72. package/dist/surface.js +3 -0
  73. package/dist/sync/BootstrapFetcher.d.ts +10 -0
  74. package/dist/sync/BootstrapFetcher.js +27 -4
  75. package/dist/sync/SyncWebSocket.d.ts +2 -1
  76. package/dist/sync/createClaimStream.d.ts +11 -2
  77. package/dist/sync/createClaimStream.js +4 -3
  78. package/dist/sync/persistedPrefix.d.ts +12 -0
  79. package/dist/sync/persistedPrefix.js +22 -0
  80. package/dist/testing/index.d.ts +2 -0
  81. package/dist/testing/index.js +1 -0
  82. package/dist/testing/mocks/FakeDatabase.d.ts +18 -0
  83. package/dist/testing/mocks/FakeDatabase.js +10 -0
  84. package/dist/testing/mocks/MockWebSocket.d.ts +2 -1
  85. package/dist/transactions/TransactionQueue.d.ts +66 -8
  86. package/dist/transactions/TransactionQueue.js +607 -89
  87. package/dist/transactions/commitEnvelope.d.ts +132 -0
  88. package/dist/transactions/commitEnvelope.js +139 -0
  89. package/dist/transactions/commitOutboxStore.d.ts +32 -0
  90. package/dist/transactions/commitOutboxStore.js +26 -0
  91. package/dist/transactions/commitPayload.d.ts +15 -0
  92. package/dist/transactions/commitPayload.js +6 -0
  93. package/dist/transactions/durableWriteStore.d.ts +123 -0
  94. package/dist/transactions/durableWriteStore.js +30 -0
  95. package/dist/transactions/httpCommitEnvelope.d.ts +44 -0
  96. package/dist/transactions/httpCommitEnvelope.js +181 -0
  97. package/dist/transactions/idempotencyKey.d.ts +10 -0
  98. package/dist/transactions/idempotencyKey.js +9 -0
  99. package/dist/transactions/replayValidation.d.ts +83 -0
  100. package/dist/transactions/replayValidation.js +46 -1
  101. package/dist/types/global.d.ts +10 -29
  102. package/dist/types/global.js +4 -7
  103. package/dist/types/streams.d.ts +2 -28
  104. package/dist/wire/bootstrapReason.d.ts +9 -0
  105. package/dist/wire/bootstrapReason.js +8 -0
  106. package/dist/wire/frames.d.ts +6 -21
  107. package/dist/wire/frames.js +4 -4
  108. package/dist/wire/index.d.ts +6 -3
  109. package/dist/wire/index.js +3 -2
  110. package/dist/wire/protocolVersion.d.ts +30 -17
  111. package/dist/wire/protocolVersion.js +34 -18
  112. package/docs/agents.md +8 -3
  113. package/docs/api.md +16 -14
  114. package/docs/client-behavior.md +6 -3
  115. package/docs/coordination.md +4 -5
  116. package/docs/data-sources.md +5 -8
  117. package/docs/guarantees.md +21 -0
  118. package/docs/integration-guide.md +1 -0
  119. package/docs/mcp.md +1 -1
  120. package/docs/migration.md +21 -1
  121. package/docs/quickstart.md +11 -0
  122. package/docs/react.md +0 -46
  123. package/examples/README.md +6 -5
  124. package/llms.txt +15 -15
  125. package/package.json +3 -3
  126. package/dist/client/ApiClient.d.ts +0 -177
@@ -22,10 +22,23 @@ export class InMemoryObjectStore {
22
22
  this.indexes.set(name, new Map());
23
23
  }
24
24
  }
25
- async put(record) {
25
+ add(record) {
26
26
  const id = record.id;
27
27
  if (!id)
28
- return;
28
+ throw new TypeError('In-memory record must carry an id');
29
+ if (this.data.has(id)) {
30
+ const error = new Error(`Record already exists: ${id}`);
31
+ error.name = 'ConstraintError';
32
+ throw error;
33
+ }
34
+ this.data.set(id, { ...record });
35
+ this.addToIndexes(id, record);
36
+ return Promise.resolve();
37
+ }
38
+ put(record) {
39
+ const id = record.id;
40
+ if (!id)
41
+ return Promise.resolve();
29
42
  // Remove from old index entries if updating
30
43
  const existing = this.data.get(id);
31
44
  if (existing) {
@@ -33,24 +46,26 @@ export class InMemoryObjectStore {
33
46
  }
34
47
  this.data.set(id, { ...record });
35
48
  this.addToIndexes(id, record);
49
+ return Promise.resolve();
36
50
  }
37
- async get(id) {
38
- return this.data.get(id);
51
+ get(id) {
52
+ return Promise.resolve(this.data.get(id));
39
53
  }
40
- async getAll() {
41
- return [...this.data.values()];
54
+ getAll() {
55
+ return Promise.resolve([...this.data.values()]);
42
56
  }
43
- async delete(id) {
57
+ delete(id) {
44
58
  const existing = this.data.get(id);
45
59
  if (existing) {
46
60
  this.removeFromIndexes(id, existing);
47
61
  this.data.delete(id);
48
62
  }
63
+ return Promise.resolve();
49
64
  }
50
- async getAllFromIndex(indexName, value) {
65
+ getAllFromIndex(indexName, value) {
51
66
  const index = this.indexes.get(indexName);
52
67
  if (!index)
53
- return [];
68
+ return Promise.resolve([]);
54
69
  // The in-memory index stores values as strings (it doesn't support
55
70
  // the full IDB key range — Date / BufferSource / arrays). For the
56
71
  // overwhelmingly-common case of string FK ids, coercing through
@@ -58,16 +73,17 @@ export class InMemoryObjectStore {
58
73
  // shared `ObjectStoreContract` signature.
59
74
  const ids = index.get(String(value));
60
75
  if (!ids)
61
- return [];
62
- return [...ids]
76
+ return Promise.resolve([]);
77
+ return Promise.resolve([...ids]
63
78
  .map((id) => this.data.get(id))
64
- .filter((r) => r != null);
79
+ .filter((r) => r != null));
65
80
  }
66
- async clear() {
81
+ clear() {
67
82
  this.data.clear();
68
83
  for (const index of this.indexes.values()) {
69
84
  index.clear();
70
85
  }
86
+ return Promise.resolve();
71
87
  }
72
88
  /** No-op — in-memory stores don't need closing. */
73
89
  markAsClosing() { }
@@ -58,7 +58,9 @@
58
58
  * first-in-first-out, which would require a persistent connection.
59
59
  */
60
60
  import type { z } from 'zod';
61
- import type { ModelOperations } from '../client/createModelProxy.js';
61
+ import type { ClaimParams, ModelRetrieveParams, ModelUpdateParams } from '../client/createModelProxy.js';
62
+ import type { ModelUpdater, ContentionOptions } from '../client/functionalUpdate.js';
63
+ import type { HeldClaim } from '../types/streams.js';
62
64
  export type CoordinationStrategy = 'merge' | 'claim' | 'queue';
63
65
  /** The structured result the tool hands back to the model (or the caller). */
64
66
  export interface CoordinatedWriteResult<T> {
@@ -105,4 +107,15 @@ export interface CoordinatedToolOptions<TInput, T> {
105
107
  timeoutMs?: number;
106
108
  };
107
109
  }
108
- export declare function coordinatedTool<TInput, T = Record<string, unknown>, CreateInput = Partial<T>>(model: ModelOperations<T, CreateInput>, options: CoordinatedToolOptions<TInput, T>): import("ai").Tool<TInput, CoordinatedWriteResult<T>>;
110
+ /**
111
+ * The small model port this helper needs. Both typed transports implement this
112
+ * exact contract; local-cache methods, wire receipts, and transport lifecycle
113
+ * deliberately stay out of an AI tool's dependency surface.
114
+ */
115
+ export interface CoordinatedModel<T> {
116
+ retrieve(params: ModelRetrieveParams): Promise<T | undefined>;
117
+ update(params: ModelUpdateParams<T>): Promise<T>;
118
+ update(id: string, updater: ModelUpdater<T>, options?: ContentionOptions): Promise<T | undefined>;
119
+ claim(params: ClaimParams<T>): Promise<HeldClaim<T>>;
120
+ }
121
+ export declare function coordinatedTool<TInput, T = Record<string, unknown>>(model: CoordinatedModel<T>, options: CoordinatedToolOptions<TInput, T>): import("ai").Tool<TInput, CoordinatedWriteResult<T>>;
@@ -27,6 +27,12 @@ export declare const IdentityResolveResponseSchema: z.ZodObject<{
27
27
  }>;
28
28
  participantId: z.ZodString;
29
29
  accountScope: z.ZodString;
30
+ projectId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
31
+ environment: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
32
+ production: "production";
33
+ sandbox: "sandbox";
34
+ }>>>;
35
+ sandboxId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
30
36
  syncGroups: z.ZodArray<z.ZodString>;
31
37
  userMeta: z.ZodRecord<z.ZodString, z.ZodUnknown>;
32
38
  }, z.core.$loose>;
@@ -25,6 +25,13 @@ export const IdentityResolveResponseSchema = z
25
25
  participantKind: AuthParticipantKindSchema,
26
26
  participantId: z.string().min(1),
27
27
  accountScope: z.string().min(1),
28
+ // The rest of the plane this credential resolves to. `nullish` (optional +
29
+ // nullable) so a server too old to send them still parses, and a human
30
+ // session — which carries no such scope — validates with them absent.
31
+ // `projectId` equals the org id for the org-default project.
32
+ projectId: z.string().min(1).nullish(),
33
+ environment: z.enum(['sandbox', 'production']).nullish(),
34
+ sandboxId: z.string().min(1).nullish(),
28
35
  syncGroups: z.array(z.string()),
29
36
  userMeta: z.record(z.string(), z.unknown()),
30
37
  })