@agentshouse/mdruntime 0.1.0-cf6e25bcd52f6 → 0.1.0-cf85301a4a962
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 +21 -19
- package/dist/acceptance.d.ts +3 -0
- package/dist/acceptance.d.ts.map +1 -0
- package/dist/acceptance.js +299 -0
- package/dist/act-lanes.d.ts +30 -0
- package/dist/act-lanes.d.ts.map +1 -0
- package/dist/act-lanes.js +225 -0
- package/dist/actions.d.ts +26 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +346 -0
- package/dist/adapter.d.ts +215 -121
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +3 -11
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +20 -60
- package/dist/authored.d.ts +88 -0
- package/dist/authored.d.ts.map +1 -0
- package/dist/authored.js +347 -0
- package/dist/binary.d.ts +6 -2
- package/dist/binary.d.ts.map +1 -1
- package/dist/binary.js +10 -3
- package/dist/bootstrap.d.ts +15 -18
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +252 -158
- package/dist/cell.d.ts +6 -0
- package/dist/cell.d.ts.map +1 -0
- package/dist/cell.js +9 -0
- package/dist/chain.d.ts +3 -2
- package/dist/chain.d.ts.map +1 -1
- package/dist/chain.js +5 -2
- package/dist/change-set.d.ts +4 -0
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +6 -0
- package/dist/change.d.ts +7 -2
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +7 -2
- package/dist/chat-types.d.ts +3 -0
- package/dist/chat-types.d.ts.map +1 -0
- package/dist/chat-types.js +11 -0
- package/dist/client.d.ts +41 -25
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +58 -69
- package/dist/collection.d.ts +28 -7
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +35 -27
- package/dist/column.d.ts +5 -0
- package/dist/column.d.ts.map +1 -0
- package/dist/column.js +9 -0
- package/dist/compile.d.ts +10 -7
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +337 -347
- package/dist/connection.d.ts +6 -144
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +116 -5227
- package/dist/context.d.ts +2 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +7 -0
- package/dist/conversation-live.d.ts +149 -0
- package/dist/conversation-live.d.ts.map +1 -0
- package/dist/conversation-live.js +259 -0
- package/dist/conversation-row.d.ts +40 -0
- package/dist/conversation-row.d.ts.map +1 -0
- package/dist/conversation-row.js +66 -0
- package/dist/conversation.d.ts +79 -56
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +1016 -883
- package/dist/declaration.d.ts +10 -0
- package/dist/declaration.d.ts.map +1 -0
- package/dist/declaration.js +24 -0
- package/dist/discovery.d.ts +12 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +175 -0
- package/dist/download.d.ts +6 -0
- package/dist/download.d.ts.map +1 -0
- package/dist/download.js +42 -0
- package/dist/durability.d.ts +20 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +7 -0
- package/dist/entry.d.ts +17 -2
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +60 -21
- package/dist/expectation.d.ts +26 -13
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +72 -19
- package/dist/failure.d.ts +3 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +8 -0
- package/dist/figures.d.ts +49 -0
- package/dist/figures.d.ts.map +1 -0
- package/dist/figures.js +199 -0
- package/dist/file.d.ts +1 -1
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +3 -2
- package/dist/holdings.d.ts +29 -0
- package/dist/holdings.d.ts.map +1 -0
- package/dist/holdings.js +95 -0
- package/dist/host.d.ts +25 -8
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +130 -56
- package/dist/house-query.d.ts +24 -0
- package/dist/house-query.d.ts.map +1 -0
- package/dist/house-query.js +76 -0
- 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 +43 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -6
- package/dist/install.d.ts +60 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +537 -0
- package/dist/lifecycle.d.ts +7 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +290 -0
- package/dist/listing.d.ts +60 -0
- package/dist/listing.d.ts.map +1 -0
- package/dist/listing.js +168 -0
- package/dist/live.d.ts +23 -6
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +138 -39
- package/dist/loaded.d.ts +7 -0
- package/dist/loaded.d.ts.map +1 -0
- package/dist/loaded.js +46 -0
- package/dist/locks.d.ts +7 -0
- package/dist/locks.d.ts.map +1 -0
- package/dist/locks.js +34 -0
- package/dist/lost.d.ts +5 -0
- package/dist/lost.d.ts.map +1 -0
- package/dist/lost.js +49 -0
- package/dist/media.d.ts +20 -4
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +183 -39
- package/dist/memory.d.ts +21 -8
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +262 -109
- package/dist/messages.d.ts +40 -5
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +118 -39
- package/dist/modal.d.ts +2 -0
- package/dist/modal.d.ts.map +1 -0
- package/dist/modal.js +11 -0
- package/dist/model.d.ts +6 -13
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +6 -23
- package/dist/models.d.ts +10 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +153 -0
- package/dist/name.d.ts +0 -1
- package/dist/name.d.ts.map +1 -1
- package/dist/name.js +3 -7
- package/dist/observation.d.ts +30 -13
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +218 -81
- package/dist/online.d.ts +7 -0
- package/dist/online.d.ts.map +1 -0
- package/dist/online.js +29 -0
- package/dist/opened.d.ts +1 -1
- package/dist/opened.d.ts.map +1 -1
- package/dist/opened.js +5 -5
- package/dist/opening.d.ts +4 -0
- package/dist/opening.d.ts.map +1 -0
- package/dist/opening.js +69 -0
- package/dist/outcome.d.ts +28 -8
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +36 -3
- package/dist/overlay.d.ts +10 -5
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +48 -24
- package/dist/page-metadata.d.ts +8 -0
- package/dist/page-metadata.d.ts.map +1 -0
- package/dist/page-metadata.js +19 -0
- package/dist/parts.d.ts +6 -0
- package/dist/parts.d.ts.map +1 -0
- package/dist/parts.js +36 -0
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +22 -0
- package/dist/preparation.d.ts +46 -0
- package/dist/preparation.d.ts.map +1 -0
- package/dist/preparation.js +344 -0
- package/dist/presence.d.ts +58 -0
- package/dist/presence.d.ts.map +1 -0
- package/dist/presence.js +231 -0
- package/dist/queries.d.ts +16 -0
- package/dist/queries.d.ts.map +1 -0
- package/dist/queries.js +330 -0
- package/dist/query.d.ts +16 -212
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +3 -505
- package/dist/questions.d.ts +30 -0
- package/dist/questions.d.ts.map +1 -0
- package/dist/questions.js +117 -0
- package/dist/queue.d.ts +40 -0
- package/dist/queue.d.ts.map +1 -0
- package/dist/queue.js +480 -0
- package/dist/reach.d.ts +26 -15
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +350 -160
- package/dist/react.d.ts +21 -3
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +33 -1
- package/dist/read.d.ts +7 -0
- package/dist/read.d.ts.map +1 -0
- package/dist/read.js +17 -0
- package/dist/readiness.d.ts +23 -22
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +21 -20
- package/dist/reads.d.ts +38 -10
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +163 -85
- package/dist/recovery.d.ts +4 -0
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +59 -2
- 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 +7 -5
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +37 -9
- package/dist/refusal.d.ts +5 -0
- package/dist/refusal.d.ts.map +1 -0
- package/dist/refusal.js +55 -0
- package/dist/replica.d.ts +12 -18
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +68 -38
- package/dist/retried.d.ts +30 -0
- package/dist/retried.d.ts.map +1 -0
- package/dist/retried.js +72 -0
- package/dist/room-draft.d.ts +51 -12
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +368 -111
- package/dist/room-drafts.d.ts +24 -0
- package/dist/room-drafts.d.ts.map +1 -0
- package/dist/room-drafts.js +222 -0
- package/dist/room-list.d.ts +10 -0
- package/dist/room-list.d.ts.map +1 -0
- package/dist/room-list.js +45 -0
- package/dist/rows.d.ts +24 -22
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +63 -186
- package/dist/running.d.ts +5 -0
- package/dist/running.d.ts.map +1 -0
- package/dist/running.js +10 -0
- package/dist/runtime.d.ts +37 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +1 -0
- package/dist/save.d.ts +43 -86
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +332 -228
- package/dist/saves.d.ts +34 -0
- package/dist/saves.d.ts.map +1 -0
- package/dist/saves.js +463 -0
- package/dist/search.d.ts +12 -63
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +9 -52
- package/dist/seed.d.ts +11 -2
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +71 -1
- package/dist/shared.d.ts +1 -7
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +13 -105
- package/dist/shown.d.ts +35 -0
- package/dist/shown.d.ts.map +1 -0
- package/dist/shown.js +326 -0
- package/dist/socket/admission.d.ts +7 -0
- package/dist/socket/admission.d.ts.map +1 -0
- package/dist/socket/admission.js +39 -0
- package/dist/socket/answers.d.ts +6 -0
- package/dist/socket/answers.d.ts.map +1 -0
- package/dist/socket/answers.js +20 -0
- package/dist/socket/lanes.d.ts +28 -0
- package/dist/socket/lanes.d.ts.map +1 -0
- package/dist/socket/lanes.js +103 -0
- package/dist/socket/reads.d.ts +10 -0
- package/dist/socket/reads.d.ts.map +1 -0
- package/dist/socket/reads.js +31 -0
- package/dist/socket/session.d.ts +41 -0
- package/dist/socket/session.d.ts.map +1 -0
- package/dist/socket/session.js +26 -0
- package/dist/socket.d.ts +68 -0
- package/dist/socket.d.ts.map +1 -0
- package/dist/socket.js +165 -0
- package/dist/source.d.ts +61 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +95 -0
- package/dist/status.d.ts +0 -6
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +0 -6
- package/dist/store/installs.d.ts +30 -0
- package/dist/store/installs.d.ts.map +1 -0
- package/dist/store/installs.js +40 -0
- package/dist/store/readiness.d.ts +11 -0
- package/dist/store/readiness.d.ts.map +1 -0
- package/dist/store/readiness.js +68 -0
- package/dist/store/records.d.ts +229 -0
- package/dist/store/records.d.ts.map +1 -0
- package/dist/store/records.js +474 -0
- package/dist/store/room-held.d.ts +8 -0
- package/dist/store/room-held.d.ts.map +1 -0
- package/dist/store/room-held.js +17 -0
- package/dist/store/rooms-shown.d.ts +8 -0
- package/dist/store/rooms-shown.d.ts.map +1 -0
- package/dist/store/rooms-shown.js +13 -0
- package/dist/store/space.d.ts +11 -0
- package/dist/store/space.d.ts.map +1 -0
- package/dist/store/space.js +41 -0
- package/dist/store/watchers.d.ts +17 -0
- package/dist/store/watchers.d.ts.map +1 -0
- package/dist/store/watchers.js +56 -0
- package/dist/store/writes.d.ts +24 -0
- package/dist/store/writes.d.ts.map +1 -0
- package/dist/store/writes.js +125 -0
- package/dist/store.d.ts +125 -175
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +173 -419
- package/dist/stored.d.ts +88 -61
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +480 -251
- package/dist/surface.d.ts +94 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/surface.js +255 -0
- package/dist/sync.d.ts +21 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +557 -0
- package/dist/tables.d.ts +128 -102
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +209 -330
- package/dist/tallies.d.ts +18 -0
- package/dist/tallies.d.ts.map +1 -0
- package/dist/tallies.js +128 -0
- package/dist/transfer.d.ts +0 -5
- package/dist/transfer.d.ts.map +1 -1
- package/dist/validation.d.ts +5 -4
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +87 -105
- 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 +85 -14
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +37 -15
- package/package.json +4 -3
- package/dist/attempt.d.ts +0 -16
- package/dist/attempt.d.ts.map +0 -1
- package/dist/attempt.js +0 -70
- 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/log.d.ts +0 -5
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -14
- package/dist/words.d.ts +0 -19
- package/dist/words.d.ts.map +0 -1
- package/dist/words.js +0 -156
package/dist/reach.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import { QueryError } from '@agentshouse/mdmodel';
|
|
2
|
+
import { inboxRooms, INBOXES_READ } from './readiness.js';
|
|
3
|
+
import { selected, typesPrint } from './collection.js';
|
|
1
4
|
import { unheldView } from './conversation.js';
|
|
2
|
-
import { modelTypes, NO_MODEL } from './model.js';
|
|
3
|
-
import { changeOf, digestApplied, digestOf, observing, } from './observation.js';
|
|
4
|
-
import { runtimeError } from './failure.js';
|
|
5
|
-
import { failure, lockedRoom, ROOM_LOCKED, undeclared, UNREADABLE, } from './outcome.js';
|
|
5
|
+
import { modelResult, modelTypes, NO_MODEL } from './model.js';
|
|
6
|
+
import { changeOf, digestApplied, digestOf, observing, unchanged, } from './observation.js';
|
|
7
|
+
import { runtimeError, uncaught } from './failure.js';
|
|
8
|
+
import { absentBinary, failure, lockedRoom, ROOM_LOCKED, undeclared, UNREADABLE, } from './outcome.js';
|
|
6
9
|
import { beneath } from './paths.js';
|
|
7
10
|
import { moveTarget, readParts, staleWrite, } from './room-draft.js';
|
|
8
11
|
import { documentKey } from './rows.js';
|
|
9
|
-
import { undeclaredSearch } from './search.js';
|
|
10
12
|
const UNHELD_TYPES = { collection: modelTypes(NO_MODEL), typedSelection: null };
|
|
11
13
|
function unconversed(name) {
|
|
12
14
|
return () => Promise.resolve(undeclared(name));
|
|
@@ -14,33 +16,66 @@ function unconversed(name) {
|
|
|
14
16
|
const NO_CONVERSATION = {
|
|
15
17
|
list: () => Promise.resolve([]),
|
|
16
18
|
read: (conversation) => Promise.resolve(unheldView(conversation)),
|
|
17
|
-
create: unconversed('
|
|
18
|
-
send: unconversed('
|
|
19
|
-
answer: unconversed('
|
|
20
|
-
interrupt: unconversed('
|
|
21
|
-
kill: unconversed('
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
create: unconversed('conversations/create'),
|
|
20
|
+
send: unconversed('conversations/send'),
|
|
21
|
+
answer: unconversed('conversations/interaction/answer'),
|
|
22
|
+
interrupt: unconversed('conversations/interrupt'),
|
|
23
|
+
kill: unconversed('conversations/kill'),
|
|
24
|
+
delete: unconversed('conversations/delete'),
|
|
25
|
+
takeOut: unconversed('conversations/take-out'),
|
|
26
|
+
decide: unconversed('agent-functions/decide'),
|
|
27
|
+
rename: unconversed('conversations/rename'),
|
|
28
|
+
set: unconversed('conversations/set'),
|
|
29
|
+
retry: unconversed('conversations/retry'),
|
|
30
|
+
pin: () => Promise.resolve(),
|
|
31
|
+
openTurn: () => Promise.resolve(),
|
|
32
|
+
dismissSuggestion: () => Promise.resolve(),
|
|
33
|
+
attach: () => Promise.resolve(undeclared('conversation.attach')),
|
|
34
|
+
attachment: (link) => Promise.resolve(absentBinary(link)),
|
|
24
35
|
};
|
|
25
36
|
const NO_CHAT_DRAFT = {
|
|
26
37
|
write: () => Promise.resolve(),
|
|
27
38
|
prepend: () => Promise.resolve(),
|
|
39
|
+
append: () => Promise.resolve(),
|
|
28
40
|
discard: () => Promise.resolve(),
|
|
29
41
|
};
|
|
30
42
|
function areasOf(reach) {
|
|
31
43
|
return reach.areas ?? [];
|
|
32
44
|
}
|
|
33
|
-
function
|
|
34
|
-
return
|
|
45
|
+
export function queriedOf(reach, provided) {
|
|
46
|
+
return reach === null ? provided : (reach.queriesOnly ?? []);
|
|
47
|
+
}
|
|
48
|
+
export function queriedOnly(reach, provided, room) {
|
|
49
|
+
return queriedOf(reach, provided).some((queried) => queried.locator === room);
|
|
50
|
+
}
|
|
51
|
+
function queriedRoom({ name, locator, handle }) {
|
|
52
|
+
return {
|
|
53
|
+
name,
|
|
54
|
+
locator,
|
|
55
|
+
handle,
|
|
56
|
+
queriesOnly: true,
|
|
57
|
+
operations: { write: [], erase: [] },
|
|
58
|
+
replica: { selection: locator, admission: 'unavailable', offline: 'locked' },
|
|
59
|
+
model: modelResult(NO_MODEL, typesPrint),
|
|
60
|
+
typedSelection: null,
|
|
61
|
+
providerOwnedPaths: [],
|
|
62
|
+
authoredPaths: [],
|
|
63
|
+
roomVersion: null,
|
|
64
|
+
documents: 0,
|
|
65
|
+
synchronizationAvailable: false,
|
|
66
|
+
refusal: null,
|
|
67
|
+
locked: false,
|
|
68
|
+
};
|
|
35
69
|
}
|
|
36
70
|
function fenced(reach, room, path) {
|
|
37
|
-
return areasOf(reach).some((area) => area.room === room &&
|
|
71
|
+
return areasOf(reach).some((area) => area.room === room &&
|
|
72
|
+
beneath(area.path, path) &&
|
|
73
|
+
!area.open.some((open) => beneath(open, path)));
|
|
38
74
|
}
|
|
39
75
|
export function holds(reach, room) {
|
|
40
76
|
return (reach === null ||
|
|
41
77
|
reach.rooms.includes(room) ||
|
|
42
|
-
reach.documents.some((document) => document.room === room)
|
|
43
|
-
typedAreas(reach, room).length > 0);
|
|
78
|
+
reach.documents.some((document) => document.room === room));
|
|
44
79
|
}
|
|
45
80
|
function wholly(reach, room) {
|
|
46
81
|
return reach === null || reach.rooms.includes(room);
|
|
@@ -49,14 +84,11 @@ export function governs(reach, room) {
|
|
|
49
84
|
if (wholly(reach, room.locator)) {
|
|
50
85
|
return { collection: true, selection: room.typedSelection !== null };
|
|
51
86
|
}
|
|
52
|
-
const
|
|
53
|
-
const paths =
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
...typedAreas(reach, room.locator).map(({ path }) => path),
|
|
58
|
-
];
|
|
59
|
-
return { collection: paths.some((path) => !selected(path)), selection: paths.some(selected) };
|
|
87
|
+
const within = (path) => selected({ selection: room.typedSelection }, path);
|
|
88
|
+
const paths = reach.documents
|
|
89
|
+
.filter((document) => document.room === room.locator)
|
|
90
|
+
.map(({ path }) => path);
|
|
91
|
+
return { collection: paths.some((path) => !within(path)), selection: paths.some(within) };
|
|
60
92
|
}
|
|
61
93
|
function covers(reach, room, path) {
|
|
62
94
|
return (reach === null ||
|
|
@@ -67,6 +99,31 @@ function covers(reach, room, path) {
|
|
|
67
99
|
function conversing(reach) {
|
|
68
100
|
return reach === null || reach.conversations;
|
|
69
101
|
}
|
|
102
|
+
function roomsAwaited(error, reach) {
|
|
103
|
+
return error.code === 'unknown-type' && reach !== null && reach.rooms.length === 0;
|
|
104
|
+
}
|
|
105
|
+
function queriedIn(input, reach, provided) {
|
|
106
|
+
const rooms = input?.rooms;
|
|
107
|
+
return Array.isArray(rooms)
|
|
108
|
+
? rooms.find((room) => typeof room === 'string' && queriedOnly(reach, provided, room))
|
|
109
|
+
: undefined;
|
|
110
|
+
}
|
|
111
|
+
async function planInReach(runtime, input, reach, answered) {
|
|
112
|
+
const queried = queriedIn(input, reach, runtime.queried());
|
|
113
|
+
if (queried !== undefined) {
|
|
114
|
+
if (answered)
|
|
115
|
+
return null;
|
|
116
|
+
throw queriesOnlyError(queried);
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
return await runtime.plan(input, reach);
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
if (error instanceof QueryError && (answered || roomsAwaited(error, reach)))
|
|
123
|
+
return null;
|
|
124
|
+
throw error;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
70
127
|
export function planReach(reach) {
|
|
71
128
|
return reach === null
|
|
72
129
|
? null
|
|
@@ -76,12 +133,35 @@ export function planReach(reach) {
|
|
|
76
133
|
...new Set(reach.documents.map(({ room, path }) => documentKey(room, path))),
|
|
77
134
|
].sort(),
|
|
78
135
|
areas: areasOf(reach)
|
|
79
|
-
.map(({ room, path,
|
|
136
|
+
.map(({ room, path, open }) => ({ room, path, open: [...new Set(open)].sort() }))
|
|
80
137
|
.sort((left, right) => documentKey(left.room, left.path) < documentKey(right.room, right.path) ? -1 : 1),
|
|
81
138
|
};
|
|
82
139
|
}
|
|
83
|
-
function
|
|
84
|
-
|
|
140
|
+
function modelsOf(rooms, models) {
|
|
141
|
+
const named = new Set(rooms.flatMap(({ model, typedSelection }) => [model.types, typedSelection?.model.types]));
|
|
142
|
+
return Object.fromEntries(Object.entries(models).filter(([key]) => named.has(key)));
|
|
143
|
+
}
|
|
144
|
+
function roomsWithin(reach, provided, { rooms, models }) {
|
|
145
|
+
const within = rooms.filter((room) => wholly(reach, room.locator));
|
|
146
|
+
return {
|
|
147
|
+
rooms: [...within, ...queriedOf(reach, provided).map(queriedRoom)],
|
|
148
|
+
models: modelsOf(within, models),
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function roomsChangeWithin(reach, provided, { changed, removed, order, models }) {
|
|
152
|
+
const kept = changed.filter(([locator]) => wholly(reach, locator));
|
|
153
|
+
const within = {
|
|
154
|
+
changed: kept,
|
|
155
|
+
removed,
|
|
156
|
+
order: order === null
|
|
157
|
+
? null
|
|
158
|
+
: [
|
|
159
|
+
...order.filter((locator) => wholly(reach, locator)),
|
|
160
|
+
...queriedOf(reach, provided).map(({ locator }) => locator),
|
|
161
|
+
],
|
|
162
|
+
models: modelsOf(kept.map(([, room]) => room), models),
|
|
163
|
+
};
|
|
164
|
+
return unchanged(within) ? null : within;
|
|
85
165
|
}
|
|
86
166
|
function typesWithin(reach, room, types) {
|
|
87
167
|
if (room === undefined)
|
|
@@ -112,12 +192,13 @@ function writeWithin(reach, write) {
|
|
|
112
192
|
function savedWithin(reach, room, result) {
|
|
113
193
|
if (reach === null || result.outcome === 'saved')
|
|
114
194
|
return result;
|
|
115
|
-
const { file, location, referrers, ...refusal } = result;
|
|
195
|
+
const { file, location, line, referrers, ...refusal } = result;
|
|
116
196
|
const hidden = file !== undefined && !covers(reach, room, file);
|
|
117
197
|
return {
|
|
118
198
|
...refusal,
|
|
119
199
|
...(file === undefined || hidden ? {} : { file }),
|
|
120
200
|
...(location === undefined || hidden ? {} : { location }),
|
|
201
|
+
...(line === undefined || hidden ? {} : { line }),
|
|
121
202
|
...(referrers === undefined
|
|
122
203
|
? {}
|
|
123
204
|
: { referrers: referrers.filter((path) => covers(reach, room, path)) }),
|
|
@@ -126,7 +207,7 @@ function savedWithin(reach, room, result) {
|
|
|
126
207
|
function statusWithin(reach, status) {
|
|
127
208
|
return {
|
|
128
209
|
...status,
|
|
129
|
-
attentionRequired: status.attentionRequired.filter((entry) =>
|
|
210
|
+
attentionRequired: status.attentionRequired.filter((entry) => covers(reach, entry.room, entry.path)),
|
|
130
211
|
unsent: status.unsent.filter((change) => covers(reach, change.room, change.path)),
|
|
131
212
|
};
|
|
132
213
|
}
|
|
@@ -144,104 +225,194 @@ function queueWithin(reach, room, entries) {
|
|
|
144
225
|
});
|
|
145
226
|
}
|
|
146
227
|
function unreached(room) {
|
|
147
|
-
return runtimeError('room
|
|
228
|
+
return runtimeError('unknown-room', `Unknown Room ${room}`);
|
|
148
229
|
}
|
|
149
230
|
function lockedError(room) {
|
|
150
231
|
return runtimeError(ROOM_LOCKED, `${room} is locked until House confirms its access`, true);
|
|
151
232
|
}
|
|
152
233
|
function deviceUnreached() {
|
|
153
|
-
return runtimeError('device-unreached', 'Only the panel
|
|
234
|
+
return runtimeError('device-unreached', 'Only the panel reaches this device');
|
|
154
235
|
}
|
|
155
236
|
const ATTACH_REQUIRED = 'attach-required';
|
|
237
|
+
const QUERIES_ONLY = 'queries-only';
|
|
238
|
+
function queriesOnlyError(room) {
|
|
239
|
+
return runtimeError(QUERIES_ONLY, `${room} answers through queryHouse`);
|
|
240
|
+
}
|
|
156
241
|
function attachRequired() {
|
|
157
|
-
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');
|
|
158
243
|
}
|
|
159
244
|
function carriesFile(parts) {
|
|
160
245
|
return parts !== null && typeof parts === 'object' && Object.hasOwn(parts, 'file');
|
|
161
246
|
}
|
|
162
|
-
export function narrowed(runtime, given,
|
|
247
|
+
export function narrowed(runtime, given, attached) {
|
|
163
248
|
const { md, watch } = runtime;
|
|
164
249
|
let reach = given;
|
|
165
|
-
let port =
|
|
250
|
+
let port = attached;
|
|
166
251
|
const open = new Set();
|
|
167
|
-
|
|
252
|
+
const coded = new Set();
|
|
253
|
+
function tiered(next) {
|
|
254
|
+
port = next;
|
|
255
|
+
for (const restart of [...coded])
|
|
256
|
+
restart();
|
|
257
|
+
}
|
|
258
|
+
const unread = port.first?.inboxes === true
|
|
259
|
+
? watch('read', [INBOXES_READ, {}], (read) => {
|
|
260
|
+
const inboxed = inboxRooms(read);
|
|
261
|
+
if (inboxed === null || JSON.stringify(inboxed) === JSON.stringify(port.inboxed)) {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
tiered({ ...port, inboxed });
|
|
265
|
+
}, uncaught)
|
|
266
|
+
: () => { };
|
|
267
|
+
function following(begin, locking = false, restarts = open) {
|
|
168
268
|
let stop = begin();
|
|
169
269
|
const restart = () => {
|
|
170
270
|
stop();
|
|
171
271
|
stop = begin();
|
|
172
272
|
};
|
|
173
273
|
open.add(restart);
|
|
274
|
+
restarts.add(restart);
|
|
174
275
|
const unwatch = locking ? runtime.watchLocks(restart) : () => { };
|
|
175
276
|
return () => {
|
|
176
277
|
open.delete(restart);
|
|
278
|
+
restarts.delete(restart);
|
|
177
279
|
unwatch();
|
|
178
280
|
stop();
|
|
179
281
|
};
|
|
180
282
|
}
|
|
181
|
-
const unlocking = (rooms) => {
|
|
182
|
-
const
|
|
183
|
-
return
|
|
184
|
-
|
|
185
|
-
|
|
283
|
+
const unlocking = (rooms, locked) => {
|
|
284
|
+
const held = (rooms ?? []).filter((room) => locked.includes(room));
|
|
285
|
+
return held.length === 0 ? null : { pending: held.map((room) => ({ room, awaits: 'unlock' })) };
|
|
286
|
+
};
|
|
287
|
+
const unlocked = (entries, locked) => entries.filter((entry) => !locked.includes(entry.room));
|
|
288
|
+
const intoLocked = async (held) => {
|
|
289
|
+
for (const move of held) {
|
|
290
|
+
if (move?.room !== undefined && (await runtime.locked(move.room)))
|
|
291
|
+
return true;
|
|
292
|
+
}
|
|
293
|
+
return false;
|
|
186
294
|
};
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
295
|
+
function ordered(deliver) {
|
|
296
|
+
let open = true;
|
|
297
|
+
let shown = Promise.resolve();
|
|
298
|
+
return {
|
|
299
|
+
push(making) {
|
|
300
|
+
shown = shown.then(() => making.then((value) => {
|
|
301
|
+
if (open)
|
|
302
|
+
deliver(value);
|
|
303
|
+
}, uncaught), uncaught);
|
|
304
|
+
},
|
|
305
|
+
stop() {
|
|
306
|
+
open = false;
|
|
307
|
+
},
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
function unlockedWatch(topic, input, deliver, fail, within) {
|
|
311
|
+
const shown = ordered(deliver);
|
|
312
|
+
const stop = watch(topic, input, (message) => {
|
|
313
|
+
shown.push(runtime.lockedRooms().then((locked) => within(message, locked)));
|
|
314
|
+
}, fail);
|
|
315
|
+
return () => {
|
|
316
|
+
shown.stop();
|
|
317
|
+
stop();
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
function lockedFirst(room, start, shut) {
|
|
321
|
+
let open = true;
|
|
322
|
+
let stop = () => { };
|
|
323
|
+
void (async () => {
|
|
324
|
+
const closed = !holds(reach, room) || (await runtime.locked(room));
|
|
325
|
+
if (!open)
|
|
326
|
+
return;
|
|
327
|
+
if (closed)
|
|
328
|
+
shut();
|
|
329
|
+
else
|
|
330
|
+
stop = start();
|
|
331
|
+
})();
|
|
332
|
+
return () => {
|
|
333
|
+
open = false;
|
|
334
|
+
stop();
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
const within = (topic, input, deliver, fail) => {
|
|
338
|
+
if (topic === 'read' && reach !== null) {
|
|
339
|
+
fail(deviceUnreached());
|
|
340
|
+
return () => { };
|
|
341
|
+
}
|
|
190
342
|
if (topic === 'rooms') {
|
|
191
|
-
return following(() => watch(topic, input, (rooms) =>
|
|
343
|
+
return following(() => watch(topic, input, (rooms) => {
|
|
344
|
+
const shown = 'rooms' in rooms
|
|
345
|
+
? roomsWithin(reach, runtime.queried(), rooms)
|
|
346
|
+
: roomsChangeWithin(reach, runtime.queried(), rooms);
|
|
347
|
+
if (shown !== null)
|
|
348
|
+
deliver(shown);
|
|
349
|
+
}, fail));
|
|
192
350
|
}
|
|
193
351
|
if (topic === 'readiness') {
|
|
194
|
-
return following(() => runtime.watchReadiness(port, reach, deliver));
|
|
352
|
+
return following(() => runtime.watchReadiness(port, reach, deliver), false, coded);
|
|
195
353
|
}
|
|
196
354
|
if (topic === 'sync-status') {
|
|
197
|
-
return following(() =>
|
|
198
|
-
const
|
|
199
|
-
|
|
355
|
+
return following(() => unlockedWatch(topic, input, deliver, fail, (status, locked) => {
|
|
356
|
+
const shown = statusWithin(reach, status);
|
|
357
|
+
return { ...shown, attentionRequired: unlocked(shown.attentionRequired, locked) };
|
|
200
358
|
}), true);
|
|
201
359
|
}
|
|
202
360
|
if (topic === 'room-drafts') {
|
|
203
|
-
return following(() =>
|
|
361
|
+
return following(() => unlockedWatch(topic, input, deliver, fail, (drafts, locked) => unlocked(draftsWithin(reach, drafts), locked)), true);
|
|
204
362
|
}
|
|
205
363
|
if (topic === 'queue') {
|
|
206
364
|
const room = input[0];
|
|
207
|
-
return following(() =>
|
|
208
|
-
if (!holds(reach, room) || runtime.locked(room)) {
|
|
209
|
-
deliver([]);
|
|
210
|
-
return () => { };
|
|
211
|
-
}
|
|
212
|
-
return watch(topic, input, (entries) => deliver(queueWithin(reach, room, entries)));
|
|
213
|
-
}, true);
|
|
365
|
+
return following(() => lockedFirst(room, () => watch(topic, input, (entries) => deliver(queueWithin(reach, room, entries)), fail), () => deliver([])), true);
|
|
214
366
|
}
|
|
215
367
|
if (topic === 'query') {
|
|
216
|
-
const plan = runtime.plan(input[0], reach);
|
|
217
368
|
let held = null;
|
|
369
|
+
let planning = null;
|
|
370
|
+
const waiting = (result) => {
|
|
371
|
+
const answer = { result, keys: [] };
|
|
372
|
+
if (held === null || changeOf(held, answer) !== null)
|
|
373
|
+
deliver(answer);
|
|
374
|
+
held = digestOf(answer);
|
|
375
|
+
};
|
|
218
376
|
return following(() => {
|
|
219
|
-
const locked = unlocking(plan.rooms);
|
|
220
|
-
if (locked !== null) {
|
|
221
|
-
const answer = { result: locked, keys: [] };
|
|
222
|
-
if (held === null || changeOf(held, answer) !== null)
|
|
223
|
-
deliver(answer);
|
|
224
|
-
held = digestOf(answer);
|
|
225
|
-
return () => { };
|
|
226
|
-
}
|
|
227
|
-
let first = true;
|
|
228
377
|
let open = true;
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
378
|
+
let stop = () => { };
|
|
379
|
+
if (planning?.reach !== reach) {
|
|
380
|
+
planning = { reach, plan: planInReach(runtime, input[0], reach, held !== null) };
|
|
381
|
+
}
|
|
382
|
+
const planned = planning.plan;
|
|
383
|
+
void (async () => {
|
|
384
|
+
const plan = await planned;
|
|
385
|
+
const locked = await runtime.lockedRooms();
|
|
386
|
+
if (!open)
|
|
233
387
|
return;
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
388
|
+
if (plan === null)
|
|
389
|
+
return waiting({ pending: [] });
|
|
390
|
+
const pending = unlocking(plan.rooms, locked);
|
|
391
|
+
if (pending !== null)
|
|
392
|
+
return waiting(pending);
|
|
393
|
+
let first = true;
|
|
394
|
+
const heard = (message) => {
|
|
395
|
+
if (!first) {
|
|
396
|
+
held = digestApplied(held, message);
|
|
397
|
+
deliver(message);
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
first = false;
|
|
401
|
+
const change = held === null ? message : changeOf(held, message);
|
|
402
|
+
held = digestOf(message);
|
|
403
|
+
if (change !== null)
|
|
404
|
+
deliver(change);
|
|
405
|
+
};
|
|
406
|
+
stop = runtime.watchPlan({ ...plan, locked }, (message) => {
|
|
407
|
+
if (open)
|
|
408
|
+
heard(message);
|
|
409
|
+
}, (error) => {
|
|
410
|
+
if (open)
|
|
411
|
+
fail(error);
|
|
412
|
+
});
|
|
413
|
+
})().catch((error) => {
|
|
243
414
|
if (open)
|
|
244
|
-
|
|
415
|
+
fail(error);
|
|
245
416
|
});
|
|
246
417
|
return () => {
|
|
247
418
|
open = false;
|
|
@@ -252,7 +423,7 @@ export function narrowed(runtime, given, told) {
|
|
|
252
423
|
if (topic === 'conversation') {
|
|
253
424
|
return following(() => {
|
|
254
425
|
if (conversing(reach))
|
|
255
|
-
return watch(topic, input, deliver);
|
|
426
|
+
return watch(topic, input, deliver, fail);
|
|
256
427
|
deliver(unheldView(input[0]));
|
|
257
428
|
return () => { };
|
|
258
429
|
});
|
|
@@ -260,12 +431,21 @@ export function narrowed(runtime, given, told) {
|
|
|
260
431
|
if (topic === 'conversations' || topic === 'agents') {
|
|
261
432
|
return following(() => {
|
|
262
433
|
if (conversing(reach))
|
|
263
|
-
return watch(topic, input, deliver);
|
|
434
|
+
return watch(topic, input, deliver, fail);
|
|
264
435
|
deliver([]);
|
|
265
436
|
return () => { };
|
|
266
437
|
});
|
|
267
438
|
}
|
|
268
|
-
|
|
439
|
+
if (topic === 'figures' ||
|
|
440
|
+
topic === 'holdings' ||
|
|
441
|
+
topic === 'listed-agents' ||
|
|
442
|
+
topic === 'room-list') {
|
|
443
|
+
if (reach === null)
|
|
444
|
+
return watch(topic, input, deliver, fail);
|
|
445
|
+
fail(deviceUnreached());
|
|
446
|
+
return () => { };
|
|
447
|
+
}
|
|
448
|
+
return watch(topic, input, deliver, fail);
|
|
269
449
|
};
|
|
270
450
|
const files = new Map();
|
|
271
451
|
let handed = 0;
|
|
@@ -282,34 +462,37 @@ export function narrowed(runtime, given, told) {
|
|
|
282
462
|
const chatDraft = () => (conversing(reach) ? md.chatDraft : NO_CHAT_DRAFT);
|
|
283
463
|
const view = {
|
|
284
464
|
...md,
|
|
285
|
-
rooms: () => md.rooms().then((rooms) => roomsWithin(reach, rooms)),
|
|
286
|
-
query: ((input) => {
|
|
287
|
-
const plan = runtime
|
|
288
|
-
|
|
465
|
+
rooms: () => md.rooms().then((rooms) => roomsWithin(reach, runtime.queried(), rooms)),
|
|
466
|
+
query: (async (input) => {
|
|
467
|
+
const plan = await planInReach(runtime, input, reach, false);
|
|
468
|
+
if (plan === null)
|
|
469
|
+
return { pending: [] };
|
|
470
|
+
const locked = await runtime.lockedRooms();
|
|
471
|
+
return unlocking(plan.rooms, locked) ?? runtime.query({ ...plan, locked });
|
|
289
472
|
}),
|
|
290
|
-
search: (input) =>
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
if (holds(reach, room) && runtime.locked(room))
|
|
473
|
+
search: (input) => runtime.search(input, reach),
|
|
474
|
+
queryHouse: (input, options) => runtime.queryHouse(input, reach, options),
|
|
475
|
+
async types(room) {
|
|
476
|
+
if (holds(reach, room) && (await runtime.locked(room)))
|
|
295
477
|
throw lockedError(room);
|
|
296
478
|
if (wholly(reach, room))
|
|
297
479
|
return md.types(room);
|
|
298
480
|
if (!holds(reach, room))
|
|
299
481
|
return structuredClone(UNHELD_TYPES);
|
|
300
|
-
return typesWithin(reach, runtime.room(room), md.types(room));
|
|
482
|
+
return typesWithin(reach, await runtime.room(room), await md.types(room));
|
|
301
483
|
},
|
|
302
484
|
async save(room, roomDrafts, writtenBy) {
|
|
303
485
|
if (!holds(reach, room))
|
|
304
486
|
throw unreached(room);
|
|
305
|
-
if (runtime.locked(room))
|
|
487
|
+
if (await runtime.locked(room)) {
|
|
306
488
|
return { outcome: 'refused', code: ROOM_LOCKED, retryable: true };
|
|
489
|
+
}
|
|
307
490
|
const held = (await Promise.all(roomDrafts.map(({ path }) => md.roomDraft.read(room, path)))).map((draft) => draft?.parts.move);
|
|
308
491
|
const outside = roomDrafts.find(({ path }, at) => !covers(reach, room, path) || !moves(reach, room, held[at]));
|
|
309
492
|
if (outside !== undefined) {
|
|
310
493
|
return { outcome: 'refused', code: 'stale', retryable: false, file: outside.path };
|
|
311
494
|
}
|
|
312
|
-
if (intoLocked(held))
|
|
495
|
+
if (await intoLocked(held))
|
|
313
496
|
return { outcome: 'refused', code: ROOM_LOCKED, retryable: true };
|
|
314
497
|
return savedWithin(reach, room, await md.save(room, roomDrafts, writtenBy));
|
|
315
498
|
},
|
|
@@ -320,95 +503,92 @@ export function narrowed(runtime, given, told) {
|
|
|
320
503
|
if (filed !== undefined) {
|
|
321
504
|
return { outcome: 'refused', code: ATTACH_REQUIRED, retryable: false, file: filed.path };
|
|
322
505
|
}
|
|
323
|
-
if (runtime.locked(room))
|
|
506
|
+
if (await runtime.locked(room)) {
|
|
324
507
|
return { outcome: 'refused', code: ROOM_LOCKED, retryable: true };
|
|
325
|
-
|
|
508
|
+
}
|
|
509
|
+
const held = parts.map(({ path, parts: one }) => readParts(one, path).move);
|
|
326
510
|
if (parts.some(({ path }, at) => !covers(reach, room, path) || !moves(reach, room, held[at]))) {
|
|
327
511
|
throw unreached(room);
|
|
328
512
|
}
|
|
329
|
-
if (intoLocked(held))
|
|
513
|
+
if (await intoLocked(held))
|
|
330
514
|
return { outcome: 'refused', code: ROOM_LOCKED, retryable: true };
|
|
331
515
|
return savedWithin(reach, room, await md.saveParts(room, parts, writtenBy));
|
|
332
516
|
},
|
|
333
|
-
resolve(room, path, destination) {
|
|
334
|
-
const at = runtime.located(room, path, destination);
|
|
517
|
+
async resolve(room, path, destination) {
|
|
518
|
+
const at = await runtime.located(room, path, destination);
|
|
335
519
|
return at !== null && !covers(reach, at.room, at.path)
|
|
336
|
-
?
|
|
520
|
+
? UNREADABLE
|
|
337
521
|
: md.resolve(room, path, destination);
|
|
338
522
|
},
|
|
339
|
-
history: (room, path, query) => !covers(reach, room, path)
|
|
340
|
-
?
|
|
341
|
-
: runtime.locked(room)
|
|
342
|
-
?
|
|
523
|
+
history: async (room, path, query) => !covers(reach, room, path)
|
|
524
|
+
? failure({ kind: 'room-not-readable', locator: room })
|
|
525
|
+
: (await runtime.locked(room))
|
|
526
|
+
? lockedRoom(room)
|
|
343
527
|
: md.history(room, path, query),
|
|
344
|
-
|
|
345
|
-
read: (room, path, revision) => !covers(reach, room, path)
|
|
346
|
-
?
|
|
347
|
-
: runtime.locked(room)
|
|
348
|
-
?
|
|
349
|
-
: hand(md.
|
|
350
|
-
link: (room, path, revision) => !covers(reach, room, path)
|
|
351
|
-
?
|
|
352
|
-
: runtime.locked(room)
|
|
353
|
-
?
|
|
354
|
-
: md.
|
|
355
|
-
show: (room, path, revision) => !covers(reach, room, path)
|
|
356
|
-
?
|
|
357
|
-
: runtime.locked(room)
|
|
358
|
-
?
|
|
359
|
-
: hand(md.
|
|
360
|
-
attach: (room, file) => !wholly(reach, room)
|
|
361
|
-
?
|
|
362
|
-
: runtime.locked(room)
|
|
363
|
-
?
|
|
364
|
-
: md.
|
|
528
|
+
attachment: {
|
|
529
|
+
read: async (room, path, revision) => !covers(reach, room, path)
|
|
530
|
+
? failure({ kind: 'room-not-readable', locator: room })
|
|
531
|
+
: (await runtime.locked(room))
|
|
532
|
+
? lockedRoom(room)
|
|
533
|
+
: hand(md.attachment.read(room, path, revision)),
|
|
534
|
+
link: async (room, path, revision) => !covers(reach, room, path)
|
|
535
|
+
? failure({ kind: 'room-not-readable', locator: room })
|
|
536
|
+
: (await runtime.locked(room))
|
|
537
|
+
? lockedRoom(room)
|
|
538
|
+
: md.attachment.link(room, path, revision),
|
|
539
|
+
show: async (room, path, revision) => !covers(reach, room, path)
|
|
540
|
+
? failure({ kind: 'room-not-readable', locator: room })
|
|
541
|
+
: (await runtime.locked(room))
|
|
542
|
+
? lockedRoom(room)
|
|
543
|
+
: hand(md.attachment.show(room, path, revision)),
|
|
544
|
+
attach: async (room, file) => !wholly(reach, room)
|
|
545
|
+
? failure({ kind: 'room-not-readable', locator: room })
|
|
546
|
+
: (await runtime.locked(room))
|
|
547
|
+
? lockedRoom(room)
|
|
548
|
+
: md.attachment.attach(room, file),
|
|
365
549
|
async part(file, part) {
|
|
366
550
|
const key = files.get(file);
|
|
367
551
|
if (key === undefined)
|
|
368
552
|
return null;
|
|
369
|
-
const bytes = await md.
|
|
553
|
+
const bytes = await md.attachment.part(key, part);
|
|
370
554
|
if (bytes === null)
|
|
371
555
|
files.delete(file);
|
|
372
556
|
return bytes;
|
|
373
557
|
},
|
|
374
558
|
},
|
|
375
559
|
reached: async (room, roomVersion, path) => (path === undefined ? wholly(reach, room) : covers(reach, room, path)) &&
|
|
376
|
-
!runtime.locked(room) &&
|
|
560
|
+
!(await runtime.locked(room)) &&
|
|
377
561
|
(await md.reached(room, roomVersion, path)),
|
|
378
|
-
log: () => (reach === null ? md.log() : ''),
|
|
379
562
|
cleanUp: () => (reach === null ? md.cleanUp() : Promise.reject(deviceUnreached())),
|
|
563
|
+
unsent: () => (reach === null ? md.unsent() : Promise.reject(deviceUnreached())),
|
|
564
|
+
sent: () => (reach === null ? md.sent() : Promise.reject(deviceUnreached())),
|
|
565
|
+
reset: () => (reach === null ? md.reset() : Promise.reject(deviceUnreached())),
|
|
566
|
+
readAgain: () => (reach === null ? md.readAgain() : Promise.reject(deviceUnreached())),
|
|
380
567
|
roomDraft: {
|
|
381
|
-
list: () => md.roomDraft.list()
|
|
568
|
+
list: async () => unlocked(draftsWithin(reach, await md.roomDraft.list()), await runtime.lockedRooms()),
|
|
382
569
|
async read(room, path) {
|
|
383
570
|
if (!covers(reach, room, path))
|
|
384
571
|
return null;
|
|
385
|
-
if (runtime.locked(room))
|
|
572
|
+
if (await runtime.locked(room))
|
|
386
573
|
throw lockedError(room);
|
|
387
574
|
return shownDraft(reach, await md.roomDraft.read(room, path));
|
|
388
575
|
},
|
|
389
|
-
write(room, path, revision, parts, next) {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
}
|
|
401
|
-
catch (error) {
|
|
402
|
-
return Promise.reject(error);
|
|
403
|
-
}
|
|
404
|
-
return md.roomDraft
|
|
405
|
-
.write(room, path, revision, parts, next)
|
|
406
|
-
.then((written) => writeWithin(reach, written));
|
|
576
|
+
async write(room, path, revision, parts, next) {
|
|
577
|
+
if (reach !== null && carriesFile(parts))
|
|
578
|
+
throw attachRequired();
|
|
579
|
+
const move = readParts(parts, path).move;
|
|
580
|
+
if (!covers(reach, room, path) || !moves(reach, room, move))
|
|
581
|
+
throw unreached(room);
|
|
582
|
+
if (await runtime.locked(room))
|
|
583
|
+
throw lockedError(room);
|
|
584
|
+
if (await intoLocked([move]))
|
|
585
|
+
throw lockedError(move.room);
|
|
586
|
+
return writeWithin(reach, await md.roomDraft.write(room, path, revision, parts, next));
|
|
407
587
|
},
|
|
408
588
|
async discard(room, path, revision) {
|
|
409
589
|
if (!covers(reach, room, path))
|
|
410
590
|
return staleWrite(null);
|
|
411
|
-
if (runtime.locked(room))
|
|
591
|
+
if (await runtime.locked(room))
|
|
412
592
|
throw lockedError(room);
|
|
413
593
|
return writeWithin(reach, await md.roomDraft.discard(room, path, revision));
|
|
414
594
|
},
|
|
@@ -418,15 +598,25 @@ export function narrowed(runtime, given, told) {
|
|
|
418
598
|
read: (id, options) => conversation().read(id, options),
|
|
419
599
|
create: (input) => conversation().create(input),
|
|
420
600
|
send: (id, operation, draft) => conversation().send(id, operation, draft),
|
|
421
|
-
answer: (id, answer) => conversation().answer(id, answer),
|
|
422
|
-
interrupt: (id) => conversation().interrupt(id),
|
|
423
|
-
kill: (id) => conversation().kill(id),
|
|
424
|
-
|
|
425
|
-
|
|
601
|
+
answer: (id, answer, operation) => conversation().answer(id, answer, operation),
|
|
602
|
+
interrupt: (id, operation) => conversation().interrupt(id, operation),
|
|
603
|
+
kill: (id, operation) => conversation().kill(id, operation),
|
|
604
|
+
delete: (id, operation) => conversation().delete(id, operation),
|
|
605
|
+
takeOut: (id, message, operation) => conversation().takeOut(id, message, operation),
|
|
606
|
+
decide: (request, decision, operation) => conversation().decide(request, decision, operation),
|
|
607
|
+
rename: (id, name, operation) => conversation().rename(id, name, operation),
|
|
608
|
+
set: (id, settings, operation) => conversation().set(id, settings, operation),
|
|
609
|
+
retry: (id, message, operation) => conversation().retry(id, message, operation),
|
|
610
|
+
pin: (figures) => conversation().pin(figures),
|
|
611
|
+
openTurn: (id, turn) => conversation().openTurn(id, turn),
|
|
612
|
+
dismissSuggestion: (id, suggestion) => conversation().dismissSuggestion(id, suggestion),
|
|
613
|
+
attach: (file) => conversation().attach(file),
|
|
614
|
+
attachment: (link) => conversation().attachment(link),
|
|
426
615
|
},
|
|
427
616
|
chatDraft: {
|
|
428
617
|
write: (id, draft, revision) => chatDraft().write(id, draft, revision),
|
|
429
618
|
prepend: (id, draft) => chatDraft().prepend(id, draft),
|
|
619
|
+
append: (id, draft) => chatDraft().append(id, draft),
|
|
430
620
|
discard: (id) => chatDraft().discard(id),
|
|
431
621
|
},
|
|
432
622
|
observe: observing(within),
|
|
@@ -439,10 +629,10 @@ export function narrowed(runtime, given, told) {
|
|
|
439
629
|
for (const restart of [...open])
|
|
440
630
|
restart();
|
|
441
631
|
},
|
|
442
|
-
|
|
443
|
-
port
|
|
444
|
-
|
|
445
|
-
restart();
|
|
632
|
+
code(next) {
|
|
633
|
+
if (port.code !== next)
|
|
634
|
+
tiered({ ...port, code: next });
|
|
446
635
|
},
|
|
636
|
+
close: unread,
|
|
447
637
|
};
|
|
448
638
|
}
|