@abloatai/ablo 0.10.1 → 0.11.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 (105) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +63 -23
  3. package/dist/BaseSyncedStore.d.ts +75 -0
  4. package/dist/BaseSyncedStore.js +193 -8
  5. package/dist/Database.d.ts +10 -2
  6. package/dist/Database.js +15 -1
  7. package/dist/SyncClient.d.ts +12 -1
  8. package/dist/SyncClient.js +110 -26
  9. package/dist/agent/Agent.d.ts +9 -9
  10. package/dist/agent/Agent.js +16 -16
  11. package/dist/agent/index.d.ts +1 -1
  12. package/dist/agent/index.js +2 -2
  13. package/dist/agent/types.d.ts +1 -1
  14. package/dist/agent/types.js +1 -1
  15. package/dist/ai-sdk/{intent-broadcast.d.ts → claim-broadcast.d.ts} +10 -10
  16. package/dist/ai-sdk/{intent-broadcast.js → claim-broadcast.js} +6 -6
  17. package/dist/ai-sdk/coordination-context.d.ts +9 -9
  18. package/dist/ai-sdk/coordination-context.js +8 -8
  19. package/dist/ai-sdk/index.d.ts +1 -1
  20. package/dist/ai-sdk/index.js +1 -1
  21. package/dist/ai-sdk/wrap.d.ts +4 -4
  22. package/dist/ai-sdk/wrap.js +4 -4
  23. package/dist/api/index.d.ts +2 -2
  24. package/dist/cli.cjs +369 -67
  25. package/dist/client/Ablo.d.ts +30 -63
  26. package/dist/client/Ablo.js +124 -103
  27. package/dist/client/ApiClient.d.ts +6 -5
  28. package/dist/client/ApiClient.js +86 -62
  29. package/dist/client/auth.d.ts +9 -4
  30. package/dist/client/auth.js +40 -5
  31. package/dist/client/createModelProxy.d.ts +41 -54
  32. package/dist/client/createModelProxy.js +123 -20
  33. package/dist/client/httpClient.d.ts +2 -0
  34. package/dist/client/httpClient.js +1 -1
  35. package/dist/client/index.d.ts +3 -3
  36. package/dist/client/writeOptionsSchema.d.ts +4 -4
  37. package/dist/client/writeOptionsSchema.js +4 -4
  38. package/dist/coordination/schema.d.ts +249 -38
  39. package/dist/coordination/schema.js +172 -39
  40. package/dist/core/index.d.ts +2 -2
  41. package/dist/core/index.js +4 -4
  42. package/dist/errorCodes.d.ts +9 -9
  43. package/dist/errorCodes.js +16 -16
  44. package/dist/errors.d.ts +51 -2
  45. package/dist/errors.js +94 -5
  46. package/dist/interfaces/index.d.ts +8 -4
  47. package/dist/policy/index.d.ts +1 -1
  48. package/dist/policy/types.d.ts +13 -13
  49. package/dist/policy/types.js +8 -8
  50. package/dist/react/AbloProvider.d.ts +51 -4
  51. package/dist/react/AbloProvider.js +95 -11
  52. package/dist/react/context.d.ts +26 -9
  53. package/dist/react/context.js +2 -2
  54. package/dist/react/index.d.ts +4 -4
  55. package/dist/react/index.js +4 -4
  56. package/dist/react/useAblo.js +5 -5
  57. package/dist/react/{useIntent.d.ts → useClaim.d.ts} +9 -9
  58. package/dist/react/useClaim.js +42 -0
  59. package/dist/schema/index.js +1 -1
  60. package/dist/schema/schema.d.ts +3 -3
  61. package/dist/schema/sugar.d.ts +3 -3
  62. package/dist/schema/sugar.js +3 -3
  63. package/dist/schema/sync-delta-wire.d.ts +8 -8
  64. package/dist/server/commit.d.ts +2 -2
  65. package/dist/sync/AreaOfInterestManager.d.ts +162 -0
  66. package/dist/sync/AreaOfInterestManager.js +233 -0
  67. package/dist/sync/BootstrapHelper.d.ts +9 -1
  68. package/dist/sync/BootstrapHelper.js +15 -5
  69. package/dist/sync/NetworkProbe.d.ts +1 -1
  70. package/dist/sync/NetworkProbe.js +1 -1
  71. package/dist/sync/SyncWebSocket.d.ts +59 -25
  72. package/dist/sync/SyncWebSocket.js +123 -26
  73. package/dist/sync/awaitClaimGrant.d.ts +40 -0
  74. package/dist/sync/awaitClaimGrant.js +86 -0
  75. package/dist/sync/createClaimStream.d.ts +34 -0
  76. package/dist/sync/{createIntentStream.js → createClaimStream.js} +92 -81
  77. package/dist/sync/createPresenceStream.js +3 -2
  78. package/dist/sync/participants.d.ts +10 -10
  79. package/dist/sync/participants.js +17 -10
  80. package/dist/sync/schemas.d.ts +8 -8
  81. package/dist/transactions/TransactionQueue.d.ts +23 -0
  82. package/dist/transactions/TransactionQueue.js +186 -12
  83. package/dist/types/global.d.ts +18 -13
  84. package/dist/types/global.js +11 -6
  85. package/dist/types/index.d.ts +9 -7
  86. package/dist/types/index.js +2 -2
  87. package/dist/types/streams.d.ts +114 -98
  88. package/dist/types/streams.js +1 -1
  89. package/dist/utils/asyncIterator.d.ts +1 -1
  90. package/dist/utils/asyncIterator.js +1 -1
  91. package/dist/wire/frames.d.ts +2 -2
  92. package/docs/api.md +3 -3
  93. package/docs/client-behavior.md +6 -3
  94. package/docs/coordination.md +13 -3
  95. package/docs/data-sources.md +29 -9
  96. package/docs/migration.md +40 -0
  97. package/docs/quickstart.md +61 -33
  98. package/docs/react.md +46 -0
  99. package/llms-full.txt +25 -8
  100. package/llms.txt +11 -9
  101. package/package.json +3 -2
  102. package/dist/react/useIntent.js +0 -42
  103. package/dist/sync/awaitIntentGrant.d.ts +0 -40
  104. package/dist/sync/awaitIntentGrant.js +0 -62
  105. package/dist/sync/createIntentStream.d.ts +0 -34
