@agentshouse/mdruntime 0.1.0-c9b1e59e5baeb → 0.1.0-ca10e63188fc5
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 +18 -15
- package/dist/adapter.d.ts +58 -32
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +5 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +21 -4
- package/dist/binary.d.ts +0 -5
- package/dist/binary.d.ts.map +1 -1
- package/dist/binary.js +1 -1
- package/dist/bootstrap.d.ts +30 -8
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +187 -85
- 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 +6 -16
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +11 -94
- package/dist/change.d.ts +31 -1
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +10 -1
- package/dist/client.d.ts +9 -5
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +80 -6
- package/dist/collection.d.ts +11 -20
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +53 -354
- 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 +17 -9
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +2431 -953
- package/dist/conversation.d.ts +4 -3
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +81 -68
- 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 +3 -5
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +5 -0
- package/dist/entry.d.ts +3 -1
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +18 -24
- 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 +4 -4
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +45 -15
- package/dist/identity.d.ts +0 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +0 -3
- package/dist/index.d.ts +11 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -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 +205 -0
- package/dist/memory.d.ts +2 -1
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +63 -22
- 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 +6 -0
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +7 -1
- 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 +13 -0
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +84 -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 +40 -5
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +38 -2
- package/dist/overlay.d.ts +1 -4
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +22 -148
- package/dist/query.d.ts +11 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +13 -1
- package/dist/reach.d.ts +11 -3
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +198 -69
- package/dist/readiness.d.ts +20 -9
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +6 -6
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +4 -2
- package/dist/recovery.d.ts +2 -2
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +8 -7
- package/dist/refresh.d.ts +15 -14
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +113 -75
- package/dist/replica.d.ts +56 -39
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +278 -197
- package/dist/room-draft.d.ts +4 -1
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +54 -13
- package/dist/rows.d.ts +38 -31
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +173 -101
- package/dist/save.d.ts +49 -14
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +352 -98
- package/dist/search.d.ts +11 -43
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +0 -213
- package/dist/shared.d.ts +4 -3
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +67 -34
- package/dist/store.d.ts +92 -96
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +329 -720
- 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 +1 -1
- package/dist/turn.d.ts.map +1 -1
- package/dist/turn.js +31 -20
- 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 +2 -6
- package/dist/windows.d.ts.map +1 -1
- package/dist/windows.js +30 -34
- package/dist/wire.d.ts +17 -1
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +5 -1
- package/dist/words.d.ts +19 -0
- package/dist/words.d.ts.map +1 -0
- package/dist/words.js +150 -0
- package/package.json +18 -19
- package/AGENTS.md +0 -299
- package/dist/chat/acts.d.ts +0 -33
- package/dist/chat/acts.d.ts.map +0 -1
- package/dist/chat/acts.js +0 -36
- package/dist/chat/context.d.ts +0 -3
- package/dist/chat/context.d.ts.map +0 -1
- package/dist/chat/context.js +0 -10
- package/dist/chat/earlier.d.ts +0 -10
- package/dist/chat/earlier.d.ts.map +0 -1
- package/dist/chat/earlier.js +0 -54
- package/dist/chat/input.d.ts +0 -9
- package/dist/chat/input.d.ts.map +0 -1
- package/dist/chat/input.js +0 -99
- package/dist/chat/kit.d.ts +0 -61
- package/dist/chat/kit.d.ts.map +0 -1
- package/dist/chat/kit.js +0 -123
- package/dist/chat/lasting.d.ts +0 -6
- package/dist/chat/lasting.d.ts.map +0 -1
- package/dist/chat/lasting.js +0 -19
- package/dist/chat/list.d.ts +0 -28
- package/dist/chat/list.d.ts.map +0 -1
- package/dist/chat/list.js +0 -99
- package/dist/chat/markdown.d.ts +0 -21
- package/dist/chat/markdown.d.ts.map +0 -1
- package/dist/chat/markdown.js +0 -246
- package/dist/chat/message.d.ts +0 -6
- package/dist/chat/message.d.ts.map +0 -1
- package/dist/chat/message.js +0 -199
- package/dist/chat/messages.d.ts +0 -22
- package/dist/chat/messages.d.ts.map +0 -1
- package/dist/chat/messages.js +0 -175
- package/dist/chat/name.d.ts +0 -6
- package/dist/chat/name.d.ts.map +0 -1
- package/dist/chat/name.js +0 -37
- package/dist/chat/opened.d.ts +0 -11
- package/dist/chat/opened.d.ts.map +0 -1
- package/dist/chat/opened.js +0 -17
- package/dist/chat/overlay.d.ts +0 -32
- package/dist/chat/overlay.d.ts.map +0 -1
- package/dist/chat/overlay.js +0 -107
- package/dist/chat/parts.d.ts +0 -57
- package/dist/chat/parts.d.ts.map +0 -1
- package/dist/chat/parts.js +0 -119
- package/dist/chat/pieces.d.ts +0 -62
- package/dist/chat/pieces.d.ts.map +0 -1
- package/dist/chat/pieces.js +0 -1110
- package/dist/chat/process.d.ts +0 -20
- package/dist/chat/process.d.ts.map +0 -1
- package/dist/chat/process.js +0 -32
- package/dist/chat/provider.d.ts +0 -64
- package/dist/chat/provider.d.ts.map +0 -1
- package/dist/chat/provider.js +0 -637
- package/dist/chat/question.d.ts +0 -9
- package/dist/chat/question.d.ts.map +0 -1
- package/dist/chat/question.js +0 -69
- package/dist/chat/questions.d.ts +0 -31
- package/dist/chat/questions.d.ts.map +0 -1
- package/dist/chat/questions.js +0 -111
- package/dist/chat/read.d.ts +0 -5
- package/dist/chat/read.d.ts.map +0 -1
- package/dist/chat/read.js +0 -13
- package/dist/chat/ready.d.ts +0 -34
- package/dist/chat/ready.d.ts.map +0 -1
- package/dist/chat/ready.js +0 -91
- package/dist/chat/steady.d.ts +0 -3
- package/dist/chat/steady.d.ts.map +0 -1
- package/dist/chat/steady.js +0 -26
- package/dist/chat/style.d.ts +0 -4
- package/dist/chat/style.d.ts.map +0 -1
- package/dist/chat/style.js +0 -302
- package/dist/chat.d.ts +0 -14
- package/dist/chat.d.ts.map +0 -1
- package/dist/chat.js +0 -8
- package/dist/read-side.d.ts +0 -27
- package/dist/read-side.d.ts.map +0 -1
- package/dist/read-side.js +0 -826
package/dist/conversation.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ConversationAction, ConversationAgents, ConversationEvent, ConversationMessage, ConversationStream, ProcessCommand, SessionOption, TurnContext } from './adapter.js';
|
|
2
2
|
import { type ChangeSet } from './change-set.js';
|
|
3
|
-
import { type ChatDraftFile } from './file.js';
|
|
4
3
|
import type { Open } from './open.js';
|
|
5
4
|
import { type CallResult, type Offline } from './outcome.js';
|
|
6
5
|
import type { DocumentResult, PendingResult } from './query.js';
|
|
@@ -17,6 +16,7 @@ export type ConversationEntry = {
|
|
|
17
16
|
created: string;
|
|
18
17
|
finished: string | null;
|
|
19
18
|
outcome: string | null;
|
|
19
|
+
waiting: boolean;
|
|
20
20
|
state: ConversationState;
|
|
21
21
|
started: string | null;
|
|
22
22
|
};
|
|
@@ -32,7 +32,6 @@ export type RunningTurn = {
|
|
|
32
32
|
};
|
|
33
33
|
export type ChatDraft = {
|
|
34
34
|
text: string;
|
|
35
|
-
files: readonly ChatDraftFile[];
|
|
36
35
|
};
|
|
37
36
|
export type ConversationOptions = {
|
|
38
37
|
limit?: number;
|
|
@@ -78,12 +77,13 @@ export type ChatDraftSurface = {
|
|
|
78
77
|
};
|
|
79
78
|
export type ConversationDependencies = {
|
|
80
79
|
agents(): ConversationAgents | undefined;
|
|
81
|
-
documents(agents: ConversationAgents): Promise<DocumentResult | PendingResult>;
|
|
80
|
+
documents(agents: ConversationAgents, after: string | undefined): Promise<DocumentResult | PendingResult>;
|
|
82
81
|
call(name: ConversationAction, input: unknown): Promise<CallResult>;
|
|
83
82
|
durably<T>(work: (local: RuntimeStore) => Promise<T>): Promise<T>;
|
|
84
83
|
stream(): ConversationStream | undefined;
|
|
85
84
|
publish(set: ChangeSet): void;
|
|
86
85
|
online(): boolean;
|
|
86
|
+
full(): boolean;
|
|
87
87
|
closed(): boolean;
|
|
88
88
|
unanswered(): void;
|
|
89
89
|
expired(operation: string): boolean;
|
|
@@ -111,6 +111,7 @@ export type ConversationStore = {
|
|
|
111
111
|
};
|
|
112
112
|
export declare function unheldView(conversation: string): ConversationView;
|
|
113
113
|
export declare const SESSION_STARTED = "Session started";
|
|
114
|
+
export declare const HISTORY_CONVERSATIONS = 64;
|
|
114
115
|
export declare function newChat(agent: string): string;
|
|
115
116
|
export declare function createConversationStore(deps: ConversationDependencies): ConversationStore;
|
|
116
117
|
//# sourceMappingURL=conversation.d.ts.map
|
|
@@ -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,
|
|
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,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,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;AAyCF,wBAAgB,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,gBAAgB,CAcjE;AAED,eAAO,MAAM,eAAe,oBAAoB,CAAC;AAIjD,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7C;AAoQD,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,wBAAwB,GAAG,iBAAiB,CA63BzF"}
|
package/dist/conversation.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { conversationChangeSet } from './change-set.js';
|
|
2
2
|
import { runtimeError } from './failure.js';
|
|
3
|
-
import {
|
|
3
|
+
import { refusedForSpace } from './durability.js';
|
|
4
4
|
import { changeBatchIdentity, chatDraftRevision } from './identity.js';
|
|
5
5
|
import { OFFLINE } from './outcome.js';
|
|
6
6
|
import { capped, cursorOf, decodedCursor, FROM_START, messageOrder, precedes } from './windows.js';
|
|
@@ -40,14 +40,17 @@ export function unheldView(conversation) {
|
|
|
40
40
|
}
|
|
41
41
|
export const SESSION_STARTED = 'Session started';
|
|
42
42
|
const NEW_CHAT = 'new:';
|
|
43
|
+
export const HISTORY_CONVERSATIONS = 64;
|
|
43
44
|
export function newChat(agent) {
|
|
44
45
|
return `${NEW_CHAT}${agent}`;
|
|
45
46
|
}
|
|
46
47
|
function creationOf(input) {
|
|
47
48
|
if (typeof input !== 'object' || input === null)
|
|
48
49
|
return null;
|
|
49
|
-
const { agent_id: agent, operation_id: operation } = input;
|
|
50
|
-
return typeof agent === 'string' && typeof operation === 'string'
|
|
50
|
+
const { agent_id: agent, operation_id: operation, replaces, } = input;
|
|
51
|
+
return typeof agent === 'string' && typeof operation === 'string' && replaces === undefined
|
|
52
|
+
? { agent, operation }
|
|
53
|
+
: null;
|
|
51
54
|
}
|
|
52
55
|
function startedTurn(turn, operation) {
|
|
53
56
|
if (operation.op === 'begin')
|
|
@@ -207,8 +210,14 @@ function askedOf(options) {
|
|
|
207
210
|
return { limit: capped(limit), after, before: beforeOf(after), total: total === true };
|
|
208
211
|
}
|
|
209
212
|
const EXPIRED = { kind: 'rejected', code: 'expired', fields: {}, retryable: false };
|
|
213
|
+
const DURABLE_WRITE = {
|
|
214
|
+
kind: 'rejected',
|
|
215
|
+
code: 'durable-write',
|
|
216
|
+
fields: {},
|
|
217
|
+
retryable: true,
|
|
218
|
+
};
|
|
210
219
|
function unwritten(draft) {
|
|
211
|
-
return draft.text === ''
|
|
220
|
+
return draft.text === '';
|
|
212
221
|
}
|
|
213
222
|
function pending(draft) {
|
|
214
223
|
return {
|
|
@@ -224,10 +233,7 @@ function withSubmitted(draft, submitted) {
|
|
|
224
233
|
return submitted.length === 0 ? unsent : { ...unsent, submitted };
|
|
225
234
|
}
|
|
226
235
|
function prepended(draft, said) {
|
|
227
|
-
return {
|
|
228
|
-
text: [said.text, draft.text].filter((one) => one !== '').join('\n'),
|
|
229
|
-
files: [...said.files, ...draft.files],
|
|
230
|
-
};
|
|
236
|
+
return { text: [said.text, draft.text].filter((one) => one !== '').join('\n') };
|
|
231
237
|
}
|
|
232
238
|
function returned(draft, submission, others) {
|
|
233
239
|
return withSubmitted({
|
|
@@ -283,7 +289,7 @@ export function createConversationStore(deps) {
|
|
|
283
289
|
deliveryUnknown: [...facts.deliveryUnknown],
|
|
284
290
|
chatDraft: draft === undefined || unwritten(draft)
|
|
285
291
|
? null
|
|
286
|
-
: { text: draft.text,
|
|
292
|
+
: { text: draft.text, revision: draft.revision },
|
|
287
293
|
};
|
|
288
294
|
}
|
|
289
295
|
function emit(conversation) {
|
|
@@ -325,9 +331,6 @@ export function createConversationStore(deps) {
|
|
|
325
331
|
}
|
|
326
332
|
}
|
|
327
333
|
}
|
|
328
|
-
function changesOf(conversation, arriving) {
|
|
329
|
-
return arriving.map(({ identity, text }) => ({ conversation, identity, text }));
|
|
330
|
-
}
|
|
331
334
|
function stateOf(conversation) {
|
|
332
335
|
const facts = liveOf(conversation);
|
|
333
336
|
if (facts.questions.length > 0)
|
|
@@ -342,6 +345,7 @@ export function createConversationStore(deps) {
|
|
|
342
345
|
created: entry.created,
|
|
343
346
|
finished: entry.finished,
|
|
344
347
|
outcome: entry.outcome,
|
|
348
|
+
waiting: entry.waiting,
|
|
345
349
|
state: stateOf(entry.conversation),
|
|
346
350
|
started: lives.get(entry.conversation)?.turn?.started ?? null,
|
|
347
351
|
}));
|
|
@@ -384,23 +388,30 @@ export function createConversationStore(deps) {
|
|
|
384
388
|
const declaration = deps.agents();
|
|
385
389
|
if (declaration === undefined)
|
|
386
390
|
return;
|
|
387
|
-
const held = await deps.documents(declaration);
|
|
388
|
-
if ('pending' in held)
|
|
389
|
-
return;
|
|
390
|
-
const { documents } = held;
|
|
391
391
|
const names = new Map();
|
|
392
392
|
const retired = new Set();
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
393
|
+
let covered = null;
|
|
394
|
+
for (let after;;) {
|
|
395
|
+
const read = await deps.documents(declaration, after);
|
|
396
|
+
if ('pending' in read)
|
|
397
|
+
return;
|
|
398
|
+
const coverage = JSON.stringify(read.coverage);
|
|
399
|
+
if (covered !== null && coverage !== covered)
|
|
400
|
+
return readAgents();
|
|
401
|
+
covered = coverage;
|
|
402
|
+
for (const document of read.documents) {
|
|
403
|
+
const identity = document.fields?.[declaration.identity];
|
|
404
|
+
const name = document.fields?.[declaration.name];
|
|
405
|
+
if (typeof identity !== 'string' || typeof name !== 'string')
|
|
406
|
+
continue;
|
|
407
|
+
names.set(identity, name);
|
|
408
|
+
const ended = declaration.retired === undefined ? null : document.fields?.[declaration.retired];
|
|
409
|
+
if (ended !== undefined && ended !== null)
|
|
410
|
+
retired.add(identity);
|
|
411
|
+
}
|
|
412
|
+
if (read.next === undefined)
|
|
413
|
+
break;
|
|
414
|
+
after = read.next;
|
|
404
415
|
}
|
|
405
416
|
const named = JSON.stringify([...names]) !== JSON.stringify([...agentNames]);
|
|
406
417
|
if (!named && JSON.stringify([...retired]) === JSON.stringify([...retiredAgents]))
|
|
@@ -478,12 +489,6 @@ export function createConversationStore(deps) {
|
|
|
478
489
|
}
|
|
479
490
|
async function remove(leaving) {
|
|
480
491
|
await deps.durably(async (local) => {
|
|
481
|
-
const removed = [];
|
|
482
|
-
for (const conversation of leaving) {
|
|
483
|
-
for (const identity of await local.messageIdentities(conversation)) {
|
|
484
|
-
removed.push({ conversation, identity, text: null });
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
492
|
await local.dropConversations(leaving);
|
|
488
493
|
const changed = [];
|
|
489
494
|
for (const conversation of leaving) {
|
|
@@ -500,7 +505,7 @@ export function createConversationStore(deps) {
|
|
|
500
505
|
await slide(local, conversation, null);
|
|
501
506
|
}
|
|
502
507
|
if (changed.length > 0)
|
|
503
|
-
deps.publish(conversationChangeSet(
|
|
508
|
+
deps.publish(conversationChangeSet(changed));
|
|
504
509
|
});
|
|
505
510
|
}
|
|
506
511
|
function gap(conversation) {
|
|
@@ -526,16 +531,17 @@ export function createConversationStore(deps) {
|
|
|
526
531
|
reads.set(conversation, message.position);
|
|
527
532
|
sealTurns(conversation, new Set([message.turn]));
|
|
528
533
|
await slide(local, conversation, [message]);
|
|
529
|
-
deps.publish(conversationChangeSet(
|
|
534
|
+
deps.publish(conversationChangeSet([conversation]));
|
|
530
535
|
});
|
|
531
536
|
}
|
|
532
537
|
async function readHistories(conversations, ended) {
|
|
533
538
|
const generations = new Map(conversations.map((one) => [one, gaps.get(one) ?? 0]));
|
|
534
|
-
let
|
|
539
|
+
let waiting = conversations.map((conversation) => ({
|
|
535
540
|
conversation,
|
|
536
541
|
after: reads.get(conversation) ?? undefined,
|
|
537
542
|
}));
|
|
538
|
-
while (
|
|
543
|
+
while (waiting.length > 0) {
|
|
544
|
+
const asking = waiting.slice(0, HISTORY_CONVERSATIONS);
|
|
539
545
|
const result = await deps.call('conversation.history', {
|
|
540
546
|
conversations: asking.map(({ conversation, after }) => ({
|
|
541
547
|
conversation,
|
|
@@ -559,7 +565,7 @@ export function createConversationStore(deps) {
|
|
|
559
565
|
if (!following.some((next) => next.conversation === conversation))
|
|
560
566
|
ended(conversation);
|
|
561
567
|
}
|
|
562
|
-
|
|
568
|
+
waiting = [...waiting.slice(HISTORY_CONVERSATIONS), ...following];
|
|
563
569
|
}
|
|
564
570
|
return null;
|
|
565
571
|
}
|
|
@@ -602,7 +608,7 @@ export function createConversationStore(deps) {
|
|
|
602
608
|
behind.delete(conversation);
|
|
603
609
|
await slide(local, conversation, arriving);
|
|
604
610
|
if (arriving.length > 0 || sealing || whole) {
|
|
605
|
-
deps.publish(conversationChangeSet(
|
|
611
|
+
deps.publish(conversationChangeSet([conversation]));
|
|
606
612
|
}
|
|
607
613
|
});
|
|
608
614
|
}
|
|
@@ -651,7 +657,14 @@ export function createConversationStore(deps) {
|
|
|
651
657
|
if (arriving === null)
|
|
652
658
|
return;
|
|
653
659
|
if (replicated.has(conversation)) {
|
|
654
|
-
|
|
660
|
+
if (deps.full()) {
|
|
661
|
+
gap(conversation);
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
void keep(conversation, arriving).catch((error) => {
|
|
665
|
+
if (refusedForSpace(error))
|
|
666
|
+
gap(conversation);
|
|
667
|
+
});
|
|
655
668
|
return;
|
|
656
669
|
}
|
|
657
670
|
if (sealTurns(conversation, new Set([arriving.turn])))
|
|
@@ -686,7 +699,6 @@ export function createConversationStore(deps) {
|
|
|
686
699
|
const blank = {
|
|
687
700
|
conversation: from,
|
|
688
701
|
text: '',
|
|
689
|
-
files: [],
|
|
690
702
|
revision: chatDraftRevision(),
|
|
691
703
|
};
|
|
692
704
|
const { moves: _answered, ...unsent } = held ?? blank;
|
|
@@ -696,7 +708,7 @@ export function createConversationStore(deps) {
|
|
|
696
708
|
drafts.set(from, left);
|
|
697
709
|
for (const one of taken)
|
|
698
710
|
drafts.set(to, one);
|
|
699
|
-
deps.publish(conversationChangeSet([
|
|
711
|
+
deps.publish(conversationChangeSet([from, to]));
|
|
700
712
|
});
|
|
701
713
|
}
|
|
702
714
|
function withDraft(conversation, next) {
|
|
@@ -705,7 +717,7 @@ export function createConversationStore(deps) {
|
|
|
705
717
|
if (following === undefined)
|
|
706
718
|
return;
|
|
707
719
|
await kept(local, conversation, following);
|
|
708
|
-
deps.publish(conversationChangeSet([
|
|
720
|
+
deps.publish(conversationChangeSet([conversation]));
|
|
709
721
|
});
|
|
710
722
|
}
|
|
711
723
|
async function submitted(conversation, operation, draft) {
|
|
@@ -717,17 +729,12 @@ export function createConversationStore(deps) {
|
|
|
717
729
|
if (submission !== undefined)
|
|
718
730
|
return undefined;
|
|
719
731
|
const said = draft ?? current;
|
|
720
|
-
submission = {
|
|
721
|
-
operation,
|
|
722
|
-
text: said?.text ?? '',
|
|
723
|
-
files: [...(said?.files ?? [])],
|
|
724
|
-
turn: null,
|
|
725
|
-
};
|
|
732
|
+
submission = { operation, text: said?.text ?? '', turn: null };
|
|
726
733
|
return {
|
|
727
734
|
conversation,
|
|
728
735
|
...(draft === undefined || current === undefined
|
|
729
|
-
? { text: '',
|
|
730
|
-
: { text: current.text,
|
|
736
|
+
? { text: '', revision: chatDraftRevision() }
|
|
737
|
+
: { text: current.text, revision: current.revision }),
|
|
731
738
|
submitted: [...(current?.submitted ?? []), submission],
|
|
732
739
|
};
|
|
733
740
|
});
|
|
@@ -742,15 +749,14 @@ export function createConversationStore(deps) {
|
|
|
742
749
|
});
|
|
743
750
|
}
|
|
744
751
|
async function dispatched(conversation, submission) {
|
|
745
|
-
const dispatch = {};
|
|
752
|
+
const dispatch = { answered: false };
|
|
746
753
|
sending.set(submission.operation, dispatch);
|
|
747
754
|
try {
|
|
748
|
-
const files = await Promise.all(submission.files.map(async (file) => ({ ...(await declaredFile(file)), blob: file.blob })));
|
|
749
755
|
const result = await invoke('conversation.send', conversation, {
|
|
750
756
|
text: submission.text,
|
|
751
|
-
files,
|
|
752
757
|
operation_id: submission.operation,
|
|
753
758
|
});
|
|
759
|
+
dispatch.answered = result.kind !== 'transport-uncertainty';
|
|
754
760
|
if (result.kind === 'revoked-authorization')
|
|
755
761
|
return result;
|
|
756
762
|
if (result.kind !== 'action' && result.retryable) {
|
|
@@ -806,8 +812,17 @@ export function createConversationStore(deps) {
|
|
|
806
812
|
return result;
|
|
807
813
|
},
|
|
808
814
|
async send(conversation, operation = changeBatchIdentity(), draft) {
|
|
815
|
+
if (deps.full())
|
|
816
|
+
return DURABLE_WRITE;
|
|
809
817
|
if (deps.online()) {
|
|
810
|
-
const
|
|
818
|
+
const held = await submitted(conversation, operation, draft).catch((error) => {
|
|
819
|
+
if (refusedForSpace(error))
|
|
820
|
+
return null;
|
|
821
|
+
throw error;
|
|
822
|
+
});
|
|
823
|
+
if (held === null)
|
|
824
|
+
return DURABLE_WRITE;
|
|
825
|
+
const { submission, earlier } = held;
|
|
811
826
|
if (!earlier || !deps.expired(operation))
|
|
812
827
|
return dispatched(conversation, submission);
|
|
813
828
|
await forgotten(conversation, submission);
|
|
@@ -816,7 +831,7 @@ export function createConversationStore(deps) {
|
|
|
816
831
|
if (draft !== undefined) {
|
|
817
832
|
await withDraft(conversation, (current) => current?.submitted?.some((one) => one.operation === operation) === true
|
|
818
833
|
? undefined
|
|
819
|
-
: returned(current ?? { conversation, text: '',
|
|
834
|
+
: returned(current ?? { conversation, text: '', revision: '' }, { operation, ...draft, turn: null }, current?.submitted ?? []));
|
|
820
835
|
}
|
|
821
836
|
return OFFLINE;
|
|
822
837
|
},
|
|
@@ -850,7 +865,6 @@ export function createConversationStore(deps) {
|
|
|
850
865
|
return withDraft(conversation, (current) => ({
|
|
851
866
|
conversation,
|
|
852
867
|
text: draft.text,
|
|
853
|
-
files: [...draft.files],
|
|
854
868
|
revision,
|
|
855
869
|
...(current === undefined ? {} : pending(current)),
|
|
856
870
|
}));
|
|
@@ -858,9 +872,7 @@ export function createConversationStore(deps) {
|
|
|
858
872
|
prepend(conversation, draft) {
|
|
859
873
|
return withDraft(conversation, (current) => ({
|
|
860
874
|
conversation,
|
|
861
|
-
...(current === undefined
|
|
862
|
-
? { text: draft.text, files: [...draft.files] }
|
|
863
|
-
: prepended(current, draft)),
|
|
875
|
+
...(current === undefined ? { text: draft.text } : prepended(current, draft)),
|
|
864
876
|
revision: chatDraftRevision(),
|
|
865
877
|
...(current === undefined ? {} : pending(current)),
|
|
866
878
|
}));
|
|
@@ -868,13 +880,7 @@ export function createConversationStore(deps) {
|
|
|
868
880
|
discard(conversation) {
|
|
869
881
|
return withDraft(conversation, (current) => current === undefined
|
|
870
882
|
? undefined
|
|
871
|
-
: {
|
|
872
|
-
conversation,
|
|
873
|
-
text: '',
|
|
874
|
-
files: [],
|
|
875
|
-
revision: chatDraftRevision(),
|
|
876
|
-
...pending(current),
|
|
877
|
-
});
|
|
883
|
+
: { conversation, text: '', revision: chatDraftRevision(), ...pending(current) });
|
|
878
884
|
},
|
|
879
885
|
};
|
|
880
886
|
return {
|
|
@@ -914,6 +920,11 @@ export function createConversationStore(deps) {
|
|
|
914
920
|
await remove(leaving);
|
|
915
921
|
},
|
|
916
922
|
async catchUp(progress) {
|
|
923
|
+
if (deps.full()) {
|
|
924
|
+
if (behind.size > 0)
|
|
925
|
+
progress.complete = false;
|
|
926
|
+
return;
|
|
927
|
+
}
|
|
917
928
|
const owed = (conversation) => behind.has(conversation) && replicated.has(conversation);
|
|
918
929
|
const read = async (conversations) => {
|
|
919
930
|
if (conversations.length === 0 || deps.closed())
|
|
@@ -967,7 +978,9 @@ export function createConversationStore(deps) {
|
|
|
967
978
|
gap(conversation);
|
|
968
979
|
},
|
|
969
980
|
reopened() {
|
|
970
|
-
sending
|
|
981
|
+
for (const [operation, dispatch] of sending)
|
|
982
|
+
if (!dispatch.answered)
|
|
983
|
+
sending.delete(operation);
|
|
971
984
|
},
|
|
972
985
|
lost() {
|
|
973
986
|
catching.clear();
|
package/dist/digest.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"digest.d.ts","sourceRoot":"","sources":["../src/digest.ts"],"names":[],"mappings":"AA0EA,MAAM,MAAM,MAAM,GAAG;IACnB,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;IAChC,GAAG,IAAI,MAAM,CAAC;CACf,CAAC;AAEF,wBAAgB,MAAM,IAAI,MAAM,CAoC/B;AAED,wBAAsB,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAMxD"}
|
package/dist/digest.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { FILE_PART_BYTES } from './tables.js';
|
|
2
|
+
const ROUNDS = new Uint32Array([
|
|
3
|
+
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
4
|
+
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
5
|
+
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
6
|
+
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
|
7
|
+
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
|
8
|
+
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
9
|
+
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
|
10
|
+
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
|
|
11
|
+
]);
|
|
12
|
+
const INITIAL = [
|
|
13
|
+
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,
|
|
14
|
+
];
|
|
15
|
+
const BLOCK = 64;
|
|
16
|
+
function rotated(value, by) {
|
|
17
|
+
return (value >>> by) | (value << (32 - by));
|
|
18
|
+
}
|
|
19
|
+
function compressed(state, words, bytes, at) {
|
|
20
|
+
for (let index = 0; index < 16; index += 1) {
|
|
21
|
+
const from = at + index * 4;
|
|
22
|
+
words[index] =
|
|
23
|
+
(bytes[from] << 24) | (bytes[from + 1] << 16) | (bytes[from + 2] << 8) | bytes[from + 3];
|
|
24
|
+
}
|
|
25
|
+
for (let index = 16; index < 64; index += 1) {
|
|
26
|
+
const early = words[index - 15];
|
|
27
|
+
const late = words[index - 2];
|
|
28
|
+
const lower = rotated(early, 7) ^ rotated(early, 18) ^ (early >>> 3);
|
|
29
|
+
const upper = rotated(late, 17) ^ rotated(late, 19) ^ (late >>> 10);
|
|
30
|
+
words[index] = (words[index - 16] + lower + words[index - 7] + upper) | 0;
|
|
31
|
+
}
|
|
32
|
+
let a = state[0];
|
|
33
|
+
let b = state[1];
|
|
34
|
+
let c = state[2];
|
|
35
|
+
let d = state[3];
|
|
36
|
+
let e = state[4];
|
|
37
|
+
let f = state[5];
|
|
38
|
+
let g = state[6];
|
|
39
|
+
let h = state[7];
|
|
40
|
+
for (let index = 0; index < 64; index += 1) {
|
|
41
|
+
const chosen = (e & f) ^ (~e & g);
|
|
42
|
+
const first = (h +
|
|
43
|
+
(rotated(e, 6) ^ rotated(e, 11) ^ rotated(e, 25)) +
|
|
44
|
+
chosen +
|
|
45
|
+
ROUNDS[index] +
|
|
46
|
+
words[index]) |
|
|
47
|
+
0;
|
|
48
|
+
const second = ((rotated(a, 2) ^ rotated(a, 13) ^ rotated(a, 22)) + ((a & b) ^ (a & c) ^ (b & c))) | 0;
|
|
49
|
+
h = g;
|
|
50
|
+
g = f;
|
|
51
|
+
f = e;
|
|
52
|
+
e = (d + first) | 0;
|
|
53
|
+
d = c;
|
|
54
|
+
c = b;
|
|
55
|
+
b = a;
|
|
56
|
+
a = (first + second) | 0;
|
|
57
|
+
}
|
|
58
|
+
state[0] += a;
|
|
59
|
+
state[1] += b;
|
|
60
|
+
state[2] += c;
|
|
61
|
+
state[3] += d;
|
|
62
|
+
state[4] += e;
|
|
63
|
+
state[5] += f;
|
|
64
|
+
state[6] += g;
|
|
65
|
+
state[7] += h;
|
|
66
|
+
}
|
|
67
|
+
export function digest() {
|
|
68
|
+
const state = new Uint32Array(INITIAL);
|
|
69
|
+
const words = new Uint32Array(64);
|
|
70
|
+
const pending = new Uint8Array(BLOCK);
|
|
71
|
+
let held = 0;
|
|
72
|
+
let size = 0;
|
|
73
|
+
return {
|
|
74
|
+
update(bytes) {
|
|
75
|
+
size += bytes.length;
|
|
76
|
+
let from = 0;
|
|
77
|
+
if (held > 0) {
|
|
78
|
+
const taken = Math.min(BLOCK - held, bytes.length);
|
|
79
|
+
pending.set(bytes.subarray(0, taken), held);
|
|
80
|
+
held += taken;
|
|
81
|
+
from = taken;
|
|
82
|
+
if (held < BLOCK)
|
|
83
|
+
return;
|
|
84
|
+
compressed(state, words, pending, 0);
|
|
85
|
+
held = 0;
|
|
86
|
+
}
|
|
87
|
+
for (; from + BLOCK <= bytes.length; from += BLOCK)
|
|
88
|
+
compressed(state, words, bytes, from);
|
|
89
|
+
pending.set(bytes.subarray(from), 0);
|
|
90
|
+
held = bytes.length - from;
|
|
91
|
+
},
|
|
92
|
+
hex() {
|
|
93
|
+
const bits = size * 8;
|
|
94
|
+
const tail = new Uint8Array(held < 56 ? BLOCK : BLOCK * 2);
|
|
95
|
+
tail.set(pending.subarray(0, held));
|
|
96
|
+
tail[held] = 0x80;
|
|
97
|
+
const length = new DataView(tail.buffer, tail.length - 8);
|
|
98
|
+
length.setUint32(0, Math.floor(bits / 0x1_0000_0000));
|
|
99
|
+
length.setUint32(4, bits >>> 0);
|
|
100
|
+
const final = new Uint32Array(state);
|
|
101
|
+
for (let from = 0; from < tail.length; from += BLOCK)
|
|
102
|
+
compressed(final, words, tail, from);
|
|
103
|
+
return [...final].map((word) => word.toString(16).padStart(8, '0')).join('');
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
export async function sha256(blob) {
|
|
108
|
+
const hashed = digest();
|
|
109
|
+
for (let at = 0; at < blob.size; at += FILE_PART_BYTES) {
|
|
110
|
+
hashed.update(new Uint8Array(await blob.slice(at, at + FILE_PART_BYTES).arrayBuffer()));
|
|
111
|
+
}
|
|
112
|
+
return hashed.hex();
|
|
113
|
+
}
|
package/dist/durability.d.ts
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import type { Persistence } from './readiness.js';
|
|
2
|
-
export type StorageEstimate = {
|
|
3
|
-
readonly usage: number;
|
|
4
|
-
readonly quota: number;
|
|
5
|
-
};
|
|
6
2
|
export type RuntimeShell = {
|
|
7
3
|
persistence: Persistence;
|
|
8
4
|
generation: string | null;
|
|
5
|
+
onScreen: boolean;
|
|
9
6
|
keepGeneration(value: string): void | Promise<void>;
|
|
10
7
|
dropGeneration(): void | Promise<void>;
|
|
11
|
-
|
|
8
|
+
cleanUp?(): Promise<number>;
|
|
12
9
|
};
|
|
10
|
+
export declare function refusedForSpace(error: unknown): boolean;
|
|
13
11
|
export declare function detectStorageLoss(stored: string | null, reported: string | null): string | null;
|
|
14
12
|
export declare function nextGeneration(stored: string | null, reported: string | null): string;
|
|
15
13
|
//# sourceMappingURL=durability.d.ts.map
|
package/dist/durability.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"durability.d.ts","sourceRoot":"","sources":["../src/durability.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAIlD,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"durability.d.ts","sourceRoot":"","sources":["../src/durability.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAIlD,MAAM,MAAM,YAAY,GAAG;IACzB,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,cAAc,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CAC7B,CAAC;AAEF,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAMvD;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAG/F;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAGrF"}
|
package/dist/durability.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
const STORAGE_LOSS_CODE = 'storage-loss';
|
|
2
|
+
export function refusedForSpace(error) {
|
|
3
|
+
return (typeof error === 'object' &&
|
|
4
|
+
error !== null &&
|
|
5
|
+
error.name === 'QuotaExceededError');
|
|
6
|
+
}
|
|
2
7
|
export function detectStorageLoss(stored, reported) {
|
|
3
8
|
if (reported === null || reported === stored)
|
|
4
9
|
return null;
|
package/dist/entry.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { VerifiedModel } from '@agentshouse/mdmodel';
|
|
1
2
|
import { type QueryRows } from './query.js';
|
|
3
|
+
import type { Connection } from './tables.js';
|
|
2
4
|
export { QueryError } from './query.js';
|
|
3
5
|
export type EntryRoom = {
|
|
4
6
|
locator: string;
|
|
@@ -13,5 +15,5 @@ export declare function entryRefusal(template: unknown): string | null;
|
|
|
13
15
|
export type EntryScope = {
|
|
14
16
|
results(queries: Readonly<Record<string, unknown>>): Promise<Record<string, QueryRows>>;
|
|
15
17
|
};
|
|
16
|
-
export declare function entryScope(rooms: readonly EntryRoom[]): EntryScope;
|
|
18
|
+
export declare function entryScope(rooms: readonly EntryRoom[], roomTypes: VerifiedModel, connection: Connection): EntryScope;
|
|
17
19
|
//# sourceMappingURL=entry.d.ts.map
|
package/dist/entry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAK1D,OAAO,EAML,KAAK,SAAS,EAEf,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,GAAG,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