@abloatai/ablo 0.7.0 → 0.9.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 (181) hide show
  1. package/CHANGELOG.md +72 -1
  2. package/README.md +80 -66
  3. package/dist/BaseSyncedStore.d.ts +73 -0
  4. package/dist/BaseSyncedStore.js +179 -5
  5. package/dist/Model.d.ts +42 -0
  6. package/dist/Model.js +103 -44
  7. package/dist/SyncEngineContext.d.ts +2 -1
  8. package/dist/SyncEngineContext.js +5 -3
  9. package/dist/agent/session.js +6 -5
  10. package/dist/ai-sdk/coordination-context.js +4 -0
  11. package/dist/ai-sdk/index.d.ts +56 -47
  12. package/dist/ai-sdk/index.js +56 -47
  13. package/dist/ai-sdk/intent-broadcast.d.ts +5 -0
  14. package/dist/ai-sdk/intent-broadcast.js +11 -4
  15. package/dist/ai-sdk/wrap.d.ts +14 -11
  16. package/dist/ai-sdk/wrap.js +11 -13
  17. package/dist/auth/credentialSource.d.ts +34 -0
  18. package/dist/auth/credentialSource.js +63 -0
  19. package/dist/auth/index.d.ts +2 -22
  20. package/dist/auth/index.js +26 -36
  21. package/dist/auth/schemas.d.ts +35 -0
  22. package/dist/auth/schemas.js +53 -0
  23. package/dist/client/Ablo.d.ts +259 -33
  24. package/dist/client/Ablo.js +276 -73
  25. package/dist/client/ApiClient.d.ts +52 -4
  26. package/dist/client/ApiClient.js +236 -66
  27. package/dist/client/auth.d.ts +21 -2
  28. package/dist/client/auth.js +77 -5
  29. package/dist/client/createInternalComponents.d.ts +2 -0
  30. package/dist/client/createInternalComponents.js +8 -1
  31. package/dist/client/createModelProxy.d.ts +187 -79
  32. package/dist/client/createModelProxy.js +203 -68
  33. package/dist/client/httpClient.d.ts +71 -0
  34. package/dist/client/httpClient.js +69 -0
  35. package/dist/client/identity.d.ts +2 -6
  36. package/dist/client/identity.js +63 -11
  37. package/dist/client/index.d.ts +1 -0
  38. package/dist/client/index.js +1 -0
  39. package/dist/client/registerDataSource.d.ts +19 -0
  40. package/dist/client/registerDataSource.js +59 -0
  41. package/dist/client/validateAbloOptions.d.ts +2 -1
  42. package/dist/client/validateAbloOptions.js +8 -7
  43. package/dist/core/DatabaseManager.js +30 -2
  44. package/dist/core/openIDBWithTimeout.d.ts +36 -0
  45. package/dist/core/openIDBWithTimeout.js +88 -1
  46. package/dist/errorCodes.d.ts +92 -1
  47. package/dist/errorCodes.js +139 -7
  48. package/dist/errors.d.ts +54 -3
  49. package/dist/errors.js +192 -44
  50. package/dist/index.d.ts +23 -10
  51. package/dist/index.js +21 -8
  52. package/dist/keys/index.d.ts +76 -0
  53. package/dist/keys/index.js +171 -0
  54. package/dist/mutators/UndoManager.d.ts +86 -50
  55. package/dist/mutators/UndoManager.js +129 -22
  56. package/dist/mutators/inverseOp.d.ts +129 -0
  57. package/dist/mutators/inverseOp.js +74 -0
  58. package/dist/mutators/readerActions.d.ts +1 -1
  59. package/dist/mutators/undoApply.d.ts +42 -0
  60. package/dist/mutators/undoApply.js +143 -0
  61. package/dist/query/client.d.ts +10 -9
  62. package/dist/query/client.js +22 -14
  63. package/dist/react/AbloProvider.d.ts +23 -101
  64. package/dist/react/AbloProvider.js +61 -103
  65. package/dist/react/ClientSideSuspense.d.ts +1 -1
  66. package/dist/react/DefaultFallback.d.ts +1 -1
  67. package/dist/react/SyncGroupProvider.d.ts +1 -1
  68. package/dist/react/index.d.ts +3 -2
  69. package/dist/react/index.js +3 -2
  70. package/dist/react/useAblo.d.ts +4 -4
  71. package/dist/react/useAblo.js +10 -5
  72. package/dist/react/useCurrentUserId.d.ts +1 -1
  73. package/dist/react/useCurrentUserId.js +1 -1
  74. package/dist/react/useMutators.js +19 -12
  75. package/dist/react/useReactive.js +16 -3
  76. package/dist/schema/ddl.d.ts +26 -3
  77. package/dist/schema/ddl.js +152 -4
  78. package/dist/schema/index.d.ts +4 -0
  79. package/dist/schema/index.js +12 -0
  80. package/dist/schema/model.d.ts +11 -0
  81. package/dist/schema/model.js +2 -0
  82. package/dist/schema/openapi.d.ts +28 -0
  83. package/dist/schema/openapi.js +118 -0
  84. package/dist/schema/plane.d.ts +23 -0
  85. package/dist/schema/plane.js +19 -0
  86. package/dist/schema/relation.d.ts +20 -0
  87. package/dist/schema/serialize.d.ts +7 -3
  88. package/dist/schema/serialize.js +6 -2
  89. package/dist/schema/sync-delta-row.d.ts +157 -0
  90. package/dist/schema/sync-delta-row.js +102 -0
  91. package/dist/schema/sync-delta-wire.d.ts +180 -0
  92. package/dist/schema/sync-delta-wire.js +102 -0
  93. package/dist/server/adapter.d.ts +156 -0
  94. package/dist/server/adapter.js +19 -0
  95. package/dist/server/commit.d.ts +82 -0
  96. package/dist/server/commit.js +1 -0
  97. package/dist/server/index.d.ts +14 -0
  98. package/dist/server/index.js +1 -0
  99. package/dist/server/next.d.ts +51 -0
  100. package/dist/server/next.js +47 -0
  101. package/dist/server/read-config.d.ts +60 -0
  102. package/dist/server/read-config.js +8 -0
  103. package/dist/server/storage-mode.d.ts +17 -0
  104. package/dist/server/storage-mode.js +12 -0
  105. package/dist/source/adapter.d.ts +59 -0
  106. package/dist/source/adapter.js +19 -0
  107. package/dist/source/adapters/drizzle.d.ts +34 -0
  108. package/dist/source/adapters/drizzle.js +147 -0
  109. package/dist/source/adapters/memory.d.ts +12 -0
  110. package/dist/source/adapters/memory.js +114 -0
  111. package/dist/source/adapters/prisma.d.ts +57 -0
  112. package/dist/source/adapters/prisma.js +199 -0
  113. package/dist/source/conformance.d.ts +32 -0
  114. package/dist/source/conformance.js +134 -0
  115. package/dist/source/contract.d.ts +143 -0
  116. package/dist/source/contract.js +98 -0
  117. package/dist/source/index.d.ts +61 -10
  118. package/dist/source/index.js +98 -0
  119. package/dist/source/next.d.ts +33 -0
  120. package/dist/source/next.js +26 -0
  121. package/dist/sync/BootstrapHelper.d.ts +10 -0
  122. package/dist/sync/BootstrapHelper.js +56 -42
  123. package/dist/sync/ConnectionManager.d.ts +57 -1
  124. package/dist/sync/ConnectionManager.js +186 -11
  125. package/dist/sync/HydrationCoordinator.d.ts +93 -17
  126. package/dist/sync/HydrationCoordinator.js +241 -41
  127. package/dist/sync/NetworkProbe.d.ts +60 -18
  128. package/dist/sync/NetworkProbe.js +121 -23
  129. package/dist/sync/SyncWebSocket.d.ts +45 -70
  130. package/dist/sync/SyncWebSocket.js +113 -89
  131. package/dist/sync/createIntentStream.js +10 -1
  132. package/dist/sync/participants.js +5 -2
  133. package/dist/transactions/TransactionQueue.js +13 -1
  134. package/dist/types/streams.d.ts +9 -0
  135. package/dist/utils/mobx-setup.js +1 -0
  136. package/dist/webhooks/events.d.ts +38 -0
  137. package/dist/webhooks/events.js +40 -0
  138. package/dist/webhooks/index.d.ts +10 -0
  139. package/dist/webhooks/index.js +10 -0
  140. package/dist/wire/errorEnvelope.d.ts +34 -0
  141. package/dist/wire/errorEnvelope.js +86 -0
  142. package/dist/wire/frames.d.ts +119 -0
  143. package/dist/wire/frames.js +1 -0
  144. package/dist/wire/index.d.ts +24 -0
  145. package/dist/wire/index.js +21 -0
  146. package/dist/wire/listEnvelope.d.ts +45 -0
  147. package/dist/wire/listEnvelope.js +17 -0
  148. package/docs/api-keys.md +5 -5
  149. package/docs/api.md +125 -65
  150. package/docs/audit.md +16 -9
  151. package/docs/cli.md +57 -47
  152. package/docs/client-behavior.md +54 -40
  153. package/docs/coordination.md +66 -80
  154. package/docs/data-sources.md +56 -34
  155. package/docs/examples/agent-human.md +74 -28
  156. package/docs/examples/ai-sdk-tool.md +29 -22
  157. package/docs/examples/existing-python-backend.md +41 -26
  158. package/docs/examples/nextjs.md +32 -17
  159. package/docs/examples/scoped-agent.md +43 -28
  160. package/docs/examples/server-agent.md +40 -15
  161. package/docs/guarantees.md +38 -27
  162. package/docs/identity.md +65 -59
  163. package/docs/index.md +30 -19
  164. package/docs/integration-guide.md +78 -78
  165. package/docs/interaction-model.md +43 -35
  166. package/docs/mcp/claude-code.md +11 -19
  167. package/docs/mcp/cursor.md +7 -25
  168. package/docs/mcp/windsurf.md +7 -20
  169. package/docs/mcp.md +103 -26
  170. package/docs/quickstart.md +63 -61
  171. package/docs/react.md +24 -16
  172. package/docs/roadmap.md +13 -13
  173. package/docs/schema-contract.md +111 -0
  174. package/docs/the-loop.md +21 -0
  175. package/examples/README.md +8 -4
  176. package/examples/data-source/README.md +10 -7
  177. package/examples/data-source/customer-server.ts +27 -25
  178. package/examples/data-source/run.ts +4 -3
  179. package/examples/quickstart.ts +1 -1
  180. package/llms.txt +55 -21
  181. package/package.json +48 -3
