@agentshouse/mdruntime 0.1.0-c193f3bb8a163 → 0.1.0-c1996d5af6e1f
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 +1 -1
- 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 +35 -7
- package/dist/adapter.d.ts +97 -21
- 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/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 +17 -8
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +16 -16
- package/dist/collection.d.ts +1 -0
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +7 -1
- 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 +5 -3
- package/dist/conversation-live.d.ts +3 -3
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +4 -3
- package/dist/conversation-row.d.ts +12 -0
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +10 -0
- package/dist/conversation.d.ts +14 -8
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +68 -49
- package/dist/declaration.js +3 -3
- package/dist/discovery.d.ts +1 -1
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +18 -5
- package/dist/download.d.ts +2 -2
- package/dist/download.d.ts.map +1 -1
- package/dist/entry.d.ts +22 -3
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +111 -45
- package/dist/figures.d.ts +1 -1
- package/dist/figures.d.ts.map +1 -1
- package/dist/figures.js +2 -2
- package/dist/host.d.ts +5 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +50 -22
- package/dist/house-query.d.ts +14 -11
- package/dist/house-query.d.ts.map +1 -1
- package/dist/house-query.js +69 -8
- 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 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -6
- package/dist/lifecycle.d.ts +1 -1
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +24 -19
- 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 +5 -6
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +94 -25
- package/dist/memory.d.ts +2 -2
- package/dist/memory.js +9 -9
- package/dist/messages.d.ts +10 -1
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +24 -4
- package/dist/model.d.ts +6 -5
- package/dist/model.d.ts.map +1 -1
- package/dist/name.d.ts +0 -1
- package/dist/name.d.ts.map +1 -1
- package/dist/name.js +3 -7
- 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 -2
- package/dist/outcome.d.ts +21 -13
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +5 -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 +1 -0
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +1 -0
- 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 +59 -14
- package/dist/query.d.ts +2 -2
- package/dist/query.d.ts.map +1 -1
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +2 -1
- package/dist/reach.d.ts +5 -2
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +55 -15
- package/dist/react.d.ts +6 -0
- 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.map +1 -1
- package/dist/reads.js +15 -4
- 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.map +1 -1
- package/dist/room-list.js +2 -0
- package/dist/rows.d.ts +9 -2
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +19 -5
- 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/runs.d.ts +27 -0
- package/dist/runs.d.ts.map +1 -0
- package/dist/runs.js +92 -0
- package/dist/runtime.d.ts +4 -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 +5 -5
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +71 -45
- 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.map +1 -1
- package/dist/shown.js +17 -4
- package/dist/socket/session.d.ts +3 -1
- package/dist/socket/session.d.ts.map +1 -1
- package/dist/socket/session.js +2 -0
- package/dist/socket.d.ts +3 -1
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +7 -0
- package/dist/source.d.ts +19 -0
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +35 -7
- package/dist/store/records.d.ts +14 -5
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +11 -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 +138 -31
- package/dist/surface.d.ts +11 -5
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +9 -6
- package/dist/sync.d.ts +2 -1
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +26 -18
- package/dist/tables.d.ts +26 -2
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +24 -3
- 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 +11 -6
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +12 -11
- package/package.json +4 -4
- package/dist/binary.d.ts.map +0 -1
- package/dist/binary.js +0 -8
package/dist/saves.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { isImageType, parse } from '@agentshouse/mdmodel';
|
|
2
|
-
import {
|
|
2
|
+
import { attachmentRecord } from './attachment.js';
|
|
3
3
|
import { changeSet } from './change-set.js';
|
|
4
4
|
import { queuedFile } from './change.js';
|
|
5
|
-
import { available,
|
|
5
|
+
import { available, definitionsAt, typeAt } from './collection.js';
|
|
6
6
|
import { runtimeError } from './failure.js';
|
|
7
7
|
import { attachedFile } from './file.js';
|
|
8
8
|
import { roomDraftRevision } from './identity.js';
|
|
9
9
|
import { compositionFor } from './listing.js';
|
|
10
10
|
import { scoped } from './models.js';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { absentAttachment, attachAnswer, attachmentAnswer, attachmentLinkAnswer, failure, linkedAnswer, OFFLINE, UNCERTAIN, } from './outcome.js';
|
|
12
|
+
import { sameAttachment } from './overlay.js';
|
|
13
13
|
import { ancestors } from './paths.js';
|
|
14
14
|
import { connectionNow } from './preparation.js';
|
|
15
15
|
import { append, sliceAt, withdrawable } from './queue.js';
|
|
16
16
|
import { entryAt, replaying, slicing, } from './replica.js';
|
|
17
|
-
import {
|
|
17
|
+
import { attachmentBase, changesOf, held, heldFile, joinedOver, moveTarget, readSavedParts, } from './room-draft.js';
|
|
18
18
|
import { refuse } from './refusal.js';
|
|
19
19
|
import { visibleOf } from './room-drafts.js';
|
|
20
20
|
import { destination, planSave, } from './save.js';
|
|
@@ -77,7 +77,7 @@ export function saveParts(runtime, locator, named, writtenBy) {
|
|
|
77
77
|
for (const { path, parts } of read) {
|
|
78
78
|
const file = parts.file === undefined
|
|
79
79
|
? undefined
|
|
80
|
-
: await heldFile(parts.file.blob, parts.file.base === undefined ?
|
|
80
|
+
: await heldFile(parts.file.blob, parts.file.base === undefined ? attachmentBase(visible, path) : parts.file.base);
|
|
81
81
|
if (parts.file !== undefined && file !== undefined) {
|
|
82
82
|
files.push({ key: file.localId, blob: parts.file.blob });
|
|
83
83
|
}
|
|
@@ -159,7 +159,7 @@ async function loaded(runtime, locator, replica, saved, consumed, files, written
|
|
|
159
159
|
}
|
|
160
160
|
function textDiffers(left, right) {
|
|
161
161
|
return ((left?.content ?? undefined) !== (right?.content ?? undefined) ||
|
|
162
|
-
!
|
|
162
|
+
!sameAttachment(left?.binary ?? undefined, right?.binary ?? undefined));
|
|
163
163
|
}
|
|
164
164
|
function textOf(entry) {
|
|
165
165
|
if (entry === null)
|
|
@@ -176,12 +176,16 @@ function lookupOf(local, key, view) {
|
|
|
176
176
|
]));
|
|
177
177
|
};
|
|
178
178
|
}
|
|
179
|
-
function declaredOf(entry) {
|
|
179
|
+
function declaredOf(composition, path, entry) {
|
|
180
180
|
if (entry.binary !== null)
|
|
181
181
|
return { type: undefined, binary: true };
|
|
182
|
-
|
|
182
|
+
const content = entry.content ?? '';
|
|
183
|
+
return {
|
|
184
|
+
type: typeAt(composition, path, parse(content, path, definitionsAt(composition, path))),
|
|
185
|
+
binary: false,
|
|
186
|
+
};
|
|
183
187
|
}
|
|
184
|
-
function overriddenLookup(lookup, overrides) {
|
|
188
|
+
function overriddenLookup(composition, lookup, overrides) {
|
|
185
189
|
return async (paths) => {
|
|
186
190
|
const known = new Map(await lookup(paths.filter((path) => !overrides.has(path))));
|
|
187
191
|
for (const path of paths) {
|
|
@@ -191,7 +195,7 @@ function overriddenLookup(lookup, overrides) {
|
|
|
191
195
|
if (entry === null)
|
|
192
196
|
known.delete(path);
|
|
193
197
|
else
|
|
194
|
-
known.set(path, declaredOf(entry));
|
|
198
|
+
known.set(path, declaredOf(composition, path, entry));
|
|
195
199
|
}
|
|
196
200
|
return known;
|
|
197
201
|
};
|
|
@@ -212,10 +216,12 @@ function validatorOf(runtime, record, confirmedLayer) {
|
|
|
212
216
|
if (textOf(was) !== textOf(now))
|
|
213
217
|
changes.push({ path, was: textOf(was), now: textOf(now) });
|
|
214
218
|
}
|
|
215
|
-
|
|
216
|
-
|
|
219
|
+
const composition = compositionFor(runtime, record);
|
|
220
|
+
return validatedNeighbourhood(changes, composition, {
|
|
221
|
+
lookup: overriddenLookup(composition, lookupOf(local, record.key, 'confirmed'), overrides),
|
|
217
222
|
texts: textsOf(local, record.key, 'confirmed'),
|
|
218
223
|
referrers: referrersOf(local, record.key, 'confirmed'),
|
|
224
|
+
holders: (sought) => local.holders(record.key, 'confirmed', sought),
|
|
219
225
|
});
|
|
220
226
|
};
|
|
221
227
|
}
|
|
@@ -245,7 +251,7 @@ export function batchFile(store, batch) {
|
|
|
245
251
|
return (await store.open()).file(localId, change?.kind === 'binary' ? change.mediaType : '');
|
|
246
252
|
};
|
|
247
253
|
}
|
|
248
|
-
async function
|
|
254
|
+
async function transferAttachment(runtime, request, transfer, answer) {
|
|
249
255
|
const { store, socket, presence } = runtime;
|
|
250
256
|
const { session } = socket;
|
|
251
257
|
if (socket.closed() || session.now().refusal !== null)
|
|
@@ -281,19 +287,19 @@ async function transferBinary(runtime, request, transfer, answer) {
|
|
|
281
287
|
return UNCERTAIN;
|
|
282
288
|
}
|
|
283
289
|
}
|
|
284
|
-
function
|
|
290
|
+
function fetchAttachment(runtime, request, name) {
|
|
285
291
|
const { store, socket } = runtime;
|
|
286
|
-
return
|
|
292
|
+
return transferAttachment(runtime, request, (authorization) => store.opened.fetch(name, () => socket.binary(authorization, request)), attachmentAnswer);
|
|
287
293
|
}
|
|
288
|
-
async function
|
|
294
|
+
async function readAttachment(runtime, request, name) {
|
|
289
295
|
if (runtime.socket.closed())
|
|
290
296
|
return UNCERTAIN;
|
|
291
297
|
const held = await runtime.store.opened.find(name);
|
|
292
298
|
if (held !== null)
|
|
293
299
|
return held;
|
|
294
|
-
return
|
|
300
|
+
return fetchAttachment(runtime, request, name);
|
|
295
301
|
}
|
|
296
|
-
async function
|
|
302
|
+
async function attachmentPath(store, locator, path, revision) {
|
|
297
303
|
if (revision !== undefined)
|
|
298
304
|
return { kind: 'path', locator, path, revision };
|
|
299
305
|
const replica = await store.replica(locator);
|
|
@@ -306,7 +312,7 @@ async function binaryPath(store, locator, path, revision) {
|
|
|
306
312
|
return null;
|
|
307
313
|
if (held.binary.state === 'pending')
|
|
308
314
|
return { kind: 'pending', localId: held.binary.localId };
|
|
309
|
-
const record =
|
|
315
|
+
const record = attachmentRecord(path, held.binary, held.revision ?? undefined);
|
|
310
316
|
if (record.state !== 'accepted')
|
|
311
317
|
return null;
|
|
312
318
|
const queued = replica.queue.flatMap((batch) => batch.changes);
|
|
@@ -334,17 +340,17 @@ async function binaryPath(store, locator, path, revision) {
|
|
|
334
340
|
revision: record.revision,
|
|
335
341
|
};
|
|
336
342
|
}
|
|
337
|
-
async function
|
|
343
|
+
async function askedAttachment({ store, socket }, locator, path, revision) {
|
|
338
344
|
await socket.ready;
|
|
339
345
|
const drafted = (await store.draft(locator, path))?.parts.file;
|
|
340
346
|
return drafted !== undefined && drafted.localId === revision
|
|
341
347
|
? { kind: 'pending', localId: revision }
|
|
342
|
-
:
|
|
348
|
+
: attachmentPath(store, locator, path, revision);
|
|
343
349
|
}
|
|
344
|
-
async function
|
|
350
|
+
async function pendingAttachment(store, locator, path, localId) {
|
|
345
351
|
const facts = await queuedFacts(store, locator, path, localId);
|
|
346
352
|
return facts === null
|
|
347
|
-
?
|
|
353
|
+
? absentAttachment(path)
|
|
348
354
|
: {
|
|
349
355
|
kind: 'binary',
|
|
350
356
|
file: localId,
|
|
@@ -352,13 +358,13 @@ async function pendingBinary(store, locator, path, localId) {
|
|
|
352
358
|
mediaType: facts.mediaType,
|
|
353
359
|
};
|
|
354
360
|
}
|
|
355
|
-
async function
|
|
356
|
-
const asked = await
|
|
361
|
+
async function readAttachmentPath(runtime, locator, path, revision) {
|
|
362
|
+
const asked = await askedAttachment(runtime, locator, path, revision);
|
|
357
363
|
if (asked === null)
|
|
358
|
-
return
|
|
364
|
+
return absentAttachment(path);
|
|
359
365
|
if (asked.kind === 'pending')
|
|
360
|
-
return
|
|
361
|
-
return
|
|
366
|
+
return pendingAttachment(runtime.store, locator, path, asked.localId);
|
|
367
|
+
return readAttachment(runtime, asked, { locator, path: asked.path, revision: asked.revision });
|
|
362
368
|
}
|
|
363
369
|
async function heldMediaType(store, locator, path) {
|
|
364
370
|
const replica = await store.record(locator);
|
|
@@ -366,23 +372,42 @@ async function heldMediaType(store, locator, path) {
|
|
|
366
372
|
return held === undefined ? store.attached.of(locator, path)?.mediaType : held.binary?.mediaType;
|
|
367
373
|
}
|
|
368
374
|
function linkOf(runtime, asked, held) {
|
|
369
|
-
return
|
|
375
|
+
return transferAttachment(runtime, asked, (authorization) => runtime.socket.link(authorization, asked), (result) => attachmentLinkAnswer(result, held));
|
|
370
376
|
}
|
|
371
|
-
async function
|
|
377
|
+
async function linkAttachmentPath(runtime, locator, path, revision) {
|
|
372
378
|
const { store, socket } = runtime;
|
|
373
379
|
await socket.ready;
|
|
374
|
-
const asked = await
|
|
380
|
+
const asked = await attachmentPath(store, locator, path, revision);
|
|
375
381
|
if (asked === null || asked.kind === 'pending')
|
|
376
|
-
return
|
|
382
|
+
return absentAttachment(path);
|
|
377
383
|
return linkOf(runtime, asked, revision === undefined ? await heldMediaType(store, locator, path) : undefined);
|
|
378
384
|
}
|
|
379
|
-
|
|
385
|
+
function shownImage(runtime, asked, name) {
|
|
386
|
+
const { store, socket } = runtime;
|
|
387
|
+
return new Promise((answer) => {
|
|
388
|
+
void transferAttachment(runtime, asked, (authorization) => store.opened.fetch(name, async () => {
|
|
389
|
+
const read = await socket.binary(authorization, asked);
|
|
390
|
+
const copies = read.kind === 'binary' ? (read.copies ?? []) : [];
|
|
391
|
+
if (read.kind === 'binary' && read.url !== undefined && copies.length > 0) {
|
|
392
|
+
answer({
|
|
393
|
+
kind: 'link',
|
|
394
|
+
url: read.url,
|
|
395
|
+
name: asked.path.slice(asked.path.lastIndexOf('/') + 1),
|
|
396
|
+
mediaType: read.mediaType,
|
|
397
|
+
copies,
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
return read;
|
|
401
|
+
}), attachmentAnswer).then(answer);
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
async function showAttachmentPath(runtime, locator, path, revision) {
|
|
380
405
|
const { store } = runtime;
|
|
381
|
-
const asked = await
|
|
406
|
+
const asked = await askedAttachment(runtime, locator, path, revision);
|
|
382
407
|
if (asked === null)
|
|
383
|
-
return
|
|
408
|
+
return absentAttachment(path);
|
|
384
409
|
if (asked.kind === 'pending')
|
|
385
|
-
return
|
|
410
|
+
return pendingAttachment(store, locator, path, asked.localId);
|
|
386
411
|
if (runtime.socket.closed())
|
|
387
412
|
return UNCERTAIN;
|
|
388
413
|
const name = { locator, path: asked.path, revision: asked.revision };
|
|
@@ -391,8 +416,9 @@ async function showBinaryPath(runtime, locator, path, revision) {
|
|
|
391
416
|
return kept;
|
|
392
417
|
const mediaType = await heldMediaType(store, locator, path);
|
|
393
418
|
if (mediaType !== undefined && isImageType(mediaType))
|
|
394
|
-
return
|
|
395
|
-
|
|
419
|
+
return shownImage(runtime, asked, name);
|
|
420
|
+
const linked = await linkOf(runtime, asked, revision === undefined ? mediaType : undefined);
|
|
421
|
+
return linked.kind === 'link' ? { ...linked, copies: [] } : linked;
|
|
396
422
|
}
|
|
397
423
|
async function attachFile(runtime, locator, file, answer) {
|
|
398
424
|
const { store, socket } = runtime;
|
|
@@ -404,7 +430,7 @@ async function attachFile(runtime, locator, file, answer) {
|
|
|
404
430
|
socket.session.now().refusal !== null)
|
|
405
431
|
return OFFLINE;
|
|
406
432
|
const request = await attachedFile(locator, file);
|
|
407
|
-
return
|
|
433
|
+
return transferAttachment(runtime, { locator }, async (held) => {
|
|
408
434
|
const result = await socket.attach(held, request);
|
|
409
435
|
if (result.kind === 'attached' && locator !== null) {
|
|
410
436
|
store.attached.hold(locator, result.path, {
|
|
@@ -418,7 +444,7 @@ async function attachFile(runtime, locator, file, answer) {
|
|
|
418
444
|
async function keyedAttachment(runtime, link) {
|
|
419
445
|
await runtime.socket.ready;
|
|
420
446
|
const asked = { kind: 'key', link };
|
|
421
|
-
return
|
|
447
|
+
return transferAttachment(runtime, { locator: null }, (authorization) => runtime.socket.link(authorization, asked), (result) => attachmentLinkAnswer(result));
|
|
422
448
|
}
|
|
423
449
|
export function conversationFiles(runtime) {
|
|
424
450
|
return {
|
|
@@ -426,12 +452,12 @@ export function conversationFiles(runtime) {
|
|
|
426
452
|
attachment: (link) => keyedAttachment(runtime, link),
|
|
427
453
|
};
|
|
428
454
|
}
|
|
429
|
-
export function
|
|
455
|
+
export function attachmentSurface(runtime) {
|
|
430
456
|
return {
|
|
431
457
|
part: runtime.store.part,
|
|
432
|
-
read: (room, path, revision) =>
|
|
433
|
-
link: (room, path, revision) =>
|
|
434
|
-
show: (room, path, revision) =>
|
|
458
|
+
read: (room, path, revision) => readAttachmentPath(runtime, room, path, revision),
|
|
459
|
+
link: (room, path, revision) => linkAttachmentPath(runtime, room, path, revision),
|
|
460
|
+
show: (room, path, revision) => showAttachmentPath(runtime, room, path, revision),
|
|
435
461
|
attach: (room, file) => attachFile(runtime, room, file, attachAnswer),
|
|
436
462
|
};
|
|
437
463
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selector.d.ts","sourceRoot":"","sources":["../src/selector.ts"],"names":[],"mappings":"AAaA,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,OAAO,GACtC,OAAO,CAET;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,OAAO,EAAE,CAOnF"}
|
package/dist/selector.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
function rewrittenAt(value, members, rewrite) {
|
|
2
|
+
if (Array.isArray(value))
|
|
3
|
+
return value.map((one) => rewrittenAt(one, members, rewrite));
|
|
4
|
+
const [member, ...rest] = members;
|
|
5
|
+
if (member === undefined)
|
|
6
|
+
return rewrite(value);
|
|
7
|
+
if (value === null || typeof value !== 'object' || !Object.hasOwn(value, member))
|
|
8
|
+
return value;
|
|
9
|
+
const held = value;
|
|
10
|
+
return { ...held, [member]: rewrittenAt(held[member], rest, rewrite) };
|
|
11
|
+
}
|
|
12
|
+
export function selectorRewritten(value, selector, rewrite) {
|
|
13
|
+
return rewrittenAt(value, selector.split('.'), rewrite);
|
|
14
|
+
}
|
|
15
|
+
export function selectorValues(value, selector) {
|
|
16
|
+
const selected = [];
|
|
17
|
+
selectorRewritten(value, selector, (one) => {
|
|
18
|
+
selected.push(one);
|
|
19
|
+
return one;
|
|
20
|
+
});
|
|
21
|
+
return selected;
|
|
22
|
+
}
|
package/dist/shown.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shown.d.ts","sourceRoot":"","sources":["../src/shown.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAA8B,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAA6B,KAAK,aAAa,EAAmB,MAAM,aAAa,CAAC;AAiB7F,eAAO,MAAM,WAAW,UAAU,CAAC;AAEnC,eAAO,MAAM,YAAY,gBAAgB,CAAC;AAE1C,eAAO,MAAM,aAAa,uBAAuB,CAAC;AAElD,eAAO,MAAM,kBAAkB,iBAAiB,CAAC;AAEjD,eAAO,MAAM,kBAAkB,iBAAiB,CAAC;AAEjD,eAAO,MAAM,YAAY,WAAW,CAAC;AAErC,eAAO,MAAM,eAAe,cAAc,CAAC;AAE3C,eAAO,MAAM,eAAe,sBAAsB,CAAC;AAEnD,eAAO,MAAM,WAAW,UAAU,CAAC;AAEnC,eAAO,MAAM,UAAU,YAAa,MAAM,WAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"shown.d.ts","sourceRoot":"","sources":["../src/shown.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAA8B,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM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AI,CAAC,CAepD;AAED,wBAAgB,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAIpE;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAE3D;AAED,wBAAgB,YAAY,CAAC,EAAE,MAAM,EAAE,EAAE,OAAO,GAAG,MAAM,CAExD;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAK5D;AAYD,wBAAsB,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,UAAU,EAAE,CAAC,CAGjG;AAcD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBhF;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAQjG;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,QAG/D;AAED,wBAAsB,IAAI,CACxB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,aAAa,GAAG,IAAI,EAC9B,IAAI,GAAE,IAAqC,iBAkC5C"}
|
package/dist/shown.js
CHANGED
|
@@ -14,8 +14,16 @@ export const TIME_ZONE_TOPIC = 'time-zone';
|
|
|
14
14
|
export const AUTHORITY_TOPIC = 'authority-changes';
|
|
15
15
|
export const LOCKS_TOPIC = 'locks';
|
|
16
16
|
export const queueTopic = (locator) => `queue\u0000${locator}`;
|
|
17
|
-
async function attended({ store, localSaves }) {
|
|
18
|
-
const held =
|
|
17
|
+
async function attended({ store, socket, localSaves }) {
|
|
18
|
+
const held = store.needed()
|
|
19
|
+
? await store.status()
|
|
20
|
+
: {
|
|
21
|
+
queued: [],
|
|
22
|
+
lastCompleted: socket.session.now().lastCompleted,
|
|
23
|
+
unsent: [],
|
|
24
|
+
resets: [],
|
|
25
|
+
returned: [],
|
|
26
|
+
};
|
|
19
27
|
const attentionRequired = held.returned.flatMap((record) => record.returned === null
|
|
20
28
|
? []
|
|
21
29
|
: [{ room: record.locator, path: record.path, returned: structuredClone(record.returned) }]);
|
|
@@ -43,7 +51,7 @@ async function attended({ store, localSaves }) {
|
|
|
43
51
|
};
|
|
44
52
|
}
|
|
45
53
|
async function queuedWork({ store, localSaves }) {
|
|
46
|
-
return !localSaves && (await store.queued()).length > 0;
|
|
54
|
+
return !localSaves && store.needed() && (await store.queued()).length > 0;
|
|
47
55
|
}
|
|
48
56
|
export function recoverReads({ liveQueries, figures }, locators) {
|
|
49
57
|
liveQueries.recover(locators);
|
|
@@ -266,6 +274,8 @@ export function publishChangeSet(runtime, set) {
|
|
|
266
274
|
}
|
|
267
275
|
export async function submissionDue(runtime, locators) {
|
|
268
276
|
const { store } = runtime;
|
|
277
|
+
if (!store.needed())
|
|
278
|
+
return;
|
|
269
279
|
const due = (await store.queued()).filter((locator) => locators === undefined || locators.includes(locator));
|
|
270
280
|
if (due.length === 0)
|
|
271
281
|
return;
|
|
@@ -295,7 +305,10 @@ export async function rest(runtime, progress, live = () => !runtime.socket.close
|
|
|
295
305
|
if (synced && !session.now().recorded) {
|
|
296
306
|
const completedAt = new Date().toISOString();
|
|
297
307
|
try {
|
|
298
|
-
|
|
308
|
+
if (store.needed())
|
|
309
|
+
await (await store.open()).fact('lastCompleted', completedAt);
|
|
310
|
+
else
|
|
311
|
+
session.set({ lastCompleted: completedAt });
|
|
299
312
|
if (!live())
|
|
300
313
|
return;
|
|
301
314
|
session.set({ recorded: true });
|
package/dist/socket/session.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Authorization, ProviderRefusal, QueriedRoom, ServiceMode } from '../adapter.js';
|
|
1
|
+
import type { Authorization, Discovery, ProviderRefusal, QueriedRoom, ServiceMode } from '../adapter.js';
|
|
2
2
|
import { type Cell } from '../cell.js';
|
|
3
3
|
import type { Open } from '../open.js';
|
|
4
4
|
import type { CycleProgress, SyncStatus } from '../status.js';
|
|
@@ -24,6 +24,8 @@ export type Session = {
|
|
|
24
24
|
readonly roomsNamed: boolean;
|
|
25
25
|
readonly roomsListed: boolean;
|
|
26
26
|
readonly queriesOnly: readonly QueriedRoom[];
|
|
27
|
+
readonly unstored: Discovery | null;
|
|
28
|
+
readonly lastCompleted: string | null;
|
|
27
29
|
readonly serviceMode: ServiceMode;
|
|
28
30
|
readonly haltedRefusal: boolean;
|
|
29
31
|
readonly openSignals: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/socket/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/socket/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,SAAS,EACT,eAAe,EACf,WAAW,EACX,WAAW,EACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE9D,MAAM,MAAM,aAAa,GAAG,4BAA4B,GAAG,uBAAuB,CAAC;AAEnF,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC;AAExD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,qBAAqB,CAAC;IAC5B,sBAAsB,EAAE,OAAO,CAAC;IAChC,OAAO,EAAE,eAAe,GAAG,IAAI,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACnB,QAAQ,CAAC,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Aa,CAAC,aAAa,EAAE,aAAa,GAAG,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,CAwBrF"}
|
package/dist/socket/session.js
CHANGED
package/dist/socket.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Adapter, Authorization, ConversationEvent, Discovery, HeldRoom, RoomStreamEvent, ServiceMode } from './adapter.js';
|
|
1
|
+
import type { Adapter, Authorization, ConversationEvent, Discovery, HeldRoom, RoomStreamEvent, RunEvent, ServiceMode } from './adapter.js';
|
|
2
2
|
import type { Reads } from './bootstrap.js';
|
|
3
3
|
import type { Cell } from './cell.js';
|
|
4
4
|
import type { Retries } from './retried.js';
|
|
@@ -30,6 +30,7 @@ export type RuntimeSocket = Admission & Answers & {
|
|
|
30
30
|
readonly ready: Promise<void>;
|
|
31
31
|
readonly firstDiscovery: Promise<void>;
|
|
32
32
|
conversations(): Adapter['conversations'];
|
|
33
|
+
runs(): Adapter['runs'];
|
|
33
34
|
search(): Adapter['search'];
|
|
34
35
|
queryHouse(): Adapter['queryHouse'];
|
|
35
36
|
discover(authorized: Authorization): ReturnType<NonNullable<Adapter['discover']>> | undefined;
|
|
@@ -43,6 +44,7 @@ export type RuntimeSocket = Admission & Answers & {
|
|
|
43
44
|
authorize(): Promise<void>;
|
|
44
45
|
observe(listen: (event: SocketEvent) => void): void;
|
|
45
46
|
observeConversations(listen: (event: ConversationEvent) => void): void;
|
|
47
|
+
observeRuns(listen: (event: RunEvent) => void): void;
|
|
46
48
|
observeServiceMode(listen: (mode: ServiceMode) => void): void;
|
|
47
49
|
close(): void;
|
|
48
50
|
readyFromStore(): void;
|
package/dist/socket.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket.d.ts","sourceRoot":"","sources":["../src/socket.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,aAAa,EACb,iBAAiB,EACjB,SAAS,EACT,QAAQ,EACR,eAAe,EACf,WAAW,EAC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G,OAAO,CAAC;IACpC,MAAM,IAAI,OAAO,CAAC;IAClB,WAAW,IAAI,OAAO,CAAC;IACvB,QAAQ,IAAI,OAAO,CAAC;IACpB,UAAU,IAAI,MAAM,CAAC;IACrB,MAAM,IAAI,OAAO,CAAC;IAClB,IAAI,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,GAAG,IAAI,CAAC;IACvC,IAAI,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC3B,KAAK,IAAI,IAAI,CAAC;IACd,UAAU,IAAI,IAAI,CAAC;IACnB,SAAS,IAAI,IAAI,CAAC;CACnB,CAAC;AAEJ,wBAAgB,YAAY,CAC1B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,aAAa,GAAG,SAAS,GACvC,aAAa,CAgKf"}
|
package/dist/socket.js
CHANGED
|
@@ -18,6 +18,7 @@ export function createSocket(adapter, retries, authorization) {
|
|
|
18
18
|
});
|
|
19
19
|
let withdrawStream;
|
|
20
20
|
let withdrawConversations;
|
|
21
|
+
let withdrawRuns;
|
|
21
22
|
let withdrawServiceMode;
|
|
22
23
|
let socketOpen = false;
|
|
23
24
|
let announced = false;
|
|
@@ -76,6 +77,7 @@ export function createSocket(adapter, retries, authorization) {
|
|
|
76
77
|
ready,
|
|
77
78
|
firstDiscovery,
|
|
78
79
|
conversations: () => adapter.conversations,
|
|
80
|
+
runs: () => adapter.runs,
|
|
79
81
|
search: () => adapter.search,
|
|
80
82
|
queryHouse: () => adapter.queryHouse,
|
|
81
83
|
discover: (authorized) => adapter.discover?.(authorized),
|
|
@@ -107,6 +109,9 @@ export function createSocket(adapter, retries, authorization) {
|
|
|
107
109
|
return;
|
|
108
110
|
withdrawConversations = stream.observe(listen);
|
|
109
111
|
},
|
|
112
|
+
observeRuns(listen) {
|
|
113
|
+
withdrawRuns = adapter.runs?.observe(listen);
|
|
114
|
+
},
|
|
110
115
|
observeServiceMode(listen) {
|
|
111
116
|
withdrawServiceMode = adapter.serviceMode?.observe(listen);
|
|
112
117
|
},
|
|
@@ -117,6 +122,8 @@ export function createSocket(adapter, retries, authorization) {
|
|
|
117
122
|
withdrawStream = undefined;
|
|
118
123
|
withdrawConversations?.();
|
|
119
124
|
withdrawConversations = undefined;
|
|
125
|
+
withdrawRuns?.();
|
|
126
|
+
withdrawRuns = undefined;
|
|
120
127
|
withdrawServiceMode?.();
|
|
121
128
|
},
|
|
122
129
|
readyFromStore: () => readyFromStore(),
|
package/dist/source.d.ts
CHANGED
|
@@ -44,6 +44,23 @@ export type HouseSource = {
|
|
|
44
44
|
readonly kind: 'declined';
|
|
45
45
|
readonly agent: string;
|
|
46
46
|
readonly owner: string;
|
|
47
|
+
} | {
|
|
48
|
+
readonly kind: 'restart';
|
|
49
|
+
} | {
|
|
50
|
+
readonly kind: 'instructions_proposal';
|
|
51
|
+
readonly proposal: string;
|
|
52
|
+
readonly room: {
|
|
53
|
+
readonly ref: string;
|
|
54
|
+
readonly handle: string;
|
|
55
|
+
readonly name: string;
|
|
56
|
+
};
|
|
57
|
+
readonly text: string;
|
|
58
|
+
readonly baseVersion: number | null;
|
|
59
|
+
readonly state: ProposalState | null;
|
|
60
|
+
} | {
|
|
61
|
+
readonly kind: 'milestone';
|
|
62
|
+
} | {
|
|
63
|
+
readonly kind: 'not_saved';
|
|
47
64
|
};
|
|
48
65
|
export type ChatRequest = {
|
|
49
66
|
readonly request: string;
|
|
@@ -54,6 +71,8 @@ type RequestAgentFunction = {
|
|
|
54
71
|
readonly name: string;
|
|
55
72
|
readonly version: number;
|
|
56
73
|
};
|
|
74
|
+
declare const PROPOSAL_STATES: readonly ['waiting', 'sent', 'accepted', 'not_taken'];
|
|
75
|
+
export type ProposalState = (typeof PROPOSAL_STATES)[number];
|
|
57
76
|
export declare function sourceOf(value: unknown, sender: string | null): HouseSource | null;
|
|
58
77
|
export {};
|
|
59
78
|
//# sourceMappingURL=source.d.ts.map
|
package/dist/source.d.ts.map
CHANGED
|
@@ -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
package/dist/source.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { record, text } from './read.js';
|
|
2
2
|
const ANSWERS = ['at_once', 'ask_me', 'off'];
|
|
3
|
-
function
|
|
3
|
+
function agentRunOf(value) {
|
|
4
4
|
if (value === null)
|
|
5
5
|
return null;
|
|
6
|
-
const
|
|
7
|
-
const name = text(
|
|
8
|
-
const version =
|
|
6
|
+
const agentRun = record(value);
|
|
7
|
+
const name = text(agentRun, 'name');
|
|
8
|
+
const version = agentRun.version;
|
|
9
9
|
return name === null || typeof version !== 'number' ? undefined : { name, version };
|
|
10
10
|
}
|
|
11
11
|
function answerOf(value) {
|
|
@@ -13,7 +13,7 @@ function answerOf(value) {
|
|
|
13
13
|
}
|
|
14
14
|
function requestOf(source) {
|
|
15
15
|
const request = text(source, 'request');
|
|
16
|
-
const
|
|
16
|
+
const agentRun = agentRunOf(source.agent_function);
|
|
17
17
|
const requester = record(source.requester);
|
|
18
18
|
const by = text(requester, 'name');
|
|
19
19
|
const room = record(source.room);
|
|
@@ -22,7 +22,7 @@ function requestOf(source) {
|
|
|
22
22
|
const called = text(room, 'name');
|
|
23
23
|
const sent = typeof source.sent === 'string' ? source.sent : null;
|
|
24
24
|
if (request === null ||
|
|
25
|
-
|
|
25
|
+
agentRun === undefined ||
|
|
26
26
|
by === null ||
|
|
27
27
|
ref === null ||
|
|
28
28
|
handle === null ||
|
|
@@ -32,7 +32,7 @@ function requestOf(source) {
|
|
|
32
32
|
return {
|
|
33
33
|
kind: 'request',
|
|
34
34
|
request,
|
|
35
|
-
agentFunction,
|
|
35
|
+
agentFunction: agentRun,
|
|
36
36
|
requester: { name: by, room: text(requester, 'room') !== null },
|
|
37
37
|
room: { ref, handle, name: called },
|
|
38
38
|
sent,
|
|
@@ -41,10 +41,38 @@ function requestOf(source) {
|
|
|
41
41
|
approved: text(source, 'approved_at'),
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
+
const PROPOSAL_STATES = ['waiting', 'sent', 'accepted', 'not_taken'];
|
|
45
|
+
function proposalOf(source) {
|
|
46
|
+
const proposal = text(source, 'proposal');
|
|
47
|
+
const room = record(source.room);
|
|
48
|
+
const ref = text(room, 'ref');
|
|
49
|
+
const handle = text(room, 'handle');
|
|
50
|
+
const called = text(room, 'name');
|
|
51
|
+
const proposed = typeof source.text === 'string' ? source.text : null;
|
|
52
|
+
const base = source.base_version;
|
|
53
|
+
if (proposal === null || ref === null || handle === null || called === null || proposed === null)
|
|
54
|
+
return null;
|
|
55
|
+
return {
|
|
56
|
+
kind: 'instructions_proposal',
|
|
57
|
+
proposal,
|
|
58
|
+
room: { ref, handle, name: called },
|
|
59
|
+
text: proposed,
|
|
60
|
+
baseVersion: typeof base === 'number' ? base : null,
|
|
61
|
+
state: PROPOSAL_STATES.find((one) => one === source.state) ?? null,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
44
64
|
export function sourceOf(value, sender) {
|
|
45
65
|
const source = record(value);
|
|
46
66
|
if (source.kind === 'request')
|
|
47
67
|
return requestOf(source);
|
|
68
|
+
if (source.kind === 'instructions_proposal')
|
|
69
|
+
return proposalOf(source);
|
|
70
|
+
if (source.kind === 'restart')
|
|
71
|
+
return { kind: 'restart' };
|
|
72
|
+
if (source.kind === 'milestone')
|
|
73
|
+
return { kind: 'milestone' };
|
|
74
|
+
if (source.kind === 'not_saved')
|
|
75
|
+
return { kind: 'not_saved' };
|
|
48
76
|
if (source.kind === 'trigger') {
|
|
49
77
|
const trigger = text(record(source.trigger), 'description');
|
|
50
78
|
const room = record(source.room);
|