@agentshouse/mdruntime 0.1.0-c38e1bde25d7f → 0.1.0-c396ea417807b
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/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +30 -1
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +25 -5
- package/dist/adapter.d.ts +46 -17
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +2 -2
- package/dist/{binary.d.ts → attachment.d.ts} +4 -4
- package/dist/attachment.d.ts.map +1 -0
- package/dist/{binary.js → attachment.js} +2 -2
- package/dist/authored.d.ts.map +1 -1
- package/dist/authored.js +2 -0
- package/dist/chain.d.ts +1 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/chain.js +5 -2
- package/dist/change.d.ts +2 -2
- package/dist/client.d.ts +3 -3
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +11 -11
- package/dist/collection.d.ts +1 -0
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +7 -1
- package/dist/compile.d.ts +2 -1
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +71 -37
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +2 -0
- package/dist/conversation.d.ts +12 -5
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +6 -3
- package/dist/declaration.js +2 -2
- package/dist/download.d.ts +2 -2
- package/dist/download.d.ts.map +1 -1
- package/dist/entry.d.ts +13 -3
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +72 -24
- package/dist/figures.d.ts +1 -1
- package/dist/figures.d.ts.map +1 -1
- package/dist/figures.js +2 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +12 -12
- package/dist/house-query.d.ts +8 -2
- package/dist/house-query.d.ts.map +1 -1
- package/dist/house-query.js +53 -5
- package/dist/identity.d.ts +1 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +1 -1
- package/dist/index.d.ts +11 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +2 -0
- package/dist/live.d.ts +14 -0
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +29 -12
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +19 -6
- package/dist/memory.d.ts +2 -2
- package/dist/memory.js +9 -9
- package/dist/model.d.ts +6 -5
- package/dist/model.d.ts.map +1 -1
- package/dist/opened.d.ts +5 -5
- package/dist/opened.d.ts.map +1 -1
- package/dist/opened.js +2 -2
- package/dist/outcome.d.ts +16 -16
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +5 -5
- package/dist/overlay.d.ts +19 -8
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +108 -37
- package/dist/paths.d.ts +1 -1
- package/dist/paths.js +1 -1
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +56 -13
- package/dist/query.d.ts +2 -2
- package/dist/query.d.ts.map +1 -1
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +13 -13
- package/dist/readiness.d.ts +4 -1
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +2 -1
- package/dist/reads.d.ts +2 -0
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +27 -4
- package/dist/reference-forms.d.ts +4 -0
- package/dist/reference-forms.d.ts.map +1 -0
- package/dist/reference-forms.js +74 -0
- package/dist/refresh.d.ts +1 -1
- package/dist/refresh.js +4 -4
- package/dist/replica.d.ts +3 -8
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +3 -3
- package/dist/room-draft.d.ts +1 -1
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +4 -4
- package/dist/room-drafts.js +2 -2
- package/dist/rows.d.ts +9 -1
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +18 -4
- package/dist/runtime.d.ts +2 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +6 -6
- package/dist/saves.d.ts +5 -5
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +51 -45
- package/dist/selector.d.ts +3 -0
- package/dist/selector.d.ts.map +1 -0
- package/dist/selector.js +22 -0
- package/dist/source.d.ts +2 -0
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +2 -0
- package/dist/store/records.d.ts +12 -5
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +10 -4
- package/dist/store.d.ts +1 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/stored.d.ts +9 -2
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +33 -11
- package/dist/surface.d.ts +2 -2
- package/dist/surface.js +2 -2
- package/dist/sync.js +1 -1
- package/dist/tables.d.ts +14 -2
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +10 -3
- package/dist/tallies.js +2 -2
- package/dist/validation.d.ts +2 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +49 -3
- package/dist/wire.d.ts +6 -6
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +6 -6
- package/package.json +3 -3
- package/dist/binary.d.ts.map +0 -1
package/dist/overlay.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { apply, create, documentValue, parse, serialize, TYPE_FIELD, } from '@agentshouse/mdmodel';
|
|
2
2
|
import { definitionsAt } from './collection.js';
|
|
3
|
-
import { isPart, } from './change.js';
|
|
3
|
+
import { departure, isPart, } from './change.js';
|
|
4
4
|
import { drafted, entriesIn, settling } from './shared.js';
|
|
5
5
|
import { ROW_WEIGHT } from './turn.js';
|
|
6
|
-
export function*
|
|
6
|
+
export function* acceptedAttachments(files) {
|
|
7
7
|
for (const [path, file] of entriesIn(files))
|
|
8
8
|
yield [path, { state: 'accepted', ...file }];
|
|
9
9
|
}
|
|
10
|
-
export function
|
|
10
|
+
export function sameAttachment(left, right) {
|
|
11
11
|
if (left === undefined || right === undefined)
|
|
12
12
|
return left === right;
|
|
13
13
|
return (left.state === right.state &&
|
|
@@ -67,12 +67,6 @@ export function composed(path, fields, sections, composition) {
|
|
|
67
67
|
})),
|
|
68
68
|
], definition);
|
|
69
69
|
}
|
|
70
|
-
export function compose(path, fields, sections, composition) {
|
|
71
|
-
const next = composed(path, fields, sections, composition);
|
|
72
|
-
if (next.outcome !== 'applied')
|
|
73
|
-
throw new Error(`the creation of ${path} writes no document`);
|
|
74
|
-
return serialize(next.document);
|
|
75
|
-
}
|
|
76
70
|
function edited(change, priors) {
|
|
77
71
|
if (change.kind === 'field')
|
|
78
72
|
return {
|
|
@@ -104,7 +98,7 @@ function edit(staged, changes, priors, composition) {
|
|
|
104
98
|
const wanted = changes.map((change) => edited(change, priors));
|
|
105
99
|
const first = apply(parsed.document, wanted, definition);
|
|
106
100
|
if (first.outcome === 'refuse')
|
|
107
|
-
return
|
|
101
|
+
return { refusal: first.refusal };
|
|
108
102
|
if (first.outcome === 'applied') {
|
|
109
103
|
staged.documents[path] = serialize(first.document);
|
|
110
104
|
return 0;
|
|
@@ -164,10 +158,16 @@ function erase(staged, path) {
|
|
|
164
158
|
}
|
|
165
159
|
function stage(staged, change, composition) {
|
|
166
160
|
if (change.kind === 'create') {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
161
|
+
if ('content' in change)
|
|
162
|
+
staged.documents[change.path] = change.content;
|
|
163
|
+
else {
|
|
164
|
+
const next = composed(change.path, change.fields, change.sections, composition);
|
|
165
|
+
if (next.outcome === 'refuse')
|
|
166
|
+
return { refusal: next.refusal };
|
|
167
|
+
if (next.outcome === 'stale')
|
|
168
|
+
throw new Error(`the creation of ${change.path} writes no document`);
|
|
169
|
+
staged.documents[change.path] = serialize(next.document);
|
|
170
|
+
}
|
|
171
171
|
delete staged.fileIds[change.path];
|
|
172
172
|
delete staged.created[change.path];
|
|
173
173
|
delete staged.changes[change.path];
|
|
@@ -219,8 +219,38 @@ function arrive(heads, change) {
|
|
|
219
219
|
if (change.change !== undefined)
|
|
220
220
|
heads.changes[change.path] = change.change;
|
|
221
221
|
}
|
|
222
|
-
|
|
223
|
-
const
|
|
222
|
+
function* stagedBatch(staged, batch, composition, settled) {
|
|
223
|
+
const priors = yield* priorsOf(batch.preconditions);
|
|
224
|
+
for (let index = 0; index < batch.changes.length; index += 1) {
|
|
225
|
+
const change = batch.changes[index];
|
|
226
|
+
if (!isPart(change)) {
|
|
227
|
+
const staging = stage(staged, change, composition);
|
|
228
|
+
if (typeof staging === 'boolean')
|
|
229
|
+
settled(index, change.path, staging ? 0 : 1);
|
|
230
|
+
else
|
|
231
|
+
settled(index, change.path, 1, staging.refusal);
|
|
232
|
+
yield ROW_WEIGHT;
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
const run = [change];
|
|
236
|
+
while (index + 1 < batch.changes.length) {
|
|
237
|
+
const next = batch.changes[index + 1];
|
|
238
|
+
if (!isPart(next) || next.path !== change.path)
|
|
239
|
+
break;
|
|
240
|
+
run.push(next);
|
|
241
|
+
index += 1;
|
|
242
|
+
}
|
|
243
|
+
const text = staged.documents[change.path] ?? '';
|
|
244
|
+
const edited = edit(staged, run, priors, composition);
|
|
245
|
+
if (typeof edited === 'number')
|
|
246
|
+
settled(index, change.path, edited);
|
|
247
|
+
else
|
|
248
|
+
settled(index, change.path, run.length, edited.refusal);
|
|
249
|
+
yield ROW_WEIGHT + text.length;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function stagedOf(base) {
|
|
253
|
+
return {
|
|
224
254
|
documents: drafted(base.documents),
|
|
225
255
|
binaries: drafted(base.binaries),
|
|
226
256
|
revisions: drafted(base.revisions),
|
|
@@ -228,29 +258,14 @@ export function* overlaying(base, queue, composition, unapplied) {
|
|
|
228
258
|
created: drafted(base.created),
|
|
229
259
|
changes: drafted(base.changes),
|
|
230
260
|
};
|
|
261
|
+
}
|
|
262
|
+
export function* overlaying(base, queue, composition, unapplied) {
|
|
263
|
+
const staged = stagedOf(base);
|
|
231
264
|
for (const batch of queue) {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
const change = batch.changes[index];
|
|
235
|
-
if (!isPart(change)) {
|
|
236
|
-
if (!stage(staged, change, composition))
|
|
237
|
-
unapplied?.();
|
|
238
|
-
yield ROW_WEIGHT;
|
|
239
|
-
continue;
|
|
240
|
-
}
|
|
241
|
-
const run = [change];
|
|
242
|
-
while (index + 1 < batch.changes.length) {
|
|
243
|
-
const next = batch.changes[index + 1];
|
|
244
|
-
if (!isPart(next) || next.path !== change.path)
|
|
245
|
-
break;
|
|
246
|
-
run.push(next);
|
|
247
|
-
index += 1;
|
|
248
|
-
}
|
|
249
|
-
const text = staged.documents[change.path] ?? '';
|
|
250
|
-
for (let left = edit(staged, run, priors, composition); left > 0; left -= 1)
|
|
265
|
+
yield* stagedBatch(staged, batch, composition, (_index, _path, left) => {
|
|
266
|
+
for (let count = left; count > 0; count -= 1)
|
|
251
267
|
unapplied?.();
|
|
252
|
-
|
|
253
|
-
}
|
|
268
|
+
});
|
|
254
269
|
}
|
|
255
270
|
return {
|
|
256
271
|
documents: yield* settling(staged.documents),
|
|
@@ -261,3 +276,59 @@ export function* overlaying(base, queue, composition, unapplied) {
|
|
|
261
276
|
changes: yield* settling(staged.changes),
|
|
262
277
|
};
|
|
263
278
|
}
|
|
279
|
+
function writesText(change) {
|
|
280
|
+
return isPart(change) || change.kind === 'create' || change.kind === 'replace';
|
|
281
|
+
}
|
|
282
|
+
function textWrites(changes) {
|
|
283
|
+
const identities = changes.map((_, index) => departure(changes, index));
|
|
284
|
+
const created = new Set(changes.flatMap((change, index) => (change.kind === 'create' ? [identities[index]] : [])));
|
|
285
|
+
const last = new Map(changes.flatMap((change, index) => writesText(change) ? [[identities[index], index]] : []));
|
|
286
|
+
return { identities, created, last };
|
|
287
|
+
}
|
|
288
|
+
export function unreadDocuments(batch, base) {
|
|
289
|
+
const { identities, created, last } = textWrites(batch.changes);
|
|
290
|
+
return batch.changes.map((_, index) => {
|
|
291
|
+
const identity = identities[index];
|
|
292
|
+
if (last.get(identity) !== index)
|
|
293
|
+
return null;
|
|
294
|
+
const made = created.has(identity);
|
|
295
|
+
return { stale: false, content: '', base: made ? null : base, created: made };
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
export function* writtenDocuments(base, batch, composition) {
|
|
299
|
+
const { changes } = batch;
|
|
300
|
+
const { identities, created, last } = textWrites(changes);
|
|
301
|
+
const read = new Map(batch.preconditions.flatMap((precondition) => precondition.kind === 'revision' ? [[precondition.path, precondition.revision]] : []));
|
|
302
|
+
const stale = new Set();
|
|
303
|
+
const refused = new Map();
|
|
304
|
+
const texts = new Map();
|
|
305
|
+
const staged = stagedOf(base);
|
|
306
|
+
yield* stagedBatch(staged, batch, composition, (index, path, unapplied, refusal) => {
|
|
307
|
+
if (!writesText(changes[index]))
|
|
308
|
+
return;
|
|
309
|
+
const identity = identities[index];
|
|
310
|
+
if (unapplied > 0)
|
|
311
|
+
stale.add(identity);
|
|
312
|
+
if (refusal !== undefined && !refused.has(identity))
|
|
313
|
+
refused.set(identity, refusal);
|
|
314
|
+
const text = staged.documents[path];
|
|
315
|
+
if (text !== undefined)
|
|
316
|
+
texts.set(index, text);
|
|
317
|
+
});
|
|
318
|
+
return changes.map((_, index) => {
|
|
319
|
+
const identity = identities[index];
|
|
320
|
+
if (last.get(identity) !== index)
|
|
321
|
+
return null;
|
|
322
|
+
const content = texts.get(index);
|
|
323
|
+
if (content === undefined || stale.has(identity)) {
|
|
324
|
+
const refusal = refused.get(identity);
|
|
325
|
+
return refusal === undefined ? { stale: true } : { stale: true, refusal };
|
|
326
|
+
}
|
|
327
|
+
return {
|
|
328
|
+
stale: false,
|
|
329
|
+
content,
|
|
330
|
+
base: read.get(changes[index].path) ?? read.get(identity) ?? base.revisions[identity] ?? null,
|
|
331
|
+
created: created.has(identity),
|
|
332
|
+
};
|
|
333
|
+
});
|
|
334
|
+
}
|
package/dist/paths.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare function normalize(path: string): string | null;
|
|
2
2
|
export declare function beneath(prefix: string, path: string): boolean;
|
|
3
3
|
export declare function covered(prefixes: readonly string[], path: string): boolean;
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function documentAt(patterns: readonly string[], path: string): boolean;
|
|
5
5
|
export declare function ancestors(path: string): readonly string[];
|
|
6
6
|
//# sourceMappingURL=paths.d.ts.map
|
package/dist/paths.js
CHANGED
|
@@ -41,7 +41,7 @@ function matched(pattern, path) {
|
|
|
41
41
|
return ((open ? names.length > fixed.length : names.length === fixed.length) &&
|
|
42
42
|
fixed.every((one, at) => named(one, names[at])));
|
|
43
43
|
}
|
|
44
|
-
export function
|
|
44
|
+
export function documentAt(patterns, path) {
|
|
45
45
|
return patterns.some((pattern) => matched(pattern, path));
|
|
46
46
|
}
|
|
47
47
|
export function ancestors(path) {
|
package/dist/queries.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../src/queries.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../src/queries.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,EAIL,KAAK,KAAK,EAGV,KAAK,GAAG,EACT,MAAM,WAAW,CAAC;AAMnB,OAAO,EAKL,KAAK,IAAI,EACT,KAAK,WAAW,EAEjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAa,KAAK,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAEhF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAgB,KAAK,YAAY,EA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} from './figures.js';
|
|
3
3
|
import { roomInFlight } from './install.js';
|
|
4
|
-
import { readerOf } from './live.js';
|
|
4
|
+
import { hearerOf, readerOf, } from './live.js';
|
|
5
5
|
import { compositionFor, roomFacts } from './listing.js';
|
|
6
6
|
import { lockedRooms } from './locks.js';
|
|
7
7
|
import { askedOnline, offline } from './online.js';
|
|
@@ -77,8 +77,31 @@ function coveredRooms(runtime, locators, whole, held) {
|
|
|
77
77
|
return { pending };
|
|
78
78
|
return { coverage: { rooms: coverage, overlay }, rooms: read };
|
|
79
79
|
}
|
|
80
|
+
const UNFOLLOWED = { held: [], awaiting: [] };
|
|
81
|
+
function followsOf(runtime, plan, held) {
|
|
82
|
+
if (plan.hop === null)
|
|
83
|
+
return UNFOLLOWED;
|
|
84
|
+
const reached = plan.reach === null ? everyRoom(runtime, held) : roomsOfReach(plan.reach);
|
|
85
|
+
const reads = hearerOf(plan);
|
|
86
|
+
const follows = [];
|
|
87
|
+
const awaiting = [];
|
|
88
|
+
for (const locator of [...new Set(reached)].filter(reads).sort()) {
|
|
89
|
+
const replica = held.rooms.get(locator);
|
|
90
|
+
const awaits = awaitsOf(runtime, locator, held);
|
|
91
|
+
if (awaits === null) {
|
|
92
|
+
if (replica !== undefined)
|
|
93
|
+
follows.push({ locator, key: replica.key });
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
const handle = replica?.handle ?? runtime.presence.room(locator)?.handle;
|
|
97
|
+
if (handle !== undefined)
|
|
98
|
+
awaiting.push({ room: locator, awaits, handle });
|
|
99
|
+
}
|
|
100
|
+
return { held: follows, awaiting };
|
|
101
|
+
}
|
|
80
102
|
function covered(runtime, plan, held) {
|
|
81
|
-
|
|
103
|
+
const cover = coveredRooms(runtime, reachedRooms(runtime, plan, held), anyRoom(plan), held);
|
|
104
|
+
return 'pending' in cover ? cover : { ...cover, follows: followsOf(runtime, plan, held) };
|
|
82
105
|
}
|
|
83
106
|
function pendingAt(runtime, plan, reads, held, rooms) {
|
|
84
107
|
const reached = reaching(runtime, plan, reads, held);
|
|
@@ -112,8 +135,8 @@ export async function figuresCover(runtime) {
|
|
|
112
135
|
function sameCover(left, right) {
|
|
113
136
|
return JSON.stringify(left) === JSON.stringify(right);
|
|
114
137
|
}
|
|
115
|
-
async function windowRows(local, plan, rooms, unchanged) {
|
|
116
|
-
const first = await local.query(plan, rooms, QUERY_BYTES);
|
|
138
|
+
async function windowRows(local, plan, rooms, follows, unchanged) {
|
|
139
|
+
const first = await local.query(plan, rooms, follows, QUERY_BYTES);
|
|
117
140
|
if (first.more === undefined || !('documents' in first)) {
|
|
118
141
|
const { more: _more, ...rows } = first;
|
|
119
142
|
return rows;
|
|
@@ -127,7 +150,7 @@ async function windowRows(local, plan, rooms, unchanged) {
|
|
|
127
150
|
after: { text: more, values: JSON.parse(more) },
|
|
128
151
|
limit: plan.limit === null ? null : plan.limit - documents.length,
|
|
129
152
|
total: false,
|
|
130
|
-
}, rooms, QUERY_BYTES);
|
|
153
|
+
}, rooms, follows, QUERY_BYTES);
|
|
131
154
|
if (!('documents' in page))
|
|
132
155
|
return null;
|
|
133
156
|
documents.push(...page.documents);
|
|
@@ -156,17 +179,34 @@ async function composedRooms(runtime, plan, rooms) {
|
|
|
156
179
|
: { ...room, composition: compositionFor(runtime, stored.record) };
|
|
157
180
|
});
|
|
158
181
|
}
|
|
182
|
+
async function awaitedFollows(runtime, local, plan, cover) {
|
|
183
|
+
const { awaiting } = cover.follows;
|
|
184
|
+
if (awaiting.length === 0)
|
|
185
|
+
return [];
|
|
186
|
+
const named = new Set(await local.named(plan, cover.rooms, awaiting.map(({ handle }) => handle)));
|
|
187
|
+
const pending = awaiting
|
|
188
|
+
.filter(({ handle }) => named.has(handle))
|
|
189
|
+
.map(({ room, awaits }) => ({ room, awaits }));
|
|
190
|
+
awaitPreparation(runtime, { pending });
|
|
191
|
+
return pending;
|
|
192
|
+
}
|
|
159
193
|
async function coveredRows(runtime, plan, cover) {
|
|
160
194
|
const { store } = runtime;
|
|
161
195
|
for (;;) {
|
|
162
196
|
const before = await cover();
|
|
163
197
|
if ('pending' in before)
|
|
164
|
-
return { pending: before };
|
|
198
|
+
return { pending: before, cover: before };
|
|
165
199
|
const local = await store.open();
|
|
166
|
-
const
|
|
200
|
+
const awaited = await awaitedFollows(runtime, local, plan, before);
|
|
201
|
+
if (awaited.length > 0) {
|
|
202
|
+
if (sameCover(before, await cover()))
|
|
203
|
+
return { pending: { pending: awaited }, cover: before };
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
const keys = [...before.rooms, ...before.follows.held].map(({ key }) => key);
|
|
167
207
|
const changes = local.changes(keys);
|
|
168
208
|
const current = () => local.changes(keys) === changes;
|
|
169
|
-
const rows = await windowRows(local, plan, await composedRooms(runtime, plan, before.rooms), current);
|
|
209
|
+
const rows = await windowRows(local, plan, await composedRooms(runtime, plan, before.rooms), before.follows.held, current);
|
|
170
210
|
const after = await cover();
|
|
171
211
|
if (rows !== null && sameCover(before, after))
|
|
172
212
|
return { rows, cover: before, current };
|
|
@@ -187,11 +227,14 @@ function keyedOf(rows, coverage) {
|
|
|
187
227
|
export async function answeredPlan(runtime, plan, cover) {
|
|
188
228
|
const answered = await coveredRows(runtime, plan, cover);
|
|
189
229
|
if ('pending' in answered) {
|
|
190
|
-
|
|
191
|
-
return { result: pending, keys: [], current: () => true };
|
|
230
|
+
return { result: answered.pending, keys: [], current: () => true, cover: answered.cover };
|
|
192
231
|
}
|
|
193
232
|
const held = answered.cover;
|
|
194
|
-
return {
|
|
233
|
+
return {
|
|
234
|
+
...keyedOf(answered.rows, held.coverage),
|
|
235
|
+
current: answered.current,
|
|
236
|
+
cover: answered.cover,
|
|
237
|
+
};
|
|
195
238
|
}
|
|
196
239
|
async function coverNow(runtime, plan) {
|
|
197
240
|
const cover = covered(runtime, plan, await runtime.store.covering());
|
|
@@ -255,11 +298,11 @@ export function watchPlanned(runtime, planning, deliver, fail) {
|
|
|
255
298
|
}
|
|
256
299
|
export async function searched(runtime, input, reach) {
|
|
257
300
|
const { store, socket } = runtime;
|
|
258
|
-
const asked = searchPlanOf(input);
|
|
259
|
-
await socket.ready;
|
|
260
301
|
const search = socket.search();
|
|
261
302
|
if (search === undefined)
|
|
262
303
|
return undeclared('search');
|
|
304
|
+
const asked = searchPlanOf(input);
|
|
305
|
+
await socket.ready;
|
|
263
306
|
if (await offline(runtime))
|
|
264
307
|
return OFFLINE;
|
|
265
308
|
const reached = reach === null ? null : new Set(reach.rooms);
|
package/dist/query.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type HeldRooms, type QueryPlan } from '@agentshouse/mdmodel';
|
|
2
2
|
import type { HeadChange } from './adapter.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { AttachmentRecord } from './attachment.js';
|
|
4
4
|
import type { Open } from './open.js';
|
|
5
5
|
export type Backlink = {
|
|
6
6
|
path: string;
|
|
@@ -19,7 +19,7 @@ export type QueryDocument = {
|
|
|
19
19
|
change?: HeadChange | null;
|
|
20
20
|
fileId?: string | null;
|
|
21
21
|
revision?: string | null;
|
|
22
|
-
|
|
22
|
+
attachment?: AttachmentRecord;
|
|
23
23
|
size?: number | null;
|
|
24
24
|
created?: string | null;
|
|
25
25
|
};
|
package/dist/query.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,KAAK,EAAE,U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M,WAAW,GAAG,cAAc,GAAG,WAAW,GAAG,aAAa,CAAC;AAEvE,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7B,KAAK,EAAE,SAAS,QAAQ,EAAE,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG,SAAS,GAAG;IAC7B,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3B,CAAC;AAEF,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,GAAE,SAAS,GAAG,IAAW,GAAG,IAAI,CAEjG"}
|
package/dist/reach.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reach.d.ts","sourceRoot":"","sources":["../src/reach.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAgB,UAAU,EAA4B,MAAM,cAAc,CAAC;AACvF,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,
|
|
1
|
+
{"version":3,"file":"reach.d.ts","sourceRoot":"","sources":["../src/reach.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAgB,UAAU,EAA4B,MAAM,cAAc,CAAC;AACvF,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAA4C,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEjG,OAAO,KAAK,EAAE,SAAS,EAAe,YAAY,EAAE,MAAM,cAAc,CAAC;AAEzE,O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
2
|
-
import { inboxRooms, INBOXES_READ } from './readiness.js';
|
|
2
|
+
import { inboxRooms, INBOXES_LISTED, INBOXES_READ } from './readiness.js';
|
|
3
3
|
import { selected, typesPrint } from './collection.js';
|
|
4
4
|
import { unheldView } from './conversation.js';
|
|
5
5
|
import { modelResult, modelTypes, NO_MODEL } from './model.js';
|
|
6
6
|
import { changeOf, digestApplied, digestOf, observing, unchanged, } from './observation.js';
|
|
7
7
|
import { runtimeError, uncaught } from './failure.js';
|
|
8
|
-
import {
|
|
8
|
+
import { absentAttachment, failure, lockedRoom, ROOM_LOCKED, undeclared, UNREADABLE, } from './outcome.js';
|
|
9
9
|
import { beneath } from './paths.js';
|
|
10
10
|
import { moveTarget, readParts, staleWrite, } from './room-draft.js';
|
|
11
11
|
import { documentKey } from './rows.js';
|
|
@@ -25,13 +25,13 @@ const NO_CONVERSATION = {
|
|
|
25
25
|
takeOut: unconversed('conversations/take-out'),
|
|
26
26
|
decide: unconversed('agent-functions/decide'),
|
|
27
27
|
rename: unconversed('conversations/rename'),
|
|
28
|
-
|
|
28
|
+
set: unconversed('conversations/set'),
|
|
29
29
|
retry: unconversed('conversations/retry'),
|
|
30
30
|
pin: () => Promise.resolve(),
|
|
31
31
|
openTurn: () => Promise.resolve(),
|
|
32
32
|
dismissSuggestion: () => Promise.resolve(),
|
|
33
33
|
attach: () => Promise.resolve(undeclared('conversation.attach')),
|
|
34
|
-
attachment: (link) => Promise.resolve(
|
|
34
|
+
attachment: (link) => Promise.resolve(absentAttachment(link)),
|
|
35
35
|
};
|
|
36
36
|
const NO_CHAT_DRAFT = {
|
|
37
37
|
write: () => Promise.resolve(),
|
|
@@ -239,7 +239,7 @@ function queriesOnlyError(room) {
|
|
|
239
239
|
return runtimeError(QUERIES_ONLY, `${room} answers through queryHouse`);
|
|
240
240
|
}
|
|
241
241
|
function attachRequired() {
|
|
242
|
-
return runtimeError(ATTACH_REQUIRED, 'App code takes a file in with
|
|
242
|
+
return runtimeError(ATTACH_REQUIRED, 'App code takes a file in with attachment.attach');
|
|
243
243
|
}
|
|
244
244
|
function carriesFile(parts) {
|
|
245
245
|
return parts !== null && typeof parts === 'object' && Object.hasOwn(parts, 'file');
|
|
@@ -256,7 +256,7 @@ export function narrowed(runtime, given, attached) {
|
|
|
256
256
|
restart();
|
|
257
257
|
}
|
|
258
258
|
const unread = port.first?.inboxes === true
|
|
259
|
-
? watch('read', [INBOXES_READ,
|
|
259
|
+
? watch('read', [INBOXES_READ, INBOXES_LISTED], (read) => {
|
|
260
260
|
const inboxed = inboxRooms(read);
|
|
261
261
|
if (inboxed === null || JSON.stringify(inboxed) === JSON.stringify(port.inboxed)) {
|
|
262
262
|
return;
|
|
@@ -525,32 +525,32 @@ export function narrowed(runtime, given, attached) {
|
|
|
525
525
|
: (await runtime.locked(room))
|
|
526
526
|
? lockedRoom(room)
|
|
527
527
|
: md.history(room, path, query),
|
|
528
|
-
|
|
528
|
+
attachment: {
|
|
529
529
|
read: async (room, path, revision) => !covers(reach, room, path)
|
|
530
530
|
? failure({ kind: 'room-not-readable', locator: room })
|
|
531
531
|
: (await runtime.locked(room))
|
|
532
532
|
? lockedRoom(room)
|
|
533
|
-
: hand(md.
|
|
533
|
+
: hand(md.attachment.read(room, path, revision)),
|
|
534
534
|
link: async (room, path, revision) => !covers(reach, room, path)
|
|
535
535
|
? failure({ kind: 'room-not-readable', locator: room })
|
|
536
536
|
: (await runtime.locked(room))
|
|
537
537
|
? lockedRoom(room)
|
|
538
|
-
: md.
|
|
538
|
+
: md.attachment.link(room, path, revision),
|
|
539
539
|
show: async (room, path, revision) => !covers(reach, room, path)
|
|
540
540
|
? failure({ kind: 'room-not-readable', locator: room })
|
|
541
541
|
: (await runtime.locked(room))
|
|
542
542
|
? lockedRoom(room)
|
|
543
|
-
: hand(md.
|
|
543
|
+
: hand(md.attachment.show(room, path, revision)),
|
|
544
544
|
attach: async (room, file) => !wholly(reach, room)
|
|
545
545
|
? failure({ kind: 'room-not-readable', locator: room })
|
|
546
546
|
: (await runtime.locked(room))
|
|
547
547
|
? lockedRoom(room)
|
|
548
|
-
: md.
|
|
548
|
+
: md.attachment.attach(room, file),
|
|
549
549
|
async part(file, part) {
|
|
550
550
|
const key = files.get(file);
|
|
551
551
|
if (key === undefined)
|
|
552
552
|
return null;
|
|
553
|
-
const bytes = await md.
|
|
553
|
+
const bytes = await md.attachment.part(key, part);
|
|
554
554
|
if (bytes === null)
|
|
555
555
|
files.delete(file);
|
|
556
556
|
return bytes;
|
|
@@ -605,7 +605,7 @@ export function narrowed(runtime, given, attached) {
|
|
|
605
605
|
takeOut: (id, message, operation) => conversation().takeOut(id, message, operation),
|
|
606
606
|
decide: (request, decision, operation) => conversation().decide(request, decision, operation),
|
|
607
607
|
rename: (id, name, operation) => conversation().rename(id, name, operation),
|
|
608
|
-
|
|
608
|
+
set: (id, settings, operation) => conversation().set(id, settings, operation),
|
|
609
609
|
retry: (id, message, operation) => conversation().retry(id, message, operation),
|
|
610
610
|
pin: (figures) => conversation().pin(figures),
|
|
611
611
|
openTurn: (id, turn) => conversation().openTurn(id, turn),
|
package/dist/readiness.d.ts
CHANGED
|
@@ -58,7 +58,10 @@ export type ReadinessFacts = Omit<Readiness, 'status' | 'ready' | 'usable' | 'du
|
|
|
58
58
|
readonly first: TierFacts;
|
|
59
59
|
readonly established: boolean;
|
|
60
60
|
};
|
|
61
|
-
export declare const INBOXES_READ = "
|
|
61
|
+
export declare const INBOXES_READ = "inbox";
|
|
62
|
+
export declare const INBOXES_LISTED: {
|
|
63
|
+
op: string;
|
|
64
|
+
};
|
|
62
65
|
export declare const COMPLETE_ROOMS: ReadonlySet<string>;
|
|
63
66
|
export declare function inboxRooms({ answer }: ObservedRead): readonly string[] | null;
|
|
64
67
|
export declare function readinessOf(facts: ReadinessFacts): ReadinessShown;
|
package/dist/readiness.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readiness.d.ts","sourceRoot":"","sources":["../src/readiness.ts"],"names":[],"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AuC,CAAC;AAEvF,wBAAgB,UAAU,CAAC,EAAE,MAAM,EAAE,EAAE,YAAY,GAAG,SAAS,MAAM,EAAE,GAAG,IAAI,CAI7E;AAQD,wBAAgB,WAAW,CAAC,KAAK,EAAE,cAAc,GAAG,cAAc,CAsBjE"}
|
package/dist/readiness.js
CHANGED
package/dist/reads.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type CallResult } from './outcome.js';
|
|
2
2
|
import type { Recovery } from './recovery.js';
|
|
3
3
|
import type { Attempt, Retries } from './retried.js';
|
|
4
|
+
import type { ChangedRead } from './adapter.js';
|
|
4
5
|
import type { Connection, RuntimeDatabase } from './tables.js';
|
|
5
6
|
export declare const READ_TABLES: readonly string[];
|
|
6
7
|
export type ReadAt = {
|
|
@@ -16,6 +17,7 @@ export type ObservedRead = {
|
|
|
16
17
|
export type ReadAnswers = {
|
|
17
18
|
watch(name: string, input: unknown, deliver: (read: ObservedRead) => void): () => void;
|
|
18
19
|
again(led?: Promise<unknown>): void;
|
|
20
|
+
changed(reads: readonly ChangedRead[]): void;
|
|
19
21
|
reopened(): void;
|
|
20
22
|
};
|
|
21
23
|
export type ReadAnswersOptions = {
|
package/dist/reads.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reads.d.ts","sourceRoot":"","sources":["../src/reads.ts"],"names":[],"mappings":"AAEA,OAAO,EAA6B,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE/D,eAAO,MAAM,WAAW,EAAE,SAAS,MAAM,EAExC,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,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,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,CA4KpE"}
|
package/dist/reads.js
CHANGED
|
@@ -16,6 +16,13 @@ export function readsOfOtherBuildsForgotten(connection, build) {
|
|
|
16
16
|
connection.run('DELETE FROM read_answers WHERE build <> ?', [build]);
|
|
17
17
|
return null;
|
|
18
18
|
}
|
|
19
|
+
function named(read, changed) {
|
|
20
|
+
const asked = read.asked;
|
|
21
|
+
return (read.at.name === changed.name &&
|
|
22
|
+
asked !== null &&
|
|
23
|
+
typeof asked === 'object' &&
|
|
24
|
+
Object.entries(changed.input).every(([field, value]) => asked[field] === value));
|
|
25
|
+
}
|
|
19
26
|
function answered(result) {
|
|
20
27
|
return result.kind === 'action' && answeredResult(result.result);
|
|
21
28
|
}
|
|
@@ -25,14 +32,25 @@ export function readAnswers(options) {
|
|
|
25
32
|
const leading = new Set(options.leading);
|
|
26
33
|
const reads = new Map();
|
|
27
34
|
function leads(read) {
|
|
28
|
-
|
|
35
|
+
const op = read.asked?.op;
|
|
36
|
+
return (leading.has(read.at.name) || (typeof op === 'string' && leading.has(`${read.at.name}.${op}`)));
|
|
37
|
+
}
|
|
38
|
+
function kept(name, input) {
|
|
39
|
+
if (unkept.has(name))
|
|
40
|
+
return false;
|
|
41
|
+
const { op, ...named } = (input ?? {});
|
|
42
|
+
if (typeof op !== 'string')
|
|
43
|
+
return true;
|
|
44
|
+
const opName = `${name}.${op}`;
|
|
45
|
+
return (!unkept.has(opName) &&
|
|
46
|
+
!Object.keys(named).some((field) => named[field] !== undefined && unkept.has(`${opName} ${field}`)));
|
|
29
47
|
}
|
|
30
48
|
function show(read, shown) {
|
|
31
49
|
read.shown = shown;
|
|
32
50
|
for (const deliver of read.observers)
|
|
33
51
|
deliver(shown);
|
|
34
52
|
}
|
|
35
|
-
async function
|
|
53
|
+
async function keep(read, answer) {
|
|
36
54
|
if (!read.shown.kept || options.full())
|
|
37
55
|
return;
|
|
38
56
|
await database.ask({ kind: 'read.keep', ...read.at, answer }).catch((error) => {
|
|
@@ -64,7 +82,7 @@ export function readAnswers(options) {
|
|
|
64
82
|
if (text === read.text && read.shown.failure === null)
|
|
65
83
|
return;
|
|
66
84
|
read.text = text;
|
|
67
|
-
await
|
|
85
|
+
await keep(read, text);
|
|
68
86
|
await led;
|
|
69
87
|
if (!options.closed())
|
|
70
88
|
show(read, { ...read.shown, answer, failure: null });
|
|
@@ -109,7 +127,7 @@ export function readAnswers(options) {
|
|
|
109
127
|
});
|
|
110
128
|
}
|
|
111
129
|
function opened(name, input, key) {
|
|
112
|
-
const held =
|
|
130
|
+
const held = kept(name, input);
|
|
113
131
|
const read = {
|
|
114
132
|
key,
|
|
115
133
|
at: { name, input: JSON.stringify(input ?? null), build },
|
|
@@ -162,6 +180,11 @@ export function readAnswers(options) {
|
|
|
162
180
|
if (!leads(read))
|
|
163
181
|
void ask(read, led);
|
|
164
182
|
},
|
|
183
|
+
changed(changed) {
|
|
184
|
+
for (const read of reads.values())
|
|
185
|
+
if (changed.some((one) => named(read, one)))
|
|
186
|
+
void ask(read);
|
|
187
|
+
},
|
|
165
188
|
reopened() {
|
|
166
189
|
for (const read of reads.values()) {
|
|
167
190
|
recovery.cancel(retrying(read));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reference-forms.d.ts","sourceRoot":"","sources":["../src/reference-forms.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,UAAU,EAAS,MAAM,aAAa,CAAC;AAuBrD,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGpD;AAuCD,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAuB7D"}
|