@abloatai/ablo 0.5.1 → 0.7.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 (129) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/README.md +248 -124
  3. package/dist/BaseSyncedStore.d.ts +3 -3
  4. package/dist/BaseSyncedStore.js +3 -3
  5. package/dist/api/index.d.ts +3 -3
  6. package/dist/api/index.js +1 -1
  7. package/dist/client/Ablo.d.ts +91 -93
  8. package/dist/client/Ablo.js +122 -60
  9. package/dist/client/ApiClient.d.ts +14 -14
  10. package/dist/client/ApiClient.js +81 -55
  11. package/dist/client/createInternalComponents.d.ts +2 -3
  12. package/dist/client/createInternalComponents.js +2 -3
  13. package/dist/client/createModelProxy.d.ts +116 -90
  14. package/dist/client/createModelProxy.js +128 -128
  15. package/dist/client/index.d.ts +6 -7
  16. package/dist/client/index.js +4 -5
  17. package/dist/client/validateAbloOptions.js +5 -5
  18. package/dist/coordination/index.d.ts +6 -0
  19. package/dist/coordination/index.js +6 -0
  20. package/dist/coordination/schema.d.ts +329 -0
  21. package/dist/coordination/schema.js +209 -0
  22. package/dist/core/QueryView.d.ts +4 -1
  23. package/dist/core/QueryView.js +1 -1
  24. package/dist/core/index.d.ts +2 -0
  25. package/dist/core/index.js +7 -0
  26. package/dist/core/query-utils.d.ts +7 -10
  27. package/dist/core/query-utils.js +2 -3
  28. package/dist/errorCodes.d.ts +264 -0
  29. package/dist/errorCodes.js +251 -0
  30. package/dist/errors.d.ts +59 -14
  31. package/dist/errors.js +73 -12
  32. package/dist/index.d.ts +11 -9
  33. package/dist/index.js +8 -12
  34. package/dist/interfaces/index.d.ts +2 -10
  35. package/dist/mutators/Transaction.d.ts +2 -2
  36. package/dist/mutators/Transaction.js +2 -2
  37. package/dist/mutators/mutateActions.d.ts +44 -0
  38. package/dist/{react/useMutate.js → mutators/mutateActions.js} +11 -28
  39. package/dist/mutators/readerActions.d.ts +32 -0
  40. package/dist/{react/useReader.js → mutators/readerActions.js} +2 -18
  41. package/dist/policy/index.d.ts +1 -1
  42. package/dist/policy/index.js +1 -1
  43. package/dist/policy/types.d.ts +31 -0
  44. package/dist/policy/types.js +15 -0
  45. package/dist/query/types.d.ts +1 -1
  46. package/dist/react/AbloProvider.d.ts +13 -1
  47. package/dist/react/AbloProvider.js +14 -6
  48. package/dist/react/context.d.ts +4 -4
  49. package/dist/react/index.d.ts +4 -5
  50. package/dist/react/index.js +3 -7
  51. package/dist/react/useAblo.d.ts +14 -14
  52. package/dist/react/useAblo.js +26 -26
  53. package/dist/react/useIntent.d.ts +2 -2
  54. package/dist/react/useIntent.js +2 -2
  55. package/dist/react/useMutators.d.ts +1 -1
  56. package/dist/react/usePresence.d.ts +3 -3
  57. package/dist/react/usePresence.js +4 -4
  58. package/dist/react/useUndoScope.d.ts +1 -1
  59. package/dist/schema/ddl.d.ts +62 -0
  60. package/dist/schema/ddl.js +317 -0
  61. package/dist/schema/diff.d.ts +167 -0
  62. package/dist/schema/diff.js +280 -0
  63. package/dist/schema/field.d.ts +16 -19
  64. package/dist/schema/field.js +30 -17
  65. package/dist/schema/generate.d.ts +19 -0
  66. package/dist/schema/generate.js +87 -0
  67. package/dist/schema/index.d.ts +9 -3
  68. package/dist/schema/index.js +14 -2
  69. package/dist/schema/model.d.ts +87 -25
  70. package/dist/schema/model.js +33 -3
  71. package/dist/schema/relation.d.ts +17 -0
  72. package/dist/schema/roles.d.ts +148 -0
  73. package/dist/schema/roles.js +149 -0
  74. package/dist/schema/schema.d.ts +10 -69
  75. package/dist/schema/schema.js +58 -24
  76. package/dist/schema/select.d.ts +25 -0
  77. package/dist/schema/select.js +55 -0
  78. package/dist/schema/serialize.d.ts +96 -0
  79. package/dist/schema/serialize.js +231 -0
  80. package/dist/schema/sugar.d.ts +20 -3
  81. package/dist/schema/sugar.js +5 -1
  82. package/dist/schema/tenancy.d.ts +66 -0
  83. package/dist/schema/tenancy.js +58 -0
  84. package/dist/sync/HydrationCoordinator.d.ts +2 -0
  85. package/dist/sync/HydrationCoordinator.js +23 -17
  86. package/dist/sync/SyncWebSocket.d.ts +17 -0
  87. package/dist/sync/SyncWebSocket.js +46 -1
  88. package/dist/sync/awaitIntentGrant.d.ts +26 -0
  89. package/dist/sync/awaitIntentGrant.js +60 -0
  90. package/dist/sync/createIntentStream.d.ts +2 -1
  91. package/dist/sync/createIntentStream.js +89 -5
  92. package/dist/sync/createPresenceStream.js +1 -1
  93. package/dist/sync/participants.d.ts +2 -2
  94. package/dist/sync/participants.js +9 -18
  95. package/dist/types/global.d.ts +43 -52
  96. package/dist/types/global.js +16 -18
  97. package/dist/types/streams.d.ts +90 -42
  98. package/docs/api-keys.md +44 -0
  99. package/docs/api.md +72 -173
  100. package/docs/audit.md +5 -5
  101. package/docs/cli.md +212 -0
  102. package/docs/client-behavior.md +42 -43
  103. package/docs/coordination.md +343 -0
  104. package/docs/data-sources.md +16 -16
  105. package/docs/examples/agent-human.md +30 -32
  106. package/docs/examples/ai-sdk-tool.md +32 -33
  107. package/docs/examples/existing-python-backend.md +38 -36
  108. package/docs/examples/nextjs.md +24 -25
  109. package/docs/examples/scoped-agent.md +78 -0
  110. package/docs/examples/server-agent.md +20 -61
  111. package/docs/guarantees.md +34 -56
  112. package/docs/identity.md +529 -0
  113. package/docs/index.md +18 -24
  114. package/docs/integration-guide.md +130 -144
  115. package/docs/interaction-model.md +32 -95
  116. package/docs/mcp/claude-code.md +3 -3
  117. package/docs/mcp/cursor.md +1 -1
  118. package/docs/mcp/windsurf.md +1 -1
  119. package/docs/mcp.md +11 -26
  120. package/docs/quickstart.md +43 -49
  121. package/docs/react.md +74 -24
  122. package/docs/roadmap.md +17 -7
  123. package/llms.txt +34 -39
  124. package/package.json +8 -1
  125. package/dist/react/useMutate.d.ts +0 -83
  126. package/dist/react/useQuery.d.ts +0 -123
  127. package/dist/react/useQuery.js +0 -145
  128. package/dist/react/useReader.d.ts +0 -69
  129. package/docs/capabilities.md +0 -163
