@agentshouse/mdruntime 0.1.0-c26a54071744b → 0.1.0-c27d511fb284d
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 +18 -16
- package/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +32 -22
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +51 -28
- package/dist/adapter.d.ts +136 -29
- 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 +347 -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 +20 -15
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +28 -57
- 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 +2 -1
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +73 -42
- package/dist/connection.d.ts +1 -1
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +14 -14
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -1
- package/dist/conversation-live.d.ts +19 -9
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +18 -8
- package/dist/conversation-row.d.ts +8 -1
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +20 -7
- package/dist/conversation.d.ts +29 -12
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +241 -177
- 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 +30 -8
- 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 +2 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +7 -0
- package/dist/entry.d.ts +25 -1
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +111 -34
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +3 -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/host.d.ts +7 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +75 -31
- 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 +20 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -6
- package/dist/install.d.ts +9 -3
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +44 -46
- package/dist/lifecycle.d.ts +1 -1
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +40 -29
- package/dist/listing.d.ts +24 -12
- package/dist/listing.d.ts.map +1 -1
- package/dist/listing.js +50 -21
- 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.map +1 -1
- package/dist/locks.js +4 -3
- package/dist/lost.d.ts.map +1 -1
- package/dist/lost.js +2 -3
- 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 +63 -23
- package/dist/messages.d.ts +17 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +29 -10
- 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 +5 -8
- 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 +5 -5
- package/dist/opened.d.ts.map +1 -1
- package/dist/opened.js +2 -2
- package/dist/opening.d.ts.map +1 -1
- package/dist/opening.js +20 -10
- package/dist/outcome.d.ts +30 -13
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +21 -6
- package/dist/overlay.d.ts +20 -9
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +110 -41
- package/dist/parts.d.ts +3 -0
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +31 -5
- 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 +198 -87
- package/dist/presence.d.ts +8 -2
- package/dist/presence.d.ts.map +1 -1
- package/dist/presence.js +24 -13
- package/dist/queries.d.ts +1 -1
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +116 -71
- package/dist/query.d.ts +2 -2
- package/dist/query.d.ts.map +1 -1
- package/dist/questions.d.ts +1 -0
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +3 -1
- package/dist/queue.d.ts +1 -1
- package/dist/queue.d.ts.map +1 -1
- package/dist/queue.js +54 -39
- package/dist/reach.d.ts +15 -6
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +162 -38
- package/dist/react.d.ts +6 -1
- package/dist/react.d.ts.map +1 -1
- 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 +1 -1
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +17 -6
- package/dist/recovery.d.ts +1 -0
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +2 -1
- package/dist/reference-forms.d.ts +4 -0
- package/dist/reference-forms.d.ts.map +1 -0
- package/dist/reference-forms.js +74 -0
- package/dist/refresh.d.ts +1 -1
- package/dist/refresh.js +4 -4
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +1 -3
- package/dist/replica.d.ts +3 -8
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +5 -5
- package/dist/room-draft.d.ts +29 -4
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +239 -18
- 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 +45 -0
- package/dist/rows.d.ts +11 -2
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +24 -10
- package/dist/running.d.ts +5 -0
- package/dist/running.d.ts.map +1 -0
- package/dist/running.js +10 -0
- package/dist/runtime.d.ts +5 -4
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts +1 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +17 -86
- package/dist/saves.d.ts +7 -5
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +107 -57
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +2 -2
- 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 +5 -2
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +79 -43
- 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 +2 -2
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +3 -9
- package/dist/source.d.ts +7 -0
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +15 -2
- 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 +30 -8
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +70 -26
- 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 +15 -10
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +12 -5
- 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 +13 -8
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +57 -26
- package/dist/sync.d.ts +4 -2
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +52 -35
- package/dist/tables.d.ts +28 -52
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +95 -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 +36 -17
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +20 -14
- package/package.json +4 -4
- package/dist/binary.d.ts.map +0 -1
- package/dist/binary.js +0 -8
- package/dist/log.d.ts +0 -6
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -14
package/dist/queries.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { identityOf } from '@agentshouse/mdmodel';
|
|
2
2
|
import { ROOM_TOTALS } from './figures.js';
|
|
3
3
|
import { roomInFlight } from './install.js';
|
|
4
|
+
import { hearerOf, readerOf, } from './live.js';
|
|
4
5
|
import { compositionFor, roomFacts } from './listing.js';
|
|
5
6
|
import { lockedRooms } from './locks.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
7
|
+
import { askedOnline, offline } from './online.js';
|
|
8
|
+
import { OFFLINE, UNCERTAIN, failure, undeclared } from './outcome.js';
|
|
9
|
+
import { prepare } from './preparation.js';
|
|
8
10
|
import { planWithin, } from './query.js';
|
|
9
11
|
import { planReach } from './reach.js';
|
|
10
|
-
import {
|
|
11
|
-
import { documentKey } from './rows.js';
|
|
12
|
+
import { documentKey, roomsOfReach } from './rows.js';
|
|
12
13
|
import { searchPlanOf } from './search.js';
|
|
13
14
|
import { seedApplies, seededResult, watchSeeded } from './seed.js';
|
|
14
15
|
import { capped, MAXIMUM_WINDOW } from './windows.js';
|
|
@@ -22,35 +23,47 @@ function everyRoom({ presence }, held) {
|
|
|
22
23
|
]),
|
|
23
24
|
];
|
|
24
25
|
}
|
|
26
|
+
function anyHeld({ presence }, held, locator) {
|
|
27
|
+
return (presence.room(locator) !== undefined || held.rooms.has(locator) || held.queues.has(locator));
|
|
28
|
+
}
|
|
29
|
+
function anyRoom(plan) {
|
|
30
|
+
return plan.rooms === null && plan.reach === null;
|
|
31
|
+
}
|
|
32
|
+
function reaching(runtime, plan, reads, held) {
|
|
33
|
+
if (!anyRoom(plan))
|
|
34
|
+
return reads;
|
|
35
|
+
return (locator) => reads(locator) && anyHeld(runtime, held, locator);
|
|
36
|
+
}
|
|
25
37
|
function reachedRooms(runtime, plan, held) {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
return [...new Set(named)]
|
|
29
|
-
.filter((locator) => (reached === null || reached.has(locator)) && !plan.locked.includes(locator))
|
|
30
|
-
.sort();
|
|
38
|
+
const named = plan.rooms ?? (plan.reach === null ? everyRoom(runtime, held) : roomsOfReach(plan.reach));
|
|
39
|
+
return [...new Set(named)].filter(reaching(runtime, plan, readerOf(plan), held)).sort();
|
|
31
40
|
}
|
|
32
41
|
function awaited({ socket, presence }, locator) {
|
|
33
42
|
return (!socket.session.now().roomsListed || presence.room(locator)?.replica.admission === 'admitted');
|
|
34
43
|
}
|
|
44
|
+
function awaitsOf(runtime, locator, held) {
|
|
45
|
+
const replica = held.rooms.get(locator);
|
|
46
|
+
if (replica === undefined)
|
|
47
|
+
return awaited(runtime, locator) ? 'acquisition' : null;
|
|
48
|
+
return replica.indexed ? null : 'preparation';
|
|
49
|
+
}
|
|
35
50
|
function coveredRooms(runtime, locators, whole, held) {
|
|
36
51
|
const { store, socket } = runtime;
|
|
37
|
-
if (
|
|
52
|
+
if (whole &&
|
|
53
|
+
!socket.session.now().roomsListed &&
|
|
54
|
+
(locators.length === 0 || !store.device.now().completedWhenOpened))
|
|
38
55
|
return { pending: [] };
|
|
39
56
|
const pending = [];
|
|
40
57
|
const coverage = [];
|
|
41
58
|
const overlay = [];
|
|
42
59
|
const read = [];
|
|
43
60
|
for (const locator of locators) {
|
|
61
|
+
const awaits = awaitsOf(runtime, locator, held);
|
|
62
|
+
if (awaits !== null)
|
|
63
|
+
pending.push({ room: locator, awaits });
|
|
44
64
|
const replica = held.rooms.get(locator);
|
|
45
|
-
if (replica === undefined)
|
|
46
|
-
if (awaited(runtime, locator))
|
|
47
|
-
pending.push({ room: locator, awaits: 'acquisition' });
|
|
65
|
+
if (awaits !== null || replica === undefined)
|
|
48
66
|
continue;
|
|
49
|
-
}
|
|
50
|
-
if (!replica.indexed) {
|
|
51
|
-
pending.push({ room: locator, awaits: 'preparation' });
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
67
|
coverage.push({
|
|
55
68
|
room: locator,
|
|
56
69
|
generation: replica.transfer,
|
|
@@ -64,8 +77,43 @@ function coveredRooms(runtime, locators, whole, held) {
|
|
|
64
77
|
return { pending };
|
|
65
78
|
return { coverage: { rooms: coverage, overlay }, rooms: read };
|
|
66
79
|
}
|
|
80
|
+
const UNFOLLOWED = { held: [], awaiting: [] };
|
|
81
|
+
function followsOf(runtime, plan, held) {
|
|
82
|
+
if (plan.hop === null)
|
|
83
|
+
return UNFOLLOWED;
|
|
84
|
+
const reached = plan.reach === null ? everyRoom(runtime, held) : roomsOfReach(plan.reach);
|
|
85
|
+
const reads = hearerOf(plan);
|
|
86
|
+
const follows = [];
|
|
87
|
+
const awaiting = [];
|
|
88
|
+
for (const locator of [...new Set(reached)].filter(reads).sort()) {
|
|
89
|
+
const replica = held.rooms.get(locator);
|
|
90
|
+
const awaits = awaitsOf(runtime, locator, held);
|
|
91
|
+
if (awaits === null) {
|
|
92
|
+
if (replica !== undefined)
|
|
93
|
+
follows.push({ locator, key: replica.key });
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
const handle = replica?.handle ?? runtime.presence.room(locator)?.handle;
|
|
97
|
+
if (handle !== undefined)
|
|
98
|
+
awaiting.push({ room: locator, awaits, handle });
|
|
99
|
+
}
|
|
100
|
+
return { held: follows, awaiting };
|
|
101
|
+
}
|
|
67
102
|
function covered(runtime, plan, held) {
|
|
68
|
-
|
|
103
|
+
const cover = coveredRooms(runtime, reachedRooms(runtime, plan, held), anyRoom(plan), held);
|
|
104
|
+
return 'pending' in cover ? cover : { ...cover, follows: followsOf(runtime, plan, held) };
|
|
105
|
+
}
|
|
106
|
+
function pendingAt(runtime, plan, reads, held, rooms) {
|
|
107
|
+
const reached = reaching(runtime, plan, reads, held);
|
|
108
|
+
const at = new Map();
|
|
109
|
+
for (const room of rooms) {
|
|
110
|
+
const awaits = reached(room) ? awaitsOf(runtime, room, held) : null;
|
|
111
|
+
at.set(room, awaits === null ? null : { room, awaits });
|
|
112
|
+
}
|
|
113
|
+
awaitPreparation(runtime, {
|
|
114
|
+
pending: [...at.values()].filter((room) => room !== null),
|
|
115
|
+
});
|
|
116
|
+
return at;
|
|
69
117
|
}
|
|
70
118
|
function awaitPreparation(runtime, cover) {
|
|
71
119
|
if (!('pending' in cover))
|
|
@@ -87,8 +135,8 @@ export async function figuresCover(runtime) {
|
|
|
87
135
|
function sameCover(left, right) {
|
|
88
136
|
return JSON.stringify(left) === JSON.stringify(right);
|
|
89
137
|
}
|
|
90
|
-
async function windowRows(local, plan, rooms, unchanged) {
|
|
91
|
-
const first = await local.query(plan, rooms, QUERY_BYTES);
|
|
138
|
+
async function windowRows(local, plan, rooms, follows, unchanged) {
|
|
139
|
+
const first = await local.query(plan, rooms, follows, QUERY_BYTES);
|
|
92
140
|
if (first.more === undefined || !('documents' in first)) {
|
|
93
141
|
const { more: _more, ...rows } = first;
|
|
94
142
|
return rows;
|
|
@@ -102,7 +150,7 @@ async function windowRows(local, plan, rooms, unchanged) {
|
|
|
102
150
|
after: { text: more, values: JSON.parse(more) },
|
|
103
151
|
limit: plan.limit === null ? null : plan.limit - documents.length,
|
|
104
152
|
total: false,
|
|
105
|
-
}, rooms, QUERY_BYTES);
|
|
153
|
+
}, rooms, follows, QUERY_BYTES);
|
|
106
154
|
if (!('documents' in page))
|
|
107
155
|
return null;
|
|
108
156
|
documents.push(...page.documents);
|
|
@@ -131,17 +179,34 @@ async function composedRooms(runtime, plan, rooms) {
|
|
|
131
179
|
: { ...room, composition: compositionFor(runtime, stored.record) };
|
|
132
180
|
});
|
|
133
181
|
}
|
|
182
|
+
async function awaitedFollows(runtime, local, plan, cover) {
|
|
183
|
+
const { awaiting } = cover.follows;
|
|
184
|
+
if (awaiting.length === 0)
|
|
185
|
+
return [];
|
|
186
|
+
const named = new Set(await local.named(plan, cover.rooms, awaiting.map(({ handle }) => handle)));
|
|
187
|
+
const pending = awaiting
|
|
188
|
+
.filter(({ handle }) => named.has(handle))
|
|
189
|
+
.map(({ room, awaits }) => ({ room, awaits }));
|
|
190
|
+
awaitPreparation(runtime, { pending });
|
|
191
|
+
return pending;
|
|
192
|
+
}
|
|
134
193
|
async function coveredRows(runtime, plan, cover) {
|
|
135
194
|
const { store } = runtime;
|
|
136
195
|
for (;;) {
|
|
137
196
|
const before = await cover();
|
|
138
197
|
if ('pending' in before)
|
|
139
|
-
return { pending: before };
|
|
198
|
+
return { pending: before, cover: before };
|
|
140
199
|
const local = await store.open();
|
|
141
|
-
const
|
|
200
|
+
const awaited = await awaitedFollows(runtime, local, plan, before);
|
|
201
|
+
if (awaited.length > 0) {
|
|
202
|
+
if (sameCover(before, await cover()))
|
|
203
|
+
return { pending: { pending: awaited }, cover: before };
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
const keys = [...before.rooms, ...before.follows.held].map(({ key }) => key);
|
|
142
207
|
const changes = local.changes(keys);
|
|
143
208
|
const current = () => local.changes(keys) === changes;
|
|
144
|
-
const rows = await windowRows(local, plan, await composedRooms(runtime, plan, before.rooms), current);
|
|
209
|
+
const rows = await windowRows(local, plan, await composedRooms(runtime, plan, before.rooms), before.follows.held, current);
|
|
145
210
|
const after = await cover();
|
|
146
211
|
if (rows !== null && sameCover(before, after))
|
|
147
212
|
return { rows, cover: before, current };
|
|
@@ -162,11 +227,14 @@ function keyedOf(rows, coverage) {
|
|
|
162
227
|
export async function answeredPlan(runtime, plan, cover) {
|
|
163
228
|
const answered = await coveredRows(runtime, plan, cover);
|
|
164
229
|
if ('pending' in answered) {
|
|
165
|
-
|
|
166
|
-
return { result: pending, keys: [], current: () => true };
|
|
230
|
+
return { result: answered.pending, keys: [], current: () => true, cover: answered.cover };
|
|
167
231
|
}
|
|
168
232
|
const held = answered.cover;
|
|
169
|
-
return {
|
|
233
|
+
return {
|
|
234
|
+
...keyedOf(answered.rows, held.coverage),
|
|
235
|
+
current: answered.current,
|
|
236
|
+
cover: answered.cover,
|
|
237
|
+
};
|
|
170
238
|
}
|
|
171
239
|
async function coverNow(runtime, plan) {
|
|
172
240
|
const cover = covered(runtime, plan, await runtime.store.covering());
|
|
@@ -204,11 +272,14 @@ export async function roomTallies(runtime, rooms, since) {
|
|
|
204
272
|
});
|
|
205
273
|
}
|
|
206
274
|
export function watchPlan(runtime, plan, deliver, fail) {
|
|
275
|
+
const reads = readerOf(plan);
|
|
207
276
|
return watchSeeded(runtime, plan, deliver, (behind, answered) => runtime.liveQueries.watch(plan, identityOf(plan), (held) => {
|
|
208
277
|
const cover = covered(runtime, plan, held);
|
|
209
278
|
awaitPreparation(runtime, cover);
|
|
210
279
|
return behind(cover, held);
|
|
211
|
-
},
|
|
280
|
+
}, (held, rooms) => runtime.store.seeds.of(plan.key) === undefined
|
|
281
|
+
? pendingAt(runtime, plan, reads, held, rooms)
|
|
282
|
+
: null, answered, fail));
|
|
212
283
|
}
|
|
213
284
|
export function watchPlanned(runtime, planning, deliver, fail) {
|
|
214
285
|
let stop = null;
|
|
@@ -226,22 +297,13 @@ export function watchPlanned(runtime, planning, deliver, fail) {
|
|
|
226
297
|
};
|
|
227
298
|
}
|
|
228
299
|
export async function searched(runtime, input, reach) {
|
|
229
|
-
const { store, socket
|
|
230
|
-
const
|
|
300
|
+
const { store, socket } = runtime;
|
|
301
|
+
const search = socket.search();
|
|
302
|
+
if (search === undefined)
|
|
303
|
+
return undeclared('search');
|
|
231
304
|
const asked = searchPlanOf(input);
|
|
232
305
|
await socket.ready;
|
|
233
|
-
|
|
234
|
-
if (search === undefined) {
|
|
235
|
-
return {
|
|
236
|
-
kind: 'undeclared',
|
|
237
|
-
code: 'action-undeclared',
|
|
238
|
-
fields: { name: 'search' },
|
|
239
|
-
retryable: false,
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
if (socket.closed() ||
|
|
243
|
-
session.now().refusal !== null ||
|
|
244
|
-
(await connectionNow(runtime)) !== 'connected')
|
|
306
|
+
if (await offline(runtime))
|
|
245
307
|
return OFFLINE;
|
|
246
308
|
const reached = reach === null ? null : new Set(reach.rooms);
|
|
247
309
|
const named = asked.rooms === null
|
|
@@ -253,33 +315,16 @@ export async function searched(runtime, input, reach) {
|
|
|
253
315
|
const rooms = named === null ? null : named.filter((room) => held.has(room)).sort();
|
|
254
316
|
if (rooms !== null && rooms.length === 0)
|
|
255
317
|
return { kind: 'found', documents: [] };
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
}
|
|
259
|
-
catch {
|
|
318
|
+
const result = await askedOnline(runtime, (authorization) => search(authorization, { text: asked.text, rooms }));
|
|
319
|
+
if (result === null)
|
|
260
320
|
return UNCERTAIN;
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
if (
|
|
264
|
-
return
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
journal.record(`outcome search ${result.kind}`);
|
|
271
|
-
if (result.kind === 'rejected')
|
|
272
|
-
return result;
|
|
273
|
-
if (result.kind !== 'found')
|
|
274
|
-
return failure(result);
|
|
275
|
-
const kept = rooms === null ? null : new Set(rooms);
|
|
276
|
-
return {
|
|
277
|
-
kind: 'found',
|
|
278
|
-
documents: result.documents.filter((hit) => kept === null || kept.has(hit.room)),
|
|
279
|
-
};
|
|
280
|
-
}
|
|
281
|
-
catch {
|
|
282
|
-
journal.record('outcome search transport-uncertainty');
|
|
283
|
-
return UNCERTAIN;
|
|
284
|
-
}
|
|
321
|
+
if (result.kind === 'rejected')
|
|
322
|
+
return result;
|
|
323
|
+
if (result.kind !== 'found')
|
|
324
|
+
return failure(result);
|
|
325
|
+
const kept = rooms === null ? null : new Set(rooms);
|
|
326
|
+
return {
|
|
327
|
+
kind: 'found',
|
|
328
|
+
documents: result.documents.filter((hit) => kept === null || kept.has(hit.room)),
|
|
329
|
+
};
|
|
285
330
|
}
|
package/dist/query.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type HeldRooms, type QueryPlan } from '@agentshouse/mdmodel';
|
|
2
2
|
import type { HeadChange } from './adapter.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { AttachmentRecord } from './attachment.js';
|
|
4
4
|
import type { Open } from './open.js';
|
|
5
5
|
export type Backlink = {
|
|
6
6
|
path: string;
|
|
@@ -19,7 +19,7 @@ export type QueryDocument = {
|
|
|
19
19
|
change?: HeadChange | null;
|
|
20
20
|
fileId?: string | null;
|
|
21
21
|
revision?: string | null;
|
|
22
|
-
|
|
22
|
+
attachment?: AttachmentRecord;
|
|
23
23
|
size?: number | null;
|
|
24
24
|
created?: string | null;
|
|
25
25
|
};
|
package/dist/query.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,MAAM,QAAQ,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAErE,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM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I,CAAC;IACxB,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3B,CAAC;AAEF,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,GAAE,SAAS,GAAG,IAAW,GAAG,IAAI,CAEjG"}
|
package/dist/questions.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export type ChatQuestion = {
|
|
|
16
16
|
readonly interaction: string;
|
|
17
17
|
readonly asked: string | null;
|
|
18
18
|
readonly secret: boolean;
|
|
19
|
+
readonly page: string | null;
|
|
19
20
|
readonly message: string;
|
|
20
21
|
readonly fields: readonly ChatField[];
|
|
21
22
|
readonly undelivered: boolean;
|
package/dist/questions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"questions.d.ts","sourceRoot":"","sources":["../src/questions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAG1D,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,cAAc,CAAC;IAC5E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAE3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CAAC;AAE3D,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,CAAC;IACtC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B,CAAC;AAuCF,wBAAgB,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAEjD;AA4DD,wBAAgB,WAAW,CACzB,IAAI,EAAE,IAAI,CAAC,gBAAgB,EAAE,WAAW,CAAC,GAAG,IAAI,GAC/C,SAAS,YAAY,EAAE,CAkBzB;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,GAAG,IAAI,CAKzE;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,GAAG,IAAI,CAE1E"}
|
package/dist/questions.js
CHANGED
|
@@ -54,8 +54,9 @@ function askedOf(request) {
|
|
|
54
54
|
const params = record(request.params);
|
|
55
55
|
const method = text(request, 'method');
|
|
56
56
|
if (method === 'session/request_permission') {
|
|
57
|
+
const air = record(record(record(params._meta).jetbrains).air);
|
|
57
58
|
return {
|
|
58
|
-
message: '',
|
|
59
|
+
message: text(record(air.permission), 'description') ?? '',
|
|
59
60
|
fields: [
|
|
60
61
|
{
|
|
61
62
|
name: OPTION,
|
|
@@ -97,6 +98,7 @@ export function questionsOf(view) {
|
|
|
97
98
|
interaction,
|
|
98
99
|
asked: text(one, 'asked_at'),
|
|
99
100
|
secret: one.secret === true,
|
|
101
|
+
page: one.secret === true ? text(one, 'page') : null,
|
|
100
102
|
undelivered: one.telegram_undelivered === true,
|
|
101
103
|
...asked,
|
|
102
104
|
},
|
package/dist/queue.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { Runtime } from './runtime.js';
|
|
|
5
5
|
import type { SavePlan } from './save.js';
|
|
6
6
|
import type { SaveResult } from './saves.js';
|
|
7
7
|
import type { PendingState, RoomCommit, Store, StoredFile, View, Work } from './store.js';
|
|
8
|
-
export type Queueing = Pick<Runtime, 'store' | '
|
|
8
|
+
export type Queueing = Pick<Runtime, 'store' | 'localSaves'> & {
|
|
9
9
|
readonly socket: Pick<Runtime['socket'], 'continuing'>;
|
|
10
10
|
readonly presence: Pick<Runtime['presence'], 'lost' | 'unheldModel' | 'room'>;
|
|
11
11
|
};
|
package/dist/queue.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../src/queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAmC,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAKhF,OAAO,EAUL,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,QAAQ,EACb,KAAK,KAAK,EAEX,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../src/queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAmC,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAKhF,OAAO,EAUL,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,QAAQ,EACb,KAAK,KAAK,EAEX,MAAM,cAAc,CAAC;AAUtB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,c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7 @@ import { declared } from './declaration.js';
|
|
|
5
5
|
import { runtimeError } from './failure.js';
|
|
6
6
|
import { roomDraftRevision } from './identity.js';
|
|
7
7
|
import { landed, movedBy, overlayOf, replaying, slicing, slicingWith, standing, storedRecord, touchedBy, } from './replica.js';
|
|
8
|
-
import { returnedBy, returnedInto } from './room-draft.js';
|
|
8
|
+
import { joinedOver, marksOver, returnedBy, returnedInto, } from './room-draft.js';
|
|
9
9
|
import { documentKey } from './rows.js';
|
|
10
10
|
import { stepped } from './turn.js';
|
|
11
11
|
export function withdrawable(states) {
|
|
@@ -38,7 +38,7 @@ async function landedWhole(store, record, batch, confirmedLayer, current) {
|
|
|
38
38
|
return false;
|
|
39
39
|
return landed(half, await sliceAt(store, other.record, 'confirmed', [half]), store.composed(other.record));
|
|
40
40
|
}
|
|
41
|
-
async function returnedDrafts(store, locator, work, leaving, composition) {
|
|
41
|
+
async function returnedDrafts(store, locator, work, leaving, composition, visible) {
|
|
42
42
|
const written = new Map();
|
|
43
43
|
for (const { batch, returned } of leaving) {
|
|
44
44
|
if (returned === null || batch.between?.destination.room === locator)
|
|
@@ -46,9 +46,18 @@ async function returnedDrafts(store, locator, work, leaving, composition) {
|
|
|
46
46
|
for (const saved of work.states.get(batch.id)?.drafts ?? []) {
|
|
47
47
|
const existing = written.get(saved.path) ?? (await store.draft(locator, saved.path));
|
|
48
48
|
const parts = returnedInto(existing?.parts, saved.parts, composition === undefined ? undefined : definitionsAt(composition, saved.path));
|
|
49
|
-
|
|
49
|
+
const record = parts === null
|
|
50
50
|
? { ...existing, returned }
|
|
51
|
-
: {
|
|
51
|
+
: {
|
|
52
|
+
locator,
|
|
53
|
+
path: saved.path,
|
|
54
|
+
revision: roomDraftRevision(),
|
|
55
|
+
parts,
|
|
56
|
+
marks: existing?.marks ?? {},
|
|
57
|
+
returned,
|
|
58
|
+
};
|
|
59
|
+
const join = visible === undefined ? null : joinedOver(record.parts, record.marks, saved.path, visible);
|
|
60
|
+
written.set(saved.path, join === null ? record : { ...record, ...join, revision: roomDraftRevision() });
|
|
52
61
|
}
|
|
53
62
|
}
|
|
54
63
|
return written;
|
|
@@ -90,6 +99,7 @@ async function carriedBack(runtime, locator, unlanded, written) {
|
|
|
90
99
|
path,
|
|
91
100
|
revision: roomDraftRevision(),
|
|
92
101
|
parts,
|
|
102
|
+
marks: marksOver(existing?.marks ?? {}, record.marks),
|
|
93
103
|
returned: existing?.returned ?? null,
|
|
94
104
|
});
|
|
95
105
|
}
|
|
@@ -166,7 +176,7 @@ async function together(runtime, local, settlements) {
|
|
|
166
176
|
return mergeChangeSets(all.map((one) => one.apply(answer)));
|
|
167
177
|
}
|
|
168
178
|
async function settlement(runtime, local, locator, work, record, queue, settling = {}) {
|
|
169
|
-
const { store,
|
|
179
|
+
const { store, localSaves } = runtime;
|
|
170
180
|
const before = work.replica;
|
|
171
181
|
const view = settling.view ?? 'confirmed';
|
|
172
182
|
const previousQueue = work.queue;
|
|
@@ -175,37 +185,47 @@ async function settlement(runtime, local, locator, work, record, queue, settling
|
|
|
175
185
|
...(before !== undefined && before.record.key === record.key ? before.overlaid : []),
|
|
176
186
|
...(overrides?.set.map(({ path }) => path) ?? []),
|
|
177
187
|
...(overrides?.removed ?? []),
|
|
188
|
+
...[...work.states.values()].flatMap(({ drafts }) => drafts.map(({ path }) => path)),
|
|
178
189
|
]);
|
|
179
190
|
const confirmedLayer = overrides === undefined
|
|
180
191
|
? read
|
|
181
192
|
: await stepped(slicingWith(read, overrides.set, overrides.removed));
|
|
182
193
|
const composition = store.composed(record);
|
|
183
194
|
const shown = queue.filter((batch) => {
|
|
184
|
-
const held = store.
|
|
195
|
+
const held = store.conflicted.of(locator, batch.id);
|
|
185
196
|
return (held !== undefined &&
|
|
186
|
-
Object.entries(held).some(([path, revision]) => confirmedLayer.revisions[path] !== revision));
|
|
197
|
+
Object.entries(held.revisions).some(([path, revision]) => confirmedLayer.revisions[path] !== revision));
|
|
187
198
|
});
|
|
188
199
|
const unshown = queue.filter((batch) => !shown.includes(batch));
|
|
189
200
|
const { withdrawn, kept } = await stepped(standing(confirmedLayer, unshown, withdrawable(work.states), localSaves, locator, composition));
|
|
190
201
|
const founded = kept.filter((batch) => !unshown.includes(batch));
|
|
191
202
|
const queueChanged = kept.length !== previousQueue.length || founded.length > 0;
|
|
192
|
-
const unqueued = shown.map((batch) =>
|
|
203
|
+
const unqueued = shown.map((batch) => {
|
|
204
|
+
const { returned } = store.conflicted.of(locator, batch.id);
|
|
205
|
+
return {
|
|
206
|
+
batch,
|
|
207
|
+
returned: returned === null || landed(batch, confirmedLayer, composition) ? null : returned,
|
|
208
|
+
};
|
|
209
|
+
});
|
|
193
210
|
for (const batch of withdrawn) {
|
|
194
|
-
|
|
211
|
+
const held = await landedWhole(store, record, batch, confirmedLayer);
|
|
212
|
+
unqueued.push({ batch, returned: held ? null : returnedBy() });
|
|
195
213
|
}
|
|
196
214
|
const returning = [
|
|
197
|
-
...[...unqueued].reverse().map(({ batch,
|
|
215
|
+
...[...unqueued].reverse().map(({ batch, returned }) => ({
|
|
198
216
|
batch,
|
|
199
|
-
returned: localSaves
|
|
217
|
+
returned: localSaves ? null : returned,
|
|
200
218
|
})),
|
|
201
219
|
...(settling.leaving ?? []),
|
|
202
220
|
];
|
|
203
|
-
const
|
|
221
|
+
const replayedLayer = await replayed(store, record, confirmedLayer, kept);
|
|
222
|
+
const written = await returnedDrafts(store, locator, work, returning, composition, replayedLayer.visible);
|
|
204
223
|
const carried = await carriedBack(runtime, locator, [
|
|
205
|
-
...[...unqueued]
|
|
224
|
+
...[...unqueued]
|
|
225
|
+
.reverse()
|
|
226
|
+
.flatMap(({ batch, returned }) => (returned === null ? [] : [batch])),
|
|
206
227
|
...(settling.leaving ?? []).flatMap(({ batch, returned }) => returned === null ? [] : [batch]),
|
|
207
228
|
], written);
|
|
208
|
-
const replayedLayer = await replayed(store, record, confirmedLayer, kept);
|
|
209
229
|
const { overlay } = await overlayDiff(record, before, replayedLayer.visible, replayedLayer.touched);
|
|
210
230
|
const commit = {
|
|
211
231
|
rooms: [
|
|
@@ -242,13 +262,9 @@ async function settlement(runtime, local, locator, work, record, queue, settling
|
|
|
242
262
|
apply: (answer) => {
|
|
243
263
|
for (const batch of previousQueue) {
|
|
244
264
|
if (!staying.has(batch.id))
|
|
245
|
-
store.
|
|
265
|
+
store.conflicted.drop(locator, batch.id);
|
|
246
266
|
}
|
|
247
267
|
const drafts = [...written.keys(), ...carried.taken];
|
|
248
|
-
for (const { batch, landed: held } of unqueued) {
|
|
249
|
-
const outcome = localSaves ? 'dropped' : held ? 'landed' : 'withdrawn';
|
|
250
|
-
journal.record(`outcome ${locator} ${batch.id} ${outcome}`);
|
|
251
|
-
}
|
|
252
268
|
const changed = answer.changed[locator];
|
|
253
269
|
if (settling.commit?.published !== undefined ||
|
|
254
270
|
settling.commit?.refreshed === true ||
|
|
@@ -270,28 +286,19 @@ async function settlement(runtime, local, locator, work, record, queue, settling
|
|
|
270
286
|
};
|
|
271
287
|
}
|
|
272
288
|
async function unpairing(runtime, local, locator, batches) {
|
|
273
|
-
const { store,
|
|
289
|
+
const { store, localSaves } = runtime;
|
|
274
290
|
const ids = new Set(batches.map(({ id }) => id));
|
|
275
291
|
const leaving = batches.map((batch) => ({
|
|
276
292
|
batch,
|
|
277
293
|
returned: !localSaves && leavingIn(batch, locator) ? returnedBy() : null,
|
|
278
294
|
}));
|
|
279
|
-
const outcome = localSaves ? 'dropped' : 'unpaired';
|
|
280
295
|
const work = await store.work(locator);
|
|
281
296
|
const current = work.replica;
|
|
282
297
|
if (current !== undefined) {
|
|
283
|
-
|
|
284
|
-
return {
|
|
285
|
-
...settled,
|
|
286
|
-
apply(answer) {
|
|
287
|
-
for (const batch of batches)
|
|
288
|
-
journal.record(`outcome ${locator} ${batch.id} ${outcome}`);
|
|
289
|
-
return settled.apply(answer);
|
|
290
|
-
},
|
|
291
|
-
};
|
|
298
|
+
return settlement(runtime, local, locator, work, current.record, current.queue.filter((one) => !ids.has(one.id)), { leaving });
|
|
292
299
|
}
|
|
293
300
|
const queue = work.queue.filter((one) => !ids.has(one.id));
|
|
294
|
-
const written = await returnedDrafts(store, locator, work, leaving, unheldComposition(runtime, locator));
|
|
301
|
+
const written = await returnedDrafts(store, locator, work, leaving, unheldComposition(runtime, locator), undefined);
|
|
295
302
|
const carried = await carriedBack(runtime, locator, leaving.flatMap(({ batch, returned }) => (returned === null ? [] : [batch])), written);
|
|
296
303
|
return {
|
|
297
304
|
locator,
|
|
@@ -310,8 +317,6 @@ async function unpairing(runtime, local, locator, batches) {
|
|
|
310
317
|
],
|
|
311
318
|
},
|
|
312
319
|
apply() {
|
|
313
|
-
for (const batch of batches)
|
|
314
|
-
journal.record(`outcome ${locator} ${batch.id} ${outcome}`);
|
|
315
320
|
return mergeChangeSets([
|
|
316
321
|
changeSet(locator, {
|
|
317
322
|
queue: true,
|
|
@@ -378,6 +383,12 @@ export function settle(runtime, locators, decide) {
|
|
|
378
383
|
await settled(runtime, local, settlements, decided.flatMap(({ after }) => (after === undefined ? [] : [after])));
|
|
379
384
|
});
|
|
380
385
|
}
|
|
386
|
+
function awaited(head, confirmedLayer, composition, { affected }, held) {
|
|
387
|
+
const touched = [...touchedBy([head])];
|
|
388
|
+
if (held)
|
|
389
|
+
return landed(head, confirmedLayer, composition) ? [] : touched;
|
|
390
|
+
return touched.filter((path) => Object.hasOwn(affected, path) && confirmedLayer.documents[path] !== affected[path]);
|
|
391
|
+
}
|
|
381
392
|
export function answered(runtime, locator, head, answer) {
|
|
382
393
|
const { store, socket } = runtime;
|
|
383
394
|
return store.exclusive(async () => {
|
|
@@ -391,18 +402,22 @@ export function answered(runtime, locator, head, answer) {
|
|
|
391
402
|
const confirmedLayer = await sliceAt(store, current.record, 'confirmed', [head]);
|
|
392
403
|
const held = answer.kind === 'conflicted' &&
|
|
393
404
|
(await landedWhole(store, current.record, head, confirmedLayer, answer.affected));
|
|
394
|
-
if (held &&
|
|
395
|
-
partnerOf(head, locator) === null &&
|
|
396
|
-
!landed(head, confirmedLayer, store.composed(current.record))) {
|
|
397
|
-
store.landed.hold(locator, head.id, Object.fromEntries([...touchedBy([head])].map((path) => [path, confirmedLayer.revisions[path]])));
|
|
398
|
-
return;
|
|
399
|
-
}
|
|
400
405
|
const returned = {
|
|
401
406
|
kind: answer.kind,
|
|
402
407
|
code: answer.code,
|
|
403
408
|
fields: answer.fields,
|
|
404
409
|
retryable: answer.retryable,
|
|
405
410
|
};
|
|
411
|
+
if (answer.kind === 'conflicted' && partnerOf(head, locator) === null) {
|
|
412
|
+
const behind = awaited(head, confirmedLayer, store.composed(current.record), answer, held);
|
|
413
|
+
if (behind.length > 0) {
|
|
414
|
+
store.conflicted.hold(locator, head.id, {
|
|
415
|
+
revisions: Object.fromEntries(behind.map((path) => [path, confirmedLayer.revisions[path]])),
|
|
416
|
+
returned: held ? null : returned,
|
|
417
|
+
});
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
406
421
|
await settled(runtime, local, [
|
|
407
422
|
await settlement(runtime, local, locator, work, current.record, current.queue.filter((batch) => batch.id !== head.id), { leaving: [{ batch: head, returned: held ? null : returned }] }),
|
|
408
423
|
], []);
|
package/dist/reach.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ReadinessPort } from './preparation.js';
|
|
1
|
+
import type { ListedRoom } from './listing.js';
|
|
2
|
+
import type { ReadinessMessage, ReadinessPort } from './preparation.js';
|
|
3
|
+
import { type CodeAvailability } from './readiness.js';
|
|
3
4
|
import type { MdRuntime, RuntimeTopic } from './surface.js';
|
|
5
|
+
import type { QueriedRoom } from './adapter.js';
|
|
4
6
|
import type { Plan, PlanReach, QueryResult } from './query.js';
|
|
5
|
-
import type { Readiness } from './readiness.js';
|
|
6
7
|
import type { SearchResult } from './search.js';
|
|
8
|
+
import type { HouseQueryResult } from './house-query.js';
|
|
7
9
|
export type ReachedDocument = {
|
|
8
10
|
readonly room: string;
|
|
9
11
|
readonly path: string;
|
|
@@ -17,6 +19,7 @@ export type PortReach = {
|
|
|
17
19
|
readonly rooms: readonly string[];
|
|
18
20
|
readonly documents: readonly ReachedDocument[];
|
|
19
21
|
readonly areas?: readonly ReachedArea[];
|
|
22
|
+
readonly queriesOnly?: readonly QueriedRoom[];
|
|
20
23
|
readonly conversations: boolean;
|
|
21
24
|
};
|
|
22
25
|
export type Deliver = (message: unknown) => void;
|
|
@@ -28,19 +31,25 @@ export type RuntimeView = {
|
|
|
28
31
|
};
|
|
29
32
|
export type NarrowedView = RuntimeView & {
|
|
30
33
|
narrow(reach: PortReach | null): void;
|
|
34
|
+
code(code: CodeAvailability): void;
|
|
35
|
+
close(): void;
|
|
31
36
|
};
|
|
32
37
|
export type Reachable = RuntimeView & {
|
|
33
38
|
plan(input: unknown, reach: PortReach | null): Promise<Plan>;
|
|
34
39
|
query(plan: Plan): Promise<QueryResult>;
|
|
35
40
|
watchPlan(plan: Plan, deliver: Deliver, fail: Fail): () => void;
|
|
36
41
|
search(input: unknown, reach: PortReach | null): Promise<SearchResult>;
|
|
37
|
-
|
|
42
|
+
queryHouse(input: unknown, reach: PortReach | null, options: unknown): Promise<HouseQueryResult>;
|
|
43
|
+
queried(): readonly QueriedRoom[];
|
|
44
|
+
watchReadiness(port: ReadinessPort, reach: PortReach | null, deliver: (readiness: ReadinessMessage) => void): () => void;
|
|
38
45
|
locked(room: string): Promise<boolean>;
|
|
39
46
|
lockedRooms(): Promise<readonly string[]>;
|
|
40
47
|
watchLocks(notify: () => void): () => void;
|
|
41
48
|
located(room: string, path: string, destination: string): Promise<ReachedDocument | null>;
|
|
42
|
-
room(locator: string): Promise<
|
|
49
|
+
room(locator: string): Promise<ListedRoom | undefined>;
|
|
43
50
|
};
|
|
51
|
+
export declare function queriedOf(reach: PortReach | null, provided: readonly QueriedRoom[]): readonly QueriedRoom[];
|
|
52
|
+
export declare function queriedOnly(reach: PortReach | null, provided: readonly QueriedRoom[], room: string): boolean;
|
|
44
53
|
export declare function holds(reach: PortReach | null, room: string): boolean;
|
|
45
54
|
export declare function governs(reach: PortReach | null, room: {
|
|
46
55
|
readonly locator: string;
|
|
@@ -52,5 +61,5 @@ export declare function governs(reach: PortReach | null, room: {
|
|
|
52
61
|
readonly selection: boolean;
|
|
53
62
|
};
|
|
54
63
|
export declare function planReach(reach: PortReach | null): PlanReach | null;
|
|
55
|
-
export declare function narrowed(runtime: Reachable, given: PortReach | null,
|
|
64
|
+
export declare function narrowed(runtime: Reachable, given: PortReach | null, attached: ReadinessPort): NarrowedView;
|
|
56
65
|
//# sourceMappingURL=reach.d.ts.map
|