@agentshouse/mdruntime 0.1.0-c3903a68dcbbf → 0.1.0-c3c7796382e28
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 +25 -12
- package/dist/adapter.d.ts +216 -74
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +1 -9
- package/dist/attached-model.d.ts +15 -0
- package/dist/attached-model.d.ts.map +1 -0
- package/dist/attached-model.js +64 -0
- package/dist/attempt.d.ts +16 -0
- package/dist/attempt.d.ts.map +1 -0
- package/dist/attempt.js +70 -0
- package/dist/binary.d.ts +18 -0
- package/dist/binary.d.ts.map +1 -0
- package/dist/binary.js +8 -0
- package/dist/bootstrap.d.ts +44 -7
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +224 -46
- package/dist/chain.d.ts +11 -0
- package/dist/chain.d.ts.map +1 -0
- package/dist/chain.js +64 -0
- package/dist/change-set.d.ts +9 -14
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +11 -60
- package/dist/change.d.ts +45 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +34 -0
- package/dist/client.d.ts +37 -21
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +159 -35
- package/dist/collection.d.ts +14 -15
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +65 -63
- package/dist/compile.d.ts +16 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +765 -0
- package/dist/connection.d.ts +67 -42
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +4006 -1085
- package/dist/conversation.d.ts +59 -21
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +786 -243
- package/dist/digest.d.ts +7 -0
- package/dist/digest.d.ts.map +1 -0
- package/dist/digest.js +113 -0
- package/dist/durability.d.ts +5 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +5 -0
- package/dist/entry.d.ts +19 -0
- package/dist/entry.d.ts.map +1 -0
- package/dist/entry.js +151 -0
- package/dist/expectation.d.ts +21 -0
- package/dist/expectation.d.ts.map +1 -0
- package/dist/expectation.js +70 -0
- package/dist/failure.d.ts +13 -0
- package/dist/failure.d.ts.map +1 -0
- package/dist/failure.js +19 -0
- package/dist/fence.d.ts +6 -0
- package/dist/fence.d.ts.map +1 -0
- package/dist/fence.js +10 -0
- package/dist/file.d.ts +2 -19
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +7 -122
- package/dist/fulltext.d.ts +27 -0
- package/dist/fulltext.d.ts.map +1 -0
- package/dist/fulltext.js +368 -0
- package/dist/host.d.ts +21 -3
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +165 -72
- package/dist/identity.d.ts +4 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +16 -1
- package/dist/index.d.ts +19 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -1
- package/dist/live.d.ts +22 -0
- package/dist/live.d.ts.map +1 -0
- package/dist/live.js +124 -0
- package/dist/media.d.ts +8 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +208 -0
- package/dist/memory.d.ts +22 -8
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +207 -48
- package/dist/messages.d.ts +28 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +90 -0
- package/dist/model.d.ts +23 -14
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +22 -4
- package/dist/name.d.ts +4 -0
- package/dist/name.d.ts.map +1 -0
- package/dist/name.js +122 -0
- package/dist/observation.d.ts +21 -1
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +128 -17
- package/dist/open.d.ts +2 -0
- package/dist/open.d.ts.map +1 -0
- package/dist/open.js +1 -0
- package/dist/opened.d.ts +22 -0
- package/dist/opened.d.ts.map +1 -0
- package/dist/opened.js +107 -0
- package/dist/outcome.d.ts +75 -21
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +81 -1
- package/dist/overlay.d.ts +15 -5
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +136 -180
- package/dist/paths.d.ts +0 -1
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +0 -16
- package/dist/query.d.ts +78 -7
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +126 -43
- package/dist/reach.d.ts +53 -0
- package/dist/reach.d.ts.map +1 -0
- package/dist/reach.js +448 -0
- package/dist/react.d.ts +43 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +54 -0
- package/dist/readiness.d.ts +64 -0
- package/dist/readiness.d.ts.map +1 -0
- package/dist/readiness.js +33 -0
- package/dist/reads.d.ts +11 -0
- package/dist/reads.d.ts.map +1 -0
- package/dist/reads.js +100 -0
- package/dist/recovery.d.ts +25 -0
- package/dist/recovery.d.ts.map +1 -0
- package/dist/recovery.js +198 -0
- package/dist/refresh.d.ts +19 -7
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +125 -53
- package/dist/replica.d.ts +59 -33
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +324 -162
- package/dist/room-draft.d.ts +44 -9
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +191 -40
- package/dist/rows.d.ts +39 -34
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +195 -81
- package/dist/save.d.ts +72 -6
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +889 -179
- package/dist/search.d.ts +41 -29
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +37 -105
- package/dist/seed.d.ts +16 -0
- package/dist/seed.d.ts.map +1 -0
- package/dist/seed.js +75 -0
- package/dist/shared.d.ts +16 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +431 -0
- package/dist/status.d.ts +6 -2
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +0 -8
- package/dist/store.d.ts +129 -70
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +373 -365
- package/dist/stored.d.ts +152 -0
- package/dist/stored.d.ts.map +1 -0
- package/dist/stored.js +571 -0
- package/dist/tables.d.ts +354 -0
- package/dist/tables.d.ts.map +1 -0
- package/dist/tables.js +624 -0
- package/dist/turn.d.ts +9 -0
- package/dist/turn.d.ts.map +1 -0
- package/dist/turn.js +75 -0
- package/dist/validation.d.ts +30 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +162 -0
- package/dist/windows.d.ts +22 -0
- package/dist/windows.d.ts.map +1 -0
- package/dist/windows.js +89 -0
- package/dist/wire.d.ts +194 -19
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +90 -67
- package/dist/words.d.ts +19 -0
- package/dist/words.d.ts.map +1 -0
- package/dist/words.js +150 -0
- package/package.json +33 -10
- package/AGENTS.md +0 -210
- package/dist/attachment.d.ts +0 -3
- package/dist/attachment.d.ts.map +0 -1
- package/dist/attachment.js +0 -8
- package/dist/read-side.d.ts +0 -14
- package/dist/read-side.d.ts.map +0 -1
- package/dist/read-side.js +0 -371
package/dist/memory.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { ROOM_CONTRACT_VERSION, } from './adapter.js';
|
|
2
|
-
import { MD_MODEL } from './collection.js';
|
|
3
1
|
import { sameChange } from './overlay.js';
|
|
2
|
+
const ATTACHMENTS = 'attachments';
|
|
3
|
+
function lastName(path) {
|
|
4
|
+
return path.slice(path.lastIndexOf('/') + 1);
|
|
5
|
+
}
|
|
4
6
|
const FIXTURE_RETENTION = {
|
|
5
7
|
history: { kind: 'duration', seconds: 1 },
|
|
6
|
-
outcome:
|
|
8
|
+
outcome: 604_800,
|
|
7
9
|
refreshHorizon: 1,
|
|
8
10
|
};
|
|
9
11
|
function declaredRetention(value) {
|
|
@@ -15,6 +17,14 @@ function declaredRetention(value) {
|
|
|
15
17
|
}
|
|
16
18
|
throw new Error('history retention duration must be a finite positive number of seconds');
|
|
17
19
|
}
|
|
20
|
+
const MODEL_ABSENT = { kind: 'model-unavailable', reason: 'not-readable' };
|
|
21
|
+
function modelsOf(room) {
|
|
22
|
+
return { collection: room.model ?? MODEL_ABSENT };
|
|
23
|
+
}
|
|
24
|
+
function changedModels(room, from) {
|
|
25
|
+
const now = modelsOf(room);
|
|
26
|
+
return JSON.stringify(now) === JSON.stringify(modelsOf(from)) ? undefined : now;
|
|
27
|
+
}
|
|
18
28
|
function named(source, paths) {
|
|
19
29
|
const taken = {};
|
|
20
30
|
for (const path of paths) {
|
|
@@ -31,8 +41,6 @@ async function resolveScript(answer, fallback, request) {
|
|
|
31
41
|
}
|
|
32
42
|
export function createMemoryAdapter(options = {}) {
|
|
33
43
|
let rooms = options.rooms === undefined ? [] : [...options.rooms];
|
|
34
|
-
const mdModel = options.mdModel ?? MD_MODEL;
|
|
35
|
-
const supportedVersions = options.supportedVersions ?? [ROOM_CONTRACT_VERSION];
|
|
36
44
|
const capabilities = options.capabilities ?? [];
|
|
37
45
|
const providerLimits = options.providerLimits ?? [];
|
|
38
46
|
const retention = declaredRetention(options.retention);
|
|
@@ -46,8 +54,12 @@ export function createMemoryAdapter(options = {}) {
|
|
|
46
54
|
const scripted = new Map();
|
|
47
55
|
const unsealed = new Map();
|
|
48
56
|
const sealed = new Set();
|
|
57
|
+
const sentTurns = new Map();
|
|
49
58
|
const historyPageSize = options.historyPageSize;
|
|
50
|
-
|
|
59
|
+
const attached = new Map();
|
|
60
|
+
const linked = new WeakMap();
|
|
61
|
+
let held = [];
|
|
62
|
+
let expiring = [];
|
|
51
63
|
let replicated = [];
|
|
52
64
|
let issued = 0;
|
|
53
65
|
function scriptConversations(entries) {
|
|
@@ -76,6 +88,19 @@ export function createMemoryAdapter(options = {}) {
|
|
|
76
88
|
const wanted = ordinals.get(`${locator}\u0000${target}`);
|
|
77
89
|
return held !== undefined && wanted !== undefined && held >= wanted;
|
|
78
90
|
}
|
|
91
|
+
function heldBlob(room, path) {
|
|
92
|
+
return attached.get(`${room.locator}\u0000${path}`) ?? room.blobs?.[path];
|
|
93
|
+
}
|
|
94
|
+
function freePath(room, name) {
|
|
95
|
+
const dot = name.lastIndexOf('.');
|
|
96
|
+
const stem = dot > 0 ? name.slice(0, dot) : name;
|
|
97
|
+
const extension = dot > 0 ? name.slice(dot) : '';
|
|
98
|
+
for (let count = 1;; count += 1) {
|
|
99
|
+
const path = `${ATTACHMENTS}/${count === 1 ? stem : `${stem}-${count}`}${extension}`;
|
|
100
|
+
if (heldBlob(room, path) === undefined && room.documents?.[path] === undefined)
|
|
101
|
+
return path;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
79
104
|
function retain(entries) {
|
|
80
105
|
for (const room of entries) {
|
|
81
106
|
note(room.locator, room);
|
|
@@ -89,38 +114,54 @@ export function createMemoryAdapter(options = {}) {
|
|
|
89
114
|
return {
|
|
90
115
|
name: room.name,
|
|
91
116
|
locator: room.locator,
|
|
117
|
+
handle: room.handle,
|
|
92
118
|
roomVersion: room.roomVersion,
|
|
93
119
|
operations: room.operations,
|
|
94
120
|
replica: room.replica,
|
|
95
|
-
attachedModel: room.attachedModel,
|
|
96
121
|
...(room.typedSelection === undefined ? {} : { typedSelection: room.typedSelection }),
|
|
97
|
-
...(room.untypedFolders === undefined ? {} : { untypedFolders: room.untypedFolders }),
|
|
98
122
|
providerOwnedPaths: room.providerOwnedPaths,
|
|
99
123
|
};
|
|
100
124
|
}
|
|
101
|
-
function page(room,
|
|
125
|
+
function page(room, after) {
|
|
102
126
|
const paths = Object.keys(room.documents ?? {}).sort();
|
|
127
|
+
const opening = after === undefined;
|
|
128
|
+
const from = opening ? 0 : paths.filter((path) => path <= after).length;
|
|
103
129
|
const size = pageSize ?? paths.length;
|
|
104
130
|
const taken = paths.slice(from, from + size);
|
|
105
131
|
const next = from + taken.length;
|
|
106
|
-
const targets =
|
|
132
|
+
const targets = opening ? Object.keys(room.binaryFiles ?? {}) : [];
|
|
107
133
|
return {
|
|
108
134
|
kind: 'bootstrap',
|
|
109
135
|
roomVersion: room.roomVersion,
|
|
136
|
+
...(opening ? { models: modelsOf(room) } : {}),
|
|
110
137
|
documents: named(room.documents ?? {}, taken),
|
|
111
|
-
revisions: named(room.revisions ?? {}, taken),
|
|
138
|
+
revisions: named(room.revisions ?? {}, [...taken, ...targets]),
|
|
139
|
+
...(room.fileIds === undefined
|
|
140
|
+
? {}
|
|
141
|
+
: { fileIds: named(room.fileIds, [...taken, ...targets]) }),
|
|
112
142
|
changes: named(room.changes ?? {}, [...taken, ...targets]),
|
|
113
|
-
|
|
114
|
-
...(
|
|
115
|
-
...(next < paths.length ? { pageToken:
|
|
143
|
+
binaryFiles: named(room.binaryFiles ?? {}, targets),
|
|
144
|
+
...(opening && room.folders !== undefined ? { folders: room.folders } : {}),
|
|
145
|
+
...(next < paths.length ? { pageToken: taken.at(-1) } : {}),
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
function foldersMoved(room, from) {
|
|
149
|
+
const now = new Set(room.folders ?? []);
|
|
150
|
+
const before = new Set(from.folders ?? []);
|
|
151
|
+
const folders = [...now].filter((folder) => !before.has(folder)).sort();
|
|
152
|
+
const folderRemovals = [...before].filter((folder) => !now.has(folder)).sort();
|
|
153
|
+
return {
|
|
154
|
+
...(folders.length === 0 ? {} : { folders }),
|
|
155
|
+
...(folderRemovals.length === 0 ? {} : { folderRemovals }),
|
|
116
156
|
};
|
|
117
157
|
}
|
|
118
158
|
function advancement(room, from, at) {
|
|
119
159
|
const current = room.documents ?? {};
|
|
120
160
|
const previous = from.documents ?? {};
|
|
121
|
-
const currentTargets = new Set(room.
|
|
122
|
-
const previousTargets = new Set(from.
|
|
161
|
+
const currentTargets = new Set(Object.keys(room.binaryFiles ?? {}));
|
|
162
|
+
const previousTargets = new Set(Object.keys(from.binaryFiles ?? {}));
|
|
123
163
|
const headMoved = (path) => room.revisions?.[path] !== from.revisions?.[path] ||
|
|
164
|
+
room.fileIds?.[path] !== from.fileIds?.[path] ||
|
|
124
165
|
!sameChange(room.changes?.[path], from.changes?.[path]);
|
|
125
166
|
const changed = Object.keys(current)
|
|
126
167
|
.filter((path) => current[path] !== previous[path] || headMoved(path))
|
|
@@ -135,22 +176,25 @@ export function createMemoryAdapter(options = {}) {
|
|
|
135
176
|
const targets = opening
|
|
136
177
|
? [...currentTargets].filter((target) => !previousTargets.has(target) || headMoved(target))
|
|
137
178
|
: [];
|
|
138
|
-
const
|
|
139
|
-
const declared = opening && JSON.stringify(attachments) !== JSON.stringify(from.attachments ?? []);
|
|
179
|
+
const models = opening ? changedModels(room, from) : undefined;
|
|
140
180
|
return {
|
|
141
181
|
kind: 'net-advancement',
|
|
142
182
|
roomVersion: room.roomVersion,
|
|
183
|
+
...(models === undefined ? {} : { models }),
|
|
143
184
|
documents: named(current, taken),
|
|
144
|
-
revisions: named(room.revisions ?? {}, taken),
|
|
185
|
+
revisions: named(room.revisions ?? {}, [...taken, ...targets]),
|
|
186
|
+
...(room.fileIds === undefined
|
|
187
|
+
? {}
|
|
188
|
+
: { fileIds: named(room.fileIds, [...taken, ...targets]) }),
|
|
145
189
|
changes: named(room.changes ?? {}, [...taken, ...targets]),
|
|
146
|
-
|
|
190
|
+
binaryFiles: named(room.binaryFiles ?? {}, targets),
|
|
191
|
+
...(opening ? foldersMoved(room, from) : {}),
|
|
147
192
|
removals: opening
|
|
148
193
|
? [
|
|
149
194
|
...Object.keys(previous).filter((path) => !(path in current) && !currentTargets.has(path)),
|
|
150
195
|
...[...previousTargets].filter((target) => !currentTargets.has(target) && !(target in current)),
|
|
151
196
|
].sort()
|
|
152
197
|
: [],
|
|
153
|
-
...(declared ? { attachments } : {}),
|
|
154
198
|
...(pageToken === undefined ? {} : { pageToken }),
|
|
155
199
|
};
|
|
156
200
|
}
|
|
@@ -171,7 +215,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
171
215
|
function historiesOf(input) {
|
|
172
216
|
const asked = input?.conversations;
|
|
173
217
|
if (!Array.isArray(asked))
|
|
174
|
-
return { kind: 'rejected', code: 'invalid_request', fields: {} };
|
|
218
|
+
return { kind: 'rejected', code: 'invalid_request', fields: {}, retryable: false };
|
|
175
219
|
const histories = [];
|
|
176
220
|
for (const entry of asked) {
|
|
177
221
|
const conversation = typeof entry.conversation === 'string' ? scripted.get(entry.conversation) : undefined;
|
|
@@ -199,21 +243,32 @@ export function createMemoryAdapter(options = {}) {
|
|
|
199
243
|
const named = typeof input.conversation === 'string' ? input.conversation : '';
|
|
200
244
|
const conversation = scripted.get(named);
|
|
201
245
|
if (conversation === undefined) {
|
|
202
|
-
return {
|
|
246
|
+
return {
|
|
247
|
+
kind: 'rejected',
|
|
248
|
+
code: 'unknown-conversation',
|
|
249
|
+
fields: { conversation: named },
|
|
250
|
+
retryable: false,
|
|
251
|
+
};
|
|
203
252
|
}
|
|
204
253
|
const outcome = conversation.outcomes?.[name];
|
|
205
254
|
if (outcome !== undefined)
|
|
206
255
|
return outcome;
|
|
207
256
|
if (name === 'conversation.send') {
|
|
257
|
+
const operation = typeof input.operation_id === 'string' ? input.operation_id : null;
|
|
258
|
+
const answered = operation === null ? undefined : sentTurns.get(operation);
|
|
259
|
+
if (answered !== undefined)
|
|
260
|
+
return { kind: 'action', result: { turn: answered } };
|
|
208
261
|
issued += 1;
|
|
209
262
|
const turn = `turn-${issued}`;
|
|
210
263
|
unsealed.set(turn, named);
|
|
264
|
+
if (operation !== null)
|
|
265
|
+
sentTurns.set(operation, turn);
|
|
211
266
|
return { kind: 'action', result: { turn } };
|
|
212
267
|
}
|
|
213
268
|
if (name === 'conversation.cancel') {
|
|
214
269
|
const turn = typeof input.turn === 'string' ? input.turn : '';
|
|
215
270
|
if (sealed.has(turn) || !unsealed.has(turn)) {
|
|
216
|
-
return { kind: 'rejected', code: 'turn-sealed', fields: { turn } };
|
|
271
|
+
return { kind: 'rejected', code: 'turn-sealed', fields: { turn }, retryable: false };
|
|
217
272
|
}
|
|
218
273
|
unsealed.delete(turn);
|
|
219
274
|
return { kind: 'action', result: { turn, cancelled: true } };
|
|
@@ -222,18 +277,24 @@ export function createMemoryAdapter(options = {}) {
|
|
|
222
277
|
scripted.delete(named);
|
|
223
278
|
return { kind: 'action', result: { conversation: named } };
|
|
224
279
|
}
|
|
280
|
+
function announceList() {
|
|
281
|
+
const entries = [...scripted.values()].flatMap(({ conversation, listed }) => listed === undefined ? [] : [{ conversation, ...listed }]);
|
|
282
|
+
for (const listener of listeners)
|
|
283
|
+
listener({ kind: 'list', entries });
|
|
284
|
+
}
|
|
225
285
|
function discovery() {
|
|
226
286
|
return {
|
|
227
287
|
kind: 'discovery',
|
|
228
|
-
supportedVersions,
|
|
229
|
-
mdModel,
|
|
230
288
|
rooms: rooms.map(declared),
|
|
231
289
|
capabilities,
|
|
232
290
|
providerLimits,
|
|
233
291
|
retention,
|
|
292
|
+
...(options.member === undefined ? {} : { member: options.member }),
|
|
234
293
|
};
|
|
235
294
|
}
|
|
236
295
|
return {
|
|
296
|
+
...(options.exhaustiveDiscovery === undefined ? {} : { exhaustiveDiscovery: true }),
|
|
297
|
+
...(options.roomTypes === undefined ? {} : { roomTypes: options.roomTypes }),
|
|
237
298
|
setRooms(next) {
|
|
238
299
|
rooms = [...next];
|
|
239
300
|
retain(rooms);
|
|
@@ -241,9 +302,28 @@ export function createMemoryAdapter(options = {}) {
|
|
|
241
302
|
setConversations(next) {
|
|
242
303
|
scriptConversations(next);
|
|
243
304
|
},
|
|
244
|
-
|
|
305
|
+
open() {
|
|
306
|
+
announceList();
|
|
307
|
+
for (const observer of observers)
|
|
308
|
+
observer({ kind: 'opened' });
|
|
309
|
+
},
|
|
310
|
+
close({ revoked = false, lost = !revoked } = {}) {
|
|
245
311
|
for (const observer of observers)
|
|
246
|
-
observer(
|
|
312
|
+
observer({ kind: 'closed', revoked, lost });
|
|
313
|
+
},
|
|
314
|
+
expire(locators) {
|
|
315
|
+
expiring = [...locators];
|
|
316
|
+
},
|
|
317
|
+
notifyRoomVersion({ locator, roomVersion }) {
|
|
318
|
+
for (const observer of observers)
|
|
319
|
+
observer({ kind: 'room-version', locator, roomVersion });
|
|
320
|
+
},
|
|
321
|
+
notifyAuthorityChanged(scope) {
|
|
322
|
+
for (const observer of observers) {
|
|
323
|
+
observer(scope === undefined
|
|
324
|
+
? { kind: 'authority-changed' }
|
|
325
|
+
: { kind: 'authority-changed', scope });
|
|
326
|
+
}
|
|
247
327
|
},
|
|
248
328
|
notifyConversation(event) {
|
|
249
329
|
if (event.kind === 'accepted-message') {
|
|
@@ -257,8 +337,8 @@ export function createMemoryAdapter(options = {}) {
|
|
|
257
337
|
for (const observer of modeObservers)
|
|
258
338
|
observer(mode);
|
|
259
339
|
},
|
|
260
|
-
|
|
261
|
-
return
|
|
340
|
+
heldRooms() {
|
|
341
|
+
return held;
|
|
262
342
|
},
|
|
263
343
|
replicatedConversations() {
|
|
264
344
|
return replicated;
|
|
@@ -282,12 +362,47 @@ export function createMemoryAdapter(options = {}) {
|
|
|
282
362
|
};
|
|
283
363
|
},
|
|
284
364
|
},
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
365
|
+
roomStream: {
|
|
366
|
+
hold(asked) {
|
|
367
|
+
held = asked.map((room) => room.locator);
|
|
368
|
+
const expired = expiring.filter((locator) => held.includes(locator));
|
|
369
|
+
expiring = [];
|
|
370
|
+
const moved = asked.flatMap((room) => {
|
|
371
|
+
const current = rooms.find((entry) => entry.locator === room.locator);
|
|
372
|
+
return current === undefined ||
|
|
373
|
+
expired.includes(room.locator) ||
|
|
374
|
+
current.roomVersion === room.roomVersion
|
|
375
|
+
? []
|
|
376
|
+
: [{ locator: room.locator, roomVersion: current.roomVersion }];
|
|
377
|
+
});
|
|
378
|
+
queueMicrotask(() => {
|
|
379
|
+
for (const observer of observers) {
|
|
380
|
+
for (const room of moved)
|
|
381
|
+
observer({ kind: 'room-version', ...room });
|
|
382
|
+
observer({ kind: 'opening', expired });
|
|
383
|
+
}
|
|
384
|
+
});
|
|
288
385
|
},
|
|
386
|
+
reopen() {
|
|
387
|
+
queueMicrotask(() => {
|
|
388
|
+
for (const observer of observers) {
|
|
389
|
+
observer({ kind: 'closed', revoked: false, lost: false });
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
},
|
|
393
|
+
published() { },
|
|
289
394
|
observe(notify) {
|
|
290
395
|
observers.add(notify);
|
|
396
|
+
queueMicrotask(() => {
|
|
397
|
+
if (!observers.has(notify))
|
|
398
|
+
return;
|
|
399
|
+
if (options.unopened === true) {
|
|
400
|
+
notify({ kind: 'closed', revoked: false, lost: true });
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
announceList();
|
|
404
|
+
notify({ kind: 'opened' });
|
|
405
|
+
});
|
|
291
406
|
return () => {
|
|
292
407
|
observers.delete(notify);
|
|
293
408
|
};
|
|
@@ -299,13 +414,6 @@ export function createMemoryAdapter(options = {}) {
|
|
|
299
414
|
else
|
|
300
415
|
scripts[operation] = answer;
|
|
301
416
|
},
|
|
302
|
-
async model(_authorization, request) {
|
|
303
|
-
return resolveScript(scripts.model, () => {
|
|
304
|
-
const room = rooms.find((entry) => entry.locator === request.locator);
|
|
305
|
-
const answer = request.attached === 'collection' ? room?.model : room?.selectionModel;
|
|
306
|
-
return answer ?? { kind: 'model-unavailable', reason: 'not-readable' };
|
|
307
|
-
}, request);
|
|
308
|
-
},
|
|
309
417
|
async authorize() {
|
|
310
418
|
return resolveScript(scripts.authorize, () => ({}), undefined);
|
|
311
419
|
},
|
|
@@ -318,13 +426,21 @@ export function createMemoryAdapter(options = {}) {
|
|
|
318
426
|
});
|
|
319
427
|
},
|
|
320
428
|
reached,
|
|
429
|
+
follows(locator, roomVersion, next) {
|
|
430
|
+
const scripted = scripts.follows;
|
|
431
|
+
if (typeof scripted === 'boolean')
|
|
432
|
+
return scripted;
|
|
433
|
+
if (scripted !== undefined)
|
|
434
|
+
return scripted(locator, roomVersion, next);
|
|
435
|
+
return true;
|
|
436
|
+
},
|
|
321
437
|
async bootstrap(_authorization, request) {
|
|
322
438
|
return resolveScript(scripts.bootstrap, () => {
|
|
323
439
|
const room = rooms.find((entry) => entry.locator === request.locator);
|
|
324
440
|
if (room === undefined) {
|
|
325
441
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
326
442
|
}
|
|
327
|
-
return page(room, request.pageToken
|
|
443
|
+
return page(room, request.pageToken);
|
|
328
444
|
}, request).then((answer) => note(request.locator, answer));
|
|
329
445
|
},
|
|
330
446
|
async refresh(_authorization, request) {
|
|
@@ -342,10 +458,6 @@ export function createMemoryAdapter(options = {}) {
|
|
|
342
458
|
}
|
|
343
459
|
return advancement(continuation.room, continuation.from, continuation.at);
|
|
344
460
|
}
|
|
345
|
-
if (request.minPosition !== undefined &&
|
|
346
|
-
!reached(room.locator, room.roomVersion, request.minPosition)) {
|
|
347
|
-
return { kind: 'retryable-refusal', code: 'replica_behind', fields: {} };
|
|
348
|
-
}
|
|
349
461
|
if (request.fromRoomVersion === room.roomVersion) {
|
|
350
462
|
return { kind: 'still-current' };
|
|
351
463
|
}
|
|
@@ -361,8 +473,20 @@ export function createMemoryAdapter(options = {}) {
|
|
|
361
473
|
if (room === undefined) {
|
|
362
474
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
363
475
|
}
|
|
364
|
-
return {
|
|
365
|
-
|
|
476
|
+
return {
|
|
477
|
+
kind: 'rejected',
|
|
478
|
+
code: 'unscripted-mutation',
|
|
479
|
+
fields: {},
|
|
480
|
+
retryable: false,
|
|
481
|
+
affected: {},
|
|
482
|
+
};
|
|
483
|
+
}, request).then((answer) => {
|
|
484
|
+
const destination = request.changeBatch.between?.destination.room;
|
|
485
|
+
if (answer.kind === 'accepted' && answer.destination !== undefined && destination) {
|
|
486
|
+
note(destination, answer.destination);
|
|
487
|
+
}
|
|
488
|
+
return note(request.locator, answer);
|
|
489
|
+
});
|
|
366
490
|
},
|
|
367
491
|
async history(_authorization, request) {
|
|
368
492
|
return resolveScript(scripts.history, () => {
|
|
@@ -376,11 +500,46 @@ export function createMemoryAdapter(options = {}) {
|
|
|
376
500
|
};
|
|
377
501
|
}, request);
|
|
378
502
|
},
|
|
503
|
+
async binary(_authorization, request) {
|
|
504
|
+
return resolveScript(scripts.binary, () => {
|
|
505
|
+
const room = rooms.find((entry) => entry.locator === request.locator);
|
|
506
|
+
if (room === undefined)
|
|
507
|
+
return { kind: 'room-not-readable', locator: request.locator };
|
|
508
|
+
const blob = heldBlob(room, request.path);
|
|
509
|
+
return blob === undefined
|
|
510
|
+
? { kind: 'rejected', code: 'file_not_found', fields: {}, retryable: false }
|
|
511
|
+
: { kind: 'binary', body: blob.stream(), mediaType: blob.type };
|
|
512
|
+
}, request);
|
|
513
|
+
},
|
|
514
|
+
async link(_authorization, request) {
|
|
515
|
+
return resolveScript(scripts.link, () => {
|
|
516
|
+
const room = rooms.find((entry) => entry.locator === request.locator);
|
|
517
|
+
if (room === undefined)
|
|
518
|
+
return { kind: 'room-not-readable', locator: request.locator };
|
|
519
|
+
const blob = heldBlob(room, request.path);
|
|
520
|
+
if (blob === undefined) {
|
|
521
|
+
return { kind: 'rejected', code: 'file_not_found', fields: {}, retryable: false };
|
|
522
|
+
}
|
|
523
|
+
const url = linked.get(blob) ?? URL.createObjectURL(blob);
|
|
524
|
+
linked.set(blob, url);
|
|
525
|
+
return { kind: 'link', url, name: lastName(request.path), mediaType: blob.type };
|
|
526
|
+
}, request);
|
|
527
|
+
},
|
|
528
|
+
async attach(_authorization, request) {
|
|
529
|
+
return resolveScript(scripts.attach, () => {
|
|
530
|
+
const room = rooms.find((entry) => entry.locator === request.locator);
|
|
531
|
+
if (room === undefined)
|
|
532
|
+
return { kind: 'room-not-readable', locator: request.locator };
|
|
533
|
+
const path = freePath(room, request.name);
|
|
534
|
+
attached.set(`${room.locator}\u0000${path}`, request.blob);
|
|
535
|
+
return { kind: 'attached', path, revision: `attached-${attached.size}` };
|
|
536
|
+
}, request);
|
|
537
|
+
},
|
|
379
538
|
async action(_authorization, request) {
|
|
380
539
|
return resolveScript(scripts.action, () => {
|
|
381
540
|
if (request.name.startsWith('conversation.'))
|
|
382
541
|
return conversationAction(request);
|
|
383
|
-
return { kind: 'rejected', code: 'unscripted-action', fields: {} };
|
|
542
|
+
return { kind: 'rejected', code: 'unscripted-action', fields: {}, retryable: false };
|
|
384
543
|
}, request).then((answer) => {
|
|
385
544
|
if (answer.kind === 'action' && answer.at !== undefined)
|
|
386
545
|
note(answer.at.locator, answer.at);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { AcceptedMessage } from './adapter.js';
|
|
2
|
+
import type { Connection } from './tables.js';
|
|
3
|
+
export declare const MESSAGE_TABLES: readonly string[];
|
|
4
|
+
export type HeldConversation = {
|
|
5
|
+
readonly conversation: string;
|
|
6
|
+
readonly read: string | null | undefined;
|
|
7
|
+
readonly partial: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type MessageWindow = {
|
|
10
|
+
readonly messages: AcceptedMessage[];
|
|
11
|
+
readonly more: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type ConversationWrite = {
|
|
14
|
+
readonly conversation: string;
|
|
15
|
+
readonly messages: readonly AcceptedMessage[];
|
|
16
|
+
readonly read?: {
|
|
17
|
+
readonly at: string | null;
|
|
18
|
+
readonly partial: boolean;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export declare function heldConversations(connection: Connection): HeldConversation[];
|
|
22
|
+
export declare function keptMessages(connection: Connection, { conversation, messages, read }: ConversationWrite): null;
|
|
23
|
+
export declare function messageWindow(connection: Connection, conversation: string, limit: number, before: readonly [string, string] | null): MessageWindow;
|
|
24
|
+
export declare function messageCount(connection: Connection, conversation: string): number;
|
|
25
|
+
export declare function turnArrived(connection: Connection, conversation: string, turn: string): boolean;
|
|
26
|
+
export declare function droppedMessages(connection: Connection, conversations: readonly string[]): void;
|
|
27
|
+
export declare function forgottenMessages(connection: Connection): void;
|
|
28
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,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;AAED,wBAAgB,WAAW,CAAC,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAO/F;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAW9F;AAED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAG9D"}
|
package/dist/messages.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { indexMessage, unindexMessages } from './fulltext.js';
|
|
2
|
+
export const MESSAGE_TABLES = [
|
|
3
|
+
'CREATE TABLE conversation_reads (conversation TEXT PRIMARY KEY, read TEXT, partial INTEGER NOT NULL) WITHOUT ROWID',
|
|
4
|
+
'CREATE TABLE conversation_messages (id INTEGER PRIMARY KEY, conversation TEXT NOT NULL, identity TEXT NOT NULL, turn TEXT NOT NULL, position TEXT NOT NULL, message TEXT NOT NULL, text TEXT NOT NULL)',
|
|
5
|
+
'CREATE UNIQUE INDEX conversation_messages_identity ON conversation_messages (conversation, identity)',
|
|
6
|
+
'CREATE INDEX conversation_messages_position ON conversation_messages (conversation, position, identity)',
|
|
7
|
+
'CREATE INDEX conversation_messages_turn ON conversation_messages (conversation, turn)',
|
|
8
|
+
];
|
|
9
|
+
function text(value) {
|
|
10
|
+
return typeof value === 'string' ? value : String(value);
|
|
11
|
+
}
|
|
12
|
+
export function heldConversations(connection) {
|
|
13
|
+
const held = new Map();
|
|
14
|
+
for (const row of connection.rows('SELECT conversation, read, partial FROM conversation_reads')) {
|
|
15
|
+
held.set(text(row.conversation), {
|
|
16
|
+
conversation: text(row.conversation),
|
|
17
|
+
read: row.read === null ? null : text(row.read),
|
|
18
|
+
partial: Number(row.partial) === 1,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
for (const row of connection.rows('SELECT DISTINCT conversation FROM conversation_messages WHERE conversation NOT IN (SELECT conversation FROM conversation_reads)')) {
|
|
22
|
+
held.set(text(row.conversation), {
|
|
23
|
+
conversation: text(row.conversation),
|
|
24
|
+
read: undefined,
|
|
25
|
+
partial: true,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return [...held.values()];
|
|
29
|
+
}
|
|
30
|
+
export function keptMessages(connection, { conversation, messages, read }) {
|
|
31
|
+
for (const message of messages) {
|
|
32
|
+
const [held] = connection.rows('SELECT id FROM conversation_messages WHERE conversation = ? AND identity = ?', [conversation, message.identity]);
|
|
33
|
+
const record = [
|
|
34
|
+
message.turn,
|
|
35
|
+
message.position,
|
|
36
|
+
JSON.stringify(message.message ?? null),
|
|
37
|
+
message.text,
|
|
38
|
+
];
|
|
39
|
+
let id;
|
|
40
|
+
if (held === undefined) {
|
|
41
|
+
connection.run('INSERT INTO conversation_messages (conversation, identity, turn, position, message, text) VALUES (?, ?, ?, ?, ?, ?)', [conversation, message.identity, ...record]);
|
|
42
|
+
id = Number(connection.rows('SELECT last_insert_rowid() AS id')[0].id);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
id = Number(held.id);
|
|
46
|
+
unindexMessages(connection, [id]);
|
|
47
|
+
connection.run('UPDATE conversation_messages SET turn = ?, position = ?, message = ?, text = ? WHERE id = ?', [...record, id]);
|
|
48
|
+
}
|
|
49
|
+
indexMessage(connection, id, message.text);
|
|
50
|
+
}
|
|
51
|
+
if (read !== undefined) {
|
|
52
|
+
connection.run('INSERT OR REPLACE INTO conversation_reads (conversation, read, partial) VALUES (?, ?, ?)', [conversation, read.at, read.partial ? 1 : 0]);
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
function accepted(row) {
|
|
57
|
+
return {
|
|
58
|
+
identity: text(row.identity),
|
|
59
|
+
turn: text(row.turn),
|
|
60
|
+
position: text(row.position),
|
|
61
|
+
text: text(row.text),
|
|
62
|
+
message: JSON.parse(text(row.message)),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export function messageWindow(connection, conversation, limit, before) {
|
|
66
|
+
const rows = connection.rows(`SELECT identity, turn, position, message, text FROM conversation_messages WHERE conversation = ?${before === null ? '' : ' AND (position < ? OR (position = ? AND identity < ?))'} ORDER BY position DESC, identity DESC LIMIT ?`, before === null
|
|
67
|
+
? [conversation, limit + 1]
|
|
68
|
+
: [conversation, before[0], before[0], before[1], limit + 1]);
|
|
69
|
+
return { messages: rows.slice(0, limit).map(accepted).reverse(), more: rows.length > limit };
|
|
70
|
+
}
|
|
71
|
+
export function messageCount(connection, conversation) {
|
|
72
|
+
const [counted] = connection.rows('SELECT count(*) AS held FROM conversation_messages WHERE conversation = ?', [conversation]);
|
|
73
|
+
return Number(counted?.held ?? 0);
|
|
74
|
+
}
|
|
75
|
+
export function turnArrived(connection, conversation, turn) {
|
|
76
|
+
return (connection.rows('SELECT 1 FROM conversation_messages WHERE conversation = ? AND turn = ? LIMIT 1', [conversation, turn]).length > 0);
|
|
77
|
+
}
|
|
78
|
+
export function droppedMessages(connection, conversations) {
|
|
79
|
+
for (const conversation of conversations) {
|
|
80
|
+
unindexMessages(connection, connection
|
|
81
|
+
.rows('SELECT id FROM conversation_messages WHERE conversation = ?', [conversation])
|
|
82
|
+
.map((row) => Number(row.id)));
|
|
83
|
+
connection.run('DELETE FROM conversation_messages WHERE conversation = ?', [conversation]);
|
|
84
|
+
connection.run('DELETE FROM conversation_reads WHERE conversation = ?', [conversation]);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export function forgottenMessages(connection) {
|
|
88
|
+
connection.run('DELETE FROM conversation_messages');
|
|
89
|
+
connection.run('DELETE FROM conversation_reads');
|
|
90
|
+
}
|
package/dist/model.d.ts
CHANGED
|
@@ -1,55 +1,64 @@
|
|
|
1
|
-
import type { Definition,
|
|
1
|
+
import type { Definition, ValueFacts, VerifiedModel } from '@agentshouse/mdmodel';
|
|
2
|
+
import type { Open } from './open.js';
|
|
2
3
|
export type ModelIdentity = {
|
|
3
4
|
identity: string;
|
|
4
5
|
version: string;
|
|
5
6
|
};
|
|
6
7
|
export type ModelSnapshot = ModelIdentity & {
|
|
7
8
|
schema: string | null;
|
|
9
|
+
revision: string | null;
|
|
8
10
|
};
|
|
9
|
-
export type ModelUnavailableReason = 'not-readable' | 'revoked' | 'not-acquired' | '
|
|
11
|
+
export type ModelUnavailableReason = Open<'not-readable' | 'revoked' | 'not-acquired' | 'invalid'>;
|
|
10
12
|
export type ModelResult = {
|
|
11
13
|
kind: 'model';
|
|
12
14
|
snapshot: ModelSnapshot;
|
|
13
15
|
} | {
|
|
14
16
|
kind: 'model-unavailable';
|
|
15
17
|
reason: ModelUnavailableReason;
|
|
16
|
-
} | {
|
|
17
|
-
kind: 'transport-uncertainty';
|
|
18
|
-
} | {
|
|
19
|
-
kind: 'revoked-authorization';
|
|
20
|
-
};
|
|
21
|
-
export type MdType = {
|
|
22
|
-
name: string;
|
|
23
|
-
fields: Readonly<Record<string, FieldSpec>>;
|
|
24
|
-
sections: Readonly<Record<string, SectionSpec>>;
|
|
25
18
|
};
|
|
19
|
+
export type MdType = Definition;
|
|
26
20
|
export type ModelState = {
|
|
27
21
|
status: 'unavailable';
|
|
28
22
|
reason: ModelUnavailableReason;
|
|
23
|
+
schema?: string | null;
|
|
24
|
+
revision?: string | null;
|
|
29
25
|
} | {
|
|
30
26
|
status: 'current' | 'cached';
|
|
31
27
|
snapshot: ModelSnapshot;
|
|
32
28
|
verifiedWith: ModelIdentity;
|
|
33
29
|
types: VerifiedModel['types'];
|
|
34
30
|
};
|
|
35
|
-
export type
|
|
31
|
+
export type StoredModel = Extract<ModelState, {
|
|
36
32
|
status: 'unavailable';
|
|
33
|
+
}> | Omit<Extract<ModelState, {
|
|
34
|
+
status: 'current' | 'cached';
|
|
35
|
+
}>, 'types'>;
|
|
36
|
+
export type TypesResult = {
|
|
37
|
+
status: Open<'unavailable'>;
|
|
37
38
|
reason: ModelUnavailableReason;
|
|
39
|
+
types: null;
|
|
40
|
+
schema?: string | null;
|
|
41
|
+
revision?: string | null;
|
|
38
42
|
} | {
|
|
39
|
-
status: 'current' | 'cached'
|
|
43
|
+
status: Open<'current' | 'cached'>;
|
|
40
44
|
identity: string;
|
|
41
45
|
version: string;
|
|
42
46
|
verifiedWith: ModelIdentity;
|
|
43
47
|
types: readonly MdType[];
|
|
48
|
+
schema: string | null;
|
|
49
|
+
revision: string | null;
|
|
44
50
|
};
|
|
45
51
|
export type ValidationReceipt = {
|
|
46
52
|
identity: string;
|
|
47
53
|
version: string;
|
|
48
|
-
source: 'current' | 'cached'
|
|
54
|
+
source: Open<'current' | 'cached'>;
|
|
49
55
|
};
|
|
50
56
|
export declare const NO_MODEL: ModelState;
|
|
51
57
|
export declare function definitionOf(state: ModelState, type: string | undefined): Definition | undefined;
|
|
52
58
|
export declare function modelTypes(state: ModelState): TypesResult;
|
|
59
|
+
export declare function storedModel(state: ModelState): StoredModel;
|
|
53
60
|
export declare function cached(state: ModelState): ModelState;
|
|
54
61
|
export declare function sameModel(left: ModelIdentity, right: ModelIdentity): boolean;
|
|
62
|
+
export declare function sameTyping(left: ModelState, right: ModelState): boolean;
|
|
63
|
+
export declare function referenceField(facts: ValueFacts | undefined): boolean;
|
|
55
64
|
//# sourceMappingURL=model.d.ts.map
|
package/dist/model.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAClF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,MAAM,aAAa,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAA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