@agentshouse/mdruntime-adapter 0.1.0-c57d433251ca5 → 0.1.0-c5a778fb66fff
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 +3 -27
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +14 -108
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +162 -127
- 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 +3 -8
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +13 -27
- package/dist/house-model.d.ts +2 -0
- package/dist/house-model.d.ts.map +1 -0
- package/dist/house-model.js +484 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- 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 +4 -2
- package/dist/part.d.ts.map +1 -1
- package/dist/part.js +15 -13
- package/dist/read.d.ts +28 -7
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +172 -95
- package/dist/room-types.d.ts +7 -0
- package/dist/room-types.d.ts.map +1 -0
- package/dist/room-types.js +125 -0
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +48 -55
- package/dist/stream.d.ts +1 -0
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +17 -2
- package/dist/transport.d.ts +11 -10
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +2 -1
- package/dist/upload.d.ts +12 -0
- package/dist/upload.d.ts.map +1 -0
- package/dist/upload.js +63 -0
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +13 -17
- package/package.json +8 -4
- package/AGENTS.md +0 -304
- package/dist/handed.d.ts +0 -15
- package/dist/handed.d.ts.map +0 -1
- package/dist/handed.js +0 -45
- package/dist/referrer.d.ts +0 -7
- package/dist/referrer.d.ts.map +0 -1
- package/dist/referrer.js +0 -33
package/dist/adapter.js
CHANGED
|
@@ -1,60 +1,49 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { stepped } from '@agentshouse/mdruntime';
|
|
2
2
|
import { DISCOVER_PREFIXES, capabilities, discoveredRoom, mapDiscovery, parseDiscovery, trackedFrom, } from './discovery.js';
|
|
3
|
-
import { partModels, streamedModels, viewModels } from './model.js';
|
|
3
|
+
import { manifestedModels, partModels, streamedModels, viewModels } from './model.js';
|
|
4
4
|
import { gathered, gatheredEach, selections } from './gather.js';
|
|
5
5
|
import { createSiteAdapter } from './site.js';
|
|
6
|
-
import { authorityRoot, bootstrapping, emptyScope, housePart, parseEnumeration, parseGrant, parseParted, refreshFrom, viewOf, wholeView, } from './read.js';
|
|
7
|
-
import { PART_ATTEMPTS, unverifiedPart } from './part.js';
|
|
6
|
+
import { authorityRoot, bootstrapping, emptyScope, housePart, manifested, parseEnumeration, parseFileAddress, parseGrant, parseParted, partInventory, refreshFrom, viewOf, wholeView, } from './read.js';
|
|
7
|
+
import { PART_ATTEMPTS, partArrival, partFrame, unverifiedPart } from './part.js';
|
|
8
8
|
import { sha256Hex } from './digest.js';
|
|
9
|
-
import {
|
|
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 {
|
|
15
|
+
import { HOUSE_NAMEABLE_ROOM_TYPES, HOUSE_ROOM_TYPES } from './room-types.js';
|
|
16
16
|
import { followsVersion, logPosition, presented, reachedVersion, roomVersion, } from './version.js';
|
|
17
17
|
const UNCERTAIN = { kind: 'transport-uncertainty' };
|
|
18
18
|
const UNCERTAIN_READ = { kind: 'transport-uncertainty' };
|
|
19
|
+
const OCTET_STREAM = 'application/octet-stream';
|
|
20
|
+
const EXPIRED_ADDRESS = 403;
|
|
19
21
|
function lapsedGrant(outcome) {
|
|
20
22
|
return outcome.kind === 'rejected' && outcome.code === 'upload_unavailable';
|
|
21
23
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
return known;
|
|
27
|
-
const sorted = await stepped(sortedKeys(held.documents));
|
|
28
|
-
heldPaths.set(held.documents, sorted);
|
|
29
|
-
return sorted;
|
|
30
|
-
}
|
|
31
|
-
function heldFiles(authority, held, paths, bound) {
|
|
32
|
-
const files = [];
|
|
33
|
-
let through = null;
|
|
34
|
-
for (let at = 0; at < paths.length && through === null; at += 1) {
|
|
35
|
-
const revision = held.revisions[paths[at]];
|
|
36
|
-
if (revision === undefined)
|
|
37
|
-
continue;
|
|
38
|
-
if (files.length === bound)
|
|
39
|
-
through = files.at(-1).path;
|
|
40
|
-
else
|
|
41
|
-
files.push({ path: paths[at], revision });
|
|
42
|
-
}
|
|
24
|
+
async function heldFiles(authority, held, bound) {
|
|
25
|
+
const listed = await held.files(null, bound + 1);
|
|
26
|
+
const files = listed.slice(0, bound);
|
|
27
|
+
const through = listed.length > bound ? (files.at(-1)?.path ?? null) : null;
|
|
43
28
|
return files.length === 0 ? null : { room: authority, through, files };
|
|
44
29
|
}
|
|
45
30
|
async function reused(scope, held) {
|
|
46
31
|
const sent = new Set(scope.contents.map((entry) => entry.path));
|
|
47
32
|
const contents = [...scope.contents];
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
33
|
+
const asked = scope.files.filter((file) => file.binary === undefined && !sent.has(file.path));
|
|
34
|
+
if (asked.length === 0)
|
|
35
|
+
return scope;
|
|
36
|
+
if (held === undefined)
|
|
37
|
+
return null;
|
|
38
|
+
const kept = await held.contents(asked.map(({ path }) => path));
|
|
39
|
+
for (const file of asked) {
|
|
40
|
+
const found = kept.get(file.path);
|
|
41
|
+
if (found === undefined ||
|
|
42
|
+
found.revision !== file.revision ||
|
|
43
|
+
(await sha256Hex(found.content)) !== file.sha256) {
|
|
55
44
|
return null;
|
|
56
45
|
}
|
|
57
|
-
contents.push({ path: file.path, content });
|
|
46
|
+
contents.push({ path: file.path, content: found.content });
|
|
58
47
|
}
|
|
59
48
|
return { ...scope, contents };
|
|
60
49
|
}
|
|
@@ -65,51 +54,56 @@ export function createAgentsHouseAdapter(options) {
|
|
|
65
54
|
const notifications = houseNotifications(transport, 'credential');
|
|
66
55
|
const tracked = new Map();
|
|
67
56
|
const handed = new Map();
|
|
57
|
+
let heldRevisions;
|
|
68
58
|
let bounds;
|
|
69
59
|
function declared() {
|
|
70
60
|
if (bounds === undefined)
|
|
71
61
|
throw new Error('no Discovery declared the bounds');
|
|
72
62
|
return bounds;
|
|
73
63
|
}
|
|
74
|
-
function
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
64
|
+
async function fetchedPart(entry, continued, listed, received, arriving) {
|
|
65
|
+
if (received !== undefined) {
|
|
66
|
+
const kept = new Uint8Array(received);
|
|
67
|
+
const held = await housePart(continued.room, kept, listed, 'credential');
|
|
68
|
+
if (held !== null)
|
|
69
|
+
return 'kind' in held ? held : { scope: held, frame: kept };
|
|
80
70
|
}
|
|
81
|
-
return next.then((room) => {
|
|
82
|
-
if (handed.get(locator) === held)
|
|
83
|
-
handed.set(locator, room);
|
|
84
|
-
else
|
|
85
|
-
handed.delete(locator);
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
async function fetchedPart(entry, continued, listed) {
|
|
89
71
|
for (let attempt = 0; attempt < PART_ATTEMPTS; attempt += 1) {
|
|
90
72
|
const answered = await transport.door(DOOR_BOOTSTRAP, {
|
|
91
73
|
prefixes: [authorityRoot(entry.handle)],
|
|
92
74
|
part: listed.part,
|
|
93
75
|
...(continued.held === undefined ? {} : { held: [continued.held] }),
|
|
94
|
-
});
|
|
76
|
+
}, partArrival(listed, arriving));
|
|
95
77
|
const failure = classifyRead(answered.status, answered.body, entry.locator);
|
|
96
78
|
if (failure !== null)
|
|
97
79
|
return failure;
|
|
98
|
-
const
|
|
80
|
+
const frame = partFrame(answered.body);
|
|
81
|
+
if (frame === null)
|
|
82
|
+
continue;
|
|
83
|
+
const scope = await housePart(continued.room, frame, listed, 'credential');
|
|
99
84
|
if (scope !== null)
|
|
100
|
-
return scope;
|
|
85
|
+
return 'kind' in scope ? scope : { scope, frame };
|
|
101
86
|
}
|
|
102
87
|
return unverifiedPart(entry.locator);
|
|
103
88
|
}
|
|
104
|
-
async function
|
|
89
|
+
async function manifestPage(asked, continued) {
|
|
90
|
+
const inventory = partInventory(continued.room);
|
|
91
|
+
if (inventory.parts === 0) {
|
|
92
|
+
const page = await partPage(asked, continued, undefined, undefined);
|
|
93
|
+
return page.kind === 'bootstrap' ? { ...page, inventory } : page;
|
|
94
|
+
}
|
|
95
|
+
const { models, seen } = await manifestedModels(continued.room, asked.entry);
|
|
96
|
+
return manifested(continued.room, inventory, JSON.stringify({ ...continued, seen }), models);
|
|
97
|
+
}
|
|
98
|
+
async function partPage(asked, continued, received, arriving) {
|
|
105
99
|
const { entry } = asked;
|
|
106
100
|
const listed = continued.room.parts[continued.next];
|
|
107
101
|
const sent = listed === undefined
|
|
108
|
-
? emptyScope(continued.room)
|
|
109
|
-
: await fetchedPart(entry, continued, listed);
|
|
102
|
+
? { scope: emptyScope(continued.room), frame: null }
|
|
103
|
+
: await fetchedPart(entry, continued, listed, received, arriving);
|
|
110
104
|
if ('kind' in sent)
|
|
111
105
|
return sent;
|
|
112
|
-
const scope = await reused(sent, asked.held);
|
|
106
|
+
const scope = await reused(sent.scope, asked.held);
|
|
113
107
|
if (scope === null) {
|
|
114
108
|
return asked.held === undefined
|
|
115
109
|
? UNCERTAIN_READ
|
|
@@ -118,19 +112,20 @@ export function createAgentsHouseAdapter(options) {
|
|
|
118
112
|
const next = continued.next + 1;
|
|
119
113
|
const more = next < continued.room.parts.length;
|
|
120
114
|
if (continued.next === 0 && !more)
|
|
121
|
-
|
|
115
|
+
handed.set(entry.locator, roomVersion(scope));
|
|
122
116
|
else
|
|
123
117
|
handed.delete(entry.locator);
|
|
124
118
|
notifications.reach(entry.authority, scope);
|
|
125
119
|
const seen = [
|
|
126
120
|
...continued.seen,
|
|
127
|
-
...
|
|
121
|
+
...(scope.files.some((file) => file.path === entry.schema) ? [entry.schema] : []),
|
|
128
122
|
];
|
|
129
123
|
const models = await partModels(scope, entry, new Set(seen), !more);
|
|
130
124
|
return {
|
|
131
125
|
...(await stepped(bootstrapping(scope))),
|
|
132
126
|
...(models === undefined ? {} : { models }),
|
|
133
127
|
...(more ? { pageToken: JSON.stringify({ ...continued, next, seen }) } : {}),
|
|
128
|
+
...(sent.frame === null ? {} : { received: sent.frame }),
|
|
134
129
|
};
|
|
135
130
|
}
|
|
136
131
|
async function enumeratedPage(ask, page) {
|
|
@@ -162,18 +157,21 @@ export function createAgentsHouseAdapter(options) {
|
|
|
162
157
|
const answer = await refreshFrom(view, ask.fromRoomVersion);
|
|
163
158
|
if (answer.kind !== 'net-advancement')
|
|
164
159
|
return answer;
|
|
165
|
-
|
|
160
|
+
handed.set(ask.entry.locator, roomVersion(view));
|
|
166
161
|
const models = await viewModels(view, ask.entry);
|
|
167
162
|
return models === undefined ? answer : { ...answer, models };
|
|
168
163
|
}
|
|
169
164
|
async function streamed(entry, request, from) {
|
|
170
|
-
|
|
171
|
-
if (held?.roomVersion !== request.fromRoomVersion)
|
|
165
|
+
if (handed.get(entry.locator) !== request.fromRoomVersion)
|
|
172
166
|
return null;
|
|
173
|
-
const
|
|
167
|
+
const asked = notifications.edited(entry, from);
|
|
168
|
+
const kept = asked.length === 0 || heldRevisions === undefined
|
|
169
|
+
? new Map()
|
|
170
|
+
: await heldRevisions(entry.locator, asked);
|
|
171
|
+
const advanced = await stepped(notifications.advance(entry, from, (path, revision) => kept.get(path) === revision));
|
|
174
172
|
if (advanced === null)
|
|
175
173
|
return null;
|
|
176
|
-
|
|
174
|
+
handed.set(entry.locator, advanced.page.roomVersion);
|
|
177
175
|
const models = await streamedModels(advanced.schemas, entry, 'credential');
|
|
178
176
|
return models === undefined ? advanced.page : { ...advanced.page, models };
|
|
179
177
|
}
|
|
@@ -183,7 +181,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
183
181
|
const at = logPosition(room.roomVersion);
|
|
184
182
|
if (entry === undefined || at === null)
|
|
185
183
|
return [];
|
|
186
|
-
handed.set(room.locator,
|
|
184
|
+
handed.set(room.locator, room.roomVersion);
|
|
187
185
|
notifications.reach(entry.authority, at);
|
|
188
186
|
return [presented(entry.authority, at)];
|
|
189
187
|
});
|
|
@@ -201,8 +199,9 @@ export function createAgentsHouseAdapter(options) {
|
|
|
201
199
|
const held = handed.get(entry.locator);
|
|
202
200
|
if (held === undefined)
|
|
203
201
|
return outcome;
|
|
204
|
-
const follows = followsVersion(held
|
|
205
|
-
|
|
202
|
+
const follows = followsVersion(held, outcome.roomVersion);
|
|
203
|
+
if (follows)
|
|
204
|
+
handed.set(entry.locator, outcome.roomVersion);
|
|
206
205
|
const at = logPosition(outcome.roomVersion);
|
|
207
206
|
if (follows && at !== null)
|
|
208
207
|
notifications.reach(entry.authority, at);
|
|
@@ -231,8 +230,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
231
230
|
for (const ask of asks) {
|
|
232
231
|
if (ask.held === undefined || bound === 0)
|
|
233
232
|
continue;
|
|
234
|
-
const
|
|
235
|
-
const files = heldFiles(ask.entry.authority, ask.held, paths, bound);
|
|
233
|
+
const files = await heldFiles(ask.entry.authority, ask.held, bound);
|
|
236
234
|
if (files !== null)
|
|
237
235
|
held.push(files);
|
|
238
236
|
}
|
|
@@ -270,7 +268,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
270
268
|
continue;
|
|
271
269
|
}
|
|
272
270
|
const kept = held.find((files) => files.room === asked.entry.authority);
|
|
273
|
-
answer(asked.ask, await
|
|
271
|
+
answer(asked.ask, await manifestPage(asked.asked, {
|
|
274
272
|
room,
|
|
275
273
|
next: 0,
|
|
276
274
|
seen: [],
|
|
@@ -342,7 +340,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
342
340
|
};
|
|
343
341
|
}
|
|
344
342
|
const grant = parseGrant(minted.body);
|
|
345
|
-
if (grant === null
|
|
343
|
+
if (grant === null)
|
|
346
344
|
return { outcome: UNCERTAIN };
|
|
347
345
|
const delivered = await transport.transfer({
|
|
348
346
|
act: 'authored_batch_upload',
|
|
@@ -352,7 +350,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
352
350
|
if (delivered.status !== 200)
|
|
353
351
|
return { outcome: UNCERTAIN };
|
|
354
352
|
const holding = parseGrant(delivered.body);
|
|
355
|
-
if (holding === null
|
|
353
|
+
if (holding === null)
|
|
356
354
|
return { outcome: UNCERTAIN };
|
|
357
355
|
const upload = { url: holding.url, operation: holding.operation, bytes, sha256 };
|
|
358
356
|
await keep(upload);
|
|
@@ -362,21 +360,16 @@ export function createAgentsHouseAdapter(options) {
|
|
|
362
360
|
const refusal = doorRefusal(answer.body);
|
|
363
361
|
if (refusal?.code !== 'files_unstaged')
|
|
364
362
|
return null;
|
|
365
|
-
const
|
|
366
|
-
if (!Array.isArray(
|
|
363
|
+
const uploads = refusal.fields.upload;
|
|
364
|
+
if (!Array.isArray(uploads))
|
|
367
365
|
return false;
|
|
368
|
-
for (const
|
|
369
|
-
const
|
|
370
|
-
const change = batch.changes.find((held) => held.kind === 'binary' && held.sha256 === sha256);
|
|
371
|
-
if (
|
|
366
|
+
for (const named of uploads) {
|
|
367
|
+
const upload = houseUpload(named);
|
|
368
|
+
const change = batch.changes.find((held) => held.kind === 'binary' && held.sha256 === named.sha256);
|
|
369
|
+
if (upload === null || change === undefined)
|
|
372
370
|
return false;
|
|
373
|
-
const
|
|
374
|
-
|
|
375
|
-
url,
|
|
376
|
-
body: await file(change.localId),
|
|
377
|
-
operation,
|
|
378
|
-
});
|
|
379
|
-
if (delivered.status !== 200)
|
|
371
|
+
const finished = await finishedUpload(transport, upload, await file(change.localId));
|
|
372
|
+
if (finished?.body?.staged !== true)
|
|
380
373
|
return false;
|
|
381
374
|
}
|
|
382
375
|
return true;
|
|
@@ -402,7 +395,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
402
395
|
destination: { authority: into.authority, handle: into.handle },
|
|
403
396
|
}));
|
|
404
397
|
}
|
|
405
|
-
function
|
|
398
|
+
function addressed(answer, locator) {
|
|
406
399
|
const failure = classifyDoor(answer.status, answer.body, locator);
|
|
407
400
|
if (failure !== null) {
|
|
408
401
|
return failure.kind === 'scoped-refusal'
|
|
@@ -414,33 +407,61 @@ export function createAgentsHouseAdapter(options) {
|
|
|
414
407
|
}
|
|
415
408
|
: failure;
|
|
416
409
|
}
|
|
417
|
-
const
|
|
418
|
-
|
|
419
|
-
if (grant === null || grant.method !== 'GET' || typeof name !== 'string') {
|
|
420
|
-
return UNCERTAIN_READ;
|
|
421
|
-
}
|
|
422
|
-
return { kind: 'link', url: grant.url, name };
|
|
410
|
+
const address = parseFileAddress(answer.body);
|
|
411
|
+
return address === null ? UNCERTAIN_READ : { kind: 'address', ...address };
|
|
423
412
|
}
|
|
424
|
-
|
|
425
|
-
const
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
413
|
+
function linked(answer, locator) {
|
|
414
|
+
const address = addressed(answer, locator);
|
|
415
|
+
return address.kind === 'address'
|
|
416
|
+
? { kind: 'link', url: address.url, name: address.name, mediaType: address.mediaType }
|
|
417
|
+
: address;
|
|
418
|
+
}
|
|
419
|
+
function refusedAttach(answer, locator) {
|
|
420
|
+
const failure = classifyDoor(answer.status, answer.body, locator);
|
|
421
|
+
if (failure === null)
|
|
422
|
+
return null;
|
|
423
|
+
return failure.kind === 'scoped-refusal'
|
|
424
|
+
? {
|
|
425
|
+
kind: 'rejected',
|
|
426
|
+
code: failure.code,
|
|
427
|
+
fields: failure.fields,
|
|
428
|
+
retryable: failure.retryable,
|
|
429
|
+
}
|
|
430
|
+
: failure;
|
|
431
|
+
}
|
|
432
|
+
async function downloaded(ask, locator) {
|
|
433
|
+
let address = addressed(await ask(), locator);
|
|
434
|
+
if (address.kind !== 'address')
|
|
435
|
+
return address;
|
|
436
|
+
let read = await transport.download(address.url);
|
|
437
|
+
if (read.status === EXPIRED_ADDRESS) {
|
|
438
|
+
address = addressed(await ask(), locator);
|
|
439
|
+
if (address.kind !== 'address')
|
|
440
|
+
return address;
|
|
441
|
+
read = await transport.download(address.url);
|
|
442
|
+
}
|
|
443
|
+
if (read.status !== 200 || read.body === null)
|
|
430
444
|
return UNCERTAIN_READ;
|
|
431
|
-
return {
|
|
445
|
+
return {
|
|
446
|
+
kind: 'binary',
|
|
447
|
+
body: read.body,
|
|
448
|
+
mediaType: address.mediaType,
|
|
449
|
+
sha256: address.sha256,
|
|
450
|
+
};
|
|
432
451
|
}
|
|
433
|
-
function
|
|
452
|
+
function pathAddress(request) {
|
|
434
453
|
const entry = authorityFor(request.locator);
|
|
435
454
|
if (entry === undefined)
|
|
436
455
|
return null;
|
|
437
|
-
return transport.door(DOOR_FILES_GET, {
|
|
456
|
+
return () => transport.door(DOOR_FILES_GET, {
|
|
438
457
|
room_ref: entry.authority,
|
|
439
458
|
path: request.path,
|
|
440
459
|
revision: request.revision,
|
|
441
460
|
});
|
|
442
461
|
}
|
|
443
462
|
return {
|
|
463
|
+
roomTypes: HOUSE_ROOM_TYPES,
|
|
464
|
+
nameableRoomTypes: HOUSE_NAMEABLE_ROOM_TYPES,
|
|
444
465
|
async authorize() {
|
|
445
466
|
return options.authorize();
|
|
446
467
|
},
|
|
@@ -490,7 +511,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
490
511
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
491
512
|
const asked = { entry, held: request.held };
|
|
492
513
|
if (request.pageToken !== undefined) {
|
|
493
|
-
return partPage(asked, JSON.parse(request.pageToken));
|
|
514
|
+
return partPage(asked, JSON.parse(request.pageToken), request.received, request.arriving);
|
|
494
515
|
}
|
|
495
516
|
return bootstrapTogether(asked);
|
|
496
517
|
},
|
|
@@ -550,34 +571,45 @@ export function createAgentsHouseAdapter(options) {
|
|
|
550
571
|
});
|
|
551
572
|
},
|
|
552
573
|
async binary(_authorization, request) {
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
return downloaded(await asked, request.locator);
|
|
558
|
-
}
|
|
559
|
-
const referrer = houseReferrer(request.referrer, tracked);
|
|
560
|
-
if (referrer === null) {
|
|
561
|
-
return { kind: 'rejected', code: 'referrer_unknown', fields: {}, retryable: false };
|
|
562
|
-
}
|
|
563
|
-
const answer = await transport.door(DOOR_FILES_GET, {
|
|
564
|
-
file: request.fileRef,
|
|
565
|
-
referrer: referrer.referrer,
|
|
566
|
-
});
|
|
567
|
-
return downloaded(answer, referrer.locator);
|
|
574
|
+
const ask = pathAddress(request);
|
|
575
|
+
if (ask === null)
|
|
576
|
+
return { kind: 'room-not-readable', locator: request.locator };
|
|
577
|
+
return downloaded(ask, request.locator);
|
|
568
578
|
},
|
|
569
579
|
async link(_authorization, request) {
|
|
570
|
-
const
|
|
571
|
-
if (
|
|
580
|
+
const ask = pathAddress(request);
|
|
581
|
+
if (ask === null)
|
|
572
582
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
573
|
-
return
|
|
583
|
+
return linked(await ask(), request.locator);
|
|
574
584
|
},
|
|
575
|
-
|
|
576
|
-
const
|
|
577
|
-
if (
|
|
578
|
-
return
|
|
579
|
-
const
|
|
580
|
-
|
|
585
|
+
async attach(_authorization, request) {
|
|
586
|
+
const entry = authorityFor(request.locator);
|
|
587
|
+
if (entry === undefined)
|
|
588
|
+
return { kind: 'room-not-readable', locator: request.locator };
|
|
589
|
+
const declared = await transport.door(DOOR_FILES_ATTACH, {
|
|
590
|
+
room_ref: entry.authority,
|
|
591
|
+
name: request.name,
|
|
592
|
+
bytes: request.byteLength,
|
|
593
|
+
sha256: request.sha256,
|
|
594
|
+
media_type: request.mediaType.length > 0 ? request.mediaType : OCTET_STREAM,
|
|
595
|
+
});
|
|
596
|
+
const refused = refusedAttach(declared, request.locator);
|
|
597
|
+
if (refused !== null)
|
|
598
|
+
return refused;
|
|
599
|
+
const upload = houseUpload(declared.body?.upload);
|
|
600
|
+
if (upload === null)
|
|
601
|
+
return UNCERTAIN_READ;
|
|
602
|
+
const finished = await finishedUpload(transport, upload, request.blob);
|
|
603
|
+
if (finished === null)
|
|
604
|
+
return UNCERTAIN_READ;
|
|
605
|
+
const unfinished = refusedAttach(finished, request.locator);
|
|
606
|
+
if (unfinished !== null)
|
|
607
|
+
return unfinished;
|
|
608
|
+
const { path, revision } = (finished.body ?? {});
|
|
609
|
+
const root = `/rooms/${entry.handle}/`;
|
|
610
|
+
return typeof path === 'string' && path.startsWith(root) && typeof revision === 'string'
|
|
611
|
+
? { kind: 'attached', path: path.slice(root.length), revision }
|
|
612
|
+
: UNCERTAIN_READ;
|
|
581
613
|
},
|
|
582
614
|
reached(locator, version, target) {
|
|
583
615
|
return reachedVersion(version, target, authorityFor(locator)?.logEpoch);
|
|
@@ -591,7 +623,10 @@ export function createAgentsHouseAdapter(options) {
|
|
|
591
623
|
roomStream: {
|
|
592
624
|
hold: held,
|
|
593
625
|
reopen: notifications.reopen,
|
|
594
|
-
observe
|
|
626
|
+
observe(notify, receipts, revisions) {
|
|
627
|
+
heldRevisions = revisions;
|
|
628
|
+
return notifications.observe(notify, receipts);
|
|
629
|
+
},
|
|
595
630
|
published(locator, roomVersion) {
|
|
596
631
|
const at = logPosition(roomVersion);
|
|
597
632
|
if (at !== null)
|
|
@@ -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
|
@@ -23,16 +23,12 @@ export type HouseOperations = {
|
|
|
23
23
|
delete: readonly string[];
|
|
24
24
|
};
|
|
25
25
|
export type HouseReadLevel = 'mcp' | 'online' | 'local';
|
|
26
|
-
export type HouseModel = {
|
|
27
|
-
root: string;
|
|
28
|
-
paths: readonly string[];
|
|
29
|
-
};
|
|
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
|
read: HouseReadLevel;
|
|
@@ -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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