@@ -20,15 +20,17 @@
20
20
  */
21
21
  import type { Schema, SchemaRecord, InferModel, InferCreate } from '../schema/schema.js';
22
22
  import type { SyncEngineConfig, SyncLogger, MutationExecutor, MutationDispatcher, SyncObservabilityProvider, SyncAnalytics, SessionErrorDetector, OnlineStatusProvider } from '../interfaces/index.js';
23
+ import type { ModelTarget, ModelClaim } from '../coordination/schema.js';
24
+ export type { ModelTarget, ModelClaim };
23
25
  import { ObjectPool } from '../ObjectPool.js';
24
26
  import type { SyncStoreContract } from '../react/context.js';
25
27
  import type { SyncWebSocket } from '../sync/SyncWebSocket.js';
26
28
  import type { SyncGroupInput } from '../schema/roles.js';
27
29
  import { type SyncStatus } from '../BaseSyncedStore.js';
28
- import type { IntentStream, IntentWaitOptions, PresenceStream, Snapshot } from '../types/streams.js';
30
+ import type { ClaimStream, ClaimWaitOptions, PresenceStream, Snapshot } from '../types/streams.js';
29
31
  import type { ParticipantManager } from '../sync/participants.js';
30
- import type { ActiveIntent, Duration, Intent, TargetRange } from '../types/streams.js';
31
- import { type AbloApi, type AbloApiClientOptions, type AbloApiIntents } from './ApiClient.js';
32
+ import type { ClaimHandle, Duration, Claim } from '../types/streams.js';
33
+ import { type AbloApi, type AbloApiClientOptions, type AbloApiClaims } from './ApiClient.js';
32
34
  import { type AbloHttpClient, type AbloHttpClientOptions } from './httpClient.js';
33
35
  /**
34
36
  * Async function that resolves an apiKey at request time. Use for
@@ -384,30 +386,9 @@ export interface InternalAbloOptions<S extends SchemaRecord = SchemaRecord> {
384
386
  * `claim({ id })` — durable claim handle for coordinated writes
385
387
  */
386
388
  export type { ModelCountOptions, ModelListOptions, ModelListScope, ModelLoadOptions, ModelRetrieveParams, ModelCreateParams, ModelUpdateParams, ModelDeleteParams, ClaimOptions, ClaimParams, ClaimLookupParams, ClaimReorderParams, ClaimHandle, ModelOperations, } from './createModelProxy.js';
387
- import type { ModelOperations, ClaimOptions, ClaimParams, ClaimLookupParams, ClaimReorderParams, ClaimHandle, ModelLoadOptions } from './createModelProxy.js';
389
+ import type { ModelOperations, ClaimOptions, ClaimParams, ClaimLookupParams, ClaimReorderParams, ModelLoadOptions } from './createModelProxy.js';
388
390
  export type ModelOperationAction = 'create' | 'update' | 'delete' | 'archive' | 'unarchive';
389
391
  export type CommitWait = 'queued' | 'confirmed';