@@ -1,6 +1,6 @@
1
1
  # Guarantees
2
2
 
3
- This page is the short contract for what Ablo Sync guarantees at the state
3
+ This page is the short contract for what Ablo guarantees at the state
4
4
  boundary.
5
5
 
6
6
  ## Confirmed Writes
@@ -9,19 +9,18 @@ boundary.
9
9
  the authoritative sync cursor.
10
10
 
11
11
  ```ts
12
- const updated = await ablo.tasks.update(
13
- 'task_123',
14
- { status: 'done' },
12
+ const updated = await ablo.weatherReports.update(
13
+ 'report_stockholm',
14
+ { status: 'ready' },
15
15
  { wait: 'confirmed' },
16
16
  );
17
17
  ```
18
18
 
19
19
  If the call resolves, the write was accepted by the server. If it rejects, the
20
20
  error explains whether the write was rejected for auth, validation, stale state,
21
- active intent conflict, idempotency, rate limit, or transport failure.
21
+ active claim conflict, idempotency, rate limit, or transport failure.
22
22
 
23
- Schema model writes return the updated model row. Advanced resource writes and
24
- `commits.create(...)` return a receipt with the commit status and sync cursor.
23
+ Schema model writes return the updated model row.
25
24
 
26
25
  ## Optimistic Local State
27
26
 
@@ -42,11 +41,11 @@ Use `snapshot(...)` and `readAt` when a write depends on state the agent already
42
41
  read:
43
42
 
44
43
  ```ts
45
- const snap = ablo.snapshot({ tasks: 'task_123' });
44
+ const snap = ablo.snapshot({ weatherReports: 'report_stockholm' });
46
45
 
47
- await ablo.tasks.update(
48
- 'task_123',
49
- { status: 'done' },
46
+ await ablo.weatherReports.update(
47
+ 'report_stockholm',
48
+ { status: 'ready' },
50
49
  { readAt: snap.stamp, onStale: 'reject', wait: 'confirmed' },
51
50
  );
52
51
  ```
@@ -61,45 +60,30 @@ Advanced policies exist for controlled product flows:
61
60
  - `flag` accepts the write and marks it for product review.
62
61
  - `merge` is reserved for server-defined merge behavior.
63
62
 
64
- ## Intent Coordination
63
+ ## Claim Coordination
65
64
 
