@abloatai/ablo 0.6.0 → 0.8.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 (121) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/README.md +95 -57
  3. package/dist/BaseSyncedStore.d.ts +1 -1
  4. package/dist/BaseSyncedStore.js +8 -4
  5. package/dist/SyncEngineContext.d.ts +2 -1
  6. package/dist/SyncEngineContext.js +5 -3
  7. package/dist/agent/session.js +3 -2
  8. package/dist/auth/index.js +39 -11
  9. package/dist/client/Ablo.d.ts +112 -3
  10. package/dist/client/Ablo.js +144 -10
  11. package/dist/client/ApiClient.d.ts +32 -0
  12. package/dist/client/ApiClient.js +76 -44
  13. package/dist/client/auth.d.ts +11 -1
  14. package/dist/client/auth.js +21 -2
  15. package/dist/client/createModelProxy.d.ts +120 -53
  16. package/dist/client/createModelProxy.js +66 -31
  17. package/dist/client/identity.js +14 -0
  18. package/dist/client/registerDataSource.d.ts +19 -0
  19. package/dist/client/registerDataSource.js +57 -0
  20. package/dist/client/validateAbloOptions.d.ts +2 -1
  21. package/dist/client/validateAbloOptions.js +8 -7
  22. package/dist/coordination/index.d.ts +6 -0
  23. package/dist/coordination/index.js +6 -0
  24. package/dist/coordination/schema.d.ts +329 -0
  25. package/dist/coordination/schema.js +209 -0
  26. package/dist/core/QueryView.d.ts +4 -1
  27. package/dist/core/QueryView.js +1 -1
  28. package/dist/core/query-utils.d.ts +7 -10
  29. package/dist/core/query-utils.js +2 -3
  30. package/dist/errorCodes.d.ts +286 -0
  31. package/dist/errorCodes.js +284 -0
  32. package/dist/errors.d.ts +103 -7
  33. package/dist/errors.js +192 -41
  34. package/dist/index.d.ts +11 -6
  35. package/dist/index.js +10 -6
  36. package/dist/keys/index.d.ts +61 -0
  37. package/dist/keys/index.js +151 -0
  38. package/dist/policy/index.d.ts +1 -1
  39. package/dist/policy/index.js +1 -1
  40. package/dist/policy/types.d.ts +31 -0
  41. package/dist/policy/types.js +15 -0
  42. package/dist/query/client.js +19 -8
  43. package/dist/react/AbloProvider.d.ts +37 -0
  44. package/dist/react/AbloProvider.js +107 -4
  45. package/dist/react/ClientSideSuspense.d.ts +1 -1
  46. package/dist/react/DefaultFallback.d.ts +1 -1
  47. package/dist/react/SyncGroupProvider.d.ts +1 -1
  48. package/dist/react/index.d.ts +3 -2
  49. package/dist/react/index.js +3 -2
  50. package/dist/react/useAblo.d.ts +4 -4
  51. package/dist/react/useAblo.js +10 -5
  52. package/dist/react/useReactive.js +16 -3
  53. package/dist/schema/ddl.d.ts +62 -0
  54. package/dist/schema/ddl.js +317 -0
  55. package/dist/schema/diff.d.ts +6 -0
  56. package/dist/schema/diff.js +21 -3
  57. package/dist/schema/field.d.ts +16 -19
  58. package/dist/schema/field.js +30 -17
  59. package/dist/schema/index.d.ts +7 -4
  60. package/dist/schema/index.js +9 -3
  61. package/dist/schema/model.d.ts +87 -25
  62. package/dist/schema/model.js +33 -3
  63. package/dist/schema/relation.d.ts +17 -0
  64. package/dist/schema/roles.d.ts +148 -0
  65. package/dist/schema/roles.js +149 -0
  66. package/dist/schema/schema.d.ts +2 -112
  67. package/dist/schema/schema.js +50 -62
  68. package/dist/schema/select.d.ts +25 -0
  69. package/dist/schema/select.js +55 -0
  70. package/dist/schema/serialize.d.ts +16 -12
  71. package/dist/schema/serialize.js +16 -12
  72. package/dist/schema/sugar.d.ts +20 -3
  73. package/dist/schema/sugar.js +5 -1
  74. package/dist/schema/tenancy.d.ts +66 -0
  75. package/dist/schema/tenancy.js +58 -0
  76. package/dist/sync/BootstrapHelper.js +46 -27
  77. package/dist/sync/ConnectionManager.d.ts +3 -1
  78. package/dist/sync/ConnectionManager.js +37 -1
  79. package/dist/sync/HydrationCoordinator.d.ts +2 -0
  80. package/dist/sync/HydrationCoordinator.js +26 -19
  81. package/dist/sync/NetworkProbe.d.ts +8 -0
  82. package/dist/sync/NetworkProbe.js +24 -2
  83. package/dist/sync/SyncWebSocket.d.ts +1 -1
  84. package/dist/sync/SyncWebSocket.js +43 -53
  85. package/dist/sync/createIntentStream.d.ts +2 -1
  86. package/dist/sync/createIntentStream.js +46 -1
  87. package/dist/sync/participants.js +10 -16
  88. package/dist/transactions/TransactionQueue.js +13 -1
  89. package/dist/types/streams.d.ts +53 -33
  90. package/docs/api-keys.md +47 -3
  91. package/docs/api.md +103 -57
  92. package/docs/audit.md +16 -9
  93. package/docs/cli.md +222 -0
  94. package/docs/client-behavior.md +35 -21
  95. package/docs/coordination.md +74 -36
  96. package/docs/data-sources.md +23 -21
  97. package/docs/examples/agent-human.md +72 -28
  98. package/docs/examples/ai-sdk-tool.md +14 -11
  99. package/docs/examples/existing-python-backend.md +30 -19
  100. package/docs/examples/nextjs.md +21 -8
  101. package/docs/examples/scoped-agent.md +93 -0
  102. package/docs/examples/server-agent.md +27 -5
  103. package/docs/guarantees.md +29 -17
  104. package/docs/identity.md +198 -121
  105. package/docs/index.md +35 -18
  106. package/docs/integration-guide.md +79 -83
  107. package/docs/interaction-model.md +40 -25
  108. package/docs/mcp/claude-code.md +9 -17
  109. package/docs/mcp/cursor.md +6 -24
  110. package/docs/mcp/windsurf.md +6 -19
  111. package/docs/mcp.md +103 -26
  112. package/docs/quickstart.md +31 -39
  113. package/docs/react.md +18 -14
  114. package/docs/roadmap.md +15 -3
  115. package/docs/schema-contract.md +109 -0
  116. package/examples/README.md +8 -4
  117. package/examples/data-source/README.md +6 -2
  118. package/examples/data-source/run.ts +4 -3
  119. package/examples/quickstart.ts +1 -1
  120. package/llms.txt +27 -16
  121. package/package.json +13 -1
