@agentshouse/mdruntime 0.1.0-c93103f5357ff → 0.1.0-c94cfdbdb6f68
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/AGENTS.md +194 -194
- package/README.md +8 -8
- package/dist/adapter.d.ts +20 -6
- package/dist/adapter.d.ts.map +1 -1
- package/dist/bootstrap.d.ts +2 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/chat/earlier.d.ts +10 -0
- package/dist/chat/earlier.d.ts.map +1 -0
- package/dist/chat/earlier.js +54 -0
- package/dist/chat/list.d.ts.map +1 -1
- package/dist/chat/list.js +39 -3
- package/dist/chat/provider.d.ts.map +1 -1
- package/dist/chat/provider.js +11 -12
- package/dist/chat/question.d.ts +1 -1
- package/dist/chat/question.d.ts.map +1 -1
- package/dist/chat/question.js +7 -18
- package/dist/chat/style.js +1 -1
- package/dist/client.d.ts +6 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +7 -3
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +64 -34
- package/dist/connection.d.ts +9 -4
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +312 -154
- package/dist/conversation.d.ts +6 -0
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +161 -41
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +2 -1
- package/dist/host.d.ts +0 -3
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +8 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/memory.d.ts +6 -3
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +17 -11
- package/dist/observation.d.ts +2 -0
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +9 -3
- package/dist/outcome.d.ts +8 -2
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +3 -0
- package/dist/query.d.ts +21 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +28 -5
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +13 -0
- package/dist/react.d.ts +1 -2
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +2 -14
- package/dist/read-side.d.ts +3 -1
- package/dist/read-side.d.ts.map +1 -1
- package/dist/read-side.js +251 -69
- package/dist/reads.d.ts +11 -0
- package/dist/reads.d.ts.map +1 -0
- package/dist/reads.js +98 -0
- package/dist/refresh.d.ts +4 -4
- package/dist/refresh.d.ts.map +1 -1
- package/dist/replica.d.ts +5 -1
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +19 -3
- package/dist/rows.d.ts +1 -0
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +5 -0
- package/dist/save.d.ts +1 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +22 -8
- package/dist/search.d.ts +15 -2
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +76 -17
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +18 -4
- package/dist/store.d.ts +16 -2
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +48 -14
- package/dist/turn.d.ts +3 -3
- package/dist/turn.d.ts.map +1 -1
- package/dist/turn.js +11 -5
- package/dist/windows.d.ts +26 -0
- package/dist/windows.d.ts.map +1 -0
- package/dist/windows.js +93 -0
- package/dist/wire.d.ts +16 -0
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +4 -0
- package/package.json +2 -2
- package/dist/acquisition.d.ts +0 -14
- package/dist/acquisition.d.ts.map +0 -1
- package/dist/acquisition.js +0 -24
package/dist/conversation.d.ts
CHANGED
|
@@ -36,10 +36,14 @@ export type ChatDraft = {
|
|
|
36
36
|
};
|
|
37
37
|
export type ConversationOptions = {
|
|
38
38
|
limit?: number;
|
|
39
|
+
after?: string;
|
|
40
|
+
total?: true;
|
|
39
41
|
};
|
|
40
42
|
export type ConversationView = {
|
|
41
43
|
conversation: string;
|
|
42
44
|
messages: readonly ConversationMessage[];
|
|
45
|
+
next?: string;
|
|
46
|
+
total?: number;
|
|
43
47
|
turn: RunningTurn | null;
|
|
44
48
|
questions: readonly unknown[];
|
|
45
49
|
process: {
|
|
@@ -64,6 +68,7 @@ export type ConversationSurface = {
|
|
|
64
68
|
};
|
|
65
69
|
export type ChatDraftSurface = {
|
|
66
70
|
write(conversation: string, draft: ChatDraft, revision?: string): Promise<void>;
|
|
71
|
+
prepend(conversation: string, draft: ChatDraft): Promise<void>;
|
|
67
72
|
discard(conversation: string): Promise<void>;
|
|
68
73
|
};
|
|
69
74
|
export type ConversationDependencies = {
|
|
@@ -89,6 +94,7 @@ export type ConversationStore = {
|
|
|
89
94
|
known(): boolean;
|
|
90
95
|
reconnected(): void;
|
|
91
96
|
reopened(): void;
|
|
97
|
+
lost(): void;
|
|
92
98
|
watch(conversation: string, options: ConversationOptions, deliver: (view: ConversationView) => void): () => void;
|
|
93
99
|
watchList(deliver: (entries: readonly ConversationEntry[]) => void): () => void;
|
|
94
100
|
watchAgents(deliver: (agents: readonly ConversationAgent[]) => void): () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../src/conversation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EAEjB,mBAAmB,EACnB,kBAAkB,EAElB,cAAc,EACd,aAAa,EACb,WAAW,EAEZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAyB,KAAK,SAAS,EAAsB,MAAM,iBAAiB,CAAC;AAE5F,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAE7D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAW,KAAK,UAAU,EAAE,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,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OAAO,EAAE,CAAC,OAAO,EAAE,SAAS,iBAAiB,EAAE,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAChF,WAAW,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,SAAS,iBAAiB,EAAE,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IACjF,OAAO,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,CAAC;IAC9B,OAAO,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC;IAC3C,UAAU,IAAI,SAAS,MAAM,EAAE,CAAC;IAChC,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC;IACxC,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AA2BF,wBAAgB,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,gBAAgB,CAWjE;AAED,eAAO,MAAM,eAAe,oBAAoB,CAAC;AAIjD,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7C;AAyPD,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,wBAAwB,GAAG,iBAAiB,CA+2BzF"}
|
package/dist/conversation.js
CHANGED
|
@@ -3,6 +3,7 @@ import { runtimeError } from './failure.js';
|
|
|
3
3
|
import { declaredFile } from './file.js';
|
|
4
4
|
import { changeBatchIdentity, chatDraftRevision } from './identity.js';
|
|
5
5
|
import { OFFLINE } from './outcome.js';
|
|
6
|
+
import { capped, cursorOf, decodedCursor, FROM_START, messageOrder, precedes } from './windows.js';
|
|
6
7
|
const QUIET = {
|
|
7
8
|
turn: null,
|
|
8
9
|
questions: [],
|
|
@@ -10,6 +11,7 @@ const QUIET = {
|
|
|
10
11
|
commands: [],
|
|
11
12
|
options: [],
|
|
12
13
|
};
|
|
14
|
+
const FACTS = ['questions', 'process', 'commands', 'options'];
|
|
13
15
|
export function unheldView(conversation) {
|
|
14
16
|
return {
|
|
15
17
|
conversation,
|
|
@@ -82,19 +84,25 @@ function appliedTurn(held, operation) {
|
|
|
82
84
|
parts: held.parts.map((kept, at) => (at === operation.index ? changed : kept)),
|
|
83
85
|
};
|
|
84
86
|
}
|
|
85
|
-
function ordered(left, right) {
|
|
86
|
-
if (left.position !== right.position)
|
|
87
|
-
return left.position < right.position ? -1 : 1;
|
|
88
|
-
if (left.identity !== right.identity)
|
|
89
|
-
return left.identity < right.identity ? -1 : 1;
|
|
90
|
-
return 0;
|
|
91
|
-
}
|
|
92
87
|
function windowOf(held, arriving, limit) {
|
|
93
88
|
const byIdentity = new Map(held.map((message) => [message.identity, message]));
|
|
94
89
|
for (const message of arriving)
|
|
95
90
|
byIdentity.set(message.identity, message);
|
|
96
|
-
const next = [...byIdentity.values()].sort(
|
|
97
|
-
|
|
91
|
+
const next = [...byIdentity.values()].sort(messageOrder);
|
|
92
|
+
const start = Math.max(0, next.length - limit);
|
|
93
|
+
return { messages: next.slice(start), dropped: start > 0 };
|
|
94
|
+
}
|
|
95
|
+
function frameOf(asked, messages, more, total) {
|
|
96
|
+
const oldest = messages[0];
|
|
97
|
+
const next = !more
|
|
98
|
+
? undefined
|
|
99
|
+
: oldest === undefined
|
|
100
|
+
? (asked.after ?? FROM_START)
|
|
101
|
+
: cursorOf([oldest.position, oldest.identity]);
|
|
102
|
+
return {
|
|
103
|
+
...(next === undefined ? {} : { next }),
|
|
104
|
+
...(total === null ? {} : { total }),
|
|
105
|
+
};
|
|
98
106
|
}
|
|
99
107
|
function newestOf(arriving, from) {
|
|
100
108
|
return arriving.reduce((top, message) => (top === null || message.position > top ? message.position : top), from);
|
|
@@ -165,14 +173,24 @@ function answered(result, field) {
|
|
|
165
173
|
const value = answer[field];
|
|
166
174
|
return typeof value === 'string' ? value : null;
|
|
167
175
|
}
|
|
168
|
-
function
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
if (
|
|
176
|
+
function beforeOf(after) {
|
|
177
|
+
if (after === undefined)
|
|
178
|
+
return null;
|
|
179
|
+
const decoded = typeof after === 'string' ? decodedCursor(after) : null;
|
|
180
|
+
if (decoded?.length === 0)
|
|
181
|
+
return null;
|
|
182
|
+
const [position, identity] = decoded ?? [];
|
|
183
|
+
if (decoded?.length !== 2 || typeof position !== 'string' || typeof identity !== 'string') {
|
|
184
|
+
throw runtimeError('invalid-after', `conversation after must be the next an earlier view returned, got ${String(after)}`);
|
|
185
|
+
}
|
|
186
|
+
return [position, identity];
|
|
187
|
+
}
|
|
188
|
+
function askedOf(options) {
|
|
189
|
+
const { limit, after, total } = options;
|
|
190
|
+
if (limit !== undefined && (!Number.isInteger(limit) || limit < 0)) {
|
|
173
191
|
throw runtimeError('invalid-limit', `conversation limit must be a non-negative integer, got ${String(limit)}`);
|
|
174
192
|
}
|
|
175
|
-
return limit;
|
|
193
|
+
return { limit: capped(limit), after, before: beforeOf(after), total: total === true };
|
|
176
194
|
}
|
|
177
195
|
const EXPIRED = { kind: 'rejected', code: 'expired', fields: {}, retryable: false };
|
|
178
196
|
function unwritten(draft) {
|
|
@@ -191,11 +209,16 @@ function withSubmitted(draft, submitted) {
|
|
|
191
209
|
const { submitted: _held, ...unsent } = draft;
|
|
192
210
|
return submitted.length === 0 ? unsent : { ...unsent, submitted };
|
|
193
211
|
}
|
|
212
|
+
function prepended(draft, said) {
|
|
213
|
+
return {
|
|
214
|
+
text: [said.text, draft.text].filter((one) => one !== '').join('\n'),
|
|
215
|
+
files: [...said.files, ...draft.files],
|
|
216
|
+
};
|
|
217
|
+
}
|
|
194
218
|
function returned(draft, submission, others) {
|
|
195
219
|
return withSubmitted({
|
|
196
220
|
conversation: draft.conversation,
|
|
197
|
-
|
|
198
|
-
files: [...submission.files, ...draft.files],
|
|
221
|
+
...prepended(draft, submission),
|
|
199
222
|
revision: chatDraftRevision(),
|
|
200
223
|
}, others);
|
|
201
224
|
}
|
|
@@ -206,8 +229,10 @@ export function createConversationStore(deps) {
|
|
|
206
229
|
const drafts = new Map();
|
|
207
230
|
const sending = new Map();
|
|
208
231
|
const behind = new Set();
|
|
232
|
+
const catching = new Map();
|
|
209
233
|
const gaps = new Map();
|
|
210
234
|
const lives = new Map();
|
|
235
|
+
const unsent = new Map();
|
|
211
236
|
const views = new Map();
|
|
212
237
|
const listing = new Map();
|
|
213
238
|
const creations = new Set();
|
|
@@ -222,7 +247,7 @@ export function createConversationStore(deps) {
|
|
|
222
247
|
function liveOf(conversation) {
|
|
223
248
|
return lives.get(conversation) ?? QUIET;
|
|
224
249
|
}
|
|
225
|
-
function viewOf(conversation, held) {
|
|
250
|
+
function viewOf(conversation, held, frame) {
|
|
226
251
|
const draft = drafts.get(conversation);
|
|
227
252
|
const facts = liveOf(conversation);
|
|
228
253
|
return {
|
|
@@ -233,6 +258,7 @@ export function createConversationStore(deps) {
|
|
|
233
258
|
text,
|
|
234
259
|
message,
|
|
235
260
|
})),
|
|
261
|
+
...frame,
|
|
236
262
|
turn: structuredClone(facts.turn),
|
|
237
263
|
questions: structuredClone(facts.questions),
|
|
238
264
|
process: facts.process === null ? null : { ...facts.process },
|
|
@@ -252,16 +278,34 @@ export function createConversationStore(deps) {
|
|
|
252
278
|
const ready = [...view.watchers].filter((watcher) => watcher.ready);
|
|
253
279
|
if (ready.length === 0)
|
|
254
280
|
continue;
|
|
255
|
-
const value = viewOf(conversation, view.window);
|
|
281
|
+
const value = viewOf(conversation, view.window, sharedFrame(view, view.window));
|
|
256
282
|
for (const watcher of ready)
|
|
257
283
|
watcher.notify(value);
|
|
258
284
|
}
|
|
259
285
|
}
|
|
260
|
-
function
|
|
286
|
+
function sharedFrame(view, window) {
|
|
287
|
+
return frameOf(view.asked, window, view.more, view.total);
|
|
288
|
+
}
|
|
289
|
+
async function slide(local, conversation, arriving) {
|
|
290
|
+
let count;
|
|
261
291
|
for (const view of views.values()) {
|
|
262
292
|
if (view.conversation !== conversation || view.window === null)
|
|
263
293
|
continue;
|
|
264
|
-
|
|
294
|
+
if (arriving === null) {
|
|
295
|
+
view.window = [];
|
|
296
|
+
view.more = false;
|
|
297
|
+
if (view.total !== null)
|
|
298
|
+
view.total = 0;
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
301
|
+
const joining = arriving.filter((message) => precedes(message, view.asked.before));
|
|
302
|
+
const next = windowOf(view.window, joining, view.asked.limit);
|
|
303
|
+
view.window = next.messages;
|
|
304
|
+
view.more ||= next.dropped;
|
|
305
|
+
if (view.total !== null && arriving.length > 0) {
|
|
306
|
+
count ??= await local.messageCount(conversation);
|
|
307
|
+
view.total = count;
|
|
308
|
+
}
|
|
265
309
|
}
|
|
266
310
|
}
|
|
267
311
|
function changesOf(conversation, arriving) {
|
|
@@ -363,9 +407,29 @@ export function createConversationStore(deps) {
|
|
|
363
407
|
return agentsRead;
|
|
364
408
|
}
|
|
365
409
|
function live(conversation, change) {
|
|
410
|
+
const owed = unsent.get(conversation);
|
|
411
|
+
for (const fact of FACTS.filter((one) => one in change))
|
|
412
|
+
owed?.delete(fact);
|
|
366
413
|
setLive(conversation, { ...liveOf(conversation), ...change });
|
|
367
414
|
emit(conversation);
|
|
368
415
|
}
|
|
416
|
+
function openingEnded() {
|
|
417
|
+
const owed = [...unsent];
|
|
418
|
+
unsent.clear();
|
|
419
|
+
for (const [conversation, facts] of owed) {
|
|
420
|
+
const held = lives.get(conversation);
|
|
421
|
+
if (held === undefined || facts.size === 0)
|
|
422
|
+
continue;
|
|
423
|
+
setLive(conversation, {
|
|
424
|
+
turn: held.turn,
|
|
425
|
+
questions: facts.has('questions') ? QUIET.questions : held.questions,
|
|
426
|
+
process: facts.has('process') ? QUIET.process : held.process,
|
|
427
|
+
commands: facts.has('commands') ? QUIET.commands : held.commands,
|
|
428
|
+
options: facts.has('options') ? QUIET.options : held.options,
|
|
429
|
+
});
|
|
430
|
+
emit(conversation);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
369
433
|
function relayed(conversation, turn, operation) {
|
|
370
434
|
const held = liveOf(conversation).turn;
|
|
371
435
|
const next = held?.turn === turn ? appliedTurn(held, operation) : startedTurn(turn, operation);
|
|
@@ -409,8 +473,9 @@ export function createConversationStore(deps) {
|
|
|
409
473
|
partials.delete(conversation);
|
|
410
474
|
drafts.delete(conversation);
|
|
411
475
|
behind.delete(conversation);
|
|
476
|
+
unsent.delete(conversation);
|
|
412
477
|
setLive(conversation, null);
|
|
413
|
-
slide(conversation, null);
|
|
478
|
+
await slide(local, conversation, null);
|
|
414
479
|
}
|
|
415
480
|
if (changed.length > 0)
|
|
416
481
|
deps.publish(conversationChangeSet(removed, changed));
|
|
@@ -438,11 +503,11 @@ export function createConversationStore(deps) {
|
|
|
438
503
|
if (advances)
|
|
439
504
|
reads.set(conversation, message.position);
|
|
440
505
|
sealTurns(conversation, new Set([message.turn]));
|
|
441
|
-
slide(conversation, [message]);
|
|
506
|
+
await slide(local, conversation, [message]);
|
|
442
507
|
deps.publish(conversationChangeSet(changesOf(conversation, [message]), [conversation]));
|
|
443
508
|
});
|
|
444
509
|
}
|
|
445
|
-
async function readHistories(conversations) {
|
|
510
|
+
async function readHistories(conversations, ended) {
|
|
446
511
|
const generations = new Map(conversations.map((one) => [one, gaps.get(one) ?? 0]));
|
|
447
512
|
let asking = conversations.map((conversation) => ({
|
|
448
513
|
conversation,
|
|
@@ -468,10 +533,33 @@ export function createConversationStore(deps) {
|
|
|
468
533
|
following.push({ conversation: page.conversation, after: page.next });
|
|
469
534
|
}
|
|
470
535
|
}
|
|
536
|
+
for (const { conversation } of asking) {
|
|
537
|
+
if (!following.some((next) => next.conversation === conversation))
|
|
538
|
+
ended(conversation);
|
|
539
|
+
}
|
|
471
540
|
asking = following;
|
|
472
541
|
}
|
|
473
542
|
return null;
|
|
474
543
|
}
|
|
544
|
+
function caughtUp(conversations) {
|
|
545
|
+
const ends = new Map();
|
|
546
|
+
for (const conversation of conversations) {
|
|
547
|
+
const held = new Promise((end) => ends.set(conversation, end));
|
|
548
|
+
catching.set(conversation, held);
|
|
549
|
+
void held.then(() => {
|
|
550
|
+
if (catching.get(conversation) === held)
|
|
551
|
+
catching.delete(conversation);
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
const ended = (conversation) => ends.get(conversation)?.();
|
|
555
|
+
const read = readHistories(conversations, ended);
|
|
556
|
+
const endAll = () => {
|
|
557
|
+
for (const conversation of conversations)
|
|
558
|
+
ended(conversation);
|
|
559
|
+
};
|
|
560
|
+
read.then(endAll, endAll);
|
|
561
|
+
return read;
|
|
562
|
+
}
|
|
475
563
|
function keepPage(conversation, arriving, from, next, generation) {
|
|
476
564
|
return deps.durably(async (local) => {
|
|
477
565
|
if (!replicated.has(conversation))
|
|
@@ -490,7 +578,7 @@ export function createConversationStore(deps) {
|
|
|
490
578
|
sealTurns(conversation, new Set(arriving.map((message) => message.turn)));
|
|
491
579
|
if (whole && (gaps.get(conversation) ?? 0) === generation)
|
|
492
580
|
behind.delete(conversation);
|
|
493
|
-
slide(conversation, arriving);
|
|
581
|
+
await slide(local, conversation, arriving);
|
|
494
582
|
if (arriving.length > 0 || sealing || whole) {
|
|
495
583
|
deps.publish(conversationChangeSet(changesOf(conversation, arriving), [conversation]));
|
|
496
584
|
}
|
|
@@ -501,11 +589,8 @@ export function createConversationStore(deps) {
|
|
|
501
589
|
if (event.kind === 'gap') {
|
|
502
590
|
if (replicated.has(conversation))
|
|
503
591
|
gap(conversation);
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
return;
|
|
507
|
-
setLive(conversation, { ...QUIET, turn: held.turn });
|
|
508
|
-
emit(conversation);
|
|
592
|
+
if (lives.has(conversation))
|
|
593
|
+
unsent.set(conversation, new Set(FACTS));
|
|
509
594
|
return;
|
|
510
595
|
}
|
|
511
596
|
if (event.kind === 'turn') {
|
|
@@ -667,8 +752,12 @@ export function createConversationStore(deps) {
|
|
|
667
752
|
return entries();
|
|
668
753
|
},
|
|
669
754
|
async read(conversation, options = {}) {
|
|
670
|
-
const
|
|
671
|
-
return deps.durably(async (local) =>
|
|
755
|
+
const asked = askedOf(options);
|
|
756
|
+
return deps.durably(async (local) => {
|
|
757
|
+
const { messages, more } = await local.messageWindow(conversation, asked.limit, asked.before);
|
|
758
|
+
const total = asked.total ? await local.messageCount(conversation) : null;
|
|
759
|
+
return structuredClone(viewOf(conversation, messages, frameOf(asked, messages, more, total)));
|
|
760
|
+
});
|
|
672
761
|
},
|
|
673
762
|
async create(input) {
|
|
674
763
|
const result = await deps.call('conversation.create', input);
|
|
@@ -732,6 +821,16 @@ export function createConversationStore(deps) {
|
|
|
732
821
|
...(current === undefined ? {} : pending(current)),
|
|
733
822
|
}));
|
|
734
823
|
},
|
|
824
|
+
prepend(conversation, draft) {
|
|
825
|
+
return withDraft(conversation, (current) => ({
|
|
826
|
+
conversation,
|
|
827
|
+
...(current === undefined
|
|
828
|
+
? { text: draft.text, files: [...draft.files] }
|
|
829
|
+
: prepended(current, draft)),
|
|
830
|
+
revision: chatDraftRevision(),
|
|
831
|
+
...(current === undefined ? {} : pending(current)),
|
|
832
|
+
}));
|
|
833
|
+
},
|
|
735
834
|
discard(conversation) {
|
|
736
835
|
return withDraft(conversation, (current) => current === undefined
|
|
737
836
|
? undefined
|
|
@@ -781,12 +880,20 @@ export function createConversationStore(deps) {
|
|
|
781
880
|
await remove(leaving);
|
|
782
881
|
},
|
|
783
882
|
async catchUp(progress) {
|
|
784
|
-
const
|
|
785
|
-
|
|
786
|
-
|
|
883
|
+
const owed = (conversation) => behind.has(conversation) && replicated.has(conversation);
|
|
884
|
+
const read = async (conversations) => {
|
|
885
|
+
if (conversations.length === 0 || deps.closed())
|
|
886
|
+
return;
|
|
887
|
+
const failed = await caughtUp(conversations);
|
|
787
888
|
if (failed?.kind === 'transport-uncertainty')
|
|
788
889
|
progress.reachable = false;
|
|
789
|
-
}
|
|
890
|
+
};
|
|
891
|
+
const asking = [...behind].filter(owed).sort();
|
|
892
|
+
const awaited = asking.filter((conversation) => catching.has(conversation));
|
|
893
|
+
await Promise.all([
|
|
894
|
+
read(asking.filter((conversation) => !catching.has(conversation))),
|
|
895
|
+
Promise.all(awaited.map((conversation) => catching.get(conversation))).then(() => read(awaited.filter((conversation) => owed(conversation) && !catching.has(conversation)))),
|
|
896
|
+
]);
|
|
790
897
|
if (behind.size > 0)
|
|
791
898
|
progress.complete = false;
|
|
792
899
|
},
|
|
@@ -828,27 +935,38 @@ export function createConversationStore(deps) {
|
|
|
828
935
|
reopened() {
|
|
829
936
|
sending.clear();
|
|
830
937
|
},
|
|
938
|
+
lost() {
|
|
939
|
+
catching.clear();
|
|
940
|
+
},
|
|
831
941
|
watch(conversation, options, deliver) {
|
|
832
|
-
const
|
|
833
|
-
const key = JSON.stringify([conversation, limit ?? null]);
|
|
942
|
+
const asked = askedOf(options);
|
|
943
|
+
const key = JSON.stringify([conversation, asked.limit, asked.after ?? null, asked.total]);
|
|
834
944
|
const view = views.get(key) ?? {
|
|
835
945
|
conversation,
|
|
836
|
-
|
|
946
|
+
asked,
|
|
837
947
|
watchers: new Set(),
|
|
838
948
|
window: null,
|
|
949
|
+
more: false,
|
|
950
|
+
total: null,
|
|
839
951
|
};
|
|
840
952
|
views.set(key, view);
|
|
841
953
|
const watcher = { notify: deliver, ready: false };
|
|
842
954
|
view.watchers.add(watcher);
|
|
843
955
|
void deps
|
|
844
956
|
.durably(async (local) => {
|
|
845
|
-
view.window
|
|
957
|
+
if (view.window !== null)
|
|
958
|
+
return;
|
|
959
|
+
const { messages, more } = await local.messageWindow(conversation, asked.limit, asked.before);
|
|
960
|
+
view.window = messages;
|
|
961
|
+
view.more = more;
|
|
962
|
+
view.total = asked.total ? await local.messageCount(conversation) : null;
|
|
846
963
|
})
|
|
847
964
|
.then(() => {
|
|
848
965
|
if (deps.closed() || !view.watchers.has(watcher))
|
|
849
966
|
return;
|
|
850
967
|
watcher.ready = true;
|
|
851
|
-
|
|
968
|
+
const window = view.window ?? [];
|
|
969
|
+
watcher.notify(viewOf(conversation, window, sharedFrame(view, window)));
|
|
852
970
|
})
|
|
853
971
|
.catch(() => { });
|
|
854
972
|
return () => {
|
|
@@ -900,6 +1018,7 @@ export function createConversationStore(deps) {
|
|
|
900
1018
|
creations.delete(entry.conversation);
|
|
901
1019
|
}
|
|
902
1020
|
listKnown = true;
|
|
1021
|
+
openingEnded();
|
|
903
1022
|
}
|
|
904
1023
|
else if (event.kind === 'listed') {
|
|
905
1024
|
listing.set(event.entry.conversation, { ...event.entry });
|
|
@@ -926,6 +1045,7 @@ export function createConversationStore(deps) {
|
|
|
926
1045
|
close() {
|
|
927
1046
|
views.clear();
|
|
928
1047
|
lives.clear();
|
|
1048
|
+
unsent.clear();
|
|
929
1049
|
listWatchers.clear();
|
|
930
1050
|
agentWatchers.clear();
|
|
931
1051
|
},
|
package/dist/entry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"AAGA,OAAO,EAML,KAAK,SAAS,EAEf,MAAM,YAAY,CAAC;AAIpB,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAE9D,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;AA0D7E,wBAAgB,UAAU,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAE3E;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,OAAO,GAAG,SAAS,MAAM,EAAE,CAMpE;AAkCD,wBAAgB,YAAY,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAQ7D;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,OAA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AAC,KAAK,EAAE,SAAS,SAAS,EAAE,GAAG,UAAU,CAuDlE"}
|
package/dist/entry.js
CHANGED
|
@@ -134,7 +134,7 @@ export function entryScope(rooms) {
|
|
|
134
134
|
after: rowsOf(room.locator, path, passingFrontmatter(collection, path) ?? null, composition, null, null, null),
|
|
135
135
|
}));
|
|
136
136
|
});
|
|
137
|
-
readSide.apply({
|
|
137
|
+
const seeded = readSide.apply({
|
|
138
138
|
documents,
|
|
139
139
|
drafts: [],
|
|
140
140
|
rooms: [],
|
|
@@ -146,6 +146,7 @@ export function entryScope(rooms) {
|
|
|
146
146
|
const planned = { listed: true, rooms: held };
|
|
147
147
|
return {
|
|
148
148
|
async results(queries) {
|
|
149
|
+
await seeded;
|
|
149
150
|
const results = {};
|
|
150
151
|
for (const [name, query] of Object.entries(queries)) {
|
|
151
152
|
results[name] = (await readSide.query(planOf(query, planned), () => null)).rows;
|
package/dist/host.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type MdRuntimeOptions } from './connection.js';
|
|
2
|
-
import type { RuntimeDemand } from './acquisition.js';
|
|
3
2
|
import type { PortReach } from './reach.js';
|
|
4
3
|
import type { CapacityCause, CodeAvailability, Persistence, Readiness, SearchObligation } from './readiness.js';
|
|
5
4
|
import type { EntrySeed } from './seed.js';
|
|
@@ -17,7 +16,6 @@ export type AttachedPort = {
|
|
|
17
16
|
};
|
|
18
17
|
export type MdRuntimeHost = {
|
|
19
18
|
attach(port: RuntimePort, app: string, release?: string, reach?: PortReach, code?: CodeAvailability, search?: SearchObligation): AttachedPort;
|
|
20
|
-
acquire(demand: RuntimeDemand): void;
|
|
21
19
|
seed(entry: EntrySeed): void;
|
|
22
20
|
persisted(answer: Persistence): void;
|
|
23
21
|
endAuthorization(holder?: string): Promise<void>;
|
|
@@ -25,7 +23,6 @@ export type MdRuntimeHost = {
|
|
|
25
23
|
stop(): Promise<void>;
|
|
26
24
|
};
|
|
27
25
|
export declare function serveMdRuntime(options: MdRuntimeHostOptions): MdRuntimeHost;
|
|
28
|
-
export type { RuntimeDemand } from './acquisition.js';
|
|
29
26
|
export { entrySeedOf, type EntrySeed } from './seed.js';
|
|
30
27
|
export type { PortReach, ReachedDocument } from './reach.js';
|
|
31
28
|
export type { CapacityCause, CodeAvailability, Persistence, SearchObligation, } from './readiness.js';
|
package/dist/host.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,gBAAgB,
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,gBAAgB,EAItB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,SAAS,EACT,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAG3C,OAAO,EAGL,KAAK,WAAW,EAOjB,MAAM,WAAW,CAAC;AAInB,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,GAAG;IAAE,eAAe,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEpF,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,IAAI,IAAI,CAAC;IACf,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IAC/B,SAAS,CAAC,OAAO,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAC/D,QAAQ,CAAC,OAAO,EAAE,SAAS,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAC9D,IAAI,CAAC,IAAI,EAAE,gBAAgB,EAAE,QAAQ,EAAE,aAAa,GAAG,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,MAAM,WAAW,CAAC"}
|
package/dist/host.js
CHANGED
|
@@ -16,10 +16,14 @@ function answered(md, app, writtenBy, member, input) {
|
|
|
16
16
|
return md.types(input[0]);
|
|
17
17
|
case 'save':
|
|
18
18
|
return md.save(input[0], input[1], writtenBy);
|
|
19
|
+
case 'saveParts':
|
|
20
|
+
return md.saveParts(input[0], input[1], writtenBy);
|
|
19
21
|
case 'history':
|
|
20
22
|
return md.history(input[0], input[1], input[2]);
|
|
21
23
|
case 'binaryFile.read':
|
|
22
24
|
return md.binaryFile.read(input[0], input[1], input[2]);
|
|
25
|
+
case 'binaryFile.link':
|
|
26
|
+
return md.binaryFile.link(input[0], input[1], input[2]);
|
|
23
27
|
case 'binaryFile.readReference':
|
|
24
28
|
return md.binaryFile.readReference(input[0]);
|
|
25
29
|
case 'call':
|
|
@@ -46,6 +50,8 @@ function answered(md, app, writtenBy, member, input) {
|
|
|
46
50
|
return md.presentation.read(app);
|
|
47
51
|
case 'presentation.write':
|
|
48
52
|
return md.presentation.write(app, input[0]);
|
|
53
|
+
case 'presentation.edit':
|
|
54
|
+
return md.presentation.edit(app, input[0]);
|
|
49
55
|
case 'conversation.list':
|
|
50
56
|
return md.conversation.list();
|
|
51
57
|
case 'conversation.read':
|
|
@@ -66,6 +72,8 @@ function answered(md, app, writtenBy, member, input) {
|
|
|
66
72
|
return md.conversation.delete(input[0]);
|
|
67
73
|
case 'chatDraft.write':
|
|
68
74
|
return md.chatDraft.write(input[0], input[1], input[2]);
|
|
75
|
+
case 'chatDraft.prepend':
|
|
76
|
+
return md.chatDraft.prepend(input[0], input[1]);
|
|
69
77
|
case 'chatDraft.discard':
|
|
70
78
|
return md.chatDraft.discard(input[0]);
|
|
71
79
|
}
|
|
@@ -224,9 +232,6 @@ export function serveMdRuntime(options) {
|
|
|
224
232
|
}
|
|
225
233
|
return {
|
|
226
234
|
attach,
|
|
227
|
-
acquire(demand) {
|
|
228
|
-
runtime.acquire(demand);
|
|
229
|
-
},
|
|
230
235
|
seed(entry) {
|
|
231
236
|
runtime.seed(entry);
|
|
232
237
|
},
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export type {
|
|
1
|
+
export type { AcceptedMessage, ActionDeclaration, ActionRequest, ActionResult, Adapter, AdapterFailure, Authorization, BinaryFile, BinaryLinkResult, BinaryRequest, BinaryResult, ReferrerScope, BootstrapPage, BootstrapRequest, BootstrapResult, Capability, ChangeAuthor, ContractUnavailable, ConversationAction, ConversationAgents, ConversationEvent, ConversationHistories, ConversationHistoryPage, ConversationHistoryRequest, ConversationMessage, ConversationStream, DiscoverResult, DiscoveredRoom, Discovery, DiscoveryScope, HistoryAuthor, HistoryRequest, HistoryResult, HistoryRetention, HistoryRevision, HeldContent, HeldRoom, KeptReceipt, ListedConversation, MdModelIdentity, Member, MutationRequest, MutationResult, PageToken, ProviderLimit, ProviderRefusal, RefreshPage, RefreshRequest, RefreshResult, Retention, RetryableRefusal, RevokedAuthorization, RoomModels, RoomNotReadable, RoomStream, RoomStreamEvent, RoomVersionAt, ServiceMode, ServiceModeSignal, StreamReceipts, TransportUncertainty, TurnContext, TurnOperation, TypedSelection, } from './adapter.js';
|
|
2
2
|
export type { Change, ChangeBatch, Precondition, WrittenBy } from './change.js';
|
|
3
3
|
export type { ChatDraft, ChatDraftSurface, ConversationAgent, ConversationEntry, ConversationOptions, ConversationState, ConversationSurface, ConversationView, RunningTurn, } from './conversation.js';
|
|
4
4
|
export type { ChatDraftFile, FileDeclaration } from './file.js';
|
|
5
|
-
export type { AppRoom, AppTypedSelection, BinaryFileSurface, ConnectionRefusal, ConnectionRefusalCode, HistoryQuery, MdRuntime, MdRuntimeOptions, PresentationSurface, RoomDraftSurface, RoomSchemas, SavedRoomDraft, SaveResult, } from './connection.js';
|
|
5
|
+
export type { AppRoom, AppTypedSelection, BinaryFileSurface, ConnectionRefusal, ConnectionRefusalCode, HistoryQuery, MdRuntime, MdRuntimeOptions, PresentationSurface, RoomDraftSurface, RoomSchemas, SavedParts, SavedRoomDraft, SaveResult, } from './connection.js';
|
|
6
6
|
export type { Observation } from './observation.js';
|
|
7
|
-
export type { BinaryAnswer, CallResult, Failure, HistoryAnswer, Offline, QueueEntry, Submission, } from './outcome.js';
|
|
7
|
+
export type { BinaryAnswer, BinaryLinkAnswer, CallResult, Failure, HistoryAnswer, Offline, QueueEntry, Submission, } from './outcome.js';
|
|
8
8
|
export type { BinaryFileRecord, BinaryReference } from './binary.js';
|
|
9
9
|
export type { RuntimeError } from './failure.js';
|
|
10
10
|
export type { ChangedPart, FieldValue, ReturnReason, RoomDraft, RoomDraftCreation, RoomDraftParts, RoomDraftWrite, TextParts, } from './room-draft.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,OAAO,EACP,cAAc,EACd,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAC1B,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,SAAS,EACT,cAAc,EACd,aAAa,EACb,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,QAAQ,EACR,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,MAAM,EACN,eAAe,EACf,cAAc,EACd,SAAS,EACT,aAAa,EACb,eAAe,EACf,WAAW,EACX,cAAc,EACd,aA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UAAU,EACV,WAAW,EACX,WAAW,EACX,iBAAiB,GAClB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/memory.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ModelResult } from './model.js';
|
|
2
|
-
import { type AcceptedMessage, type ActionResult, type Adapter, type BinaryFile, type Capability, type ConversationAction, type ConversationEvent, type DiscoveredRoom, type HeadChange, type ListedConversation, type Member, type ProviderLimit, type Retention, type
|
|
2
|
+
import { type AcceptedMessage, type ActionResult, type Adapter, type BinaryFile, type Capability, type ConversationAction, type ConversationEvent, type DiscoveryScope, type DiscoveredRoom, type HeadChange, type ListedConversation, type Member, type ProviderLimit, type Retention, type ServiceMode } from './adapter.js';
|
|
3
3
|
export type MemoryRoom = DiscoveredRoom & {
|
|
4
4
|
model?: ModelResult;
|
|
5
5
|
selectionModel?: ModelResult;
|
|
@@ -33,16 +33,19 @@ export type MemoryAdapter = Adapter & {
|
|
|
33
33
|
setConversations(conversations: readonly MemoryConversation[]): void;
|
|
34
34
|
script(operation: keyof Adapter, answer: unknown): void;
|
|
35
35
|
open(): void;
|
|
36
|
-
close(
|
|
36
|
+
close(closing?: {
|
|
37
|
+
revoked?: boolean;
|
|
38
|
+
lost?: boolean;
|
|
39
|
+
}): void;
|
|
37
40
|
expire(locators: readonly string[]): void;
|
|
38
41
|
notifyRoomVersion(notification: {
|
|
39
42
|
locator: string;
|
|
40
43
|
roomVersion: string;
|
|
41
44
|
}): void;
|
|
45
|
+
notifyAuthorityChanged(scope?: DiscoveryScope): void;
|
|
42
46
|
notifyConversation(event: ConversationEvent): void;
|
|
43
47
|
notifyServiceMode(mode: ServiceMode): void;
|
|
44
48
|
heldRooms(): readonly string[];
|
|
45
|
-
heldDemand(): AcquiredDemand | null;
|
|
46
49
|
replicatedConversations(): readonly string[];
|
|
47
50
|
};
|
|
48
51
|
export declare function createMemoryAdapter(options?: MemoryAdapterOptions): MemoryAdapter;
|
package/dist/memory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EACL,KAAK,eAAe,EAEpB,KAAK,YAAY,EACjB,KAAK,OAAO,EAEZ,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EACL,KAAK,eAAe,EAEpB,KAAK,YAAY,EACjB,KAAK,OAAO,EAEZ,KAAK,UAAU,EAMf,KAAK,UAAU,EACf,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EAItB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,UAAU,EAGf,KAAK,kBAAkB,EACvB,KAAK,MAAM,EAGX,KAAK,aAAa,EAIlB,KAAK,SAAS,EAGd,KAAK,WAAW,EACjB,MAAM,cAAc,CAAC;AAkBtB,MAAM,MAAM,UAAU,GAAG,cAAc,GAAG;IACxC,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,cAAc,CAAC,EAAE,WAAW,CAAC;IAC7B,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC7C,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC7C,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC3C,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IAC/C,WAAW,CAAC,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