@enbox/agent 0.5.9 → 0.5.11

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 (44) hide show
  1. package/dist/browser.mjs +9 -9
  2. package/dist/browser.mjs.map +4 -4
  3. package/dist/esm/dwn-api.js.map +1 -1
  4. package/dist/esm/dwn-record-upgrade.js +1 -1
  5. package/dist/esm/dwn-record-upgrade.js.map +1 -1
  6. package/dist/esm/index.js +4 -0
  7. package/dist/esm/index.js.map +1 -1
  8. package/dist/esm/sync-closure-resolver.js +855 -0
  9. package/dist/esm/sync-closure-resolver.js.map +1 -0
  10. package/dist/esm/sync-closure-types.js +189 -0
  11. package/dist/esm/sync-closure-types.js.map +1 -0
  12. package/dist/esm/sync-engine-level.js +977 -224
  13. package/dist/esm/sync-engine-level.js.map +1 -1
  14. package/dist/esm/sync-messages.js +19 -5
  15. package/dist/esm/sync-messages.js.map +1 -1
  16. package/dist/esm/sync-replication-ledger.js +220 -0
  17. package/dist/esm/sync-replication-ledger.js.map +1 -0
  18. package/dist/esm/types/sync.js +54 -1
  19. package/dist/esm/types/sync.js.map +1 -1
  20. package/dist/types/dwn-api.d.ts.map +1 -1
  21. package/dist/types/index.d.ts +5 -0
  22. package/dist/types/index.d.ts.map +1 -1
  23. package/dist/types/sync-closure-resolver.d.ts +19 -0
  24. package/dist/types/sync-closure-resolver.d.ts.map +1 -0
  25. package/dist/types/sync-closure-types.d.ts +122 -0
  26. package/dist/types/sync-closure-types.d.ts.map +1 -0
  27. package/dist/types/sync-engine-level.d.ts +137 -11
  28. package/dist/types/sync-engine-level.d.ts.map +1 -1
  29. package/dist/types/sync-messages.d.ts +6 -1
  30. package/dist/types/sync-messages.d.ts.map +1 -1
  31. package/dist/types/sync-replication-ledger.d.ts +72 -0
  32. package/dist/types/sync-replication-ledger.d.ts.map +1 -0
  33. package/dist/types/types/sync.d.ts +188 -0
  34. package/dist/types/types/sync.d.ts.map +1 -1
  35. package/package.json +3 -3
  36. package/src/dwn-api.ts +2 -1
  37. package/src/dwn-record-upgrade.ts +1 -1
  38. package/src/index.ts +5 -0
  39. package/src/sync-closure-resolver.ts +919 -0
  40. package/src/sync-closure-types.ts +270 -0
  41. package/src/sync-engine-level.ts +1062 -255
  42. package/src/sync-messages.ts +21 -6
  43. package/src/sync-replication-ledger.ts +197 -0
  44. package/src/types/sync.ts +202 -0
@@ -1,3 +1,4 @@
1
+ import type { ProgressToken } from '@enbox/dwn-sdk-js';
1
2
  import type { EnboxPlatformAgent } from './agent.js';
2
3
  /**
3
4
  * The SyncEngine is responsible for syncing messages between the agent and the platform.
@@ -21,6 +22,123 @@ export type SyncConnectivityState = 'online' | 'offline' | 'unknown';
21
22
  * `'live'` for `MessagesSubscribe`-based real-time sync with SMT fallback.
22
23
  */
23
24
  export type SyncMode = 'poll' | 'live';
