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