package/llms.txt CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Ablo is the state coordination layer for apps where humans and agents edit the same data.
4
4
 
5
+ Here is the problem it solves. Two writers touch `report_stockholm` at once. The agent claims the row, does slow work (an LLM call, a fetch), and commits; the human's UI sees the claim live and never clobbers it. Claims don't lock. If another writer holds the row, `claim` waits for them, re-reads the fresh row, then hands it to you — so two writers serialize instead of clobbering.
6
+
5
7
  Use AI SDK for the agent loop. Use Ablo when agent reads and writes must persist, coordinate with concurrent work, and leave an audit trail.
6
8
 
7
9
  ## Use this API
@@ -21,7 +23,7 @@ const schema = defineSchema({
21
23
 
22
24
  const ablo = Ablo({ schema, apiKey: process.env.ABLO_API_KEY });
23
25
 
24
- const [report] = await ablo.weatherReports.load({ where: { id: 'report_stockholm' } });
26
+ const report = await ablo.weatherReports.retrieve('report_stockholm');
25
27
  if (!report) throw new Error('Row not found');
26
28
 
27
29
  const updated = await ablo.weatherReports.claim('report_stockholm', async (report) => {
@@ -33,20 +35,29 @@ const updated = await ablo.weatherReports.claim('report_stockholm', async (repor
33
35
  });
34
36
  ```
35
37
 
36
- That is the normal app path: declare models in a schema, then use `ablo.<model>.load(...)`, `ablo.<model>.retrieve(...)`, `ablo.<model>.create(...)`, `ablo.<model>.update(...)`, and `ablo.<model>.delete(...)`.
38
+ That is the normal app path: declare models in a schema, then use `ablo.<model>.retrieve(...)`, `ablo.<model>.create(...)`, `ablo.<model>.update(...)`, and `ablo.<model>.delete(...)`.
39
+
40
+ Treat the schema as the integration contract. It drives typed model clients,
41
+ React selectors, server and agent writes, Data Source request/response shape,
42
+ hosted schema push, and schema-version gating. Do not invent a parallel
43
+ string-keyed write path for rows that belong to a schema model.
37
44
 
38
45
  For full integrations, use `integration-guide` as the canonical doc. It covers
39
46
  the same model API across Ablo-managed state, Data Source-backed app databases,
40
47
  React selectors, multiplayer, and future agent workers.
41
48
 
42
- `ablo.<model>.list(...)` and `count(...)` are synchronous local reads. They
43
- accept `where`, `filter`, `orderBy`, `limit`, `offset`, and `scope`; scope
44
- defaults to `'live'`, with `'archived'` and `'all'` for lifecycle-aware reads.
49
+ Reads come in two flavors, and you pick by whether you can wait. `retrieve(id)`
50
+ (one row) and `list({ where })` (many) are async — they hit the server and return
51
+ a Promise, so await them. `get(id)`, `getAll({ where })`, and `getCount({ where })`
52
+ are synchronous — they read the local graph and are reactive in render, so no
53
+ await. The query reads accept `where`, `filter`, `orderBy`, `limit`, `offset`,
54
+ and `state`; state defaults to `'live'`, with `'archived'` and `'all'` to include
55
+ retired rows.
45
56
 
46
- Advanced schema-less agents exist for workers that cannot import the app schema,
47
- but do not teach that path first.
57
+ Workers that can't import the app schema can use a schema-less mode (covered in
58
+ `integration-guide`).
48
59
 
49
- React reads should use selector `useAblo`: `useAblo((ablo) => ablo.weatherReports.retrieve(id))`.
60
+ React reads should use selector `useAblo`: `useAblo((ablo) => ablo.weatherReports.get(id))` (synchronous local read, reactive in render).
50
61
  Use zero-argument `useAblo()` only when a component needs the client for an
51
62
  event handler or effect. Treat `useQuery`, `useOne`, `useReader`, and
52
63
  `useMutate` as compatibility hooks for older string-keyed integrations, not the
@@ -57,7 +68,7 @@ first integration path.
57
68
  Multiplayer is not a separate mode. When human UI, server actions, and agents use
58
69
  the same schema client and write through `ablo.<model>`, Ablo coordinates the
59
70
  shared model stream: confirmed deltas fan out to subscribers, active claims are
60
- visible through `claimState(id)`, and stale writes can be rejected with `readAt`.
71
+ visible through `claim.state(id)`, and stale writes can be rejected with `readAt`.
61
72
 
62
73
  If an app writes directly to its own database outside Ablo, that write bypasses
63
74
  coordination until the app reports it through Data Source events.
@@ -65,7 +76,7 @@ coordination until the app reports it through Data Source events.
65
76
  ## Nouns
66
77
 
67
78
  - `Model client` is the typed `ablo.<model>` object generated from schema.
68
- - `Claim` holds a model row while slow work runs; `claimState(id)` observes it.
79
+ - `Claim` holds a model row while slow work runs; `claim.state(id)` observes it.
69
80
  - `Commit` is the durable protocol write behind `ablo.<model>.update(...)`.
70
81
  - `Receipt` confirms the commit.
71
82
 
@@ -76,23 +87,23 @@ Server reads through `ablo.model(name)` can pass `ifClaimed: 'return'` to
76
87
  receive active claims, `ifClaimed: 'fail'` to throw `AbloClaimedError`, or
77
88
  `ifClaimed: 'wait'` to wait until the active claim clears.
78
89
 
79
- Schema clients wait from the realtime claim stream. Schema-less HTTP callers must provide an explicit `claimedPollInterval` when using `ifClaimed: 'wait'`; Ablo does not hide a hard-coded polling loop.
90
+ Schema clients learn when a claim clears by listening to the live claim stream, so they don't need to poll. Schema-less HTTP callers must provide an explicit `claimedPollInterval` when using `ifClaimed: 'wait'`; Ablo does not hide a hard-coded polling loop.
80
91
 
81
92
  Use `claimedTimeout` only as a maximum wait, not as the coordination mechanism.
82
93
 
83
94
  ## Guarantees
84
95
 
85
- `wait: 'confirmed'` means the server accepted the write. Schema model writes are optimistic by default; server rejection rolls back local state. Use `snapshot(...)` plus `readAt` and `onStale: 'reject'` to prevent lost updates.
96
+ `wait: 'confirmed'` means the server accepted the write. Schema model writes are optimistic by default; server rejection rolls back local state. To prevent lost updates, read with `snapshot(...)` to capture a `readAt`, then write with `onStale: 'reject'` the server rejects your update if someone else changed the row after that `readAt`.
86
97
 
87
98
  Claims coordinate writers; they do not block readers. Most users should stay on
88
- schema-backed reads/writes and `claim(...)`; do not teach manual protocol
89
- bookkeeping in the happy path.
99
+ schema-backed reads/writes and `claim(...)`; manual protocol bookkeeping is not
100
+ part of the happy path.
90
101
 
91
102
  All SDK errors extend `AbloError`. Important classes: `AbloClaimedError`, `AbloStaleContextError`, `AbloAuthenticationError`, `AbloPermissionError`, `AbloRateLimitError`, `AbloIdempotencyError`, `AbloConnectionError`, `AbloValidationError`, and `AbloServerError`.
92
103
 
93
104
  ## Schema Scope
94
105
 
95
- Teach schema as model fields and relations first. Advanced schema helpers such as `mutable`, `readOnly`, `field`, `indexed`, queries, and load strategies exist for offline/cache/indexing-heavy apps, but they should not be the first concept a new integration sees.
106
+ A schema is model fields and relations. Advanced schema helpers such as `mutable`, `readOnly`, `field`, `indexed`, queries, and load strategies exist for offline/cache/indexing-heavy apps; reach for them only after the basic field/relation schema is working.
96
107
 
97
108
  ## Storage Boundary
98
109
 
@@ -135,4 +146,4 @@ Import from these public paths only:
135
146
 
136
147
  Do not teach `/api`, `/agent`, `/ai-sdk`, `/core`, `/realtime`, `/source`, or internal subpaths.
137
148
 
138
- Canonical docs to read before integrating: `quickstart`, `integration-guide`, `guarantees`, `client-behavior`, `data-sources`, `examples/existing-python-backend`, `api`, `examples/ai-sdk-tool`, and `examples/server-agent`.
149
+ Canonical docs to read before integrating: `quickstart`, `schema-contract`, `integration-guide`, `guarantees`, `client-behavior`, `data-sources`, `examples/existing-python-backend`, `api`, `examples/ai-sdk-tool`, and `examples/server-agent`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abloatai/ablo",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "description": "State control API for AI agents and collaborative apps.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -20,6 +20,11 @@
20
20
  "import": "./dist/schema/index.js",
21
21
  "default": "./dist/schema/index.js"
22
22
  },
23
+ "./coordination": {
24
+ "types": "./dist/coordination/index.d.ts",
25
+ "import": "./dist/coordination/index.js",
26
+ "default": "./dist/coordination/index.js"
27
+ },
23
28
  "./react": {
24
29
  "types": "./dist/react/index.d.ts",
25
30
  "import": "./dist/react/index.js",
@@ -49,6 +54,11 @@
49
54
  "types": "./dist/source/index.d.ts",
50
55
  "import": "./dist/source/index.js",
51
56
  "default": "./dist/source/index.js"
57
+ },
58
+ "./keys": {
59
+ "types": "./dist/keys/index.d.ts",
60
+ "import": "./dist/keys/index.js",
61
+ "default": "./dist/keys/index.js"
52
62
  }
53
63
  },
54
64
  "files": [
@@ -71,6 +81,8 @@
71
81
  "build": "npm run clean && tsc -p tsconfig.build.json",
72
82
  "pack:check": "npm_config_cache=${TMPDIR:-/tmp}/ablo-npm-cache npm pack --dry-run",
73
83
  "lint:imports": "node scripts/check-js-extensions.mjs",
84
+ "generate:errors": "tsx scripts/generate-error-docs.mts",
85
+ "lint:errors": "tsx scripts/check-error-docs.mts",
74
86
  "lint:pkg": "publint",
75
87
  "prepublishOnly": "npm run build && npm run lint:pkg",
76
88
  "test": "jest",