@abloatai/ablo 0.11.1 → 0.11.2
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 +34 -0
- package/README.md +10 -2
- package/dist/Model.d.ts +39 -0
- package/dist/Model.js +68 -0
- package/dist/auth/credentialPolicy.d.ts +145 -0
- package/dist/auth/credentialPolicy.js +130 -0
- package/dist/cli.cjs +39 -6
- package/dist/client/Ablo.d.ts +39 -88
- package/dist/client/Ablo.js +38 -98
- package/dist/client/ApiClient.d.ts +10 -1
- package/dist/client/ApiClient.js +19 -11
- package/dist/client/auth.d.ts +12 -5
- package/dist/client/auth.js +2 -1
- package/dist/client/createModelProxy.d.ts +49 -10
- package/dist/client/createModelProxy.js +6 -0
- package/dist/client/httpClient.d.ts +17 -3
- package/dist/client/httpClient.js +1 -0
- package/dist/client/identity.js +134 -122
- package/dist/client/index.d.ts +1 -1
- package/dist/client/sessionMint.d.ts +15 -0
- package/dist/client/sessionMint.js +86 -0
- package/dist/errorCodes.d.ts +2 -0
- package/dist/errorCodes.js +2 -0
- package/dist/errors.d.ts +3 -2
- package/dist/errors.js +3 -2
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -7
- package/dist/mutators/RecordingTransaction.js +14 -42
- package/dist/react/AbloProvider.d.ts +1 -6
- package/dist/react/AbloProvider.js +1 -5
- package/dist/react/context.d.ts +1 -31
- package/dist/react/context.js +2 -2
- package/dist/react/index.d.ts +0 -6
- package/dist/react/index.js +0 -7
- package/dist/react/useSyncStatus.d.ts +1 -1
- package/dist/realtime/index.d.ts +1 -1
- package/dist/schema/generate.js +1 -2
- package/dist/schema/schema.d.ts +13 -2
- package/dist/schema/schema.js +26 -0
- package/dist/surface.d.ts +29 -0
- package/dist/surface.js +60 -0
- package/dist/sync/ConnectionManager.d.ts +16 -5
- package/dist/sync/ConnectionManager.js +42 -7
- package/dist/transactions/TransactionQueue.d.ts +0 -11
- package/dist/transactions/TransactionQueue.js +12 -56
- package/dist/types/global.d.ts +3 -0
- package/dist/types/streams.d.ts +0 -22
- package/dist/utils/mobx-setup.js +1 -0
- package/docs/api-keys.md +49 -0
- package/docs/api.md +3 -2
- package/docs/client-behavior.md +1 -0
- package/docs/coordination.md +75 -21
- package/docs/examples/existing-python-backend.md +9 -5
- package/docs/examples/scoped-agent.md +1 -1
- package/docs/guarantees.md +4 -3
- package/docs/identity.md +89 -82
- package/docs/integration-guide.md +19 -10
- package/docs/migration.md +9 -2
- package/docs/quickstart.md +6 -2
- package/docs/react.md +3 -3
- package/docs/schema-contract.md +23 -5
- package/llms-full.txt +18 -16
- package/llms.txt +6 -6
- package/package.json +1 -1
- package/dist/api/index.d.ts +0 -10
- package/dist/api/index.js +0 -9
- package/dist/principal.d.ts +0 -44
- package/dist/principal.js +0 -49
- package/dist/react/SyncGroupProvider.d.ts +0 -19
- package/dist/react/SyncGroupProvider.js +0 -44
- package/dist/react/useClaim.d.ts +0 -29
- package/dist/react/useClaim.js +0 -42
- package/dist/react/usePresence.d.ts +0 -32
- package/dist/react/usePresence.js +0 -41
package/dist/principal.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Principal constructors — a thin typed façade over the raw
|
|
3
|
-
* `SessionRef` / `AgentRef` shapes so call sites don't have to memorize
|
|
4
|
-
* the discriminated-union tags.
|
|
5
|
-
*
|
|
6
|
-
* ```ts
|
|
7
|
-
* import Ablo, { session } from '@abloatai/ablo';
|
|
8
|
-
*
|
|
9
|
-
* const ablo = Ablo({ schema, apiKey });
|
|
10
|
-
* const participant = await ablo.participants.join({
|
|
11
|
-
* type: 'Matter',
|
|
12
|
-
* id: 'deal-1',
|
|
13
|
-
* });
|
|
14
|
-
* ```
|
|
15
|
-
*
|
|
16
|
-
* Browser-human flows use `session(...)`. Agent-spawn-agent flows use
|
|
17
|
-
* `agent(...)`, but those rarely appear in customer code because the
|
|
18
|
-
* participant layer handles attenuation.
|
|
19
|
-
*
|
|
20
|
-
* These are pure — no I/O, no hidden state. If the shape ever grows a
|
|
21
|
-
* required field (say, a scope hint for the restricted key), the helper
|
|
22
|
-
* is the one place to flag migrations.
|
|
23
|
-
*/
|
|
24
|
-
/**
|
|
25
|
-
* Build a `SessionRef` from the identifiers your auth system already
|
|
26
|
-
* holds. Typical inputs: the Better Auth session id, the user id, and
|
|
27
|
-
* the organization the session is scoped to.
|
|
28
|
-
*/
|
|
29
|
-
export function session(params) {
|
|
30
|
-
return {
|
|
31
|
-
kind: 'session',
|
|
32
|
-
id: params.id,
|
|
33
|
-
userId: params.userId,
|
|
34
|
-
organizationId: params.organizationId,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Build an `AgentRef` from an agent id + the capability token that
|
|
39
|
-
* authenticates it. Rare in application code — the common path is
|
|
40
|
-
* `participant.join(child)` where the parent's token is attenuated
|
|
41
|
-
* automatically.
|
|
42
|
-
*/
|
|
43
|
-
export function agent(params) {
|
|
44
|
-
return {
|
|
45
|
-
kind: 'agent',
|
|
46
|
-
id: params.id,
|
|
47
|
-
capabilityToken: params.capabilityToken,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
2
|
-
export interface SyncGroupProviderProps {
|
|
3
|
-
/** The sync-group identifier — e.g., `matter:abc-123`, `deck:xyz`. */
|
|
4
|
-
id: string;
|
|
5
|
-
children: ReactNode;
|
|
6
|
-
}
|
|
7
|
-
export declare function SyncGroupProvider({ id, children }: SyncGroupProviderProps): import("react").JSX.Element;
|
|
8
|
-
/**
|
|
9
|
-
* Returns the ID of the nearest `<SyncGroupProvider>`. Throws if
|
|
10
|
-
* called outside one — sync-group awareness is mandatory by design,
|
|
11
|
-
* so the error points the consumer at the provider instead of
|
|
12
|
-
* returning undefined and letting downstream code silently miss scope.
|
|
13
|
-
*
|
|
14
|
-
* If a component legitimately renders both inside and outside a
|
|
15
|
-
* group, structure the tree so the hook is only called on the
|
|
16
|
-
* inside path (e.g., split into two components). Silent nulls are
|
|
17
|
-
* never the right answer.
|
|
18
|
-
*/
|
|
19
|
-
export declare function useSyncGroup(): string;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { createContext, useContext, useMemo } from 'react';
|
|
4
|
-
import { AbloValidationError } from '../errors.js';
|
|
5
|
-
/**
|
|
6
|
-
* Narrow context for a per-entity sync-group scope. Maps directly onto
|
|
7
|
-
* Liveblocks' `<RoomProvider id="...">`: wrap a subtree, and any hooks
|
|
8
|
-
* inside can read `useSyncGroup()` to discover "which entity am I
|
|
9
|
-
* scoped to?" without threading the ID through props.
|
|
10
|
-
*
|
|
11
|
-
* Typical IDs follow the multiplayer sync-group convention: `matter:<id>`,
|
|
12
|
-
* `deck:<id>`, `project:<id>`. The ID is an opaque string — the
|
|
13
|
-
* provider doesn't parse it.
|
|
14
|
-
*
|
|
15
|
-
* v0.3.0 scope: this is a thin passthrough. Future versions will
|
|
16
|
-
* scope `useQuery` / `useOne` results to the group automatically.
|
|
17
|
-
*/
|
|
18
|
-
const SyncGroupContext = createContext(null);
|
|
19
|
-
export function SyncGroupProvider({ id, children }) {
|
|
20
|
-
// Stabilize the context value so consumers memoized on it don't
|
|
21
|
-
// re-render when the provider re-renders for unrelated reasons.
|
|
22
|
-
const value = useMemo(() => id, [id]);
|
|
23
|
-
return _jsx(SyncGroupContext.Provider, { value: value, children: children });
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Returns the ID of the nearest `<SyncGroupProvider>`. Throws if
|
|
27
|
-
* called outside one — sync-group awareness is mandatory by design,
|
|
28
|
-
* so the error points the consumer at the provider instead of
|
|
29
|
-
* returning undefined and letting downstream code silently miss scope.
|
|
30
|
-
*
|
|
31
|
-
* If a component legitimately renders both inside and outside a
|
|
32
|
-
* group, structure the tree so the hook is only called on the
|
|
33
|
-
* inside path (e.g., split into two components). Silent nulls are
|
|
34
|
-
* never the right answer.
|
|
35
|
-
*/
|
|
36
|
-
export function useSyncGroup() {
|
|
37
|
-
const id = useContext(SyncGroupContext);
|
|
38
|
-
if (!id) {
|
|
39
|
-
throw new AbloValidationError('useSyncGroup: no <SyncGroupProvider> mounted above this component. ' +
|
|
40
|
-
'Wrap your tree with <SyncGroupProvider id="matter:..."> from ' +
|
|
41
|
-
'@abloatai/ablo/react.', { code: 'no_sync_group_provider' });
|
|
42
|
-
}
|
|
43
|
-
return id;
|
|
44
|
-
}
|
package/dist/react/useClaim.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { ResolveClaims } from '../types/global.js';
|
|
2
|
-
/**
|
|
3
|
-
* Named-claim invoker, typed via `ResolveClaims[ClaimName]`.
|
|
4
|
-
*
|
|
5
|
-
* The consumer declares their claim vocabulary in the global:
|
|
6
|
-
*
|
|
7
|
-
* ```ts
|
|
8
|
-
* declare module '@abloatai/ablo' {
|
|
9
|
-
* interface Register {
|
|
10
|
-
* Claims: {
|
|
11
|
-
* editLayer: { slideId: string; layerId: string };
|
|
12
|
-
* generateWithAI: { entityId: string; tool: string };
|
|
13
|
-
* };
|
|
14
|
-
* }
|
|
15
|
-
* }
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* Then `useClaim('editLayer')` returns a function whose sole argument
|
|
19
|
-
* is the `editLayer` claim shape — no runtime checks, purely compile-
|
|
20
|
-
* time narrowing.
|
|
21
|
-
*
|
|
22
|
-
* The SDK doesn't own what happens next: the `beginClaim` function on
|
|
23
|
-
* the React context (supplied via `SyncProvider`) is where the claim
|
|
24
|
-
* claim turns into a network effect. A Node-backed consumer wires it
|
|
25
|
-
* through `SyncAgent.beginClaim`; a browser-backed consumer may
|
|
26
|
-
* broadcast it through their own WebSocket. This hook is pure sugar
|
|
27
|
-
* that adds the typed name + claim narrowing.
|
|
28
|
-
*/
|
|
29
|
-
export declare function useClaim<Name extends keyof ResolveClaims & string>(claimName: Name): (claim: ResolveClaims[Name]) => unknown;
|
package/dist/react/useClaim.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { useCallback } from 'react';
|
|
3
|
-
import { useSyncContext } from './context.js';
|
|
4
|
-
import { AbloValidationError } from '../errors.js';
|
|
5
|
-
/**
|
|
6
|
-
* Named-claim invoker, typed via `ResolveClaims[ClaimName]`.
|
|
7
|
-
*
|
|
8
|
-
* The consumer declares their claim vocabulary in the global:
|
|
9
|
-
*
|
|
10
|
-
* ```ts
|
|
11
|
-
* declare module '@abloatai/ablo' {
|
|
12
|
-
* interface Register {
|
|
13
|
-
* Claims: {
|
|
14
|
-
* editLayer: { slideId: string; layerId: string };
|
|
15
|
-
* generateWithAI: { entityId: string; tool: string };
|
|
16
|
-
* };
|
|
17
|
-
* }
|
|
18
|
-
* }
|
|
19
|
-
* ```
|
|
20
|
-
*
|
|
21
|
-
* Then `useClaim('editLayer')` returns a function whose sole argument
|
|
22
|
-
* is the `editLayer` claim shape — no runtime checks, purely compile-
|
|
23
|
-
* time narrowing.
|
|
24
|
-
*
|
|
25
|
-
* The SDK doesn't own what happens next: the `beginClaim` function on
|
|
26
|
-
* the React context (supplied via `SyncProvider`) is where the claim
|
|
27
|
-
* claim turns into a network effect. A Node-backed consumer wires it
|
|
28
|
-
* through `SyncAgent.beginClaim`; a browser-backed consumer may
|
|
29
|
-
* broadcast it through their own WebSocket. This hook is pure sugar
|
|
30
|
-
* that adds the typed name + claim narrowing.
|
|
31
|
-
*/
|
|
32
|
-
export function useClaim(claimName) {
|
|
33
|
-
const { beginClaim } = useSyncContext();
|
|
34
|
-
return useCallback((claim) => {
|
|
35
|
-
if (!beginClaim) {
|
|
36
|
-
throw new AbloValidationError(`useClaim: no \`beginClaim\` wired into SyncProvider. Pass ` +
|
|
37
|
-
`a \`beginClaim\` prop (typically bound to your transport) ` +
|
|
38
|
-
`to enable claim invocations.`, { code: 'claim_not_wired' });
|
|
39
|
-
}
|
|
40
|
-
return beginClaim(claimName, claim);
|
|
41
|
-
}, [beginClaim, claimName]);
|
|
42
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { ResolvePresence } from '../types/global.js';
|
|
2
|
-
/**
|
|
3
|
-
* Read the consumer-supplied presence state with `ResolvePresence`d
|
|
4
|
-
* typing — the shape the consumer declared in
|
|
5
|
-
* `declare module '@abloatai/ablo' { interface Register { Presence: ... } }`.
|
|
6
|
-
*
|
|
7
|
-
* The SDK doesn't own a presence wire format. Consumers plug whatever
|
|
8
|
-
* backs their cursors, status, or activity (a MobX store, a custom
|
|
9
|
-
* WebSocket channel, `SyncAgent` in Node, a Zustand slice) via the
|
|
10
|
-
* `presence` prop on `SyncProvider`. This hook returns it typed.
|
|
11
|
-
*
|
|
12
|
-
* ```ts
|
|
13
|
-
* // apps/your-app/src/ablo-sync.d.ts
|
|
14
|
-
* declare module '@abloatai/ablo' {
|
|
15
|
-
* interface Register {
|
|
16
|
-
* Presence: { cursor: { x: number; y: number } | null; status: 'away' | 'online' };
|
|
17
|
-
* }
|
|
18
|
-
* }
|
|
19
|
-
*
|
|
20
|
-
* // consumer's <SyncProvider> wiring
|
|
21
|
-
* <SyncProvider store={store} organizationId={orgId} presence={presenceStore}>
|
|
22
|
-
*
|
|
23
|
-
* // any component
|
|
24
|
-
* const presence = usePresence();
|
|
25
|
-
* presence?.cursor?.x; // fully typed
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* Returns `undefined` when no provider-level presence source is wired —
|
|
29
|
-
* consumers can narrow with a guard or configure a default in their
|
|
30
|
-
* provider.
|
|
31
|
-
*/
|
|
32
|
-
export declare function usePresence(): ResolvePresence | undefined;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { useSyncContext } from './context.js';
|
|
3
|
-
/**
|
|
4
|
-
* Read the consumer-supplied presence state with `ResolvePresence`d
|
|
5
|
-
* typing — the shape the consumer declared in
|
|
6
|
-
* `declare module '@abloatai/ablo' { interface Register { Presence: ... } }`.
|
|
7
|
-
*
|
|
8
|
-
* The SDK doesn't own a presence wire format. Consumers plug whatever
|
|
9
|
-
* backs their cursors, status, or activity (a MobX store, a custom
|
|
10
|
-
* WebSocket channel, `SyncAgent` in Node, a Zustand slice) via the
|
|
11
|
-
* `presence` prop on `SyncProvider`. This hook returns it typed.
|
|
12
|
-
*
|
|
13
|
-
* ```ts
|
|
14
|
-
* // apps/your-app/src/ablo-sync.d.ts
|
|
15
|
-
* declare module '@abloatai/ablo' {
|
|
16
|
-
* interface Register {
|
|
17
|
-
* Presence: { cursor: { x: number; y: number } | null; status: 'away' | 'online' };
|
|
18
|
-
* }
|
|
19
|
-
* }
|
|
20
|
-
*
|
|
21
|
-
* // consumer's <SyncProvider> wiring
|
|
22
|
-
* <SyncProvider store={store} organizationId={orgId} presence={presenceStore}>
|
|
23
|
-
*
|
|
24
|
-
* // any component
|
|
25
|
-
* const presence = usePresence();
|
|
26
|
-
* presence?.cursor?.x; // fully typed
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
* Returns `undefined` when no provider-level presence source is wired —
|
|
30
|
-
* consumers can narrow with a guard or configure a default in their
|
|
31
|
-
* provider.
|
|
32
|
-
*/
|
|
33
|
-
export function usePresence() {
|
|
34
|
-
const ctx = useSyncContext();
|
|
35
|
-
// The runtime value is whatever the consumer passed to `SyncProvider`.
|
|
36
|
-
// The type assertion reflects the consumer's declared global, which
|
|
37
|
-
// the hook can't verify at runtime — but the consumer controls both
|
|
38
|
-
// ends (the registration and the provider prop) so this is a
|
|
39
|
-
// single-source-of-truth contract, not blind trust.
|
|
40
|
-
return ctx.presence;
|
|
41
|
-
}
|