@agentshouse/mdruntime 0.1.0-cf96c797c5fa8 → 0.1.0-cfb2ae0107054
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 +100 -119
- package/dist/adapter.d.ts +24 -2
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attempt.d.ts.map +1 -1
- package/dist/attempt.js +14 -1
- package/dist/bootstrap.d.ts +2 -2
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +28 -6
- package/dist/chat/acts.d.ts +3 -4
- package/dist/chat/acts.d.ts.map +1 -1
- package/dist/chat/acts.js +10 -10
- package/dist/chat/list.d.ts +6 -0
- package/dist/chat/list.d.ts.map +1 -1
- package/dist/chat/list.js +6 -3
- package/dist/chat/markdown.d.ts +2 -1
- package/dist/chat/markdown.d.ts.map +1 -1
- package/dist/chat/markdown.js +7 -6
- package/dist/chat/provider.d.ts.map +1 -1
- package/dist/chat/provider.js +25 -50
- package/dist/chat/ready.d.ts.map +1 -1
- package/dist/chat/ready.js +2 -2
- package/dist/chat/style.js +3 -3
- package/dist/client.d.ts +2 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1 -1
- package/dist/connection.d.ts +1 -0
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +337 -150
- package/dist/conversation.d.ts +4 -2
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +143 -58
- package/dist/entry.d.ts +17 -0
- package/dist/entry.d.ts.map +1 -0
- package/dist/entry.js +156 -0
- package/dist/fence.d.ts +6 -0
- package/dist/fence.d.ts.map +1 -0
- package/dist/fence.js +10 -0
- package/dist/host.d.ts +3 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +8 -5
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/memory.d.ts +1 -0
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +9 -0
- package/dist/outcome.d.ts +4 -0
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +1 -0
- package/dist/reach.js +1 -1
- package/dist/save.d.ts +1 -2
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +6 -5
- package/dist/store.d.ts +25 -8
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +164 -38
- package/package.json +12 -8
package/dist/conversation.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { ConversationAction, ConversationAgents, ConversationEvent, Convers
|
|
|
2
2
|
import { type ChangeSet } from './change-set.js';
|
|
3
3
|
import { type ChatDraftFile } from './file.js';
|
|
4
4
|
import type { Open } from './open.js';
|
|
5
|
-
import type
|
|
5
|
+
import { type CallResult, type Offline } from './outcome.js';
|
|
6
6
|
import type { DocumentResult } from './query.js';
|
|
7
7
|
import type { SearchedMessage } from './search.js';
|
|
8
8
|
import type { CycleProgress } from './status.js';
|
|
@@ -56,7 +56,7 @@ export type ConversationSurface = {
|
|
|
56
56
|
list(): Promise<readonly ConversationEntry[]>;
|
|
57
57
|
read(conversation: string, options?: ConversationOptions): Promise<ConversationView>;
|
|
58
58
|
create(input: unknown): Promise<CallResult>;
|
|
59
|
-
send(conversation: string): Promise<CallResult>;
|
|
59
|
+
send(conversation: string, operation?: string, draft?: ChatDraft): Promise<CallResult | Offline>;
|
|
60
60
|
answer(conversation: string, answer: unknown): Promise<CallResult>;
|
|
61
61
|
interrupt(conversation: string): Promise<CallResult>;
|
|
62
62
|
kill(conversation: string): Promise<CallResult>;
|
|
@@ -74,6 +74,7 @@ export type ConversationDependencies = {
|
|
|
74
74
|
durably<T>(work: (local: RuntimeStore) => Promise<T>): Promise<T>;
|
|
75
75
|
stream(): ConversationStream | undefined;
|
|
76
76
|
publish(set: ChangeSet): void;
|
|
77
|
+
online(): boolean;
|
|
77
78
|
closed(): boolean;
|
|
78
79
|
};
|
|
79
80
|
export type ConversationStore = {
|
|
@@ -82,6 +83,7 @@ export type ConversationStore = {
|
|
|
82
83
|
hydrate(held: readonly HeldConversation[], drafts: readonly ChatDraftRecord[]): void;
|
|
83
84
|
reconcile(): Promise<void>;
|
|
84
85
|
catchUp(progress: CycleProgress): Promise<void>;
|
|
86
|
+
resend(progress: CycleProgress): Promise<void>;
|
|
85
87
|
current(): boolean;
|
|
86
88
|
reconnected(): void;
|
|
87
89
|
watch(conversation: string, options: ConversationOptions, deliver: (view: ConversationView) => 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,KAAK,EAAE,
|
|
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,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EA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OAAO,CAAC;IACnB,WAAW,IAAI,IAAI,CAAC;IACpB,KAAK,CACH,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,GACxC,MAAM,IAAI,CAAC;IACd,SAAS,CAAC,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,QAAQ,IAAI,SAAS,eAAe,EAAE,CAAC;IACvC,OAAO,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAAC;IACxE,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAuBF,wBAAgB,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,gBAAgB,CAWjE;AAmLD,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,wBAAwB,GAAG,iBAAiB,CA6qBzF"}
|
package/dist/conversation.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { conversationChangeSet } from './change-set.js';
|
|
2
2
|
import { runtimeError } from './failure.js';
|
|
3
3
|
import { declaredFile } from './file.js';
|
|
4
|
-
import { chatDraftRevision } from './identity.js';
|
|
4
|
+
import { changeBatchIdentity, chatDraftRevision } from './identity.js';
|
|
5
|
+
import { OFFLINE } from './outcome.js';
|
|
5
6
|
const QUIET = {
|
|
6
7
|
turn: null,
|
|
7
8
|
questions: [],
|
|
@@ -158,11 +159,29 @@ function limitOf(options) {
|
|
|
158
159
|
}
|
|
159
160
|
return limit;
|
|
160
161
|
}
|
|
162
|
+
function unwritten(draft) {
|
|
163
|
+
return draft.text === '' && draft.files.length === 0;
|
|
164
|
+
}
|
|
165
|
+
function pending(draft) {
|
|
166
|
+
return draft.submitted === undefined ? {} : { submitted: draft.submitted };
|
|
167
|
+
}
|
|
168
|
+
function withSubmitted(draft, submitted) {
|
|
169
|
+
const { submitted: _held, ...unsent } = draft;
|
|
170
|
+
return submitted.length === 0 ? unsent : { ...unsent, submitted };
|
|
171
|
+
}
|
|
172
|
+
function returned(draft, submission, others) {
|
|
173
|
+
return withSubmitted({
|
|
174
|
+
conversation: draft.conversation,
|
|
175
|
+
text: [submission.text, draft.text].filter((one) => one !== '').join('\n'),
|
|
176
|
+
files: [...submission.files, ...draft.files],
|
|
177
|
+
revision: chatDraftRevision(),
|
|
178
|
+
}, others);
|
|
179
|
+
}
|
|
161
180
|
export function createConversationStore(deps) {
|
|
162
181
|
const messages = new Map();
|
|
163
182
|
const reads = new Map();
|
|
164
183
|
const drafts = new Map();
|
|
165
|
-
const sending = new
|
|
184
|
+
const sending = new Set();
|
|
166
185
|
const behind = new Set();
|
|
167
186
|
const gaps = new Map();
|
|
168
187
|
const lives = new Map();
|
|
@@ -200,7 +219,7 @@ export function createConversationStore(deps) {
|
|
|
200
219
|
process: facts.process === null ? null : { ...facts.process },
|
|
201
220
|
commands: structuredClone(facts.commands),
|
|
202
221
|
options: structuredClone(facts.options),
|
|
203
|
-
chatDraft: draft === undefined || draft
|
|
222
|
+
chatDraft: draft === undefined || unwritten(draft)
|
|
204
223
|
? null
|
|
205
224
|
: { text: draft.text, files: [...draft.files], revision: draft.revision },
|
|
206
225
|
};
|
|
@@ -370,18 +389,15 @@ export function createConversationStore(deps) {
|
|
|
370
389
|
const advances = read !== undefined &&
|
|
371
390
|
!behind.has(conversation) &&
|
|
372
391
|
(read === null || message.position > read);
|
|
373
|
-
|
|
392
|
+
await sealed(local, conversation, new Set([message.turn]));
|
|
374
393
|
await local.keepMessages({
|
|
375
394
|
conversation,
|
|
376
395
|
messages: [message],
|
|
377
396
|
...(advances ? { read: message.position } : {}),
|
|
378
|
-
sealed,
|
|
379
397
|
});
|
|
380
398
|
messages.set(conversation, merged(messages.get(conversation) ?? [], [message]));
|
|
381
399
|
if (advances)
|
|
382
400
|
reads.set(conversation, message.position);
|
|
383
|
-
if (sealed)
|
|
384
|
-
drafts.delete(conversation);
|
|
385
401
|
sealTurns(conversation, new Set([message.turn]));
|
|
386
402
|
deps.publish(conversationChangeSet([{ conversation, identity: message.identity }], [conversation]));
|
|
387
403
|
});
|
|
@@ -433,17 +449,14 @@ export function createConversationStore(deps) {
|
|
|
433
449
|
if (!replicated.has(conversation))
|
|
434
450
|
return;
|
|
435
451
|
const newest = arriving.reduce((top, message) => (top === null || message.position > top ? message.position : top), from ?? null);
|
|
436
|
-
const
|
|
437
|
-
|
|
438
|
-
await local.keepMessages({ conversation, messages: arriving, read: newest, sealed });
|
|
452
|
+
const sealing = await sealed(local, conversation, new Set(arriving.map((message) => message.turn)));
|
|
453
|
+
await local.keepMessages({ conversation, messages: arriving, read: newest });
|
|
439
454
|
messages.set(conversation, merged(messages.get(conversation) ?? [], arriving));
|
|
440
455
|
reads.set(conversation, newest);
|
|
441
|
-
if (sealed)
|
|
442
|
-
drafts.delete(conversation);
|
|
443
456
|
sealTurns(conversation, new Set(arriving.map((message) => message.turn)));
|
|
444
457
|
if ((gaps.get(conversation) ?? 0) === generation)
|
|
445
458
|
behind.delete(conversation);
|
|
446
|
-
if (arriving.length > 0 ||
|
|
459
|
+
if (arriving.length > 0 || sealing) {
|
|
447
460
|
deps.publish(conversationChangeSet(arriving.map((message) => ({ conversation, identity: message.identity })), [conversation]));
|
|
448
461
|
}
|
|
449
462
|
});
|
|
@@ -490,22 +503,89 @@ export function createConversationStore(deps) {
|
|
|
490
503
|
if (sealTurns(conversation, new Set([arriving.turn])))
|
|
491
504
|
emit(conversation);
|
|
492
505
|
}
|
|
506
|
+
async function kept(local, conversation, following) {
|
|
507
|
+
if (following === null || (unwritten(following) && following.submitted === undefined)) {
|
|
508
|
+
await local.dropChatDraft(conversation);
|
|
509
|
+
drafts.delete(conversation);
|
|
510
|
+
}
|
|
511
|
+
else {
|
|
512
|
+
await local.keepChatDraft(following);
|
|
513
|
+
drafts.set(conversation, following);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
async function sealed(local, conversation, turns) {
|
|
517
|
+
const held = drafts.get(conversation);
|
|
518
|
+
const submitted = held?.submitted ?? [];
|
|
519
|
+
const left = submitted.filter((one) => one.turn === null || !turns.has(one.turn));
|
|
520
|
+
if (held === undefined || left.length === submitted.length)
|
|
521
|
+
return false;
|
|
522
|
+
await kept(local, conversation, withSubmitted(held, left));
|
|
523
|
+
return true;
|
|
524
|
+
}
|
|
493
525
|
function withDraft(conversation, next) {
|
|
494
526
|
return deps.durably(async (local) => {
|
|
495
527
|
const following = next(drafts.get(conversation));
|
|
496
528
|
if (following === undefined)
|
|
497
529
|
return;
|
|
498
|
-
|
|
499
|
-
await local.dropChatDraft(conversation);
|
|
500
|
-
drafts.delete(conversation);
|
|
501
|
-
}
|
|
502
|
-
else {
|
|
503
|
-
await local.keepChatDraft(following);
|
|
504
|
-
drafts.set(conversation, following);
|
|
505
|
-
}
|
|
530
|
+
await kept(local, conversation, following);
|
|
506
531
|
deps.publish(conversationChangeSet([], [conversation]));
|
|
507
532
|
});
|
|
508
533
|
}
|
|
534
|
+
async function submitted(conversation, operation, draft) {
|
|
535
|
+
let submission;
|
|
536
|
+
await withDraft(conversation, (current) => {
|
|
537
|
+
submission = current?.submitted?.find((one) => one.operation === operation);
|
|
538
|
+
if (submission !== undefined)
|
|
539
|
+
return undefined;
|
|
540
|
+
const said = draft ?? current;
|
|
541
|
+
submission = {
|
|
542
|
+
operation,
|
|
543
|
+
text: said?.text ?? '',
|
|
544
|
+
files: [...(said?.files ?? [])],
|
|
545
|
+
turn: null,
|
|
546
|
+
};
|
|
547
|
+
return {
|
|
548
|
+
conversation,
|
|
549
|
+
...(draft === undefined || current === undefined
|
|
550
|
+
? { text: '', files: [], revision: chatDraftRevision() }
|
|
551
|
+
: { text: current.text, files: current.files, revision: current.revision }),
|
|
552
|
+
submitted: [...(current?.submitted ?? []), submission],
|
|
553
|
+
};
|
|
554
|
+
});
|
|
555
|
+
return submission;
|
|
556
|
+
}
|
|
557
|
+
async function dispatched(conversation, submission) {
|
|
558
|
+
sending.add(submission.operation);
|
|
559
|
+
try {
|
|
560
|
+
const files = await Promise.all(submission.files.map(async (file) => ({ ...(await declaredFile(file)), blob: file.blob })));
|
|
561
|
+
const result = await invoke('conversation.send', conversation, {
|
|
562
|
+
text: submission.text,
|
|
563
|
+
files,
|
|
564
|
+
operation_id: submission.operation,
|
|
565
|
+
});
|
|
566
|
+
if (result.kind === 'revoked-authorization')
|
|
567
|
+
return result;
|
|
568
|
+
if (result.kind !== 'action' && result.retryable)
|
|
569
|
+
return result;
|
|
570
|
+
const turn = turnOf(result);
|
|
571
|
+
await withDraft(conversation, (current) => {
|
|
572
|
+
const held = current?.submitted?.find((one) => one.operation === submission.operation);
|
|
573
|
+
if (current === undefined || held === undefined || held.turn !== null)
|
|
574
|
+
return undefined;
|
|
575
|
+
const others = current.submitted.filter((one) => one !== held);
|
|
576
|
+
if (result.kind !== 'action')
|
|
577
|
+
return returned(current, held, others);
|
|
578
|
+
const arrived = (messages.get(conversation) ?? []).some((message) => message.turn === turn);
|
|
579
|
+
return withSubmitted(current, turn === null || arrived
|
|
580
|
+
? others
|
|
581
|
+
: current.submitted.map((one) => (one === held ? { ...held, turn } : one)));
|
|
582
|
+
});
|
|
583
|
+
return result;
|
|
584
|
+
}
|
|
585
|
+
finally {
|
|
586
|
+
sending.delete(submission.operation);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
509
589
|
function invoke(name, conversation, extra = {}) {
|
|
510
590
|
return deps.call(name, { conversation, ...extra });
|
|
511
591
|
}
|
|
@@ -521,41 +601,16 @@ export function createConversationStore(deps) {
|
|
|
521
601
|
create(input) {
|
|
522
602
|
return deps.call('conversation.create', input);
|
|
523
603
|
},
|
|
524
|
-
async send(conversation) {
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
if (pending !== undefined) {
|
|
528
|
-
sending.set(conversation, pending);
|
|
529
|
-
deps.publish(conversationChangeSet([], [conversation]));
|
|
604
|
+
async send(conversation, operation = changeBatchIdentity(), draft) {
|
|
605
|
+
if (deps.online()) {
|
|
606
|
+
return dispatched(conversation, await submitted(conversation, operation, draft));
|
|
530
607
|
}
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
})));
|
|
536
|
-
const result = await invoke('conversation.send', conversation, {
|
|
537
|
-
text: draft?.text ?? '',
|
|
538
|
-
files,
|
|
539
|
-
});
|
|
540
|
-
const turn = turnOf(result);
|
|
541
|
-
if (turn === null || draft === undefined)
|
|
542
|
-
return result;
|
|
543
|
-
await withDraft(conversation, (current) => {
|
|
544
|
-
if (current !== draft)
|
|
545
|
-
return undefined;
|
|
546
|
-
const sealed = (messages.get(conversation) ?? []).some((message) => message.turn === turn);
|
|
547
|
-
return sealed ? null : { ...draft, turn };
|
|
548
|
-
});
|
|
549
|
-
return result;
|
|
550
|
-
}
|
|
551
|
-
finally {
|
|
552
|
-
if (pending !== undefined && sending.get(conversation) === pending) {
|
|
553
|
-
sending.delete(conversation);
|
|
554
|
-
if (drafts.get(conversation) === draft) {
|
|
555
|
-
deps.publish(conversationChangeSet([], [conversation]));
|
|
556
|
-
}
|
|
557
|
-
}
|
|
608
|
+
if (draft !== undefined) {
|
|
609
|
+
await withDraft(conversation, (current) => current?.submitted?.some((one) => one.operation === operation) === true
|
|
610
|
+
? undefined
|
|
611
|
+
: returned(current ?? { conversation, text: '', files: [], revision: '' }, { operation, ...draft, turn: null }, current?.submitted ?? []));
|
|
558
612
|
}
|
|
613
|
+
return OFFLINE;
|
|
559
614
|
},
|
|
560
615
|
answer(conversation, answer) {
|
|
561
616
|
return invoke('conversation.answer', conversation, { answer });
|
|
@@ -570,7 +625,12 @@ export function createConversationStore(deps) {
|
|
|
570
625
|
const result = await invoke('conversation.cancel', conversation, { turn });
|
|
571
626
|
if (result.kind !== 'action')
|
|
572
627
|
return result;
|
|
573
|
-
await withDraft(conversation, (current) =>
|
|
628
|
+
await withDraft(conversation, (current) => {
|
|
629
|
+
const held = current?.submitted?.find((one) => one.turn === turn);
|
|
630
|
+
if (current === undefined || held === undefined)
|
|
631
|
+
return undefined;
|
|
632
|
+
return returned(current, held, current.submitted.filter((one) => one !== held));
|
|
633
|
+
});
|
|
574
634
|
return result;
|
|
575
635
|
},
|
|
576
636
|
delete(conversation) {
|
|
@@ -579,16 +639,24 @@ export function createConversationStore(deps) {
|
|
|
579
639
|
};
|
|
580
640
|
const chatDraft = {
|
|
581
641
|
write(conversation, draft, revision = chatDraftRevision()) {
|
|
582
|
-
return withDraft(conversation, () => ({
|
|
642
|
+
return withDraft(conversation, (current) => ({
|
|
583
643
|
conversation,
|
|
584
644
|
text: draft.text,
|
|
585
645
|
files: [...draft.files],
|
|
586
|
-
turn: null,
|
|
587
646
|
revision,
|
|
647
|
+
...(current?.submitted === undefined ? {} : { submitted: current.submitted }),
|
|
588
648
|
}));
|
|
589
649
|
},
|
|
590
650
|
discard(conversation) {
|
|
591
|
-
return withDraft(conversation, (current) =>
|
|
651
|
+
return withDraft(conversation, (current) => current === undefined
|
|
652
|
+
? undefined
|
|
653
|
+
: {
|
|
654
|
+
conversation,
|
|
655
|
+
text: '',
|
|
656
|
+
files: [],
|
|
657
|
+
revision: chatDraftRevision(),
|
|
658
|
+
...pending(current),
|
|
659
|
+
});
|
|
592
660
|
},
|
|
593
661
|
};
|
|
594
662
|
return {
|
|
@@ -634,6 +702,23 @@ export function createConversationStore(deps) {
|
|
|
634
702
|
if (behind.size > 0)
|
|
635
703
|
progress.complete = false;
|
|
636
704
|
},
|
|
705
|
+
async resend(progress) {
|
|
706
|
+
for (const [conversation, held] of [...drafts]) {
|
|
707
|
+
for (const submission of held.submitted ?? []) {
|
|
708
|
+
if (submission.turn !== null || sending.has(submission.operation))
|
|
709
|
+
continue;
|
|
710
|
+
if (deps.closed())
|
|
711
|
+
return;
|
|
712
|
+
const result = await dispatched(conversation, submission);
|
|
713
|
+
if (result.kind === 'revoked-authorization')
|
|
714
|
+
return;
|
|
715
|
+
if (result.kind === 'transport-uncertainty') {
|
|
716
|
+
progress.reachable = false;
|
|
717
|
+
return;
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
},
|
|
637
722
|
current() {
|
|
638
723
|
return behind.size === 0;
|
|
639
724
|
},
|
package/dist/entry.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type QueryResult } from './query.js';
|
|
2
|
+
export { QueryError } from './query.js';
|
|
3
|
+
export type EntryRoom = {
|
|
4
|
+
locator: string;
|
|
5
|
+
schema: string | null;
|
|
6
|
+
documents: Readonly<Record<string, string>>;
|
|
7
|
+
};
|
|
8
|
+
export type EntryArguments = Readonly<Record<string, string>>;
|
|
9
|
+
export type EntryParameterKind = 'string' | 'integer' | 'number' | 'boolean';
|
|
10
|
+
export declare function boundQuery(template: unknown, args: EntryArguments): unknown;
|
|
11
|
+
export declare function entryParameters(template: unknown): readonly string[];
|
|
12
|
+
export declare function entryRefusal(template: unknown): string | null;
|
|
13
|
+
export type EntryScope = {
|
|
14
|
+
results(queries: Readonly<Record<string, unknown>>): Promise<Record<string, QueryResult>>;
|
|
15
|
+
};
|
|
16
|
+
export declare function entryScope(rooms: readonly EntryRoom[]): EntryScope;
|
|
17
|
+
//# sourceMappingURL=entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"AAGA,OAAO,EAML,KAAK,WAAW,EAEjB,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,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;CAC3F,CAAC;AAEF,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,GAAG,UAAU,CAqDlE"}
|
package/dist/entry.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { attachedModel } from './attached-model.js';
|
|
2
|
+
import { collectionOf, passingDocument } from './collection.js';
|
|
3
|
+
import { NO_MODEL } from './model.js';
|
|
4
|
+
import { invalid, planOf, plain, QueryError, } from './query.js';
|
|
5
|
+
import { createReadSide } from './read-side.js';
|
|
6
|
+
import { rowsOf } from './rows.js';
|
|
7
|
+
export { QueryError } from './query.js';
|
|
8
|
+
const PARAMETER = '$param';
|
|
9
|
+
const KIND = 'as';
|
|
10
|
+
const INTEGER = /^-?(?:0|[1-9][0-9]*)$/u;
|
|
11
|
+
const NUMBER = /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?$/u;
|
|
12
|
+
function parameterOf(value) {
|
|
13
|
+
if (!plain(value) || !Object.hasOwn(value, PARAMETER))
|
|
14
|
+
return null;
|
|
15
|
+
const { [PARAMETER]: name, [KIND]: kind = 'string', ...rest } = value;
|
|
16
|
+
if (typeof name !== 'string' || Object.keys(rest).length > 0)
|
|
17
|
+
return null;
|
|
18
|
+
if (kind !== 'string' && kind !== 'integer' && kind !== 'number' && kind !== 'boolean') {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return { name, kind };
|
|
22
|
+
}
|
|
23
|
+
function converted(text, kind, at) {
|
|
24
|
+
if (kind === 'string')
|
|
25
|
+
return text;
|
|
26
|
+
if (kind === 'boolean') {
|
|
27
|
+
if (text === 'true' || text === 'false')
|
|
28
|
+
return text === 'true';
|
|
29
|
+
return invalid(at, 'expects true or false');
|
|
30
|
+
}
|
|
31
|
+
if (!(kind === 'integer' ? INTEGER : NUMBER).test(text))
|
|
32
|
+
invalid(at, `expects ${kind === 'integer' ? 'an integer' : 'a number'}`);
|
|
33
|
+
const number = Number(text);
|
|
34
|
+
if (!Number.isFinite(number) || (kind === 'integer' && !Number.isSafeInteger(number))) {
|
|
35
|
+
invalid(at, 'is out of range');
|
|
36
|
+
}
|
|
37
|
+
return number;
|
|
38
|
+
}
|
|
39
|
+
function bound(template, args, at) {
|
|
40
|
+
const parameter = parameterOf(template);
|
|
41
|
+
if (parameter !== null) {
|
|
42
|
+
const text = args[parameter.name];
|
|
43
|
+
if (text === undefined || !Object.hasOwn(args, parameter.name)) {
|
|
44
|
+
invalid(at, `names the parameter ${parameter.name}, which the route lacks`);
|
|
45
|
+
}
|
|
46
|
+
return converted(text, parameter.kind, at);
|
|
47
|
+
}
|
|
48
|
+
if (Array.isArray(template)) {
|
|
49
|
+
return template.map((item, index) => bound(item, args, `${at}[${index}]`));
|
|
50
|
+
}
|
|
51
|
+
if (plain(template)) {
|
|
52
|
+
return Object.fromEntries(Object.entries(template).map(([name, value]) => [
|
|
53
|
+
name,
|
|
54
|
+
bound(value, args, at === '' ? name : `${at}.${name}`),
|
|
55
|
+
]));
|
|
56
|
+
}
|
|
57
|
+
return template;
|
|
58
|
+
}
|
|
59
|
+
export function boundQuery(template, args) {
|
|
60
|
+
return bound(template, args, '');
|
|
61
|
+
}
|
|
62
|
+
export function entryParameters(template) {
|
|
63
|
+
const parameter = parameterOf(template);
|
|
64
|
+
if (parameter !== null)
|
|
65
|
+
return [parameter.name];
|
|
66
|
+
if (Array.isArray(template))
|
|
67
|
+
return [...new Set(template.flatMap(entryParameters))];
|
|
68
|
+
if (plain(template))
|
|
69
|
+
return [...new Set(Object.values(template).flatMap(entryParameters))];
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
const SAMPLED = {
|
|
73
|
+
direction: 'asc',
|
|
74
|
+
nulls: 'last',
|
|
75
|
+
stringSort: 'lexical',
|
|
76
|
+
locale: 'en',
|
|
77
|
+
limit: 0,
|
|
78
|
+
pathPrefix: 'entry',
|
|
79
|
+
field: '/entry',
|
|
80
|
+
fields: '/entry',
|
|
81
|
+
types: 'any',
|
|
82
|
+
$in: 'entry',
|
|
83
|
+
$nin: 'entry',
|
|
84
|
+
$all: 'entry',
|
|
85
|
+
$size: 0,
|
|
86
|
+
$exists: true,
|
|
87
|
+
$gt: 0,
|
|
88
|
+
$gte: 0,
|
|
89
|
+
$lt: 0,
|
|
90
|
+
$lte: 0,
|
|
91
|
+
};
|
|
92
|
+
function sampled(template, key) {
|
|
93
|
+
if (parameterOf(template) !== null)
|
|
94
|
+
return Object.hasOwn(SAMPLED, key) ? SAMPLED[key] : null;
|
|
95
|
+
if (Array.isArray(template))
|
|
96
|
+
return template.map((item) => sampled(item, key));
|
|
97
|
+
if (plain(template)) {
|
|
98
|
+
return Object.fromEntries(Object.entries(template).map(([name, value]) => [name, sampled(value, name)]));
|
|
99
|
+
}
|
|
100
|
+
return template;
|
|
101
|
+
}
|
|
102
|
+
export function entryRefusal(template) {
|
|
103
|
+
try {
|
|
104
|
+
planOf(sampled(template, ''), { listed: false, rooms: [] });
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
if (error instanceof QueryError)
|
|
109
|
+
return error.message;
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
export function entryScope(rooms) {
|
|
114
|
+
const readSide = createReadSide();
|
|
115
|
+
const held = [];
|
|
116
|
+
const documents = rooms.flatMap((room) => {
|
|
117
|
+
const model = attachedModel({
|
|
118
|
+
kind: 'model',
|
|
119
|
+
snapshot: { identity: room.locator, version: '', schema: room.schema, revision: null },
|
|
120
|
+
}, NO_MODEL).state;
|
|
121
|
+
held.push({
|
|
122
|
+
locator: room.locator,
|
|
123
|
+
available: model.status !== 'unavailable',
|
|
124
|
+
types: model.status === 'unavailable' ? [] : Object.values(model.types),
|
|
125
|
+
});
|
|
126
|
+
const composition = { model, selection: null };
|
|
127
|
+
const collection = collectionOf(room.documents, composition);
|
|
128
|
+
return Object.keys(room.documents)
|
|
129
|
+
.sort()
|
|
130
|
+
.map((path) => ({
|
|
131
|
+
locator: room.locator,
|
|
132
|
+
path,
|
|
133
|
+
before: [],
|
|
134
|
+
after: rowsOf(room.locator, path, passingDocument(collection, path) ?? null, composition, null, null),
|
|
135
|
+
}));
|
|
136
|
+
});
|
|
137
|
+
readSide.apply({
|
|
138
|
+
documents,
|
|
139
|
+
drafts: [],
|
|
140
|
+
rooms: [],
|
|
141
|
+
queues: [],
|
|
142
|
+
presentations: [],
|
|
143
|
+
messages: [],
|
|
144
|
+
conversations: [],
|
|
145
|
+
});
|
|
146
|
+
const planned = { listed: true, rooms: held };
|
|
147
|
+
return {
|
|
148
|
+
async results(queries) {
|
|
149
|
+
const results = {};
|
|
150
|
+
for (const [name, query] of Object.entries(queries)) {
|
|
151
|
+
results[name] = await readSide.query(planOf(query, planned));
|
|
152
|
+
}
|
|
153
|
+
return results;
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
}
|
package/dist/fence.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fence.d.ts","sourceRoot":"","sources":["../src/fence.ts"],"names":[],"mappings":"AAAA,qBAAa,SAAS,CAAC,CAAC,CAAE,SAAQ,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;;IAG9C,YAAY,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,EAG/C;IAEQ,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAE5C;CACF"}
|
package/dist/fence.js
ADDED
package/dist/host.d.ts
CHANGED
|
@@ -10,11 +10,12 @@ export type AttachedPort = {
|
|
|
10
10
|
};
|
|
11
11
|
export type MdRuntimeHost = {
|
|
12
12
|
attach(port: RuntimePort, app: string, release?: string, reach?: PortReach): AttachedPort;
|
|
13
|
-
endAuthorization(): Promise<void>;
|
|
13
|
+
endAuthorization(holder?: string): Promise<void>;
|
|
14
|
+
lose(locators: readonly string[]): Promise<void>;
|
|
14
15
|
stop(): Promise<void>;
|
|
15
16
|
};
|
|
16
17
|
export declare function serveMdRuntime(options: MdRuntimeHostOptions): MdRuntimeHost;
|
|
17
18
|
export type { PortReach, ReachedDocument } from './reach.js';
|
|
18
|
-
export { AUTHORED_SCHEMA, STORE_SCHEMA } from './store.js';
|
|
19
|
+
export { AUTHORED_SCHEMA, authoredBinding, authoredBy, authoredHolder, bindAuthored, STORE_SCHEMA, } from './store.js';
|
|
19
20
|
export type { RuntimePort } from './wire.js';
|
|
20
21
|
//# sourceMappingURL=host.d.ts.map
|
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,EAEtB,MA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AAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,IAAI,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB,CAAC;AA0FF,wBAAgB,cAAc,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CAoH3E;AAED,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EACL,eAAe,EACf,eAAe,EACf,UAAU,EACV,cAAc,EACd,YAAY,EACZ,YAAY,GACb,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/host.js
CHANGED
|
@@ -50,7 +50,7 @@ function answered(md, app, writtenBy, member, input) {
|
|
|
50
50
|
case 'conversation.create':
|
|
51
51
|
return md.conversation.create(input[0]);
|
|
52
52
|
case 'conversation.send':
|
|
53
|
-
return md.conversation.send(input[0]);
|
|
53
|
+
return md.conversation.send(input[0], input[1], input[2]);
|
|
54
54
|
case 'conversation.answer':
|
|
55
55
|
return md.conversation.answer(input[0], input[1]);
|
|
56
56
|
case 'conversation.interrupt':
|
|
@@ -161,19 +161,22 @@ export function serveMdRuntime(options) {
|
|
|
161
161
|
}
|
|
162
162
|
return {
|
|
163
163
|
attach,
|
|
164
|
-
async endAuthorization() {
|
|
164
|
+
async endAuthorization(holder) {
|
|
165
165
|
authorized = false;
|
|
166
166
|
for (const [detach, send] of [...attachments]) {
|
|
167
167
|
send({ kind: 'ended' });
|
|
168
168
|
detach();
|
|
169
169
|
}
|
|
170
170
|
close();
|
|
171
|
-
await removeRuntimeStore()
|
|
172
|
-
|
|
171
|
+
if (!(await removeRuntimeStore(holder)))
|
|
172
|
+
await options.shell.dropGeneration();
|
|
173
|
+
},
|
|
174
|
+
lose(locators) {
|
|
175
|
+
return runtime.lose(locators);
|
|
173
176
|
},
|
|
174
177
|
stop() {
|
|
175
178
|
return runtime.stop();
|
|
176
179
|
},
|
|
177
180
|
};
|
|
178
181
|
}
|
|
179
|
-
export { AUTHORED_SCHEMA, STORE_SCHEMA } from './store.js';
|
|
182
|
+
export { AUTHORED_SCHEMA, authoredBinding, authoredBy, authoredHolder, bindAuthored, STORE_SCHEMA, } from './store.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export type { AcceptedMessage, ActionDeclaration, ActionRequest, ActionResult, Adapter, AdapterFailure, Authorization, BinaryFile, BinaryRequest, BinaryResult, ReferrerScope, BootstrapPage, BootstrapRequest, BootstrapResult, Capability, ChangeAuthor, ContractUnavailable, ConversationAction, ConversationAgents, ConversationEvent, ConversationHistories, ConversationHistoryPage, ConversationHistoryRequest, ConversationMessage, ConversationStream, DiscoverResult, DiscoveredRoom, Discovery, HistoryAuthor, HistoryRequest, HistoryResult, HistoryRetention, HistoryRevision, HeldRoom, ListedConversation, MdModelIdentity, Member, MutationRequest, MutationResult, PageToken, ProviderLimit, ProviderRefusal, RefreshPage, RefreshRequest, RefreshResult, Retention, RetryableRefusal, RevokedAuthorization, RoomModels, RoomNotReadable, RoomStream, RoomStreamEvent, RoomVersionAt, ServiceMode, ServiceModeSignal, TransportUncertainty, TurnContext, TurnOperation, TypedSelection, } from './adapter.js';
|
|
1
|
+
export type { AcceptedMessage, ActionDeclaration, ActionRequest, ActionResult, Adapter, AdapterFailure, Authorization, BinaryFile, BinaryRequest, BinaryResult, ReferrerScope, BootstrapPage, BootstrapRequest, BootstrapResult, Capability, ChangeAuthor, ContractUnavailable, ConversationAction, ConversationAgents, ConversationEvent, ConversationHistories, ConversationHistoryPage, ConversationHistoryRequest, ConversationMessage, ConversationStream, DiscoverResult, DiscoveredRoom, Discovery, 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
5
|
export type { AppRoom, AppTypedSelection, BinaryFileSurface, ConnectionRefusal, ConnectionRefusalCode, HistoryQuery, MdRuntime, MdRuntimeOptions, PresentationSurface, RoomDraftSurface, RoomSchemas, SavedRoomDraft, SaveResult, } from './connection.js';
|
|
6
6
|
export type { Observation } from './observation.js';
|
|
7
|
-
export type { BinaryAnswer, CallResult, Failure, HistoryAnswer, QueueEntry, Submission, } from './outcome.js';
|
|
7
|
+
export type { BinaryAnswer, 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, } 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,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,OAAO,EACP,cAAc,EACd,aAAa,EACb,UAAU,EACV,aAAa,EACb,YAAY,EACZ,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,eA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,cAAc,CAAC"}
|
|
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,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,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,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,oBAAoB,EACpB,UAAU,EACV,eAAe,EACf,UAAU,EACV,eAAe,EACf,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,WAAW,EACX,aAAa,EACb,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAChF,YAAY,EACV,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAChE,YAAY,EACV,OAAO,EACP,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB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