@agentshouse/mdruntime 0.1.0-cedd665dffa4c → 0.1.0-cee2924c82d23
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 +9 -9
- package/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +30 -1
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +48 -9
- package/dist/adapter.d.ts +118 -19
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +2 -2
- 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 +2 -2
- package/dist/chat-types.js +2 -2
- package/dist/client.d.ts +16 -7
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +24 -51
- package/dist/collection.d.ts +3 -1
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +16 -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 +71 -39
- package/dist/connection.d.ts +1 -1
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +6 -2
- package/dist/conversation-live.d.ts +2 -3
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +2 -2
- package/dist/conversation.d.ts +18 -9
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +38 -22
- 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 -5
- 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 +1 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +3 -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 +2 -2
- package/dist/file.d.ts +1 -1
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +1 -1
- package/dist/host.d.ts +6 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +57 -21
- 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 +17 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -5
- package/dist/lifecycle.d.ts +1 -1
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +28 -16
- package/dist/listing.d.ts +20 -12
- package/dist/listing.d.ts.map +1 -1
- package/dist/listing.js +33 -17
- package/dist/live.d.ts +14 -0
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +29 -12
- package/dist/loaded.d.ts +5 -3
- package/dist/loaded.d.ts.map +1 -1
- package/dist/loaded.js +12 -6
- package/dist/locks.d.ts.map +1 -1
- package/dist/locks.js +2 -0
- package/dist/media.d.ts +14 -3
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +126 -30
- package/dist/memory.d.ts +4 -2
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +47 -16
- package/dist/messages.d.ts +6 -1
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +11 -4
- 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/name.d.ts +0 -1
- package/dist/name.d.ts.map +1 -1
- package/dist/name.js +3 -7
- package/dist/observation.d.ts +2 -0
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +42 -9
- 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 +18 -2
- package/dist/outcome.d.ts +27 -14
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +14 -5
- package/dist/overlay.d.ts +19 -8
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +108 -37
- package/dist/parts.d.ts +3 -1
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +30 -7
- package/dist/paths.d.ts +1 -1
- package/dist/paths.js +1 -1
- package/dist/preparation.d.ts +10 -5
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +78 -48
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +75 -53
- 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/reach.d.ts +13 -3
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +114 -25
- package/dist/react.d.ts +5 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/readiness.d.ts +17 -4
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +17 -7
- 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/replica.d.ts +3 -8
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +3 -3
- package/dist/room-draft.d.ts +1 -1
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +9 -6
- package/dist/room-drafts.d.ts.map +1 -1
- package/dist/room-drafts.js +8 -6
- 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 +9 -1
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +18 -4
- 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 -2
- 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 +6 -6
- package/dist/saves.d.ts +7 -5
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +86 -49
- 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 +2 -0
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +21 -4
- 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 +1 -0
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +1 -0
- package/dist/source.d.ts +2 -0
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +2 -0
- package/dist/store/records.d.ts +22 -5
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +14 -4
- package/dist/store.d.ts +3 -2
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +4 -1
- package/dist/stored.d.ts +17 -3
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +139 -35
- package/dist/surface.d.ts +12 -7
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +48 -15
- package/dist/sync.d.ts +4 -2
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +45 -23
- package/dist/tables.d.ts +16 -47
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +69 -321
- package/dist/tallies.js +2 -2
- package/dist/validation.d.ts +2 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +49 -3
- package/dist/wire.d.ts +28 -6
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +17 -11
- package/package.json +4 -4
- package/dist/binary.d.ts.map +0 -1
- package/dist/binary.js +0 -8
package/dist/queries.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { identityOf } from '@agentshouse/mdmodel';
|
|
2
2
|
import { ROOM_TOTALS } from './figures.js';
|
|
3
3
|
import { roomInFlight } from './install.js';
|
|
4
|
-
import { readerOf } from './live.js';
|
|
4
|
+
import { hearerOf, readerOf, } from './live.js';
|
|
5
5
|
import { compositionFor, roomFacts } from './listing.js';
|
|
6
6
|
import { lockedRooms } from './locks.js';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { askedOnline, offline } from './online.js';
|
|
8
|
+
import { OFFLINE, UNCERTAIN, failure, undeclared } from './outcome.js';
|
|
9
|
+
import { prepare } from './preparation.js';
|
|
9
10
|
import { planWithin, } from './query.js';
|
|
10
11
|
import { planReach } from './reach.js';
|
|
11
|
-
import { refuse } from './refusal.js';
|
|
12
12
|
import { documentKey, roomsOfReach } from './rows.js';
|
|
13
13
|
import { searchPlanOf } from './search.js';
|
|
14
14
|
import { seedApplies, seededResult, watchSeeded } from './seed.js';
|
|
@@ -49,7 +49,9 @@ function awaitsOf(runtime, locator, held) {
|
|
|
49
49
|
}
|
|
50
50
|
function coveredRooms(runtime, locators, whole, held) {
|
|
51
51
|
const { store, socket } = runtime;
|
|
52
|
-
if (
|
|
52
|
+
if (whole &&
|
|
53
|
+
!socket.session.now().roomsListed &&
|
|
54
|
+
(locators.length === 0 || !store.device.now().completedWhenOpened))
|
|
53
55
|
return { pending: [] };
|
|
54
56
|
const pending = [];
|
|
55
57
|
const coverage = [];
|
|
@@ -75,8 +77,31 @@ function coveredRooms(runtime, locators, whole, held) {
|
|
|
75
77
|
return { pending };
|
|
76
78
|
return { coverage: { rooms: coverage, overlay }, rooms: read };
|
|
77
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
|
+
}
|
|
78
102
|
function covered(runtime, plan, held) {
|
|
79
|
-
|
|
103
|
+
const cover = coveredRooms(runtime, reachedRooms(runtime, plan, held), anyRoom(plan), held);
|
|
104
|
+
return 'pending' in cover ? cover : { ...cover, follows: followsOf(runtime, plan, held) };
|
|
80
105
|
}
|
|
81
106
|
function pendingAt(runtime, plan, reads, held, rooms) {
|
|
82
107
|
const reached = reaching(runtime, plan, reads, held);
|
|
@@ -110,8 +135,8 @@ export async function figuresCover(runtime) {
|
|
|
110
135
|
function sameCover(left, right) {
|
|
111
136
|
return JSON.stringify(left) === JSON.stringify(right);
|
|
112
137
|
}
|
|
113
|
-
async function windowRows(local, plan, rooms, unchanged) {
|
|
114
|
-
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);
|
|
115
140
|
if (first.more === undefined || !('documents' in first)) {
|
|
116
141
|
const { more: _more, ...rows } = first;
|
|
117
142
|
return rows;
|
|
@@ -125,7 +150,7 @@ async function windowRows(local, plan, rooms, unchanged) {
|
|
|
125
150
|
after: { text: more, values: JSON.parse(more) },
|
|
126
151
|
limit: plan.limit === null ? null : plan.limit - documents.length,
|
|
127
152
|
total: false,
|
|
128
|
-
}, rooms, QUERY_BYTES);
|
|
153
|
+
}, rooms, follows, QUERY_BYTES);
|
|
129
154
|
if (!('documents' in page))
|
|
130
155
|
return null;
|
|
131
156
|
documents.push(...page.documents);
|
|
@@ -154,17 +179,34 @@ async function composedRooms(runtime, plan, rooms) {
|
|
|
154
179
|
: { ...room, composition: compositionFor(runtime, stored.record) };
|
|
155
180
|
});
|
|
156
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
|
+
}
|
|
157
193
|
async function coveredRows(runtime, plan, cover) {
|
|
158
194
|
const { store } = runtime;
|
|
159
195
|
for (;;) {
|
|
160
196
|
const before = await cover();
|
|
161
197
|
if ('pending' in before)
|
|
162
|
-
return { pending: before };
|
|
198
|
+
return { pending: before, cover: before };
|
|
163
199
|
const local = await store.open();
|
|
164
|
-
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);
|
|
165
207
|
const changes = local.changes(keys);
|
|
166
208
|
const current = () => local.changes(keys) === changes;
|
|
167
|
-
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);
|
|
168
210
|
const after = await cover();
|
|
169
211
|
if (rows !== null && sameCover(before, after))
|
|
170
212
|
return { rows, cover: before, current };
|
|
@@ -185,11 +227,14 @@ function keyedOf(rows, coverage) {
|
|
|
185
227
|
export async function answeredPlan(runtime, plan, cover) {
|
|
186
228
|
const answered = await coveredRows(runtime, plan, cover);
|
|
187
229
|
if ('pending' in answered) {
|
|
188
|
-
|
|
189
|
-
return { result: pending, keys: [], current: () => true };
|
|
230
|
+
return { result: answered.pending, keys: [], current: () => true, cover: answered.cover };
|
|
190
231
|
}
|
|
191
232
|
const held = answered.cover;
|
|
192
|
-
return {
|
|
233
|
+
return {
|
|
234
|
+
...keyedOf(answered.rows, held.coverage),
|
|
235
|
+
current: answered.current,
|
|
236
|
+
cover: answered.cover,
|
|
237
|
+
};
|
|
193
238
|
}
|
|
194
239
|
async function coverNow(runtime, plan) {
|
|
195
240
|
const cover = covered(runtime, plan, await runtime.store.covering());
|
|
@@ -253,21 +298,12 @@ export function watchPlanned(runtime, planning, deliver, fail) {
|
|
|
253
298
|
}
|
|
254
299
|
export async function searched(runtime, input, reach) {
|
|
255
300
|
const { store, socket } = runtime;
|
|
256
|
-
const
|
|
301
|
+
const search = socket.search();
|
|
302
|
+
if (search === undefined)
|
|
303
|
+
return undeclared('search');
|
|
257
304
|
const asked = searchPlanOf(input);
|
|
258
305
|
await socket.ready;
|
|
259
|
-
|
|
260
|
-
if (search === undefined) {
|
|
261
|
-
return {
|
|
262
|
-
kind: 'undeclared',
|
|
263
|
-
code: 'action-undeclared',
|
|
264
|
-
fields: { name: 'search' },
|
|
265
|
-
retryable: false,
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
if (socket.closed() ||
|
|
269
|
-
session.now().refusal !== null ||
|
|
270
|
-
(await connectionNow(runtime)) !== 'connected')
|
|
306
|
+
if (await offline(runtime))
|
|
271
307
|
return OFFLINE;
|
|
272
308
|
const reached = reach === null ? null : new Set(reach.rooms);
|
|
273
309
|
const named = asked.rooms === null
|
|
@@ -279,30 +315,16 @@ export async function searched(runtime, input, reach) {
|
|
|
279
315
|
const rooms = named === null ? null : named.filter((room) => held.has(room)).sort();
|
|
280
316
|
if (rooms !== null && rooms.length === 0)
|
|
281
317
|
return { kind: 'found', documents: [] };
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
}
|
|
285
|
-
catch {
|
|
318
|
+
const result = await askedOnline(runtime, (authorization) => search(authorization, { text: asked.text, rooms }));
|
|
319
|
+
if (result === null)
|
|
286
320
|
return UNCERTAIN;
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
if (
|
|
290
|
-
return
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
return result;
|
|
297
|
-
if (result.kind !== 'found')
|
|
298
|
-
return failure(result);
|
|
299
|
-
const kept = rooms === null ? null : new Set(rooms);
|
|
300
|
-
return {
|
|
301
|
-
kind: 'found',
|
|
302
|
-
documents: result.documents.filter((hit) => kept === null || kept.has(hit.room)),
|
|
303
|
-
};
|
|
304
|
-
}
|
|
305
|
-
catch {
|
|
306
|
-
return UNCERTAIN;
|
|
307
|
-
}
|
|
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
|
+
};
|
|
308
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,EAA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AC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7B,KAAK,EAAE,SAAS,QAAQ,EAAE,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG,SAAS,GAAG;IAC7B,KAAK,EAAE,SAAS,GAAG,IAAI,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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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/reach.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ListedRoom } from './listing.js';
|
|
2
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
7
|
import type { SearchResult } from './search.js';
|
|
8
|
+
import type { HouseQueryResult } from './house-query.js';
|
|
6
9
|
export type ReachedDocument = {
|
|
7
10
|
readonly room: string;
|
|
8
11
|
readonly path: string;
|
|
@@ -16,6 +19,7 @@ export type PortReach = {
|
|
|
16
19
|
readonly rooms: readonly string[];
|
|
17
20
|
readonly documents: readonly ReachedDocument[];
|
|
18
21
|
readonly areas?: readonly ReachedArea[];
|
|
22
|
+
readonly queriesOnly?: readonly QueriedRoom[];
|
|
19
23
|
readonly conversations: boolean;
|
|
20
24
|
};
|
|
21
25
|
export type Deliver = (message: unknown) => void;
|
|
@@ -27,19 +31,25 @@ export type RuntimeView = {
|
|
|
27
31
|
};
|
|
28
32
|
export type NarrowedView = RuntimeView & {
|
|
29
33
|
narrow(reach: PortReach | null): void;
|
|
34
|
+
code(code: CodeAvailability): void;
|
|
35
|
+
close(): void;
|
|
30
36
|
};
|
|
31
37
|
export type Reachable = RuntimeView & {
|
|
32
38
|
plan(input: unknown, reach: PortReach | null): Promise<Plan>;
|
|
33
39
|
query(plan: Plan): Promise<QueryResult>;
|
|
34
40
|
watchPlan(plan: Plan, deliver: Deliver, fail: Fail): () => void;
|
|
35
41
|
search(input: unknown, reach: PortReach | null): Promise<SearchResult>;
|
|
42
|
+
queryHouse(input: unknown, reach: PortReach | null, options: unknown): Promise<HouseQueryResult>;
|
|
43
|
+
queried(): readonly QueriedRoom[];
|
|
36
44
|
watchReadiness(port: ReadinessPort, reach: PortReach | null, deliver: (readiness: ReadinessMessage) => void): () => void;
|
|
37
45
|
locked(room: string): Promise<boolean>;
|
|
38
46
|
lockedRooms(): Promise<readonly string[]>;
|
|
39
47
|
watchLocks(notify: () => void): () => void;
|
|
40
48
|
located(room: string, path: string, destination: string): Promise<ReachedDocument | null>;
|
|
41
|
-
room(locator: string): Promise<
|
|
49
|
+
room(locator: string): Promise<ListedRoom | undefined>;
|
|
42
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;
|
|
43
53
|
export declare function holds(reach: PortReach | null, room: string): boolean;
|
|
44
54
|
export declare function governs(reach: PortReach | null, room: {
|
|
45
55
|
readonly locator: string;
|
|
@@ -51,5 +61,5 @@ export declare function governs(reach: PortReach | null, room: {
|
|
|
51
61
|
readonly selection: boolean;
|
|
52
62
|
};
|
|
53
63
|
export declare function planReach(reach: PortReach | null): PlanReach | null;
|
|
54
|
-
export declare function narrowed(runtime: Reachable, given: PortReach | null,
|
|
64
|
+
export declare function narrowed(runtime: Reachable, given: PortReach | null, attached: ReadinessPort): NarrowedView;
|
|
55
65
|
//# sourceMappingURL=reach.d.ts.map
|
package/dist/reach.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reach.d.ts","sourceRoot":"","sources":["../src/reach.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"reach.d.ts","sourceRoot":"","sources":["../src/reach.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAgB,UAAU,EAA4B,MAAM,cAAc,CAAC;AACvF,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAA4C,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEjG,OAAO,KAAK,EAAE,SAAS,EAAe,YAAY,EAAE,MAAM,cAAc,CAAC;AAEzE,OAAO,KAAK,EAAsB,WAAW,EAAE,MAAM,cAAc,CAAC;AA4BpE,OAAO,KAAK,EAAiB,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAS9E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGzD,MAAM,MAAM,eAAe,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/E,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,SAAS,EAAE,SAAS,eAAe,EAAE,CAAC;IAC/C,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;IACxC,QAAQ,CAAC,WAAW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KAAE,GAAG,IAAI,CAAA;CAAE,GAC/F;IAAE,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAS/D;AAmDD,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAcnE;AA6JD,wBAAgB,QAAQ,CACtB,OAAO,EAAE,SAAS,EAClB,KAAK,EAAE,SAAS,GAAG,IAAI,EACvB,QAAQ,EAAE,aAAa,GACtB,YAAY,CAgcd"}
|
package/dist/reach.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { QueryError } from '@agentshouse/mdmodel';
|
|
2
|
-
import {
|
|
2
|
+
import { inboxRooms, INBOXES_LISTED, INBOXES_READ } from './readiness.js';
|
|
3
|
+
import { selected, typesPrint } from './collection.js';
|
|
3
4
|
import { unheldView } from './conversation.js';
|
|
4
|
-
import { modelTypes, NO_MODEL } from './model.js';
|
|
5
|
+
import { modelResult, modelTypes, NO_MODEL } from './model.js';
|
|
5
6
|
import { changeOf, digestApplied, digestOf, observing, unchanged, } from './observation.js';
|
|
6
7
|
import { runtimeError, uncaught } from './failure.js';
|
|
7
|
-
import { failure, lockedRoom, ROOM_LOCKED, undeclared, UNREADABLE, } from './outcome.js';
|
|
8
|
+
import { absentAttachment, failure, lockedRoom, ROOM_LOCKED, undeclared, UNREADABLE, } from './outcome.js';
|
|
8
9
|
import { beneath } from './paths.js';
|
|
9
10
|
import { moveTarget, readParts, staleWrite, } from './room-draft.js';
|
|
10
11
|
import { documentKey } from './rows.js';
|
|
@@ -24,11 +25,13 @@ const NO_CONVERSATION = {
|
|
|
24
25
|
takeOut: unconversed('conversations/take-out'),
|
|
25
26
|
decide: unconversed('agent-functions/decide'),
|
|
26
27
|
rename: unconversed('conversations/rename'),
|
|
27
|
-
|
|
28
|
+
set: unconversed('conversations/set'),
|
|
28
29
|
retry: unconversed('conversations/retry'),
|
|
29
30
|
pin: () => Promise.resolve(),
|
|
30
31
|
openTurn: () => Promise.resolve(),
|
|
31
32
|
dismissSuggestion: () => Promise.resolve(),
|
|
33
|
+
attach: () => Promise.resolve(undeclared('conversation.attach')),
|
|
34
|
+
attachment: (link) => Promise.resolve(absentAttachment(link)),
|
|
32
35
|
};
|
|
33
36
|
const NO_CHAT_DRAFT = {
|
|
34
37
|
write: () => Promise.resolve(),
|
|
@@ -39,6 +42,31 @@ const NO_CHAT_DRAFT = {
|
|
|
39
42
|
function areasOf(reach) {
|
|
40
43
|
return reach.areas ?? [];
|
|
41
44
|
}
|
|
45
|
+
export function queriedOf(reach, provided) {
|
|
46
|
+
return reach === null ? provided : (reach.queriesOnly ?? []);
|
|
47
|
+
}
|
|
48
|
+
export function queriedOnly(reach, provided, room) {
|
|
49
|
+
return queriedOf(reach, provided).some((queried) => queried.locator === room);
|
|
50
|
+
}
|
|
51
|
+
function queriedRoom({ name, locator, handle }) {
|
|
52
|
+
return {
|
|
53
|
+
name,
|
|
54
|
+
locator,
|
|
55
|
+
handle,
|
|
56
|
+
queriesOnly: true,
|
|
57
|
+
operations: { write: [], erase: [] },
|
|
58
|
+
replica: { selection: locator, admission: 'unavailable', offline: 'locked' },
|
|
59
|
+
model: modelResult(NO_MODEL, typesPrint),
|
|
60
|
+
typedSelection: null,
|
|
61
|
+
providerOwnedPaths: [],
|
|
62
|
+
authoredPaths: [],
|
|
63
|
+
roomVersion: null,
|
|
64
|
+
documents: 0,
|
|
65
|
+
synchronizationAvailable: false,
|
|
66
|
+
refusal: null,
|
|
67
|
+
locked: false,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
42
70
|
function fenced(reach, room, path) {
|
|
43
71
|
return areasOf(reach).some((area) => area.room === room &&
|
|
44
72
|
beneath(area.path, path) &&
|
|
@@ -74,7 +102,19 @@ function conversing(reach) {
|
|
|
74
102
|
function roomsAwaited(error, reach) {
|
|
75
103
|
return error.code === 'unknown-type' && reach !== null && reach.rooms.length === 0;
|
|
76
104
|
}
|
|
105
|
+
function queriedIn(input, reach, provided) {
|
|
106
|
+
const rooms = input?.rooms;
|
|
107
|
+
return Array.isArray(rooms)
|
|
108
|
+
? rooms.find((room) => typeof room === 'string' && queriedOnly(reach, provided, room))
|
|
109
|
+
: undefined;
|
|
110
|
+
}
|
|
77
111
|
async function planInReach(runtime, input, reach, answered) {
|
|
112
|
+
const queried = queriedIn(input, reach, runtime.queried());
|
|
113
|
+
if (queried !== undefined) {
|
|
114
|
+
if (answered)
|
|
115
|
+
return null;
|
|
116
|
+
throw queriesOnlyError(queried);
|
|
117
|
+
}
|
|
78
118
|
try {
|
|
79
119
|
return await runtime.plan(input, reach);
|
|
80
120
|
}
|
|
@@ -97,14 +137,29 @@ export function planReach(reach) {
|
|
|
97
137
|
.sort((left, right) => documentKey(left.room, left.path) < documentKey(right.room, right.path) ? -1 : 1),
|
|
98
138
|
};
|
|
99
139
|
}
|
|
100
|
-
function
|
|
101
|
-
|
|
140
|
+
function modelsOf(rooms, models) {
|
|
141
|
+
const named = new Set(rooms.flatMap(({ model, typedSelection }) => [model.types, typedSelection?.model.types]));
|
|
142
|
+
return Object.fromEntries(Object.entries(models).filter(([key]) => named.has(key)));
|
|
102
143
|
}
|
|
103
|
-
function
|
|
144
|
+
function roomsWithin(reach, provided, { rooms, models }) {
|
|
145
|
+
const within = rooms.filter((room) => wholly(reach, room.locator));
|
|
146
|
+
return {
|
|
147
|
+
rooms: [...within, ...queriedOf(reach, provided).map(queriedRoom)],
|
|
148
|
+
models: modelsOf(within, models),
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function roomsChangeWithin(reach, provided, { changed, removed, order, models }) {
|
|
152
|
+
const kept = changed.filter(([locator]) => wholly(reach, locator));
|
|
104
153
|
const within = {
|
|
105
|
-
changed:
|
|
154
|
+
changed: kept,
|
|
106
155
|
removed,
|
|
107
|
-
order: order === null
|
|
156
|
+
order: order === null
|
|
157
|
+
? null
|
|
158
|
+
: [
|
|
159
|
+
...order.filter((locator) => wholly(reach, locator)),
|
|
160
|
+
...queriedOf(reach, provided).map(({ locator }) => locator),
|
|
161
|
+
],
|
|
162
|
+
models: modelsOf(kept.map(([, room]) => room), models),
|
|
108
163
|
};
|
|
109
164
|
return unchanged(within) ? null : within;
|
|
110
165
|
}
|
|
@@ -179,26 +234,48 @@ function deviceUnreached() {
|
|
|
179
234
|
return runtimeError('device-unreached', 'Only the panel reaches this device');
|
|
180
235
|
}
|
|
181
236
|
const ATTACH_REQUIRED = 'attach-required';
|
|
237
|
+
const QUERIES_ONLY = 'queries-only';
|
|
238
|
+
function queriesOnlyError(room) {
|
|
239
|
+
return runtimeError(QUERIES_ONLY, `${room} answers through queryHouse`);
|
|
240
|
+
}
|
|
182
241
|
function attachRequired() {
|
|
183
|
-
return runtimeError(ATTACH_REQUIRED, 'App code takes a file in with
|
|
242
|
+
return runtimeError(ATTACH_REQUIRED, 'App code takes a file in with attachment.attach');
|
|
184
243
|
}
|
|
185
244
|
function carriesFile(parts) {
|
|
186
245
|
return parts !== null && typeof parts === 'object' && Object.hasOwn(parts, 'file');
|
|
187
246
|
}
|
|
188
|
-
export function narrowed(runtime, given,
|
|
247
|
+
export function narrowed(runtime, given, attached) {
|
|
189
248
|
const { md, watch } = runtime;
|
|
190
249
|
let reach = given;
|
|
250
|
+
let port = attached;
|
|
191
251
|
const open = new Set();
|
|
192
|
-
|
|
252
|
+
const coded = new Set();
|
|
253
|
+
function tiered(next) {
|
|
254
|
+
port = next;
|
|
255
|
+
for (const restart of [...coded])
|
|
256
|
+
restart();
|
|
257
|
+
}
|
|
258
|
+
const unread = port.first?.inboxes === true
|
|
259
|
+
? watch('read', [INBOXES_READ, INBOXES_LISTED], (read) => {
|
|
260
|
+
const inboxed = inboxRooms(read);
|
|
261
|
+
if (inboxed === null || JSON.stringify(inboxed) === JSON.stringify(port.inboxed)) {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
tiered({ ...port, inboxed });
|
|
265
|
+
}, uncaught)
|
|
266
|
+
: () => { };
|
|
267
|
+
function following(begin, locking = false, restarts = open) {
|
|
193
268
|
let stop = begin();
|
|
194
269
|
const restart = () => {
|
|
195
270
|
stop();
|
|
196
271
|
stop = begin();
|
|
197
272
|
};
|
|
198
273
|
open.add(restart);
|
|
274
|
+
restarts.add(restart);
|
|
199
275
|
const unwatch = locking ? runtime.watchLocks(restart) : () => { };
|
|
200
276
|
return () => {
|
|
201
277
|
open.delete(restart);
|
|
278
|
+
restarts.delete(restart);
|
|
202
279
|
unwatch();
|
|
203
280
|
stop();
|
|
204
281
|
};
|
|
@@ -264,15 +341,15 @@ export function narrowed(runtime, given, port) {
|
|
|
264
341
|
}
|
|
265
342
|
if (topic === 'rooms') {
|
|
266
343
|
return following(() => watch(topic, input, (rooms) => {
|
|
267
|
-
const shown =
|
|
268
|
-
? roomsWithin(reach, rooms)
|
|
269
|
-
: roomsChangeWithin(reach, rooms);
|
|
344
|
+
const shown = 'rooms' in rooms
|
|
345
|
+
? roomsWithin(reach, runtime.queried(), rooms)
|
|
346
|
+
: roomsChangeWithin(reach, runtime.queried(), rooms);
|
|
270
347
|
if (shown !== null)
|
|
271
348
|
deliver(shown);
|
|
272
349
|
}, fail));
|
|
273
350
|
}
|
|
274
351
|
if (topic === 'readiness') {
|
|
275
|
-
return following(() => runtime.watchReadiness(port, reach, deliver));
|
|
352
|
+
return following(() => runtime.watchReadiness(port, reach, deliver), false, coded);
|
|
276
353
|
}
|
|
277
354
|
if (topic === 'sync-status') {
|
|
278
355
|
return following(() => unlockedWatch(topic, input, deliver, fail, (status, locked) => {
|
|
@@ -359,7 +436,10 @@ export function narrowed(runtime, given, port) {
|
|
|
359
436
|
return () => { };
|
|
360
437
|
});
|
|
361
438
|
}
|
|
362
|
-
if (topic === 'figures' ||
|
|
439
|
+
if (topic === 'figures' ||
|
|
440
|
+
topic === 'holdings' ||
|
|
441
|
+
topic === 'listed-agents' ||
|
|
442
|
+
topic === 'room-list') {
|
|
363
443
|
if (reach === null)
|
|
364
444
|
return watch(topic, input, deliver, fail);
|
|
365
445
|
fail(deviceUnreached());
|
|
@@ -382,7 +462,7 @@ export function narrowed(runtime, given, port) {
|
|
|
382
462
|
const chatDraft = () => (conversing(reach) ? md.chatDraft : NO_CHAT_DRAFT);
|
|
383
463
|
const view = {
|
|
384
464
|
...md,
|
|
385
|
-
rooms: () => md.rooms().then((rooms) => roomsWithin(reach, rooms)),
|
|
465
|
+
rooms: () => md.rooms().then((rooms) => roomsWithin(reach, runtime.queried(), rooms)),
|
|
386
466
|
query: (async (input) => {
|
|
387
467
|
const plan = await planInReach(runtime, input, reach, false);
|
|
388
468
|
if (plan === null)
|
|
@@ -391,6 +471,7 @@ export function narrowed(runtime, given, port) {
|
|
|
391
471
|
return unlocking(plan.rooms, locked) ?? runtime.query({ ...plan, locked });
|
|
392
472
|
}),
|
|
393
473
|
search: (input) => runtime.search(input, reach),
|
|
474
|
+
queryHouse: (input, options) => runtime.queryHouse(input, reach, options),
|
|
394
475
|
async types(room) {
|
|
395
476
|
if (holds(reach, room) && (await runtime.locked(room)))
|
|
396
477
|
throw lockedError(room);
|
|
@@ -444,32 +525,32 @@ export function narrowed(runtime, given, port) {
|
|
|
444
525
|
: (await runtime.locked(room))
|
|
445
526
|
? lockedRoom(room)
|
|
446
527
|
: md.history(room, path, query),
|
|
447
|
-
|
|
528
|
+
attachment: {
|
|
448
529
|
read: async (room, path, revision) => !covers(reach, room, path)
|
|
449
530
|
? failure({ kind: 'room-not-readable', locator: room })
|
|
450
531
|
: (await runtime.locked(room))
|
|
451
532
|
? lockedRoom(room)
|
|
452
|
-
: hand(md.
|
|
533
|
+
: hand(md.attachment.read(room, path, revision)),
|
|
453
534
|
link: async (room, path, revision) => !covers(reach, room, path)
|
|
454
535
|
? failure({ kind: 'room-not-readable', locator: room })
|
|
455
536
|
: (await runtime.locked(room))
|
|
456
537
|
? lockedRoom(room)
|
|
457
|
-
: md.
|
|
538
|
+
: md.attachment.link(room, path, revision),
|
|
458
539
|
show: async (room, path, revision) => !covers(reach, room, path)
|
|
459
540
|
? failure({ kind: 'room-not-readable', locator: room })
|
|
460
541
|
: (await runtime.locked(room))
|
|
461
542
|
? lockedRoom(room)
|
|
462
|
-
: hand(md.
|
|
543
|
+
: hand(md.attachment.show(room, path, revision)),
|
|
463
544
|
attach: async (room, file) => !wholly(reach, room)
|
|
464
545
|
? failure({ kind: 'room-not-readable', locator: room })
|
|
465
546
|
: (await runtime.locked(room))
|
|
466
547
|
? lockedRoom(room)
|
|
467
|
-
: md.
|
|
548
|
+
: md.attachment.attach(room, file),
|
|
468
549
|
async part(file, part) {
|
|
469
550
|
const key = files.get(file);
|
|
470
551
|
if (key === undefined)
|
|
471
552
|
return null;
|
|
472
|
-
const bytes = await md.
|
|
553
|
+
const bytes = await md.attachment.part(key, part);
|
|
473
554
|
if (bytes === null)
|
|
474
555
|
files.delete(file);
|
|
475
556
|
return bytes;
|
|
@@ -480,6 +561,7 @@ export function narrowed(runtime, given, port) {
|
|
|
480
561
|
(await md.reached(room, roomVersion, path)),
|
|
481
562
|
cleanUp: () => (reach === null ? md.cleanUp() : Promise.reject(deviceUnreached())),
|
|
482
563
|
unsent: () => (reach === null ? md.unsent() : Promise.reject(deviceUnreached())),
|
|
564
|
+
sent: () => (reach === null ? md.sent() : Promise.reject(deviceUnreached())),
|
|
483
565
|
reset: () => (reach === null ? md.reset() : Promise.reject(deviceUnreached())),
|
|
484
566
|
readAgain: () => (reach === null ? md.readAgain() : Promise.reject(deviceUnreached())),
|
|
485
567
|
roomDraft: {
|
|
@@ -523,11 +605,13 @@ export function narrowed(runtime, given, port) {
|
|
|
523
605
|
takeOut: (id, message, operation) => conversation().takeOut(id, message, operation),
|
|
524
606
|
decide: (request, decision, operation) => conversation().decide(request, decision, operation),
|
|
525
607
|
rename: (id, name, operation) => conversation().rename(id, name, operation),
|
|
526
|
-
|
|
608
|
+
set: (id, settings, operation) => conversation().set(id, settings, operation),
|
|
527
609
|
retry: (id, message, operation) => conversation().retry(id, message, operation),
|
|
528
610
|
pin: (figures) => conversation().pin(figures),
|
|
529
611
|
openTurn: (id, turn) => conversation().openTurn(id, turn),
|
|
530
612
|
dismissSuggestion: (id, suggestion) => conversation().dismissSuggestion(id, suggestion),
|
|
613
|
+
attach: (file) => conversation().attach(file),
|
|
614
|
+
attachment: (link) => conversation().attachment(link),
|
|
531
615
|
},
|
|
532
616
|
chatDraft: {
|
|
533
617
|
write: (id, draft, revision) => chatDraft().write(id, draft, revision),
|
|
@@ -545,5 +629,10 @@ export function narrowed(runtime, given, port) {
|
|
|
545
629
|
for (const restart of [...open])
|
|
546
630
|
restart();
|
|
547
631
|
},
|
|
632
|
+
code(next) {
|
|
633
|
+
if (port.code !== next)
|
|
634
|
+
tiered({ ...port, code: next });
|
|
635
|
+
},
|
|
636
|
+
close: unread,
|
|
548
637
|
};
|
|
549
638
|
}
|