@@ -7,10 +7,12 @@
7
7
  * testable in isolation and the constructor doesn't carry it.
8
8
  *
9
9
  * Each schema model gets one `ModelOperations<T, CreateInput>` —
10
- * exposes `retrieve`, `list`, `count`, `create`, `update`, `delete`,
11
- * `claim`, `claimState`, `queue`, `release`, `subscribe`, and `load`.
12
- * The factory returns a plain object; the client assembles the
13
- * `ablo.<model>` lookup table from these.
10
+ * exposes the async server reads `retrieve` / `list`, the synchronous
11
+ * local-graph snapshots `get` / `getAll` / `getCount`, the writes
12
+ * `create` / `update` / `delete`, the coordination namespace `claim`
13
+ * (`claim({ id })` plus `claim.state` / `claim.queue` / `claim.release` /
14
+ * `claim.reorder`), and `onChange`. The factory returns a plain object; the
15
+ * client assembles the `ablo.<model>` lookup table from these.
14
16
  */
15
17
  import type { MutationOptions } from '../interfaces/index.js';
16
18
  import type { ModelRegistry } from '../ModelRegistry.js';
@@ -19,7 +21,7 @@ import type { SyncClient } from '../SyncClient.js';
19
21
  import type { HydrationCoordinator } from '../sync/HydrationCoordinator.js';
