@abloatai/ablo 0.27.0 → 0.29.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 +59 -3
- package/README.md +1 -1
- package/dist/BaseSyncedStore.js +8 -9
- package/dist/Database.d.ts +14 -1
- package/dist/Database.js +228 -28
- package/dist/Model.d.ts +17 -0
- package/dist/Model.js +32 -1
- package/dist/SyncClient.d.ts +10 -6
- package/dist/SyncClient.js +390 -75
- package/dist/adapters/inMemoryStorage.d.ts +1 -0
- package/dist/adapters/inMemoryStorage.js +29 -13
- package/dist/ai-sdk/coordinatedTool.d.ts +15 -2
- package/dist/auth/schemas.d.ts +6 -0
- package/dist/auth/schemas.js +7 -0
- package/dist/cli.cjs +821 -402
- package/dist/client/Ablo.d.ts +53 -24
- package/dist/client/Ablo.js +12 -199
- package/dist/client/claimHeartbeatLoop.d.ts +1 -1
- package/dist/client/claimHeartbeatLoop.js +1 -1
- package/dist/client/createInternalComponents.d.ts +4 -0
- package/dist/client/createInternalComponents.js +3 -1
- package/dist/client/durableWrites.d.ts +21 -0
- package/dist/client/durableWrites.js +46 -0
- package/dist/client/httpClient.d.ts +21 -45
- package/dist/client/httpClient.js +104 -26
- package/dist/client/httpTransport.d.ts +8 -0
- package/dist/client/{ApiClient.js → httpTransport.js} +361 -308
- package/dist/client/modelRegistration.js +11 -0
- package/dist/client/options.d.ts +54 -7
- package/dist/client/options.js +3 -2
- package/dist/client/resourceTypes.d.ts +9 -85
- package/dist/client/resourceTypes.js +1 -1
- package/dist/client/sessionMint.d.ts +5 -6
- package/dist/client/sessionMint.js +4 -5
- package/dist/client/validateAbloOptions.js +3 -3
- package/dist/client/wsMutationExecutor.d.ts +3 -2
- package/dist/client/wsMutationExecutor.js +3 -2
- package/dist/coordination/schema.d.ts +30 -0
- package/dist/coordination/schema.js +14 -0
- package/dist/core/StoreManager.d.ts +2 -0
- package/dist/core/StoreManager.js +12 -0
- package/dist/core/index.d.ts +1 -1
- package/dist/errorCodes.js +6 -2
- package/dist/errors.d.ts +4 -40
- package/dist/errors.js +5 -5
- package/dist/index.d.ts +20 -8
- package/dist/index.js +9 -5
- package/dist/interfaces/index.d.ts +5 -2
- package/dist/mutators/UndoManager.d.ts +2 -0
- package/dist/mutators/UndoManager.js +32 -0
- package/dist/mutators/defineMutators.d.ts +18 -0
- package/dist/mutators/defineMutators.js +4 -8
- package/dist/react/index.d.ts +1 -1
- package/dist/react/useAblo.d.ts +6 -4
- package/dist/react/useAblo.js +25 -3
- package/dist/schema/index.d.ts +2 -2
- package/dist/schema/index.js +1 -1
- package/dist/schema/schema.d.ts +31 -1
- package/dist/schema/select.d.ts +15 -0
- package/dist/schema/select.js +27 -3
- package/dist/source/connector.d.ts +3 -3
- package/dist/source/factory.d.ts +4 -6
- package/dist/source/factory.js +4 -7
- package/dist/source/index.d.ts +4 -4
- package/dist/source/index.js +2 -2
- package/dist/source/signing.d.ts +0 -3
- package/dist/source/types.d.ts +0 -26
- package/dist/stores/ObjectStore.d.ts +14 -1
- package/dist/stores/ObjectStore.js +33 -10
- package/dist/stores/ObjectStoreContract.d.ts +2 -0
- package/dist/surface.d.ts +1 -1
- package/dist/surface.js +3 -0
- package/dist/sync/BootstrapFetcher.d.ts +10 -0
- package/dist/sync/BootstrapFetcher.js +27 -4
- package/dist/sync/SyncWebSocket.d.ts +2 -1
- package/dist/sync/createClaimStream.d.ts +11 -2
- package/dist/sync/createClaimStream.js +4 -3
- package/dist/sync/persistedPrefix.d.ts +12 -0
- package/dist/sync/persistedPrefix.js +22 -0
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.js +1 -0
- package/dist/testing/mocks/FakeDatabase.d.ts +18 -0
- package/dist/testing/mocks/FakeDatabase.js +10 -0
- package/dist/testing/mocks/MockWebSocket.d.ts +2 -1
- package/dist/transactions/TransactionQueue.d.ts +66 -8
- package/dist/transactions/TransactionQueue.js +607 -89
- package/dist/transactions/commitEnvelope.d.ts +132 -0
- package/dist/transactions/commitEnvelope.js +139 -0
- package/dist/transactions/commitOutboxStore.d.ts +32 -0
- package/dist/transactions/commitOutboxStore.js +26 -0
- package/dist/transactions/commitPayload.d.ts +15 -0
- package/dist/transactions/commitPayload.js +6 -0
- package/dist/transactions/durableWriteStore.d.ts +123 -0
- package/dist/transactions/durableWriteStore.js +30 -0
- package/dist/transactions/httpCommitEnvelope.d.ts +44 -0
- package/dist/transactions/httpCommitEnvelope.js +181 -0
- package/dist/transactions/idempotencyKey.d.ts +10 -0
- package/dist/transactions/idempotencyKey.js +9 -0
- package/dist/transactions/replayValidation.d.ts +83 -0
- package/dist/transactions/replayValidation.js +46 -1
- package/dist/types/global.d.ts +10 -29
- package/dist/types/global.js +4 -7
- package/dist/types/streams.d.ts +2 -28
- package/dist/wire/bootstrapReason.d.ts +9 -0
- package/dist/wire/bootstrapReason.js +8 -0
- package/dist/wire/frames.d.ts +6 -21
- package/dist/wire/frames.js +4 -4
- package/dist/wire/index.d.ts +6 -3
- package/dist/wire/index.js +3 -2
- package/dist/wire/protocolVersion.d.ts +30 -17
- package/dist/wire/protocolVersion.js +34 -18
- package/docs/agents.md +8 -3
- package/docs/api.md +16 -14
- package/docs/client-behavior.md +6 -3
- package/docs/coordination.md +4 -5
- package/docs/data-sources.md +5 -8
- package/docs/guarantees.md +21 -0
- package/docs/integration-guide.md +1 -0
- package/docs/mcp.md +1 -1
- package/docs/migration.md +21 -1
- package/docs/quickstart.md +11 -0
- package/docs/react.md +0 -46
- package/examples/README.md +6 -5
- package/llms.txt +15 -15
- package/package.json +3 -3
- package/dist/client/ApiClient.d.ts +0 -177
|
@@ -22,10 +22,23 @@ export class InMemoryObjectStore {
|
|
|
22
22
|
this.indexes.set(name, new Map());
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
add(record) {
|
|
26
26
|
const id = record.id;
|
|
27
27
|
if (!id)
|
|
28
|
-
|
|
28
|
+
throw new TypeError('In-memory record must carry an id');
|
|
29
|
+
if (this.data.has(id)) {
|
|
30
|
+
const error = new Error(`Record already exists: ${id}`);
|
|
31
|
+
error.name = 'ConstraintError';
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
this.data.set(id, { ...record });
|
|
35
|
+
this.addToIndexes(id, record);
|
|
36
|
+
return Promise.resolve();
|
|
37
|
+
}
|
|
38
|
+
put(record) {
|
|
39
|
+
const id = record.id;
|
|
40
|
+
if (!id)
|
|
41
|
+
return Promise.resolve();
|
|
29
42
|
// Remove from old index entries if updating
|
|
30
43
|
const existing = this.data.get(id);
|
|
31
44
|
if (existing) {
|
|
@@ -33,24 +46,26 @@ export class InMemoryObjectStore {
|
|
|
33
46
|
}
|
|
34
47
|
this.data.set(id, { ...record });
|
|
35
48
|
this.addToIndexes(id, record);
|
|
49
|
+
return Promise.resolve();
|
|
36
50
|
}
|
|
37
|
-
|
|
38
|
-
return this.data.get(id);
|
|
51
|
+
get(id) {
|
|
52
|
+
return Promise.resolve(this.data.get(id));
|
|
39
53
|
}
|
|
40
|
-
|
|
41
|
-
return [...this.data.values()];
|
|
54
|
+
getAll() {
|
|
55
|
+
return Promise.resolve([...this.data.values()]);
|
|
42
56
|
}
|
|
43
|
-
|
|
57
|
+
delete(id) {
|
|
44
58
|
const existing = this.data.get(id);
|
|
45
59
|
if (existing) {
|
|
46
60
|
this.removeFromIndexes(id, existing);
|
|
47
61
|
this.data.delete(id);
|
|
48
62
|
}
|
|
63
|
+
return Promise.resolve();
|
|
49
64
|
}
|
|
50
|
-
|
|
65
|
+
getAllFromIndex(indexName, value) {
|
|
51
66
|
const index = this.indexes.get(indexName);
|
|
52
67
|
if (!index)
|
|
53
|
-
return [];
|
|
68
|
+
return Promise.resolve([]);
|
|
54
69
|
// The in-memory index stores values as strings (it doesn't support
|
|
55
70
|
// the full IDB key range — Date / BufferSource / arrays). For the
|
|
56
71
|
// overwhelmingly-common case of string FK ids, coercing through
|
|
@@ -58,16 +73,17 @@ export class InMemoryObjectStore {
|
|
|
58
73
|
// shared `ObjectStoreContract` signature.
|
|
59
74
|
const ids = index.get(String(value));
|
|
60
75
|
if (!ids)
|
|
61
|
-
return [];
|
|
62
|
-
return [...ids]
|
|
76
|
+
return Promise.resolve([]);
|
|
77
|
+
return Promise.resolve([...ids]
|
|
63
78
|
.map((id) => this.data.get(id))
|
|
64
|
-
.filter((r) => r != null);
|
|
79
|
+
.filter((r) => r != null));
|
|
65
80
|
}
|
|
66
|
-
|
|
81
|
+
clear() {
|
|
67
82
|
this.data.clear();
|
|
68
83
|
for (const index of this.indexes.values()) {
|
|
69
84
|
index.clear();
|
|
70
85
|
}
|
|
86
|
+
return Promise.resolve();
|
|
71
87
|
}
|
|
72
88
|
/** No-op — in-memory stores don't need closing. */
|
|
73
89
|
markAsClosing() { }
|
|
@@ -58,7 +58,9 @@
|
|
|
58
58
|
* first-in-first-out, which would require a persistent connection.
|
|
59
59
|
*/
|
|
60
60
|
import type { z } from 'zod';
|
|
61
|
-
import type {
|
|
61
|
+
import type { ClaimParams, ModelRetrieveParams, ModelUpdateParams } from '../client/createModelProxy.js';
|
|
62
|
+
import type { ModelUpdater, ContentionOptions } from '../client/functionalUpdate.js';
|
|
63
|
+
import type { HeldClaim } from '../types/streams.js';
|
|
62
64
|
export type CoordinationStrategy = 'merge' | 'claim' | 'queue';
|
|
63
65
|
/** The structured result the tool hands back to the model (or the caller). */
|
|
64
66
|
export interface CoordinatedWriteResult<T> {
|
|
@@ -105,4 +107,15 @@ export interface CoordinatedToolOptions<TInput, T> {
|
|
|
105
107
|
timeoutMs?: number;
|
|
106
108
|
};
|
|
107
109
|
}
|
|
108
|
-
|
|
110
|
+
/**
|
|
111
|
+
* The small model port this helper needs. Both typed transports implement this
|
|
112
|
+
* exact contract; local-cache methods, wire receipts, and transport lifecycle
|
|
113
|
+
* deliberately stay out of an AI tool's dependency surface.
|
|
114
|
+
*/
|
|
115
|
+
export interface CoordinatedModel<T> {
|
|
116
|
+
retrieve(params: ModelRetrieveParams): Promise<T | undefined>;
|
|
117
|
+
update(params: ModelUpdateParams<T>): Promise<T>;
|
|
118
|
+
update(id: string, updater: ModelUpdater<T>, options?: ContentionOptions): Promise<T | undefined>;
|
|
119
|
+
claim(params: ClaimParams<T>): Promise<HeldClaim<T>>;
|
|
120
|
+
}
|
|
121
|
+
export declare function coordinatedTool<TInput, T = Record<string, unknown>>(model: CoordinatedModel<T>, options: CoordinatedToolOptions<TInput, T>): import("ai").Tool<TInput, CoordinatedWriteResult<T>>;
|
package/dist/auth/schemas.d.ts
CHANGED
|
@@ -27,6 +27,12 @@ export declare const IdentityResolveResponseSchema: z.ZodObject<{
|
|
|
27
27
|
}>;
|
|
28
28
|
participantId: z.ZodString;
|
|
29
29
|
accountScope: z.ZodString;
|
|
30
|
+
projectId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
31
|
+
environment: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
32
|
+
production: "production";
|
|
33
|
+
sandbox: "sandbox";
|
|
34
|
+
}>>>;
|
|
35
|
+
sandboxId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
30
36
|
syncGroups: z.ZodArray<z.ZodString>;
|
|
31
37
|
userMeta: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
32
38
|
}, z.core.$loose>;
|
package/dist/auth/schemas.js
CHANGED
|
@@ -25,6 +25,13 @@ export const IdentityResolveResponseSchema = z
|
|
|
25
25
|
participantKind: AuthParticipantKindSchema,
|
|
26
26
|
participantId: z.string().min(1),
|
|
27
27
|
accountScope: z.string().min(1),
|
|
28
|
+
// The rest of the plane this credential resolves to. `nullish` (optional +
|
|
29
|
+
// nullable) so a server too old to send them still parses, and a human
|
|
30
|
+
// session — which carries no such scope — validates with them absent.
|
|
31
|
+
// `projectId` equals the org id for the org-default project.
|
|
32
|
+
projectId: z.string().min(1).nullish(),
|
|
33
|
+
environment: z.enum(['sandbox', 'production']).nullish(),
|
|
34
|
+
sandboxId: z.string().min(1).nullish(),
|
|
28
35
|
syncGroups: z.array(z.string()),
|
|
29
36
|
userMeta: z.record(z.string(), z.unknown()),
|
|
30
37
|
})
|