66
- Intents are live coordination signals. They are not database locks.
65
+ > The guarantee, not the how-to. Methods, the claim-state object, and the `queue`
66
+ > live in [Coordination](./coordination.md).
67
67
 
68
- When another human or agent is active on the same target, the caller chooses the
69
- behavior:
68
+ Claims are live coordination signals. They are not database locks.
70
69
 
71
- - `ifBusy: 'return'` returns active intents immediately.
72
- - `ifBusy: 'wait'` waits until the matching intent clears.
73
- - `ifBusy: 'fail'` throws `AbloBusyError` with the active intents attached.
70
+ Claims are **advisory** and **cooperative**. `ablo.<model>.claim(id, ...)`
71
+ serializes on contention: if another human or agent already holds the row, the
72
+ claim waits for them to finish, then re-reads the row before handing it back, so
73
+ you proceed from fresh state. Reads are open by default —
74
+ `ablo.<model>.claimState(id)` returns the current claim state (or `null`) without
75
+ ever blocking. Server/model reads can opt into `ifClaimed: 'wait'` or
76
+ `ifClaimed: 'fail'` when they should not read through active work.
74
77
 
75
- Schema clients wait from the realtime intent stream. Schema-less HTTP callers
76
- must pass an explicit `busyPollInterval` if they choose `ifBusy: 'wait'`; Ablo
77
- does not hide a hard-coded polling loop. `busyTimeout` is only a maximum wait.
78
+ A claim does not reject or block other writers; it announces work so peers
79
+ serialize behind it rather than racing. While you hold a claim, the matching
80
+ `ablo.<model>.update(id, ...)` is stale-guarded and rejects with
81
+ `AbloStaleContextError` if the row advanced past your claim point.
78
82
 
79
83
  ## Agent Runs
80
84
 
81
- `agent.run(...)` is the advanced schema-less run envelope for workers that cannot
82
- import the app schema. It returns one of three statuses:
83
-
84
- - `done` — the handler returned successfully.
85
- - `failed` — the handler threw or the commit failed.
86
- - `cancelled` — the run signal aborted.
87
-
88
- Normal schema-backed agents should import the same schema as the app and write
89
- through `ablo.<model>.update(...)`. The lower-level run envelope exists for
90
- platform runtimes that need capability and task management without app code.
91
-
92
- ## Capabilities and Tasks
93
-
94
- Capabilities scope what an agent is allowed to do. Tasks group a run for audit
95
- and cost attribution.
96
-
97
- Most users do not create either one manually. The SDK and hosted API manage the
98
- common case. Manual capability and task APIs are for platform builders, custom
99
- agent runtimes, and internal infrastructure.
100
-
101
- Use `lease` as a crash cleanup window. A successful agent run still closes when
102
- the handler returns, fails, or is cancelled.
85
+ Agents should import the same schema as the app and write through
86
+ `ablo.<model>.claim(...)` plus `ablo.<model>.update(...)`.
103
87
 
104
88
  ## Audit Trail
105
89
 
@@ -107,19 +91,17 @@ Accepted writes can be attributed to:
107
91
 
108
92
  - the actor that wrote,
109
93
  - the human or system the actor worked on behalf of,
110
- - the capability that scoped the write,
111
- - the task or run that caused it,
112
- - the resource, operation, and state cursor.
94
+ - the model, operation, and state cursor.
113
95
 
114
96
  For agent work, this is what lets an audit surface answer: "what changed, who
115
97
  authorized it, which run did it, and what state was it based on?"
116
98
 
117
99
  ## Persistence
118
100
 
119
- Ablo defaults to volatile local persistence. That keeps the SDK focused on
101
+ Ablo defaults to volatile in-memory persistence. That keeps the SDK focused on
120
102
  coordination and audit instead of silently becoming a browser storage product.
121
103
 
122
- Opt into durable browser cache and offline queueing when you need it:
104
+ Opt into a durable browser cache that survives reloads when you need it:
123
105
 
124
106
  ```ts
125
107
  const ablo = Ablo({
@@ -137,12 +119,8 @@ Ablo does not need a customer database URL. When your own database is canonical,
137
119
  Ablo calls a signed Data Source endpoint and records the coordination result for
138
120
  receipts, realtime fanout, and audit. See [Connect Your Database](./data-sources.md).
139
121
 
140
- ## Batches
141
-
142
- Most apps should use `ablo.<model>.create/update/delete`. Use
143
- `commits.create(...)` only when you need a low-level batch or a schema-less
144
- runtime.
122
+ ## Writes
145
123
 
146
- Each operation in the commit carries its own target, data, stale policy, and
147
- idempotency context. The server validates authorization, stale state, active
148
- intent conflicts, and idempotency before accepting the commit.
124
+ Use `ablo.<model>.create/update/delete` for state changes. The server validates
125
+ authorization, stale state, active claim conflicts, and idempotency before
126
+ accepting the write.