390
- export interface ModelTarget {
391
- /** The model name — matches `ablo.<model>` and the schema's `model()`. */
392
- readonly model: string;
393
- readonly id: string;
394
- readonly path?: string;
395
- readonly range?: TargetRange;
396
- readonly field?: string;
397
- readonly meta?: Record<string, unknown>;
398
- }
399
- export interface ModelClaim {
400
- readonly id: string;
401
- readonly actor: string;
402
- readonly participantKind: ActiveIntent['participantKind'];
403
- readonly action: string;
404
- readonly description?: string;
405
- readonly field?: string;
406
- readonly status?: 'active' | 'queued';
407
- readonly position?: number;
408
- readonly expiresAt: string;
409
- readonly target: ModelTarget;
410
- }
411
392
  export interface ModelRead<T = Record<string, unknown>> {
412
393
  readonly data: T;
413
394
  readonly stamp: number;
@@ -431,18 +412,18 @@ export interface ClaimedOptions {
431
412
  */
432
413
  readonly maxQueueDepth?: number;
433
414
  }
434
- export type { IntentWaitOptions } from '../types/streams.js';
415
+ export type { ClaimWaitOptions } from '../types/streams.js';
435
416
  export interface ModelReadOptions extends ClaimedOptions {
436
417
  }
437
- export interface IntentCreateOptions {
418
+ export interface ClaimCreateOptions {
438
419
  readonly target: ModelTarget;
439
420
  readonly action: string;
440
421
  readonly ttl?: Duration;
441
422
  /**
442
423
  * Join the server's fair FIFO queue when the target is already claimed,
443
424
  * rather than failing immediately. `create` then resolves only once the
444
- * lease is actually ours (the server pushes `intent_acquired` if the target
445
- * was free, or `intent_granted` when we reach the head of the line). Without
425
+ * lease is actually ours (the server pushes `claim_acquired` if the target
426
+ * was free, or `claim_granted` when we reach the head of the line). Without
446
427
  * this, a contended claim throws. Used by `ablo.<model>.claim` so writers
447
428
  * serialize instead of racing.
448
429
  */
@@ -455,20 +436,6 @@ export interface IntentCreateOptions {
455
436
  */
456
437
  readonly maxQueueDepth?: number;
457
438
  }
458
- export interface IntentHandle extends AsyncDisposable {
459
- readonly id: string;
460
- /**
461
- * True when the lease was granted AFTER waiting in the server's FIFO
462
- * queue behind a holder (`intent_granted`), false/absent for an
463
- * immediate grant (`intent_acquired`). Consumers re-read the target
464
- * row when this is set — the row may have changed while we queued, and
465
- * the local coordination snapshot can't detect that for org-scoped
466
- * subscriptions (intent fan-out is entity-scoped).
467
- */
468
- readonly waited?: boolean;
469
- release(): Promise<void>;
470
- revoke(): void;
471
- }
472
439
  export interface CommitOperationInput {
473
440
  readonly action: ModelOperationAction;
474
441
  /** The model name — matches `ablo.<model>` and the schema's `model()`. */
@@ -481,7 +448,7 @@ export interface CommitOperationInput {
481
448
  readonly onStale?: 'reject' | 'force' | 'flag' | 'merge' | null;
482
449
  }
483
450
  export interface CommitCreateOptions {
484
- readonly intent?: string | {
451
+ readonly claimRef?: string | {
485
452
  readonly id: string;
486
453
  } | null;
487
454
  readonly idempotencyKey?: string | null;
@@ -508,13 +475,13 @@ export interface CommitReceipt {
508
475
  export interface CommitResource {
509
476
  create(options: CommitCreateOptions): Promise<CommitReceipt>;
510
477
  }
511
- export interface IntentResource extends IntentStream {
512
- create(options: IntentCreateOptions): Promise<IntentHandle>;
478
+ export interface ClaimResource extends ClaimStream {
479
+ create(options: ClaimCreateOptions): Promise<ClaimHandle>;
513
480
  list(target?: Partial<ModelTarget>): readonly ModelClaim[];
514
- waitFor(target: Partial<ModelTarget>, options?: IntentWaitOptions): Promise<void>;
481
+ waitFor(target: Partial<ModelTarget>, options?: ClaimWaitOptions): Promise<void>;
515
482
  }
516
483
  export interface ModelMutationOptions extends ClaimedOptions {
517
- readonly intent?: string | {
484
+ readonly claimRef?: string | {
518
485
  readonly id: string;
519
486
  } | null;
520
487
  readonly idempotencyKey?: string | null;
@@ -537,14 +504,14 @@ export interface HttpClaimApi<T> {
537
504
  * Current holder of the lease on a row, or `null` when free. For UI badges,
538
505
  * preflight checks, and operators.
539
506
  */
540
- state(params: ClaimLookupParams<T>): Promise<Intent | null>;
507
+ state(params: ClaimLookupParams<T>): Promise<Claim | null>;
541
508
  /**
542
509
  * FIFO wait line behind the holder. Advanced: useful for operator UIs and
543
510
  * schedulers.
544
511
  */
545
512
  queue(params: ClaimLookupParams<T>): Promise<{
546
513
  readonly object: 'list';
547
- readonly data: readonly Intent[];
514
+ readonly data: readonly Claim[];
548
515
  }>;
549
516
  /**
550
517
  * Re-rank the wait line. Advanced and permission-gated.
@@ -859,7 +826,7 @@ export type Ablo<S extends SchemaRecord> = {
859
826
  * Canonical multiplayer participant surface. Joins a structured app
860
827
  * target, derives the transport scope internally, opens a scoped
861
828
  * claim on the existing WebSocket, and returns target-bound presence
862
- * + intent helpers.
829
+ * + claim helpers.
863
830
  *
864
831
  * ```ts
865
832
  * const participant = await ablo.participants.join({
@@ -869,7 +836,7 @@ export type Ablo<S extends SchemaRecord> = {
869
836
  * range: { startLine: 10, endLine: 40 },
870
837
  * });
871
838
  * participant.presence.editing();
872
- * const claim = participant.intents.claim('rewrite imports');
839
+ * const claim = participant.claims.claim('rewrite imports');
873
840
  * ```
874
841
  */
875
842
  readonly participants: ParticipantManager;
@@ -1000,7 +967,7 @@ import type * as _SchemaTypes from '../schema/schema.js';
1000
967
  export declare namespace Ablo {
1001
968
  type Options<S extends SchemaRecord = SchemaRecord> = AbloOptions<S>;
1002
969
  type Api = AbloApi;
1003
- type ApiIntents = AbloApiIntents;
970
+ type ApiClaims = AbloApiClaims;
1004
971
  type Capability = import('./ApiClient.js').Capability;
1005
972
  type CapabilityCreateOptions = import('./ApiClient.js').CapabilityCreateOptions;
1006
973
  type CapabilityRecord = import('./ApiClient.js').CapabilityRecord;
@@ -1015,13 +982,13 @@ export declare namespace Ablo {
1015
982
  type TargetRange = _Streams.TargetRange;
1016
983
  type Duration = _Streams.Duration;
1017
984
  type PresenceStream = _Streams.PresenceStream;
1018
- type IntentStream = _Streams.IntentStream;
985
+ type ClaimStream = _Streams.ClaimStream;
1019
986
  type Peer = _Streams.Peer;
1020
987
  type Activity = _Streams.Activity;
1021
- type ActiveIntent = _Streams.ActiveIntent;
1022
- type Claim = _Streams.Claim;
1023
- type IntentRejection = _Streams.IntentRejection;
1024
- type IntentLost = _Streams.IntentLost;
988
+ type ActiveClaim = _Streams.ActiveClaim;
989
+ type ClaimHandle = _Streams.ClaimHandle;
990
+ type ClaimRejection = _Streams.ClaimRejection;
991
+ type ClaimLost = _Streams.ClaimLost;
1025
992
  type Snapshot<TSchema extends _SchemaTypes.Schema = _SchemaTypes.Schema, K extends keyof TSchema['models'] = keyof TSchema['models']> = _Streams.Snapshot<TSchema, K>;
1026
993
  namespace Auth {
1027
994
  type Principal = _Streams.Principal;
@@ -1057,11 +1024,11 @@ export declare namespace Ablo {
1057
1024
  type Receipt = import('./Ablo.js').CommitReceipt;
1058
1025
  type Client = import('./Ablo.js').CommitResource;
1059
1026
  }
1060
- namespace Intent {
1061
- type Handle = import('./Ablo.js').IntentHandle;
1062
- type CreateOptions = import('./Ablo.js').IntentCreateOptions;
1063
- type WaitOptions = import('./Ablo.js').IntentWaitOptions;
1064
- type Client = import('./Ablo.js').IntentResource;
1027
+ namespace Claim {
1028
+ type Handle = import('./Ablo.js').ClaimHandle;
1029
+ type CreateOptions = import('./Ablo.js').ClaimCreateOptions;
1030
+ type WaitOptions = import('./Ablo.js').ClaimWaitOptions;
1031
+ type Client = import('./Ablo.js').ClaimResource;
1065
1032
  }
1066
1033
  namespace Model {
1067
1034
  type Target = import('./Ablo.js').ModelTarget;