20
22
  import type { LoadWhere } from '../query/types.js';
21
23
  import { ModelScope } from '../types/index.js';
22
- import type { Duration, Intent, IntentWaitOptions, Snapshot } from '../types/streams.js';
24
+ import type { Duration, Intent, IntentWaitOptions, Snapshot, TargetRange } from '../types/streams.js';
23
25
  export interface ModelClientMeta {
24
26
  readonly key: string;
25
27
  readonly typename: string;
@@ -48,7 +50,7 @@ export interface ModelLoadOptions<T> {
48
50
  * - tuple form: `[['name', 'ILIKE', '%Goldman%']]` for operators
49
51
  *
50
52
  * See `LoadWhere<T>` in `query/types.ts`. For OR semantics, run two
51
- * `load()` calls and union — the wire protocol is AND-only.
53
+ * `list()` calls and union — the wire protocol is AND-only.
52
54
  */
53
55
  where?: LoadWhere<T>;
54
56
  orderBy?: {
@@ -68,6 +70,9 @@ export interface ModelLoadOptions<T> {
68
70
  */
69
71
  expand?: readonly string[];
70
72
  }
73
+ /** Options for the single-row async server read `retrieve({ id })`. A subset of
74
+ * {@link ModelLoadOptions} — `where`/`limit`/`orderBy` are fixed by the id. */
75
+ export type ModelRetrieveOptions = Pick<ModelLoadOptions<unknown>, 'type' | 'expand'>;
71
76
  export interface IntentLeaseHandle {
72
77
  readonly id: string;
73
78
  release(): Promise<void>;
@@ -79,6 +84,9 @@ export interface ModelCollaboration<T> {
79
84
  model: string;
80
85
  id: string;
81
86
  field?: string;
87
+ path?: string;
88
+ range?: TargetRange;
89
+ meta?: Record<string, unknown>;
82
90
  };
83
91
  action: string;
84
92
  ttl?: Duration;
@@ -134,12 +142,19 @@ export interface ModelCollaboration<T> {
134
142
  */
135
143
  readonly selfParticipantId: string;
136
144
  }
137
- /** Options for `claim(id, …)`. */
138
- export interface ClaimOptions {
145
+ export interface ClaimTargetOptions<T = Record<string, unknown>> {
139
146
  /** Phase shown to observers while held. Defaults to `'editing'`. */
140
147
  action?: string;
148
+ /** Peer-visible explanation of the work being performed. */
149
+ description?: string;
141
150
  /** Field-level target, for fine-grained claimed-state badges. */
142
151
  field?: string;
152
+ /** Optional path for document/file-like targets. */
153
+ path?: string;
154
+ /** Optional range for document/file-like targets. */
155
+ range?: TargetRange;
156
+ /** App-defined structured metadata. */
157
+ meta?: Record<string, unknown>;
143
158
  /** Crash-cleanup TTL — the claim auto-releases if the holder dies. */
144
159
  ttl?: Duration;
145
160
  /**
@@ -159,106 +174,199 @@ export interface ClaimOptions {
159
174
  */
160
175
  maxQueueDepth?: number;
161
176
  }
177
+ /** Options for `claim({ id, ... })`. */
178
+ export interface ClaimParams<T = Record<string, unknown>> extends ClaimTargetOptions<T> {
179
+ readonly id: string;
180
+ }
181
+ export interface ClaimLookupParams<T = Record<string, unknown>> {
182
+ readonly id: string;
183
+ readonly field?: string;
184
+ }
185
+ export interface ClaimReorderParams<T = Record<string, unknown>> extends ClaimLookupParams<T> {
186
+ readonly order: readonly Intent[];
187
+ }
162
188
  /**
163
- * A claimed row: the entity's data plus an async-dispose hook, so
189
+ * A claim handle: the held entity data plus an explicit release hook, so
164
190
  *
165
191
  * ```ts
166
- * await ablo.weatherReports.claim('report_stockholm', async (report) => {
167
- * await ablo.weatherReports.update(report.id, { status: 'ready' });
192
+ * const claim = await ablo.weatherReports.claim({
193
+ * id: 'report_stockholm',
194
+ * action: 'forecasting',
195
+ * description: 'Fetching current weather before writing the forecast.',
168
196
  * });
197
+ * try {
198
+ * await ablo.weatherReports.update({
199
+ * id: claim.target.id,
200
+ * data: { status: 'ready' },
201
+ * claim,
202
+ * });
203
+ * } finally {
204
+ * await claim.release();
205
+ * }
169
206
  * ```
170
207
  *
171
- * releases the claim when the callback returns or throws. Read it like any row
172
- * (`report.location`); write it through the flat `ablo.<model>.update(report.id, )`
173
- * verb there is no method chaining on the claim.
208
+ * `data` is a snapshot taken after the lease is held. Write through the flat
209
+ * `ablo.<model>.update({ id, data, claim })` verb — the handle carries the
210
+ * lease id and snapshot watermark for attribution + stale protection.
174
211
  */
175
- export type ClaimedRow<T> = T & AsyncDisposable;
212
+ export interface ClaimHandle<T = Record<string, unknown>> extends AsyncDisposable {
213
+ readonly object: 'claim';
214
+ readonly claimId: string;
215
+ readonly target: {
216
+ readonly model: string;
217
+ readonly id: string;
218
+ readonly field?: string;
219
+ readonly path?: string;
220
+ readonly range?: TargetRange;
221
+ readonly meta?: Record<string, unknown>;
222
+ };
223
+ readonly action: string;
224
+ readonly description?: string;
225
+ readonly data: T;
226
+ release(): Promise<void>;
227
+ revoke(): void;
228
+ }
229
+ export type ClaimOptions<T = Record<string, unknown>> = ClaimTargetOptions<T>;
230
+ /**
231
+ * The coordination surface for a model, exposed as a callable namespace.
232
+ *
233
+ * Most callers do not need this namespace directly. Put `claim: { ... }` on a
234
+ * write and the SDK acquires/releases around that one mutation:
235
+ *
236
+ * ```ts
237
+ * await ablo.tasks.update({
238
+ * id,
239
+ * data: { title },
240
+ * claim: {
241
+ * field: 'title',
242
+ * action: 'renaming',
243
+ * description: 'Renaming the task to match the project brief.',
244
+ * },
245
+ * });
246
+ * ```
247
+ *
248
+ * Use `claim({ id, ... })` when a tool spans multiple writes and needs one
249
+ * handle. `state`, `queue`, and `reorder` are coordination reads/scheduler
250
+ * controls for UI and operators.
251
+ */
252
+ export interface ClaimApi<T> {
253
+ /** Take a claim and get an explicit held-work handle back. */
254
+ (params: ClaimParams<T>): Promise<ClaimHandle<T>>;
255
+ /**
256
+ * Current holder for a row, or `null` when free. Use this for UI badges and
257
+ * preflight checks, not for the normal write path.
258
+ */
259
+ state(params: ClaimLookupParams<T>): Intent | null;
260
+ /**
261
+ * FIFO wait line behind the current holder. Advanced: useful for operator
262
+ * UIs and schedulers.
263
+ */
264
+ queue(params: ClaimLookupParams<T>): {
265
+ readonly object: 'list';
266
+ readonly data: readonly Intent[];
267
+ };
268
+ /**
269
+ * Re-rank the wait line. Advanced and permission-gated.
270
+ */
271
+ reorder(params: ClaimReorderParams<T>): void;
272
+ /** Release a manual claim handle early. Single-write claims auto-release. */
273
+ release(params: ClaimLookupParams<T> | ClaimHandle<T>): Promise<void>;
274
+ }
275
+ export interface ModelRetrieveParams extends ModelRetrieveOptions {
276
+ readonly id: string;
277
+ }
278
+ export interface ModelCreateParams<T, CreateInput> extends MutationOptions {
279
+ readonly data: CreateInput;
280
+ readonly id?: string | null;
281
+ readonly claim?: ClaimHandle<T> | ClaimTargetOptions<T> | null;
282
+ }
283
+ export interface ModelUpdateParams<T> extends MutationOptions {
284
+ readonly id: string;
285
+ readonly data: Partial<T>;
286
+ readonly claim?: ClaimHandle<T> | ClaimTargetOptions<T> | null;
287
+ }
288
+ export interface ModelDeleteParams<T> extends MutationOptions {
289
+ readonly id: string;
290
+ readonly claim?: ClaimHandle<T> | ClaimTargetOptions<T> | null;
291
+ }
176
292
  export interface ModelOperations<T, CreateInput> {
177
293
  /**
178
- * Retrieve a single entity by id from the local pool. Synchronous.
179
- * Returns `undefined` when the entity isn't loaded yet use
180
- * `load({where: {id}})` if you want to lazy-hydrate from storage/network.
294
+ * Read a single entity by id from the **server** — async. Resolves through
295
+ * the 3-tier lookup (local pool IndexedDB network `POST /sync/query`)
296
+ * and lands the row in the local graph. Resolves to `undefined` when no
297
+ * such row exists.
298
+ *
299
+ * This is the default "get me this entity" read and the one hosted /
300
+ * stateless callers want, since their local graph starts empty. For a
301
+ * synchronous read of an already-warm graph (a React selector) use
302
+ * `get(id)`.
181
303
  *
182
- * Mirrors `stripe.customers.retrieve(id)`.
304
+ * Mirrors `stripe.customers.retrieve({ id })` — network-backed.
183
305
  */
184
- retrieve(id: string): T | undefined;
306
+ retrieve(params: ModelRetrieveParams): Promise<T | undefined>;
185
307
  /**
186
- * List entities matching a filter from the local pool. Synchronous.
187
- * No network round-trip use `load()` for hydration.
308
+ * List entities matching a filter from the **server** — async. Same 3-tier
309
+ * lookup + graph hydration as `retrieve`; single-flight deduped. Returns the
310
+ * matched rows.
188
311
  *
189
- * Mirrors `stripe.customers.list({...})`.
312
+ * Mirrors `stripe.customers.list({...})` — network-backed. For a synchronous
313
+ * read of the local graph use `getAll(...)`.
314
+ */
315
+ list(options?: ModelLoadOptions<T>): Promise<T[]>;
316
+ /**
317
+ * Synchronous snapshot of a single entity from the **local graph** — no
318
+ * network. Returns `undefined` when the row isn't resident (cold hosted
319
+ * client, or a `lazy` model not yet loaded). Pairs with reactive selectors:
320
+ * `useAblo((ablo) => ablo.<model>.get(id))`.
321
+ */
322
+ get(id: string): T | undefined;
323
+ /**
324
+ * Synchronous snapshot of a filtered collection from the **local graph** —
325
+ * no network round-trip. Empty until `retrieve`/`list`/bootstrap has warmed
326
+ * the graph.
190
327
  */
191
- list(options?: ModelListOptions<T>): T[];
192
- /** Count entities matching a filter (synchronous, from local pool). */
193
- count(options?: ModelCountOptions<T>): number;
328
+ getAll(options?: ModelListOptions<T>): T[];
329
+ /** Count entities in the **local graph** (synchronous, no network). */
330
+ getCount(options?: ModelCountOptions<T>): number;
194
331
  /**
195
332
  * Create a new entity — **optimistic, offline-first**. Resolves once
196
333
  * the mutation is queued locally, not when the server confirms.
197
334
  * Server rejection rolls back automatically; watch `sync.syncStatus`.
198
335
  */
199
- create(data: CreateInput, options?: MutationOptions): Promise<T>;
336
+ create(params: ModelCreateParams<T, CreateInput>): Promise<T>;
200
337
  /** Update an entity by id — optimistic, offline-first (see `create`). */
201
- update(id: string, data: Partial<T>, options?: MutationOptions): Promise<T>;
338
+ update(params: ModelUpdateParams<T>): Promise<T>;
202
339
  /** Delete an entity by id — optimistic, offline-first (see `create`). */
203
- delete(id: string, options?: MutationOptions): Promise<void>;
340
+ delete(params: ModelDeleteParams<T>): Promise<void>;
204
341
  /**
205
- * Claim a row so other writers wait or are rejected until you're done.
206
- * Reads stay open by default. Prefer the callback form for ordinary held
207
- * work; it releases when the callback returns or throws. The `await using`
208
- * form is also available for wider lexical scopes.
342
+ * Claim a row so other writers wait or are rejected until you're done, and
343
+ * inspect or manage that coordination through the same namespace. Call it to
344
+ * take a claim handle; reach for its members to observe and steer the wait line:
209
345
  *
210
- * ```ts
211
- * await ablo.weatherReports.claim('report_stockholm', async (report) => {
212
- * const weather = await getWeather(report.location);
213
- * await ablo.weatherReports.update(report.id, { forecast: weather });
214
- * });
215
- * ```
216
- */
217
- claim(id: string, options?: ClaimOptions): Promise<ClaimedRow<T>>;
218
- claim<R>(id: string, work: (row: ClaimedRow<T>) => Promise<R> | R, options?: ClaimOptions): Promise<R>;
219
- /**
220
- * Read who's coordinating on a row — the current holder (who, phase,
221
- * until when), or `null` when free. Synchronous and reactive; for
222
- * observers/UI. Never blocks.
223
- */
224
- claimState(id: string): Intent | null;
225
- /**
226
- * The wait queue on a row — who's lined up behind the holder and what each
227
- * intends. Reactive snapshot (synced from the server, like `activity`);
228
- * returns a Stripe-style list envelope, FIFO order, empty when no one waits.
346
+ * - `claim.state({ id })` — who holds the row now, or `null` when free
347
+ * - `claim.queue({ id })` who's lined up behind the holder
348
+ * - `claim.release({ id })` — drop a claim early (usually implicit on scope exit)
349
+ * - `claim.reorder({ id, order })` re-rank the wait line
229
350
  *
230
351
  * ```ts
231
- * const { data } = ablo.decks.queue('deck_1');
232
- * // → [{ heldBy: 'agent:summarizer', action: 'editing', position: 0 }, …]
233
- * ```
234
- */
235
- queue(id: string): {
236
- readonly object: 'list';
237
- readonly data: readonly Intent[];
238
- };
239
- /**
240
- * Re-rank the wait queue on a record — move waiters to the front in the
241
- * given order. Pass the `Intent[]` from `queue(id).data`, reordered. A
242
- * privileged operation: the server gates it (the caller needs the
243
- * `intent.reorder` capability), so it's fire-and-forget — the new order
244
- * arrives reactively through `queue(id)`.
352
+ * const claim = await ablo.weatherReports.claim({
353
+ * id: 'report_stockholm',
354
+ * action: 'forecasting',
355
+ * description: 'Fetching fresh weather before updating the report.',
356
+ * });
357
+ * const weather = await getWeather(claim.data.location);
358
+ * await ablo.weatherReports.update({
359
+ * id: claim.target.id,
360
+ * data: { forecast: weather },
361
+ * claim,
362
+ * });
363
+ * await claim.release();
245
364
  *
246
- * ```ts
247
- * const { data } = ablo.decks.queue('deck_1');
248
- * ablo.decks.reorder('deck_1', [data[2], data[0], data[1]]); // promote #2
365
+ * const holder = ablo.weatherReports.claim.state({ id: 'report_stockholm' });
249
366
  * ```
250
367
  */
251
- reorder(id: string, order: readonly Intent[]): void;
252
- /** Release a claim you hold early. Usually implicit (scope exit). */
253
- release(id: string): Promise<void>;
368
+ claim: ClaimApi<T>;
254
369
  /** Listen for changes (callback called on every change). */
255
370
  onChange(callback: (entities: T[]) => void, options?: ModelListOptions<T>): () => void;
256
- /**
257
- * Load matching rows into the local graph if they are not already
258
- * present. Single-flight: concurrent calls with the same args share
259
- * one in-flight request. Default `type: 'complete'` waits for the
260
- * server; `type: 'unknown'` returns local + refreshes async.
261
- */
262
- load(options?: ModelLoadOptions<T>): Promise<T[]>;
263
371
  }
264
372
  export declare function createModelProxy<T, C>(schemaKey: string, registeredModelName: string, objectPool: ObjectPool, syncClient: SyncClient, registry: ModelRegistry, hydration: HydrationCoordinator, collaboration?: ModelCollaboration<T>): ModelOperations<T, C>;