@agentshouse/mdruntime 0.1.0-cbbae1fff01c6 → 0.1.0-cc00e9289ddf4
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/README.md +17 -15
- package/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +14 -23
- package/dist/act-lanes.d.ts +30 -0
- package/dist/act-lanes.d.ts.map +1 -0
- package/dist/act-lanes.js +225 -0
- package/dist/actions.d.ts +8 -2
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +114 -63
- package/dist/adapter.d.ts +30 -12
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +0 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +0 -5
- package/dist/chat-types.d.ts +0 -2
- package/dist/chat-types.d.ts.map +1 -1
- package/dist/chat-types.js +0 -2
- package/dist/client.d.ts +8 -18
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +27 -15
- package/dist/compile.d.ts +2 -0
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +17 -4
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +15 -13
- package/dist/conversation-live.d.ts +23 -8
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +21 -9
- package/dist/conversation-row.d.ts +2 -0
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +2 -0
- package/dist/conversation.d.ts +27 -5
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +279 -168
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +8 -6
- package/dist/durability.d.ts +4 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +4 -0
- package/dist/entry.js +1 -1
- package/dist/expectation.d.ts +25 -14
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +51 -20
- package/dist/failure.d.ts +2 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +3 -0
- package/dist/figures.d.ts.map +1 -1
- package/dist/figures.js +4 -2
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +2 -1
- package/dist/host.d.ts +1 -0
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +39 -11
- package/dist/index.d.ts +11 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -6
- package/dist/install.d.ts +10 -4
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +45 -46
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +22 -16
- package/dist/listing.d.ts +7 -3
- package/dist/listing.d.ts.map +1 -1
- package/dist/listing.js +26 -13
- package/dist/live.d.ts +5 -3
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +71 -30
- package/dist/locks.d.ts.map +1 -1
- package/dist/locks.js +2 -3
- package/dist/lost.d.ts.map +1 -1
- package/dist/lost.js +2 -3
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +7 -10
- package/dist/memory.d.ts +3 -1
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +50 -22
- package/dist/messages.d.ts +12 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +24 -10
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +5 -8
- package/dist/observation.d.ts +27 -12
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +173 -69
- package/dist/opening.d.ts.map +1 -1
- package/dist/opening.js +3 -9
- package/dist/outcome.d.ts +7 -0
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +23 -2
- package/dist/overlay.d.ts +3 -0
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +8 -4
- package/dist/page-metadata.d.ts +8 -0
- package/dist/page-metadata.d.ts.map +1 -0
- package/dist/page-metadata.js +19 -0
- package/dist/parts.d.ts +2 -9
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +6 -14
- package/dist/preparation.d.ts +27 -6
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +137 -56
- package/dist/presence.d.ts +7 -1
- package/dist/presence.d.ts.map +1 -1
- package/dist/presence.js +22 -9
- package/dist/queries.d.ts +2 -2
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +62 -24
- package/dist/questions.d.ts +0 -5
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +0 -7
- package/dist/queue.d.ts +2 -2
- package/dist/queue.d.ts.map +1 -1
- package/dist/queue.js +25 -30
- package/dist/reach.d.ts +2 -3
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +75 -21
- package/dist/react.d.ts +7 -5
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +28 -5
- package/dist/readiness.d.ts +9 -3
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +3 -5
- package/dist/reads.d.ts +3 -1
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +5 -1
- package/dist/recovery.d.ts +3 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +29 -7
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +1 -3
- package/dist/retried.d.ts +30 -0
- package/dist/retried.d.ts.map +1 -0
- package/dist/retried.js +72 -0
- package/dist/room-draft.d.ts +2 -2
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +26 -21
- package/dist/rows.d.ts +2 -0
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +3 -0
- package/dist/runtime.d.ts +2 -2
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts +1 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +105 -55
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +3 -6
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +2 -2
- package/dist/shown.d.ts +3 -2
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +58 -39
- package/dist/socket/lanes.d.ts +12 -4
- package/dist/socket/lanes.d.ts.map +1 -1
- package/dist/socket/lanes.js +34 -8
- package/dist/socket.d.ts +3 -3
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +3 -9
- package/dist/source.d.ts +0 -7
- package/dist/source.d.ts.map +1 -1
- package/dist/store/installs.d.ts +2 -2
- package/dist/store/installs.d.ts.map +1 -1
- package/dist/store/installs.js +10 -4
- package/dist/store/readiness.d.ts +5 -4
- package/dist/store/readiness.d.ts.map +1 -1
- package/dist/store/readiness.js +28 -12
- package/dist/store/records.d.ts +11 -4
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +56 -20
- package/dist/store/rooms-shown.d.ts +8 -0
- package/dist/store/rooms-shown.d.ts.map +1 -0
- package/dist/store/rooms-shown.js +13 -0
- package/dist/store.d.ts +9 -6
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +11 -2
- package/dist/stored.d.ts +24 -13
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +73 -17
- package/dist/surface.d.ts +4 -3
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +12 -13
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +31 -17
- package/dist/tables.d.ts +14 -7
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +36 -15
- package/dist/tallies.d.ts.map +1 -1
- package/dist/tallies.js +1 -2
- package/dist/wire.d.ts +40 -3
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +11 -1
- package/package.json +3 -3
- package/dist/attempt.d.ts +0 -16
- package/dist/attempt.d.ts.map +0 -1
- package/dist/attempt.js +0 -70
- package/dist/job.d.ts +0 -5
- package/dist/job.d.ts.map +0 -1
- package/dist/job.js +0 -7
- package/dist/log.d.ts +0 -6
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -14
package/dist/install.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AdapterFailure, Authorization, DiscoveredRoom, NotReady, RetryableRefusal } from './adapter.js';
|
|
2
2
|
import { type Reads } from './bootstrap.js';
|
|
3
|
-
import type { Installation, RoomCoverage } from './readiness.js';
|
|
3
|
+
import type { Installation, InstallationAmount, RoomCoverage } from './readiness.js';
|
|
4
4
|
import { advancement, type Refresher } from './refresh.js';
|
|
5
5
|
import type { ReplicaRecord } from './replica.js';
|
|
6
6
|
import type { Runtime } from './runtime.js';
|
|
@@ -33,9 +33,15 @@ type Refreshed = {
|
|
|
33
33
|
kind: 'advanced';
|
|
34
34
|
}>;
|
|
35
35
|
export declare const ERASE_BATCH = 512;
|
|
36
|
-
export
|
|
36
|
+
export type InstallShare = {
|
|
37
|
+
readonly installing: boolean;
|
|
38
|
+
readonly downloading: boolean;
|
|
39
|
+
readonly bytes: InstallationAmount;
|
|
40
|
+
};
|
|
41
|
+
export declare function installShare(store: Store, { room, state }: RoomCoverage, held: ReadonlyMap<string, CoveredRoom>): InstallShare;
|
|
42
|
+
export declare function installationOf(installing: number, downloading: number, bytes: InstallationAmount): Installation;
|
|
37
43
|
export declare function roomInFlight(store: Store, locator: string): boolean;
|
|
38
|
-
export declare function sweep({ store, socket
|
|
44
|
+
export declare function sweep({ store, socket }: Runtime): void;
|
|
39
45
|
export declare function caughtUpTo(runtime: Runtime, locator: string): void;
|
|
40
46
|
export declare function catching(store: Store, locator: string): void;
|
|
41
47
|
export declare function standingAt(store: Store, locator: string, held: Pick<ReplicaRecord, 'key'> | undefined): Standing;
|
|
@@ -46,7 +52,7 @@ export declare function reachedBy({ store, socket }: Runtime, locator: string, r
|
|
|
46
52
|
export declare function behind({ store, socket }: Runtime, room: DiscoveredRoom): Promise<boolean>;
|
|
47
53
|
export declare function writtenAfter({ store, socket }: Runtime, locator: string, roomVersion: string, path: string): Promise<boolean>;
|
|
48
54
|
export declare function pullRefresh(runtime: Runtime, authorized: Authorization, record: ReplicaRecord, liveness: Live, hold: InstallHold, refresh: Refresher): Promise<Refreshed>;
|
|
49
|
-
export declare function pullBootstrap(runtime: Runtime, authorized: Authorization, room: DiscoveredRoom, local: RuntimeStore, liveness: Live, prior: ReplicaRecord | undefined, from?: Reads, unheld?: Unheld): Promise<import("./bootstrap.js").Bootstrapped | NotReady | import("./adapter.js").RevokedAuthorization | import("./adapter.js").RoomNotReadable | Unconfirmed | {
|
|
55
|
+
export declare function pullBootstrap(runtime: Runtime, authorized: Authorization, room: DiscoveredRoom, local: RuntimeStore, liveness: Live, prior: ReplicaRecord | undefined, from?: Reads, unheld?: Unheld): Promise<import("./bootstrap.js").Bootstrapped | NotReady | import("./adapter.js").RevokedAuthorization | import("./adapter.js").RoomNotReadable | import("./adapter.js").TransportUncertainty | Unconfirmed | {
|
|
50
56
|
readonly kind: 'transport-uncertainty';
|
|
51
57
|
} | RetryableRefusal | import("./adapter.js").ScopedRefusal>;
|
|
52
58
|
export declare function publish(runtime: Runtime, local: RuntimeStore, room: DiscoveredRoom, reached: ReplicaRecord, landing: Landing, live: Live): Promise<boolean>;
|
package/dist/install.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,cAAc,EACd,QAAQ,EACR,gBAAgB,EAEjB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAkC,KAAK,KAAK,EAAgB,MAAM,gBAAgB,CAAC;AAO1F,OAAO,KAAK,EACV,YAAY,
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,cAAc,EACd,QAAQ,EACR,gBAAgB,EAEjB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAkC,KAAK,KAAK,EAAgB,MAAM,gBAAgB,CAAC;AAO1F,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAElB,YAAY,EACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAmB,MAAM,cAAc,CAAC;AAC5E,OAAO,KAAK,EAAE,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from, bytes) {
|
|
|
79
79
|
}
|
|
80
80
|
return end;
|
|
81
81
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
bytes
|
|
99
|
-
|
|
100
|
-
|
|
82
|
+
const UNSHARED = {
|
|
83
|
+
installing: false,
|
|
84
|
+
downloading: false,
|
|
85
|
+
bytes: { done: 0, total: 0 },
|
|
86
|
+
};
|
|
87
|
+
export function installShare(store, { room, state }, held) {
|
|
88
|
+
if (state === 'unadmitted')
|
|
89
|
+
return UNSHARED;
|
|
90
|
+
const install = store.installs.of(room);
|
|
91
|
+
const underway = state === 'acquiring' || (install.installing && state !== 'complete');
|
|
92
|
+
const kept = underway ? NOTHING_HELD.bytes : (held.get(room)?.bytes ?? NOTHING_HELD.bytes);
|
|
93
|
+
const now = amountOf(install, kept);
|
|
94
|
+
const earlier = underway ? install.startedOver : null;
|
|
95
|
+
return {
|
|
96
|
+
installing: underway,
|
|
97
|
+
downloading: underway && (install.streaming || install.arrived === null),
|
|
98
|
+
bytes: {
|
|
99
|
+
done: Math.max(now.done, earlier?.done ?? 0),
|
|
100
|
+
total: Math.max(now.total, earlier?.total ?? 0),
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
export function installationOf(installing, downloading, bytes) {
|
|
101
105
|
const step = installing === 0
|
|
102
106
|
? null
|
|
103
|
-
: downloading
|
|
107
|
+
: downloading > 0
|
|
104
108
|
? 'downloading'
|
|
105
109
|
: bytes.done < bytes.total
|
|
106
110
|
? 'writing'
|
|
@@ -113,15 +117,15 @@ export function roomInFlight(store, locator) {
|
|
|
113
117
|
}
|
|
114
118
|
function installing(runtime, locator) {
|
|
115
119
|
runtime.store.installs.change(locator, (held) => ({ ...held, installing: true }));
|
|
116
|
-
runtime.store.readiness.queue();
|
|
120
|
+
runtime.store.readiness.queue([locator]);
|
|
117
121
|
}
|
|
118
122
|
function installed(runtime, locator) {
|
|
119
123
|
if (!runtime.store.installs.of(locator).installing)
|
|
120
124
|
return;
|
|
121
125
|
runtime.store.installs.change(locator, (held) => ({ ...held, installing: false }));
|
|
122
|
-
runtime.store.readiness.queue();
|
|
126
|
+
runtime.store.readiness.queue([locator]);
|
|
123
127
|
}
|
|
124
|
-
export function sweep({ store, socket
|
|
128
|
+
export function sweep({ store, socket }) {
|
|
125
129
|
if (store.device.now().sweeping || socket.closed())
|
|
126
130
|
return;
|
|
127
131
|
store.device.set({ sweeping: true });
|
|
@@ -132,7 +136,6 @@ export function sweep({ store, socket, journal }) {
|
|
|
132
136
|
}
|
|
133
137
|
}
|
|
134
138
|
catch (error) {
|
|
135
|
-
journal.record('erasure failed');
|
|
136
139
|
uncaught(error);
|
|
137
140
|
}
|
|
138
141
|
finally {
|
|
@@ -144,7 +147,7 @@ export function caughtUpTo(runtime, locator) {
|
|
|
144
147
|
if (!runtime.store.installs.of(locator).catching)
|
|
145
148
|
return;
|
|
146
149
|
runtime.store.installs.change(locator, (held) => ({ ...held, catching: false }));
|
|
147
|
-
recoverReads(runtime);
|
|
150
|
+
recoverReads(runtime, [locator]);
|
|
148
151
|
}
|
|
149
152
|
export function catching(store, locator) {
|
|
150
153
|
store.installs.change(locator, (held) => ({ ...held, catching: true }));
|
|
@@ -263,7 +266,7 @@ function refreshingOf(runtime, local, locator, key, composition, liveness, repla
|
|
|
263
266
|
export async function pullRefresh(runtime, authorized, record, liveness, hold, refresh) {
|
|
264
267
|
if (!liveness())
|
|
265
268
|
return unconfirmed;
|
|
266
|
-
const { store
|
|
269
|
+
const { store } = runtime;
|
|
267
270
|
const from = standingAt(store, record.locator, record);
|
|
268
271
|
const local = await store.open();
|
|
269
272
|
try {
|
|
@@ -277,11 +280,8 @@ export async function pullRefresh(runtime, authorized, record, liveness, hold, r
|
|
|
277
280
|
hold.take();
|
|
278
281
|
}
|
|
279
282
|
}, authorized, record, (models, kept) => (liveness() ? remodel(runtime, models, kept) : kept), liveness, refreshingOf(runtime, local, record.locator, record.key, store.composed(record), liveness, false, record.roomVersion));
|
|
280
|
-
if (result.kind !== 'advanced')
|
|
281
|
-
journal.record(`transfer refresh ${record.locator} ${result.kind}`);
|
|
283
|
+
if (result.kind !== 'advanced')
|
|
282
284
|
return result;
|
|
283
|
-
}
|
|
284
|
-
journal.record(`transfer refresh ${record.locator} ${result.record.roomVersion}`);
|
|
285
285
|
return {
|
|
286
286
|
kind: 'advanced',
|
|
287
287
|
record: result.record,
|
|
@@ -292,14 +292,14 @@ export async function pullRefresh(runtime, authorized, record, liveness, hold, r
|
|
|
292
292
|
catch (error) {
|
|
293
293
|
if (refusedForSpace(error))
|
|
294
294
|
return unconfirmed;
|
|
295
|
-
journal.record(`transfer refresh ${record.locator} transport-uncertainty`);
|
|
296
295
|
throw error;
|
|
297
296
|
}
|
|
298
297
|
}
|
|
299
298
|
async function abandoned(runtime, local, locator) {
|
|
300
299
|
await local.abandon(locator);
|
|
301
300
|
runtime.store.installs.change(locator, (held) => transferGone(setBack(held)));
|
|
302
|
-
recoverReads(runtime);
|
|
301
|
+
recoverReads(runtime, [locator]);
|
|
302
|
+
runtime.store.readiness.queue([locator]);
|
|
303
303
|
sweep(runtime);
|
|
304
304
|
}
|
|
305
305
|
function staging(runtime, local, liveness, unheld) {
|
|
@@ -313,7 +313,7 @@ function staging(runtime, local, liveness, unheld) {
|
|
|
313
313
|
if (done === null)
|
|
314
314
|
return false;
|
|
315
315
|
store.installs.change(locator, (held) => built(held, done.done, done.text));
|
|
316
|
-
runtime.store.readiness.queue();
|
|
316
|
+
runtime.store.readiness.queue([locator]);
|
|
317
317
|
if (done.done)
|
|
318
318
|
return true;
|
|
319
319
|
}
|
|
@@ -337,9 +337,9 @@ function staging(runtime, local, liveness, unheld) {
|
|
|
337
337
|
arrived: bytes,
|
|
338
338
|
streaming: true,
|
|
339
339
|
}));
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
340
|
+
const due = store.installs.arrivalsDue(locator, performance.now(), ARRIVAL_REPORT_MS);
|
|
341
|
+
if (due.length > 0)
|
|
342
|
+
runtime.store.readiness.queue(due);
|
|
343
343
|
},
|
|
344
344
|
end() {
|
|
345
345
|
if (ended)
|
|
@@ -348,7 +348,7 @@ function staging(runtime, local, liveness, unheld) {
|
|
|
348
348
|
if (!store.installs.of(locator).streaming)
|
|
349
349
|
return;
|
|
350
350
|
store.installs.change(locator, (held) => ({ ...held, streaming: false }));
|
|
351
|
-
runtime.store.readiness.queue();
|
|
351
|
+
runtime.store.readiness.queue([locator]);
|
|
352
352
|
},
|
|
353
353
|
};
|
|
354
354
|
},
|
|
@@ -376,7 +376,7 @@ function staging(runtime, local, liveness, unheld) {
|
|
|
376
376
|
underived: owed,
|
|
377
377
|
}));
|
|
378
378
|
installing(runtime, locator);
|
|
379
|
-
recoverReads(runtime);
|
|
379
|
+
recoverReads(runtime, [locator]);
|
|
380
380
|
if (owed < store.deriveBytes())
|
|
381
381
|
return held;
|
|
382
382
|
return (await derived(locator, key, composition)) ? held : null;
|
|
@@ -411,7 +411,8 @@ function staging(runtime, local, liveness, unheld) {
|
|
|
411
411
|
done: { bytes },
|
|
412
412
|
};
|
|
413
413
|
store.installs.change(locator, (room) => ({ ...room, transfer: held }));
|
|
414
|
-
recoverReads(runtime);
|
|
414
|
+
recoverReads(runtime, [locator]);
|
|
415
|
+
store.readiness.queue([locator]);
|
|
415
416
|
return { record: held, staged: parted };
|
|
416
417
|
},
|
|
417
418
|
derive: derived,
|
|
@@ -427,7 +428,8 @@ function staging(runtime, local, liveness, unheld) {
|
|
|
427
428
|
if (!liveness())
|
|
428
429
|
return;
|
|
429
430
|
store.installs.change(locator, (held) => transferGone(setBack(held)));
|
|
430
|
-
recoverReads(runtime);
|
|
431
|
+
recoverReads(runtime, [locator]);
|
|
432
|
+
store.readiness.queue([locator]);
|
|
431
433
|
},
|
|
432
434
|
release: (key) => store.exclusive(async () => {
|
|
433
435
|
await local.release(key);
|
|
@@ -438,23 +440,20 @@ function staging(runtime, local, liveness, unheld) {
|
|
|
438
440
|
export async function pullBootstrap(runtime, authorized, room, local, liveness, prior, from = runtime.socket.reads, unheld) {
|
|
439
441
|
if (!liveness())
|
|
440
442
|
return unconfirmed;
|
|
441
|
-
const { store
|
|
443
|
+
const { store } = runtime;
|
|
442
444
|
if (prior !== undefined) {
|
|
443
445
|
catching(store, room.locator);
|
|
444
|
-
recoverReads(runtime);
|
|
446
|
+
recoverReads(runtime, [room.locator]);
|
|
445
447
|
}
|
|
446
448
|
try {
|
|
447
449
|
const result = await bootstrapRoom(from, authorized, room, {
|
|
448
450
|
collection: prior?.model ?? runtime.presence.unheldModel(room.locator) ?? NO_MODEL,
|
|
449
451
|
}, runtime.builtIn, runtime.typedPaths, (models, held) => (liveness() ? remodel(runtime, models, held) : held), liveness, staging(runtime, local, liveness, unheld));
|
|
450
|
-
const detail = result.kind === 'staged' ? result.record.roomVersion : result.kind;
|
|
451
|
-
journal.record(`transfer bootstrap ${room.locator} ${detail}`);
|
|
452
452
|
if (result.kind === 'staged' &&
|
|
453
453
|
(await older(runtime, room.locator, result.record.roomVersion))) {
|
|
454
454
|
caughtUpTo(runtime, room.locator);
|
|
455
455
|
installed(runtime, room.locator);
|
|
456
456
|
await abandoned(runtime, local, room.locator);
|
|
457
|
-
journal.record(`transfer bootstrap ${room.locator} older than shown`);
|
|
458
457
|
return { kind: 'transport-uncertainty' };
|
|
459
458
|
}
|
|
460
459
|
if (result.kind !== 'staged') {
|
|
@@ -468,7 +467,6 @@ export async function pullBootstrap(runtime, authorized, room, local, liveness,
|
|
|
468
467
|
installed(runtime, room.locator);
|
|
469
468
|
if (refusedForSpace(error))
|
|
470
469
|
return unconfirmed;
|
|
471
|
-
journal.record(`transfer bootstrap ${room.locator} transport-uncertainty`);
|
|
472
470
|
throw error;
|
|
473
471
|
}
|
|
474
472
|
}
|
|
@@ -510,6 +508,7 @@ export function publish(runtime, local, room, reached, landing, live) {
|
|
|
510
508
|
},
|
|
511
509
|
after() {
|
|
512
510
|
runtime.presence.installed(room.locator, landing.kind === 'bootstrapped');
|
|
511
|
+
runtime.retries.succeeded('download', room.locator);
|
|
513
512
|
store.prepareAgain(room.locator);
|
|
514
513
|
if (landing.kind === 'bootstrapped') {
|
|
515
514
|
store.installs.change(room.locator, (held) => ({
|
package/dist/lifecycle.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../src/lifecycle.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../src/lifecycle.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAoO5C,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,QAOhD;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,QAQ1C;AAED,wBAAgB,KAAK,CAAC,EACpB,KAAK,EACL,MAAM,EACN,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,WAAW,EACX,OAAO,GACR,EAAE,OAAO,QAST;AAED,wBAAsB,IAAI,CAAC,OAAO,EAAE,OAAO,iBAS1C;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,GAAG,SAAS,QAyCtE"}
|
package/dist/lifecycle.js
CHANGED
|
@@ -9,6 +9,7 @@ import { refuse } from './refusal.js';
|
|
|
9
9
|
import { moveTo, recoverReads, rest, SERVICE_MODE_TOPIC, show, submissionDue, transferring, } from './shown.js';
|
|
10
10
|
import { applyRoom, changeAuthority, countAuthorityChange, finishOpening, loadRoom, OPENING_LANE, reload, resynchronize, sync, } from './sync.js';
|
|
11
11
|
const CONVERSATION_LANE = 'conversations';
|
|
12
|
+
const RELOADING = 'reloading';
|
|
12
13
|
function closing(runtime, opened) {
|
|
13
14
|
const { store, socket } = runtime;
|
|
14
15
|
return socket.lanes.task(OPENING_LANE, async (live) => {
|
|
@@ -51,13 +52,13 @@ function owedReloads(runtime, expired, held) {
|
|
|
51
52
|
.map((room) => room.locator);
|
|
52
53
|
for (const locator of reloading)
|
|
53
54
|
catching(store, locator);
|
|
54
|
-
recoverReads(runtime);
|
|
55
|
+
recoverReads(runtime, reloading);
|
|
55
56
|
return reloading;
|
|
56
57
|
}
|
|
57
|
-
async function reloadNow(runtime, replacing, progress, held, installing) {
|
|
58
|
+
async function reloadNow(runtime, among, replacing, progress, held, installing) {
|
|
58
59
|
const { store, socket, presence } = runtime;
|
|
59
60
|
const { lanes } = socket;
|
|
60
|
-
const discovered = presence.rooms();
|
|
61
|
+
const discovered = among === null ? presence.rooms() : among.flatMap((locator) => presence.room(locator) ?? []);
|
|
61
62
|
const reloaded = discovered.filter((room) => held.has(room.locator) && !installing.has(room.locator) && replacing(room));
|
|
62
63
|
const acquired = discovered.filter((room) => (!held.has(room.locator) || installing.has(room.locator)) &&
|
|
63
64
|
room.replica.admission === 'admitted' &&
|
|
@@ -78,8 +79,10 @@ async function reloadNow(runtime, replacing, progress, held, installing) {
|
|
|
78
79
|
.roomTask(room.locator, (live) => loadRoom(runtime, room, local, progress, live, unheld))
|
|
79
80
|
.then(() => rest(runtime, progress));
|
|
80
81
|
}
|
|
82
|
+
runtime.retries.succeeded('download', RELOADING);
|
|
81
83
|
}
|
|
82
|
-
catch {
|
|
84
|
+
catch (error) {
|
|
85
|
+
runtime.retries.failed('download', RELOADING, error);
|
|
83
86
|
for (const room of reloaded)
|
|
84
87
|
presence.reload(room.locator, false);
|
|
85
88
|
progress.reachable = false;
|
|
@@ -93,12 +96,13 @@ function caughtUpRooms(runtime, expired) {
|
|
|
93
96
|
socket.named();
|
|
94
97
|
const cycle = progress ?? { complete: true, reachable: true };
|
|
95
98
|
replaced(store, expired);
|
|
96
|
-
const
|
|
97
|
-
const
|
|
99
|
+
const among = progress === null ? expired : null;
|
|
100
|
+
const installing = store.installs.underway(among);
|
|
101
|
+
const held = among === null ? store.rooms() : store.rooms(among);
|
|
98
102
|
const reloading = progress === null
|
|
99
103
|
? Promise.resolve([])
|
|
100
104
|
: held.then((stored) => owedReloads(runtime, expired, stored));
|
|
101
|
-
const replacing = Promise.all([held, reloading]).then(([stored, owed]) => reloadNow(runtime, (room) => expired.includes(room.locator) || owed.includes(room.locator), cycle, stored, installing));
|
|
105
|
+
const replacing = Promise.all([held, reloading]).then(([stored, owed]) => reloadNow(runtime, among, (room) => expired.includes(room.locator) || owed.includes(room.locator), cycle, stored, installing));
|
|
102
106
|
return socket.lanes.task(OPENING_LANE, async (live) => {
|
|
103
107
|
if (!live())
|
|
104
108
|
return;
|
|
@@ -120,8 +124,10 @@ function caughtUpRooms(runtime, expired) {
|
|
|
120
124
|
!owed.includes(room.locator))
|
|
121
125
|
.map((room) => [room.locator, declared(room)])), 'current', local);
|
|
122
126
|
}
|
|
127
|
+
runtime.retries.succeeded('download', OPENING_LANE);
|
|
123
128
|
}
|
|
124
|
-
catch {
|
|
129
|
+
catch (error) {
|
|
130
|
+
runtime.retries.failed('download', OPENING_LANE, error);
|
|
125
131
|
progress.complete = false;
|
|
126
132
|
progress.reachable = false;
|
|
127
133
|
}
|
|
@@ -130,7 +136,7 @@ function caughtUpRooms(runtime, expired) {
|
|
|
130
136
|
});
|
|
131
137
|
}
|
|
132
138
|
function signalled(runtime, mode) {
|
|
133
|
-
const { store, socket
|
|
139
|
+
const { store, socket } = runtime;
|
|
134
140
|
const { session } = socket;
|
|
135
141
|
const { closed, serviceMode, haltedRefusal, openSignals } = session.now();
|
|
136
142
|
if (closed)
|
|
@@ -142,8 +148,7 @@ function signalled(runtime, mode) {
|
|
|
142
148
|
session.set({ haltedRefusal: false });
|
|
143
149
|
if (mode !== serviceMode) {
|
|
144
150
|
session.set({ serviceMode: mode });
|
|
145
|
-
store.readiness.queue();
|
|
146
|
-
journal.record(`service mode ${mode}`);
|
|
151
|
+
store.readiness.queue([]);
|
|
147
152
|
store.tell(SERVICE_MODE_TOPIC, mode);
|
|
148
153
|
}
|
|
149
154
|
if (releasing)
|
|
@@ -158,7 +163,7 @@ async function runCurrency(runtime, live) {
|
|
|
158
163
|
return;
|
|
159
164
|
await reconcileConversations(conversations);
|
|
160
165
|
if (conversations.current()) {
|
|
161
|
-
|
|
166
|
+
await rest(runtime, null, live);
|
|
162
167
|
return;
|
|
163
168
|
}
|
|
164
169
|
const progress = {
|
|
@@ -168,8 +173,10 @@ async function runCurrency(runtime, live) {
|
|
|
168
173
|
moveTo(runtime, transferring(runtime));
|
|
169
174
|
try {
|
|
170
175
|
await catchUpConversations(conversations, progress);
|
|
176
|
+
runtime.retries.succeeded('conversations', CONVERSATION_LANE);
|
|
171
177
|
}
|
|
172
|
-
catch {
|
|
178
|
+
catch (error) {
|
|
179
|
+
runtime.retries.failed('conversations', CONVERSATION_LANE, error);
|
|
173
180
|
progress.reachable = false;
|
|
174
181
|
}
|
|
175
182
|
await rest(runtime, progress, live);
|
|
@@ -183,9 +190,8 @@ export function scheduleCurrency(runtime) {
|
|
|
183
190
|
void socket.lanes.task(CONVERSATION_LANE, (live) => runCurrency(runtime, live));
|
|
184
191
|
}
|
|
185
192
|
export function spaceFreed(runtime) {
|
|
186
|
-
const { store, socket
|
|
193
|
+
const { store, socket } = runtime;
|
|
187
194
|
store.prepareAgain();
|
|
188
|
-
journal.record('space freed');
|
|
189
195
|
store.readiness.queue();
|
|
190
196
|
const { closed, authorization } = socket.session.now();
|
|
191
197
|
if (closed || authorization === undefined)
|
|
@@ -222,7 +228,7 @@ export function start(runtime, signal) {
|
|
|
222
228
|
socket.observeServiceMode((mode) => signalled(runtime, mode));
|
|
223
229
|
socket.observeConversations((event) => {
|
|
224
230
|
if (event.kind === 'list' || event.kind === 'listed' || event.kind === 'unlisted')
|
|
225
|
-
store.readiness.queue();
|
|
231
|
+
store.readiness.queue([]);
|
|
226
232
|
receiveConversationEvent(conversations, event);
|
|
227
233
|
if (event.kind !== 'gap' || conversations.current())
|
|
228
234
|
return;
|
package/dist/listing.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { HeldRooms } from '@agentshouse/mdmodel';
|
|
2
2
|
import type { DiscoveredRoom, HeldRoom, OperationScopes, ProviderRefusal, ReplicaAdmission, RoomDeclaration } from './adapter.js';
|
|
3
3
|
import type { Composition } from './collection.js';
|
|
4
|
+
import type { KeyedChange } from './observation.js';
|
|
4
5
|
import { type ModelState, type TypesResult } from './model.js';
|
|
5
6
|
import { type PortReach } from './reach.js';
|
|
6
7
|
import type { ReplicaRecord } from './replica.js';
|
|
@@ -27,10 +28,11 @@ export type AppRoom = {
|
|
|
27
28
|
locked: boolean;
|
|
28
29
|
};
|
|
29
30
|
type ListedRoom = Omit<AppRoom, 'documents' | 'locked'>;
|
|
30
|
-
type ListedEntry = ListedRoom & {
|
|
31
|
+
export type ListedEntry = ListedRoom & {
|
|
31
32
|
readonly documents: number;
|
|
32
33
|
};
|
|
33
34
|
export type Listing = ReadonlyMap<string, ListedEntry>;
|
|
35
|
+
export type RoomsChange = KeyedChange<string, AppRoom>;
|
|
34
36
|
export declare function modelIn({ socket, presence }: Runtime, locator: string, stored: Stored | undefined): ModelState;
|
|
35
37
|
export declare function compositionFor(runtime: Runtime, record: ReplicaRecord): Composition;
|
|
36
38
|
export declare function declarationOf({ presence }: Runtime, locator: string, stored: Stored | undefined): {
|
|
@@ -38,9 +40,11 @@ export declare function declarationOf({ presence }: Runtime, locator: string, st
|
|
|
38
40
|
readonly available: boolean;
|
|
39
41
|
} | undefined;
|
|
40
42
|
export declare function listedLocators({ presence }: Runtime, held: ReadonlyMap<string, unknown>): string[];
|
|
41
|
-
export declare function
|
|
43
|
+
export declare function listedOrHeld({ presence }: Runtime, held: ReadonlyMap<string, unknown>, locator: string): boolean;
|
|
44
|
+
export declare function listedEntries(runtime: Runtime, touched: readonly string[]): Promise<readonly ListedEntry[] | null>;
|
|
42
45
|
export declare function listingNow(runtime: Runtime): Promise<Listing>;
|
|
43
|
-
export declare function shownRooms(
|
|
46
|
+
export declare function shownRooms(runtime: Runtime, listing: Listing): readonly AppRoom[];
|
|
47
|
+
export declare function shownChange(runtime: Runtime, entries: readonly ListedEntry[]): RoomsChange;
|
|
44
48
|
export declare function roomFacts(runtime: Runtime, reach?: PortReach | null): Promise<HeldRooms>;
|
|
45
49
|
export declare function heldRooms({ store }: Runtime, listed: readonly DiscoveredRoom[]): Promise<HeldRoom[]>;
|
|
46
50
|
export declare function name(runtime: Runtime, locator: string): Promise<void>;
|
package/dist/listing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listing.d.ts","sourceRoot":"","sources":["../src/listing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EACV,cAAc,EACd,QAAQ,EACR,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,eAAe,EAChB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"listing.d.ts","sourceRoot":"","sources":["../src/listing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EACV,cAAc,EACd,QAAQ,EACR,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,eAAe,EAChB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAwB,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AACrF,OA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,CAAC,SAAS,CAAC,CAoBpB;AAED,wBAAsB,SAAS,CAC7B,EAAE,KAAK,EAAE,EAAE,OAAO,EAClB,MAAM,EAAE,SAAS,cAAc,EAAE,GAChC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAYrB;AAED,wBAAsB,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAO3D"}
|
package/dist/listing.js
CHANGED
|
@@ -26,6 +26,9 @@ export function listedLocators({ presence }, held) {
|
|
|
26
26
|
const listed = presence.rooms().map(({ locator }) => locator);
|
|
27
27
|
return [...new Set([...listed, ...held.keys()])];
|
|
28
28
|
}
|
|
29
|
+
export function listedOrHeld({ presence }, held, locator) {
|
|
30
|
+
return presence.room(locator) !== undefined || held.has(locator);
|
|
31
|
+
}
|
|
29
32
|
function selectionModel({ socket, builtIn }) {
|
|
30
33
|
return socket.session.now().refusal?.code === 'revoked-authorization'
|
|
31
34
|
? { status: 'unavailable', reason: 'revoked' }
|
|
@@ -64,27 +67,27 @@ function listingOf(runtime, held) {
|
|
|
64
67
|
}
|
|
65
68
|
return listing;
|
|
66
69
|
}
|
|
67
|
-
export async function
|
|
70
|
+
export async function listedEntries(runtime, touched) {
|
|
68
71
|
const { store } = runtime;
|
|
69
|
-
|
|
70
|
-
if (roomsShown === null)
|
|
72
|
+
if (store.roomsShown.now() === null)
|
|
71
73
|
return null;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
if (touched.length === 0)
|
|
75
|
+
return [];
|
|
76
|
+
const held = await store.rooms(touched);
|
|
77
|
+
const entries = [];
|
|
78
|
+
for (const locator of touched) {
|
|
75
79
|
const room = listedRoom(runtime, locator, held.get(locator));
|
|
76
|
-
if (room === undefined ||
|
|
80
|
+
if (room === undefined || store.roomsShown.now()?.has(locator) !== true)
|
|
77
81
|
return null;
|
|
78
|
-
|
|
82
|
+
entries.push(room);
|
|
79
83
|
}
|
|
80
|
-
return
|
|
84
|
+
return entries;
|
|
81
85
|
}
|
|
82
86
|
export async function listingNow(runtime) {
|
|
83
87
|
return listingOf(runtime, await runtime.store.rooms());
|
|
84
88
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return structuredClone([...listing.values()].map(({ documents, ...room }) => locked.has(room.locator)
|
|
89
|
+
function shownRoom({ presence }, { documents, ...room }) {
|
|
90
|
+
return presence.lockedAs(room.locator, room.replica.offline)
|
|
88
91
|
? {
|
|
89
92
|
...room,
|
|
90
93
|
model: modelTypes(NO_MODEL),
|
|
@@ -92,7 +95,17 @@ export function shownRooms({ presence }, listing) {
|
|
|
92
95
|
documents: 0,
|
|
93
96
|
locked: true,
|
|
94
97
|
}
|
|
95
|
-
: { ...room, documents, locked: false }
|
|
98
|
+
: { ...room, documents, locked: false };
|
|
99
|
+
}
|
|
100
|
+
export function shownRooms(runtime, listing) {
|
|
101
|
+
return structuredClone([...listing.values()].map((entry) => shownRoom(runtime, entry)));
|
|
102
|
+
}
|
|
103
|
+
export function shownChange(runtime, entries) {
|
|
104
|
+
return {
|
|
105
|
+
changed: structuredClone(entries.map((entry) => [entry.locator, shownRoom(runtime, entry)])),
|
|
106
|
+
removed: [],
|
|
107
|
+
order: null,
|
|
108
|
+
};
|
|
96
109
|
}
|
|
97
110
|
export async function roomFacts(runtime, reach = null) {
|
|
98
111
|
const { store, socket, builtIn } = runtime;
|
package/dist/live.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ChangeSet } from './change-set.js';
|
|
2
2
|
import { type KeyedResult, type QueryMessage } from './observation.js';
|
|
3
|
-
import type { PendingResult, Plan, QueryCoverage } from './query.js';
|
|
3
|
+
import type { PendingResult, PendingRoom, Plan, QueryCoverage } from './query.js';
|
|
4
4
|
import type { Fail } from './reach.js';
|
|
5
5
|
import type { QueryRoom } from './tables.js';
|
|
6
6
|
export type Cover = {
|
|
@@ -11,13 +11,15 @@ export type Ran = KeyedResult & {
|
|
|
11
11
|
readonly current: () => boolean;
|
|
12
12
|
};
|
|
13
13
|
export type Run = (plan: Plan, cover: () => Promise<Cover>) => Promise<Ran>;
|
|
14
|
+
export type PendingAt<H> = (held: H, rooms: readonly string[]) => ReadonlyMap<string, PendingRoom | null> | null;
|
|
14
15
|
type Listener = (message: QueryMessage) => void;
|
|
15
16
|
export type LiveQueries<H> = {
|
|
16
17
|
touched(set: ChangeSet): void;
|
|
17
|
-
recover(): void;
|
|
18
|
-
watch(plan: Plan, identity: string, cover: (held: H) => Cover, deliver: Listener, failed: Fail): () => void;
|
|
18
|
+
recover(locators?: readonly string[]): void;
|
|
19
|
+
watch(plan: Plan, identity: string, cover: (held: H) => Cover, pendingAt: PendingAt<H>, deliver: Listener, failed: Fail): () => void;
|
|
19
20
|
close(): void;
|
|
20
21
|
};
|
|
22
|
+
export declare function readerOf(plan: Plan): (locator: string) => boolean;
|
|
21
23
|
export declare function createLiveQueries<H>(run: Run, holding: () => Promise<H>): LiveQueries<H>;
|
|
22
24
|
export {};
|
|
23
25
|
//# sourceMappingURL=live.d.ts.map
|
package/dist/live.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"live.d.ts","sourceRoot":"","sources":["../src/live.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,
|
|
1
|
+
{"version":3,"file":"live.d.ts","sourceRoot":"","sources":["../src/live.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAQL,KAAK,WAAW,EAChB,KAAK,YAAY,EAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAClF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE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