@agentshouse/mdruntime 0.1.0-cc5745cd9af96 → 0.1.0-ccbb89b0ca151
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 +56 -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 +186 -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 +6 -20
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +31 -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 +16 -9
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +2399 -952
- package/dist/conversation.d.ts +3 -3
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +80 -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 +195 -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.map +1 -1
- package/dist/model.js +1 -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 +12 -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 +36 -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 +277 -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 +83 -95
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +317 -720
- package/dist/stored.d.ts +152 -0
- package/dist/stored.d.ts.map +1 -0
- package/dist/stored.js +607 -0
- package/dist/tables.d.ts +352 -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 -103
- 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 -7
- package/dist/chat/message.d.ts.map +0 -1
- package/dist/chat/message.js +0 -202
- package/dist/chat/messages.d.ts +0 -24
- package/dist/chat/messages.d.ts.map +0 -1
- package/dist/chat/messages.js +0 -187
- 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 -638
- 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';
|
|
@@ -33,7 +32,6 @@ export type RunningTurn = {
|
|
|
33
32
|
};
|
|
34
33
|
export type ChatDraft = {
|
|
35
34
|
text: string;
|
|
36
|
-
files: readonly ChatDraftFile[];
|
|
37
35
|
};
|
|
38
36
|
export type ConversationOptions = {
|
|
39
37
|
limit?: number;
|
|
@@ -79,12 +77,13 @@ export type ChatDraftSurface = {
|
|
|
79
77
|
};
|
|
80
78
|
export type ConversationDependencies = {
|
|
81
79
|
agents(): ConversationAgents | undefined;
|
|
82
|
-
documents(agents: ConversationAgents): Promise<DocumentResult | PendingResult>;
|
|
80
|
+
documents(agents: ConversationAgents, after: string | undefined): Promise<DocumentResult | PendingResult>;
|
|
83
81
|
call(name: ConversationAction, input: unknown): Promise<CallResult>;
|
|
84
82
|
durably<T>(work: (local: RuntimeStore) => Promise<T>): Promise<T>;
|
|
85
83
|
stream(): ConversationStream | undefined;
|
|
86
84
|
publish(set: ChangeSet): void;
|
|
87
85
|
online(): boolean;
|
|
86
|
+
full(): boolean;
|
|
88
87
|
closed(): boolean;
|
|
89
88
|
unanswered(): void;
|
|
90
89
|
expired(operation: string): boolean;
|
|
@@ -112,6 +111,7 @@ export type ConversationStore = {
|
|
|
112
111
|
};
|
|
113
112
|
export declare function unheldView(conversation: string): ConversationView;
|
|
114
113
|
export declare const SESSION_STARTED = "Session started";
|
|
114
|
+
export declare const HISTORY_CONVERSATIONS = 64;
|
|
115
115
|
export declare function newChat(agent: string): string;
|
|
116
116
|
export declare function createConversationStore(deps: ConversationDependencies): ConversationStore;
|
|
117
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,EAElB,cAAc,EACd,aAAa,EACb,WAAW,EAEZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAyB,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAIxE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAW,KAAK,UAAU,EAA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,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)
|
|
@@ -385,23 +388,30 @@ export function createConversationStore(deps) {
|
|
|
385
388
|
const declaration = deps.agents();
|
|
386
389
|
if (declaration === undefined)
|
|
387
390
|
return;
|
|
388
|
-
const held = await deps.documents(declaration);
|
|
389
|
-
if ('pending' in held)
|
|
390
|
-
return;
|
|
391
|
-
const { documents } = held;
|
|
392
391
|
const names = new Map();
|
|
393
392
|
const retired = new Set();
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
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;
|
|
405
415
|
}
|
|
406
416
|
const named = JSON.stringify([...names]) !== JSON.stringify([...agentNames]);
|
|
407
417
|
if (!named && JSON.stringify([...retired]) === JSON.stringify([...retiredAgents]))
|
|
@@ -479,12 +489,6 @@ export function createConversationStore(deps) {
|
|
|
479
489
|
}
|
|
480
490
|
async function remove(leaving) {
|
|
481
491
|
await deps.durably(async (local) => {
|
|
482
|
-
const removed = [];
|
|
483
|
-
for (const conversation of leaving) {
|
|
484
|
-
for (const identity of await local.messageIdentities(conversation)) {
|
|
485
|
-
removed.push({ conversation, identity, text: null });
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
492
|
await local.dropConversations(leaving);
|
|
489
493
|
const changed = [];
|
|
490
494
|
for (const conversation of leaving) {
|
|
@@ -501,7 +505,7 @@ export function createConversationStore(deps) {
|
|
|
501
505
|
await slide(local, conversation, null);
|
|
502
506
|
}
|
|
503
507
|
if (changed.length > 0)
|
|
504
|
-
deps.publish(conversationChangeSet(
|
|
508
|
+
deps.publish(conversationChangeSet(changed));
|
|
505
509
|
});
|
|
506
510
|
}
|
|
507
511
|
function gap(conversation) {
|
|
@@ -527,16 +531,17 @@ export function createConversationStore(deps) {
|
|
|
527
531
|
reads.set(conversation, message.position);
|
|
528
532
|
sealTurns(conversation, new Set([message.turn]));
|
|
529
533
|
await slide(local, conversation, [message]);
|
|
530
|
-
deps.publish(conversationChangeSet(
|
|
534
|
+
deps.publish(conversationChangeSet([conversation]));
|
|
531
535
|
});
|
|
532
536
|
}
|
|
533
537
|
async function readHistories(conversations, ended) {
|
|
534
538
|
const generations = new Map(conversations.map((one) => [one, gaps.get(one) ?? 0]));
|
|
535
|
-
let
|
|
539
|
+
let waiting = conversations.map((conversation) => ({
|
|
536
540
|
conversation,
|
|
537
541
|
after: reads.get(conversation) ?? undefined,
|
|
538
542
|
}));
|
|
539
|
-
while (
|
|
543
|
+
while (waiting.length > 0) {
|
|
544
|
+
const asking = waiting.slice(0, HISTORY_CONVERSATIONS);
|
|
540
545
|
const result = await deps.call('conversation.history', {
|
|
541
546
|
conversations: asking.map(({ conversation, after }) => ({
|
|
542
547
|
conversation,
|
|
@@ -560,7 +565,7 @@ export function createConversationStore(deps) {
|
|
|
560
565
|
if (!following.some((next) => next.conversation === conversation))
|
|
561
566
|
ended(conversation);
|
|
562
567
|
}
|
|
563
|
-
|
|
568
|
+
waiting = [...waiting.slice(HISTORY_CONVERSATIONS), ...following];
|
|
564
569
|
}
|
|
565
570
|
return null;
|
|
566
571
|
}
|
|
@@ -603,7 +608,7 @@ export function createConversationStore(deps) {
|
|
|
603
608
|
behind.delete(conversation);
|
|
604
609
|
await slide(local, conversation, arriving);
|
|
605
610
|
if (arriving.length > 0 || sealing || whole) {
|
|
606
|
-
deps.publish(conversationChangeSet(
|
|
611
|
+
deps.publish(conversationChangeSet([conversation]));
|
|
607
612
|
}
|
|
608
613
|
});
|
|
609
614
|
}
|
|
@@ -652,7 +657,14 @@ export function createConversationStore(deps) {
|
|
|
652
657
|
if (arriving === null)
|
|
653
658
|
return;
|
|
654
659
|
if (replicated.has(conversation)) {
|
|
655
|
-
|
|
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
|
+
});
|
|
656
668
|
return;
|
|
657
669
|
}
|
|
658
670
|
if (sealTurns(conversation, new Set([arriving.turn])))
|
|
@@ -687,7 +699,6 @@ export function createConversationStore(deps) {
|
|
|
687
699
|
const blank = {
|
|
688
700
|
conversation: from,
|
|
689
701
|
text: '',
|
|
690
|
-
files: [],
|
|
691
702
|
revision: chatDraftRevision(),
|
|
692
703
|
};
|
|
693
704
|
const { moves: _answered, ...unsent } = held ?? blank;
|
|
@@ -697,7 +708,7 @@ export function createConversationStore(deps) {
|
|
|
697
708
|
drafts.set(from, left);
|
|
698
709
|
for (const one of taken)
|
|
699
710
|
drafts.set(to, one);
|
|
700
|
-
deps.publish(conversationChangeSet([
|
|
711
|
+
deps.publish(conversationChangeSet([from, to]));
|
|
701
712
|
});
|
|
702
713
|
}
|
|
703
714
|
function withDraft(conversation, next) {
|
|
@@ -706,7 +717,7 @@ export function createConversationStore(deps) {
|
|
|
706
717
|
if (following === undefined)
|
|
707
718
|
return;
|
|
708
719
|
await kept(local, conversation, following);
|
|
709
|
-
deps.publish(conversationChangeSet([
|
|
720
|
+
deps.publish(conversationChangeSet([conversation]));
|
|
710
721
|
});
|
|
711
722
|
}
|
|
712
723
|
async function submitted(conversation, operation, draft) {
|
|
@@ -718,17 +729,12 @@ export function createConversationStore(deps) {
|
|
|
718
729
|
if (submission !== undefined)
|
|
719
730
|
return undefined;
|
|
720
731
|
const said = draft ?? current;
|
|
721
|
-
submission = {
|
|
722
|
-
operation,
|
|
723
|
-
text: said?.text ?? '',
|
|
724
|
-
files: [...(said?.files ?? [])],
|
|
725
|
-
turn: null,
|
|
726
|
-
};
|
|
732
|
+
submission = { operation, text: said?.text ?? '', turn: null };
|
|
727
733
|
return {
|
|
728
734
|
conversation,
|
|
729
735
|
...(draft === undefined || current === undefined
|
|
730
|
-
? { text: '',
|
|
731
|
-
: { text: current.text,
|
|
736
|
+
? { text: '', revision: chatDraftRevision() }
|
|
737
|
+
: { text: current.text, revision: current.revision }),
|
|
732
738
|
submitted: [...(current?.submitted ?? []), submission],
|
|
733
739
|
};
|
|
734
740
|
});
|
|
@@ -743,15 +749,14 @@ export function createConversationStore(deps) {
|
|
|
743
749
|
});
|
|
744
750
|
}
|
|
745
751
|
async function dispatched(conversation, submission) {
|
|
746
|
-
const dispatch = {};
|
|
752
|
+
const dispatch = { answered: false };
|
|
747
753
|
sending.set(submission.operation, dispatch);
|
|
748
754
|
try {
|
|
749
|
-
const files = await Promise.all(submission.files.map(async (file) => ({ ...(await declaredFile(file)), blob: file.blob })));
|
|
750
755
|
const result = await invoke('conversation.send', conversation, {
|
|
751
756
|
text: submission.text,
|
|
752
|
-
files,
|
|
753
757
|
operation_id: submission.operation,
|
|
754
758
|
});
|
|
759
|
+
dispatch.answered = result.kind !== 'transport-uncertainty';
|
|
755
760
|
if (result.kind === 'revoked-authorization')
|
|
756
761
|
return result;
|
|
757
762
|
if (result.kind !== 'action' && result.retryable) {
|
|
@@ -807,8 +812,17 @@ export function createConversationStore(deps) {
|
|
|
807
812
|
return result;
|
|
808
813
|
},
|
|
809
814
|
async send(conversation, operation = changeBatchIdentity(), draft) {
|
|
815
|
+
if (deps.full())
|
|
816
|
+
return DURABLE_WRITE;
|
|
810
817
|
if (deps.online()) {
|
|
811
|
-
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;
|
|
812
826
|
if (!earlier || !deps.expired(operation))
|
|
813
827
|
return dispatched(conversation, submission);
|
|
814
828
|
await forgotten(conversation, submission);
|
|
@@ -817,7 +831,7 @@ export function createConversationStore(deps) {
|
|
|
817
831
|
if (draft !== undefined) {
|
|
818
832
|
await withDraft(conversation, (current) => current?.submitted?.some((one) => one.operation === operation) === true
|
|
819
833
|
? undefined
|
|
820
|
-
: returned(current ?? { conversation, text: '',
|
|
834
|
+
: returned(current ?? { conversation, text: '', revision: '' }, { operation, ...draft, turn: null }, current?.submitted ?? []));
|
|
821
835
|
}
|
|
822
836
|
return OFFLINE;
|
|
823
837
|
},
|
|
@@ -851,7 +865,6 @@ export function createConversationStore(deps) {
|
|
|
851
865
|
return withDraft(conversation, (current) => ({
|
|
852
866
|
conversation,
|
|
853
867
|
text: draft.text,
|
|
854
|
-
files: [...draft.files],
|
|
855
868
|
revision,
|
|
856
869
|
...(current === undefined ? {} : pending(current)),
|
|
857
870
|
}));
|
|
@@ -859,9 +872,7 @@ export function createConversationStore(deps) {
|
|
|
859
872
|
prepend(conversation, draft) {
|
|
860
873
|
return withDraft(conversation, (current) => ({
|
|
861
874
|
conversation,
|
|
862
|
-
...(current === undefined
|
|
863
|
-
? { text: draft.text, files: [...draft.files] }
|
|
864
|
-
: prepended(current, draft)),
|
|
875
|
+
...(current === undefined ? { text: draft.text } : prepended(current, draft)),
|
|
865
876
|
revision: chatDraftRevision(),
|
|
866
877
|
...(current === undefined ? {} : pending(current)),
|
|
867
878
|
}));
|
|
@@ -869,13 +880,7 @@ export function createConversationStore(deps) {
|
|
|
869
880
|
discard(conversation) {
|
|
870
881
|
return withDraft(conversation, (current) => current === undefined
|
|
871
882
|
? undefined
|
|
872
|
-
: {
|
|
873
|
-
conversation,
|
|
874
|
-
text: '',
|
|
875
|
-
files: [],
|
|
876
|
-
revision: chatDraftRevision(),
|
|
877
|
-
...pending(current),
|
|
878
|
-
});
|
|
883
|
+
: { conversation, text: '', revision: chatDraftRevision(), ...pending(current) });
|
|
879
884
|
},
|
|
880
885
|
};
|
|
881
886
|
return {
|
|
@@ -915,6 +920,11 @@ export function createConversationStore(deps) {
|
|
|
915
920
|
await remove(leaving);
|
|
916
921
|
},
|
|
917
922
|
async catchUp(progress) {
|
|
923
|
+
if (deps.full()) {
|
|
924
|
+
if (behind.size > 0)
|
|
925
|
+
progress.complete = false;
|
|
926
|
+
return;
|
|
927
|
+
}
|
|
918
928
|
const owed = (conversation) => behind.has(conversation) && replicated.has(conversation);
|
|
919
929
|
const read = async (conversations) => {
|
|
920
930
|
if (conversations.length === 0 || deps.closed())
|
|
@@ -968,7 +978,9 @@ export function createConversationStore(deps) {
|
|
|
968
978
|
gap(conversation);
|
|
969
979
|
},
|
|
970
980
|
reopened() {
|
|
971
|
-
sending
|
|
981
|
+
for (const [operation, dispatch] of sending)
|
|
982
|
+
if (!dispatch.answered)
|
|
983
|
+
sending.delete(operation);
|
|
972
984
|
},
|
|
973
985
|
lost() {
|
|
974
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,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,EAA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