@abloatai/ablo 0.10.0 → 0.11.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.
- package/CHANGELOG.md +16 -0
- package/README.md +2 -1
- package/dist/BaseSyncedStore.d.ts +75 -0
- package/dist/BaseSyncedStore.js +193 -8
- package/dist/Database.d.ts +10 -2
- package/dist/Database.js +15 -1
- package/dist/SyncClient.d.ts +12 -1
- package/dist/SyncClient.js +110 -26
- package/dist/agent/Agent.d.ts +9 -9
- package/dist/agent/Agent.js +16 -16
- package/dist/agent/index.d.ts +1 -1
- package/dist/agent/index.js +2 -2
- package/dist/agent/types.d.ts +1 -1
- package/dist/agent/types.js +1 -1
- package/dist/ai-sdk/{intent-broadcast.d.ts → claim-broadcast.d.ts} +10 -10
- package/dist/ai-sdk/{intent-broadcast.js → claim-broadcast.js} +6 -6
- package/dist/ai-sdk/coordination-context.d.ts +9 -9
- package/dist/ai-sdk/coordination-context.js +8 -8
- package/dist/ai-sdk/index.d.ts +1 -1
- package/dist/ai-sdk/index.js +1 -1
- package/dist/ai-sdk/wrap.d.ts +4 -4
- package/dist/ai-sdk/wrap.js +4 -4
- package/dist/api/index.d.ts +2 -2
- package/dist/cli.cjs +254 -48
- package/dist/client/Ablo.d.ts +30 -63
- package/dist/client/Ablo.js +108 -102
- package/dist/client/ApiClient.d.ts +6 -5
- package/dist/client/ApiClient.js +83 -62
- package/dist/client/createModelProxy.d.ts +16 -54
- package/dist/client/createModelProxy.js +44 -16
- package/dist/client/httpClient.d.ts +2 -0
- package/dist/client/httpClient.js +1 -1
- package/dist/client/index.d.ts +3 -3
- package/dist/client/writeOptionsSchema.d.ts +4 -4
- package/dist/client/writeOptionsSchema.js +4 -4
- package/dist/coordination/schema.d.ts +249 -38
- package/dist/coordination/schema.js +172 -39
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +4 -4
- package/dist/errorCodes.d.ts +9 -9
- package/dist/errorCodes.js +15 -15
- package/dist/errors.d.ts +51 -2
- package/dist/errors.js +94 -5
- package/dist/interfaces/index.d.ts +8 -4
- package/dist/policy/index.d.ts +1 -1
- package/dist/policy/types.d.ts +13 -13
- package/dist/policy/types.js +8 -8
- package/dist/react/AbloProvider.d.ts +51 -4
- package/dist/react/AbloProvider.js +95 -11
- package/dist/react/context.d.ts +26 -9
- package/dist/react/context.js +2 -2
- package/dist/react/index.d.ts +4 -4
- package/dist/react/index.js +4 -4
- package/dist/react/useAblo.js +5 -5
- package/dist/react/{useIntent.d.ts → useClaim.d.ts} +9 -9
- package/dist/react/useClaim.js +42 -0
- package/dist/schema/index.js +1 -1
- package/dist/schema/sugar.d.ts +3 -3
- package/dist/schema/sugar.js +3 -3
- package/dist/schema/sync-delta-wire.d.ts +8 -8
- package/dist/server/commit.d.ts +2 -2
- package/dist/sync/AreaOfInterestManager.d.ts +162 -0
- package/dist/sync/AreaOfInterestManager.js +233 -0
- package/dist/sync/BootstrapHelper.d.ts +9 -1
- package/dist/sync/BootstrapHelper.js +15 -5
- package/dist/sync/NetworkProbe.d.ts +1 -1
- package/dist/sync/NetworkProbe.js +1 -1
- package/dist/sync/SyncWebSocket.d.ts +59 -25
- package/dist/sync/SyncWebSocket.js +123 -26
- package/dist/sync/awaitClaimGrant.d.ts +40 -0
- package/dist/sync/awaitClaimGrant.js +86 -0
- package/dist/sync/createClaimStream.d.ts +34 -0
- package/dist/sync/{createIntentStream.js → createClaimStream.js} +92 -81
- package/dist/sync/createPresenceStream.js +3 -2
- package/dist/sync/participants.d.ts +10 -10
- package/dist/sync/participants.js +17 -10
- package/dist/sync/schemas.d.ts +8 -8
- package/dist/transactions/TransactionQueue.d.ts +12 -0
- package/dist/transactions/TransactionQueue.js +126 -8
- package/dist/types/global.d.ts +10 -10
- package/dist/types/global.js +3 -3
- package/dist/types/index.d.ts +9 -7
- package/dist/types/index.js +2 -2
- package/dist/types/streams.d.ts +114 -98
- package/dist/types/streams.js +1 -1
- package/dist/utils/asyncIterator.d.ts +1 -1
- package/dist/utils/asyncIterator.js +1 -1
- package/dist/wire/frames.d.ts +2 -2
- package/docs/migration.md +52 -0
- package/package.json +3 -2
- package/dist/react/useIntent.js +0 -42
- package/dist/sync/awaitIntentGrant.d.ts +0 -40
- package/dist/sync/awaitIntentGrant.js +0 -62
- package/dist/sync/createIntentStream.d.ts +0 -34
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `awaitIntentGrant` — the client side of the fair-queue handover.
|
|
3
|
-
*
|
|
4
|
-
* When a `claim` is contended, the server enqueues it and replies `queued`
|
|
5
|
-
* (HTTP 202 on `/v1/intents`, or `intent_queued` over WS). The grant is then
|
|
6
|
-
* PUSHED later over the WS as `intent_granted` when the claim reaches the head.
|
|
7
|
-
* This resolves once that frame arrives for our `intentId` — so the caller's
|
|
8
|
-
* `claim` promise stays pending (event-driven; no poll, no race) until it's
|
|
9
|
-
* actually our turn. Rejects on `intent_lost` (surfaced as `claim_lost`: the claim was taken away — TTL
|
|
10
|
-
* lapse on disconnect, revoke) or an optional timeout.
|
|
11
|
-
*
|
|
12
|
-
* Takes only a minimal `{ subscribe }` transport so it unit-tests against a
|
|
13
|
-
* fake; `SyncWebSocket` satisfies it structurally.
|
|
14
|
-
*/
|
|
15
|
-
import { AbloClaimedError } from '../errors.js';
|
|
16
|
-
export function awaitIntentGrant(transport, intentId, options) {
|
|
17
|
-
return new Promise((resolve, reject) => {
|
|
18
|
-
const unsubs = [];
|
|
19
|
-
let timer;
|
|
20
|
-
const settle = (fn) => {
|
|
21
|
-
if (timer)
|
|
22
|
-
clearTimeout(timer);
|
|
23
|
-
for (const u of unsubs)
|
|
24
|
-
u();
|
|
25
|
-
fn();
|
|
26
|
-
};
|
|
27
|
-
// The target was free → `intent_acquired` (immediate); it was contended,
|
|
28
|
-
// we waited in line, and reached the head → `intent_granted`. Either frame
|
|
29
|
-
// means the lease is now ours; `waited` records which path it was.
|
|
30
|
-
unsubs.push(transport.subscribe('intent_acquired', (p) => {
|
|
31
|
-
if (p?.intentId === intentId)
|
|
32
|
-
settle(() => resolve({ waited: false }));
|
|
33
|
-
}));
|
|
34
|
-
unsubs.push(transport.subscribe('intent_granted', (p) => {
|
|
35
|
-
if (p?.intentId === intentId)
|
|
36
|
-
settle(() => resolve({ waited: true }));
|
|
37
|
-
}));
|
|
38
|
-
if (options?.maxQueueDepth !== undefined) {
|
|
39
|
-
const max = options.maxQueueDepth;
|
|
40
|
-
unsubs.push(transport.subscribe('intent_queued', (p) => {
|
|
41
|
-
if (p?.intentId !== intentId)
|
|
42
|
-
return;
|
|
43
|
-
const position = typeof p.position === 'number' ? p.position : 0;
|
|
44
|
-
if (position >= max) {
|
|
45
|
-
settle(() => reject(new AbloClaimedError(`Claim queue for ${intentId} is ${position} deep (max ${max}).`, { code: 'queue_too_deep' })));
|
|
46
|
-
}
|
|
47
|
-
}));
|
|
48
|
-
}
|
|
49
|
-
unsubs.push(transport.subscribe('intent_lost', (p) => {
|
|
50
|
-
if (p?.intentId === intentId) {
|
|
51
|
-
settle(() => reject(new AbloClaimedError(`Claim lost while queued for ${intentId}.`, {
|
|
52
|
-
code: 'claim_lost',
|
|
53
|
-
})));
|
|
54
|
-
}
|
|
55
|
-
}));
|
|
56
|
-
if (options?.timeoutMs && options.timeoutMs > 0) {
|
|
57
|
-
timer = setTimeout(() => {
|
|
58
|
-
settle(() => reject(new AbloClaimedError(`Timed out waiting for the queue grant on claim ${intentId}.`, { code: 'grant_timeout' })));
|
|
59
|
-
}, options.timeoutMs);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Transport-driven IntentStream factory.
|
|
3
|
-
*
|
|
4
|
-
* Mirrors `createPresenceStream` — built directly on `SyncWebSocket`,
|
|
5
|
-
* no SyncAgent wrapper. Intents derive their `others` view from the
|
|
6
|
-
* same `presence_update` frames the presence stream consumes (the
|
|
7
|
-
* Hub piggybacks `activeIntents` on every presence frame). Outbound
|
|
8
|
-
* announce/revoke ride the same socket via `intent_begin` /
|
|
9
|
-
* `intent_abandon` frames.
|
|
10
|
-
*
|
|
11
|
-
* Wire contract (apps/sync-server/src/hub/types.ts):
|
|
12
|
-
* • Outbound: `{ type: 'intent_begin', payload: { intentId,
|
|
13
|
-
* entityType, entityId, action, field?, estimatedMs? } }`
|
|
14
|
-
* • Outbound: `{ type: 'intent_abandon', payload: { intentId,
|
|
15
|
-
* entityType?, entityId? } }`
|
|
16
|
-
* • Inbound (via presence): `event.activeIntents: IntentClaim[]`
|
|
17
|
-
* stamped with `declaredAt`, `expiresAt`.
|
|
18
|
-
* • Inbound: `intent_rejected` event with conflict metadata.
|
|
19
|
-
*
|
|
20
|
-
* After the dual-engine collapse (step #36), this is the only
|
|
21
|
-
* IntentStream factory in the SDK; the older compatibility path
|
|
22
|
-
* deletes.
|
|
23
|
-
*/
|
|
24
|
-
import type { SyncWebSocket } from './SyncWebSocket.js';
|
|
25
|
-
import type { IntentStream } from '../types/streams.js';
|
|
26
|
-
export interface IntentStreamConfig {
|
|
27
|
-
/** Identity used to filter our own active intents out of `others`. */
|
|
28
|
-
participantId: string;
|
|
29
|
-
}
|
|
30
|
-
export interface AttachableIntentStream extends IntentStream {
|
|
31
|
-
attach(transport: SyncWebSocket): void;
|
|
32
|
-
dispose(): void;
|
|
33
|
-
}
|
|
34
|
-
export declare function createIntentStream(config: IntentStreamConfig, transport?: SyncWebSocket | null): AttachableIntentStream;
|