@agentshouse/mdruntime 0.1.0-cf08ada271a7f → 0.1.0-cf08df9b663d8
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.map +1 -1
- package/dist/acceptance.js +57 -38
- 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 +8 -2
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +173 -83
- package/dist/adapter.d.ts +210 -30
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +0 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +2 -7
- 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/chain.d.ts +1 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/chain.js +5 -2
- package/dist/change.d.ts +6 -2
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +3 -0
- package/dist/chat-types.d.ts +0 -2
- package/dist/chat-types.d.ts.map +1 -1
- package/dist/chat-types.js +2 -4
- package/dist/client.d.ts +29 -24
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +49 -64
- package/dist/collection.d.ts +6 -1
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +23 -9
- 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 +4 -1
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +88 -44
- package/dist/connection.d.ts +1 -1
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +32 -17
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -1
- package/dist/conversation-live.d.ts +26 -11
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +24 -11
- package/dist/conversation-row.d.ts +23 -1
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +37 -8
- package/dist/conversation.d.ts +45 -11
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +337 -203
- package/dist/declaration.js +3 -3
- package/dist/discovery.d.ts +3 -1
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +46 -48
- 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 +6 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +7 -0
- package/dist/entry.d.ts +26 -1
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +126 -36
- package/dist/expectation.d.ts +25 -14
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +51 -20
- package/dist/failure.d.ts +2 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +6 -1
- package/dist/figures.d.ts +1 -1
- package/dist/figures.d.ts.map +1 -1
- package/dist/figures.js +6 -4
- 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.map +1 -1
- package/dist/holdings.js +5 -3
- package/dist/host.d.ts +7 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +94 -30
- 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 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +1 -1
- package/dist/index.d.ts +27 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -9
- package/dist/install.d.ts +10 -5
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +49 -55
- package/dist/lifecycle.d.ts +2 -2
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +74 -51
- package/dist/linked-file.d.ts +7 -0
- package/dist/linked-file.d.ts.map +1 -0
- package/dist/linked-file.js +13 -0
- package/dist/listing.d.ts +27 -20
- package/dist/listing.d.ts.map +1 -1
- package/dist/listing.js +68 -69
- package/dist/live.d.ts +19 -3
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +94 -36
- 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 +2 -4
- package/dist/locks.d.ts.map +1 -1
- package/dist/locks.js +10 -38
- package/dist/lost.d.ts.map +1 -1
- package/dist/lost.js +8 -20
- package/dist/media.d.ts +19 -3
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +181 -34
- package/dist/memory.d.ts +7 -3
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +99 -37
- package/dist/messages.d.ts +21 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +48 -16
- 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 +10 -7
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +7 -1
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +18 -35
- 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 +29 -12
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +206 -69
- 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 +4 -4
- package/dist/opening.d.ts.map +1 -1
- package/dist/opening.js +22 -10
- package/dist/outcome.d.ts +33 -13
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +36 -6
- package/dist/overlay.d.ts +21 -7
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +112 -39
- 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 +5 -9
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +30 -15
- package/dist/paths.d.ts +1 -1
- package/dist/paths.js +1 -1
- package/dist/preparation.d.ts +33 -7
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +207 -96
- 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 +2 -2
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +137 -79
- package/dist/query.d.ts +2 -2
- package/dist/query.d.ts.map +1 -1
- package/dist/questions.d.ts +1 -5
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +3 -8
- package/dist/queue.d.ts +2 -1
- package/dist/queue.d.ts.map +1 -1
- package/dist/queue.js +76 -49
- package/dist/reach.d.ts +15 -6
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +196 -37
- package/dist/react.d.ts +17 -5
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +28 -5
- package/dist/readiness.d.ts +23 -4
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +18 -10
- package/dist/reads.d.ts +5 -3
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +26 -14
- package/dist/recovery.d.ts +4 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +31 -8
- package/dist/refresh.d.ts +1 -1
- package/dist/refresh.js +4 -4
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +2 -4
- package/dist/replica.d.ts +3 -8
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +5 -5
- 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 +31 -6
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +262 -36
- package/dist/room-drafts.d.ts.map +1 -1
- package/dist/room-drafts.js +12 -7
- 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 +11 -3
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +25 -11
- 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 +11 -5
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts +2 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +120 -135
- package/dist/saves.d.ts +7 -5
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +116 -65
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +4 -4
- package/dist/selector.d.ts +3 -0
- package/dist/selector.d.ts.map +1 -0
- package/dist/selector.js +22 -0
- package/dist/shown.d.ts +8 -5
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +95 -67
- package/dist/socket/lanes.d.ts +12 -4
- package/dist/socket/lanes.d.ts.map +1 -1
- package/dist/socket/lanes.js +34 -8
- package/dist/socket/session.d.ts +4 -1
- package/dist/socket/session.d.ts.map +1 -1
- package/dist/socket/session.js +3 -0
- package/dist/socket.d.ts +9 -6
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +17 -16
- package/dist/source.d.ts +42 -7
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +76 -9
- package/dist/store/installs.d.ts +2 -2
- package/dist/store/installs.d.ts.map +1 -1
- package/dist/store/installs.js +10 -4
- package/dist/store/readiness.d.ts +5 -4
- package/dist/store/readiness.d.ts.map +1 -1
- package/dist/store/readiness.js +28 -12
- package/dist/store/records.d.ts +31 -7
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +70 -24
- 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.d.ts +24 -14
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +49 -17
- package/dist/stored.d.ts +41 -16
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +215 -57
- package/dist/surface.d.ts +20 -8
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +66 -32
- package/dist/sync.d.ts +4 -2
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +109 -82
- package/dist/tables.d.ts +40 -52
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +109 -326
- package/dist/tallies.d.ts.map +1 -1
- package/dist/tallies.js +3 -4
- package/dist/validation.d.ts +2 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +50 -10
- package/dist/wire.d.ts +68 -8
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +28 -11
- package/package.json +4 -4
- 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/job.d.ts +0 -5
- package/dist/job.d.ts.map +0 -1
- package/dist/job.js +0 -7
- package/dist/log.d.ts +0 -6
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -14
- package/dist/socket/rooms.d.ts +0 -41
- package/dist/socket/rooms.d.ts.map +0 -1
- package/dist/socket/rooms.js +0 -90
- package/dist/store/fences.d.ts +0 -16
- package/dist/store/fences.d.ts.map +0 -1
- package/dist/store/fences.js +0 -26
package/dist/reach.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import {
|
|
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';
|
|
2
5
|
import { unheldView } from './conversation.js';
|
|
3
|
-
import { modelTypes, NO_MODEL } from './model.js';
|
|
4
|
-
import { changeOf, digestApplied, digestOf, observing, } from './observation.js';
|
|
6
|
+
import { modelResult, modelTypes, NO_MODEL } from './model.js';
|
|
7
|
+
import { changeOf, digestApplied, digestOf, observing, unchanged, } from './observation.js';
|
|
5
8
|
import { runtimeError, uncaught } from './failure.js';
|
|
6
|
-
import { failure, lockedRoom, ROOM_LOCKED, undeclared, UNREADABLE, } from './outcome.js';
|
|
9
|
+
import { absentAttachment, failure, lockedRoom, ROOM_LOCKED, undeclared, UNREADABLE, } from './outcome.js';
|
|
7
10
|
import { beneath } from './paths.js';
|
|
8
11
|
import { moveTarget, readParts, staleWrite, } from './room-draft.js';
|
|
9
12
|
import { documentKey } from './rows.js';
|
|
@@ -20,15 +23,51 @@ const NO_CONVERSATION = {
|
|
|
20
23
|
interrupt: unconversed('conversations/interrupt'),
|
|
21
24
|
kill: unconversed('conversations/kill'),
|
|
22
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)),
|
|
23
36
|
};
|
|
24
37
|
const NO_CHAT_DRAFT = {
|
|
25
38
|
write: () => Promise.resolve(),
|
|
26
39
|
prepend: () => Promise.resolve(),
|
|
40
|
+
append: () => Promise.resolve(),
|
|
27
41
|
discard: () => Promise.resolve(),
|
|
28
42
|
};
|
|
29
43
|
function areasOf(reach) {
|
|
30
44
|
return reach.areas ?? [];
|
|
31
45
|
}
|
|
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
|
+
};
|
|
70
|
+
}
|
|
32
71
|
function fenced(reach, room, path) {
|
|
33
72
|
return areasOf(reach).some((area) => area.room === room &&
|
|
34
73
|
beneath(area.path, path) &&
|
|
@@ -61,6 +100,31 @@ function covers(reach, room, path) {
|
|
|
61
100
|
function conversing(reach) {
|
|
62
101
|
return reach === null || reach.conversations;
|
|
63
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
|
+
}
|
|
64
128
|
export function planReach(reach) {
|
|
65
129
|
return reach === null
|
|
66
130
|
? null
|
|
@@ -74,8 +138,31 @@ export function planReach(reach) {
|
|
|
74
138
|
.sort((left, right) => documentKey(left.room, left.path) < documentKey(right.room, right.path) ? -1 : 1),
|
|
75
139
|
};
|
|
76
140
|
}
|
|
77
|
-
function
|
|
78
|
-
|
|
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;
|
|
79
166
|
}
|
|
80
167
|
function typesWithin(reach, room, types) {
|
|
81
168
|
if (room === undefined)
|
|
@@ -106,12 +193,13 @@ function writeWithin(reach, write) {
|
|
|
106
193
|
function savedWithin(reach, room, result) {
|
|
107
194
|
if (reach === null || result.outcome === 'saved')
|
|
108
195
|
return result;
|
|
109
|
-
const { file, location, referrers, ...refusal } = result;
|
|
196
|
+
const { file, location, line, referrers, ...refusal } = result;
|
|
110
197
|
const hidden = file !== undefined && !covers(reach, room, file);
|
|
111
198
|
return {
|
|
112
199
|
...refusal,
|
|
113
200
|
...(file === undefined || hidden ? {} : { file }),
|
|
114
201
|
...(location === undefined || hidden ? {} : { location }),
|
|
202
|
+
...(line === undefined || hidden ? {} : { line }),
|
|
115
203
|
...(referrers === undefined
|
|
116
204
|
? {}
|
|
117
205
|
: { referrers: referrers.filter((path) => covers(reach, room, path)) }),
|
|
@@ -124,6 +212,18 @@ function statusWithin(reach, status) {
|
|
|
124
212
|
unsent: status.unsent.filter((change) => covers(reach, change.room, change.path)),
|
|
125
213
|
};
|
|
126
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
|
+
}
|
|
127
227
|
function queueWithin(reach, room, entries) {
|
|
128
228
|
return entries
|
|
129
229
|
.filter(({ batch }) => batch.changes.every((change) => covers(reach, room, change.path) &&
|
|
@@ -147,26 +247,48 @@ function deviceUnreached() {
|
|
|
147
247
|
return runtimeError('device-unreached', 'Only the panel reaches this device');
|
|
148
248
|
}
|
|
149
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
|
+
}
|
|
150
254
|
function attachRequired() {
|
|
151
|
-
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');
|
|
152
256
|
}
|
|
153
257
|
function carriesFile(parts) {
|
|
154
258
|
return parts !== null && typeof parts === 'object' && Object.hasOwn(parts, 'file');
|
|
155
259
|
}
|
|
156
|
-
export function narrowed(runtime, given,
|
|
260
|
+
export function narrowed(runtime, given, attached) {
|
|
157
261
|
const { md, watch } = runtime;
|
|
158
262
|
let reach = given;
|
|
263
|
+
let port = attached;
|
|
159
264
|
const open = new Set();
|
|
160
|
-
|
|
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) {
|
|
161
281
|
let stop = begin();
|
|
162
282
|
const restart = () => {
|
|
163
283
|
stop();
|
|
164
284
|
stop = begin();
|
|
165
285
|
};
|
|
166
286
|
open.add(restart);
|
|
287
|
+
restarts.add(restart);
|
|
167
288
|
const unwatch = locking ? runtime.watchLocks(restart) : () => { };
|
|
168
289
|
return () => {
|
|
169
290
|
open.delete(restart);
|
|
291
|
+
restarts.delete(restart);
|
|
170
292
|
unwatch();
|
|
171
293
|
stop();
|
|
172
294
|
};
|
|
@@ -231,10 +353,16 @@ export function narrowed(runtime, given, port) {
|
|
|
231
353
|
return () => { };
|
|
232
354
|
}
|
|
233
355
|
if (topic === 'rooms') {
|
|
234
|
-
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));
|
|
235
363
|
}
|
|
236
364
|
if (topic === 'readiness') {
|
|
237
|
-
return following(() => runtime.watchReadiness(port, reach, deliver));
|
|
365
|
+
return following(() => runtime.watchReadiness(port, reach, deliver), false, coded);
|
|
238
366
|
}
|
|
239
367
|
if (topic === 'sync-status') {
|
|
240
368
|
return following(() => unlockedWatch(topic, input, deliver, fail, (status, locked) => {
|
|
@@ -250,24 +378,31 @@ export function narrowed(runtime, given, port) {
|
|
|
250
378
|
return following(() => lockedFirst(room, () => watch(topic, input, (entries) => deliver(queueWithin(reach, room, entries)), fail), () => deliver([])), true);
|
|
251
379
|
}
|
|
252
380
|
if (topic === 'query') {
|
|
253
|
-
const planning = runtime.plan(input[0], reach);
|
|
254
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
|
+
};
|
|
255
389
|
return following(() => {
|
|
256
390
|
let open = true;
|
|
257
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;
|
|
258
396
|
void (async () => {
|
|
259
|
-
const plan = await
|
|
397
|
+
const plan = await planned;
|
|
260
398
|
const locked = await runtime.lockedRooms();
|
|
261
399
|
if (!open)
|
|
262
400
|
return;
|
|
401
|
+
if (plan === null)
|
|
402
|
+
return waiting({ pending: [] });
|
|
263
403
|
const pending = unlocking(plan.rooms, locked);
|
|
264
|
-
if (pending !== null)
|
|
265
|
-
|
|
266
|
-
if (held === null || changeOf(held, answer) !== null)
|
|
267
|
-
deliver(answer);
|
|
268
|
-
held = digestOf(answer);
|
|
269
|
-
return;
|
|
270
|
-
}
|
|
404
|
+
if (pending !== null)
|
|
405
|
+
return waiting(pending);
|
|
271
406
|
let first = true;
|
|
272
407
|
const heard = (message) => {
|
|
273
408
|
if (!first) {
|
|
@@ -281,8 +416,7 @@ export function narrowed(runtime, given, port) {
|
|
|
281
416
|
if (change !== null)
|
|
282
417
|
deliver(change);
|
|
283
418
|
};
|
|
284
|
-
|
|
285
|
-
stop = runtime.watchPlan(current, (message) => {
|
|
419
|
+
stop = runtime.watchPlan({ ...plan, locked }, (message) => {
|
|
286
420
|
if (open)
|
|
287
421
|
heard(message);
|
|
288
422
|
}, (error) => {
|
|
@@ -299,6 +433,9 @@ export function narrowed(runtime, given, port) {
|
|
|
299
433
|
};
|
|
300
434
|
}, true);
|
|
301
435
|
}
|
|
436
|
+
if (topic === 'runs') {
|
|
437
|
+
return following(() => unlockedWatch(topic, input, deliver, fail, (runs, locked) => runsWithin(reach, runsAsked(input[0]), runs, locked)), true);
|
|
438
|
+
}
|
|
302
439
|
if (topic === 'conversation') {
|
|
303
440
|
return following(() => {
|
|
304
441
|
if (conversing(reach))
|
|
@@ -315,7 +452,10 @@ export function narrowed(runtime, given, port) {
|
|
|
315
452
|
return () => { };
|
|
316
453
|
});
|
|
317
454
|
}
|
|
318
|
-
if (topic === 'figures' ||
|
|
455
|
+
if (topic === 'figures' ||
|
|
456
|
+
topic === 'holdings' ||
|
|
457
|
+
topic === 'listed-agents' ||
|
|
458
|
+
topic === 'room-list') {
|
|
319
459
|
if (reach === null)
|
|
320
460
|
return watch(topic, input, deliver, fail);
|
|
321
461
|
fail(deviceUnreached());
|
|
@@ -338,13 +478,16 @@ export function narrowed(runtime, given, port) {
|
|
|
338
478
|
const chatDraft = () => (conversing(reach) ? md.chatDraft : NO_CHAT_DRAFT);
|
|
339
479
|
const view = {
|
|
340
480
|
...md,
|
|
341
|
-
rooms: () => md.rooms().then((rooms) => roomsWithin(reach, rooms)),
|
|
481
|
+
rooms: () => md.rooms().then((rooms) => roomsWithin(reach, runtime.queried(), rooms)),
|
|
342
482
|
query: (async (input) => {
|
|
343
|
-
const plan = await runtime
|
|
483
|
+
const plan = await planInReach(runtime, input, reach, false);
|
|
484
|
+
if (plan === null)
|
|
485
|
+
return { pending: [] };
|
|
344
486
|
const locked = await runtime.lockedRooms();
|
|
345
487
|
return unlocking(plan.rooms, locked) ?? runtime.query({ ...plan, locked });
|
|
346
488
|
}),
|
|
347
489
|
search: (input) => runtime.search(input, reach),
|
|
490
|
+
queryHouse: (input, options) => runtime.queryHouse(input, reach, options),
|
|
348
491
|
async types(room) {
|
|
349
492
|
if (holds(reach, room) && (await runtime.locked(room)))
|
|
350
493
|
throw lockedError(room);
|
|
@@ -398,32 +541,32 @@ export function narrowed(runtime, given, port) {
|
|
|
398
541
|
: (await runtime.locked(room))
|
|
399
542
|
? lockedRoom(room)
|
|
400
543
|
: md.history(room, path, query),
|
|
401
|
-
|
|
544
|
+
attachment: {
|
|
402
545
|
read: async (room, path, revision) => !covers(reach, room, path)
|
|
403
546
|
? failure({ kind: 'room-not-readable', locator: room })
|
|
404
547
|
: (await runtime.locked(room))
|
|
405
548
|
? lockedRoom(room)
|
|
406
|
-
: hand(md.
|
|
549
|
+
: hand(md.attachment.read(room, path, revision)),
|
|
407
550
|
link: async (room, path, revision) => !covers(reach, room, path)
|
|
408
551
|
? failure({ kind: 'room-not-readable', locator: room })
|
|
409
552
|
: (await runtime.locked(room))
|
|
410
553
|
? lockedRoom(room)
|
|
411
|
-
: md.
|
|
554
|
+
: md.attachment.link(room, path, revision),
|
|
412
555
|
show: async (room, path, revision) => !covers(reach, room, path)
|
|
413
556
|
? failure({ kind: 'room-not-readable', locator: room })
|
|
414
557
|
: (await runtime.locked(room))
|
|
415
558
|
? lockedRoom(room)
|
|
416
|
-
: hand(md.
|
|
559
|
+
: hand(md.attachment.show(room, path, revision)),
|
|
417
560
|
attach: async (room, file) => !wholly(reach, room)
|
|
418
561
|
? failure({ kind: 'room-not-readable', locator: room })
|
|
419
562
|
: (await runtime.locked(room))
|
|
420
563
|
? lockedRoom(room)
|
|
421
|
-
: md.
|
|
564
|
+
: md.attachment.attach(room, file),
|
|
422
565
|
async part(file, part) {
|
|
423
566
|
const key = files.get(file);
|
|
424
567
|
if (key === undefined)
|
|
425
568
|
return null;
|
|
426
|
-
const bytes = await md.
|
|
569
|
+
const bytes = await md.attachment.part(key, part);
|
|
427
570
|
if (bytes === null)
|
|
428
571
|
files.delete(file);
|
|
429
572
|
return bytes;
|
|
@@ -432,9 +575,9 @@ export function narrowed(runtime, given, port) {
|
|
|
432
575
|
reached: async (room, roomVersion, path) => (path === undefined ? wholly(reach, room) : covers(reach, room, path)) &&
|
|
433
576
|
!(await runtime.locked(room)) &&
|
|
434
577
|
(await md.reached(room, roomVersion, path)),
|
|
435
|
-
log: () => (reach === null ? md.log() : ''),
|
|
436
578
|
cleanUp: () => (reach === null ? md.cleanUp() : Promise.reject(deviceUnreached())),
|
|
437
579
|
unsent: () => (reach === null ? md.unsent() : Promise.reject(deviceUnreached())),
|
|
580
|
+
sent: () => (reach === null ? md.sent() : Promise.reject(deviceUnreached())),
|
|
438
581
|
reset: () => (reach === null ? md.reset() : Promise.reject(deviceUnreached())),
|
|
439
582
|
readAgain: () => (reach === null ? md.readAgain() : Promise.reject(deviceUnreached())),
|
|
440
583
|
roomDraft: {
|
|
@@ -471,14 +614,25 @@ export function narrowed(runtime, given, port) {
|
|
|
471
614
|
read: (id, options) => conversation().read(id, options),
|
|
472
615
|
create: (input) => conversation().create(input),
|
|
473
616
|
send: (id, operation, draft) => conversation().send(id, operation, draft),
|
|
474
|
-
answer: (id, answer) => conversation().answer(id, answer),
|
|
475
|
-
interrupt: (id) => conversation().interrupt(id),
|
|
476
|
-
kill: (id) => conversation().kill(id),
|
|
477
|
-
delete: (id) => conversation().delete(id),
|
|
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),
|
|
478
631
|
},
|
|
479
632
|
chatDraft: {
|
|
480
633
|
write: (id, draft, revision) => chatDraft().write(id, draft, revision),
|
|
481
634
|
prepend: (id, draft) => chatDraft().prepend(id, draft),
|
|
635
|
+
append: (id, draft) => chatDraft().append(id, draft),
|
|
482
636
|
discard: (id) => chatDraft().discard(id),
|
|
483
637
|
},
|
|
484
638
|
observe: observing(within),
|
|
@@ -491,5 +645,10 @@ export function narrowed(runtime, given, port) {
|
|
|
491
645
|
for (const restart of [...open])
|
|
492
646
|
restart();
|
|
493
647
|
},
|
|
648
|
+
code(next) {
|
|
649
|
+
if (port.code !== next)
|
|
650
|
+
tiered({ ...port, code: next });
|
|
651
|
+
},
|
|
652
|
+
close: unread,
|
|
494
653
|
};
|
|
495
654
|
}
|
package/dist/react.d.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import type { DocumentQuery, GroupQuery } from '@agentshouse/mdmodel';
|
|
2
|
+
import type { Acting, Lane, LaneShown } from './act-lanes.js';
|
|
2
3
|
import type { MdRuntimeClient } from './client.js';
|
|
3
4
|
import type { AppRoom } from './listing.js';
|
|
4
5
|
import type { ConnectionRefusal } from './socket.js';
|
|
5
6
|
import type { SavedRoomDraft, SaveResult } from './saves.js';
|
|
6
|
-
import type { Member, ServiceMode } from './adapter.js';
|
|
7
|
+
import type { ListedAgent, Member, RoomList, ServiceMode } from './adapter.js';
|
|
7
8
|
import type { ConversationAgent, ConversationEntry, ConversationOptions, ConversationView } from './conversation.js';
|
|
8
9
|
import { type RuntimeError } from './failure.js';
|
|
9
10
|
import type { FiguresResult } from './figures.js';
|
|
10
11
|
import type { Holdings } from './holdings.js';
|
|
11
|
-
import type { Expecting } from './expectation.js';
|
|
12
|
+
import type { Descriptor, Expecting } from './expectation.js';
|
|
12
13
|
import type { QueueEntry } from './outcome.js';
|
|
13
14
|
import type { DocumentResult, GroupResult, PendingResult } from './query.js';
|
|
14
15
|
import type { Readiness } from './readiness.js';
|
|
16
|
+
import type { ObservedRead } from './reads.js';
|
|
17
|
+
import type { Runs } from './runs.js';
|
|
15
18
|
import type { RoomDraft, RoomDraftParts } from './room-draft.js';
|
|
16
19
|
import type { SyncStatus } from './status.js';
|
|
17
20
|
type Client = MdRuntimeClient | null;
|
|
@@ -29,6 +32,7 @@ export declare function useObserve(client: Client, topic: 'storage-loss'): Obser
|
|
|
29
32
|
export declare function useObserve(client: Client, topic: 'sync-status'): Observed<SyncStatus>;
|
|
30
33
|
export declare function useObserve(client: Client, topic: 'service-mode'): Observed<ServiceMode>;
|
|
31
34
|
export declare function useObserve(client: Client, topic: 'member'): Observed<Member | null>;
|
|
35
|
+
export declare function useObserve(client: Client, topic: 'time-zone'): Observed<string | null>;
|
|
32
36
|
export declare function useObserve(client: Client, topic: 'authority-changes'): Observed<number>;
|
|
33
37
|
export declare function useObserve(client: Client, topic: 'query', query: DocumentQuery): Observed<DocumentResult | PendingResult>;
|
|
34
38
|
export declare function useObserve(client: Client, topic: 'query', query: GroupQuery): Observed<GroupResult | PendingResult>;
|
|
@@ -38,11 +42,19 @@ export declare function useObserve(client: Client, topic: 'presentation'): Obser
|
|
|
38
42
|
export declare function useObserve(client: Client, topic: 'conversation', conversation: string, options: ConversationOptions): Observed<ConversationView>;
|
|
39
43
|
export declare function useObserve(client: Client, topic: 'conversations'): Observed<readonly ConversationEntry[]>;
|
|
40
44
|
export declare function useObserve(client: Client, topic: 'agents'): Observed<readonly ConversationAgent[]>;
|
|
45
|
+
export declare function useObserve(client: Client, topic: 'listed-agents'): Observed<readonly ListedAgent[]>;
|
|
46
|
+
export declare function useObserve(client: Client, topic: 'room-list'): Observed<RoomList | null>;
|
|
41
47
|
export declare function useObserve(client: Client, topic: 'figures'): Observed<FiguresResult>;
|
|
42
48
|
export declare function useObserve(client: Client, topic: 'holdings'): Observed<Holdings>;
|
|
43
|
-
export declare function
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
export declare function useObserve(client: Client, topic: 'read', name: string, input: unknown): Observed<ObservedRead>;
|
|
50
|
+
export declare function useObserve(client: Client, topic: 'runs', asked: {
|
|
51
|
+
room: string;
|
|
52
|
+
} | {
|
|
53
|
+
sent: true;
|
|
54
|
+
}): Observed<Runs | PendingResult>;
|
|
55
|
+
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;
|
|
56
|
+
export type LaneHeld<O> = LaneShown<O> & Pick<Lane<O>, 'run' | 'forget'>;
|
|
57
|
+
export declare function useLane<O>(lanes: Acting<O>): LaneHeld<O>;
|
|
46
58
|
export type Saving = {
|
|
47
59
|
readonly busy: boolean;
|
|
48
60
|
readonly outcome: SaveResult | null;
|
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,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC/E,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,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EA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AAS,CAAC,EAAE,EACpB,IAAI,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,GAC7B,CAAC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,CAmB1B;AAED,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC,CAAC;AAEzE,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAIxD;AAED,MAAM,MAAM,MAAM,GAAG;IACnB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI,CAAC;IACtC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACpF,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,cAAc,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACvF,CAAC;AAMF,wBAAgB,OAAO,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CA8BvD"}
|
package/dist/react.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCallback, useEffect, useId, useLayoutEffect, useRef, useState } from 'react';
|
|
1
|
+
import { useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore, } from 'react';
|
|
2
2
|
import { failed } from './failure.js';
|
|
3
3
|
const LOADING = { state: 'loading' };
|
|
4
4
|
export function useObserve(client, topic, ...input) {
|
|
@@ -32,14 +32,37 @@ export function useObserve(client, topic, ...input) {
|
|
|
32
32
|
}, [client, key]);
|
|
33
33
|
return held !== null && held.client === client && held.key === key ? held.observed : LOADING;
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
function sameHeld(descriptor, was, now) {
|
|
36
|
+
if (was === now)
|
|
37
|
+
return true;
|
|
38
|
+
if (was === null || now === null || was.size !== now.size)
|
|
39
|
+
return false;
|
|
40
|
+
const before = new Map([...was].map(([place, value]) => [descriptor.place(place), value]));
|
|
41
|
+
return [...now].every(([place, value]) => {
|
|
42
|
+
const at = descriptor.place(place);
|
|
43
|
+
return before.has(at) && Object.is(before.get(at), value);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
export function useExpected(store, descriptor, places, held) {
|
|
36
47
|
const reader = useId();
|
|
37
|
-
|
|
48
|
+
const version = useSyncExternalStore(store.subscribe, store.version);
|
|
49
|
+
const asked = JSON.stringify(places.map((one) => descriptor.place(one)));
|
|
50
|
+
const kept = useRef(held);
|
|
51
|
+
if (!sameHeld(descriptor, kept.current, held))
|
|
52
|
+
kept.current = held;
|
|
53
|
+
const shown = kept.current;
|
|
54
|
+
useLayoutEffect(() => store.reads(reader, descriptor, places), [store, reader, descriptor, asked]);
|
|
38
55
|
useLayoutEffect(() => () => store.left(reader), [store, reader]);
|
|
39
56
|
useEffect(() => {
|
|
40
57
|
if (shown !== null)
|
|
41
|
-
store.heard(reader, shown);
|
|
42
|
-
}, [store, reader, shown]);
|
|
58
|
+
store.heard(reader, descriptor, shown);
|
|
59
|
+
}, [store, reader, descriptor, shown]);
|
|
60
|
+
return useCallback((place, value) => store.draw(descriptor, place, value), [store, descriptor, version]);
|
|
61
|
+
}
|
|
62
|
+
export function useLane(lanes) {
|
|
63
|
+
const lane = useMemo(() => lanes.open(), [lanes]);
|
|
64
|
+
const shown = useSyncExternalStore(lane.subscribe, lane.shown);
|
|
65
|
+
return useMemo(() => ({ ...shown, run: lane.run, forget: lane.forget }), [shown, lane]);
|
|
43
66
|
}
|
|
44
67
|
const IDLE = { busy: false, outcome: null, failure: null };
|
|
45
68
|
export function useSave(client) {
|
package/dist/readiness.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { Open } from './open.js';
|
|
2
|
-
|
|
2
|
+
import type { ObservedRead } from './reads.js';
|
|
3
|
+
export type CodeAvailability = Open<'stored' | 'boot' | 'absent'>;
|
|
4
|
+
export type FirstTier = {
|
|
5
|
+
readonly handles: readonly string[];
|
|
6
|
+
readonly conversations: boolean;
|
|
7
|
+
readonly inboxes: boolean;
|
|
8
|
+
};
|
|
3
9
|
export type RoomPreparation = Open<'complete' | 'acquiring' | 'preparing' | 'unadmitted'>;
|
|
4
10
|
export type RoomCoverage = {
|
|
5
11
|
readonly room: string;
|
|
@@ -12,7 +18,7 @@ export type TargetCoverage = {
|
|
|
12
18
|
readonly rooms: readonly RoomCoverage[];
|
|
13
19
|
readonly conversations: ConversationCoverage;
|
|
14
20
|
};
|
|
15
|
-
export type Persistence = Open<'granted' | 'denied' | 'unavailable'>;
|
|
21
|
+
export type Persistence = Open<'granted' | 'denied' | 'unavailable' | 'memory'>;
|
|
16
22
|
export type Durability = Open<'persistent' | 'best-effort'>;
|
|
17
23
|
export type ConnectionAvailability = Open<'connected' | 'connecting' | 'unreachable'>;
|
|
18
24
|
export type HouseOutcome = Open<'open' | 'write-halted' | 'refused'>;
|
|
@@ -41,9 +47,22 @@ export type Readiness = {
|
|
|
41
47
|
readonly installation: Installation;
|
|
42
48
|
readonly lost: boolean;
|
|
43
49
|
};
|
|
50
|
+
export type ReadinessShown = Omit<Readiness, 'coverage'> & {
|
|
51
|
+
readonly coverage: Omit<TargetCoverage, 'rooms'>;
|
|
52
|
+
};
|
|
53
|
+
export type TierFacts = Omit<TargetCoverage, 'complete' | 'rooms'> & {
|
|
54
|
+
readonly unsettled: number;
|
|
55
|
+
};
|
|
44
56
|
export type ReadinessFacts = Omit<Readiness, 'status' | 'ready' | 'usable' | 'durability' | 'coverage'> & {
|
|
45
|
-
readonly coverage:
|
|
57
|
+
readonly coverage: TierFacts;
|
|
58
|
+
readonly first: TierFacts;
|
|
46
59
|
readonly established: boolean;
|
|
47
60
|
};
|
|
48
|
-
export declare
|
|
61
|
+
export declare const INBOXES_READ = "inbox";
|
|
62
|
+
export declare const INBOXES_LISTED: {
|
|
63
|
+
op: string;
|
|
64
|
+
};
|
|
65
|
+
export declare const COMPLETE_ROOMS: ReadonlySet<string>;
|
|
66
|
+
export declare function inboxRooms({ answer }: ObservedRead): readonly string[] | null;
|
|
67
|
+
export declare function readinessOf(facts: ReadinessFacts): ReadinessShown;
|
|
49
68
|
//# sourceMappingURL=readiness.d.ts.map
|
package/dist/readiness.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readiness.d.ts","sourceRoot":"","sources":["../src/readiness.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"readiness.d.ts","sourceRoot":"","sources":["../src/readiness.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAC,CAAC;AAElE,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,UAAU,GAAG,WAAW,GAAG,WAAW,GAAG,YAAY,CAAC,CAAC;AAE1F,MAAM,MAAM,YAAY,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK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AAE7C,eAAO,MAAM,cAAc,EAAE,WAAW,CAAC,MAAM,CAAuC,CAAC;AAEvF,wBAAgB,UAAU,CAAC,EAAE,MAAM,EAAE,EAAE,YAAY,GAAG,SAAS,MAAM,EAAE,GAAG,IAAI,CAI7E;AAQD,wBAAgB,WAAW,CAAC,KAAK,EAAE,cAAc,GAAG,cAAc,CAsBjE"}
|
package/dist/readiness.js
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
|
-
const
|
|
1
|
+
export const INBOXES_READ = 'inbox';
|
|
2
|
+
export const INBOXES_LISTED = { op: 'list' };
|
|
3
|
+
export const COMPLETE_ROOMS = new Set(['complete', 'unadmitted']);
|
|
4
|
+
export function inboxRooms({ answer }) {
|
|
5
|
+
if (answer === null)
|
|
6
|
+
return null;
|
|
7
|
+
const { inboxes } = answer;
|
|
8
|
+
return [...new Set(inboxes.flatMap(({ room }) => (room === undefined ? [] : [room])))].sort();
|
|
9
|
+
}
|
|
10
|
+
function held({ listed, conversations, unsettled }) {
|
|
11
|
+
return (listed && (conversations === 'complete' || conversations === 'undeclared') && unsettled === 0);
|
|
12
|
+
}
|
|
2
13
|
export function readinessOf(facts) {
|
|
3
|
-
const { established, coverage:
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const stored = facts.code === 'stored';
|
|
10
|
-
const ready = stored && complete;
|
|
11
|
-
const usable = stored && (ready || established);
|
|
14
|
+
const { established, first, coverage: whole, ...reported } = facts;
|
|
15
|
+
const complete = held(whole);
|
|
16
|
+
const coverage = { listed: whole.listed, conversations: whole.conversations, complete };
|
|
17
|
+
const ready = facts.code === 'stored' && complete;
|
|
18
|
+
const boot = facts.code === 'boot' || facts.code === 'stored';
|
|
19
|
+
const usable = ready || (boot && (held(first) || established));
|
|
12
20
|
const status = ready
|
|
13
21
|
? 'ready'
|
|
14
22
|
: facts.space !== null
|