@agentshouse/mdruntime 0.1.0-c97456d63baba → 0.1.0-c9b1e59e5baeb
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 +221 -221
- package/README.md +8 -8
- package/dist/adapter.d.ts +35 -6
- package/dist/adapter.d.ts.map +1 -1
- package/dist/bootstrap.d.ts +2 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +5 -1
- package/dist/change-set.d.ts +5 -2
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +8 -2
- package/dist/chat/earlier.d.ts +10 -0
- package/dist/chat/earlier.d.ts.map +1 -0
- package/dist/chat/earlier.js +54 -0
- package/dist/chat/kit.js +1 -1
- package/dist/chat/list.d.ts +2 -1
- package/dist/chat/list.d.ts.map +1 -1
- package/dist/chat/list.js +40 -4
- package/dist/chat/markdown.d.ts +1 -0
- package/dist/chat/markdown.d.ts.map +1 -1
- package/dist/chat/markdown.js +78 -20
- package/dist/chat/message.d.ts.map +1 -1
- package/dist/chat/message.js +9 -2
- package/dist/chat/messages.d.ts.map +1 -1
- package/dist/chat/messages.js +36 -16
- package/dist/chat/overlay.d.ts +1 -0
- package/dist/chat/overlay.d.ts.map +1 -1
- package/dist/chat/overlay.js +10 -0
- package/dist/chat/pieces.d.ts +62 -0
- package/dist/chat/pieces.d.ts.map +1 -0
- package/dist/chat/pieces.js +1110 -0
- package/dist/chat/provider.d.ts +1 -0
- package/dist/chat/provider.d.ts.map +1 -1
- package/dist/chat/provider.js +22 -14
- package/dist/chat/question.d.ts +1 -1
- package/dist/chat/question.d.ts.map +1 -1
- package/dist/chat/question.js +7 -18
- package/dist/chat/ready.d.ts +1 -1
- package/dist/chat/ready.d.ts.map +1 -1
- package/dist/chat/ready.js +1 -1
- package/dist/chat/steady.d.ts +3 -0
- package/dist/chat/steady.d.ts.map +1 -0
- package/dist/chat/steady.js +26 -0
- package/dist/chat/style.js +1 -1
- package/dist/chat.d.ts +2 -2
- package/dist/chat.d.ts.map +1 -1
- package/dist/chat.js +2 -2
- package/dist/client.d.ts +6 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +16 -5
- package/dist/collection.d.ts +4 -3
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +128 -63
- package/dist/connection.d.ts +13 -5
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +506 -228
- package/dist/conversation.d.ts +11 -0
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +195 -41
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +3 -2
- package/dist/host.d.ts +9 -7
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +58 -9
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/memory.d.ts +7 -3
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +24 -11
- package/dist/observation.d.ts +2 -0
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +9 -3
- package/dist/outcome.d.ts +8 -2
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +3 -0
- package/dist/overlay.d.ts +5 -4
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +197 -132
- package/dist/query.d.ts +27 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +36 -7
- package/dist/reach.d.ts +1 -2
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +17 -4
- package/dist/react.d.ts +3 -3
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +7 -17
- package/dist/read-side.d.ts +3 -1
- package/dist/read-side.d.ts.map +1 -1
- package/dist/read-side.js +256 -69
- package/dist/reads.d.ts +11 -0
- package/dist/reads.d.ts.map +1 -0
- package/dist/reads.js +98 -0
- package/dist/refresh.d.ts +4 -4
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +39 -14
- package/dist/replica.d.ts +11 -5
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +79 -41
- package/dist/room-draft.d.ts +12 -0
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +11 -12
- package/dist/rows.d.ts +3 -1
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +8 -1
- package/dist/save.d.ts +4 -2
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +195 -111
- package/dist/search.d.ts +27 -6
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +89 -7
- package/dist/seed.d.ts +16 -0
- package/dist/seed.d.ts.map +1 -0
- package/dist/seed.js +75 -0
- package/dist/shared.d.ts +4 -0
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +63 -33
- package/dist/store.d.ts +20 -4
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +404 -317
- package/dist/turn.d.ts +5 -3
- package/dist/turn.d.ts.map +1 -1
- package/dist/turn.js +26 -7
- package/dist/windows.d.ts +26 -0
- package/dist/windows.d.ts.map +1 -0
- package/dist/windows.js +93 -0
- package/dist/wire.d.ts +16 -0
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +4 -0
- package/package.json +2 -2
- package/dist/acquisition.d.ts +0 -14
- package/dist/acquisition.d.ts.map +0 -1
- package/dist/acquisition.js +0 -24
package/dist/reads.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
function declaredAs(declaration) {
|
|
2
|
+
if (declaration === null || typeof declaration !== 'object')
|
|
3
|
+
return declaration;
|
|
4
|
+
const { roomVersion: _version, ...declared } = declaration;
|
|
5
|
+
return declared;
|
|
6
|
+
}
|
|
7
|
+
function sameHeld(one, other) {
|
|
8
|
+
return one?.documents === other?.documents && one?.revisions === other?.revisions;
|
|
9
|
+
}
|
|
10
|
+
function failed(answer) {
|
|
11
|
+
return answer?.kind === 'transport-uncertainty';
|
|
12
|
+
}
|
|
13
|
+
function continues(answer) {
|
|
14
|
+
const page = answer;
|
|
15
|
+
return page?.kind === 'net-advancement' && page.pageToken !== undefined;
|
|
16
|
+
}
|
|
17
|
+
export function doorReads(adapter, declaration, generation) {
|
|
18
|
+
const reading = new Map();
|
|
19
|
+
const taken = new Map();
|
|
20
|
+
let carrying = false;
|
|
21
|
+
function joined(read, authorization, request, ask) {
|
|
22
|
+
const key = `${read} ${request.locator} ${request.pageToken ?? ''}`;
|
|
23
|
+
const { held, ...named } = request;
|
|
24
|
+
const asked = JSON.stringify([declaredAs(declaration(request.locator)), named]);
|
|
25
|
+
const asking = generation();
|
|
26
|
+
const current = reading.get(key);
|
|
27
|
+
if (current !== undefined &&
|
|
28
|
+
current.authorization === authorization &&
|
|
29
|
+
current.asked === asked &&
|
|
30
|
+
sameHeld(current.held, held) &&
|
|
31
|
+
(!current.settled || current.holder < asking)) {
|
|
32
|
+
if (current.settled && !current.continued)
|
|
33
|
+
reading.delete(key);
|
|
34
|
+
else
|
|
35
|
+
current.holder = Math.max(current.holder, asking);
|
|
36
|
+
if (current.from === asking)
|
|
37
|
+
return current.answer;
|
|
38
|
+
const again = () => joined(read, authorization, request, ask);
|
|
39
|
+
return current.answer.then((answer) => {
|
|
40
|
+
if (failed(answer))
|
|
41
|
+
return again();
|
|
42
|
+
taken.set(request.locator, (taken.get(request.locator) ?? 0) + 1);
|
|
43
|
+
return answer;
|
|
44
|
+
}, again);
|
|
45
|
+
}
|
|
46
|
+
const answer = ask();
|
|
47
|
+
const sent = {
|
|
48
|
+
locator: request.locator,
|
|
49
|
+
authorization,
|
|
50
|
+
asked,
|
|
51
|
+
held,
|
|
52
|
+
answer,
|
|
53
|
+
from: asking,
|
|
54
|
+
holder: asking,
|
|
55
|
+
settled: false,
|
|
56
|
+
continued: false,
|
|
57
|
+
};
|
|
58
|
+
reading.set(key, sent);
|
|
59
|
+
const settled = (result, kept) => {
|
|
60
|
+
sent.settled = true;
|
|
61
|
+
sent.continued = kept && read === 'refresh' && continues(result);
|
|
62
|
+
if (reading.get(key) !== sent)
|
|
63
|
+
return;
|
|
64
|
+
const live = sent.holder === generation();
|
|
65
|
+
if (!kept || (live ? !sent.continued : !carrying))
|
|
66
|
+
reading.delete(key);
|
|
67
|
+
};
|
|
68
|
+
answer.then((result) => settled(result, !failed(result)), () => settled(null, false));
|
|
69
|
+
return answer;
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
bootstrap: (authorization, request) => joined('bootstrap', authorization, request, () => adapter.bootstrap(authorization, request)),
|
|
73
|
+
refresh: (authorization, request) => joined('refresh', authorization, request, () => adapter.refresh(authorization, request)),
|
|
74
|
+
reached: (locator, roomVersion, target) => adapter.reached(locator, roomVersion, target),
|
|
75
|
+
carried: (locator) => taken.get(locator) ?? 0,
|
|
76
|
+
finished(locator, turn) {
|
|
77
|
+
for (const [key, held] of reading) {
|
|
78
|
+
if (held.locator !== locator || !held.settled || held.holder !== turn)
|
|
79
|
+
continue;
|
|
80
|
+
if (turn === generation() || !carrying)
|
|
81
|
+
reading.delete(key);
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
opened() {
|
|
85
|
+
carrying = true;
|
|
86
|
+
},
|
|
87
|
+
applied() {
|
|
88
|
+
carrying = false;
|
|
89
|
+
for (const [key, held] of reading) {
|
|
90
|
+
if (held.settled && held.holder !== generation())
|
|
91
|
+
reading.delete(key);
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
lost() {
|
|
95
|
+
reading.clear();
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
}
|
package/dist/refresh.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Remodel } from './bootstrap.js';
|
|
1
|
+
import type { AdapterFailure, Authorization, RetryableRefusal } from './adapter.js';
|
|
2
|
+
import type { Reads, Remodel } from './bootstrap.js';
|
|
3
3
|
import { type ConfirmedLayer } from './replica.js';
|
|
4
4
|
import type { ReplicaRecord } from './store.js';
|
|
5
5
|
import { type Refused, type Unconfirmed } from './transfer.js';
|
|
@@ -19,6 +19,6 @@ export type RefreshOutcome = {
|
|
|
19
19
|
} | {
|
|
20
20
|
kind: 'beyond-horizon';
|
|
21
21
|
} | RetryableRefusal | Unconfirmed | Refused | AdapterFailure;
|
|
22
|
-
export declare function advancement(adapter:
|
|
23
|
-
export declare function refreshRoom(adapter:
|
|
22
|
+
export declare function advancement(adapter: Reads, authorization: Authorization, held: ReplicaRecord, remodel: Remodel, continuing: () => boolean): Promise<Advancement>;
|
|
23
|
+
export declare function refreshRoom(adapter: Reads, authorization: Authorization, confirmed: ConfirmedLayer, remodel: Remodel, continuing: () => boolean): Promise<RefreshOutcome>;
|
|
24
24
|
//# sourceMappingURL=refresh.d.ts.map
|
package/dist/refresh.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../src/refresh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../src/refresh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAe,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEjG,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAc,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAE/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,EAAe,KAAK,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5E,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,GACzB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,aAAa,CAAA;CAAE,GAC3C;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAC1B,gBAAgB,GAChB,WAAW,GACX,cAAc,CAAC;AAEnB,MAAM,MAAM,cAAc,GACtB;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,GACzB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,SAAS,EAAE,cAAc,CAAA;CAAE,GAC/C;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAC1B,gBAAgB,GAChB,WAAW,GACX,OAAO,GACP,cAAc,CAAC;AAEnB,wBAAsB,WAAW,CAC/B,OAAO,EAAE,KAAK,EACd,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,OAAO,GACxB,OAAO,CAAC,WAAW,CAAC,CAgGtB;AAED,wBAAsB,WAAW,CAC/B,OAAO,EAAE,KAAK,EACd,aAAa,EAAE,aAAa,EAC5B,SAAS,EAAE,cAAc,EACzB,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,OAAO,GACxB,OAAO,CAAC,cAAc,CAAC,CAKzB"}
|
package/dist/refresh.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { acceptedBinaries } from './overlay.js';
|
|
2
2
|
import { readStaged } from './replica.js';
|
|
3
|
-
import { drafted,
|
|
3
|
+
import { drafted, settling } from './shared.js';
|
|
4
|
+
import { ROW_WEIGHT, stepped } from './turn.js';
|
|
4
5
|
import { unconfirmed } from './transfer.js';
|
|
5
6
|
export async function advancement(adapter, authorization, held, remodel, continuing) {
|
|
6
7
|
const locator = held.locator;
|
|
@@ -19,33 +20,56 @@ export async function advancement(adapter, authorization, held, remodel, continu
|
|
|
19
20
|
});
|
|
20
21
|
const documents = drafted(held.documents);
|
|
21
22
|
const revisions = drafted(held.revisions);
|
|
23
|
+
const fileIds = drafted(held.fileIds);
|
|
22
24
|
const changes = drafted(held.changes);
|
|
23
25
|
const written = drafted(held.written);
|
|
24
26
|
const binaries = drafted(held.binaries);
|
|
25
|
-
const stage = (page)
|
|
27
|
+
const stage = function* (page) {
|
|
26
28
|
for (const path of Object.keys(page.documents)) {
|
|
27
29
|
delete binaries[path];
|
|
30
|
+
delete fileIds[path];
|
|
28
31
|
delete changes[path];
|
|
29
32
|
written[path] = roomVersion;
|
|
33
|
+
yield ROW_WEIGHT;
|
|
30
34
|
}
|
|
31
35
|
for (const path of Object.keys(page.binaryFiles)) {
|
|
32
36
|
delete documents[path];
|
|
37
|
+
delete fileIds[path];
|
|
33
38
|
delete changes[path];
|
|
34
39
|
delete written[path];
|
|
40
|
+
yield ROW_WEIGHT;
|
|
41
|
+
}
|
|
42
|
+
for (const [path, content] of Object.entries(page.documents)) {
|
|
43
|
+
documents[path] = content;
|
|
44
|
+
yield ROW_WEIGHT + content.length;
|
|
45
|
+
}
|
|
46
|
+
for (const [path, binary] of Object.entries(acceptedBinaries(page.binaryFiles))) {
|
|
47
|
+
binaries[path] = binary;
|
|
48
|
+
yield ROW_WEIGHT;
|
|
49
|
+
}
|
|
50
|
+
for (const [path, revision] of Object.entries(page.revisions)) {
|
|
51
|
+
revisions[path] = revision;
|
|
52
|
+
yield ROW_WEIGHT;
|
|
53
|
+
}
|
|
54
|
+
for (const [path, fileId] of Object.entries(page.fileIds ?? {})) {
|
|
55
|
+
fileIds[path] = fileId;
|
|
56
|
+
yield ROW_WEIGHT;
|
|
57
|
+
}
|
|
58
|
+
for (const [path, change] of Object.entries(page.changes)) {
|
|
59
|
+
changes[path] = change;
|
|
60
|
+
yield ROW_WEIGHT;
|
|
35
61
|
}
|
|
36
|
-
Object.assign(documents, page.documents);
|
|
37
|
-
Object.assign(binaries, acceptedBinaries(page.binaryFiles));
|
|
38
|
-
Object.assign(revisions, page.revisions);
|
|
39
|
-
Object.assign(changes, page.changes);
|
|
40
62
|
for (const path of page.removals) {
|
|
41
63
|
delete documents[path];
|
|
42
64
|
delete revisions[path];
|
|
65
|
+
delete fileIds[path];
|
|
43
66
|
delete changes[path];
|
|
44
67
|
delete written[path];
|
|
45
68
|
delete binaries[path];
|
|
69
|
+
yield ROW_WEIGHT;
|
|
46
70
|
}
|
|
47
71
|
};
|
|
48
|
-
stage(first);
|
|
72
|
+
await stepped(stage(first));
|
|
49
73
|
let pageToken = first.pageToken;
|
|
50
74
|
while (pageToken !== undefined) {
|
|
51
75
|
if (!continuing())
|
|
@@ -62,7 +86,7 @@ export async function advancement(adapter, authorization, held, remodel, continu
|
|
|
62
86
|
return page;
|
|
63
87
|
if (page.roomVersion !== roomVersion)
|
|
64
88
|
return unconfirmed;
|
|
65
|
-
stage(page);
|
|
89
|
+
await stepped(stage(page));
|
|
66
90
|
pageToken = page.pageToken;
|
|
67
91
|
}
|
|
68
92
|
return {
|
|
@@ -72,11 +96,12 @@ export async function advancement(adapter, authorization, held, remodel, continu
|
|
|
72
96
|
model: models.collection,
|
|
73
97
|
selectionModel: models.selection,
|
|
74
98
|
roomVersion,
|
|
75
|
-
documents:
|
|
76
|
-
binaries:
|
|
77
|
-
revisions:
|
|
78
|
-
|
|
79
|
-
|
|
99
|
+
documents: await stepped(settling(documents)),
|
|
100
|
+
binaries: await stepped(settling(binaries)),
|
|
101
|
+
revisions: await stepped(settling(revisions)),
|
|
102
|
+
fileIds: await stepped(settling(fileIds)),
|
|
103
|
+
changes: await stepped(settling(changes)),
|
|
104
|
+
written: await stepped(settling(written)),
|
|
80
105
|
},
|
|
81
106
|
};
|
|
82
107
|
}
|
|
@@ -84,6 +109,6 @@ export async function refreshRoom(adapter, authorization, confirmed, remodel, co
|
|
|
84
109
|
const advanced = await advancement(adapter, authorization, confirmed.record, remodel, continuing);
|
|
85
110
|
if (advanced.kind !== 'advanced')
|
|
86
111
|
return advanced;
|
|
87
|
-
const staged = readStaged(advanced.record, confirmed);
|
|
112
|
+
const staged = await readStaged(advanced.record, confirmed);
|
|
88
113
|
return staged.kind === 'staged' ? { kind: 'advanced', confirmed: staged.confirmed } : staged;
|
|
89
114
|
}
|
package/dist/replica.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { type Layer } from './overlay.js';
|
|
|
4
4
|
import type { MutationResult } from './adapter.js';
|
|
5
5
|
import type { ReplicaRecord } from './store.js';
|
|
6
6
|
import type { Refused } from './transfer.js';
|
|
7
|
+
import { type Later } from './turn.js';
|
|
7
8
|
export type ConfirmedLayer = {
|
|
8
9
|
record: ReplicaRecord;
|
|
9
10
|
collection: Collection;
|
|
@@ -31,16 +32,21 @@ type ReplayStep = {
|
|
|
31
32
|
export declare function compositionOf(record: ReplicaRecord): Composition;
|
|
32
33
|
export declare function confirmedOf(record: ReplicaRecord, previous?: ConfirmedLayer): ConfirmedLayer;
|
|
33
34
|
export declare function sameMembership(record: ReplicaRecord, other: ReplicaRecord): boolean;
|
|
34
|
-
export declare function readStaged(staged: ReplicaRecord, previous?: ConfirmedLayer): Staged
|
|
35
|
-
export declare function readReclassified(record: ReplicaRecord, previous: ConfirmedLayer): Staged | {
|
|
35
|
+
export declare function readStaged(staged: ReplicaRecord, previous?: ConfirmedLayer): Later<Staged>;
|
|
36
|
+
export declare function readReclassified(record: ReplicaRecord, previous: ConfirmedLayer): Later<Staged | {
|
|
36
37
|
kind: 'deferred';
|
|
37
|
-
}
|
|
38
|
+
}>;
|
|
38
39
|
type Accepted = Extract<MutationResult, {
|
|
39
40
|
kind: 'accepted';
|
|
40
41
|
}>;
|
|
41
|
-
export declare function applyReturned(confirmed: ConfirmedLayer, submitted: ChangeBatch, accepted: Accepted, roomVersion: string, writtenAt: string): Staged
|
|
42
|
+
export declare function applyReturned(confirmed: ConfirmedLayer, submitted: ChangeBatch, accepted: Accepted, roomVersion: string, writtenAt: string): Later<Staged>;
|
|
43
|
+
export declare function replicating(confirmed: ConfirmedLayer, queue: readonly ChangeBatch[], previous?: Replica): Generator<number, Replica, void>;
|
|
42
44
|
export declare function replicaOf(confirmed: ConfirmedLayer, queue: readonly ChangeBatch[], previous?: Replica): Replica;
|
|
43
45
|
export declare function landed(batch: ChangeBatch, confirmed: ConfirmedLayer, current?: Readonly<Record<string, string>>): boolean;
|
|
44
|
-
export
|
|
46
|
+
export type Standing = {
|
|
47
|
+
readonly withdrawn: readonly ChangeBatch[];
|
|
48
|
+
readonly kept: readonly ChangeBatch[];
|
|
49
|
+
};
|
|
50
|
+
export declare function standing(confirmed: ConfirmedLayer, queue: readonly ChangeBatch[], withdrawable: (batch: ChangeBatch) => boolean, local: boolean): Generator<number, Standing, void>;
|
|
45
51
|
export {};
|
|
46
52
|
//# sourceMappingURL=replica.d.ts.map
|
package/dist/replica.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replica.d.ts","sourceRoot":"","sources":["../src/replica.ts"],"names":[],"mappings":"AACA,OAAO,EAAmC,KAAK,WAAW,EAAqB,MAAM,aAAa,CAAC;AACnG,OAAO,EAKL,KAAK,UAAU,EACf,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAML,KAAK,KAAK,EACX,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"replica.d.ts","sourceRoot":"","sources":["../src/replica.ts"],"names":[],"mappings":"AACA,OAAO,EAAmC,KAAK,WAAW,EAAqB,MAAM,aAAa,CAAC;AACnG,OAAO,EAKL,KAAK,UAAU,EACf,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAML,KAAK,KAAK,EACX,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAqB,KAAK,KAAK,EAAE,MAAM,WAAW,CAAC;AAE1D,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,aAAa,CAAC;IACtB,UAAU,EAAE,UAAU,CAAC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C3B,SAAS,EAAE,cAAc,EACzB,SAAS,EAAE,WAAW,EACtB,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,GAChB,KAAK,CAAC,MAAM,CAAC,CAoCf;AAgDD,wBAAiB,WAAW,CAC1B,SAAS,EAAE,cAAc,EACzB,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,QAAQ,CAAC,EAAE,OAAO,GACjB,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CA+BlC;AAED,wBAAgB,SAAS,CACvB,SAAS,EAAE,cAAc,EACzB,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,QAAQ,CAAC,EAAE,OAAO,GACjB,OAAO,CAET;AA0ED,wBAAgB,MAAM,CACpB,KAAK,EAAE,WAAW,EAClB,SAAS,EAAE,cAAc,EACzB,OAAO,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM,GAC7C,OAAO,CAoBT;AAgBD,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,SAAS,EAAE,SAAS,WAAW,EAAE,CAAC;IAC3C,QAAQ,CAAC,IAAI,EAAE,SAAS,WAAW,EAAE,CAAC;CACvC,CAAC;AAEF,wBAAiB,QAAQ,CACvB,SAAS,EAAE,cAAc,EACzB,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,YAAY,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,EAC7C,KAAK,EAAE,OAAO,GACb,SAAS,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,CA6BnC"}
|
package/dist/replica.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { equalValue, parse } from '@agentshouse/mdmodel';
|
|
2
2
|
import { immutable, landing } from './change.js';
|
|
3
|
-
import { changedCleanly,
|
|
4
|
-
import { acceptedBinaries,
|
|
3
|
+
import { changedCleanly, collecting, unreadable, validateCollection, } from './collection.js';
|
|
4
|
+
import { acceptedBinaries, overlayChanged, overlaying, sameText, } from './overlay.js';
|
|
5
5
|
import { providerRewritten } from './save.js';
|
|
6
|
-
import { drafted, patched, settled,
|
|
6
|
+
import { drafted, patched, settled, sharing } from './shared.js';
|
|
7
|
+
import { finished, stepped } from './turn.js';
|
|
7
8
|
export function compositionOf(record) {
|
|
8
9
|
return {
|
|
9
10
|
model: record.model,
|
|
@@ -12,71 +13,82 @@ export function compositionOf(record) {
|
|
|
12
13
|
: { roots: record.typedSelection.roots, model: record.selectionModel },
|
|
13
14
|
};
|
|
14
15
|
}
|
|
15
|
-
function
|
|
16
|
-
const documents =
|
|
17
|
-
const binaries =
|
|
18
|
-
const revisions =
|
|
19
|
-
const
|
|
20
|
-
const
|
|
16
|
+
function* holding(record) {
|
|
17
|
+
const documents = yield* sharing(record.documents);
|
|
18
|
+
const binaries = yield* sharing(record.binaries);
|
|
19
|
+
const revisions = yield* sharing(record.revisions);
|
|
20
|
+
const fileIds = yield* sharing(record.fileIds);
|
|
21
|
+
const changes = yield* sharing(record.changes);
|
|
22
|
+
const written = yield* sharing(record.written);
|
|
21
23
|
return documents === record.documents &&
|
|
22
24
|
binaries === record.binaries &&
|
|
23
25
|
revisions === record.revisions &&
|
|
26
|
+
fileIds === record.fileIds &&
|
|
24
27
|
changes === record.changes &&
|
|
25
28
|
written === record.written
|
|
26
29
|
? record
|
|
27
|
-
: { ...record, documents, binaries, revisions, changes, written };
|
|
30
|
+
: { ...record, documents, binaries, revisions, fileIds, changes, written };
|
|
28
31
|
}
|
|
29
32
|
export function confirmedOf(record, previous) {
|
|
30
|
-
|
|
33
|
+
return finished(confirming(record, previous));
|
|
34
|
+
}
|
|
35
|
+
function* confirming(record, previous) {
|
|
36
|
+
const kept = yield* holding(record);
|
|
31
37
|
return {
|
|
32
38
|
record: kept,
|
|
33
|
-
collection:
|
|
39
|
+
collection: yield* collecting(kept.documents, compositionOf(kept), previous?.collection),
|
|
34
40
|
};
|
|
35
41
|
}
|
|
36
42
|
export function sameMembership(record, other) {
|
|
37
43
|
return (JSON.stringify(record.typedSelection?.roots ?? null) ===
|
|
38
44
|
JSON.stringify(other.typedSelection?.roots ?? null));
|
|
39
45
|
}
|
|
40
|
-
function cleanly(record, previous) {
|
|
46
|
+
function* cleanly(record, previous) {
|
|
41
47
|
if (previous === undefined)
|
|
42
48
|
return false;
|
|
43
49
|
const before = previous.record;
|
|
44
|
-
return changedCleanly({ text: record.documents, binaries: record.binaries }, { text: before.documents, binaries: before.binaries, composition: compositionOf(before) }, compositionOf(record));
|
|
50
|
+
return yield* changedCleanly({ text: record.documents, binaries: record.binaries }, { text: before.documents, binaries: before.binaries, composition: compositionOf(before) }, compositionOf(record));
|
|
45
51
|
}
|
|
46
|
-
|
|
47
|
-
const record =
|
|
48
|
-
const textChanged = previous === undefined || !
|
|
52
|
+
function* staging(staged, previous) {
|
|
53
|
+
const record = yield* holding(staged);
|
|
54
|
+
const textChanged = previous === undefined || !(yield* sameText(record, previous.record));
|
|
49
55
|
const modeled = record.model.status !== 'unavailable' || record.selectionModel.status !== 'unavailable';
|
|
50
56
|
if (modeled &&
|
|
51
57
|
(textChanged ||
|
|
52
58
|
record.model !== previous?.record.model ||
|
|
53
59
|
record.selectionModel !== previous?.record.selectionModel) &&
|
|
54
|
-
!cleanly(record, previous)) {
|
|
55
|
-
const verdict = validateCollection(record.documents, Object.keys(record.binaries), compositionOf(record));
|
|
60
|
+
!(yield* cleanly(record, previous))) {
|
|
61
|
+
const verdict = yield* validateCollection(record.documents, Object.keys(record.binaries), compositionOf(record));
|
|
56
62
|
if (verdict.verdict === 'refuse' && verdict.rule !== 'model-unavailable') {
|
|
57
63
|
return { kind: 'refused', refusal: verdict };
|
|
58
64
|
}
|
|
59
65
|
if (verdict.verdict === 'refuse') {
|
|
60
|
-
const refused = unreadable(record.documents, previous?.record.documents);
|
|
66
|
+
const refused = yield* unreadable(record.documents, previous?.record.documents);
|
|
61
67
|
if (refused !== null)
|
|
62
68
|
return refused;
|
|
63
69
|
}
|
|
64
70
|
}
|
|
65
71
|
else if (textChanged) {
|
|
66
|
-
const refused = unreadable(record.documents, previous?.record.documents);
|
|
72
|
+
const refused = yield* unreadable(record.documents, previous?.record.documents);
|
|
67
73
|
if (refused !== null)
|
|
68
74
|
return refused;
|
|
69
75
|
}
|
|
70
|
-
return { kind: 'staged', confirmed:
|
|
76
|
+
return { kind: 'staged', confirmed: yield* confirming(record, previous) };
|
|
71
77
|
}
|
|
72
|
-
export function
|
|
73
|
-
|
|
78
|
+
export function readStaged(staged, previous) {
|
|
79
|
+
return stepped(staging(staged, previous));
|
|
80
|
+
}
|
|
81
|
+
function* reclassifying(record, previous) {
|
|
82
|
+
const verdict = yield* validateCollection(record.documents, Object.keys(record.binaries), compositionOf(record));
|
|
74
83
|
if (verdict.verdict !== 'refuse')
|
|
75
|
-
return { kind: 'staged', confirmed:
|
|
84
|
+
return { kind: 'staged', confirmed: yield* confirming(record, previous) };
|
|
76
85
|
return verdict.rule === 'model-unavailable'
|
|
77
86
|
? { kind: 'deferred' }
|
|
78
87
|
: { kind: 'refused', refusal: verdict };
|
|
79
88
|
}
|
|
89
|
+
export function readReclassified(record, previous) {
|
|
90
|
+
return stepped(reclassifying(record, previous));
|
|
91
|
+
}
|
|
80
92
|
function returnedBinaries(held, submitted, accepted) {
|
|
81
93
|
const binaries = drafted(held);
|
|
82
94
|
for (const change of submitted.changes) {
|
|
@@ -94,13 +106,17 @@ function returnedBinaries(held, submitted, accepted) {
|
|
|
94
106
|
return settled(binaries);
|
|
95
107
|
}
|
|
96
108
|
export function applyReturned(confirmed, submitted, accepted, roomVersion, writtenAt) {
|
|
97
|
-
const { documents, revisions, changes, removals } = accepted;
|
|
109
|
+
const { documents, revisions, fileIds, changes, removals } = accepted;
|
|
98
110
|
const nextDocuments = drafted(confirmed.record.documents);
|
|
99
111
|
const nextRevisions = drafted(confirmed.record.revisions);
|
|
112
|
+
const nextFileIds = drafted(confirmed.record.fileIds);
|
|
100
113
|
const nextChanges = drafted(confirmed.record.changes);
|
|
101
114
|
const nextWritten = drafted(confirmed.record.written);
|
|
102
115
|
Object.assign(nextDocuments, documents);
|
|
103
116
|
Object.assign(nextRevisions, revisions);
|
|
117
|
+
for (const path of Object.keys({ ...documents, ...revisions }))
|
|
118
|
+
delete nextFileIds[path];
|
|
119
|
+
Object.assign(nextFileIds, fileIds);
|
|
104
120
|
for (const path of Object.keys(documents))
|
|
105
121
|
nextWritten[path] = writtenAt;
|
|
106
122
|
for (const [path, revision] of Object.entries(revisions)) {
|
|
@@ -111,6 +127,7 @@ export function applyReturned(confirmed, submitted, accepted, roomVersion, writt
|
|
|
111
127
|
for (const path of removals) {
|
|
112
128
|
delete nextDocuments[path];
|
|
113
129
|
delete nextRevisions[path];
|
|
130
|
+
delete nextFileIds[path];
|
|
114
131
|
delete nextChanges[path];
|
|
115
132
|
delete nextWritten[path];
|
|
116
133
|
}
|
|
@@ -119,12 +136,13 @@ export function applyReturned(confirmed, submitted, accepted, roomVersion, writt
|
|
|
119
136
|
roomVersion,
|
|
120
137
|
documents: settled(nextDocuments),
|
|
121
138
|
revisions: settled(nextRevisions),
|
|
139
|
+
fileIds: settled(nextFileIds),
|
|
122
140
|
changes: settled(nextChanges),
|
|
123
141
|
written: settled(nextWritten),
|
|
124
142
|
binaries: returnedBinaries(confirmed.record.binaries, submitted, accepted),
|
|
125
143
|
}, confirmed);
|
|
126
144
|
}
|
|
127
|
-
function
|
|
145
|
+
function* predicting(confirmed, batches, previous) {
|
|
128
146
|
const composition = compositionOf(confirmed.record);
|
|
129
147
|
let layer = confirmed.record;
|
|
130
148
|
const replay = [];
|
|
@@ -134,7 +152,7 @@ function predicted(confirmed, batches, previous) {
|
|
|
134
152
|
const old = prior.get(batch.id);
|
|
135
153
|
const hasMove = batch.changes.some((change) => change.kind === 'move');
|
|
136
154
|
const reuseRewrite = old?.collection !== undefined &&
|
|
137
|
-
|
|
155
|
+
(yield* sameText(before, old.before)) &&
|
|
138
156
|
old.collection.composition.model === composition.model &&
|
|
139
157
|
old.collection.composition.selection?.model === composition.selection?.model &&
|
|
140
158
|
JSON.stringify(old.collection.composition.selection?.roots) ===
|
|
@@ -142,17 +160,17 @@ function predicted(confirmed, batches, previous) {
|
|
|
142
160
|
const collection = hasMove
|
|
143
161
|
? reuseRewrite
|
|
144
162
|
? old.collection
|
|
145
|
-
:
|
|
163
|
+
: yield* collecting(before.documents, composition, old?.collection ?? confirmed.collection)
|
|
146
164
|
: undefined;
|
|
147
165
|
const effective = collection === undefined
|
|
148
166
|
? batch
|
|
149
167
|
: reuseRewrite
|
|
150
168
|
? old.effective
|
|
151
|
-
: providerRewritten(batch, { ...before, collection });
|
|
169
|
+
: yield* providerRewritten(batch, { ...before, collection });
|
|
152
170
|
layer =
|
|
153
171
|
old === undefined
|
|
154
|
-
?
|
|
155
|
-
: overlayChanged(before,
|
|
172
|
+
? yield* overlaying(before, [effective])
|
|
173
|
+
: yield* overlayChanged(before, effective, old.before, old.effective, old.after);
|
|
156
174
|
replay.push({
|
|
157
175
|
id: batch.id,
|
|
158
176
|
before,
|
|
@@ -163,7 +181,7 @@ function predicted(confirmed, batches, previous) {
|
|
|
163
181
|
}
|
|
164
182
|
return { layer, replay };
|
|
165
183
|
}
|
|
166
|
-
export function
|
|
184
|
+
export function* replicating(confirmed, queue, previous) {
|
|
167
185
|
const batches = Object.freeze(queue.map(immutable));
|
|
168
186
|
if (batches.length === 0) {
|
|
169
187
|
return {
|
|
@@ -173,23 +191,27 @@ export function replicaOf(confirmed, queue, previous) {
|
|
|
173
191
|
documents: confirmed.record.documents,
|
|
174
192
|
binaries: confirmed.record.binaries,
|
|
175
193
|
revisions: confirmed.record.revisions,
|
|
194
|
+
fileIds: confirmed.record.fileIds,
|
|
176
195
|
changes: confirmed.record.changes,
|
|
177
196
|
collection: confirmed.collection,
|
|
178
197
|
},
|
|
179
198
|
replay: [],
|
|
180
199
|
};
|
|
181
200
|
}
|
|
182
|
-
const { layer, replay } =
|
|
201
|
+
const { layer, replay } = yield* predicting(confirmed, batches, previous);
|
|
183
202
|
return {
|
|
184
203
|
confirmed,
|
|
185
204
|
queue: batches,
|
|
186
205
|
replay,
|
|
187
206
|
visible: {
|
|
188
207
|
...layer,
|
|
189
|
-
collection:
|
|
208
|
+
collection: yield* collecting(layer.documents, compositionOf(confirmed.record), previous?.visible.collection ?? confirmed.collection),
|
|
190
209
|
},
|
|
191
210
|
};
|
|
192
211
|
}
|
|
212
|
+
export function replicaOf(confirmed, queue, previous) {
|
|
213
|
+
return finished(replicating(confirmed, queue, previous));
|
|
214
|
+
}
|
|
193
215
|
function present(layer, path) {
|
|
194
216
|
return layer.documents[path] !== undefined || layer.binaries[path] !== undefined;
|
|
195
217
|
}
|
|
@@ -284,32 +306,48 @@ export function landed(batch, confirmed, current = {}) {
|
|
|
284
306
|
});
|
|
285
307
|
});
|
|
286
308
|
}
|
|
287
|
-
|
|
309
|
+
function founded(batch, layer) {
|
|
310
|
+
let changed = false;
|
|
311
|
+
const preconditions = batch.preconditions.map((precondition) => {
|
|
312
|
+
if (precondition.kind !== 'content')
|
|
313
|
+
return precondition;
|
|
314
|
+
const revision = layer.revisions[precondition.path];
|
|
315
|
+
if (revision === undefined || layer.documents[precondition.path] !== precondition.content) {
|
|
316
|
+
return precondition;
|
|
317
|
+
}
|
|
318
|
+
changed = true;
|
|
319
|
+
return { kind: 'revision', path: precondition.path, revision };
|
|
320
|
+
});
|
|
321
|
+
return changed ? immutable({ ...batch, preconditions }) : batch;
|
|
322
|
+
}
|
|
323
|
+
export function* standing(confirmed, queue, withdrawable, local) {
|
|
288
324
|
if (!queue.some(withdrawable))
|
|
289
|
-
return [];
|
|
325
|
+
return { withdrawn: [], kept: queue };
|
|
290
326
|
const composition = compositionOf(confirmed.record);
|
|
291
327
|
let layer = confirmed.record;
|
|
292
328
|
const withdrawn = [];
|
|
329
|
+
const kept = [];
|
|
293
330
|
for (const batch of queue) {
|
|
294
331
|
if (withdrawable(batch) && !holds(layer, batch.preconditions)) {
|
|
295
332
|
withdrawn.push(batch);
|
|
296
333
|
continue;
|
|
297
334
|
}
|
|
298
335
|
const effective = batch.changes.some((change) => change.kind === 'move')
|
|
299
|
-
? providerRewritten(batch, {
|
|
336
|
+
? yield* providerRewritten(batch, {
|
|
300
337
|
...layer,
|
|
301
|
-
collection:
|
|
338
|
+
collection: yield* collecting(layer.documents, composition),
|
|
302
339
|
})
|
|
303
340
|
: batch;
|
|
304
341
|
let unapplied = false;
|
|
305
|
-
const next =
|
|
342
|
+
const next = yield* overlaying(layer, [effective], () => {
|
|
306
343
|
unapplied = true;
|
|
307
344
|
});
|
|
308
345
|
if (local && unapplied) {
|
|
309
346
|
withdrawn.push(batch);
|
|
310
347
|
continue;
|
|
311
348
|
}
|
|
349
|
+
kept.push(local || !withdrawable(batch) ? batch : founded(batch, layer));
|
|
312
350
|
layer = next;
|
|
313
351
|
}
|
|
314
|
-
return withdrawn;
|
|
352
|
+
return { withdrawn, kept };
|
|
315
353
|
}
|
package/dist/room-draft.d.ts
CHANGED
|
@@ -130,6 +130,18 @@ export declare function underneath(parts: HeldParts, path: string, visible: Visi
|
|
|
130
130
|
export declare function heldFile(blob: Blob, base: string | null): Promise<HeldFile>;
|
|
131
131
|
export declare function binaryBase(visible: VisibleLayer | undefined, path: string): string | null;
|
|
132
132
|
export declare function changedParts(path: string, report: ChangedUnderneath): readonly ChangedPart[];
|
|
133
|
+
export type TextParts = {
|
|
134
|
+
readonly fields?: Readonly<Record<string, {
|
|
135
|
+
readonly value: unknown;
|
|
136
|
+
}>>;
|
|
137
|
+
readonly sections?: Readonly<Record<string, {
|
|
138
|
+
readonly value: string;
|
|
139
|
+
}>>;
|
|
140
|
+
readonly preamble?: {
|
|
141
|
+
readonly value: string;
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
export declare function partsAfter(markdown: string, parts: TextParts): string;
|
|
133
145
|
export declare function returnedInto(existing: HeldParts | undefined, returned: HeldParts): HeldParts;
|
|
134
146
|
export declare function moveTarget(move: {
|
|
135
147
|
readonly to: string;
|
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":"AAQA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIxD,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,MAAM,CAAA;CAAE,CAAC;AAElC,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CACxB,MAAM,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAA;KAAE,CAAC,CACxE,CAAC;IACF,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,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ACzB,SAAS,UAAU,EAAE,CAqBvB"}
|
package/dist/room-draft.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { apply, equalValue, frontmatterValue, parse, serialize } from '@agentshouse/mdmodel';
|
|
1
|
+
import { apply, equalValue, frontmatterValue, parse, serialize, } from '@agentshouse/mdmodel';
|
|
2
2
|
import { runtimeError } from './failure.js';
|
|
3
3
|
import { hexDigest } from './file.js';
|
|
4
4
|
import { binaryLocalId } from './identity.js';
|
|
@@ -279,16 +279,15 @@ function frontmatterOf(fields) {
|
|
|
279
279
|
const opened = parse('---\n---\n');
|
|
280
280
|
if (!opened.ok)
|
|
281
281
|
return malformed();
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
function concatenated(markdown, parts) {
|
|
282
|
+
const next = apply(opened.document, fields.map(([name, part]) => ({
|
|
283
|
+
kind: 'field',
|
|
284
|
+
name,
|
|
285
|
+
value: part.value,
|
|
286
|
+
prior: undefined,
|
|
287
|
+
})));
|
|
288
|
+
return next.outcome === 'applied' ? serialize(next.document) : malformed();
|
|
289
|
+
}
|
|
290
|
+
export function partsAfter(markdown, parts) {
|
|
292
291
|
const fields = named(parts.fields);
|
|
293
292
|
const pieces = [
|
|
294
293
|
...(fields.length === 0 ? [] : [frontmatterOf(fields)]),
|
|
@@ -319,7 +318,7 @@ export function returnedInto(existing, returned) {
|
|
|
319
318
|
delete next.fields;
|
|
320
319
|
delete next.sections;
|
|
321
320
|
delete next.preamble;
|
|
322
|
-
const value =
|
|
321
|
+
const value = partsAfter(whole.value, existing.markdown === undefined ? existing : returned);
|
|
323
322
|
next.markdown = { value, base: whole.base };
|
|
324
323
|
}
|
|
325
324
|
const creation = existing.creation ?? returned.creation;
|