@agentshouse/mdruntime 0.1.0-ca9afacd5aebd → 0.1.0-caee7332d2235
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 +271 -290
- package/README.md +8 -8
- package/dist/adapter.d.ts +52 -10
- 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 +3 -2
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +33 -7
- package/dist/change-set.d.ts +7 -2
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +41 -10
- 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/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.d.ts +2 -1
- package/dist/chat/kit.d.ts.map +1 -1
- package/dist/chat/kit.js +3 -3
- package/dist/chat/list.d.ts +8 -1
- package/dist/chat/list.d.ts.map +1 -1
- package/dist/chat/list.js +48 -8
- package/dist/chat/markdown.d.ts +3 -1
- package/dist/chat/markdown.d.ts.map +1 -1
- package/dist/chat/markdown.js +85 -26
- package/dist/chat/message.d.ts.map +1 -1
- package/dist/chat/message.js +3 -3
- package/dist/chat/messages.d.ts +1 -0
- package/dist/chat/messages.d.ts.map +1 -1
- package/dist/chat/messages.js +35 -15
- 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 -1
- package/dist/chat/provider.d.ts.map +1 -1
- package/dist/chat/provider.js +65 -80
- 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 -0
- package/dist/chat/ready.d.ts.map +1 -1
- package/dist/chat/ready.js +4 -4
- 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 +4 -4
- package/dist/chat.d.ts +1 -1
- package/dist/chat.d.ts.map +1 -1
- package/dist/chat.js +1 -1
- package/dist/client.d.ts +17 -9
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +19 -6
- package/dist/collection.d.ts +20 -5
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +309 -33
- package/dist/connection.d.ts +31 -9
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +1602 -386
- package/dist/conversation.d.ts +20 -7
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +474 -163
- package/dist/durability.d.ts +7 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/entry.d.ts +17 -0
- package/dist/entry.d.ts.map +1 -0
- package/dist/entry.js +157 -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 +15 -3
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +94 -12
- package/dist/identity.d.ts +2 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +6 -0
- package/dist/index.d.ts +10 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/memory.d.ts +8 -2
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +33 -6
- package/dist/model.d.ts +4 -2
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +10 -1
- package/dist/observation.d.ts +7 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +29 -12
- package/dist/outcome.d.ts +12 -2
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +4 -0
- package/dist/overlay.d.ts +5 -3
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +203 -159
- package/dist/query.d.ts +56 -4
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +36 -7
- package/dist/reach.d.ts +6 -3
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +30 -5
- package/dist/react.d.ts +8 -6
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +7 -17
- package/dist/read-side.d.ts +16 -7
- package/dist/read-side.d.ts.map +1 -1
- package/dist/read-side.js +486 -100
- package/dist/readiness.d.ts +53 -0
- package/dist/readiness.d.ts.map +1 -0
- package/dist/readiness.js +33 -0
- package/dist/reads.d.ts +11 -0
- package/dist/reads.d.ts.map +1 -0
- package/dist/reads.js +98 -0
- package/dist/recovery.d.ts +25 -0
- package/dist/recovery.d.ts.map +1 -0
- package/dist/recovery.js +197 -0
- package/dist/refresh.d.ts +4 -4
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +44 -18
- package/dist/replica.d.ts +11 -5
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +111 -56
- package/dist/room-draft.d.ts +13 -1
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +11 -12
- package/dist/rows.d.ts +6 -13
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +10 -13
- package/dist/save.d.ts +10 -4
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +216 -108
- package/dist/search.d.ts +49 -6
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +192 -47
- 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 +15 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +398 -0
- package/dist/status.d.ts +4 -0
- package/dist/status.d.ts.map +1 -1
- package/dist/store.d.ts +61 -12
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +580 -268
- package/dist/turn.d.ts +9 -0
- package/dist/turn.d.ts.map +1 -0
- package/dist/turn.js +64 -0
- 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 +152 -32
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +52 -31
- package/package.json +12 -8
package/dist/replica.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { equalValue, parse } from '@agentshouse/mdmodel';
|
|
2
2
|
import { immutable, landing } from './change.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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, sharing } from './shared.js';
|
|
7
|
+
import { finished, stepped } from './turn.js';
|
|
6
8
|
export function compositionOf(record) {
|
|
7
9
|
return {
|
|
8
10
|
model: record.model,
|
|
@@ -11,50 +13,84 @@ export function compositionOf(record) {
|
|
|
11
13
|
: { roots: record.typedSelection.roots, model: record.selectionModel },
|
|
12
14
|
};
|
|
13
15
|
}
|
|
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);
|
|
23
|
+
return documents === record.documents &&
|
|
24
|
+
binaries === record.binaries &&
|
|
25
|
+
revisions === record.revisions &&
|
|
26
|
+
fileIds === record.fileIds &&
|
|
27
|
+
changes === record.changes &&
|
|
28
|
+
written === record.written
|
|
29
|
+
? record
|
|
30
|
+
: { ...record, documents, binaries, revisions, fileIds, changes, written };
|
|
31
|
+
}
|
|
14
32
|
export function confirmedOf(record, previous) {
|
|
33
|
+
return finished(confirming(record, previous));
|
|
34
|
+
}
|
|
35
|
+
function* confirming(record, previous) {
|
|
36
|
+
const kept = yield* holding(record);
|
|
15
37
|
return {
|
|
16
|
-
record,
|
|
17
|
-
collection:
|
|
38
|
+
record: kept,
|
|
39
|
+
collection: yield* collecting(kept.documents, compositionOf(kept), previous?.collection),
|
|
18
40
|
};
|
|
19
41
|
}
|
|
20
42
|
export function sameMembership(record, other) {
|
|
21
43
|
return (JSON.stringify(record.typedSelection?.roots ?? null) ===
|
|
22
44
|
JSON.stringify(other.typedSelection?.roots ?? null));
|
|
23
45
|
}
|
|
24
|
-
|
|
25
|
-
|
|
46
|
+
function* cleanly(record, previous) {
|
|
47
|
+
if (previous === undefined)
|
|
48
|
+
return false;
|
|
49
|
+
const before = previous.record;
|
|
50
|
+
return yield* changedCleanly({ text: record.documents, binaries: record.binaries }, { text: before.documents, binaries: before.binaries, composition: compositionOf(before) }, compositionOf(record));
|
|
51
|
+
}
|
|
52
|
+
function* staging(staged, previous) {
|
|
53
|
+
const record = yield* holding(staged);
|
|
54
|
+
const textChanged = previous === undefined || !(yield* sameText(record, previous.record));
|
|
26
55
|
const modeled = record.model.status !== 'unavailable' || record.selectionModel.status !== 'unavailable';
|
|
27
56
|
if (modeled &&
|
|
28
57
|
(textChanged ||
|
|
29
58
|
record.model !== previous?.record.model ||
|
|
30
|
-
record.selectionModel !== previous?.record.selectionModel)
|
|
31
|
-
|
|
59
|
+
record.selectionModel !== previous?.record.selectionModel) &&
|
|
60
|
+
!(yield* cleanly(record, previous))) {
|
|
61
|
+
const verdict = yield* validateCollection(record.documents, Object.keys(record.binaries), compositionOf(record));
|
|
32
62
|
if (verdict.verdict === 'refuse' && verdict.rule !== 'model-unavailable') {
|
|
33
63
|
return { kind: 'refused', refusal: verdict };
|
|
34
64
|
}
|
|
35
65
|
if (verdict.verdict === 'refuse') {
|
|
36
|
-
const refused = unreadable(record.documents, previous?.record.documents);
|
|
66
|
+
const refused = yield* unreadable(record.documents, previous?.record.documents);
|
|
37
67
|
if (refused !== null)
|
|
38
68
|
return refused;
|
|
39
69
|
}
|
|
40
70
|
}
|
|
41
71
|
else if (textChanged) {
|
|
42
|
-
const refused = unreadable(record.documents, previous?.record.documents);
|
|
72
|
+
const refused = yield* unreadable(record.documents, previous?.record.documents);
|
|
43
73
|
if (refused !== null)
|
|
44
74
|
return refused;
|
|
45
75
|
}
|
|
46
|
-
return { kind: 'staged', confirmed:
|
|
76
|
+
return { kind: 'staged', confirmed: yield* confirming(record, previous) };
|
|
47
77
|
}
|
|
48
|
-
export function
|
|
49
|
-
|
|
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));
|
|
50
83
|
if (verdict.verdict !== 'refuse')
|
|
51
|
-
return { kind: 'staged', confirmed:
|
|
84
|
+
return { kind: 'staged', confirmed: yield* confirming(record, previous) };
|
|
52
85
|
return verdict.rule === 'model-unavailable'
|
|
53
86
|
? { kind: 'deferred' }
|
|
54
87
|
: { kind: 'refused', refusal: verdict };
|
|
55
88
|
}
|
|
89
|
+
export function readReclassified(record, previous) {
|
|
90
|
+
return stepped(reclassifying(record, previous));
|
|
91
|
+
}
|
|
56
92
|
function returnedBinaries(held, submitted, accepted) {
|
|
57
|
-
const binaries =
|
|
93
|
+
const binaries = drafted(held);
|
|
58
94
|
for (const change of submitted.changes) {
|
|
59
95
|
if (change.kind !== 'move')
|
|
60
96
|
continue;
|
|
@@ -64,31 +100,25 @@ function returnedBinaries(held, submitted, accepted) {
|
|
|
64
100
|
binaries[change.to] = moved;
|
|
65
101
|
delete binaries[change.path];
|
|
66
102
|
}
|
|
67
|
-
|
|
68
|
-
const written = submitted.changes.find((change, index) => change.kind === 'binary' && landing(submitted.changes, index, change.path) === path);
|
|
69
|
-
if (written === undefined)
|
|
70
|
-
continue;
|
|
71
|
-
binaries[path] = {
|
|
72
|
-
state: 'accepted',
|
|
73
|
-
fileRef,
|
|
74
|
-
byteLength: written.byteLength,
|
|
75
|
-
mediaType: written.mediaType,
|
|
76
|
-
sha256: written.sha256,
|
|
77
|
-
};
|
|
78
|
-
}
|
|
103
|
+
Object.assign(binaries, acceptedBinaries(accepted.binaryFiles ?? {}));
|
|
79
104
|
for (const path of accepted.removals)
|
|
80
105
|
delete binaries[path];
|
|
81
|
-
return binaries;
|
|
106
|
+
return settled(binaries);
|
|
82
107
|
}
|
|
83
108
|
export function applyReturned(confirmed, submitted, accepted, roomVersion, writtenAt) {
|
|
84
|
-
const { documents, revisions, changes, removals } = accepted;
|
|
85
|
-
const nextDocuments =
|
|
86
|
-
const nextRevisions =
|
|
87
|
-
const
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
109
|
+
const { documents, revisions, fileIds, changes, removals } = accepted;
|
|
110
|
+
const nextDocuments = drafted(confirmed.record.documents);
|
|
111
|
+
const nextRevisions = drafted(confirmed.record.revisions);
|
|
112
|
+
const nextFileIds = drafted(confirmed.record.fileIds);
|
|
113
|
+
const nextChanges = drafted(confirmed.record.changes);
|
|
114
|
+
const nextWritten = drafted(confirmed.record.written);
|
|
115
|
+
Object.assign(nextDocuments, documents);
|
|
116
|
+
Object.assign(nextRevisions, revisions);
|
|
117
|
+
for (const path of Object.keys({ ...documents, ...revisions }))
|
|
118
|
+
delete nextFileIds[path];
|
|
119
|
+
Object.assign(nextFileIds, fileIds);
|
|
120
|
+
for (const path of Object.keys(documents))
|
|
121
|
+
nextWritten[path] = writtenAt;
|
|
92
122
|
for (const [path, revision] of Object.entries(revisions)) {
|
|
93
123
|
if (confirmed.record.revisions[path] !== revision)
|
|
94
124
|
delete nextChanges[path];
|
|
@@ -97,20 +127,22 @@ export function applyReturned(confirmed, submitted, accepted, roomVersion, writt
|
|
|
97
127
|
for (const path of removals) {
|
|
98
128
|
delete nextDocuments[path];
|
|
99
129
|
delete nextRevisions[path];
|
|
130
|
+
delete nextFileIds[path];
|
|
100
131
|
delete nextChanges[path];
|
|
101
132
|
delete nextWritten[path];
|
|
102
133
|
}
|
|
103
134
|
return readStaged({
|
|
104
135
|
...confirmed.record,
|
|
105
136
|
roomVersion,
|
|
106
|
-
documents: nextDocuments,
|
|
107
|
-
revisions: nextRevisions,
|
|
108
|
-
|
|
109
|
-
|
|
137
|
+
documents: settled(nextDocuments),
|
|
138
|
+
revisions: settled(nextRevisions),
|
|
139
|
+
fileIds: settled(nextFileIds),
|
|
140
|
+
changes: settled(nextChanges),
|
|
141
|
+
written: settled(nextWritten),
|
|
110
142
|
binaries: returnedBinaries(confirmed.record.binaries, submitted, accepted),
|
|
111
143
|
}, confirmed);
|
|
112
144
|
}
|
|
113
|
-
function
|
|
145
|
+
function* predicting(confirmed, batches, previous) {
|
|
114
146
|
const composition = compositionOf(confirmed.record);
|
|
115
147
|
let layer = confirmed.record;
|
|
116
148
|
const replay = [];
|
|
@@ -120,7 +152,7 @@ function predicted(confirmed, batches, previous) {
|
|
|
120
152
|
const old = prior.get(batch.id);
|
|
121
153
|
const hasMove = batch.changes.some((change) => change.kind === 'move');
|
|
122
154
|
const reuseRewrite = old?.collection !== undefined &&
|
|
123
|
-
|
|
155
|
+
(yield* sameText(before, old.before)) &&
|
|
124
156
|
old.collection.composition.model === composition.model &&
|
|
125
157
|
old.collection.composition.selection?.model === composition.selection?.model &&
|
|
126
158
|
JSON.stringify(old.collection.composition.selection?.roots) ===
|
|
@@ -128,17 +160,17 @@ function predicted(confirmed, batches, previous) {
|
|
|
128
160
|
const collection = hasMove
|
|
129
161
|
? reuseRewrite
|
|
130
162
|
? old.collection
|
|
131
|
-
:
|
|
163
|
+
: yield* collecting(before.documents, composition, old?.collection ?? confirmed.collection)
|
|
132
164
|
: undefined;
|
|
133
165
|
const effective = collection === undefined
|
|
134
166
|
? batch
|
|
135
167
|
: reuseRewrite
|
|
136
168
|
? old.effective
|
|
137
|
-
: providerRewritten(batch, { ...before, collection });
|
|
169
|
+
: yield* providerRewritten(batch, { ...before, collection });
|
|
138
170
|
layer =
|
|
139
171
|
old === undefined
|
|
140
|
-
?
|
|
141
|
-
: overlayChanged(before,
|
|
172
|
+
? yield* overlaying(before, [effective])
|
|
173
|
+
: yield* overlayChanged(before, effective, old.before, old.effective, old.after);
|
|
142
174
|
replay.push({
|
|
143
175
|
id: batch.id,
|
|
144
176
|
before,
|
|
@@ -149,7 +181,7 @@ function predicted(confirmed, batches, previous) {
|
|
|
149
181
|
}
|
|
150
182
|
return { layer, replay };
|
|
151
183
|
}
|
|
152
|
-
export function
|
|
184
|
+
export function* replicating(confirmed, queue, previous) {
|
|
153
185
|
const batches = Object.freeze(queue.map(immutable));
|
|
154
186
|
if (batches.length === 0) {
|
|
155
187
|
return {
|
|
@@ -159,23 +191,27 @@ export function replicaOf(confirmed, queue, previous) {
|
|
|
159
191
|
documents: confirmed.record.documents,
|
|
160
192
|
binaries: confirmed.record.binaries,
|
|
161
193
|
revisions: confirmed.record.revisions,
|
|
194
|
+
fileIds: confirmed.record.fileIds,
|
|
162
195
|
changes: confirmed.record.changes,
|
|
163
196
|
collection: confirmed.collection,
|
|
164
197
|
},
|
|
165
198
|
replay: [],
|
|
166
199
|
};
|
|
167
200
|
}
|
|
168
|
-
const { layer, replay } =
|
|
201
|
+
const { layer, replay } = yield* predicting(confirmed, batches, previous);
|
|
169
202
|
return {
|
|
170
203
|
confirmed,
|
|
171
204
|
queue: batches,
|
|
172
205
|
replay,
|
|
173
206
|
visible: {
|
|
174
207
|
...layer,
|
|
175
|
-
collection:
|
|
208
|
+
collection: yield* collecting(layer.documents, compositionOf(confirmed.record), previous?.visible.collection ?? confirmed.collection),
|
|
176
209
|
},
|
|
177
210
|
};
|
|
178
211
|
}
|
|
212
|
+
export function replicaOf(confirmed, queue, previous) {
|
|
213
|
+
return finished(replicating(confirmed, queue, previous));
|
|
214
|
+
}
|
|
179
215
|
function present(layer, path) {
|
|
180
216
|
return layer.documents[path] !== undefined || layer.binaries[path] !== undefined;
|
|
181
217
|
}
|
|
@@ -249,7 +285,10 @@ function effects(change) {
|
|
|
249
285
|
return [{ kind: 'absent', path }];
|
|
250
286
|
}
|
|
251
287
|
export function landed(batch, confirmed, current = {}) {
|
|
252
|
-
const layer = {
|
|
288
|
+
const layer = {
|
|
289
|
+
...confirmed.record,
|
|
290
|
+
documents: patched(confirmed.record.documents, Object.entries(current)),
|
|
291
|
+
};
|
|
253
292
|
return batch.changes.every((change, index) => {
|
|
254
293
|
if (change.kind === 'replace' || (change.kind === 'create' && 'content' in change)) {
|
|
255
294
|
const at = landing(batch.changes, index, change.path);
|
|
@@ -267,32 +306,48 @@ export function landed(batch, confirmed, current = {}) {
|
|
|
267
306
|
});
|
|
268
307
|
});
|
|
269
308
|
}
|
|
270
|
-
|
|
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) {
|
|
271
324
|
if (!queue.some(withdrawable))
|
|
272
|
-
return [];
|
|
325
|
+
return { withdrawn: [], kept: queue };
|
|
273
326
|
const composition = compositionOf(confirmed.record);
|
|
274
327
|
let layer = confirmed.record;
|
|
275
328
|
const withdrawn = [];
|
|
329
|
+
const kept = [];
|
|
276
330
|
for (const batch of queue) {
|
|
277
331
|
if (withdrawable(batch) && !holds(layer, batch.preconditions)) {
|
|
278
332
|
withdrawn.push(batch);
|
|
279
333
|
continue;
|
|
280
334
|
}
|
|
281
335
|
const effective = batch.changes.some((change) => change.kind === 'move')
|
|
282
|
-
? providerRewritten(batch, {
|
|
336
|
+
? yield* providerRewritten(batch, {
|
|
283
337
|
...layer,
|
|
284
|
-
collection:
|
|
338
|
+
collection: yield* collecting(layer.documents, composition),
|
|
285
339
|
})
|
|
286
340
|
: batch;
|
|
287
341
|
let unapplied = false;
|
|
288
|
-
const next =
|
|
342
|
+
const next = yield* overlaying(layer, [effective], () => {
|
|
289
343
|
unapplied = true;
|
|
290
344
|
});
|
|
291
345
|
if (local && unapplied) {
|
|
292
346
|
withdrawn.push(batch);
|
|
293
347
|
continue;
|
|
294
348
|
}
|
|
349
|
+
kept.push(local || !withdrawable(batch) ? batch : founded(batch, layer));
|
|
295
350
|
layer = next;
|
|
296
351
|
}
|
|
297
|
-
return withdrawn;
|
|
352
|
+
return { withdrawn, kept };
|
|
298
353
|
}
|
package/dist/room-draft.d.ts
CHANGED
|
@@ -87,7 +87,7 @@ type ChangedUnderneath = {
|
|
|
87
87
|
readonly file?: string | null;
|
|
88
88
|
};
|
|
89
89
|
export type ReturnReason = ProviderRefusal & {
|
|
90
|
-
readonly kind: 'conflicted' | 'rejected' | 'expired' | 'withdrawn'
|
|
90
|
+
readonly kind: Open<'conflicted' | 'rejected' | 'expired' | 'withdrawn'>;
|
|
91
91
|
};
|
|
92
92
|
export declare function returnedBy(kind: 'expired' | 'withdrawn'): ReturnReason;
|
|
93
93
|
export type RoomDraft = {
|
|
@@ -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,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E,SAAS,UAAU,EAAE,GAAG,UAAU,CAkBzF;AAED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,SAAS,UAAU,EAAE,EAC7B,OAAO,EAAE,SAAS,MAAM,EAAE,GACzB,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;
|
package/dist/rows.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Frontmatter } from '@agentshouse/mdmodel';
|
|
2
2
|
import type { HeadChange } from './adapter.js';
|
|
3
3
|
import type { BinaryFileRecord } from './binary.js';
|
|
4
4
|
import { type Composition } from './collection.js';
|
|
@@ -13,19 +13,12 @@ export type DocumentRow = {
|
|
|
13
13
|
values: Fields;
|
|
14
14
|
reached: Readonly<Record<string, readonly unknown[]>>;
|
|
15
15
|
directories: readonly string[];
|
|
16
|
-
|
|
16
|
+
folder: string;
|
|
17
|
+
text: string | null;
|
|
17
18
|
change: HeadChange | null;
|
|
19
|
+
fileId: string | null;
|
|
18
20
|
binary: BinaryFileRecord | null;
|
|
19
21
|
};
|
|
20
|
-
export type BodyRow = {
|
|
21
|
-
key: string;
|
|
22
|
-
kind: 'body';
|
|
23
|
-
room: string;
|
|
24
|
-
path: string;
|
|
25
|
-
preamble: string;
|
|
26
|
-
sections: Readonly<Record<string, string>>;
|
|
27
|
-
markdown: string;
|
|
28
|
-
};
|
|
29
22
|
export type ReferenceRow = {
|
|
30
23
|
key: string;
|
|
31
24
|
kind: 'reference';
|
|
@@ -37,10 +30,10 @@ export type ReferenceRow = {
|
|
|
37
30
|
path: string;
|
|
38
31
|
type: string;
|
|
39
32
|
};
|
|
40
|
-
export type Row = DocumentRow |
|
|
33
|
+
export type Row = DocumentRow | ReferenceRow;
|
|
41
34
|
export declare function documentKey(room: string, path: string): string;
|
|
42
35
|
export declare function roomOfKey(key: string): string;
|
|
43
36
|
export declare function markdownPath(path: string): boolean;
|
|
44
|
-
export declare function rowsOf(room: string, path: string, document:
|
|
37
|
+
export declare function rowsOf(room: string, path: string, document: Frontmatter | null, composition: Composition, change: HeadChange | null, fileId: string | null, binary: BinaryFileRecord | null): readonly Row[];
|
|
45
38
|
export {};
|
|
46
39
|
//# sourceMappingURL=rows.d.ts.map
|
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,EAKL,KAAK,
|
|
1
|
+
{"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../src/rows.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,WAAW,EACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9D,KAAK,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAEhD,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC,CAAC,CAAC;IACtD,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IAC1B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,GAAG,GAAG,WAAW,GAAG,YAAY,CAAC;AAM7C,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAuFD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAElD;AAED,wBAAgB,MAAM,CACpB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,WAAW,GAAG,IAAI,EAC5B,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,UAAU,GAAG,IAAI,EACzB,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,MAAM,EAAE,gBAAgB,GAAG,IAAI,GAC9B,SAAS,GAAG,EAAE,CAmEhB"}
|
package/dist/rows.js
CHANGED
|
@@ -64,6 +64,9 @@ function walk(reading, node, forms, exact) {
|
|
|
64
64
|
: [{ text: `${form.text}/${segment}`, through: form.through, pending: false }]), `${exact}/${segment}`);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
+
function folderOf(path) {
|
|
68
|
+
return path.slice(0, Math.max(path.lastIndexOf('/'), 0));
|
|
69
|
+
}
|
|
67
70
|
function directoriesOf(path) {
|
|
68
71
|
const parts = path.split('/').slice(0, -1);
|
|
69
72
|
return ['', ...parts.map((_, index) => parts.slice(0, index + 1).join('/'))];
|
|
@@ -71,9 +74,8 @@ function directoriesOf(path) {
|
|
|
71
74
|
export function markdownPath(path) {
|
|
72
75
|
return path.endsWith('.md');
|
|
73
76
|
}
|
|
74
|
-
export function rowsOf(room, path, document, composition, change, binary) {
|
|
77
|
+
export function rowsOf(room, path, document, composition, change, fileId, binary) {
|
|
75
78
|
const key = documentKey(room, path);
|
|
76
|
-
const body = keyOf('b', room, path);
|
|
77
79
|
if (document === null || !markdownPath(path)) {
|
|
78
80
|
return [
|
|
79
81
|
{
|
|
@@ -86,8 +88,10 @@ export function rowsOf(room, path, document, composition, change, binary) {
|
|
|
86
88
|
values: {},
|
|
87
89
|
reached: {},
|
|
88
90
|
directories: directoriesOf(path),
|
|
89
|
-
|
|
91
|
+
folder: folderOf(path),
|
|
92
|
+
text: null,
|
|
90
93
|
change,
|
|
94
|
+
fileId,
|
|
91
95
|
binary,
|
|
92
96
|
},
|
|
93
97
|
];
|
|
@@ -117,19 +121,12 @@ export function rowsOf(room, path, document, composition, change, binary) {
|
|
|
117
121
|
values,
|
|
118
122
|
reached,
|
|
119
123
|
directories: directoriesOf(path),
|
|
120
|
-
|
|
124
|
+
folder: folderOf(path),
|
|
125
|
+
text: document.content,
|
|
121
126
|
change,
|
|
127
|
+
fileId,
|
|
122
128
|
binary,
|
|
123
129
|
},
|
|
124
|
-
{
|
|
125
|
-
key: body,
|
|
126
|
-
kind: 'body',
|
|
127
|
-
room,
|
|
128
|
-
path,
|
|
129
|
-
preamble: document.preamble,
|
|
130
|
-
sections: document.sections,
|
|
131
|
-
markdown: document.content,
|
|
132
|
-
},
|
|
133
130
|
...[...reading.targets.values()].map(({ field, target: found, forms }) => ({
|
|
134
131
|
key: keyOf('r', room, path, field, found),
|
|
135
132
|
kind: 'reference',
|
package/dist/save.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ProviderLimit } from './adapter.js';
|
|
2
2
|
import { type Change, type ChangeBatch, type Precondition, type WrittenBy } from './change.js';
|
|
3
3
|
import { type Composition } from './collection.js';
|
|
4
|
-
import { type Layer } from './overlay.js';
|
|
5
4
|
import type { VisibleLayer } from './replica.js';
|
|
6
5
|
import type { ChangedPart } from './room-draft.js';
|
|
6
|
+
import { type Later } from './turn.js';
|
|
7
7
|
export type SaveRefusal = {
|
|
8
8
|
code: string;
|
|
9
9
|
retryable: boolean;
|
|
@@ -25,6 +25,11 @@ export type SaveInput = {
|
|
|
25
25
|
bases: readonly Precondition[];
|
|
26
26
|
queued?: ReadonlySet<string>;
|
|
27
27
|
writtenBy?: WrittenBy;
|
|
28
|
+
clean?: {
|
|
29
|
+
text: Readonly<Record<string, string>>;
|
|
30
|
+
binaries: Readonly<Record<string, unknown>>;
|
|
31
|
+
composition: Composition;
|
|
32
|
+
};
|
|
28
33
|
};
|
|
29
34
|
export type BatchResult = {
|
|
30
35
|
kind: 'batch';
|
|
@@ -33,7 +38,8 @@ export type BatchResult = {
|
|
|
33
38
|
kind: 'refused';
|
|
34
39
|
refusal: SaveRefusal;
|
|
35
40
|
};
|
|
36
|
-
export declare function providerRewritten(batch: ChangeBatch, visible: VisibleLayer): ChangeBatch
|
|
41
|
+
export declare function providerRewritten(batch: ChangeBatch, visible: VisibleLayer): Generator<number, ChangeBatch, void>;
|
|
42
|
+
export declare function queuedDocuments(queue: readonly ChangeBatch[]): ReadonlySet<string>;
|
|
37
43
|
export type Requeued = {
|
|
38
44
|
kind: 'requeued';
|
|
39
45
|
queue: readonly ChangeBatch[];
|
|
@@ -55,6 +61,6 @@ export type Joining = {
|
|
|
55
61
|
};
|
|
56
62
|
export declare function requeued(queue: readonly ChangeBatch[], changes: readonly Change[], visible: VisibleLayer, changeable: (batch: ChangeBatch) => boolean, state: (queue: readonly ChangeBatch[]) => VisibleLayer): Requeued;
|
|
57
63
|
export declare function joined(queue: readonly ChangeBatch[], owner: ChangeBatch, extra: ChangeBatch): Joining;
|
|
58
|
-
export declare function limitedIn(queue: readonly ChangeBatch[], batch: ChangeBatch, limits: readonly ProviderLimit[], state: (queue: readonly ChangeBatch[]) =>
|
|
59
|
-
export declare function buildBatch(input: SaveInput): BatchResult
|
|
64
|
+
export declare function limitedIn(queue: readonly ChangeBatch[], batch: ChangeBatch, limits: readonly ProviderLimit[], state: (queue: readonly ChangeBatch[]) => VisibleLayer): SaveRefusal | null;
|
|
65
|
+
export declare function buildBatch(input: SaveInput): Later<BatchResult>;
|
|
60
66
|
//# sourceMappingURL=save.d.ts.map
|
package/dist/save.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"save.d.ts","sourceRoot":"","sources":["../src/save.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"save.d.ts","sourceRoot":"","sources":["../src/save.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAIL,KAAK,MAAM,EACX,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,aAAa,CAAC;AACrB,OAAO,EASL,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAiC,KAAK,KAAK,EAAE,MAAM,WAAW,CAAC;AAEtE,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,KAAK,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,OAAO,CAAC;IACf,WAAW,EAAE,WAAW,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,OAAO,cAAc,EAAE,eAAe,CAAC;IACnD,kBAAkB,EAAE,SAAS,MAAM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