@abloatai/ablo 0.28.0 → 0.29.1
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 +36 -0
- package/dist/Database.js +9 -6
- package/dist/SyncClient.d.ts +2 -2
- package/dist/SyncClient.js +22 -10
- package/dist/adapters/inMemoryStorage.js +18 -14
- 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 +815 -400
- package/dist/client/Ablo.d.ts +29 -23
- package/dist/client/Ablo.js +8 -196
- package/dist/client/claimHeartbeatLoop.d.ts +1 -1
- package/dist/client/claimHeartbeatLoop.js +1 -1
- package/dist/client/createInternalComponents.d.ts +4 -2
- 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 +19 -45
- package/dist/client/httpClient.js +104 -26
- package/dist/client/httpTransport.d.ts +8 -0
- package/dist/client/{ApiClient.js → httpTransport.js} +78 -291
- package/dist/client/options.d.ts +43 -19
- 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/coordination/schema.d.ts +30 -0
- package/dist/coordination/schema.js +14 -0
- package/dist/core/index.d.ts +1 -1
- package/dist/errors.d.ts +4 -40
- package/dist/errors.js +5 -5
- package/dist/index.d.ts +14 -8
- package/dist/index.js +7 -5
- package/dist/interfaces/index.d.ts +3 -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/schema/index.d.ts +1 -1
- package/dist/schema/index.js +1 -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.js +8 -8
- package/dist/surface.d.ts +1 -1
- package/dist/surface.js +1 -0
- package/dist/sync/BootstrapFetcher.d.ts +10 -0
- package/dist/sync/BootstrapFetcher.js +27 -4
- package/dist/sync/createClaimStream.d.ts +11 -2
- package/dist/sync/createClaimStream.js +4 -3
- package/dist/testing/mocks/FakeDatabase.d.ts +1 -1
- package/dist/transactions/TransactionQueue.d.ts +2 -2
- package/dist/transactions/TransactionQueue.js +3 -3
- package/dist/transactions/commitEnvelope.d.ts +1 -1
- package/dist/transactions/commitEnvelope.js +2 -2
- package/dist/transactions/commitOutboxStore.d.ts +19 -19
- package/dist/transactions/durableWriteStore.d.ts +123 -0
- package/dist/transactions/durableWriteStore.js +30 -0
- package/dist/transactions/httpCommitEnvelope.d.ts +1 -0
- package/dist/transactions/httpCommitEnvelope.js +14 -12
- package/dist/transactions/idempotencyKey.d.ts +10 -0
- package/dist/transactions/idempotencyKey.js +9 -0
- 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/frames.d.ts +6 -257
- package/dist/wire/frames.js +4 -25
- package/dist/wire/index.d.ts +4 -3
- package/dist/wire/index.js +2 -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 +6 -4
- package/docs/client-behavior.md +6 -3
- package/docs/coordination.md +2 -3
- package/docs/data-sources.md +5 -8
- package/docs/guarantees.md +21 -0
- package/docs/integration-guide.md +1 -0
- 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 +2 -7
- package/dist/client/ApiClient.d.ts +0 -177
- package/dist/commit/contract.d.ts +0 -493
- package/dist/commit/contract.js +0 -187
- package/dist/commit/index.d.ts +0 -6
- package/dist/commit/index.js +0 -5
package/dist/commit/contract.js
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The transport-independent v2 commit contract.
|
|
3
|
-
*
|
|
4
|
-
* A commit is a caller's atomic write intent. It contains ordered operations,
|
|
5
|
-
* a stable idempotency key, and explicit write preconditions. HTTP and
|
|
6
|
-
* WebSocket transports wrap these schemas; they do not redefine their data.
|
|
7
|
-
* Every public data type in this module is inferred from the Zod schema that
|
|
8
|
-
* validates it at a trust boundary.
|
|
9
|
-
*/
|
|
10
|
-
import { z } from 'zod';
|
|
11
|
-
import { ERROR_CODES } from '../errorCodes.js';
|
|
12
|
-
/** Current version of the transport-independent commit contract. */
|
|
13
|
-
export const COMMIT_CONTRACT_VERSION = 2;
|
|
14
|
-
// ── Opaque identifiers ───────────────────────────────────────────────────
|
|
15
|
-
/** Stable identity of one logical commit. Reused unchanged for every retry. */
|
|
16
|
-
export const idempotencyKeySchema = z.string().min(1).max(255).brand();
|
|
17
|
-
/** Server-issued identity of a durable commit execution. */
|
|
18
|
-
export const commitIdSchema = z.uuid().brand();
|
|
19
|
-
/** Stable identity of one operation within a commit. */
|
|
20
|
-
export const operationIdSchema = z.string().min(1).max(255).brand();
|
|
21
|
-
/** Identity of a pessimistic claim whose generation fences a write. */
|
|
22
|
-
export const claimIdSchema = z.string().min(1).max(255).brand();
|
|
23
|
-
/**
|
|
24
|
-
* Internal committed-log offset. Decimal strings preserve PostgreSQL BIGINT
|
|
25
|
-
* precision across JavaScript and JSON boundaries.
|
|
26
|
-
*/
|
|
27
|
-
export const syncOffsetSchema = z
|
|
28
|
-
.string()
|
|
29
|
-
.regex(/^(0|[1-9]\d*)$/, 'Expected a non-negative decimal sync offset')
|
|
30
|
-
.brand();
|
|
31
|
-
/** Opaque resumable cursor returned to clients; consumers must not inspect it. */
|
|
32
|
-
export const syncCursorSchema = z.string().min(1).max(4096).brand();
|
|
33
|
-
// ── JSON values ──────────────────────────────────────────────────────────
|
|
34
|
-
/** JSON-safe value accepted by a persisted or fingerprinted commit payload. */
|
|
35
|
-
export const jsonValueSchema = z.json();
|
|
36
|
-
/** JSON object accepted for entity values, patches, and structured details. */
|
|
37
|
-
export const jsonObjectSchema = z.record(z.string(), jsonValueSchema);
|
|
38
|
-
const nonEmptyJsonObjectSchema = jsonObjectSchema.refine((value) => Object.keys(value).length > 0, 'Expected at least one changed field');
|
|
39
|
-
// ── Intent ───────────────────────────────────────────────────────────────
|
|
40
|
-
/** Model and row addressed by an operation. */
|
|
41
|
-
export const entityRefSchema = z.strictObject({
|
|
42
|
-
model: z.string().min(1).max(255),
|
|
43
|
-
id: z.string().min(1).max(1024),
|
|
44
|
-
});
|
|
45
|
-
const fieldPathSchema = z.string().min(1).max(1024);
|
|
46
|
-
/**
|
|
47
|
-
* A condition that must still hold when an operation is applied. Preconditions
|
|
48
|
-
* are data rather than option flags so they are included in the request
|
|
49
|
-
* fingerprint and can be reported precisely when a commit conflicts.
|
|
50
|
-
*/
|
|
51
|
-
export const writePreconditionSchema = z.discriminatedUnion('type', [
|
|
52
|
-
z.strictObject({
|
|
53
|
-
type: z.literal('unchanged_since'),
|
|
54
|
-
cursor: syncOffsetSchema,
|
|
55
|
-
fields: z.array(fieldPathSchema).min(1).max(256).optional(),
|
|
56
|
-
}),
|
|
57
|
-
z.strictObject({
|
|
58
|
-
type: z.literal('version_matches'),
|
|
59
|
-
version: z.number().int().nonnegative(),
|
|
60
|
-
}),
|
|
61
|
-
z.strictObject({
|
|
62
|
-
type: z.literal('claim_fence'),
|
|
63
|
-
claimId: claimIdSchema,
|
|
64
|
-
generation: z.number().int().positive(),
|
|
65
|
-
}),
|
|
66
|
-
]);
|
|
67
|
-
const operationBaseShape = {
|
|
68
|
-
operationId: operationIdSchema,
|
|
69
|
-
target: entityRefSchema,
|
|
70
|
-
preconditions: z.array(writePreconditionSchema).max(16).default([]),
|
|
71
|
-
};
|
|
72
|
-
/**
|
|
73
|
-
* One ordered entity change within a commit. The discriminant makes illegal
|
|
74
|
-
* combinations unrepresentable: only create carries `value`, only patch
|
|
75
|
-
* carries `changes`, and destructive actions carry neither.
|
|
76
|
-
*/
|
|
77
|
-
export const commitOperationSchema = z.discriminatedUnion('type', [
|
|
78
|
-
z.strictObject({
|
|
79
|
-
...operationBaseShape,
|
|
80
|
-
type: z.literal('create'),
|
|
81
|
-
value: jsonObjectSchema,
|
|
82
|
-
}),
|
|
83
|
-
z.strictObject({
|
|
84
|
-
...operationBaseShape,
|
|
85
|
-
type: z.literal('patch'),
|
|
86
|
-
changes: nonEmptyJsonObjectSchema,
|
|
87
|
-
}),
|
|
88
|
-
z.strictObject({
|
|
89
|
-
...operationBaseShape,
|
|
90
|
-
type: z.literal('delete'),
|
|
91
|
-
}),
|
|
92
|
-
z.strictObject({
|
|
93
|
-
...operationBaseShape,
|
|
94
|
-
type: z.literal('archive'),
|
|
95
|
-
}),
|
|
96
|
-
z.strictObject({
|
|
97
|
-
...operationBaseShape,
|
|
98
|
-
type: z.literal('unarchive'),
|
|
99
|
-
}),
|
|
100
|
-
]);
|
|
101
|
-
/** Semantic lineage included in the durable intent and its fingerprint. */
|
|
102
|
-
export const commitMetadataSchema = z.strictObject({
|
|
103
|
-
label: z.string().min(1).max(255).optional(),
|
|
104
|
-
causedByTaskId: z.string().min(1).max(255).optional(),
|
|
105
|
-
});
|
|
106
|
-
const commitIntentShape = {
|
|
107
|
-
schemaVersion: z.literal(COMMIT_CONTRACT_VERSION),
|
|
108
|
-
operations: z.array(commitOperationSchema).min(1).max(500),
|
|
109
|
-
metadata: commitMetadataSchema.optional(),
|
|
110
|
-
};
|
|
111
|
-
/** The portion of a request that is fingerprinted, preserving operation order. */
|
|
112
|
-
export const commitIntentSchema = z.strictObject(commitIntentShape);
|
|
113
|
-
/** A caller's stable idempotency identity plus the intent it identifies. */
|
|
114
|
-
export const commitRequestSchema = z.strictObject({
|
|
115
|
-
...commitIntentShape,
|
|
116
|
-
idempotencyKey: idempotencyKeySchema,
|
|
117
|
-
});
|
|
118
|
-
/** Returns the exact semantic value that an idempotency fingerprint covers. */
|
|
119
|
-
export function commitIntentOf(request) {
|
|
120
|
-
const { idempotencyKey, ...intent } = request;
|
|
121
|
-
void idempotencyKey;
|
|
122
|
-
return intent;
|
|
123
|
-
}
|
|
124
|
-
// ── Result ───────────────────────────────────────────────────────────────
|
|
125
|
-
const registeredWireErrorCodes = Object.entries(ERROR_CODES)
|
|
126
|
-
.filter(([, spec]) => spec.surface === 'wire')
|
|
127
|
-
.map(([code]) => code);
|
|
128
|
-
const policyErrorCodeSchema = z.custom((value) => typeof value === 'string' && /^policy:.+$/.test(value), 'Expected a registered error code or policy:<reason>');
|
|
129
|
-
/** Machine-readable failure code carried by a rejected v2 commit. */
|
|
130
|
-
export const commitErrorCodeSchema = z.union([
|
|
131
|
-
z.enum(registeredWireErrorCodes),
|
|
132
|
-
policyErrorCodeSchema,
|
|
133
|
-
]);
|
|
134
|
-
/** Structured capability a rejected commit would require on retry. */
|
|
135
|
-
export const requiredCapabilitySchema = z.strictObject({
|
|
136
|
-
scope: z.string().min(1),
|
|
137
|
-
constraints: z.record(z.string(), z.union([z.string(), z.array(z.string())])).optional(),
|
|
138
|
-
issuer: z.string().min(1).optional(),
|
|
139
|
-
ttlSeconds: z.number().int().positive().optional(),
|
|
140
|
-
nonce: z.string().min(1).optional(),
|
|
141
|
-
});
|
|
142
|
-
/** Structured terminal error for a commit that did not apply. */
|
|
143
|
-
export const commitErrorSchema = z.strictObject({
|
|
144
|
-
code: commitErrorCodeSchema,
|
|
145
|
-
message: z.string().min(1),
|
|
146
|
-
field: fieldPathSchema.optional(),
|
|
147
|
-
requiredCapability: requiredCapabilitySchema.optional(),
|
|
148
|
-
details: jsonObjectSchema.optional(),
|
|
149
|
-
});
|
|
150
|
-
/** One failed precondition and the smallest current state needed to reconcile. */
|
|
151
|
-
export const commitConflictSchema = z.strictObject({
|
|
152
|
-
operationId: operationIdSchema,
|
|
153
|
-
target: entityRefSchema,
|
|
154
|
-
fields: z.array(fieldPathSchema).max(256),
|
|
155
|
-
currentValues: jsonObjectSchema,
|
|
156
|
-
observedAt: syncOffsetSchema,
|
|
157
|
-
});
|
|
158
|
-
const commitReceiptBaseShape = {
|
|
159
|
-
object: z.literal('commit_receipt'),
|
|
160
|
-
schemaVersion: z.literal(COMMIT_CONTRACT_VERSION),
|
|
161
|
-
idempotencyKey: idempotencyKeySchema,
|
|
162
|
-
commitId: commitIdSchema,
|
|
163
|
-
};
|
|
164
|
-
/**
|
|
165
|
-
* Terminal result of a commit execution. Expected outcomes are a discriminated
|
|
166
|
-
* union, so committed, conflicted, and rejected results cannot expose fields
|
|
167
|
-
* belonging to another state.
|
|
168
|
-
*/
|
|
169
|
-
export const commitReceiptSchema = z.discriminatedUnion('status', [
|
|
170
|
-
z.strictObject({
|
|
171
|
-
...commitReceiptBaseShape,
|
|
172
|
-
status: z.literal('committed'),
|
|
173
|
-
syncCursor: syncCursorSchema,
|
|
174
|
-
operationCount: z.number().int().min(1).max(500),
|
|
175
|
-
}),
|
|
176
|
-
z.strictObject({
|
|
177
|
-
...commitReceiptBaseShape,
|
|
178
|
-
status: z.literal('conflicted'),
|
|
179
|
-
syncCursor: syncCursorSchema,
|
|
180
|
-
conflicts: z.array(commitConflictSchema).min(1).max(500),
|
|
181
|
-
}),
|
|
182
|
-
z.strictObject({
|
|
183
|
-
...commitReceiptBaseShape,
|
|
184
|
-
status: z.literal('rejected'),
|
|
185
|
-
error: commitErrorSchema,
|
|
186
|
-
}),
|
|
187
|
-
]);
|
package/dist/commit/index.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Stable commit-contract entry point. Import from `@abloatai/ablo/commit`
|
|
3
|
-
* when validating, persisting, or fingerprinting v2 commit data.
|
|
4
|
-
*/
|
|
5
|
-
export { COMMIT_CONTRACT_VERSION, idempotencyKeySchema, commitIdSchema, operationIdSchema, claimIdSchema, syncOffsetSchema, syncCursorSchema, jsonValueSchema, jsonObjectSchema, entityRefSchema, writePreconditionSchema, commitOperationSchema, commitMetadataSchema, commitIntentSchema, commitRequestSchema, commitIntentOf, commitErrorCodeSchema, requiredCapabilitySchema, commitErrorSchema, commitConflictSchema, commitReceiptSchema, } from './contract.js';
|
|
6
|
-
export type { IdempotencyKey, CommitId, OperationId, ClaimId, SyncOffset, SyncCursor, JsonValue, JsonObject, EntityRef, WritePrecondition, CommitOperationInput, CommitOperation, CommitMetadata, CommitIntentInput, CommitIntent, CommitRequestInput, CommitRequest, CommitErrorCode, RequiredCapability, CommitError, CommitConflict, CommitReceiptInput, CommitReceipt, CommittedCommitReceipt, ConflictedCommitReceipt, RejectedCommitReceipt, } from './contract.js';
|
package/dist/commit/index.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Stable commit-contract entry point. Import from `@abloatai/ablo/commit`
|
|
3
|
-
* when validating, persisting, or fingerprinting v2 commit data.
|
|
4
|
-
*/
|
|
5
|
-
export { COMMIT_CONTRACT_VERSION, idempotencyKeySchema, commitIdSchema, operationIdSchema, claimIdSchema, syncOffsetSchema, syncCursorSchema, jsonValueSchema, jsonObjectSchema, entityRefSchema, writePreconditionSchema, commitOperationSchema, commitMetadataSchema, commitIntentSchema, commitRequestSchema, commitIntentOf, commitErrorCodeSchema, requiredCapabilitySchema, commitErrorSchema, commitConflictSchema, commitReceiptSchema, } from './contract.js';
|