@agentshouse/mdruntime 0.1.0-c0136de3edfbe → 0.1.0-c01d4615bfe46
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 +16 -15
- package/dist/acceptance.d.ts +0 -3
- package/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +74 -164
- package/dist/act-lanes.d.ts +30 -0
- package/dist/act-lanes.d.ts.map +1 -0
- package/dist/act-lanes.js +225 -0
- package/dist/actions.d.ts +8 -2
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +122 -68
- package/dist/adapter.d.ts +49 -55
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +0 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +0 -5
- package/dist/bootstrap.d.ts +1 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +6 -18
- package/dist/change-set.d.ts +4 -0
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +6 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +4 -2
- package/dist/chat-types.d.ts +2 -2
- package/dist/chat-types.d.ts.map +1 -1
- package/dist/chat-types.js +11 -2
- package/dist/client.d.ts +13 -19
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +35 -19
- package/dist/collection.d.ts +22 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +12 -2
- package/dist/compile.d.ts +2 -0
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +31 -24
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +32 -24
- package/dist/conversation-live.d.ts +147 -0
- package/dist/conversation-live.d.ts.map +1 -0
- package/dist/conversation-live.js +258 -0
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +7 -1
- package/dist/conversation.d.ts +52 -44
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +956 -1029
- package/dist/declaration.d.ts +10 -0
- package/dist/declaration.d.ts.map +1 -0
- package/dist/declaration.js +24 -0
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +19 -44
- package/dist/durability.d.ts +13 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +4 -0
- package/dist/entry.js +1 -1
- package/dist/expectation.d.ts +26 -13
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +72 -19
- package/dist/failure.d.ts +3 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +6 -0
- package/dist/figures.d.ts +1 -0
- package/dist/figures.d.ts.map +1 -1
- package/dist/figures.js +2 -2
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +2 -1
- package/dist/holdings.d.ts +29 -0
- package/dist/holdings.d.ts.map +1 -0
- package/dist/holdings.js +95 -0
- package/dist/host.d.ts +18 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +46 -11
- package/dist/index.d.ts +17 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -6
- package/dist/install.d.ts +2 -4
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +53 -83
- package/dist/lifecycle.d.ts +1 -1
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +45 -35
- package/dist/listing.d.ts +6 -11
- package/dist/listing.d.ts.map +1 -1
- package/dist/listing.js +25 -61
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +3 -3
- package/dist/locks.d.ts +2 -4
- package/dist/locks.d.ts.map +1 -1
- package/dist/locks.js +10 -39
- package/dist/lost.d.ts.map +1 -1
- package/dist/lost.js +10 -22
- package/dist/media.d.ts +1 -1
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +10 -13
- package/dist/memory.d.ts +7 -3
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +58 -27
- package/dist/messages.d.ts +10 -6
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +26 -36
- package/dist/model.d.ts +0 -1
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +0 -5
- package/dist/models.d.ts +4 -8
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +95 -135
- package/dist/observation.d.ts +3 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +22 -21
- package/dist/opened.d.ts +1 -1
- package/dist/opened.d.ts.map +1 -1
- package/dist/opened.js +5 -5
- package/dist/opening.d.ts.map +1 -1
- package/dist/opening.js +7 -10
- package/dist/outcome.d.ts +10 -1
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +23 -2
- package/dist/overlay.d.ts +5 -1
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +36 -21
- package/dist/page-metadata.d.ts +8 -0
- package/dist/page-metadata.d.ts.map +1 -0
- package/dist/page-metadata.js +19 -0
- package/dist/parts.d.ts +3 -58
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +10 -115
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +22 -0
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +25 -24
- package/dist/presence.d.ts +52 -0
- package/dist/presence.d.ts.map +1 -0
- package/dist/presence.js +220 -0
- package/dist/queries.d.ts +1 -1
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +24 -14
- package/dist/query.d.ts +0 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/questions.d.ts +2 -5
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +3 -6
- package/dist/queue.d.ts +40 -0
- package/dist/queue.d.ts.map +1 -0
- package/dist/queue.js +450 -0
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +68 -23
- package/dist/react.d.ts +11 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +33 -1
- package/dist/readiness.d.ts +1 -2
- package/dist/readiness.d.ts.map +1 -1
- package/dist/reads.d.ts +4 -1
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +47 -5
- package/dist/recovery.d.ts +3 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +29 -7
- package/dist/refresh.js +2 -2
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +5 -6
- package/dist/replica.d.ts +5 -10
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +15 -16
- package/dist/retried.d.ts +30 -0
- package/dist/retried.d.ts.map +1 -0
- package/dist/retried.js +72 -0
- package/dist/room-draft.d.ts +4 -6
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +48 -59
- package/dist/room-drafts.d.ts.map +1 -1
- package/dist/room-drafts.js +17 -16
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +3 -4
- package/dist/runtime.d.ts +11 -19
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts +42 -86
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +333 -163
- package/dist/saves.d.ts +2 -40
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +109 -703
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +2 -3
- package/dist/shared.d.ts +1 -6
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +13 -95
- package/dist/shown.d.ts +6 -4
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +43 -35
- package/dist/socket/lanes.d.ts +12 -4
- package/dist/socket/lanes.d.ts.map +1 -1
- package/dist/socket/lanes.js +34 -8
- package/dist/socket/session.d.ts +0 -1
- package/dist/socket/session.d.ts.map +1 -1
- package/dist/socket.d.ts +3 -6
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +5 -16
- package/dist/source.d.ts +0 -7
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +5 -4
- package/dist/store/records.d.ts +11 -8
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +43 -12
- package/dist/store/space.d.ts +1 -1
- package/dist/store/space.d.ts.map +1 -1
- package/dist/store/space.js +0 -2
- package/dist/store/watchers.js +1 -2
- package/dist/store.d.ts +12 -7
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +38 -13
- package/dist/stored.d.ts +2 -1
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +27 -15
- package/dist/surface.d.ts +7 -4
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +30 -25
- package/dist/sync.d.ts +0 -1
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +93 -89
- package/dist/tables.d.ts +19 -11
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +58 -21
- package/dist/tallies.d.ts.map +1 -1
- package/dist/tallies.js +6 -7
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +2 -2
- package/dist/wire.d.ts +53 -7
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +17 -4
- package/package.json +3 -2
- package/dist/attempt.d.ts +0 -16
- package/dist/attempt.d.ts.map +0 -1
- package/dist/attempt.js +0 -70
- package/dist/job.d.ts +0 -33
- package/dist/job.d.ts.map +0 -1
- package/dist/job.js +0 -54
- package/dist/log.d.ts +0 -6
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -14
- package/dist/socket/rooms.d.ts +0 -43
- package/dist/socket/rooms.d.ts.map +0 -1
- package/dist/socket/rooms.js +0 -90
- package/dist/store/fences.d.ts +0 -16
- package/dist/store/fences.d.ts.map +0 -1
- package/dist/store/fences.js +0 -26
package/dist/retried.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { refusedForSpace } from './durability.js';
|
|
2
|
+
export const STEPS = [
|
|
3
|
+
'database',
|
|
4
|
+
'sign_in',
|
|
5
|
+
'connection',
|
|
6
|
+
'code',
|
|
7
|
+
'download',
|
|
8
|
+
'conversations',
|
|
9
|
+
'sending',
|
|
10
|
+
'reading',
|
|
11
|
+
];
|
|
12
|
+
export class Unanswered extends Error {
|
|
13
|
+
}
|
|
14
|
+
export function uncertainError(uncertainty) {
|
|
15
|
+
return 'failure' in uncertainty ? uncertainty.failure : new Unanswered();
|
|
16
|
+
}
|
|
17
|
+
export function createRetries(shell) {
|
|
18
|
+
const failing = new Map();
|
|
19
|
+
const handedErrors = new WeakSet();
|
|
20
|
+
function failingIn(step, instance) {
|
|
21
|
+
const instances = failing.get(step) ?? new Set();
|
|
22
|
+
instances.add(instance);
|
|
23
|
+
failing.set(step, instances);
|
|
24
|
+
}
|
|
25
|
+
function handed(failure, instance) {
|
|
26
|
+
failingIn(failure.step, instance);
|
|
27
|
+
shell.retried?.(failure);
|
|
28
|
+
}
|
|
29
|
+
const retries = {
|
|
30
|
+
failed(step, instance, error) {
|
|
31
|
+
if (refusedForSpace(error))
|
|
32
|
+
return;
|
|
33
|
+
if (typeof error === 'object' && error !== null) {
|
|
34
|
+
if (handedErrors.has(error)) {
|
|
35
|
+
failingIn(step, instance);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
handedErrors.add(error);
|
|
39
|
+
}
|
|
40
|
+
if (error instanceof Unanswered)
|
|
41
|
+
retries.unanswered(step, instance);
|
|
42
|
+
else
|
|
43
|
+
handed({ step, answered: true, error }, instance);
|
|
44
|
+
},
|
|
45
|
+
unanswered(step, instance) {
|
|
46
|
+
handed({ step, answered: false }, instance);
|
|
47
|
+
},
|
|
48
|
+
uncertain(step, instance, uncertainty) {
|
|
49
|
+
if ('failure' in uncertainty)
|
|
50
|
+
retries.failed(step, instance, uncertainty.failure);
|
|
51
|
+
else
|
|
52
|
+
retries.unanswered(step, instance);
|
|
53
|
+
},
|
|
54
|
+
succeeded(step, instance) {
|
|
55
|
+
const instances = failing.get(step);
|
|
56
|
+
if (instances === undefined || !instances.delete(instance) || instances.size > 0)
|
|
57
|
+
return;
|
|
58
|
+
failing.delete(step);
|
|
59
|
+
shell.succeeded?.(step);
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
return retries;
|
|
63
|
+
}
|
|
64
|
+
export function retrying(retries, step, instance, ask) {
|
|
65
|
+
return () => ask().then((answer) => {
|
|
66
|
+
retries.succeeded(step, instance);
|
|
67
|
+
return answer;
|
|
68
|
+
}, (error) => {
|
|
69
|
+
retries.failed(step, instance, error);
|
|
70
|
+
throw error;
|
|
71
|
+
});
|
|
72
|
+
}
|
package/dist/room-draft.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type DefinitionOf } from '@agentshouse/mdmodel';
|
|
1
2
|
import type { ProviderRefusal } from './adapter.js';
|
|
2
3
|
import type { Open } from './open.js';
|
|
3
4
|
import type { Change, Precondition } from './change.js';
|
|
@@ -92,7 +93,7 @@ type ChangedUnderneath = {
|
|
|
92
93
|
export type ReturnReason = ProviderRefusal & {
|
|
93
94
|
readonly kind: Open<'conflicted' | 'rejected' | 'withdrawn'>;
|
|
94
95
|
};
|
|
95
|
-
export declare function returnedBy(
|
|
96
|
+
export declare function returnedBy(): ReturnReason;
|
|
96
97
|
export type RoomDraft = {
|
|
97
98
|
readonly room: string;
|
|
98
99
|
readonly path: string;
|
|
@@ -106,8 +107,6 @@ export type RoomDraftWrite = {
|
|
|
106
107
|
readonly roomDraft: RoomDraft | null;
|
|
107
108
|
} | {
|
|
108
109
|
readonly outcome: 'stale';
|
|
109
|
-
readonly code: string;
|
|
110
|
-
readonly retryable: boolean;
|
|
111
110
|
readonly current: RoomDraft | null;
|
|
112
111
|
};
|
|
113
112
|
export declare function staleWrite(current: RoomDraft | null): RoomDraftWrite;
|
|
@@ -146,8 +145,8 @@ export type TextParts = {
|
|
|
146
145
|
readonly value: string;
|
|
147
146
|
};
|
|
148
147
|
};
|
|
149
|
-
export declare function partsAfter(markdown: string, parts: TextParts): string;
|
|
150
|
-
export declare function returnedInto(existing: HeldParts | undefined, returned: HeldParts): HeldParts;
|
|
148
|
+
export declare function partsAfter(markdown: string, parts: TextParts, definitions?: DefinitionOf): string | null;
|
|
149
|
+
export declare function returnedInto(existing: HeldParts | undefined, returned: HeldParts, definitions?: DefinitionOf): HeldParts | null;
|
|
151
150
|
export declare function moveTarget(move: {
|
|
152
151
|
readonly to: string;
|
|
153
152
|
}): string;
|
|
@@ -169,7 +168,6 @@ export declare function changesOf(path: string, parts: HeldParts): {
|
|
|
169
168
|
changes: readonly Change[];
|
|
170
169
|
bases: readonly Precondition[];
|
|
171
170
|
};
|
|
172
|
-
export declare function joinedDraft(carried: SavedDraft, saved: readonly SavedDraft[]): SavedDraft;
|
|
173
171
|
export declare function withdrawnDrafts(drafts: readonly SavedDraft[], changes: readonly Change[]): readonly SavedDraft[];
|
|
174
172
|
export {};
|
|
175
173
|
//# sourceMappingURL=room-draft.d.ts.map
|
package/dist/room-draft.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"room-draft.d.ts","sourceRoot":"","sources":["../src/room-draft.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"room-draft.d.ts","sourceRoot":"","sources":["../src/room-draft.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,YAAY,EAElB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGpD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAKxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAAC;AAE5D,MAAM,MAAM,iBAAiB,GACzB;IACE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACrD,GACD;IAAE,QAAQ,CAAC,QAAQ,EAAE,MA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entshouse/mdmodel';
|
|
1
|
+
import { apply, create, equalValue, frontmatterValue, parse, serialize, } from '@agentshouse/mdmodel';
|
|
2
|
+
import { governing } from './collection.js';
|
|
2
3
|
import { runtimeError } from './failure.js';
|
|
3
4
|
import { sha256 } from './digest.js';
|
|
5
|
+
import { declaredType } from './outcome.js';
|
|
4
6
|
import { binaryLocalId } from './identity.js';
|
|
5
7
|
import { normalize } from './paths.js';
|
|
6
|
-
export function returnedBy(
|
|
7
|
-
return { kind, code:
|
|
8
|
+
export function returnedBy() {
|
|
9
|
+
return { kind: 'withdrawn', code: 'withdrawn', fields: {}, retryable: false };
|
|
8
10
|
}
|
|
9
11
|
export function staleWrite(current) {
|
|
10
|
-
return { outcome: 'stale',
|
|
12
|
+
return { outcome: 'stale', current };
|
|
11
13
|
}
|
|
12
14
|
function malformed(at, needs) {
|
|
13
15
|
throw runtimeError('room-draft-malformed', at === undefined ? 'room-draft-malformed' : `room-draft-malformed at ${at}: ${needs}`);
|
|
@@ -72,7 +74,7 @@ const PART_NAMES = [
|
|
|
72
74
|
'removal',
|
|
73
75
|
'file',
|
|
74
76
|
];
|
|
75
|
-
const NAMED_PARTS = `a part named ${PART_NAMES.slice(0, -1).join(', ')} or ${PART_NAMES.
|
|
77
|
+
const NAMED_PARTS = `a part named ${PART_NAMES.slice(0, -1).join(', ')} or ${PART_NAMES.slice(-1).join('')}`;
|
|
76
78
|
export function readParts(value, path) {
|
|
77
79
|
if (!plain(value))
|
|
78
80
|
malformed(path, 'an object of parts');
|
|
@@ -255,8 +257,10 @@ export function underneath(parts, path, visible) {
|
|
|
255
257
|
const markdown = visible?.documents[path] ?? null;
|
|
256
258
|
const document = visible?.collection.document(path);
|
|
257
259
|
const report = {};
|
|
260
|
+
const unread = document?.type !== undefined &&
|
|
261
|
+
governing(visible.collection.composition, path).status === 'unavailable';
|
|
258
262
|
const fields = {};
|
|
259
|
-
for (const [name, part] of named(parts.fields)) {
|
|
263
|
+
for (const [name, part] of unread ? [] : named(parts.fields)) {
|
|
260
264
|
const current = document !== undefined && Object.hasOwn(document.fields, name)
|
|
261
265
|
? { value: document.fields[name] }
|
|
262
266
|
: null;
|
|
@@ -266,7 +270,7 @@ export function underneath(parts, path, visible) {
|
|
|
266
270
|
if (Object.keys(fields).length > 0)
|
|
267
271
|
report.fields = fields;
|
|
268
272
|
const sections = {};
|
|
269
|
-
for (const [name, part] of named(parts.sections)) {
|
|
273
|
+
for (const [name, part] of unread ? [] : named(parts.sections)) {
|
|
270
274
|
const current = document !== undefined && Object.hasOwn(document.sections, name)
|
|
271
275
|
? document.sections[name]
|
|
272
276
|
: null;
|
|
@@ -276,8 +280,9 @@ export function underneath(parts, path, visible) {
|
|
|
276
280
|
if (Object.keys(sections).length > 0)
|
|
277
281
|
report.sections = sections;
|
|
278
282
|
const preamble = document?.preamble ?? null;
|
|
279
|
-
if (parts.preamble !== undefined && preamble !== parts.preamble.base)
|
|
283
|
+
if (!unread && parts.preamble !== undefined && preamble !== parts.preamble.base) {
|
|
280
284
|
report.preamble = preamble;
|
|
285
|
+
}
|
|
281
286
|
if (parts.markdown !== undefined && markdown !== parts.markdown.base)
|
|
282
287
|
report.markdown = markdown;
|
|
283
288
|
if (parts.creation !== undefined && markdown !== null)
|
|
@@ -293,13 +298,12 @@ export function underneath(parts, path, visible) {
|
|
|
293
298
|
}
|
|
294
299
|
return report;
|
|
295
300
|
}
|
|
296
|
-
const UNTYPED_MEDIA_TYPE = 'application/octet-stream';
|
|
297
301
|
export async function heldFile(blob, base) {
|
|
298
302
|
return {
|
|
299
303
|
localId: binaryLocalId(),
|
|
300
304
|
...(blob instanceof File ? { name: blob.name } : {}),
|
|
301
305
|
byteLength: blob.size,
|
|
302
|
-
mediaType: blob
|
|
306
|
+
mediaType: declaredType(blob),
|
|
303
307
|
sha256: await sha256(blob),
|
|
304
308
|
base,
|
|
305
309
|
};
|
|
@@ -333,30 +337,42 @@ function joined(existing, returned) {
|
|
|
333
337
|
export function lineEnded(text) {
|
|
334
338
|
return text === '' || text.endsWith('\n') ? text : `${text}\n`;
|
|
335
339
|
}
|
|
336
|
-
function
|
|
337
|
-
const
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
value: part.value,
|
|
344
|
-
prior: undefined,
|
|
345
|
-
})));
|
|
346
|
-
return next.outcome === 'applied' ? serialize(next.document) : malformed();
|
|
340
|
+
function written(start, changes, definition) {
|
|
341
|
+
const next = apply(start, changes, definition);
|
|
342
|
+
return next.outcome === 'applied' ? next.document : malformed();
|
|
343
|
+
}
|
|
344
|
+
function empty(definition) {
|
|
345
|
+
const parsed = parse('', '', definition);
|
|
346
|
+
return parsed.ok ? parsed.document : malformed();
|
|
347
347
|
}
|
|
348
|
-
export function partsAfter(markdown, parts) {
|
|
348
|
+
export function partsAfter(markdown, parts, definitions) {
|
|
349
349
|
const fields = named(parts.fields);
|
|
350
|
+
const sections = named(parts.sections);
|
|
351
|
+
if (fields.length === 0 && sections.length === 0 && parts.preamble === undefined)
|
|
352
|
+
return markdown;
|
|
353
|
+
const whole = parse(markdown, '', definitions);
|
|
354
|
+
const type = whole.ok ? whole.document.type : undefined;
|
|
355
|
+
const definition = definitions?.(type);
|
|
356
|
+
if (type !== undefined && definition === undefined)
|
|
357
|
+
return null;
|
|
358
|
+
const valued = fields.length === 0
|
|
359
|
+
? empty(definition)
|
|
360
|
+
: written(create(type, definition), fields.map(([name, part]) => ({
|
|
361
|
+
kind: 'field',
|
|
362
|
+
name,
|
|
363
|
+
value: part.value,
|
|
364
|
+
prior: undefined,
|
|
365
|
+
})), definition);
|
|
366
|
+
const head = parts.preamble === undefined
|
|
367
|
+
? valued
|
|
368
|
+
: written(valued, [{ kind: 'preamble', value: lineEnded(parts.preamble.value), prior: valued.preamble }], definition);
|
|
350
369
|
const pieces = [
|
|
351
|
-
...(fields.length === 0 ? [] : [
|
|
352
|
-
...(
|
|
353
|
-
...named(parts.sections).map(([name, part]) => `## ${name}\n${part.value}`),
|
|
370
|
+
...(fields.length === 0 && parts.preamble === undefined ? [] : [serialize(head)]),
|
|
371
|
+
...sections.map(([name, part]) => serialize(written(empty(definition), [{ kind: 'section', name, value: lineEnded(part.value), prior: undefined }], definition))),
|
|
354
372
|
];
|
|
355
|
-
|
|
356
|
-
return markdown;
|
|
357
|
-
return `${lineEnded(markdown)}\n${pieces.map(lineEnded).join('')}`;
|
|
373
|
+
return `${lineEnded(markdown)}\n${pieces.join('')}`;
|
|
358
374
|
}
|
|
359
|
-
export function returnedInto(existing, returned) {
|
|
375
|
+
export function returnedInto(existing, returned, definitions) {
|
|
360
376
|
if (existing === undefined)
|
|
361
377
|
return returned;
|
|
362
378
|
const next = { ...existing };
|
|
@@ -376,7 +392,9 @@ export function returnedInto(existing, returned) {
|
|
|
376
392
|
delete next.fields;
|
|
377
393
|
delete next.sections;
|
|
378
394
|
delete next.preamble;
|
|
379
|
-
const value = partsAfter(whole.value, existing.markdown === undefined ? existing : returned);
|
|
395
|
+
const value = partsAfter(whole.value, existing.markdown === undefined ? existing : returned, definitions);
|
|
396
|
+
if (value === null)
|
|
397
|
+
return null;
|
|
380
398
|
next.markdown = { value, base: whole.base };
|
|
381
399
|
}
|
|
382
400
|
const creation = existing.creation ?? returned.creation;
|
|
@@ -474,35 +492,6 @@ export function changesOf(path, parts) {
|
|
|
474
492
|
changes.push({ kind: 'remove', path });
|
|
475
493
|
return { changes, bases };
|
|
476
494
|
}
|
|
477
|
-
function rebased(before, after) {
|
|
478
|
-
return before === undefined ? after : { ...after, base: before.base };
|
|
479
|
-
}
|
|
480
|
-
function rebasedAll(before, after) {
|
|
481
|
-
return {
|
|
482
|
-
...before,
|
|
483
|
-
...Object.fromEntries(Object.entries(after).map(([name, part]) => [name, rebased(before?.[name], part)])),
|
|
484
|
-
};
|
|
485
|
-
}
|
|
486
|
-
export function joinedDraft(carried, saved) {
|
|
487
|
-
const draft = saved.find((item) => item.path === carried.path);
|
|
488
|
-
if (draft === undefined)
|
|
489
|
-
return carried;
|
|
490
|
-
const held = carried.parts;
|
|
491
|
-
const next = draft.parts;
|
|
492
|
-
return {
|
|
493
|
-
path: carried.path,
|
|
494
|
-
parts: {
|
|
495
|
-
...held,
|
|
496
|
-
...next,
|
|
497
|
-
...(next.fields === undefined ? {} : { fields: rebasedAll(held.fields, next.fields) }),
|
|
498
|
-
...(next.sections === undefined
|
|
499
|
-
? {}
|
|
500
|
-
: { sections: rebasedAll(held.sections, next.sections) }),
|
|
501
|
-
...(next.preamble === undefined ? {} : { preamble: rebased(held.preamble, next.preamble) }),
|
|
502
|
-
...(next.markdown === undefined ? {} : { markdown: rebased(held.markdown, next.markdown) }),
|
|
503
|
-
},
|
|
504
|
-
};
|
|
505
|
-
}
|
|
506
495
|
export function withdrawnDrafts(drafts, changes) {
|
|
507
496
|
return drafts.flatMap((draft) => {
|
|
508
497
|
const file = draft.parts.file;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"room-drafts.d.ts","sourceRoot":"","sources":["../src/room-drafts.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAK5D,OAAO,EAAW,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAQL,KAAK,SAAS,EAEd,KAAK,cAAc,EACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGxC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,IAAI,OAAO,CAAC,SAAS,SAAS,EAAE,CAAC,CAAC;IACtC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC;IAC5D,KAAK,CACH,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,G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GAAG,SAAS,CAAC,CAMnC;AA0CD,wBAAgB,iBAAiB,CAC/B,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAC1B,WAAW,EAAE,OAAO,EACpB,OAAO,GAAE,SAAS,CAAC,WAAW,CAAC,GAAG,IAAW,GAC5C,OAAO,CAAC,IAAI,CAAC,CAuBf;AAOD,wBAAgB,gBAAgB,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAUvF;AAoDD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,gBAAgB,CAkDnE;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,mBAAmB,CA8BzE;AAED,wBAAgB,eAAe,CAC7B,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAC1B,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAChC,MAAM,IAAI,CAiBZ;AAED,wBAAgB,iBAAiB,CAC/B,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAC1B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAChC,MAAM,IAAI,CASZ"}
|
package/dist/room-drafts.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { plain } from '@agentshouse/mdmodel';
|
|
2
2
|
import { changeSet } from './change-set.js';
|
|
3
3
|
import { collectionOf } from './collection.js';
|
|
4
|
-
import { runtimeError } from './failure.js';
|
|
4
|
+
import { runtimeError, uncaught } from './failure.js';
|
|
5
5
|
import { roomDraftRevision } from './identity.js';
|
|
6
6
|
import { normalize } from './paths.js';
|
|
7
7
|
import { slicing } from './replica.js';
|
|
@@ -100,7 +100,7 @@ async function writtenRoomDraft({ store }, room, path, revision, input, next) {
|
|
|
100
100
|
const local = await store.open();
|
|
101
101
|
const current = await store.draft(room, path);
|
|
102
102
|
if ((current?.revision ?? null) !== revision) {
|
|
103
|
-
return staleWrite(current === undefined ? null : (
|
|
103
|
+
return staleWrite(current === undefined ? null : (await roomDraftsOf(store, [current]))[0]);
|
|
104
104
|
}
|
|
105
105
|
const file = parts.file === undefined
|
|
106
106
|
? undefined
|
|
@@ -118,12 +118,10 @@ async function writtenRoomDraft({ store }, room, path, revision, input, next) {
|
|
|
118
118
|
? []
|
|
119
119
|
: [{ key: file.localId, blob: parts.file.blob }]);
|
|
120
120
|
await store.changed(changeSet(room, { drafts: [path] }));
|
|
121
|
-
return { outcome: 'written', roomDraft: (await roomDraftsOf(store, [record]))[0]
|
|
121
|
+
return { outcome: 'written', roomDraft: (await roomDraftsOf(store, [record]))[0] };
|
|
122
122
|
}
|
|
123
|
-
async function keptPresentation({ store }, app,
|
|
124
|
-
|
|
125
|
-
const stored = next(await local.presentation(app));
|
|
126
|
-
await local.present({ app, value: stored });
|
|
123
|
+
async function keptPresentation({ store }, app, value) {
|
|
124
|
+
await (await store.open()).present({ app, value });
|
|
127
125
|
await store.changed(changeSet('', { presentation: app }));
|
|
128
126
|
}
|
|
129
127
|
export function roomDraftSurface(runtime) {
|
|
@@ -142,7 +140,7 @@ export function roomDraftSurface(runtime) {
|
|
|
142
140
|
},
|
|
143
141
|
async read(room, path) {
|
|
144
142
|
const record = await store.draft(room, path);
|
|
145
|
-
return record === undefined ? null : (
|
|
143
|
+
return record === undefined ? null : (await roomDraftsOf(store, [record]))[0];
|
|
146
144
|
},
|
|
147
145
|
write(room, path, revision, input, next = roomDraftRevision()) {
|
|
148
146
|
if (typeof next !== 'string' || next === '')
|
|
@@ -161,7 +159,7 @@ export function roomDraftSurface(runtime) {
|
|
|
161
159
|
const local = await store.open();
|
|
162
160
|
const current = await store.draft(room, path);
|
|
163
161
|
if (current === undefined || current.revision !== revision) {
|
|
164
|
-
return staleWrite(current === undefined ? null : (
|
|
162
|
+
return staleWrite(current === undefined ? null : (await roomDraftsOf(store, [current]))[0]);
|
|
165
163
|
}
|
|
166
164
|
await local.discardRoomDraft(room, path);
|
|
167
165
|
await store.changed(changeSet(room, { drafts: [path] }));
|
|
@@ -177,13 +175,16 @@ export function presentationSurface(runtime) {
|
|
|
177
175
|
return store.exclusive(() => presentationOf(store, app));
|
|
178
176
|
},
|
|
179
177
|
write(app, value) {
|
|
180
|
-
return store.exclusive(() => keptPresentation(runtime, app,
|
|
178
|
+
return store.exclusive(() => keptPresentation(runtime, app, structuredClone(value)));
|
|
181
179
|
},
|
|
182
180
|
edit(app, members) {
|
|
183
|
-
return store.gathered(`presentation\u0000${app}`, structuredClone(members), (earlier, later) => ({ ...earlier, ...later }), (edited) =>
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
181
|
+
return store.gathered(`presentation\u0000${app}`, structuredClone(members), (earlier, later) => ({ ...earlier, ...later }), async (edited) => {
|
|
182
|
+
const kept = await (await store.open()).presentation(app);
|
|
183
|
+
await keptPresentation(runtime, app, Object.fromEntries([
|
|
184
|
+
...Object.entries(plain(kept) ? kept : {}).filter(([member]) => !Object.hasOwn(edited, member)),
|
|
185
|
+
...Object.entries(edited).filter(([, value]) => value !== null),
|
|
186
|
+
]));
|
|
187
|
+
});
|
|
187
188
|
},
|
|
188
189
|
};
|
|
189
190
|
}
|
|
@@ -200,7 +201,7 @@ export function watchRoomDrafts({ store, socket }, deliver) {
|
|
|
200
201
|
const value = await snapshotRoomDrafts(store);
|
|
201
202
|
if (!unwatched())
|
|
202
203
|
watcher.answer(value);
|
|
203
|
-
}),
|
|
204
|
+
}), uncaught);
|
|
204
205
|
return watcher.stop;
|
|
205
206
|
}
|
|
206
207
|
export function watchPresentation({ store, socket }, app, deliver) {
|
|
@@ -211,6 +212,6 @@ export function watchPresentation({ store, socket }, app, deliver) {
|
|
|
211
212
|
if (!socket.closed() && watcher.held())
|
|
212
213
|
watcher.answer(value);
|
|
213
214
|
})
|
|
214
|
-
.catch(
|
|
215
|
+
.catch(uncaught);
|
|
215
216
|
return watcher.stop;
|
|
216
217
|
}
|
package/dist/rows.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../src/rows.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8C,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAClG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,
|
|
1
|
+
{"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../src/rows.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8C,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAClG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAA4B,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE7E,KAAK,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AAEjC,KAAK,QAAQ,GAAG;IACd,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG;IACjB,QAAQ,CAAC,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@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { byCodePoint, documentFacts, indexed, parse } from '@agentshouse/mdmodel';
|
|
2
|
-
import { governing } from './collection.js';
|
|
3
|
-
import { definitionOf } from './model.js';
|
|
2
|
+
import { definitionsAt, governing } from './collection.js';
|
|
4
3
|
function keyOf(...parts) {
|
|
5
4
|
return `${parts.join('\u0000')}\u0000`;
|
|
6
5
|
}
|
|
@@ -29,7 +28,7 @@ function fieldsText(fields) {
|
|
|
29
28
|
}
|
|
30
29
|
export function writtenFacts(path, content, composition) {
|
|
31
30
|
const model = governing(composition, path);
|
|
32
|
-
const facts = documentFacts(path, parse(content, path), {
|
|
31
|
+
const facts = documentFacts(path, parse(content, path, definitionsAt(composition, path)), {
|
|
33
32
|
types: model.status === 'unavailable' ? {} : model.types,
|
|
34
33
|
});
|
|
35
34
|
return facts === null
|
|
@@ -72,7 +71,7 @@ export function derived(path, held, composition) {
|
|
|
72
71
|
}));
|
|
73
72
|
if (held.type === null || held.fields === null)
|
|
74
73
|
return { values: [], links: stored };
|
|
75
|
-
const definition =
|
|
74
|
+
const definition = definitionsAt(composition, path)(held.type);
|
|
76
75
|
const { values, links: fields } = indexed(path, held.fields, definition);
|
|
77
76
|
return { values, links: [...fields, ...stored] };
|
|
78
77
|
}
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,42 +1,34 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ChangeSet } from './change-set.js';
|
|
3
|
-
import type { ChangeBatch } from './change.js';
|
|
1
|
+
import type { RoomDeclaration, TypedPath } from './adapter.js';
|
|
4
2
|
import type { RuntimeShell } from './durability.js';
|
|
5
|
-
import type {
|
|
3
|
+
import type { LiveConversations } from './conversation-live.js';
|
|
4
|
+
import type { WriteRule } from './declaration.js';
|
|
6
5
|
import type { FiguresRead } from './figures.js';
|
|
7
|
-
import type { Withheld } from './install.js';
|
|
8
6
|
import type { LiveQueries } from './live.js';
|
|
9
|
-
import type { Log } from './log.js';
|
|
10
7
|
import type { ModelState } from './model.js';
|
|
8
|
+
import type { Presence } from './presence.js';
|
|
11
9
|
import type { ReadAnswers } from './reads.js';
|
|
12
10
|
import type { Recovery } from './recovery.js';
|
|
13
|
-
import type {
|
|
14
|
-
import type { RuntimeSocket
|
|
15
|
-
import type {
|
|
16
|
-
import type { Settling } from './saves.js';
|
|
17
|
-
import type { HeldCover, RuntimeStore, Store, Work } from './store.js';
|
|
11
|
+
import type { Retries } from './retried.js';
|
|
12
|
+
import type { RuntimeSocket } from './socket.js';
|
|
13
|
+
import type { HeldCover, Store } from './store.js';
|
|
18
14
|
import type { schemaTypes } from './attached-model.js';
|
|
19
15
|
export type Runtime = {
|
|
20
16
|
readonly store: Store;
|
|
21
17
|
readonly socket: RuntimeSocket;
|
|
22
|
-
readonly
|
|
18
|
+
readonly presence: Presence;
|
|
23
19
|
readonly recovery: Recovery;
|
|
20
|
+
readonly retries: Retries;
|
|
24
21
|
readonly shell: RuntimeShell;
|
|
25
22
|
readonly localSaves: boolean;
|
|
26
23
|
readonly roomTypes: Parameters<typeof schemaTypes>[1];
|
|
27
24
|
readonly builtIn: ModelState;
|
|
28
25
|
readonly typedPaths: readonly TypedPath[];
|
|
26
|
+
readonly writeRule: (declaration: RoomDeclaration) => WriteRule;
|
|
29
27
|
readonly usableWhenHeld: readonly string[];
|
|
30
28
|
readonly build: string;
|
|
31
|
-
readonly conversations:
|
|
29
|
+
readonly conversations: LiveConversations;
|
|
32
30
|
readonly liveQueries: LiveQueries<HeldCover>;
|
|
33
31
|
readonly figures: FiguresRead;
|
|
34
32
|
readonly lastAnswers: ReadAnswers;
|
|
35
|
-
settle(local: RuntimeStore, locator: string, work: Work, record: ReplicaRecord, queue: readonly ChangeBatch[], settling?: Settling): Promise<ChangeSet>;
|
|
36
|
-
scoped(result: ScopedRefusal, room: RoomDeclaration, local: RuntimeStore): Promise<void>;
|
|
37
|
-
submitLater(locator: string): void;
|
|
38
|
-
unpair(local: RuntimeStore): Promise<void>;
|
|
39
|
-
advanced(room: DiscoveredRoom, local: RuntimeStore, authorized: Authorization): Promise<Withheld | null>;
|
|
40
|
-
withhold(withheld: Withheld, room: DiscoveredRoom, local: RuntimeStore, progress: CycleProgress): Promise<void>;
|
|
41
33
|
};
|
|
42
34
|
//# sourceMappingURL=runtime.d.ts.map
|
package/dist/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,MAAM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