@agentshouse/mdruntime-adapter 0.1.0-c247535b70788 → 0.1.0-c24c242c24890
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 +2 -11
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +4 -69
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +54 -20
- 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 +11 -24
- 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 +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -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 +1 -1
- package/dist/part.d.ts.map +1 -1
- package/dist/part.js +5 -8
- package/dist/read.d.ts +8 -2
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +77 -47
- package/dist/room-types.d.ts +2 -1
- package/dist/room-types.d.ts.map +1 -1
- package/dist/room-types.js +60 -2
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +16 -25
- package/dist/stream.js +1 -1
- package/dist/transport.d.ts +2 -2
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +1 -0
- package/dist/upload.d.ts.map +1 -1
- package/dist/upload.js +25 -14
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +2 -13
- package/package.json +8 -4
- package/AGENTS.md +0 -319
- package/dist/referrer.d.ts +0 -12
- package/dist/referrer.d.ts.map +0 -1
- package/dist/referrer.js +0 -31
package/README.md
CHANGED
|
@@ -24,8 +24,8 @@ host.attach(port, 'my-app');
|
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
App code never imports this package; it reaches the Runtime only through the
|
|
27
|
-
client its host hands it. The rules an App's agent follows are
|
|
28
|
-
|
|
27
|
+
client its host hands it. The rules an App's agent follows are the `apps/` pages
|
|
28
|
+
of House's Guide, which House's `open_guide` opens.
|
|
29
29
|
|
|
30
30
|
## License
|
|
31
31
|
|
package/dist/actions.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { type AcceptedMessage, type ActionDeclaration, type ActionRequest, type ActionResult, type ConversationAgents, type ConversationHistories, type ConversationHistoryRequest
|
|
1
|
+
import { type AcceptedMessage, type ActionDeclaration, type ActionRequest, type ActionResult, type ConversationAgents, type ConversationHistories, type ConversationHistoryRequest } from '@agentshouse/mdruntime';
|
|
2
2
|
import type { HouseDoorAnswer, HouseTransport } from './transport.js';
|
|
3
|
+
export declare const HISTORY_PAGE = 100;
|
|
3
4
|
type Operated = {
|
|
4
5
|
readonly operation_id?: string;
|
|
5
6
|
};
|
|
@@ -7,10 +8,6 @@ type ConversationControl = Operated & {
|
|
|
7
8
|
readonly conversation: string;
|
|
8
9
|
};
|
|
9
10
|
export type AppInputs = {
|
|
10
|
-
readonly 'conversation.attach': FileDeclaration & {
|
|
11
|
-
readonly room: string;
|
|
12
|
-
readonly blob: Blob;
|
|
13
|
-
};
|
|
14
11
|
readonly 'conversation.answer': ConversationControl & {
|
|
15
12
|
readonly answer: {
|
|
16
13
|
readonly interaction_id: string;
|
|
@@ -29,14 +26,8 @@ export type AppInputs = {
|
|
|
29
26
|
readonly operation_id: string;
|
|
30
27
|
readonly text: string;
|
|
31
28
|
};
|
|
32
|
-
readonly 'trigger.list': {
|
|
33
|
-
readonly room_refs: readonly string[];
|
|
34
|
-
};
|
|
35
29
|
};
|
|
36
30
|
export type AppAnswers = {
|
|
37
|
-
readonly 'conversation.attach': {
|
|
38
|
-
readonly path: string;
|
|
39
|
-
};
|
|
40
31
|
readonly 'conversation.history': ConversationHistories;
|
|
41
32
|
};
|
|
42
33
|
export type AppAnswerAdditions = {
|
package/dist/actions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAE1B,KAAK,0BAA0B,EAChC,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEtE,eAAO,MAAM,YAAY,MAAM,CAAC;AAEhC,KAAK,QAAQ,GAAG;IAAE,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnD,KAAK,mBAAmB,GAAG,QAAQ,GAAG;IAAE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC;AAExE,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,qBAAqB,EAAE,mBAAmB,GAAG;QACpD,QAAQ,CAAC,MAAM,EAAE;YAAE,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;SAAE,CAAC;KAClF,CAAC;IACF,QAAQ,CAAC,qBAAqB,EAAE,QAAQ,GAAG;QACzC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;KAC5B,CAAC;IACF,QAAQ,CAAC,qBAAqB,EAAE,mBAAmB,CAAC;IACpD,QAAQ,CAAC,sBAAsB,EAAE,0BAA0B,CAAC;IAC5D,QAAQ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,MAAM,GAAG,YAAY,CAQjF;AAoDD,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAUtE"}
|
package/dist/actions.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import { changeBatchIdentity, } from '@agentshouse/mdruntime';
|
|
1
|
+
import { changeBatchIdentity, HISTORY_CONVERSATIONS, } from '@agentshouse/mdruntime';
|
|
2
2
|
import { doorRefusal } from './refusal.js';
|
|
3
|
-
|
|
4
|
-
const HISTORY_PAGE = 100;
|
|
5
|
-
const HISTORY_CONVERSATIONS = 64;
|
|
6
|
-
const TRIGGER_ROOMS = 100;
|
|
7
|
-
const OCTET_STREAM = 'application/octet-stream';
|
|
3
|
+
export const HISTORY_PAGE = 100;
|
|
8
4
|
function mapped(door, input = (given) => given) {
|
|
9
5
|
return {
|
|
10
6
|
door,
|
|
@@ -13,18 +9,16 @@ function mapped(door, input = (given) => given) {
|
|
|
13
9
|
},
|
|
14
10
|
};
|
|
15
11
|
}
|
|
16
|
-
function carried(door, carry, batched
|
|
12
|
+
function carried(door, carry, batched) {
|
|
17
13
|
return {
|
|
18
14
|
door,
|
|
19
15
|
...(batched === undefined ? {} : { batched }),
|
|
20
|
-
...(room === undefined ? {} : { room }),
|
|
21
16
|
carry: (transport, input, name) => carry(transport, `/door/${door}`, input, name),
|
|
22
17
|
};
|
|
23
18
|
}
|
|
24
19
|
const APP_ACTS = {
|
|
25
20
|
'access.read': mapped('rooms/access/read'),
|
|
26
21
|
'conversation.answer': mapped('conversations/interaction/answer', answerBody),
|
|
27
|
-
'conversation.attach': carried('conversations/attach', attachAction, undefined, 'room'),
|
|
28
22
|
'conversation.create': carried('conversations/create', createAction),
|
|
29
23
|
'conversation.delete': mapped('conversations/delete', controlBody),
|
|
30
24
|
'conversation.history': carried('conversations/history', historyAction, ['conversations']),
|
|
@@ -51,7 +45,6 @@ const APP_ACTS = {
|
|
|
51
45
|
'routineAllowance.list': mapped('routines/allowance'),
|
|
52
46
|
'routineRequest.list': mapped('routines/requests'),
|
|
53
47
|
'storage.read': mapped('storage/inventory'),
|
|
54
|
-
'trigger.list': carried('triggers/read', triggersAction, ['room_refs'], 'room_refs'),
|
|
55
48
|
'triggerOccurrence.list': mapped('triggers/fired'),
|
|
56
49
|
};
|
|
57
50
|
export const HOUSE_APP_ACTS = Object.fromEntries(Object.entries(APP_ACTS).map(([name, act]) => [name, act.door]));
|
|
@@ -61,14 +54,13 @@ export const HOUSE_SITE_ACTS = {
|
|
|
61
54
|
};
|
|
62
55
|
export const HOUSE_APP_BATCHES = Object.fromEntries(Object.entries(APP_ACTS).flatMap(([name, act]) => act.batched === undefined ? [] : [[name, act.batched]]));
|
|
63
56
|
const APP_NAMES = new Map(Object.entries(APP_ACTS).map(([name, act]) => [act.door, name]));
|
|
64
|
-
const APP_ROOMS = new Map(Object.entries(APP_ACTS).flatMap(([name, act]) => act.room === undefined ? [] : [[name, act.room]]));
|
|
65
57
|
export function houseConversationAgents(locator) {
|
|
66
58
|
return { locator, type: 'house-agent', identity: 'agent', name: 'name', retired: 'retired' };
|
|
67
59
|
}
|
|
68
60
|
export function declaredActions(routes) {
|
|
69
61
|
return routes.map((route) => {
|
|
70
62
|
const name = APP_NAMES.get(route) ?? route;
|
|
71
|
-
return { name, inputShape: {}, resultKind: 'house', room:
|
|
63
|
+
return { name, inputShape: {}, resultKind: 'house', room: 'room_ref' };
|
|
72
64
|
});
|
|
73
65
|
}
|
|
74
66
|
export function houseAction(transport, request) {
|
|
@@ -182,47 +174,6 @@ async function sendAction(transport, route, input, name) {
|
|
|
182
174
|
return outcome;
|
|
183
175
|
return { ...outcome, result: withTurn(outcome.result) };
|
|
184
176
|
}
|
|
185
|
-
function attachBody(input) {
|
|
186
|
-
const room = text(input, 'room');
|
|
187
|
-
const name = text(input, 'name');
|
|
188
|
-
const sha256 = text(input, 'contentHash');
|
|
189
|
-
const bytes = record(input).byteLength;
|
|
190
|
-
if (room === undefined || name === undefined || sha256 === undefined)
|
|
191
|
-
return null;
|
|
192
|
-
if (typeof bytes !== 'number')
|
|
193
|
-
return null;
|
|
194
|
-
const mediaType = text(input, 'mediaType');
|
|
195
|
-
return {
|
|
196
|
-
room_ref: room,
|
|
197
|
-
name,
|
|
198
|
-
bytes,
|
|
199
|
-
sha256,
|
|
200
|
-
media_type: mediaType !== undefined && mediaType.length > 0 ? mediaType : OCTET_STREAM,
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
async function attachAction(transport, route, input, name) {
|
|
204
|
-
const body = attachBody(input);
|
|
205
|
-
const blob = record(input).blob;
|
|
206
|
-
if (body === null || !(blob instanceof Blob))
|
|
207
|
-
return malformed();
|
|
208
|
-
const outcome = actionOutcome(await transport.door(route, body), name);
|
|
209
|
-
if (outcome.kind !== 'action')
|
|
210
|
-
return outcome;
|
|
211
|
-
const upload = houseUpload(record(outcome.result).upload);
|
|
212
|
-
if (upload === null)
|
|
213
|
-
return { kind: 'transport-uncertainty' };
|
|
214
|
-
const finished = await finishedUpload(transport, upload, blob);
|
|
215
|
-
if (finished === null)
|
|
216
|
-
return { kind: 'transport-uncertainty' };
|
|
217
|
-
const settled = actionOutcome(finished, name);
|
|
218
|
-
if (settled.kind !== 'action')
|
|
219
|
-
return settled;
|
|
220
|
-
const path = text(settled.result, 'path');
|
|
221
|
-
if (path === undefined)
|
|
222
|
-
return { kind: 'transport-uncertainty' };
|
|
223
|
-
const result = { path };
|
|
224
|
-
return { kind: 'action', result };
|
|
225
|
-
}
|
|
226
177
|
function historyCursor(value) {
|
|
227
178
|
const acceptedAt = text(value, 'accepted_at');
|
|
228
179
|
const messageId = text(value, 'message_id');
|
|
@@ -287,22 +238,6 @@ function historyAsks(input) {
|
|
|
287
238
|
}
|
|
288
239
|
return asks;
|
|
289
240
|
}
|
|
290
|
-
async function triggersAction(transport, route, input, name) {
|
|
291
|
-
const asked = record(input).room_refs;
|
|
292
|
-
if (!Array.isArray(asked) || asked.length === 0)
|
|
293
|
-
return malformed();
|
|
294
|
-
const rooms = [];
|
|
295
|
-
for (let at = 0; at < asked.length; at += TRIGGER_ROOMS) {
|
|
296
|
-
const outcome = actionOutcome(await transport.door(route, { room_refs: asked.slice(at, at + TRIGGER_ROOMS) }), name);
|
|
297
|
-
if (outcome.kind !== 'action')
|
|
298
|
-
return outcome;
|
|
299
|
-
const answered = record(outcome.result).rooms;
|
|
300
|
-
if (!Array.isArray(answered))
|
|
301
|
-
return { kind: 'transport-uncertainty' };
|
|
302
|
-
rooms.push(...answered);
|
|
303
|
-
}
|
|
304
|
-
return { kind: 'action', result: { rooms } };
|
|
305
|
-
}
|
|
306
241
|
async function historyAction(transport, route, input, name) {
|
|
307
242
|
const asks = historyAsks(input);
|
|
308
243
|
if (asks === null)
|
package/dist/adapter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,OAAO,
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,OAAO,EAGP,aAAa,EAkBd,MAAM,wBAAwB,CAAC;AA0ChC,OAAO,EAUL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AA0BxB,MAAM,MAAM,yBAAyB,GACjC;IACE,SAAS,EAAE,cAAc,CAAC;IAC1B,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;CACrC,GACD;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAgFrD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAyqBpF"}
|
package/dist/adapter.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
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
6
|
import { authorityRoot, bootstrapping, emptyScope, housePart, manifested, parseEnumeration, parseFileAddress, parseGrant, parseParted, partInventory, refreshFrom, viewOf, wholeView, } from './read.js';
|
|
@@ -10,13 +10,13 @@ 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';
|
|
@@ -92,7 +92,8 @@ export function createAgentsHouseAdapter(options) {
|
|
|
92
92
|
const page = await partPage(asked, continued, undefined, undefined);
|
|
93
93
|
return page.kind === 'bootstrap' ? { ...page, inventory } : page;
|
|
94
94
|
}
|
|
95
|
-
|
|
95
|
+
const { models, seen } = await manifestedModels(continued.room, asked.entry);
|
|
96
|
+
return manifested(continued.room, inventory, JSON.stringify({ ...continued, seen }), models);
|
|
96
97
|
}
|
|
97
98
|
async function partPage(asked, continued, received, arriving) {
|
|
98
99
|
const { entry } = asked;
|
|
@@ -117,7 +118,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
117
118
|
notifications.reach(entry.authority, scope);
|
|
118
119
|
const seen = [
|
|
119
120
|
...continued.seen,
|
|
120
|
-
...
|
|
121
|
+
...(scope.files.some((file) => file.path === entry.schema) ? [entry.schema] : []),
|
|
121
122
|
];
|
|
122
123
|
const models = await partModels(scope, entry, new Set(seen), !more);
|
|
123
124
|
return {
|
|
@@ -412,9 +413,22 @@ export function createAgentsHouseAdapter(options) {
|
|
|
412
413
|
function linked(answer, locator) {
|
|
413
414
|
const address = addressed(answer, locator);
|
|
414
415
|
return address.kind === 'address'
|
|
415
|
-
? { kind: 'link', url: address.url, name: address.name }
|
|
416
|
+
? { kind: 'link', url: address.url, name: address.name, mediaType: address.mediaType }
|
|
416
417
|
: address;
|
|
417
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
|
+
}
|
|
418
432
|
async function downloaded(ask, locator) {
|
|
419
433
|
let address = addressed(await ask(), locator);
|
|
420
434
|
if (address.kind !== 'address')
|
|
@@ -447,6 +461,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
447
461
|
}
|
|
448
462
|
return {
|
|
449
463
|
roomTypes: HOUSE_ROOM_TYPES,
|
|
464
|
+
nameableRoomTypes: HOUSE_NAMEABLE_ROOM_TYPES,
|
|
450
465
|
async authorize() {
|
|
451
466
|
return options.authorize();
|
|
452
467
|
},
|
|
@@ -556,17 +571,10 @@ export function createAgentsHouseAdapter(options) {
|
|
|
556
571
|
});
|
|
557
572
|
},
|
|
558
573
|
async binary(_authorization, request) {
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
return downloaded(ask, request.locator);
|
|
564
|
-
}
|
|
565
|
-
const referrer = houseReferrer(request.referrer, tracked);
|
|
566
|
-
if (referrer === null) {
|
|
567
|
-
return { kind: 'rejected', code: 'referrer_unknown', fields: {}, retryable: false };
|
|
568
|
-
}
|
|
569
|
-
return downloaded(() => transport.door(DOOR_FILES_GET, { file: request.fileRef, referrer: referrer.referrer }), 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);
|
|
570
578
|
},
|
|
571
579
|
async link(_authorization, request) {
|
|
572
580
|
const ask = pathAddress(request);
|
|
@@ -574,8 +582,34 @@ export function createAgentsHouseAdapter(options) {
|
|
|
574
582
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
575
583
|
return linked(await ask(), request.locator);
|
|
576
584
|
},
|
|
577
|
-
|
|
578
|
-
|
|
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;
|
|
579
613
|
},
|
|
580
614
|
reached(locator, version, target) {
|
|
581
615
|
return reachedVersion(version, target, authorityFor(locator)?.logEpoch);
|
|
@@ -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' | 'typedSelection'>[]): 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;AAE1D,MAAM,MAAM,WAAW,GAAG;IACxB,uBAAuB,EAAE,MAAM,CAAC;IAChC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,wBAAwB,EAAE,MAAM,CAAC;IACjC,2BAA2B,EAAE,MAAM,CAAC;IACpC,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC;AAExD,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","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AAiB,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,CAMhE;AAED,wBAAgB,YAAY,CAC1B,OAAO,EAAE,sBAAsB,CAAC,SAAS,CAAC,EAC1C,KAAK,EAAE,SAAS,IAAI,CAAC,gBAAgB,EAAE,WAAW,GAAG,gBAAgB,CAAC,EAAE,GACvE,SAAS,UAAU,EAAE,CAWvB;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
|
@@ -43,16 +43,10 @@ function parseBounds(value) {
|
|
|
43
43
|
}
|
|
44
44
|
return bounds;
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function parseTypedSelection(value) {
|
|
47
47
|
if (value === undefined)
|
|
48
48
|
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 };
|
|
49
|
+
return stringList(value) ?? undefined;
|
|
56
50
|
}
|
|
57
51
|
function parseMember(value) {
|
|
58
52
|
if (typeof value !== 'object' || value === null)
|
|
@@ -89,12 +83,12 @@ function parseAuthority(value) {
|
|
|
89
83
|
return null;
|
|
90
84
|
}
|
|
91
85
|
const at = readPosition(held);
|
|
92
|
-
const
|
|
86
|
+
const typedSelection = parseTypedSelection(held.typed_selection);
|
|
93
87
|
const protectedPaths = stringList(held.protected_paths);
|
|
94
88
|
const operations = parseOperations(held.operations);
|
|
95
89
|
const read = READ_LEVELS.find((level) => level === held.read);
|
|
96
90
|
if (at === null ||
|
|
97
|
-
|
|
91
|
+
typedSelection === undefined ||
|
|
98
92
|
protectedPaths === null ||
|
|
99
93
|
read === undefined ||
|
|
100
94
|
operations === null)
|
|
@@ -108,7 +102,7 @@ function parseAuthority(value) {
|
|
|
108
102
|
roomHandle: held.room_handle,
|
|
109
103
|
name: held.name,
|
|
110
104
|
schema: held.model_root,
|
|
111
|
-
|
|
105
|
+
typedSelection,
|
|
112
106
|
managedReplication: held.managed_replication,
|
|
113
107
|
protectedPaths,
|
|
114
108
|
read,
|
|
@@ -188,25 +182,18 @@ export function siteTracked(document) {
|
|
|
188
182
|
authority: authority.roomRef,
|
|
189
183
|
handle: authority.roomHandle,
|
|
190
184
|
schema: authority.schema,
|
|
191
|
-
|
|
192
|
-
schemas: [authority.schema],
|
|
185
|
+
typedSelection: null,
|
|
193
186
|
position: authority.position,
|
|
194
187
|
logEpoch: authority.logEpoch,
|
|
195
188
|
}));
|
|
196
189
|
}
|
|
197
|
-
function schemasOf(authority) {
|
|
198
|
-
return authority.houseModel === null
|
|
199
|
-
? [authority.schema]
|
|
200
|
-
: [authority.schema, authority.houseModel.root];
|
|
201
|
-
}
|
|
202
190
|
export function trackedFrom(document) {
|
|
203
191
|
return document.authorities.map((authority) => ({
|
|
204
192
|
locator: authority.roomRef,
|
|
205
193
|
authority: authority.roomRef,
|
|
206
194
|
handle: authority.roomHandle,
|
|
207
195
|
schema: authority.schema,
|
|
208
|
-
|
|
209
|
-
schemas: schemasOf(authority),
|
|
196
|
+
typedSelection: authority.typedSelection,
|
|
210
197
|
position: authority.position,
|
|
211
198
|
logEpoch: authority.logEpoch,
|
|
212
199
|
}));
|
|
@@ -233,7 +220,7 @@ export function declaredRetention(bounds) {
|
|
|
233
220
|
};
|
|
234
221
|
}
|
|
235
222
|
export function capabilities(actions, rooms) {
|
|
236
|
-
const house = rooms.find((room) => room.
|
|
223
|
+
const house = rooms.find((room) => room.typedSelection !== null);
|
|
237
224
|
return [
|
|
238
225
|
{
|
|
239
226
|
name: PROVIDER_ACTIONS,
|
|
@@ -268,10 +255,10 @@ export function discoveredRoom(authority) {
|
|
|
268
255
|
admission: authority.managedReplication,
|
|
269
256
|
offline: authority.read === 'online' ? 'locked' : 'open',
|
|
270
257
|
},
|
|
271
|
-
...(authority.
|
|
258
|
+
...(authority.typedSelection === null
|
|
272
259
|
? {}
|
|
273
|
-
: { typedSelection: { roots: [...authority.
|
|
274
|
-
providerOwnedPaths: [...authority.protectedPaths,
|
|
260
|
+
: { typedSelection: { roots: [...authority.typedSelection] } }),
|
|
261
|
+
providerOwnedPaths: [...authority.protectedPaths, authority.schema],
|
|
275
262
|
};
|
|
276
263
|
}
|
|
277
264
|
export function mapDiscovery(document, rooms, declared) {
|