25
+ /**
26
+ * Describes what a replication link syncs. Currently whole-tenant only
27
+ * (`kind: 'full'`). Scoped subset sync (`kind: 'protocol'` with
28
+ * `protocolPathPrefixes` / `contextIdPrefixes`) is deferred to Phase 3.
29
+ */
30
+ export type SyncScope = {
31
+ /** Scope kind. Only `'full'` is implemented in Phase 1. */
32
+ kind: 'full';
33
+ } | {
34
+ /**
35
+ * Protocol-scoped sync. Deferred to Phase 3 — included here for type
36
+ * forward-compatibility only.
37
+ */
38
+ kind: 'protocol';
39
+ protocol: string;
40
+ protocolPathPrefixes?: string[];
41
+ contextIdPrefixes?: string[];
42
+ };
43
+ /**
44
+ * Computes a deterministic, collision-resistant identifier for a {@link SyncScope}.
45
+ *
46
+ * The ID is `base64url(SHA-256(canonicalJSON))` where `canonicalJSON` is the
47
+ * scope object with keys sorted alphabetically and array values sorted
48
+ * lexicographically.
49
+ *
50
+ * Used as part of the LevelDB key for the replication ledger:
51
+ * `{tenantDid}^{remoteEndpoint}^{scopeId}`.
52
+ */
53
+ export declare function computeScopeId(scope: SyncScope): Promise<string>;
54
+ /**
55
+ * Maximum number of in-flight deliveries (runtime ordinals) a link may
56
+ * accumulate before transitioning to `repairing`. This is the overflow
57
+ * threshold for the engine's in-memory delivery tracker, not for durable
58
+ * checkpoint state. Normative per the sync redesign RFC.
59
+ */
60
+ export declare const MAX_PENDING_TOKENS = 100;
61
+ /**
62
+ * Tracks directional (pull or push) replay progression for a single
63
+ * replication link. All tokens belong to the same `(streamId, epoch)`.
64
+ *
65
+ * This is the **durable** replication checkpoint persisted to the ledger.
66
+ * In-memory delivery-order tracking (ordinals, in-flight commits) is owned
67
+ * by the sync engine and is not persisted — on crash recovery, replay
68
+ * restarts from `contiguousAppliedToken` and idempotent apply handles
69
+ * any re-delivered events.
70
+ */
71
+ export type DirectionCheckpoint = {
72
+ /**
73
+ * The latest token received from the source (pull) or confirmed by the
74
+ * remote (push). May be ahead of `contiguousAppliedToken` when events
75
+ * arrive out of order. Used for observability.
76
+ */
77
+ receivedToken?: ProgressToken;
78
+ /**
79
+ * The highest token such that all earlier delivered tokens for this link
80
+ * have been durably applied. This is the resume point after crash/reconnect.
81
+ *
82
+ * Advancement is controlled by the engine's delivery-order tracking,
83
+ * not by position arithmetic. Positions may be sparse (filtered streams).
84
+ */
85
+ contiguousAppliedToken?: ProgressToken;
86
+ };
87
+ /**
88
+ * Status of a replication link.
89
+ *
90
+ * - `initializing` — link created, no subscriptions open yet.
91
+ * - `live` — actively receiving events via subscription.
92
+ * - `repairing` — gap detected or pending overflow; running SMT reconciliation.
93
+ * - `degraded_poll` — subscription failed; polling at reduced frequency.
94
+ * - `paused` — explicitly paused by the application.
95
+ */
96
+ export type LinkStatus = 'initializing' | 'live' | 'repairing' | 'degraded_poll' | 'paused';
97
+ /**
98
+ * Durable state of a single replication link. Persisted to LevelDB and
99
+ * loaded on startup. Each link is identified by the tuple
100
+ * `(tenantDid, remoteEndpoint, scopeId)`.
101
+ */
102
+ export type ReplicationLinkState = {
103
+ /** The tenant DID this link syncs for. */
104
+ tenantDid: string;
105
+ /** The remote DWN endpoint URL. */
106
+ remoteEndpoint: string;
107
+ /** Deterministic hash of the {@link SyncScope}. See {@link computeScopeId}. */
108
+ scopeId: string;
109
+ /** The scope definition this link covers. */
110
+ scope: SyncScope;
111
+ /** Current link status. */
112
+ status: LinkStatus;
113
+ /** Pull-direction replication checkpoint (remote → local). */
114
+ pull: DirectionCheckpoint;
115
+ /** Push-direction replication checkpoint (local → remote). */
116
+ push: DirectionCheckpoint;
117
+ /** Per-link connectivity state. Used to compute the aggregate engine-level state. */
118
+ connectivity: SyncConnectivityState;
119
+ /** Delegate DID used to sign sync messages, if any. */
120
+ delegateDid?: string;
121
+ /**
122
+ * Protocol filter for this link, if any. Duplicates the protocol in `scope`
123
+ * for operational convenience — used by permission lookups and cursor key
124
+ * building. The scope is the source of truth for what to sync; this field
125
+ * is the source of truth for how to authenticate. To be consolidated in
126
+ * Phase 3 when scope resolution is more complex.
127
+ */
128
+ protocol?: string;
129
+ /** ISO-8601 timestamp of last successful sync activity. */
130
+ lastActivityAt?: string;
131
+ };
132
+ /**
133
+ * Result of a batch push operation. Replaces the previous throw-on-first-failure
134
+ * pattern so callers can advance the push replication checkpoint incrementally.
135
+ */
136
+ export type PushResult = {
137
+ /** messageCids that were accepted (202/204/409 — idempotent success). */
138
+ succeeded: string[];
139
+ /** messageCids that failed (retryable or hard error). */
140
+ failed: string[];
141
+ };
24
142
  /**
25
143
  * Parameters for {@link SyncEngine.startSync}.
26
144
  */
