@agentshouse/mdruntime 0.1.0-ca6edc1abd618 → 0.1.0-ca92b54804c33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/adapter.d.ts +101 -70
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +3 -10
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +29 -47
- package/dist/bootstrap.d.ts +16 -14
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +272 -129
- package/dist/chain.d.ts +2 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/change.d.ts +1 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/client.d.ts +13 -9
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +54 -6
- package/dist/collection.d.ts +7 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +23 -17
- package/dist/compile.d.ts +1 -6
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +108 -243
- package/dist/connection.d.ts +14 -11
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +2264 -1933
- package/dist/context.d.ts +2 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +7 -0
- package/dist/conversation.d.ts +21 -17
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +405 -253
- package/dist/durability.d.ts +6 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/entry.d.ts +3 -2
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +18 -8
- package/dist/file.d.ts +2 -11
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +6 -4
- package/dist/host.d.ts +3 -7
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +26 -29
- package/dist/identity.d.ts +0 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +0 -3
- package/dist/index.d.ts +12 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/job.d.ts +14 -0
- package/dist/job.d.ts.map +1 -0
- package/dist/job.js +28 -0
- package/dist/live.d.ts +5 -4
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +62 -20
- package/dist/media.d.ts +8 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +218 -0
- package/dist/memory.d.ts +12 -5
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +216 -85
- package/dist/messages.d.ts +3 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +20 -19
- package/dist/model.d.ts +8 -10
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +5 -17
- package/dist/observation.d.ts +3 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +8 -3
- package/dist/outcome.d.ts +13 -5
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +16 -2
- package/dist/overlay.d.ts +1 -0
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +11 -0
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +4 -0
- package/dist/query.d.ts +8 -207
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +3 -505
- package/dist/reach.d.ts +18 -11
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +195 -126
- package/dist/react.d.ts +3 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/readiness.d.ts +3 -17
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +4 -10
- package/dist/recovery.d.ts +1 -0
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +35 -1
- package/dist/refresh.d.ts +7 -5
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +33 -5
- package/dist/replica.d.ts +10 -8
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +52 -20
- package/dist/room-draft.d.ts +21 -5
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +98 -51
- package/dist/rows.d.ts +18 -16
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +45 -153
- package/dist/save.d.ts +2 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +22 -13
- package/dist/search.d.ts +12 -63
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +9 -52
- package/dist/shared.d.ts +0 -1
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +0 -10
- package/dist/status.d.ts +4 -5
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +3 -7
- package/dist/store.d.ts +101 -61
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +153 -161
- package/dist/stored.d.ts +66 -55
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +341 -273
- package/dist/tables.d.ts +90 -63
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +174 -98
- package/dist/transfer.d.ts +0 -5
- package/dist/transfer.d.ts.map +1 -1
- package/dist/validation.d.ts +3 -4
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +42 -100
- package/dist/windows.d.ts +1 -12
- package/dist/windows.d.ts.map +1 -1
- package/dist/windows.js +2 -75
- package/dist/wire.d.ts +17 -8
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +5 -2
- package/package.json +2 -2
- package/dist/fence.d.ts +0 -6
- package/dist/fence.d.ts.map +0 -1
- package/dist/fence.js +0 -10
- package/dist/fulltext.d.ts +0 -27
- package/dist/fulltext.d.ts.map +0 -1
- package/dist/fulltext.js +0 -368
- package/dist/reads.d.ts +0 -11
- package/dist/reads.d.ts.map +0 -1
- package/dist/reads.js +0 -100
- package/dist/words.d.ts +0 -19
- package/dist/words.d.ts.map +0 -1
- package/dist/words.js +0 -150
package/dist/reach.js
CHANGED
|
@@ -6,7 +6,6 @@ import { failure, lockedRoom, ROOM_LOCKED, undeclared, UNREADABLE, } from './out
|
|
|
6
6
|
import { beneath } from './paths.js';
|
|
7
7
|
import { moveTarget, readParts, staleWrite, } from './room-draft.js';
|
|
8
8
|
import { documentKey } from './rows.js';
|
|
9
|
-
import { undeclaredSearch } from './search.js';
|
|
10
9
|
const UNHELD_TYPES = { collection: modelTypes(NO_MODEL), typedSelection: null };
|
|
11
10
|
function unconversed(name) {
|
|
12
11
|
return () => Promise.resolve(undeclared(name));
|
|
@@ -14,20 +13,26 @@ function unconversed(name) {
|
|
|
14
13
|
const NO_CONVERSATION = {
|
|
15
14
|
list: () => Promise.resolve([]),
|
|
16
15
|
read: (conversation) => Promise.resolve(unheldView(conversation)),
|
|
17
|
-
create: unconversed('
|
|
18
|
-
send: unconversed('
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
cancel: unconversed('conversation.cancel'),
|
|
24
|
-
delete: unconversed('conversation.delete'),
|
|
16
|
+
create: unconversed('conversations/create'),
|
|
17
|
+
send: unconversed('conversations/send'),
|
|
18
|
+
answer: unconversed('conversations/interaction/answer'),
|
|
19
|
+
interrupt: unconversed('conversations/interrupt'),
|
|
20
|
+
kill: unconversed('conversations/kill'),
|
|
21
|
+
delete: unconversed('conversations/delete'),
|
|
25
22
|
};
|
|
26
23
|
const NO_CHAT_DRAFT = {
|
|
27
24
|
write: () => Promise.resolve(),
|
|
28
25
|
prepend: () => Promise.resolve(),
|
|
29
26
|
discard: () => Promise.resolve(),
|
|
30
27
|
};
|
|
28
|
+
function areasOf(reach) {
|
|
29
|
+
return reach.areas ?? [];
|
|
30
|
+
}
|
|
31
|
+
function fenced(reach, room, path) {
|
|
32
|
+
return areasOf(reach).some((area) => area.room === room &&
|
|
33
|
+
beneath(area.path, path) &&
|
|
34
|
+
!area.open.some((open) => beneath(open, path)));
|
|
35
|
+
}
|
|
31
36
|
export function holds(reach, room) {
|
|
32
37
|
return (reach === null ||
|
|
33
38
|
reach.rooms.includes(room) ||
|
|
@@ -48,8 +53,9 @@ export function governs(reach, room) {
|
|
|
48
53
|
}
|
|
49
54
|
function covers(reach, room, path) {
|
|
50
55
|
return (reach === null ||
|
|
51
|
-
reach
|
|
52
|
-
|
|
56
|
+
(!fenced(reach, room, path) &&
|
|
57
|
+
(reach.rooms.includes(room) ||
|
|
58
|
+
reach.documents.some((document) => document.room === room && document.path === path))));
|
|
53
59
|
}
|
|
54
60
|
function conversing(reach) {
|
|
55
61
|
return reach === null || reach.conversations;
|
|
@@ -62,6 +68,9 @@ export function planReach(reach) {
|
|
|
62
68
|
documents: [
|
|
63
69
|
...new Set(reach.documents.map(({ room, path }) => documentKey(room, path))),
|
|
64
70
|
].sort(),
|
|
71
|
+
areas: areasOf(reach)
|
|
72
|
+
.map(({ room, path, open }) => ({ room, path, open: [...new Set(open)].sort() }))
|
|
73
|
+
.sort((left, right) => documentKey(left.room, left.path) < documentKey(right.room, right.path) ? -1 : 1),
|
|
65
74
|
};
|
|
66
75
|
}
|
|
67
76
|
function roomsWithin(reach, rooms) {
|
|
@@ -110,7 +119,8 @@ function savedWithin(reach, room, result) {
|
|
|
110
119
|
function statusWithin(reach, status) {
|
|
111
120
|
return {
|
|
112
121
|
...status,
|
|
113
|
-
attentionRequired: status.attentionRequired.filter((entry) =>
|
|
122
|
+
attentionRequired: status.attentionRequired.filter((entry) => covers(reach, entry.room, entry.path)),
|
|
123
|
+
unsent: status.unsent.filter((change) => covers(reach, change.room, change.path)),
|
|
114
124
|
};
|
|
115
125
|
}
|
|
116
126
|
function queueWithin(reach, room, entries) {
|
|
@@ -127,18 +137,24 @@ function queueWithin(reach, room, entries) {
|
|
|
127
137
|
});
|
|
128
138
|
}
|
|
129
139
|
function unreached(room) {
|
|
130
|
-
return runtimeError('room
|
|
140
|
+
return runtimeError('unknown-room', `Unknown Room ${room}`);
|
|
131
141
|
}
|
|
132
142
|
function lockedError(room) {
|
|
133
143
|
return runtimeError(ROOM_LOCKED, `${room} is locked until House confirms its access`, true);
|
|
134
144
|
}
|
|
135
145
|
function deviceUnreached() {
|
|
136
|
-
return runtimeError('device-unreached', 'Only the panel
|
|
146
|
+
return runtimeError('device-unreached', 'Only the panel reaches this device');
|
|
147
|
+
}
|
|
148
|
+
const ATTACH_REQUIRED = 'attach-required';
|
|
149
|
+
function attachRequired() {
|
|
150
|
+
return runtimeError(ATTACH_REQUIRED, 'App code takes a file in with binaryFile.attach');
|
|
151
|
+
}
|
|
152
|
+
function carriesFile(parts) {
|
|
153
|
+
return parts !== null && typeof parts === 'object' && Object.hasOwn(parts, 'file');
|
|
137
154
|
}
|
|
138
|
-
export function narrowed(runtime, given,
|
|
155
|
+
export function narrowed(runtime, given, port) {
|
|
139
156
|
const { md, watch } = runtime;
|
|
140
157
|
let reach = given;
|
|
141
|
-
let port = told;
|
|
142
158
|
const open = new Set();
|
|
143
159
|
function following(begin, locking = false) {
|
|
144
160
|
let stop = begin();
|
|
@@ -154,70 +170,123 @@ export function narrowed(runtime, given, told) {
|
|
|
154
170
|
stop();
|
|
155
171
|
};
|
|
156
172
|
}
|
|
157
|
-
const unlocking = (rooms) => {
|
|
158
|
-
const
|
|
159
|
-
return
|
|
160
|
-
? null
|
|
161
|
-
: { pending: locked.map((room) => ({ room, awaits: 'unlock' })) };
|
|
173
|
+
const unlocking = (rooms, locked) => {
|
|
174
|
+
const held = (rooms ?? []).filter((room) => locked.includes(room));
|
|
175
|
+
return held.length === 0 ? null : { pending: held.map((room) => ({ room, awaits: 'unlock' })) };
|
|
162
176
|
};
|
|
163
|
-
const unlocked = (entries) => entries.filter((entry) => !
|
|
164
|
-
const intoLocked = (held) =>
|
|
165
|
-
|
|
177
|
+
const unlocked = (entries, locked) => entries.filter((entry) => !locked.includes(entry.room));
|
|
178
|
+
const intoLocked = async (held) => {
|
|
179
|
+
for (const move of held) {
|
|
180
|
+
if (move?.room !== undefined && (await runtime.locked(move.room)))
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
return false;
|
|
184
|
+
};
|
|
185
|
+
function ordered(deliver) {
|
|
186
|
+
let open = true;
|
|
187
|
+
let shown = Promise.resolve();
|
|
188
|
+
return {
|
|
189
|
+
push(making) {
|
|
190
|
+
shown = shown.then(() => making.then((value) => {
|
|
191
|
+
if (open)
|
|
192
|
+
deliver(value);
|
|
193
|
+
}, () => { }), () => { });
|
|
194
|
+
},
|
|
195
|
+
stop() {
|
|
196
|
+
open = false;
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
function unlockedWatch(topic, input, deliver, fail, within) {
|
|
201
|
+
const shown = ordered(deliver);
|
|
202
|
+
const stop = watch(topic, input, (message) => {
|
|
203
|
+
shown.push(runtime.lockedRooms().then((locked) => within(message, locked)));
|
|
204
|
+
}, fail);
|
|
205
|
+
return () => {
|
|
206
|
+
shown.stop();
|
|
207
|
+
stop();
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
function lockedFirst(room, start, shut) {
|
|
211
|
+
let open = true;
|
|
212
|
+
let stop = () => { };
|
|
213
|
+
void (async () => {
|
|
214
|
+
const closed = !holds(reach, room) || (await runtime.locked(room));
|
|
215
|
+
if (!open)
|
|
216
|
+
return;
|
|
217
|
+
if (closed)
|
|
218
|
+
shut();
|
|
219
|
+
else
|
|
220
|
+
stop = start();
|
|
221
|
+
})();
|
|
222
|
+
return () => {
|
|
223
|
+
open = false;
|
|
224
|
+
stop();
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
const within = (topic, input, deliver, fail) => {
|
|
166
228
|
if (topic === 'rooms') {
|
|
167
|
-
return following(() => watch(topic, input, (rooms) => deliver(roomsWithin(reach, rooms))));
|
|
229
|
+
return following(() => watch(topic, input, (rooms) => deliver(roomsWithin(reach, rooms)), fail));
|
|
168
230
|
}
|
|
169
231
|
if (topic === 'readiness') {
|
|
170
232
|
return following(() => runtime.watchReadiness(port, reach, deliver));
|
|
171
233
|
}
|
|
172
234
|
if (topic === 'sync-status') {
|
|
173
|
-
return following(() =>
|
|
174
|
-
const
|
|
175
|
-
|
|
235
|
+
return following(() => unlockedWatch(topic, input, deliver, fail, (status, locked) => {
|
|
236
|
+
const shown = statusWithin(reach, status);
|
|
237
|
+
return { ...shown, attentionRequired: unlocked(shown.attentionRequired, locked) };
|
|
176
238
|
}), true);
|
|
177
239
|
}
|
|
178
240
|
if (topic === 'room-drafts') {
|
|
179
|
-
return following(() =>
|
|
241
|
+
return following(() => unlockedWatch(topic, input, deliver, fail, (drafts, locked) => unlocked(draftsWithin(reach, drafts), locked)), true);
|
|
180
242
|
}
|
|
181
243
|
if (topic === 'queue') {
|
|
182
244
|
const room = input[0];
|
|
183
|
-
return following(() =>
|
|
184
|
-
if (!holds(reach, room) || runtime.locked(room)) {
|
|
185
|
-
deliver([]);
|
|
186
|
-
return () => { };
|
|
187
|
-
}
|
|
188
|
-
return watch(topic, input, (entries) => deliver(queueWithin(reach, room, entries)));
|
|
189
|
-
}, true);
|
|
245
|
+
return following(() => lockedFirst(room, () => watch(topic, input, (entries) => deliver(queueWithin(reach, room, entries)), fail), () => deliver([])), true);
|
|
190
246
|
}
|
|
191
247
|
if (topic === 'query') {
|
|
192
|
-
const
|
|
248
|
+
const planning = runtime.plan(input[0], reach);
|
|
193
249
|
let held = null;
|
|
194
250
|
return following(() => {
|
|
195
|
-
const locked = unlocking(plan.rooms);
|
|
196
|
-
if (locked !== null) {
|
|
197
|
-
const answer = { result: locked, keys: [] };
|
|
198
|
-
if (held === null || changeOf(held, answer) !== null)
|
|
199
|
-
deliver(answer);
|
|
200
|
-
held = digestOf(answer);
|
|
201
|
-
return () => { };
|
|
202
|
-
}
|
|
203
|
-
let first = true;
|
|
204
251
|
let open = true;
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
252
|
+
let stop = () => { };
|
|
253
|
+
void (async () => {
|
|
254
|
+
const plan = await planning;
|
|
255
|
+
const locked = await runtime.lockedRooms();
|
|
256
|
+
if (!open)
|
|
257
|
+
return;
|
|
258
|
+
const pending = unlocking(plan.rooms, locked);
|
|
259
|
+
if (pending !== null) {
|
|
260
|
+
const answer = { result: pending, keys: [] };
|
|
261
|
+
if (held === null || changeOf(held, answer) !== null)
|
|
262
|
+
deliver(answer);
|
|
263
|
+
held = digestOf(answer);
|
|
209
264
|
return;
|
|
210
265
|
}
|
|
211
|
-
first =
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
266
|
+
let first = true;
|
|
267
|
+
const heard = (message) => {
|
|
268
|
+
if (!first) {
|
|
269
|
+
held = digestApplied(held, message);
|
|
270
|
+
deliver(message);
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
first = false;
|
|
274
|
+
const change = held === null ? message : changeOf(held, message);
|
|
275
|
+
held = digestOf(message);
|
|
276
|
+
if (change !== null)
|
|
277
|
+
deliver(change);
|
|
278
|
+
};
|
|
279
|
+
const current = { ...plan, reach: planReach(reach), locked };
|
|
280
|
+
stop = runtime.watchPlan(current, (message) => {
|
|
281
|
+
if (open)
|
|
282
|
+
heard(message);
|
|
283
|
+
}, (error) => {
|
|
284
|
+
if (open)
|
|
285
|
+
fail(error);
|
|
286
|
+
});
|
|
287
|
+
})().catch((error) => {
|
|
219
288
|
if (open)
|
|
220
|
-
|
|
289
|
+
fail(error);
|
|
221
290
|
});
|
|
222
291
|
return () => {
|
|
223
292
|
open = false;
|
|
@@ -228,7 +297,7 @@ export function narrowed(runtime, given, told) {
|
|
|
228
297
|
if (topic === 'conversation') {
|
|
229
298
|
return following(() => {
|
|
230
299
|
if (conversing(reach))
|
|
231
|
-
return watch(topic, input, deliver);
|
|
300
|
+
return watch(topic, input, deliver, fail);
|
|
232
301
|
deliver(unheldView(input[0]));
|
|
233
302
|
return () => { };
|
|
234
303
|
});
|
|
@@ -236,16 +305,16 @@ export function narrowed(runtime, given, told) {
|
|
|
236
305
|
if (topic === 'conversations' || topic === 'agents') {
|
|
237
306
|
return following(() => {
|
|
238
307
|
if (conversing(reach))
|
|
239
|
-
return watch(topic, input, deliver);
|
|
308
|
+
return watch(topic, input, deliver, fail);
|
|
240
309
|
deliver([]);
|
|
241
310
|
return () => { };
|
|
242
311
|
});
|
|
243
312
|
}
|
|
244
|
-
return watch(topic, input, deliver);
|
|
313
|
+
return watch(topic, input, deliver, fail);
|
|
245
314
|
};
|
|
246
315
|
const files = new Map();
|
|
247
316
|
let handed = 0;
|
|
248
|
-
|
|
317
|
+
async function hand(reading) {
|
|
249
318
|
const answer = await reading;
|
|
250
319
|
if (answer.kind !== 'binary')
|
|
251
320
|
return answer;
|
|
@@ -253,78 +322,92 @@ export function narrowed(runtime, given, told) {
|
|
|
253
322
|
const file = String(handed);
|
|
254
323
|
files.set(file, answer.file);
|
|
255
324
|
return { ...answer, file };
|
|
256
|
-
}
|
|
325
|
+
}
|
|
257
326
|
const conversation = () => (conversing(reach) ? md.conversation : NO_CONVERSATION);
|
|
258
327
|
const chatDraft = () => (conversing(reach) ? md.chatDraft : NO_CHAT_DRAFT);
|
|
259
328
|
const view = {
|
|
260
329
|
...md,
|
|
261
|
-
rooms: () => roomsWithin(reach,
|
|
262
|
-
query: ((input) => {
|
|
263
|
-
const plan = runtime.plan(input, reach);
|
|
264
|
-
|
|
330
|
+
rooms: () => md.rooms().then((rooms) => roomsWithin(reach, rooms)),
|
|
331
|
+
query: (async (input) => {
|
|
332
|
+
const plan = await runtime.plan(input, reach);
|
|
333
|
+
const locked = await runtime.lockedRooms();
|
|
334
|
+
return unlocking(plan.rooms, locked) ?? runtime.query({ ...plan, locked });
|
|
265
335
|
}),
|
|
266
|
-
search: (input) =>
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
types(room) {
|
|
270
|
-
if (holds(reach, room) && runtime.locked(room))
|
|
336
|
+
search: (input) => runtime.search(input, reach),
|
|
337
|
+
async types(room) {
|
|
338
|
+
if (holds(reach, room) && (await runtime.locked(room)))
|
|
271
339
|
throw lockedError(room);
|
|
272
340
|
if (wholly(reach, room))
|
|
273
341
|
return md.types(room);
|
|
274
342
|
if (!holds(reach, room))
|
|
275
343
|
return structuredClone(UNHELD_TYPES);
|
|
276
|
-
|
|
277
|
-
return typesWithin(reach, listed, md.types(room));
|
|
344
|
+
return typesWithin(reach, await runtime.room(room), await md.types(room));
|
|
278
345
|
},
|
|
279
346
|
async save(room, roomDrafts, writtenBy) {
|
|
280
347
|
if (!holds(reach, room))
|
|
281
348
|
throw unreached(room);
|
|
282
|
-
if (runtime.locked(room))
|
|
349
|
+
if (await runtime.locked(room)) {
|
|
283
350
|
return { outcome: 'refused', code: ROOM_LOCKED, retryable: true };
|
|
351
|
+
}
|
|
284
352
|
const held = (await Promise.all(roomDrafts.map(({ path }) => md.roomDraft.read(room, path)))).map((draft) => draft?.parts.move);
|
|
285
353
|
const outside = roomDrafts.find(({ path }, at) => !covers(reach, room, path) || !moves(reach, room, held[at]));
|
|
286
354
|
if (outside !== undefined) {
|
|
287
355
|
return { outcome: 'refused', code: 'stale', retryable: false, file: outside.path };
|
|
288
356
|
}
|
|
289
|
-
if (intoLocked(held))
|
|
357
|
+
if (await intoLocked(held))
|
|
290
358
|
return { outcome: 'refused', code: ROOM_LOCKED, retryable: true };
|
|
291
359
|
return savedWithin(reach, room, await md.save(room, roomDrafts, writtenBy));
|
|
292
360
|
},
|
|
293
361
|
async saveParts(room, parts, writtenBy) {
|
|
294
362
|
if (!holds(reach, room))
|
|
295
363
|
throw unreached(room);
|
|
296
|
-
|
|
364
|
+
const filed = reach === null ? undefined : parts.find(({ parts: one }) => carriesFile(one));
|
|
365
|
+
if (filed !== undefined) {
|
|
366
|
+
return { outcome: 'refused', code: ATTACH_REQUIRED, retryable: false, file: filed.path };
|
|
367
|
+
}
|
|
368
|
+
if (await runtime.locked(room)) {
|
|
297
369
|
return { outcome: 'refused', code: ROOM_LOCKED, retryable: true };
|
|
298
|
-
|
|
370
|
+
}
|
|
371
|
+
const held = parts.map(({ path, parts: one }) => readParts(one, path).move);
|
|
299
372
|
if (parts.some(({ path }, at) => !covers(reach, room, path) || !moves(reach, room, held[at]))) {
|
|
300
373
|
throw unreached(room);
|
|
301
374
|
}
|
|
302
|
-
if (intoLocked(held))
|
|
375
|
+
if (await intoLocked(held))
|
|
303
376
|
return { outcome: 'refused', code: ROOM_LOCKED, retryable: true };
|
|
304
377
|
return savedWithin(reach, room, await md.saveParts(room, parts, writtenBy));
|
|
305
378
|
},
|
|
306
|
-
resolve(room, path, destination) {
|
|
307
|
-
const at = runtime.located(room, path, destination);
|
|
379
|
+
async resolve(room, path, destination) {
|
|
380
|
+
const at = await runtime.located(room, path, destination);
|
|
308
381
|
return at !== null && !covers(reach, at.room, at.path)
|
|
309
|
-
?
|
|
382
|
+
? UNREADABLE
|
|
310
383
|
: md.resolve(room, path, destination);
|
|
311
384
|
},
|
|
312
|
-
history: (room, path, query) => !covers(reach, room, path)
|
|
313
|
-
?
|
|
314
|
-
: runtime.locked(room)
|
|
315
|
-
?
|
|
385
|
+
history: async (room, path, query) => !covers(reach, room, path)
|
|
386
|
+
? failure({ kind: 'room-not-readable', locator: room })
|
|
387
|
+
: (await runtime.locked(room))
|
|
388
|
+
? lockedRoom(room)
|
|
316
389
|
: md.history(room, path, query),
|
|
317
390
|
binaryFile: {
|
|
318
|
-
read: (room, path, revision) => !covers(reach, room, path)
|
|
319
|
-
?
|
|
320
|
-
: runtime.locked(room)
|
|
321
|
-
?
|
|
391
|
+
read: async (room, path, revision) => !covers(reach, room, path)
|
|
392
|
+
? failure({ kind: 'room-not-readable', locator: room })
|
|
393
|
+
: (await runtime.locked(room))
|
|
394
|
+
? lockedRoom(room)
|
|
322
395
|
: hand(md.binaryFile.read(room, path, revision)),
|
|
323
|
-
link: (room, path, revision) => !covers(reach, room, path)
|
|
324
|
-
?
|
|
325
|
-
: runtime.locked(room)
|
|
326
|
-
?
|
|
396
|
+
link: async (room, path, revision) => !covers(reach, room, path)
|
|
397
|
+
? failure({ kind: 'room-not-readable', locator: room })
|
|
398
|
+
: (await runtime.locked(room))
|
|
399
|
+
? lockedRoom(room)
|
|
327
400
|
: md.binaryFile.link(room, path, revision),
|
|
401
|
+
show: async (room, path, revision) => !covers(reach, room, path)
|
|
402
|
+
? failure({ kind: 'room-not-readable', locator: room })
|
|
403
|
+
: (await runtime.locked(room))
|
|
404
|
+
? lockedRoom(room)
|
|
405
|
+
: hand(md.binaryFile.show(room, path, revision)),
|
|
406
|
+
attach: async (room, file) => !wholly(reach, room)
|
|
407
|
+
? failure({ kind: 'room-not-readable', locator: room })
|
|
408
|
+
: (await runtime.locked(room))
|
|
409
|
+
? lockedRoom(room)
|
|
410
|
+
: md.binaryFile.attach(room, file),
|
|
328
411
|
async part(file, part) {
|
|
329
412
|
const key = files.get(file);
|
|
330
413
|
if (key === undefined)
|
|
@@ -336,40 +419,37 @@ export function narrowed(runtime, given, told) {
|
|
|
336
419
|
},
|
|
337
420
|
},
|
|
338
421
|
reached: async (room, roomVersion, path) => (path === undefined ? wholly(reach, room) : covers(reach, room, path)) &&
|
|
339
|
-
!runtime.locked(room) &&
|
|
422
|
+
!(await runtime.locked(room)) &&
|
|
340
423
|
(await md.reached(room, roomVersion, path)),
|
|
341
424
|
log: () => (reach === null ? md.log() : ''),
|
|
342
425
|
cleanUp: () => (reach === null ? md.cleanUp() : Promise.reject(deviceUnreached())),
|
|
426
|
+
unsent: () => (reach === null ? md.unsent() : Promise.reject(deviceUnreached())),
|
|
427
|
+
reset: () => (reach === null ? md.reset() : Promise.reject(deviceUnreached())),
|
|
343
428
|
roomDraft: {
|
|
344
|
-
list: () => md.roomDraft.list()
|
|
429
|
+
list: async () => unlocked(draftsWithin(reach, await md.roomDraft.list()), await runtime.lockedRooms()),
|
|
345
430
|
async read(room, path) {
|
|
346
431
|
if (!covers(reach, room, path))
|
|
347
432
|
return null;
|
|
348
|
-
if (runtime.locked(room))
|
|
433
|
+
if (await runtime.locked(room))
|
|
349
434
|
throw lockedError(room);
|
|
350
435
|
return shownDraft(reach, await md.roomDraft.read(room, path));
|
|
351
436
|
},
|
|
352
|
-
write(room, path, revision, parts, next) {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
return Promise.reject(error);
|
|
364
|
-
}
|
|
365
|
-
return md.roomDraft
|
|
366
|
-
.write(room, path, revision, parts, next)
|
|
367
|
-
.then((written) => writeWithin(reach, written));
|
|
437
|
+
async write(room, path, revision, parts, next) {
|
|
438
|
+
if (reach !== null && carriesFile(parts))
|
|
439
|
+
throw attachRequired();
|
|
440
|
+
const move = readParts(parts, path).move;
|
|
441
|
+
if (!covers(reach, room, path) || !moves(reach, room, move))
|
|
442
|
+
throw unreached(room);
|
|
443
|
+
if (await runtime.locked(room))
|
|
444
|
+
throw lockedError(room);
|
|
445
|
+
if (await intoLocked([move]))
|
|
446
|
+
throw lockedError(move.room);
|
|
447
|
+
return writeWithin(reach, await md.roomDraft.write(room, path, revision, parts, next));
|
|
368
448
|
},
|
|
369
449
|
async discard(room, path, revision) {
|
|
370
450
|
if (!covers(reach, room, path))
|
|
371
451
|
return staleWrite(null);
|
|
372
|
-
if (runtime.locked(room))
|
|
452
|
+
if (await runtime.locked(room))
|
|
373
453
|
throw lockedError(room);
|
|
374
454
|
return writeWithin(reach, await md.roomDraft.discard(room, path, revision));
|
|
375
455
|
},
|
|
@@ -379,15 +459,9 @@ export function narrowed(runtime, given, told) {
|
|
|
379
459
|
read: (id, options) => conversation().read(id, options),
|
|
380
460
|
create: (input) => conversation().create(input),
|
|
381
461
|
send: (id, operation, draft) => conversation().send(id, operation, draft),
|
|
382
|
-
attach: (room, file) => !wholly(reach, room)
|
|
383
|
-
? Promise.resolve(failure({ kind: 'room-not-readable', locator: room }))
|
|
384
|
-
: runtime.locked(room)
|
|
385
|
-
? Promise.resolve(lockedRoom(room))
|
|
386
|
-
: conversation().attach(room, file),
|
|
387
462
|
answer: (id, answer) => conversation().answer(id, answer),
|
|
388
463
|
interrupt: (id) => conversation().interrupt(id),
|
|
389
464
|
kill: (id) => conversation().kill(id),
|
|
390
|
-
cancel: (id, turn) => conversation().cancel(id, turn),
|
|
391
465
|
delete: (id) => conversation().delete(id),
|
|
392
466
|
},
|
|
393
467
|
chatDraft: {
|
|
@@ -405,10 +479,5 @@ export function narrowed(runtime, given, told) {
|
|
|
405
479
|
for (const restart of [...open])
|
|
406
480
|
restart();
|
|
407
481
|
},
|
|
408
|
-
facts(next) {
|
|
409
|
-
port = next;
|
|
410
|
-
for (const restart of [...open])
|
|
411
|
-
restart();
|
|
412
|
-
},
|
|
413
482
|
};
|
|
414
483
|
}
|
package/dist/react.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import type { DocumentQuery, GroupQuery } from '@agentshouse/mdmodel';
|
|
1
2
|
import type { MdRuntimeClient } from './client.js';
|
|
2
3
|
import type { AppRoom, ConnectionRefusal, SavedRoomDraft, SaveResult } from './connection.js';
|
|
3
4
|
import type { Member, ServiceMode } from './adapter.js';
|
|
4
5
|
import type { ConversationAgent, ConversationEntry, ConversationOptions, ConversationView } from './conversation.js';
|
|
5
6
|
import { type RuntimeError } from './failure.js';
|
|
6
7
|
import type { QueueEntry } from './outcome.js';
|
|
7
|
-
import type {
|
|
8
|
+
import type { DocumentResult, GroupResult, PendingResult } from './query.js';
|
|
8
9
|
import type { Readiness } from './readiness.js';
|
|
9
10
|
import type { RoomDraft, RoomDraftParts } from './room-draft.js';
|
|
10
11
|
import type { SyncStatus } from './status.js';
|
|
@@ -23,6 +24,7 @@ export declare function useObserve(client: Client, topic: 'storage-loss'): Obser
|
|
|
23
24
|
export declare function useObserve(client: Client, topic: 'sync-status'): Observed<SyncStatus>;
|
|
24
25
|
export declare function useObserve(client: Client, topic: 'service-mode'): Observed<ServiceMode>;
|
|
25
26
|
export declare function useObserve(client: Client, topic: 'member'): Observed<Member | null>;
|
|
27
|
+
export declare function useObserve(client: Client, topic: 'authority-changes'): Observed<number>;
|
|
26
28
|
export declare function useObserve(client: Client, topic: 'query', query: DocumentQuery): Observed<DocumentResult | PendingResult>;
|
|
27
29
|
export declare function useObserve(client: Client, topic: 'query', query: GroupQuery): Observed<GroupResult | PendingResult>;
|
|
28
30
|
export declare function useObserve(client: Client, topic: 'queue', locator: string): Observed<readonly QueueEntry[]>;
|
package/dist/react.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC9F,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAU,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAEzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC9F,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAU,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAEzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO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,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,GAAG,QAAQ,CAAC,SAAS,iBAAiB,EAAE,CAAC,CAAC;AAsCpG,MAAM,MAAM,MAAM,GAAG;IACnB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI,CAAC;IACtC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACpF,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,cAAc,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACvF,CAAC;AAMF,wBAAgB,OAAO,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CA8BvD"}
|
package/dist/readiness.d.ts
CHANGED
|
@@ -1,46 +1,33 @@
|
|
|
1
1
|
import type { Open } from './open.js';
|
|
2
2
|
export type CodeAvailability = Open<'stored' | 'absent'>;
|
|
3
|
-
export type RoomPreparation = Open<'complete' | 'acquiring' | 'preparing' | '
|
|
3
|
+
export type RoomPreparation = Open<'complete' | 'acquiring' | 'preparing' | 'unadmitted'>;
|
|
4
4
|
export type RoomCoverage = {
|
|
5
5
|
readonly room: string;
|
|
6
6
|
readonly state: RoomPreparation;
|
|
7
7
|
};
|
|
8
8
|
export type ConversationCoverage = Open<'complete' | 'acquiring' | 'undeclared'>;
|
|
9
|
-
export type SearchObligation = Open<'required' | 'unused'>;
|
|
10
9
|
export type TargetCoverage = {
|
|
11
10
|
readonly complete: boolean;
|
|
12
11
|
readonly listed: boolean;
|
|
13
12
|
readonly rooms: readonly RoomCoverage[];
|
|
14
13
|
readonly conversations: ConversationCoverage;
|
|
15
|
-
readonly search: SearchObligation;
|
|
16
14
|
};
|
|
17
15
|
export type Persistence = Open<'granted' | 'denied' | 'unavailable'>;
|
|
18
16
|
export type Durability = Open<'persistent' | 'best-effort'>;
|
|
19
17
|
export type ConnectionAvailability = Open<'connected' | 'connecting' | 'unreachable'>;
|
|
20
18
|
export type HouseOutcome = Open<'open' | 'write-halted' | 'refused'>;
|
|
21
19
|
export type Space = Open<'full'>;
|
|
22
|
-
export type
|
|
23
|
-
readonly room: string;
|
|
24
|
-
readonly name: string;
|
|
25
|
-
readonly file: string;
|
|
26
|
-
readonly rule: string;
|
|
27
|
-
readonly location: string | null;
|
|
28
|
-
};
|
|
29
|
-
export type InstallationStep = Open<'listing' | 'downloading' | 'writing' | 'replaying'>;
|
|
30
|
-
export type InstallationPause = Open<'hidden'>;
|
|
20
|
+
export type InstallationStep = Open<'downloading' | 'writing' | 'replaying'>;
|
|
31
21
|
export type InstallationAmount = {
|
|
32
22
|
readonly done: number;
|
|
33
23
|
readonly total: number;
|
|
34
24
|
};
|
|
35
25
|
export type Installation = {
|
|
36
26
|
readonly step: InstallationStep | null;
|
|
37
|
-
readonly paused: InstallationPause | null;
|
|
38
27
|
readonly rooms: InstallationAmount;
|
|
39
|
-
readonly parts: InstallationAmount;
|
|
40
28
|
readonly bytes: InstallationAmount;
|
|
41
|
-
readonly received: InstallationAmount;
|
|
42
29
|
};
|
|
43
|
-
export type ReadinessStatus = Open<'preparing' | 'paused' | '
|
|
30
|
+
export type ReadinessStatus = Open<'preparing' | 'paused' | 'ready' | 'lost'>;
|
|
44
31
|
export type Readiness = {
|
|
45
32
|
readonly status: ReadinessStatus;
|
|
46
33
|
readonly ready: boolean;
|
|
@@ -53,7 +40,6 @@ export type Readiness = {
|
|
|
53
40
|
readonly house: HouseOutcome;
|
|
54
41
|
readonly space: Space | null;
|
|
55
42
|
readonly installation: Installation;
|
|
56
|
-
readonly refused: readonly RefusedRoom[];
|
|
57
43
|
readonly lost: boolean;
|
|
58
44
|
};
|
|
59
45
|
export type ReadinessFacts = Omit<Readiness, 'status' | 'ready' | 'usable' | 'durability' | 'coverage'> & {
|
package/dist/readiness.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readiness.d.ts","sourceRoot":"","sources":["../src/readiness.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAC;AAEzD,MAAM,MAAM,eAAe,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"readiness.d.ts","sourceRoot":"","sources":["../src/readiness.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAC;AAEzD,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,UAAU,GAAG,WAAW,GAAG,WAAW,GAAG,YAAY,CAAC,CAAC;AAE1F,MAAM,MAAM,YAAY,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAA;CAAE,CAAC;AAEtF,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,UAAU,GAAG,WAAW,GAAG,YAAY,CAAC,CAAC;AAEjF,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;IACxC,QAAQ,CAAC,aAAa,EAAE,oBAAoB,CAAC;CAC9C,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,GAAG,QAAQ,GAAG,aAAa,CAAC,CAAC;AAErE,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,YAAY,GAAG,aAAa,CAAC,CAAC;AA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,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,SAAS,EACT,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,YAAY,GAAG,UAAU,CAC1D,GAAG;IACF,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;IACpD,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;CAC/B,CAAC;AAIF,wBAAgB,WAAW,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS,CA2B5D"}
|
package/dist/readiness.js
CHANGED
|
@@ -1,27 +1,21 @@
|
|
|
1
1
|
const COMPLETE_ROOMS = new Set(['complete', 'unadmitted']);
|
|
2
|
-
const SETTLED_ROOMS = new Set([...COMPLETE_ROOMS, 'refused']);
|
|
3
2
|
export function readinessOf(facts) {
|
|
4
3
|
const { established, coverage: held, ...reported } = facts;
|
|
5
4
|
const settledConversations = held.conversations === 'complete' || held.conversations === 'undeclared';
|
|
6
5
|
const complete = held.listed &&
|
|
7
6
|
settledConversations &&
|
|
8
7
|
held.rooms.every((room) => COMPLETE_ROOMS.has(room.state));
|
|
9
|
-
const settled = held.listed &&
|
|
10
|
-
settledConversations &&
|
|
11
|
-
held.rooms.every((room) => SETTLED_ROOMS.has(room.state));
|
|
12
8
|
const coverage = { ...held, complete };
|
|
13
9
|
const stored = facts.code === 'stored';
|
|
14
10
|
const ready = stored && complete;
|
|
15
11
|
const usable = stored && (ready || established);
|
|
16
12
|
const status = ready
|
|
17
13
|
? 'ready'
|
|
18
|
-
: facts.space !== null
|
|
14
|
+
: facts.space !== null
|
|
19
15
|
? 'paused'
|
|
20
|
-
:
|
|
21
|
-
? '
|
|
22
|
-
:
|
|
23
|
-
? 'lost'
|
|
24
|
-
: 'preparing';
|
|
16
|
+
: facts.lost && !established
|
|
17
|
+
? 'lost'
|
|
18
|
+
: 'preparing';
|
|
25
19
|
return {
|
|
26
20
|
...reported,
|
|
27
21
|
coverage,
|