@agentshouse/mdruntime-adapter 0.1.0-c159093d95310 → 0.1.0-c15a971c6743c
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 +2 -2
- package/dist/actions.d.ts +120 -27
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +8 -99
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +85 -135
- package/dist/app-reference.d.ts +2 -0
- package/dist/app-reference.d.ts.map +1 -0
- package/dist/app-reference.js +2 -0
- package/dist/crockford.d.ts +4 -0
- package/dist/crockford.d.ts.map +1 -0
- package/dist/crockford.js +3 -0
- package/dist/discovery.d.ts +5 -10
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +18 -32
- package/dist/gather.d.ts +0 -1
- package/dist/gather.d.ts.map +1 -1
- package/dist/gather.js +1 -1
- package/dist/house-model.d.ts +2938 -0
- package/dist/house-model.d.ts.map +1 -0
- package/dist/house-model.js +1614 -0
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/model.d.ts +5 -1
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +11 -13
- package/dist/part.d.ts +12 -11
- package/dist/part.d.ts.map +1 -1
- package/dist/part.js +66 -56
- package/dist/read.d.ts +15 -13
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +114 -127
- package/dist/room-stream.d.ts +19 -0
- package/dist/room-stream.d.ts.map +1 -0
- package/dist/room-stream.js +57 -0
- package/dist/room-types.d.ts +2 -1
- package/dist/room-types.d.ts.map +1 -1
- package/dist/room-types.js +62 -2
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +40 -97
- package/dist/stream.d.ts +3 -6
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +38 -288
- package/dist/transport.d.ts +12 -21
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +1 -1
- package/dist/upload.d.ts.map +1 -1
- package/dist/upload.js +25 -14
- package/dist/write.d.ts +4 -0
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +12 -15
- package/package.json +8 -4
- package/AGENTS.md +0 -319
- package/dist/referrer.d.ts +0 -9
- package/dist/referrer.d.ts.map +0 -1
- package/dist/referrer.js +0 -41
package/dist/adapter.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { stepped } from '@agentshouse/mdruntime';
|
|
2
2
|
import { DISCOVER_PREFIXES, capabilities, discoveredRoom, mapDiscovery, parseDiscovery, trackedFrom, } from './discovery.js';
|
|
3
|
-
import {
|
|
4
|
-
import { gathered,
|
|
3
|
+
import { streamedModels, viewModels } from './model.js';
|
|
4
|
+
import { gathered, selections } from './gather.js';
|
|
5
5
|
import { createSiteAdapter } from './site.js';
|
|
6
|
-
import { authorityRoot, bootstrapping,
|
|
7
|
-
import {
|
|
6
|
+
import { authorityRoot, bootstrapping, parseEnumeration, parseFileAddress, parseGrant, refreshFrom, viewOf, wholeView, } from './read.js';
|
|
7
|
+
import { roomStreams } from './room-stream.js';
|
|
8
8
|
import { sha256Hex } from './digest.js';
|
|
9
9
|
import { finishedUpload, houseUpload } from './upload.js';
|
|
10
10
|
import { houseAction } from './actions.js';
|
|
11
11
|
import { classifyDoor, classifyRead, discoveryFailure, doorRefusal } from './refusal.js';
|
|
12
12
|
import { houseNotifications } from './stream.js';
|
|
13
|
-
import { DOOR_BATCH, DOOR_BATCH_UPLOAD, DOOR_BOOTSTRAP, DOOR_DISCOVER, DOOR_ENUMERATE, DOOR_FILES_GET, DOOR_REVISIONS, } from './transport.js';
|
|
13
|
+
import { DOOR_BATCH, DOOR_BATCH_UPLOAD, DOOR_BOOTSTRAP, DOOR_DISCOVER, DOOR_ENUMERATE, DOOR_FILES_ATTACH, DOOR_FILES_GET, DOOR_REVISIONS, } from './transport.js';
|
|
14
14
|
import { batchPaths, deltaBody, deltaBytes, deltaDigest, historyOutcome, houseChanges, houseMove, mutationOutcome, operationHead, rejectedMapping, revisionBody, uploadable, } from './write.js';
|
|
15
|
-
import {
|
|
16
|
-
import { HOUSE_ROOM_TYPES } from './room-types.js';
|
|
15
|
+
import { HOUSE_NAMEABLE_ROOM_TYPES, HOUSE_ROOM_TYPES } from './room-types.js';
|
|
17
16
|
import { followsVersion, logPosition, presented, reachedVersion, roomVersion, } from './version.js';
|
|
18
17
|
const UNCERTAIN = { kind: 'transport-uncertainty' };
|
|
19
18
|
const UNCERTAIN_READ = { kind: 'transport-uncertainty' };
|
|
19
|
+
const OCTET_STREAM = 'application/octet-stream';
|
|
20
20
|
const EXPIRED_ADDRESS = 403;
|
|
21
21
|
function lapsedGrant(outcome) {
|
|
22
22
|
return outcome.kind === 'rejected' && outcome.code === 'upload_unavailable';
|
|
@@ -54,61 +54,48 @@ export function createAgentsHouseAdapter(options) {
|
|
|
54
54
|
const notifications = houseNotifications(transport, 'credential');
|
|
55
55
|
const tracked = new Map();
|
|
56
56
|
const handed = new Map();
|
|
57
|
-
|
|
57
|
+
const rooms = roomStreams('credential');
|
|
58
|
+
const unreused = new Set();
|
|
58
59
|
let bounds;
|
|
59
60
|
function declared() {
|
|
60
61
|
if (bounds === undefined)
|
|
61
62
|
throw new Error('no Discovery declared the bounds');
|
|
62
63
|
return bounds;
|
|
63
64
|
}
|
|
64
|
-
async function
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
...(continued.held === undefined ? {} : { held: [continued.held] }),
|
|
70
|
-
});
|
|
71
|
-
const failure = classifyRead(answered.status, answered.body, entry.locator);
|
|
72
|
-
if (failure !== null)
|
|
73
|
-
return failure;
|
|
74
|
-
const scope = await housePart(continued.room, answered.body, listed, 'credential');
|
|
75
|
-
if (scope !== null)
|
|
76
|
-
return scope;
|
|
77
|
-
}
|
|
78
|
-
return unverifiedPart(entry.locator);
|
|
79
|
-
}
|
|
80
|
-
async function partPage(asked, continued) {
|
|
81
|
-
const { entry } = asked;
|
|
82
|
-
const listed = continued.room.parts[continued.next];
|
|
83
|
-
const sent = listed === undefined
|
|
84
|
-
? emptyScope(continued.room)
|
|
85
|
-
: await fetchedPart(entry, continued, listed);
|
|
86
|
-
if ('kind' in sent)
|
|
87
|
-
return sent;
|
|
88
|
-
const scope = await reused(sent, asked.held);
|
|
65
|
+
async function streamedPage(entry, token, held) {
|
|
66
|
+
const part = await rooms.part(entry, token);
|
|
67
|
+
if ('kind' in part)
|
|
68
|
+
return part;
|
|
69
|
+
const scope = await reused(part.scope, held);
|
|
89
70
|
if (scope === null) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
: bootstrapTogether({ entry, held: undefined });
|
|
71
|
+
unreused.add(entry.locator);
|
|
72
|
+
return UNCERTAIN_READ;
|
|
93
73
|
}
|
|
94
|
-
|
|
95
|
-
const more = next < continued.room.parts.length;
|
|
96
|
-
if (continued.next === 0 && !more)
|
|
74
|
+
if (part.first && part.ended)
|
|
97
75
|
handed.set(entry.locator, roomVersion(scope));
|
|
98
76
|
else
|
|
99
77
|
handed.delete(entry.locator);
|
|
100
78
|
notifications.reach(entry.authority, scope);
|
|
101
|
-
const seen = [
|
|
102
|
-
...continued.seen,
|
|
103
|
-
...entry.schemas.filter((schema) => scope.files.some((file) => file.path === schema)),
|
|
104
|
-
];
|
|
105
|
-
const models = await partModels(scope, entry, new Set(seen), !more);
|
|
106
79
|
return {
|
|
107
80
|
...(await stepped(bootstrapping(scope))),
|
|
108
|
-
...(models === undefined ? {} : { models }),
|
|
109
|
-
...(
|
|
81
|
+
...(part.models === undefined ? {} : { models: part.models }),
|
|
82
|
+
...(part.pageToken === undefined ? {} : { pageToken: part.pageToken }),
|
|
83
|
+
bytes: part.bytes,
|
|
110
84
|
};
|
|
111
85
|
}
|
|
86
|
+
async function openedRoom(entry, request) {
|
|
87
|
+
const reusing = unreused.delete(entry.locator) ? undefined : request.held;
|
|
88
|
+
const files = reusing === undefined
|
|
89
|
+
? null
|
|
90
|
+
: await heldFiles(entry.authority, reusing, declared().max_held_files);
|
|
91
|
+
const answered = await transport.streamed(DOOR_BOOTSTRAP, {
|
|
92
|
+
prefixes: [authorityRoot(entry.handle)],
|
|
93
|
+
...(files === null ? {} : { held: [files] }),
|
|
94
|
+
}, request.signal ?? new AbortController().signal);
|
|
95
|
+
if (answered.room === null)
|
|
96
|
+
return classifyDoor(answered.status, answered.body, entry.locator) ?? UNCERTAIN_READ;
|
|
97
|
+
return rooms.head(entry, answered.room, request.arriving, request.signal);
|
|
98
|
+
}
|
|
112
99
|
async function enumeratedPage(ask, page) {
|
|
113
100
|
const answer = await transport.door(DOOR_ENUMERATE, {
|
|
114
101
|
prefixes: [authorityRoot(ask.entry.handle)],
|
|
@@ -145,11 +132,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
145
132
|
async function streamed(entry, request, from) {
|
|
146
133
|
if (handed.get(entry.locator) !== request.fromRoomVersion)
|
|
147
134
|
return null;
|
|
148
|
-
const
|
|
149
|
-
const kept = asked.length === 0 || heldRevisions === undefined
|
|
150
|
-
? new Map()
|
|
151
|
-
: await heldRevisions(entry.locator, asked);
|
|
152
|
-
const advanced = await stepped(notifications.advance(entry, from, (path, revision) => kept.get(path) === revision));
|
|
135
|
+
const advanced = await stepped(notifications.advance(entry, from));
|
|
153
136
|
if (advanced === null)
|
|
154
137
|
return null;
|
|
155
138
|
handed.set(entry.locator, advanced.page.roomVersion);
|
|
@@ -205,61 +188,6 @@ export function createAgentsHouseAdapter(options) {
|
|
|
205
188
|
return result;
|
|
206
189
|
return { ...result, at: { locator, roomVersion: roomVersion({ position, logEpoch }) } };
|
|
207
190
|
}
|
|
208
|
-
async function holding(asks) {
|
|
209
|
-
const bound = Math.floor(declared().max_held_files / Math.max(1, asks.filter((ask) => ask.held !== undefined).length));
|
|
210
|
-
const held = [];
|
|
211
|
-
for (const ask of asks) {
|
|
212
|
-
if (ask.held === undefined || bound === 0)
|
|
213
|
-
continue;
|
|
214
|
-
const files = await heldFiles(ask.entry.authority, ask.held, bound);
|
|
215
|
-
if (files !== null)
|
|
216
|
-
held.push(files);
|
|
217
|
-
}
|
|
218
|
-
return held;
|
|
219
|
-
}
|
|
220
|
-
async function bootstrapped(asks, answer) {
|
|
221
|
-
let open = asks.map((asked, ask) => ({ entry: asked.entry, asked, ask }));
|
|
222
|
-
while (open.length > 0) {
|
|
223
|
-
const unreached = [];
|
|
224
|
-
for (const part of selections(open, declared().max_prefixes)) {
|
|
225
|
-
const held = await holding(part.map(({ asked }) => asked));
|
|
226
|
-
const answered = await transport.door(DOOR_BOOTSTRAP, {
|
|
227
|
-
prefixes: part.map(({ entry }) => authorityRoot(entry.handle)),
|
|
228
|
-
...(held.length === 0 ? {} : { held }),
|
|
229
|
-
});
|
|
230
|
-
const classified = part.map(({ entry }) => classifyDoor(answered.status, answered.body, entry.locator));
|
|
231
|
-
const parted = classified[0] === null ? parseParted(answered.body) : null;
|
|
232
|
-
for (const [index, asked] of part.entries()) {
|
|
233
|
-
const failure = classified[index];
|
|
234
|
-
if (failure !== null && failure !== undefined) {
|
|
235
|
-
answer(asked.ask, failure);
|
|
236
|
-
continue;
|
|
237
|
-
}
|
|
238
|
-
if (parted === null) {
|
|
239
|
-
answer(asked.ask, UNCERTAIN_READ);
|
|
240
|
-
continue;
|
|
241
|
-
}
|
|
242
|
-
const room = parted.rooms.find((candidate) => candidate.anchor === asked.entry.authority);
|
|
243
|
-
if (room === undefined && parted.next !== undefined) {
|
|
244
|
-
unreached.push(asked);
|
|
245
|
-
continue;
|
|
246
|
-
}
|
|
247
|
-
if (room === undefined) {
|
|
248
|
-
answer(asked.ask, { kind: 'room-not-readable', locator: asked.entry.locator });
|
|
249
|
-
continue;
|
|
250
|
-
}
|
|
251
|
-
const kept = held.find((files) => files.room === asked.entry.authority);
|
|
252
|
-
answer(asked.ask, await partPage(asked.asked, {
|
|
253
|
-
room,
|
|
254
|
-
next: 0,
|
|
255
|
-
seen: [],
|
|
256
|
-
...(kept === undefined ? {} : { held: kept }),
|
|
257
|
-
}));
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
open = unreached;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
191
|
function layered(asks) {
|
|
264
192
|
const depths = new Map();
|
|
265
193
|
const layers = [];
|
|
@@ -306,7 +234,6 @@ export function createAgentsHouseAdapter(options) {
|
|
|
306
234
|
}
|
|
307
235
|
return answers;
|
|
308
236
|
}
|
|
309
|
-
const bootstrapTogether = gatheredEach(bootstrapped);
|
|
310
237
|
const enumerateTogether = gathered(enumerated);
|
|
311
238
|
async function uploaded(head, changes, delta, bytes, entry, handed, keep) {
|
|
312
239
|
const paths = batchPaths(changes);
|
|
@@ -394,9 +321,22 @@ export function createAgentsHouseAdapter(options) {
|
|
|
394
321
|
function linked(answer, locator) {
|
|
395
322
|
const address = addressed(answer, locator);
|
|
396
323
|
return address.kind === 'address'
|
|
397
|
-
? { kind: 'link', url: address.url, name: address.name }
|
|
324
|
+
? { kind: 'link', url: address.url, name: address.name, mediaType: address.mediaType }
|
|
398
325
|
: address;
|
|
399
326
|
}
|
|
327
|
+
function refusedAttach(answer, locator) {
|
|
328
|
+
const failure = classifyDoor(answer.status, answer.body, locator);
|
|
329
|
+
if (failure === null)
|
|
330
|
+
return null;
|
|
331
|
+
return failure.kind === 'scoped-refusal'
|
|
332
|
+
? {
|
|
333
|
+
kind: 'rejected',
|
|
334
|
+
code: failure.code,
|
|
335
|
+
fields: failure.fields,
|
|
336
|
+
retryable: failure.retryable,
|
|
337
|
+
}
|
|
338
|
+
: failure;
|
|
339
|
+
}
|
|
400
340
|
async function downloaded(ask, locator) {
|
|
401
341
|
let address = addressed(await ask(), locator);
|
|
402
342
|
if (address.kind !== 'address')
|
|
@@ -429,6 +369,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
429
369
|
}
|
|
430
370
|
return {
|
|
431
371
|
roomTypes: HOUSE_ROOM_TYPES,
|
|
372
|
+
nameableRoomTypes: HOUSE_NAMEABLE_ROOM_TYPES,
|
|
432
373
|
async authorize() {
|
|
433
374
|
return options.authorize();
|
|
434
375
|
},
|
|
@@ -476,11 +417,9 @@ export function createAgentsHouseAdapter(options) {
|
|
|
476
417
|
const entry = authorityFor(request.locator);
|
|
477
418
|
if (entry === undefined)
|
|
478
419
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
}
|
|
483
|
-
return bootstrapTogether(asked);
|
|
420
|
+
return request.pageToken === undefined
|
|
421
|
+
? openedRoom(entry, request)
|
|
422
|
+
: streamedPage(entry, request.pageToken, request.held);
|
|
484
423
|
},
|
|
485
424
|
async refresh(_authorization, request) {
|
|
486
425
|
const entry = authorityFor(request.locator);
|
|
@@ -538,17 +477,10 @@ export function createAgentsHouseAdapter(options) {
|
|
|
538
477
|
});
|
|
539
478
|
},
|
|
540
479
|
async binary(_authorization, request) {
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
return downloaded(ask, request.locator);
|
|
546
|
-
}
|
|
547
|
-
const referrer = houseReferrer(request.referrer, tracked);
|
|
548
|
-
if (referrer === null) {
|
|
549
|
-
return { kind: 'rejected', code: 'referrer_unknown', fields: {}, retryable: false };
|
|
550
|
-
}
|
|
551
|
-
return downloaded(() => transport.door(DOOR_FILES_GET, { file: request.fileRef, referrer: referrer.referrer }), referrer.locator);
|
|
480
|
+
const ask = pathAddress(request);
|
|
481
|
+
if (ask === null)
|
|
482
|
+
return { kind: 'room-not-readable', locator: request.locator };
|
|
483
|
+
return downloaded(ask, request.locator);
|
|
552
484
|
},
|
|
553
485
|
async link(_authorization, request) {
|
|
554
486
|
const ask = pathAddress(request);
|
|
@@ -556,8 +488,34 @@ export function createAgentsHouseAdapter(options) {
|
|
|
556
488
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
557
489
|
return linked(await ask(), request.locator);
|
|
558
490
|
},
|
|
559
|
-
|
|
560
|
-
|
|
491
|
+
async attach(_authorization, request) {
|
|
492
|
+
const entry = authorityFor(request.locator);
|
|
493
|
+
if (entry === undefined)
|
|
494
|
+
return { kind: 'room-not-readable', locator: request.locator };
|
|
495
|
+
const declared = await transport.door(DOOR_FILES_ATTACH, {
|
|
496
|
+
room_ref: entry.authority,
|
|
497
|
+
name: request.name,
|
|
498
|
+
bytes: request.byteLength,
|
|
499
|
+
sha256: request.sha256,
|
|
500
|
+
media_type: request.mediaType.length > 0 ? request.mediaType : OCTET_STREAM,
|
|
501
|
+
});
|
|
502
|
+
const refused = refusedAttach(declared, request.locator);
|
|
503
|
+
if (refused !== null)
|
|
504
|
+
return refused;
|
|
505
|
+
const upload = houseUpload(declared.body?.upload);
|
|
506
|
+
if (upload === null)
|
|
507
|
+
return UNCERTAIN_READ;
|
|
508
|
+
const finished = await finishedUpload(transport, upload, request.blob);
|
|
509
|
+
if (finished === null)
|
|
510
|
+
return UNCERTAIN_READ;
|
|
511
|
+
const unfinished = refusedAttach(finished, request.locator);
|
|
512
|
+
if (unfinished !== null)
|
|
513
|
+
return unfinished;
|
|
514
|
+
const { path, revision } = (finished.body ?? {});
|
|
515
|
+
const root = `/rooms/${entry.handle}/`;
|
|
516
|
+
return typeof path === 'string' && path.startsWith(root) && typeof revision === 'string'
|
|
517
|
+
? { kind: 'attached', path: path.slice(root.length), revision }
|
|
518
|
+
: UNCERTAIN_READ;
|
|
561
519
|
},
|
|
562
520
|
reached(locator, version, target) {
|
|
563
521
|
return reachedVersion(version, target, authorityFor(locator)?.logEpoch);
|
|
@@ -571,15 +529,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
571
529
|
roomStream: {
|
|
572
530
|
hold: held,
|
|
573
531
|
reopen: notifications.reopen,
|
|
574
|
-
observe
|
|
575
|
-
heldRevisions = revisions;
|
|
576
|
-
return notifications.observe(notify, receipts);
|
|
577
|
-
},
|
|
578
|
-
published(locator, roomVersion) {
|
|
579
|
-
const at = logPosition(roomVersion);
|
|
580
|
-
if (at !== null)
|
|
581
|
-
notifications.published(locator, at);
|
|
582
|
-
},
|
|
532
|
+
observe: notifications.observe,
|
|
583
533
|
},
|
|
584
534
|
conversations: notifications.conversations,
|
|
585
535
|
serviceMode: notifications.serviceMode,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-reference.d.ts","sourceRoot":"","sources":["../src/app-reference.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,qBAAqB,QAEjC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crockford.d.ts","sourceRoot":"","sources":["../src/crockford.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,qCAAqC,CAAC;AAErE,eAAO,MAAM,mBAAmB,uCAA4B,CAAC;AAE7D,eAAO,MAAM,2BAA2B,QAAqC,CAAC"}
|
package/dist/discovery.d.ts
CHANGED
|
@@ -22,20 +22,16 @@ export type HouseOperations = {
|
|
|
22
22
|
write: readonly string[];
|
|
23
23
|
delete: readonly string[];
|
|
24
24
|
};
|
|
25
|
-
export type
|
|
26
|
-
export type HouseModel = {
|
|
27
|
-
root: string;
|
|
28
|
-
paths: readonly string[];
|
|
29
|
-
};
|
|
25
|
+
export type HouseAccessLevel = 'search' | 'open' | 'keep';
|
|
30
26
|
export type HouseAuthority = LogPosition & {
|
|
31
27
|
roomRef: string;
|
|
32
28
|
roomHandle: string;
|
|
33
29
|
name: string;
|
|
34
30
|
schema: string;
|
|
35
|
-
|
|
31
|
+
typedSelection: readonly string[] | null;
|
|
36
32
|
managedReplication: 'admitted' | 'unavailable';
|
|
37
33
|
protectedPaths: readonly string[];
|
|
38
|
-
|
|
34
|
+
level: HouseAccessLevel;
|
|
39
35
|
operations: HouseOperations;
|
|
40
36
|
};
|
|
41
37
|
export type HouseDiscoveryDocument = {
|
|
@@ -49,8 +45,7 @@ export type TrackedAuthority = LogPosition & {
|
|
|
49
45
|
authority: string;
|
|
50
46
|
handle: string;
|
|
51
47
|
schema: string;
|
|
52
|
-
|
|
53
|
-
schemas: readonly string[];
|
|
48
|
+
typedSelection: readonly string[] | null;
|
|
54
49
|
};
|
|
55
50
|
export type HouseSiteAuthority = LogPosition & {
|
|
56
51
|
roomRef: string;
|
|
@@ -67,7 +62,7 @@ export declare function siteTracked(document: HouseSiteDiscovery): TrackedAuthor
|
|
|
67
62
|
export declare function trackedFrom(document: HouseDiscoveryDocument): TrackedAuthority[];
|
|
68
63
|
export declare function providerLimits(bounds: HouseBounds): readonly ProviderLimit[];
|
|
69
64
|
export declare function declaredRetention(bounds: HouseBounds): Retention;
|
|
70
|
-
export declare function capabilities(actions: HouseDiscoveryDocument['actions'], rooms: readonly Pick<TrackedAuthority, 'authority' | '
|
|
65
|
+
export declare function capabilities(actions: HouseDiscoveryDocument['actions'], rooms: readonly Pick<TrackedAuthority, 'authority' | 'handle'>[]): readonly Capability[];
|
|
71
66
|
export declare function siteCapabilities(): readonly Capability[];
|
|
72
67
|
export declare function discoveredRoom(authority: HouseAuthority): DiscoveredRoom;
|
|
73
68
|
export declare function mapDiscovery(document: Pick<HouseDiscoveryDocument, 'bounds'>, rooms: readonly DiscoveredRoom[], declared: readonly Capability[]): Discovery;
|
package/dist/discovery.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,SAAS,EACT,MAAM,EACN,aAAa,EACb,SAAS,EACV,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAA6B,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3E,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AAEnD,eAAO,MAAM,iBAAiB,EAAE,SAAS,MAAM,EAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,SAAS,EACT,MAAM,EACN,aAAa,EACb,SAAS,EACV,MAA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EAAE,SAAS,IAAI,CAAC,gBAAgB,EAAE,WAAW,GAAG,QAAQ,CAAC,EAAE,GAC/D,SAAS,UAAU,EAAE,CASvB;AAED,wBAAgB,gBAAgB,IAAI,SAAS,UAAU,EAAE,CAOxD;AAED,wBAAgB,cAAc,CAAC,SAAS,EAAE,cAAc,GAAG,cAAc,CAqBxE;AAED,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,IAAI,CAAC,sBAAsB,EAAE,QAAQ,CAAC,EAChD,KAAK,EAAE,SAAS,cAAc,EAAE,EAChC,QAAQ,EAAE,SAAS,UAAU,EAAE,GAC9B,SAAS,CAQX"}
|
package/dist/discovery.js
CHANGED
|
@@ -2,6 +2,7 @@ import { declaredActions, houseConversationAgents, SITE_SUBMIT } from './actions
|
|
|
2
2
|
import { readPosition, roomVersion } from './version.js';
|
|
3
3
|
export const PROVIDER_ACTIONS = 'provider-actions';
|
|
4
4
|
export const DISCOVER_PREFIXES = ['/'];
|
|
5
|
+
const PRIVATE_HANDLE = 'private';
|
|
5
6
|
const BOUND_KEYS = [
|
|
6
7
|
'max_authored_file_bytes',
|
|
7
8
|
'max_batch_operations',
|
|
@@ -18,7 +19,7 @@ const BOUND_KEYS = [
|
|
|
18
19
|
'operation_retention_seconds',
|
|
19
20
|
];
|
|
20
21
|
const OPERATION_KEYS = ['write', 'delete'];
|
|
21
|
-
const
|
|
22
|
+
const ACCESS_LEVELS = ['search', 'open', 'keep'];
|
|
22
23
|
function stringList(value) {
|
|
23
24
|
if (!Array.isArray(value))
|
|
24
25
|
return null;
|
|
@@ -43,16 +44,10 @@ function parseBounds(value) {
|
|
|
43
44
|
}
|
|
44
45
|
return bounds;
|
|
45
46
|
}
|
|
46
|
-
function
|
|
47
|
+
function parseTypedSelection(value) {
|
|
47
48
|
if (value === undefined)
|
|
48
49
|
return null;
|
|
49
|
-
|
|
50
|
-
return undefined;
|
|
51
|
-
const held = value;
|
|
52
|
-
const paths = stringList(held.paths);
|
|
53
|
-
if (typeof held.root !== 'string' || held.root.length === 0 || paths === null)
|
|
54
|
-
return undefined;
|
|
55
|
-
return { root: held.root, paths };
|
|
50
|
+
return stringList(value) ?? undefined;
|
|
56
51
|
}
|
|
57
52
|
function parseMember(value) {
|
|
58
53
|
if (typeof value !== 'object' || value === null)
|
|
@@ -89,14 +84,14 @@ function parseAuthority(value) {
|
|
|
89
84
|
return null;
|
|
90
85
|
}
|
|
91
86
|
const at = readPosition(held);
|
|
92
|
-
const
|
|
87
|
+
const typedSelection = parseTypedSelection(held.typed_selection);
|
|
93
88
|
const protectedPaths = stringList(held.protected_paths);
|
|
94
89
|
const operations = parseOperations(held.operations);
|
|
95
|
-
const
|
|
90
|
+
const level = ACCESS_LEVELS.find((one) => one === held.level);
|
|
96
91
|
if (at === null ||
|
|
97
|
-
|
|
92
|
+
typedSelection === undefined ||
|
|
98
93
|
protectedPaths === null ||
|
|
99
|
-
|
|
94
|
+
level === undefined ||
|
|
100
95
|
operations === null)
|
|
101
96
|
return null;
|
|
102
97
|
if (typeof held.room_ref !== 'string' || held.room_ref.length === 0)
|
|
@@ -108,10 +103,10 @@ function parseAuthority(value) {
|
|
|
108
103
|
roomHandle: held.room_handle,
|
|
109
104
|
name: held.name,
|
|
110
105
|
schema: held.model_root,
|
|
111
|
-
|
|
106
|
+
typedSelection,
|
|
112
107
|
managedReplication: held.managed_replication,
|
|
113
108
|
protectedPaths,
|
|
114
|
-
|
|
109
|
+
level,
|
|
115
110
|
operations,
|
|
116
111
|
...at,
|
|
117
112
|
};
|
|
@@ -188,25 +183,18 @@ export function siteTracked(document) {
|
|
|
188
183
|
authority: authority.roomRef,
|
|
189
184
|
handle: authority.roomHandle,
|
|
190
185
|
schema: authority.schema,
|
|
191
|
-
|
|
192
|
-
schemas: [authority.schema],
|
|
186
|
+
typedSelection: null,
|
|
193
187
|
position: authority.position,
|
|
194
188
|
logEpoch: authority.logEpoch,
|
|
195
189
|
}));
|
|
196
190
|
}
|
|
197
|
-
function schemasOf(authority) {
|
|
198
|
-
return authority.houseModel === null
|
|
199
|
-
? [authority.schema]
|
|
200
|
-
: [authority.schema, authority.houseModel.root];
|
|
201
|
-
}
|
|
202
191
|
export function trackedFrom(document) {
|
|
203
192
|
return document.authorities.map((authority) => ({
|
|
204
193
|
locator: authority.roomRef,
|
|
205
194
|
authority: authority.roomRef,
|
|
206
195
|
handle: authority.roomHandle,
|
|
207
196
|
schema: authority.schema,
|
|
208
|
-
|
|
209
|
-
schemas: schemasOf(authority),
|
|
197
|
+
typedSelection: authority.typedSelection,
|
|
210
198
|
position: authority.position,
|
|
211
199
|
logEpoch: authority.logEpoch,
|
|
212
200
|
}));
|
|
@@ -233,14 +221,12 @@ export function declaredRetention(bounds) {
|
|
|
233
221
|
};
|
|
234
222
|
}
|
|
235
223
|
export function capabilities(actions, rooms) {
|
|
236
|
-
const
|
|
224
|
+
const own = rooms.find((room) => room.handle === PRIVATE_HANDLE);
|
|
237
225
|
return [
|
|
238
226
|
{
|
|
239
227
|
name: PROVIDER_ACTIONS,
|
|
240
228
|
actions: declaredActions(actions),
|
|
241
|
-
...(
|
|
242
|
-
? {}
|
|
243
|
-
: { conversationAgents: houseConversationAgents(house.authority) }),
|
|
229
|
+
...(own === undefined ? {} : { conversationAgents: houseConversationAgents(own.authority) }),
|
|
244
230
|
},
|
|
245
231
|
];
|
|
246
232
|
}
|
|
@@ -266,12 +252,12 @@ export function discoveredRoom(authority) {
|
|
|
266
252
|
replica: {
|
|
267
253
|
selection: locator,
|
|
268
254
|
admission: authority.managedReplication,
|
|
269
|
-
offline: authority.
|
|
255
|
+
offline: authority.level === 'open' ? 'locked' : 'open',
|
|
270
256
|
},
|
|
271
|
-
...(authority.
|
|
257
|
+
...(authority.typedSelection === null
|
|
272
258
|
? {}
|
|
273
|
-
: { typedSelection: { roots: [...authority.
|
|
274
|
-
providerOwnedPaths: [...authority.protectedPaths,
|
|
259
|
+
: { typedSelection: { roots: [...authority.typedSelection] } }),
|
|
260
|
+
providerOwnedPaths: [...authority.protectedPaths, authority.schema],
|
|
275
261
|
};
|
|
276
262
|
}
|
|
277
263
|
export function mapDiscovery(document, rooms, declared) {
|
package/dist/gather.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export declare function gatheredEach<A, R>(send: (asks: readonly A[], answer: (ask: number, result: R) => void) => Promise<void>): (ask: A) => Promise<R>;
|
|
2
1
|
export declare function gathered<A, R>(send: (asks: readonly A[]) => Promise<readonly R[]>): (ask: A) => Promise<R>;
|
|
3
2
|
export declare function selections<T>(items: readonly T[], limit: number): readonly (readonly T[])[];
|
|
4
3
|
//# sourceMappingURL=gather.d.ts.map
|
package/dist/gather.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gather.d.ts","sourceRoot":"","sources":["../src/gather.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"gather.d.ts","sourceRoot":"","sources":["../src/gather.ts"],"names":[],"mappings":"AAkCA,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAC3B,IAAI,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,KAAK,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,GAClD,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAMxB;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAO3F"}
|
package/dist/gather.js
CHANGED