@@ -48,6 +166,70 @@ export type StartSyncParams = {
48
166
  */
49
167
  interval?: string;
50
168
  };
169
+ /**
170
+ * Events emitted by the sync engine at key state transitions.
171
+ * Consumers subscribe via `SyncEngine.on('event', handler)` and can
172
+ * hook these into metrics, logging, or UI state.
173
+ */
174
+ export type SyncEvent = {
175
+ type: 'link:status-change';
176
+ tenantDid: string;
177
+ remoteEndpoint: string;
178
+ protocol?: string;
179
+ from: LinkStatus;
180
+ to: LinkStatus;
181
+ } | {
182
+ type: 'link:connectivity-change';
183
+ tenantDid: string;
184
+ remoteEndpoint: string;
185
+ protocol?: string;
186
+ from: SyncConnectivityState;
187
+ to: SyncConnectivityState;
188
+ } | {
189
+ type: 'checkpoint:pull-advance';
190
+ tenantDid: string;
191
+ remoteEndpoint: string;
192
+ protocol?: string;
193
+ position: string;
194
+ messageCid: string;
195
+ } | {
196
+ type: 'checkpoint:push-advance';
197
+ tenantDid: string;
198
+ remoteEndpoint: string;
199
+ protocol?: string;
200
+ position: string;
201
+ messageCid: string;
202
+ } | {
203
+ type: 'repair:started';
204
+ tenantDid: string;
205
+ remoteEndpoint: string;
206
+ protocol?: string;
207
+ attempt: number;
208
+ } | {
209
+ type: 'repair:completed';
210
+ tenantDid: string;
211
+ remoteEndpoint: string;
212
+ protocol?: string;
213
+ } | {
214
+ type: 'repair:failed';
215
+ tenantDid: string;
216
+ remoteEndpoint: string;
217
+ protocol?: string;
218
+ attempt: number;
219
+ error: string;
220
+ } | {
221
+ type: 'degraded-poll:entered';
222
+ tenantDid: string;
223
+ remoteEndpoint: string;
224
+ protocol?: string;
225
+ } | {
226
+ type: 'gap:detected';
227
+ tenantDid: string;
228
+ remoteEndpoint: string;
229
+ protocol?: string;
230
+ reason: string;
231
+ };
232
+ export type SyncEventListener = (event: SyncEvent) => void;
51
233
  export interface SyncEngine {
52
234
  /**
53
235
  * The agent that the SyncEngine is attached to.
@@ -104,6 +286,12 @@ export interface SyncEngine {
104
286
  * @throws {Error} if the sync operation fails to stop before the timeout.
105
287
  */
106
288
  stopSync(timeout?: number): Promise<void>;
289
+ /**
290
+ * Subscribe to sync engine events. Returns an unsubscribe function.
291
+ * Events are emitted at key state transitions: checkpoint advancement,
292
+ * link status changes, repair, degraded_poll, gap detection.
293
+ */
294
+ on(listener: SyncEventListener): () => void;
107
295
  /**
108
296
  * Release all resources held by the sync engine (LevelDB handles, timers,
109
297
  * WebSocket subscriptions). After calling `close()`, the engine should not
@@ -1 +1 @@
1
- {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../src/types/sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK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ACH,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1C;;;;OAIG;IACH,EAAE,CAAC,QAAQ,EAAE,iBAAiB,GAAG,MAAM,IAAI,CAAC;IAE5C;;;;OAIG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enbox/agent",
3
- "version": "0.5.9",
3
+ "version": "0.5.11",
4
4
  "type": "module",
5
5
  "main": "./dist/esm/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -71,8 +71,8 @@
71
71
  },
72
72
  "dependencies": {
73
73
  "@scure/bip39": "1.2.2",
74
- "@enbox/dwn-clients": "0.2.4",
75
- "@enbox/dwn-sdk-js": "0.3.0",
74
+ "@enbox/dwn-clients": "0.2.5",
75
+ "@enbox/dwn-sdk-js": "0.3.1",
76
76
  "@enbox/common": "0.1.0",
77
77
  "@enbox/crypto": "0.1.0",
78
78
  "@enbox/dids": "0.1.0",
package/src/dwn-api.ts CHANGED
@@ -5,6 +5,7 @@ import type {
5
5
  EncryptionKeyDeriver,
6
6
  GenericMessage,
7
7
  KeyDecrypter,
8
+ ProgressToken,
8
9
  ProtocolDefinition,
9
10
  RecordsWrite,
10
11
  RecordsWriteMessage,
@@ -568,7 +569,7 @@ export class AgentDwnApi {
568
569
  // subscribe message with a cursor on reconnection.
569
570
  let resubscribeFactory: ResubscribeFactory | undefined;
570
571
  if (subscriptionHandler !== undefined && !('messageCid' in request)) {
571
- resubscribeFactory = async (cursor?: string): Promise<GenericMessage> => {
572
+ resubscribeFactory = async (cursor?: ProgressToken): Promise<GenericMessage> => {
572
573
  const resumeParams = cursor !== undefined
573
574
  ? { ...request.messageParams, cursor } as DwnMessageParams[T]
574
575
  : request.messageParams;
@@ -158,7 +158,7 @@ export async function upgradeExternalRootRecord(
158
158
 
159
159
  // Notify real-time subscribers (mirrors handler behavior)
160
160
  if (eventLog !== undefined) {
161
- await eventLog.emit(tenantDid, { message: upgradedMessage }, upgradedIndexes);
161
+ await eventLog.emit(tenantDid, { message: upgradedMessage }, upgradedIndexes, upgradedCid);
162
162
  }
163
163
 
164
164
  // Cache context key info for subsequent writes in this context
package/src/index.ts CHANGED
@@ -5,6 +5,11 @@ export type * from './types/identity-vault.js';
5
5
  export type * from './types/key-manager.js';
6
6
  export type * from './types/permissions.js';
7
7
  export type * from './types/sync.js';
8
+ export { computeScopeId, MAX_PENDING_TOKENS } from './types/sync.js';
9
+ export { ReplicationLedger } from './sync-replication-ledger.js';
10
+ export { ClosureFailureCode, createClosureContext } from './sync-closure-types.js';
11
+ export type { ClosureDependencyEdge, ClosureEvaluationContext, ClosureResult } from './sync-closure-types.js';
12
+ export { evaluateClosure, evaluateClosureBatch } from './sync-closure-resolver.js';
8
13
  export type * from './types/vc.js';
9
14
 
10
15
  export * from './agent-did-resolver-cache.js';