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