@agentshouse/mdruntime 0.1.0-cec6690d5712e → 0.1.0-cedd665dffa4c
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 +24 -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 +302 -0
- package/dist/adapter.d.ts +207 -94
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +6 -10
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +35 -41
- package/dist/binary.d.ts +18 -0
- package/dist/binary.d.ts.map +1 -0
- package/dist/binary.js +8 -0
- package/dist/bootstrap.d.ts +31 -11
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +311 -92
- 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 +12 -0
- package/dist/chain.d.ts.map +1 -0
- package/dist/chain.js +64 -0
- package/dist/change-set.d.ts +13 -14
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +17 -62
- package/dist/change.d.ts +46 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +39 -0
- 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 +51 -27
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +133 -26
- package/dist/collection.d.ts +34 -9
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +55 -79
- package/dist/compile.d.ts +18 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +723 -0
- package/dist/connection.d.ts +8 -111
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +113 -2221
- package/dist/context.d.ts +2 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/{chat/context.js → context.js} +2 -5
- package/dist/conversation-live.d.ts +150 -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 +84 -45
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +1118 -584
- package/dist/declaration.d.ts +10 -0
- package/dist/declaration.d.ts.map +1 -0
- package/dist/declaration.js +24 -0
- package/dist/digest.d.ts +7 -0
- package/dist/digest.d.ts.map +1 -0
- package/dist/digest.js +113 -0
- package/dist/discovery.d.ts +10 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +150 -0
- package/dist/durability.d.ts +23 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +9 -0
- package/dist/entry.d.ts +20 -0
- package/dist/entry.d.ts.map +1 -0
- package/dist/entry.js +161 -0
- 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 +6 -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 +2 -19
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +8 -122
- 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 +29 -4
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +179 -25
- package/dist/identity.d.ts +1 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +3 -0
- package/dist/index.d.ts +42 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -2
- 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 +278 -0
- package/dist/listing.d.ts +52 -0
- package/dist/listing.d.ts.map +1 -0
- package/dist/listing.js +152 -0
- package/dist/live.d.ts +25 -0
- package/dist/live.d.ts.map +1 -0
- package/dist/live.js +206 -0
- package/dist/loaded.d.ts +5 -0
- package/dist/loaded.d.ts.map +1 -0
- package/dist/loaded.js +40 -0
- package/dist/locks.d.ts +7 -0
- package/dist/locks.d.ts.map +1 -0
- package/dist/locks.js +32 -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 +13 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +269 -0
- package/dist/memory.d.ts +26 -8
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +307 -97
- package/dist/messages.d.ts +58 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +162 -0
- package/dist/model.d.ts +11 -12
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +7 -15
- 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 +4 -0
- package/dist/name.d.ts.map +1 -0
- package/dist/name.js +122 -0
- package/dist/observation.d.ts +42 -9
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +238 -33
- package/dist/opened.d.ts +22 -0
- package/dist/opened.d.ts.map +1 -0
- package/dist/opened.js +107 -0
- package/dist/opening.d.ts +4 -0
- package/dist/opening.d.ts.map +1 -0
- package/dist/opening.js +53 -0
- package/dist/outcome.d.ts +63 -5
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +70 -0
- package/dist/overlay.d.ts +21 -6
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +163 -187
- 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 +4 -0
- package/dist/parts.d.ts.map +1 -0
- package/dist/parts.js +13 -0
- package/dist/paths.d.ts +2 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +26 -0
- package/dist/preparation.d.ts +41 -0
- package/dist/preparation.d.ts.map +1 -0
- package/dist/preparation.js +314 -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 +308 -0
- package/dist/query.d.ts +51 -183
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +3 -464
- package/dist/{chat/questions.d.ts → questions.d.ts} +5 -7
- package/dist/questions.d.ts.map +1 -0
- package/dist/{chat/questions.js → questions.js} +11 -7
- 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 +20 -5
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +357 -80
- package/dist/react.d.ts +23 -7
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +40 -18
- package/dist/{chat/read.d.ts → read.d.ts} +2 -0
- package/dist/read.d.ts.map +1 -0
- package/dist/{chat/read.js → read.js} +4 -0
- package/dist/readiness.d.ts +55 -0
- package/dist/readiness.d.ts.map +1 -0
- package/dist/readiness.js +25 -0
- package/dist/reads.d.ts +39 -0
- package/dist/reads.d.ts.map +1 -0
- package/dist/reads.js +178 -0
- package/dist/recovery.d.ts +28 -0
- package/dist/recovery.d.ts.map +1 -0
- package/dist/recovery.js +254 -0
- package/dist/refresh.d.ts +17 -14
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +145 -58
- 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 +53 -33
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +349 -167
- 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 +82 -11
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +490 -78
- package/dist/room-drafts.d.ts +24 -0
- package/dist/room-drafts.d.ts.map +1 -0
- package/dist/room-drafts.js +220 -0
- package/dist/rows.d.ts +31 -35
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +60 -126
- package/dist/runtime.d.ts +34 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +1 -0
- package/dist/save.d.ts +45 -22
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +977 -215
- package/dist/saves.d.ts +32 -0
- package/dist/saves.d.ts.map +1 -0
- package/dist/saves.js +426 -0
- package/dist/search.d.ts +15 -55
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +10 -121
- package/dist/seed.d.ts +25 -0
- package/dist/seed.d.ts.map +1 -0
- package/dist/seed.js +145 -0
- package/dist/shared.d.ts +10 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +339 -0
- package/dist/shown.d.ts +33 -0
- package/dist/shown.d.ts.map +1 -0
- package/dist/shown.js +309 -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 +38 -0
- package/dist/socket/session.d.ts.map +1 -0
- package/dist/socket/session.js +23 -0
- package/dist/socket.d.ts +67 -0
- package/dist/socket.d.ts.map +1 -0
- package/dist/socket.js +164 -0
- package/dist/source.d.ts +59 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +93 -0
- package/dist/status.d.ts +5 -2
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +3 -7
- 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 +217 -0
- package/dist/store/records.d.ts.map +1 -0
- package/dist/store/records.js +464 -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 +114 -116
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +164 -494
- package/dist/stored.d.ts +167 -0
- package/dist/stored.d.ts.map +1 -0
- package/dist/stored.js +703 -0
- package/dist/surface.d.ts +89 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/surface.js +222 -0
- package/dist/sync.d.ts +19 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +535 -0
- package/dist/tables.d.ts +419 -0
- package/dist/tables.d.ts.map +1 -0
- package/dist/tables.js +758 -0
- 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/turn.d.ts +9 -0
- package/dist/turn.d.ts.map +1 -0
- package/dist/turn.js +75 -0
- package/dist/validation.d.ts +29 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +98 -0
- package/dist/windows.d.ts +11 -0
- package/dist/windows.d.ts.map +1 -0
- package/dist/windows.js +16 -0
- package/dist/wire.d.ts +221 -34
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +74 -31
- package/package.json +28 -24
- package/AGENTS.md +0 -299
- package/dist/attachment.d.ts +0 -3
- package/dist/attachment.d.ts.map +0 -1
- package/dist/attachment.js +0 -8
- package/dist/attempt.d.ts +0 -16
- package/dist/attempt.d.ts.map +0 -1
- package/dist/attempt.js +0 -57
- package/dist/chat/acts.d.ts +0 -34
- package/dist/chat/acts.d.ts.map +0 -1
- package/dist/chat/acts.js +0 -36
- package/dist/chat/context.d.ts +0 -3
- package/dist/chat/context.d.ts.map +0 -1
- package/dist/chat/input.d.ts +0 -9
- package/dist/chat/input.d.ts.map +0 -1
- package/dist/chat/input.js +0 -99
- package/dist/chat/kit.d.ts +0 -60
- package/dist/chat/kit.d.ts.map +0 -1
- package/dist/chat/kit.js +0 -123
- package/dist/chat/lasting.d.ts +0 -6
- package/dist/chat/lasting.d.ts.map +0 -1
- package/dist/chat/lasting.js +0 -19
- package/dist/chat/list.d.ts +0 -20
- package/dist/chat/list.d.ts.map +0 -1
- package/dist/chat/list.js +0 -59
- package/dist/chat/markdown.d.ts +0 -19
- package/dist/chat/markdown.d.ts.map +0 -1
- package/dist/chat/markdown.js +0 -187
- package/dist/chat/message.d.ts +0 -6
- package/dist/chat/message.d.ts.map +0 -1
- package/dist/chat/message.js +0 -192
- package/dist/chat/messages.d.ts +0 -21
- package/dist/chat/messages.d.ts.map +0 -1
- package/dist/chat/messages.js +0 -151
- package/dist/chat/name.d.ts +0 -6
- package/dist/chat/name.d.ts.map +0 -1
- package/dist/chat/name.js +0 -37
- package/dist/chat/opened.d.ts +0 -11
- package/dist/chat/opened.d.ts.map +0 -1
- package/dist/chat/opened.js +0 -17
- package/dist/chat/overlay.d.ts +0 -31
- package/dist/chat/overlay.d.ts.map +0 -1
- package/dist/chat/overlay.js +0 -97
- package/dist/chat/parts.d.ts +0 -57
- package/dist/chat/parts.d.ts.map +0 -1
- package/dist/chat/parts.js +0 -119
- package/dist/chat/process.d.ts +0 -20
- package/dist/chat/process.d.ts.map +0 -1
- package/dist/chat/process.js +0 -32
- package/dist/chat/provider.d.ts +0 -63
- package/dist/chat/provider.d.ts.map +0 -1
- package/dist/chat/provider.js +0 -645
- package/dist/chat/question.d.ts +0 -9
- package/dist/chat/question.d.ts.map +0 -1
- package/dist/chat/question.js +0 -80
- package/dist/chat/questions.d.ts.map +0 -1
- package/dist/chat/read.d.ts.map +0 -1
- package/dist/chat/ready.d.ts +0 -33
- package/dist/chat/ready.d.ts.map +0 -1
- package/dist/chat/ready.js +0 -91
- package/dist/chat/style.d.ts +0 -4
- package/dist/chat/style.d.ts.map +0 -1
- package/dist/chat/style.js +0 -302
- package/dist/chat.d.ts +0 -14
- package/dist/chat.d.ts.map +0 -1
- package/dist/chat.js +0 -8
- package/dist/log.d.ts +0 -5
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -14
- package/dist/read-side.d.ts +0 -18
- package/dist/read-side.d.ts.map +0 -1
- package/dist/read-side.js +0 -433
package/dist/reach.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { QueryError } from '@agentshouse/mdmodel';
|
|
2
|
+
import { selected } from './collection.js';
|
|
1
3
|
import { unheldView } from './conversation.js';
|
|
2
4
|
import { modelTypes, NO_MODEL } from './model.js';
|
|
3
|
-
import {
|
|
4
|
-
import { runtimeError } from './failure.js';
|
|
5
|
-
import { failure, undeclared } from './outcome.js';
|
|
5
|
+
import { changeOf, digestApplied, digestOf, observing, unchanged, } from './observation.js';
|
|
6
|
+
import { runtimeError, uncaught } from './failure.js';
|
|
7
|
+
import { failure, lockedRoom, ROOM_LOCKED, undeclared, UNREADABLE, } from './outcome.js';
|
|
6
8
|
import { beneath } from './paths.js';
|
|
7
|
-
import { reconciled } from './read-side.js';
|
|
8
9
|
import { moveTarget, readParts, staleWrite, } from './room-draft.js';
|
|
9
10
|
import { documentKey } from './rows.js';
|
|
10
11
|
const UNHELD_TYPES = { collection: modelTypes(NO_MODEL), typedSelection: null };
|
|
@@ -14,18 +15,35 @@ function unconversed(name) {
|
|
|
14
15
|
const NO_CONVERSATION = {
|
|
15
16
|
list: () => Promise.resolve([]),
|
|
16
17
|
read: (conversation) => Promise.resolve(unheldView(conversation)),
|
|
17
|
-
create: unconversed('
|
|
18
|
-
send: unconversed('
|
|
19
|
-
answer: unconversed('
|
|
20
|
-
interrupt: unconversed('
|
|
21
|
-
kill: unconversed('
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
create: unconversed('conversations/create'),
|
|
19
|
+
send: unconversed('conversations/send'),
|
|
20
|
+
answer: unconversed('conversations/interaction/answer'),
|
|
21
|
+
interrupt: unconversed('conversations/interrupt'),
|
|
22
|
+
kill: unconversed('conversations/kill'),
|
|
23
|
+
delete: unconversed('conversations/delete'),
|
|
24
|
+
takeOut: unconversed('conversations/take-out'),
|
|
25
|
+
decide: unconversed('agent-functions/decide'),
|
|
26
|
+
rename: unconversed('conversations/rename'),
|
|
27
|
+
option: unconversed('conversations/option/set'),
|
|
28
|
+
retry: unconversed('conversations/retry'),
|
|
29
|
+
pin: () => Promise.resolve(),
|
|
30
|
+
openTurn: () => Promise.resolve(),
|
|
31
|
+
dismissSuggestion: () => Promise.resolve(),
|
|
24
32
|
};
|
|
25
33
|
const NO_CHAT_DRAFT = {
|
|
26
34
|
write: () => Promise.resolve(),
|
|
35
|
+
prepend: () => Promise.resolve(),
|
|
36
|
+
append: () => Promise.resolve(),
|
|
27
37
|
discard: () => Promise.resolve(),
|
|
28
38
|
};
|
|
39
|
+
function areasOf(reach) {
|
|
40
|
+
return reach.areas ?? [];
|
|
41
|
+
}
|
|
42
|
+
function fenced(reach, room, path) {
|
|
43
|
+
return areasOf(reach).some((area) => area.room === room &&
|
|
44
|
+
beneath(area.path, path) &&
|
|
45
|
+
!area.open.some((open) => beneath(open, path)));
|
|
46
|
+
}
|
|
29
47
|
export function holds(reach, room) {
|
|
30
48
|
return (reach === null ||
|
|
31
49
|
reach.rooms.includes(room) ||
|
|
@@ -38,20 +56,34 @@ export function governs(reach, room) {
|
|
|
38
56
|
if (wholly(reach, room.locator)) {
|
|
39
57
|
return { collection: true, selection: room.typedSelection !== null };
|
|
40
58
|
}
|
|
41
|
-
const
|
|
59
|
+
const within = (path) => selected({ selection: room.typedSelection }, path);
|
|
42
60
|
const paths = reach.documents
|
|
43
61
|
.filter((document) => document.room === room.locator)
|
|
44
62
|
.map(({ path }) => path);
|
|
45
|
-
return { collection: paths.some((path) => !
|
|
63
|
+
return { collection: paths.some((path) => !within(path)), selection: paths.some(within) };
|
|
46
64
|
}
|
|
47
65
|
function covers(reach, room, path) {
|
|
48
66
|
return (reach === null ||
|
|
49
|
-
reach
|
|
50
|
-
|
|
67
|
+
(!fenced(reach, room, path) &&
|
|
68
|
+
(reach.rooms.includes(room) ||
|
|
69
|
+
reach.documents.some((document) => document.room === room && document.path === path))));
|
|
51
70
|
}
|
|
52
71
|
function conversing(reach) {
|
|
53
72
|
return reach === null || reach.conversations;
|
|
54
73
|
}
|
|
74
|
+
function roomsAwaited(error, reach) {
|
|
75
|
+
return error.code === 'unknown-type' && reach !== null && reach.rooms.length === 0;
|
|
76
|
+
}
|
|
77
|
+
async function planInReach(runtime, input, reach, answered) {
|
|
78
|
+
try {
|
|
79
|
+
return await runtime.plan(input, reach);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
if (error instanceof QueryError && (answered || roomsAwaited(error, reach)))
|
|
83
|
+
return null;
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
55
87
|
export function planReach(reach) {
|
|
56
88
|
return reach === null
|
|
57
89
|
? null
|
|
@@ -60,11 +92,22 @@ export function planReach(reach) {
|
|
|
60
92
|
documents: [
|
|
61
93
|
...new Set(reach.documents.map(({ room, path }) => documentKey(room, path))),
|
|
62
94
|
].sort(),
|
|
95
|
+
areas: areasOf(reach)
|
|
96
|
+
.map(({ room, path, open }) => ({ room, path, open: [...new Set(open)].sort() }))
|
|
97
|
+
.sort((left, right) => documentKey(left.room, left.path) < documentKey(right.room, right.path) ? -1 : 1),
|
|
63
98
|
};
|
|
64
99
|
}
|
|
65
100
|
function roomsWithin(reach, rooms) {
|
|
66
101
|
return rooms.filter((room) => wholly(reach, room.locator));
|
|
67
102
|
}
|
|
103
|
+
function roomsChangeWithin(reach, { changed, removed, order }) {
|
|
104
|
+
const within = {
|
|
105
|
+
changed: changed.filter(([locator]) => wholly(reach, locator)),
|
|
106
|
+
removed,
|
|
107
|
+
order: order === null ? null : order.filter((locator) => wholly(reach, locator)),
|
|
108
|
+
};
|
|
109
|
+
return unchanged(within) ? null : within;
|
|
110
|
+
}
|
|
68
111
|
function typesWithin(reach, room, types) {
|
|
69
112
|
if (room === undefined)
|
|
70
113
|
return structuredClone(UNHELD_TYPES);
|
|
@@ -75,7 +118,7 @@ function typesWithin(reach, room, types) {
|
|
|
75
118
|
};
|
|
76
119
|
}
|
|
77
120
|
function moves(reach, room, move) {
|
|
78
|
-
return move === undefined || covers(reach, room, moveTarget(move));
|
|
121
|
+
return move === undefined || covers(reach, move.room ?? room, moveTarget(move));
|
|
79
122
|
}
|
|
80
123
|
function draftWithin(reach, draft) {
|
|
81
124
|
return covers(reach, draft.room, draft.path) && moves(reach, draft.room, draft.parts.move);
|
|
@@ -94,12 +137,13 @@ function writeWithin(reach, write) {
|
|
|
94
137
|
function savedWithin(reach, room, result) {
|
|
95
138
|
if (reach === null || result.outcome === 'saved')
|
|
96
139
|
return result;
|
|
97
|
-
const { file, location, referrers, ...refusal } = result;
|
|
140
|
+
const { file, location, line, referrers, ...refusal } = result;
|
|
98
141
|
const hidden = file !== undefined && !covers(reach, room, file);
|
|
99
142
|
return {
|
|
100
143
|
...refusal,
|
|
101
144
|
...(file === undefined || hidden ? {} : { file }),
|
|
102
145
|
...(location === undefined || hidden ? {} : { location }),
|
|
146
|
+
...(line === undefined || hidden ? {} : { line }),
|
|
103
147
|
...(referrers === undefined
|
|
104
148
|
? {}
|
|
105
149
|
: { referrers: referrers.filter((path) => covers(reach, room, path)) }),
|
|
@@ -109,80 +153,200 @@ function statusWithin(reach, status) {
|
|
|
109
153
|
return {
|
|
110
154
|
...status,
|
|
111
155
|
attentionRequired: status.attentionRequired.filter((entry) => covers(reach, entry.room, entry.path)),
|
|
156
|
+
unsent: status.unsent.filter((change) => covers(reach, change.room, change.path)),
|
|
112
157
|
};
|
|
113
158
|
}
|
|
114
159
|
function queueWithin(reach, room, entries) {
|
|
115
|
-
return entries
|
|
116
|
-
(
|
|
160
|
+
return entries
|
|
161
|
+
.filter(({ batch }) => batch.changes.every((change) => covers(reach, room, change.path) &&
|
|
162
|
+
(change.kind !== 'move' || covers(reach, room, change.to))))
|
|
163
|
+
.map((entry) => {
|
|
164
|
+
const { between, ...batch } = entry.batch;
|
|
165
|
+
if (between === undefined)
|
|
166
|
+
return entry;
|
|
167
|
+
return wholly(reach, between.source.room) && wholly(reach, between.destination.room)
|
|
168
|
+
? entry
|
|
169
|
+
: { ...entry, batch };
|
|
170
|
+
});
|
|
117
171
|
}
|
|
118
172
|
function unreached(room) {
|
|
119
|
-
return runtimeError('room
|
|
173
|
+
return runtimeError('unknown-room', `Unknown Room ${room}`);
|
|
174
|
+
}
|
|
175
|
+
function lockedError(room) {
|
|
176
|
+
return runtimeError(ROOM_LOCKED, `${room} is locked until House confirms its access`, true);
|
|
177
|
+
}
|
|
178
|
+
function deviceUnreached() {
|
|
179
|
+
return runtimeError('device-unreached', 'Only the panel reaches this device');
|
|
120
180
|
}
|
|
121
|
-
|
|
181
|
+
const ATTACH_REQUIRED = 'attach-required';
|
|
182
|
+
function attachRequired() {
|
|
183
|
+
return runtimeError(ATTACH_REQUIRED, 'App code takes a file in with binaryFile.attach');
|
|
184
|
+
}
|
|
185
|
+
function carriesFile(parts) {
|
|
186
|
+
return parts !== null && typeof parts === 'object' && Object.hasOwn(parts, 'file');
|
|
187
|
+
}
|
|
188
|
+
export function narrowed(runtime, given, port) {
|
|
122
189
|
const { md, watch } = runtime;
|
|
123
190
|
let reach = given;
|
|
124
191
|
const open = new Set();
|
|
125
|
-
function following(begin) {
|
|
192
|
+
function following(begin, locking = false) {
|
|
126
193
|
let stop = begin();
|
|
127
194
|
const restart = () => {
|
|
128
195
|
stop();
|
|
129
196
|
stop = begin();
|
|
130
197
|
};
|
|
131
198
|
open.add(restart);
|
|
199
|
+
const unwatch = locking ? runtime.watchLocks(restart) : () => { };
|
|
132
200
|
return () => {
|
|
133
201
|
open.delete(restart);
|
|
202
|
+
unwatch();
|
|
134
203
|
stop();
|
|
135
204
|
};
|
|
136
205
|
}
|
|
137
|
-
const
|
|
206
|
+
const unlocking = (rooms, locked) => {
|
|
207
|
+
const held = (rooms ?? []).filter((room) => locked.includes(room));
|
|
208
|
+
return held.length === 0 ? null : { pending: held.map((room) => ({ room, awaits: 'unlock' })) };
|
|
209
|
+
};
|
|
210
|
+
const unlocked = (entries, locked) => entries.filter((entry) => !locked.includes(entry.room));
|
|
211
|
+
const intoLocked = async (held) => {
|
|
212
|
+
for (const move of held) {
|
|
213
|
+
if (move?.room !== undefined && (await runtime.locked(move.room)))
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
return false;
|
|
217
|
+
};
|
|
218
|
+
function ordered(deliver) {
|
|
219
|
+
let open = true;
|
|
220
|
+
let shown = Promise.resolve();
|
|
221
|
+
return {
|
|
222
|
+
push(making) {
|
|
223
|
+
shown = shown.then(() => making.then((value) => {
|
|
224
|
+
if (open)
|
|
225
|
+
deliver(value);
|
|
226
|
+
}, uncaught), uncaught);
|
|
227
|
+
},
|
|
228
|
+
stop() {
|
|
229
|
+
open = false;
|
|
230
|
+
},
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
function unlockedWatch(topic, input, deliver, fail, within) {
|
|
234
|
+
const shown = ordered(deliver);
|
|
235
|
+
const stop = watch(topic, input, (message) => {
|
|
236
|
+
shown.push(runtime.lockedRooms().then((locked) => within(message, locked)));
|
|
237
|
+
}, fail);
|
|
238
|
+
return () => {
|
|
239
|
+
shown.stop();
|
|
240
|
+
stop();
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
function lockedFirst(room, start, shut) {
|
|
244
|
+
let open = true;
|
|
245
|
+
let stop = () => { };
|
|
246
|
+
void (async () => {
|
|
247
|
+
const closed = !holds(reach, room) || (await runtime.locked(room));
|
|
248
|
+
if (!open)
|
|
249
|
+
return;
|
|
250
|
+
if (closed)
|
|
251
|
+
shut();
|
|
252
|
+
else
|
|
253
|
+
stop = start();
|
|
254
|
+
})();
|
|
255
|
+
return () => {
|
|
256
|
+
open = false;
|
|
257
|
+
stop();
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
const within = (topic, input, deliver, fail) => {
|
|
261
|
+
if (topic === 'read' && reach !== null) {
|
|
262
|
+
fail(deviceUnreached());
|
|
263
|
+
return () => { };
|
|
264
|
+
}
|
|
138
265
|
if (topic === 'rooms') {
|
|
139
|
-
return following(() => watch(topic, input, (rooms) =>
|
|
266
|
+
return following(() => watch(topic, input, (rooms) => {
|
|
267
|
+
const shown = Array.isArray(rooms)
|
|
268
|
+
? roomsWithin(reach, rooms)
|
|
269
|
+
: roomsChangeWithin(reach, rooms);
|
|
270
|
+
if (shown !== null)
|
|
271
|
+
deliver(shown);
|
|
272
|
+
}, fail));
|
|
273
|
+
}
|
|
274
|
+
if (topic === 'readiness') {
|
|
275
|
+
return following(() => runtime.watchReadiness(port, reach, deliver));
|
|
140
276
|
}
|
|
141
277
|
if (topic === 'sync-status') {
|
|
142
|
-
return following(() =>
|
|
278
|
+
return following(() => unlockedWatch(topic, input, deliver, fail, (status, locked) => {
|
|
279
|
+
const shown = statusWithin(reach, status);
|
|
280
|
+
return { ...shown, attentionRequired: unlocked(shown.attentionRequired, locked) };
|
|
281
|
+
}), true);
|
|
143
282
|
}
|
|
144
283
|
if (topic === 'room-drafts') {
|
|
145
|
-
return following(() =>
|
|
284
|
+
return following(() => unlockedWatch(topic, input, deliver, fail, (drafts, locked) => unlocked(draftsWithin(reach, drafts), locked)), true);
|
|
146
285
|
}
|
|
147
286
|
if (topic === 'queue') {
|
|
148
287
|
const room = input[0];
|
|
149
|
-
return following(() =>
|
|
150
|
-
if (!holds(reach, room)) {
|
|
151
|
-
deliver([]);
|
|
152
|
-
return () => { };
|
|
153
|
-
}
|
|
154
|
-
return watch(topic, input, (entries) => deliver(queueWithin(reach, room, entries)));
|
|
155
|
-
});
|
|
288
|
+
return following(() => lockedFirst(room, () => watch(topic, input, (entries) => deliver(queueWithin(reach, room, entries)), fail), () => deliver([])), true);
|
|
156
289
|
}
|
|
157
290
|
if (topic === 'query') {
|
|
158
|
-
const plan = runtime.plan(input[0], reach);
|
|
159
291
|
let held = null;
|
|
292
|
+
let planning = null;
|
|
293
|
+
const waiting = (result) => {
|
|
294
|
+
const answer = { result, keys: [] };
|
|
295
|
+
if (held === null || changeOf(held, answer) !== null)
|
|
296
|
+
deliver(answer);
|
|
297
|
+
held = digestOf(answer);
|
|
298
|
+
};
|
|
160
299
|
return following(() => {
|
|
161
|
-
let
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
deliver(message);
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
const next = reconciled(held, message);
|
|
175
|
-
if (next === null)
|
|
300
|
+
let open = true;
|
|
301
|
+
let stop = () => { };
|
|
302
|
+
if (planning?.reach !== reach) {
|
|
303
|
+
planning = { reach, plan: planInReach(runtime, input[0], reach, held !== null) };
|
|
304
|
+
}
|
|
305
|
+
const planned = planning.plan;
|
|
306
|
+
void (async () => {
|
|
307
|
+
const plan = await planned;
|
|
308
|
+
const locked = await runtime.lockedRooms();
|
|
309
|
+
if (!open)
|
|
176
310
|
return;
|
|
177
|
-
|
|
178
|
-
|
|
311
|
+
if (plan === null)
|
|
312
|
+
return waiting({ pending: [] });
|
|
313
|
+
const pending = unlocking(plan.rooms, locked);
|
|
314
|
+
if (pending !== null)
|
|
315
|
+
return waiting(pending);
|
|
316
|
+
let first = true;
|
|
317
|
+
const heard = (message) => {
|
|
318
|
+
if (!first) {
|
|
319
|
+
held = digestApplied(held, message);
|
|
320
|
+
deliver(message);
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
first = false;
|
|
324
|
+
const change = held === null ? message : changeOf(held, message);
|
|
325
|
+
held = digestOf(message);
|
|
326
|
+
if (change !== null)
|
|
327
|
+
deliver(change);
|
|
328
|
+
};
|
|
329
|
+
stop = runtime.watchPlan({ ...plan, locked }, (message) => {
|
|
330
|
+
if (open)
|
|
331
|
+
heard(message);
|
|
332
|
+
}, (error) => {
|
|
333
|
+
if (open)
|
|
334
|
+
fail(error);
|
|
335
|
+
});
|
|
336
|
+
})().catch((error) => {
|
|
337
|
+
if (open)
|
|
338
|
+
fail(error);
|
|
179
339
|
});
|
|
180
|
-
|
|
340
|
+
return () => {
|
|
341
|
+
open = false;
|
|
342
|
+
stop();
|
|
343
|
+
};
|
|
344
|
+
}, true);
|
|
181
345
|
}
|
|
182
346
|
if (topic === 'conversation') {
|
|
183
347
|
return following(() => {
|
|
184
348
|
if (conversing(reach))
|
|
185
|
-
return watch(topic, input, deliver);
|
|
349
|
+
return watch(topic, input, deliver, fail);
|
|
186
350
|
deliver(unheldView(input[0]));
|
|
187
351
|
return () => { };
|
|
188
352
|
});
|
|
@@ -190,56 +354,160 @@ export function narrowed(runtime, given) {
|
|
|
190
354
|
if (topic === 'conversations' || topic === 'agents') {
|
|
191
355
|
return following(() => {
|
|
192
356
|
if (conversing(reach))
|
|
193
|
-
return watch(topic, input, deliver);
|
|
357
|
+
return watch(topic, input, deliver, fail);
|
|
194
358
|
deliver([]);
|
|
195
359
|
return () => { };
|
|
196
360
|
});
|
|
197
361
|
}
|
|
198
|
-
|
|
362
|
+
if (topic === 'figures' || topic === 'holdings' || topic === 'listed-agents') {
|
|
363
|
+
if (reach === null)
|
|
364
|
+
return watch(topic, input, deliver, fail);
|
|
365
|
+
fail(deviceUnreached());
|
|
366
|
+
return () => { };
|
|
367
|
+
}
|
|
368
|
+
return watch(topic, input, deliver, fail);
|
|
199
369
|
};
|
|
370
|
+
const files = new Map();
|
|
371
|
+
let handed = 0;
|
|
372
|
+
async function hand(reading) {
|
|
373
|
+
const answer = await reading;
|
|
374
|
+
if (answer.kind !== 'binary')
|
|
375
|
+
return answer;
|
|
376
|
+
handed += 1;
|
|
377
|
+
const file = String(handed);
|
|
378
|
+
files.set(file, answer.file);
|
|
379
|
+
return { ...answer, file };
|
|
380
|
+
}
|
|
200
381
|
const conversation = () => (conversing(reach) ? md.conversation : NO_CONVERSATION);
|
|
201
382
|
const chatDraft = () => (conversing(reach) ? md.chatDraft : NO_CHAT_DRAFT);
|
|
202
383
|
const view = {
|
|
203
384
|
...md,
|
|
204
|
-
rooms: () => roomsWithin(reach,
|
|
205
|
-
query: ((input) =>
|
|
385
|
+
rooms: () => md.rooms().then((rooms) => roomsWithin(reach, rooms)),
|
|
386
|
+
query: (async (input) => {
|
|
387
|
+
const plan = await planInReach(runtime, input, reach, false);
|
|
388
|
+
if (plan === null)
|
|
389
|
+
return { pending: [] };
|
|
390
|
+
const locked = await runtime.lockedRooms();
|
|
391
|
+
return unlocking(plan.rooms, locked) ?? runtime.query({ ...plan, locked });
|
|
392
|
+
}),
|
|
206
393
|
search: (input) => runtime.search(input, reach),
|
|
207
|
-
types(room) {
|
|
394
|
+
async types(room) {
|
|
395
|
+
if (holds(reach, room) && (await runtime.locked(room)))
|
|
396
|
+
throw lockedError(room);
|
|
208
397
|
if (wholly(reach, room))
|
|
209
398
|
return md.types(room);
|
|
210
399
|
if (!holds(reach, room))
|
|
211
400
|
return structuredClone(UNHELD_TYPES);
|
|
212
|
-
|
|
213
|
-
return typesWithin(reach, listed, md.types(room));
|
|
401
|
+
return typesWithin(reach, await runtime.room(room), await md.types(room));
|
|
214
402
|
},
|
|
215
403
|
async save(room, roomDrafts, writtenBy) {
|
|
216
404
|
if (!holds(reach, room))
|
|
217
405
|
throw unreached(room);
|
|
218
|
-
|
|
219
|
-
|
|
406
|
+
if (await runtime.locked(room)) {
|
|
407
|
+
return { outcome: 'refused', code: ROOM_LOCKED, retryable: true };
|
|
408
|
+
}
|
|
409
|
+
const held = (await Promise.all(roomDrafts.map(({ path }) => md.roomDraft.read(room, path)))).map((draft) => draft?.parts.move);
|
|
410
|
+
const outside = roomDrafts.find(({ path }, at) => !covers(reach, room, path) || !moves(reach, room, held[at]));
|
|
220
411
|
if (outside !== undefined) {
|
|
221
412
|
return { outcome: 'refused', code: 'stale', retryable: false, file: outside.path };
|
|
222
413
|
}
|
|
414
|
+
if (await intoLocked(held))
|
|
415
|
+
return { outcome: 'refused', code: ROOM_LOCKED, retryable: true };
|
|
223
416
|
return savedWithin(reach, room, await md.save(room, roomDrafts, writtenBy));
|
|
224
417
|
},
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
418
|
+
async saveParts(room, parts, writtenBy) {
|
|
419
|
+
if (!holds(reach, room))
|
|
420
|
+
throw unreached(room);
|
|
421
|
+
const filed = reach === null ? undefined : parts.find(({ parts: one }) => carriesFile(one));
|
|
422
|
+
if (filed !== undefined) {
|
|
423
|
+
return { outcome: 'refused', code: ATTACH_REQUIRED, retryable: false, file: filed.path };
|
|
424
|
+
}
|
|
425
|
+
if (await runtime.locked(room)) {
|
|
426
|
+
return { outcome: 'refused', code: ROOM_LOCKED, retryable: true };
|
|
427
|
+
}
|
|
428
|
+
const held = parts.map(({ path, parts: one }) => readParts(one, path).move);
|
|
429
|
+
if (parts.some(({ path }, at) => !covers(reach, room, path) || !moves(reach, room, held[at]))) {
|
|
430
|
+
throw unreached(room);
|
|
431
|
+
}
|
|
432
|
+
if (await intoLocked(held))
|
|
433
|
+
return { outcome: 'refused', code: ROOM_LOCKED, retryable: true };
|
|
434
|
+
return savedWithin(reach, room, await md.saveParts(room, parts, writtenBy));
|
|
435
|
+
},
|
|
436
|
+
async resolve(room, path, destination) {
|
|
437
|
+
const at = await runtime.located(room, path, destination);
|
|
438
|
+
return at !== null && !covers(reach, at.room, at.path)
|
|
439
|
+
? UNREADABLE
|
|
440
|
+
: md.resolve(room, path, destination);
|
|
441
|
+
},
|
|
442
|
+
history: async (room, path, query) => !covers(reach, room, path)
|
|
443
|
+
? failure({ kind: 'room-not-readable', locator: room })
|
|
444
|
+
: (await runtime.locked(room))
|
|
445
|
+
? lockedRoom(room)
|
|
446
|
+
: md.history(room, path, query),
|
|
447
|
+
binaryFile: {
|
|
448
|
+
read: async (room, path, revision) => !covers(reach, room, path)
|
|
449
|
+
? failure({ kind: 'room-not-readable', locator: room })
|
|
450
|
+
: (await runtime.locked(room))
|
|
451
|
+
? lockedRoom(room)
|
|
452
|
+
: hand(md.binaryFile.read(room, path, revision)),
|
|
453
|
+
link: async (room, path, revision) => !covers(reach, room, path)
|
|
454
|
+
? failure({ kind: 'room-not-readable', locator: room })
|
|
455
|
+
: (await runtime.locked(room))
|
|
456
|
+
? lockedRoom(room)
|
|
457
|
+
: md.binaryFile.link(room, path, revision),
|
|
458
|
+
show: async (room, path, revision) => !covers(reach, room, path)
|
|
459
|
+
? failure({ kind: 'room-not-readable', locator: room })
|
|
460
|
+
: (await runtime.locked(room))
|
|
461
|
+
? lockedRoom(room)
|
|
462
|
+
: hand(md.binaryFile.show(room, path, revision)),
|
|
463
|
+
attach: async (room, file) => !wholly(reach, room)
|
|
464
|
+
? failure({ kind: 'room-not-readable', locator: room })
|
|
465
|
+
: (await runtime.locked(room))
|
|
466
|
+
? lockedRoom(room)
|
|
467
|
+
: md.binaryFile.attach(room, file),
|
|
468
|
+
async part(file, part) {
|
|
469
|
+
const key = files.get(file);
|
|
470
|
+
if (key === undefined)
|
|
471
|
+
return null;
|
|
472
|
+
const bytes = await md.binaryFile.part(key, part);
|
|
473
|
+
if (bytes === null)
|
|
474
|
+
files.delete(file);
|
|
475
|
+
return bytes;
|
|
476
|
+
},
|
|
477
|
+
},
|
|
478
|
+
reached: async (room, roomVersion, path) => (path === undefined ? wholly(reach, room) : covers(reach, room, path)) &&
|
|
479
|
+
!(await runtime.locked(room)) &&
|
|
480
|
+
(await md.reached(room, roomVersion, path)),
|
|
481
|
+
cleanUp: () => (reach === null ? md.cleanUp() : Promise.reject(deviceUnreached())),
|
|
482
|
+
unsent: () => (reach === null ? md.unsent() : Promise.reject(deviceUnreached())),
|
|
483
|
+
reset: () => (reach === null ? md.reset() : Promise.reject(deviceUnreached())),
|
|
484
|
+
readAgain: () => (reach === null ? md.readAgain() : Promise.reject(deviceUnreached())),
|
|
231
485
|
roomDraft: {
|
|
232
|
-
list: () => md.roomDraft.list()
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
486
|
+
list: async () => unlocked(draftsWithin(reach, await md.roomDraft.list()), await runtime.lockedRooms()),
|
|
487
|
+
async read(room, path) {
|
|
488
|
+
if (!covers(reach, room, path))
|
|
489
|
+
return null;
|
|
490
|
+
if (await runtime.locked(room))
|
|
491
|
+
throw lockedError(room);
|
|
492
|
+
return shownDraft(reach, await md.roomDraft.read(room, path));
|
|
493
|
+
},
|
|
494
|
+
async write(room, path, revision, parts, next) {
|
|
495
|
+
if (reach !== null && carriesFile(parts))
|
|
496
|
+
throw attachRequired();
|
|
497
|
+
const move = readParts(parts, path).move;
|
|
498
|
+
if (!covers(reach, room, path) || !moves(reach, room, move))
|
|
236
499
|
throw unreached(room);
|
|
237
|
-
|
|
238
|
-
|
|
500
|
+
if (await runtime.locked(room))
|
|
501
|
+
throw lockedError(room);
|
|
502
|
+
if (await intoLocked([move]))
|
|
503
|
+
throw lockedError(move.room);
|
|
504
|
+
return writeWithin(reach, await md.roomDraft.write(room, path, revision, parts, next));
|
|
239
505
|
},
|
|
240
506
|
async discard(room, path, revision) {
|
|
241
507
|
if (!covers(reach, room, path))
|
|
242
508
|
return staleWrite(null);
|
|
509
|
+
if (await runtime.locked(room))
|
|
510
|
+
throw lockedError(room);
|
|
243
511
|
return writeWithin(reach, await md.roomDraft.discard(room, path, revision));
|
|
244
512
|
},
|
|
245
513
|
},
|
|
@@ -247,15 +515,24 @@ export function narrowed(runtime, given) {
|
|
|
247
515
|
list: () => conversation().list(),
|
|
248
516
|
read: (id, options) => conversation().read(id, options),
|
|
249
517
|
create: (input) => conversation().create(input),
|
|
250
|
-
send: (id) => conversation().send(id),
|
|
251
|
-
answer: (id, answer) => conversation().answer(id, answer),
|
|
252
|
-
interrupt: (id) => conversation().interrupt(id),
|
|
253
|
-
kill: (id) => conversation().kill(id),
|
|
254
|
-
|
|
255
|
-
|
|
518
|
+
send: (id, operation, draft) => conversation().send(id, operation, draft),
|
|
519
|
+
answer: (id, answer, operation) => conversation().answer(id, answer, operation),
|
|
520
|
+
interrupt: (id, operation) => conversation().interrupt(id, operation),
|
|
521
|
+
kill: (id, operation) => conversation().kill(id, operation),
|
|
522
|
+
delete: (id, operation) => conversation().delete(id, operation),
|
|
523
|
+
takeOut: (id, message, operation) => conversation().takeOut(id, message, operation),
|
|
524
|
+
decide: (request, decision, operation) => conversation().decide(request, decision, operation),
|
|
525
|
+
rename: (id, name, operation) => conversation().rename(id, name, operation),
|
|
526
|
+
option: (id, option, value, operation) => conversation().option(id, option, value, operation),
|
|
527
|
+
retry: (id, message, operation) => conversation().retry(id, message, operation),
|
|
528
|
+
pin: (figures) => conversation().pin(figures),
|
|
529
|
+
openTurn: (id, turn) => conversation().openTurn(id, turn),
|
|
530
|
+
dismissSuggestion: (id, suggestion) => conversation().dismissSuggestion(id, suggestion),
|
|
256
531
|
},
|
|
257
532
|
chatDraft: {
|
|
258
533
|
write: (id, draft, revision) => chatDraft().write(id, draft, revision),
|
|
534
|
+
prepend: (id, draft) => chatDraft().prepend(id, draft),
|
|
535
|
+
append: (id, draft) => chatDraft().append(id, draft),
|
|
259
536
|
discard: (id) => chatDraft().discard(id),
|
|
260
537
|
},
|
|
261
538
|
observe: observing(within),
|
package/dist/react.d.ts
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
|
+
import type { DocumentQuery, GroupQuery } from '@agentshouse/mdmodel';
|
|
2
|
+
import type { Acting, Lane, LaneShown } from './act-lanes.js';
|
|
1
3
|
import type { MdRuntimeClient } from './client.js';
|
|
2
|
-
import type { AppRoom
|
|
3
|
-
import type {
|
|
4
|
+
import type { AppRoom } from './listing.js';
|
|
5
|
+
import type { ConnectionRefusal } from './socket.js';
|
|
6
|
+
import type { SavedRoomDraft, SaveResult } from './saves.js';
|
|
7
|
+
import type { ListedAgent, Member, ServiceMode } from './adapter.js';
|
|
4
8
|
import type { ConversationAgent, ConversationEntry, ConversationOptions, ConversationView } from './conversation.js';
|
|
5
9
|
import { type RuntimeError } from './failure.js';
|
|
10
|
+
import type { FiguresResult } from './figures.js';
|
|
11
|
+
import type { Holdings } from './holdings.js';
|
|
12
|
+
import type { Descriptor, Expecting } from './expectation.js';
|
|
6
13
|
import type { QueueEntry } from './outcome.js';
|
|
7
|
-
import type {
|
|
14
|
+
import type { DocumentResult, GroupResult, PendingResult } from './query.js';
|
|
15
|
+
import type { Readiness } from './readiness.js';
|
|
8
16
|
import type { RoomDraft, RoomDraftParts } from './room-draft.js';
|
|
9
17
|
import type { SyncStatus } from './status.js';
|
|
10
18
|
type Client = MdRuntimeClient | null;
|
|
@@ -16,26 +24,34 @@ export type Observed<T> = {
|
|
|
16
24
|
};
|
|
17
25
|
export declare function useObserve(client: Client, topic: 'deployment-facts'): Observed<unknown>;
|
|
18
26
|
export declare function useObserve(client: Client, topic: 'rooms'): Observed<readonly AppRoom[]>;
|
|
27
|
+
export declare function useObserve(client: Client, topic: 'readiness'): Observed<Readiness>;
|
|
19
28
|
export declare function useObserve(client: Client, topic: 'connection-refusal'): Observed<ConnectionRefusal | null>;
|
|
20
29
|
export declare function useObserve(client: Client, topic: 'storage-loss'): Observed<string | null>;
|
|
21
30
|
export declare function useObserve(client: Client, topic: 'sync-status'): Observed<SyncStatus>;
|
|
22
31
|
export declare function useObserve(client: Client, topic: 'service-mode'): Observed<ServiceMode>;
|
|
23
32
|
export declare function useObserve(client: Client, topic: 'member'): Observed<Member | null>;
|
|
24
|
-
export declare function useObserve(client: Client, topic: '
|
|
25
|
-
export declare function useObserve(client: Client, topic: 'query', query:
|
|
33
|
+
export declare function useObserve(client: Client, topic: 'authority-changes'): Observed<number>;
|
|
34
|
+
export declare function useObserve(client: Client, topic: 'query', query: DocumentQuery): Observed<DocumentResult | PendingResult>;
|
|
35
|
+
export declare function useObserve(client: Client, topic: 'query', query: GroupQuery): Observed<GroupResult | PendingResult>;
|
|
26
36
|
export declare function useObserve(client: Client, topic: 'queue', locator: string): Observed<readonly QueueEntry[]>;
|
|
27
37
|
export declare function useObserve(client: Client, topic: 'room-drafts'): Observed<readonly RoomDraft[]>;
|
|
28
38
|
export declare function useObserve(client: Client, topic: 'presentation'): Observed<unknown>;
|
|
29
39
|
export declare function useObserve(client: Client, topic: 'conversation', conversation: string, options: ConversationOptions): Observed<ConversationView>;
|
|
30
40
|
export declare function useObserve(client: Client, topic: 'conversations'): Observed<readonly ConversationEntry[]>;
|
|
31
41
|
export declare function useObserve(client: Client, topic: 'agents'): Observed<readonly ConversationAgent[]>;
|
|
42
|
+
export declare function useObserve(client: Client, topic: 'listed-agents'): Observed<readonly ListedAgent[]>;
|
|
43
|
+
export declare function useObserve(client: Client, topic: 'figures'): Observed<FiguresResult>;
|
|
44
|
+
export declare function useObserve(client: Client, topic: 'holdings'): Observed<Holdings>;
|
|
45
|
+
export declare function useExpected<A, T>(store: Expecting, descriptor: Descriptor<A, T>, places: readonly A[], held: ReadonlyMap<A, T> | null): (place: A, held: T) => T;
|
|
46
|
+
export type LaneHeld<O> = LaneShown<O> & Pick<Lane<O>, 'run' | 'forget'>;
|
|
47
|
+
export declare function useLane<O>(lanes: Acting<O>): LaneHeld<O>;
|
|
32
48
|
export type Saving = {
|
|
33
49
|
readonly busy: boolean;
|
|
34
50
|
readonly outcome: SaveResult | null;
|
|
35
51
|
readonly failure: RuntimeError | null;
|
|
36
|
-
save(room: string,
|
|
52
|
+
save(room: string, parts: ReadonlyMap<string, RoomDraftParts>): Promise<SaveResult>;
|
|
53
|
+
saveWritten(room: string, roomDrafts: readonly SavedRoomDraft[]): Promise<SaveResult>;
|
|
37
54
|
};
|
|
38
|
-
export declare function saveRoomDrafts(client: MdRuntimeClient, room: string, roomDrafts: ReadonlyMap<string, RoomDraftParts>): Promise<SaveResult>;
|
|
39
55
|
export declare function useSave(client: MdRuntimeClient): Saving;
|
|
40
56
|
export {};
|
|
41
57
|
//# sourceMappingURL=react.d.ts.map
|