@agentshouse/mdruntime-adapter 0.1.0-c3f41ed9b4657 → 0.1.0-c3fcf52802a21
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/AGENTS.md +16 -18
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +34 -27
- 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 +4 -3
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +70 -93
- package/dist/room-types.d.ts +1 -1
- package/dist/room-types.d.ts.map +1 -1
- package/dist/room-types.js +1 -1
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +32 -45
- package/dist/transport.d.ts +2 -3
- package/dist/transport.d.ts.map +1 -1
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +2 -13
- package/package.json +2 -2
- package/dist/referrer.d.ts +0 -12
- package/dist/referrer.d.ts.map +0 -1
- package/dist/referrer.js +0 -31
package/AGENTS.md
CHANGED
|
@@ -52,7 +52,7 @@ change, and no tab sees it then.
|
|
|
52
52
|
|
|
53
53
|
A binary file at a Path is a binary Path entry. Query lists it by `path`, and History each
|
|
54
54
|
of its revisions, with its `binaryFile` record and never its bytes: `{ state: 'accepted',
|
|
55
|
-
revision, path,
|
|
55
|
+
revision, path, byteLength, mediaType, sha256 }`, or, from a Save until the
|
|
56
56
|
Provider accepts it, `{ state: 'pending', localId, path, byteLength, mediaType, sha256 }`.
|
|
57
57
|
Write one with a Room Draft whose only part is `file: { blob }`, the `Blob`'s `type` its
|
|
58
58
|
media type: Save keeps the bytes in its Pending Change, offline too, and acceptance gives
|
|
@@ -62,10 +62,8 @@ as `unknown-revision` until it is accepted. `binaryFile.read(room, path, revisio
|
|
|
62
62
|
answers a pending record's saved bytes, or an accepted one's or a History revision's, a
|
|
63
63
|
removed file's last included: the first read asks the Provider and the browser keeps the
|
|
64
64
|
bytes, and every later read of that revision, offline too, answers them from the browser.
|
|
65
|
-
Text
|
|
66
|
-
`
|
|
67
|
-
document whose text names it, kept the same way. Both
|
|
68
|
-
answer `{ kind: 'binary', stream, byteLength, mediaType }`, the bytes a `ReadableStream`
|
|
65
|
+
Text names a file only by a link to its Path. A read answers
|
|
66
|
+
`{ kind: 'binary', stream, byteLength, mediaType }`, the bytes a `ReadableStream`
|
|
69
67
|
of parts of at most a mebibyte, or a refusal or failure; read the stream to its end, or
|
|
70
68
|
take it whole with `new Response(stream).blob()` where a screen needs one `Blob`.
|
|
71
69
|
|
|
@@ -233,19 +231,19 @@ Provider unavailability and a refusal marked retryable, until the reset it names
|
|
|
233
231
|
work Pending; the MD Runtime retries the same Change Batch identity and payload, never
|
|
234
232
|
infers an outcome from transport uncertainty, and never combines, reorders, or rebases.
|
|
235
233
|
|
|
236
|
-
On a Site, every Save stays in the visitor's browser: write grants and revisions do not
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
(`
|
|
248
|
-
|
|
234
|
+
On a Site, every Save stays in the visitor's browser: write grants and revisions do not refuse it,
|
|
235
|
+
and its Pending Change shows in every query and across reloads until the browser's storage is
|
|
236
|
+
cleared. It is never sent: `observe('queue', room)` shows it `local`, Sync Status never waits on
|
|
237
|
+
it, and once the Room no longer lets it apply it leaves the queue and returns no Room Draft.
|
|
238
|
+
|
|
239
|
+
`observe('service-mode')` answers the Provider's Service Mode, `open` or `write-halted`. While writes
|
|
240
|
+
are halted, Save succeeds, its Change Batch waits unsent and the queue is submitted in order once writes
|
|
241
|
+
reopen; an Action is never held, and one the halt refuses returns that refusal: show the Provider as
|
|
242
|
+
read-only instead of retrying. `observe('readiness')` tells whether code and bound Rooms are held
|
|
243
|
+
locally (`ready`), each Room's state, each refused Room's file and rule, the persistence answer, `space`
|
|
244
|
+
(`full` once the device's storage refused a write, Save and messages refusing as `durable-write` until
|
|
245
|
+
`retry()` or a later test write finds space, or once the origin refused a newer release), and the
|
|
246
|
+
`installation`'s Rooms, parts, bytes, `received`, `step` and `paused`.
|
|
249
247
|
|
|
250
248
|
## Content safety and launch promises
|
|
251
249
|
|
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,EACP,aAAa,
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,OAAO,EACP,aAAa,EAkBd,MAAM,wBAAwB,CAAC;AA0ChC,OAAO,EASL,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;AA8ErD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAioBpF"}
|
package/dist/adapter.js
CHANGED
|
@@ -3,8 +3,8 @@ import { DISCOVER_PREFIXES, capabilities, discoveredRoom, mapDiscovery, parseDis
|
|
|
3
3
|
import { 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, parseFileAddress, 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
9
|
import { finishedUpload, houseUpload } from './upload.js';
|
|
10
10
|
import { houseAction } from './actions.js';
|
|
@@ -12,7 +12,6 @@ import { classifyDoor, classifyRead, discoveryFailure, doorRefusal } from './ref
|
|
|
12
12
|
import { houseNotifications } from './stream.js';
|
|
13
13
|
import { DOOR_BATCH, DOOR_BATCH_UPLOAD, DOOR_BOOTSTRAP, DOOR_DISCOVER, DOOR_ENUMERATE, 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 { houseReferrer, houseReferrerScope } from './referrer.js';
|
|
16
15
|
import { 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' };
|
|
@@ -61,31 +60,48 @@ export function createAgentsHouseAdapter(options) {
|
|
|
61
60
|
throw new Error('no Discovery declared the bounds');
|
|
62
61
|
return bounds;
|
|
63
62
|
}
|
|
64
|
-
async function fetchedPart(entry, continued, listed) {
|
|
63
|
+
async function fetchedPart(entry, continued, listed, received, arriving) {
|
|
64
|
+
if (received !== undefined) {
|
|
65
|
+
const kept = new Uint8Array(received);
|
|
66
|
+
const held = await housePart(continued.room, kept, listed, 'credential');
|
|
67
|
+
if (held !== null)
|
|
68
|
+
return 'kind' in held ? held : { scope: held, frame: kept };
|
|
69
|
+
}
|
|
65
70
|
for (let attempt = 0; attempt < PART_ATTEMPTS; attempt += 1) {
|
|
66
71
|
const answered = await transport.door(DOOR_BOOTSTRAP, {
|
|
67
72
|
prefixes: [authorityRoot(entry.handle)],
|
|
68
73
|
part: listed.part,
|
|
69
74
|
...(continued.held === undefined ? {} : { held: [continued.held] }),
|
|
70
|
-
});
|
|
75
|
+
}, partArrival(listed, arriving));
|
|
71
76
|
const failure = classifyRead(answered.status, answered.body, entry.locator);
|
|
72
77
|
if (failure !== null)
|
|
73
78
|
return failure;
|
|
74
|
-
const
|
|
79
|
+
const frame = partFrame(answered.body);
|
|
80
|
+
if (frame === null)
|
|
81
|
+
continue;
|
|
82
|
+
const scope = await housePart(continued.room, frame, listed, 'credential');
|
|
75
83
|
if (scope !== null)
|
|
76
|
-
return scope;
|
|
84
|
+
return 'kind' in scope ? scope : { scope, frame };
|
|
77
85
|
}
|
|
78
86
|
return unverifiedPart(entry.locator);
|
|
79
87
|
}
|
|
80
|
-
async function
|
|
88
|
+
async function manifestPage(asked, continued) {
|
|
89
|
+
const inventory = partInventory(continued.room);
|
|
90
|
+
if (inventory.parts === 0) {
|
|
91
|
+
const page = await partPage(asked, continued, undefined, undefined);
|
|
92
|
+
return page.kind === 'bootstrap' ? { ...page, inventory } : page;
|
|
93
|
+
}
|
|
94
|
+
return manifested(continued.room, inventory, JSON.stringify(continued));
|
|
95
|
+
}
|
|
96
|
+
async function partPage(asked, continued, received, arriving) {
|
|
81
97
|
const { entry } = asked;
|
|
82
98
|
const listed = continued.room.parts[continued.next];
|
|
83
99
|
const sent = listed === undefined
|
|
84
|
-
? emptyScope(continued.room)
|
|
85
|
-
: await fetchedPart(entry, continued, listed);
|
|
100
|
+
? { scope: emptyScope(continued.room), frame: null }
|
|
101
|
+
: await fetchedPart(entry, continued, listed, received, arriving);
|
|
86
102
|
if ('kind' in sent)
|
|
87
103
|
return sent;
|
|
88
|
-
const scope = await reused(sent, asked.held);
|
|
104
|
+
const scope = await reused(sent.scope, asked.held);
|
|
89
105
|
if (scope === null) {
|
|
90
106
|
return asked.held === undefined
|
|
91
107
|
? UNCERTAIN_READ
|
|
@@ -107,6 +123,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
107
123
|
...(await stepped(bootstrapping(scope))),
|
|
108
124
|
...(models === undefined ? {} : { models }),
|
|
109
125
|
...(more ? { pageToken: JSON.stringify({ ...continued, next, seen }) } : {}),
|
|
126
|
+
...(sent.frame === null ? {} : { received: sent.frame }),
|
|
110
127
|
};
|
|
111
128
|
}
|
|
112
129
|
async function enumeratedPage(ask, page) {
|
|
@@ -249,7 +266,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
249
266
|
continue;
|
|
250
267
|
}
|
|
251
268
|
const kept = held.find((files) => files.room === asked.entry.authority);
|
|
252
|
-
answer(asked.ask, await
|
|
269
|
+
answer(asked.ask, await manifestPage(asked.asked, {
|
|
253
270
|
room,
|
|
254
271
|
next: 0,
|
|
255
272
|
seen: [],
|
|
@@ -478,7 +495,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
478
495
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
479
496
|
const asked = { entry, held: request.held };
|
|
480
497
|
if (request.pageToken !== undefined) {
|
|
481
|
-
return partPage(asked, JSON.parse(request.pageToken));
|
|
498
|
+
return partPage(asked, JSON.parse(request.pageToken), request.received, request.arriving);
|
|
482
499
|
}
|
|
483
500
|
return bootstrapTogether(asked);
|
|
484
501
|
},
|
|
@@ -538,17 +555,10 @@ export function createAgentsHouseAdapter(options) {
|
|
|
538
555
|
});
|
|
539
556
|
},
|
|
540
557
|
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);
|
|
558
|
+
const ask = pathAddress(request);
|
|
559
|
+
if (ask === null)
|
|
560
|
+
return { kind: 'room-not-readable', locator: request.locator };
|
|
561
|
+
return downloaded(ask, request.locator);
|
|
552
562
|
},
|
|
553
563
|
async link(_authorization, request) {
|
|
554
564
|
const ask = pathAddress(request);
|
|
@@ -556,9 +566,6 @@ export function createAgentsHouseAdapter(options) {
|
|
|
556
566
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
557
567
|
return linked(await ask(), request.locator);
|
|
558
568
|
},
|
|
559
|
-
referrerScope(referrer) {
|
|
560
|
-
return houseReferrerScope(referrer);
|
|
561
|
-
},
|
|
562
569
|
reached(locator, version, target) {
|
|
563
570
|
return reachedVersion(version, target, authorityFor(locator)?.logEpoch);
|
|
564
571
|
},
|
package/dist/part.d.ts
CHANGED
|
@@ -7,7 +7,9 @@ export type HousePart = {
|
|
|
7
7
|
sha256: string;
|
|
8
8
|
};
|
|
9
9
|
export declare function parsePart(value: unknown): HousePart | null;
|
|
10
|
-
export declare function
|
|
11
|
-
export declare function
|
|
10
|
+
export declare function partArrival(listed: HousePart, arriving: ((bytes: number) => void) | undefined): ((answered: number) => void) | undefined;
|
|
11
|
+
export declare function partFrame(body: unknown): Uint8Array<ArrayBuffer> | null;
|
|
12
|
+
export declare function checkedPayload(frame: Uint8Array<ArrayBuffer>, listed: HousePart): Promise<Uint8Array<ArrayBuffer> | null>;
|
|
13
|
+
export declare function gunzipped(payload: Uint8Array<ArrayBuffer>): ReadableStream<string>;
|
|
12
14
|
export declare function unverifiedPart(locator: string): ScopedRefusal;
|
|
13
15
|
//# sourceMappingURL=part.d.ts.map
|
package/dist/part.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"part.d.ts","sourceRoot":"","sources":["../src/part.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAU5D,eAAO,MAAM,aAAa,IAAI,CAAC;AAE/B,eAAO,M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AgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,CAS7D"}
|
package/dist/part.js
CHANGED
|
@@ -35,14 +35,19 @@ function hex(bytes) {
|
|
|
35
35
|
text += byte.toString(16).padStart(2, '0');
|
|
36
36
|
return text;
|
|
37
37
|
}
|
|
38
|
-
export
|
|
38
|
+
export function partArrival(listed, arriving) {
|
|
39
|
+
if (arriving === undefined)
|
|
40
|
+
return undefined;
|
|
41
|
+
return (answered) => arriving(Math.min(listed.bytes, Math.floor((answered * 3) / 4)));
|
|
42
|
+
}
|
|
43
|
+
export function partFrame(body) {
|
|
39
44
|
if (typeof body !== 'object' || body === null)
|
|
40
45
|
return null;
|
|
41
46
|
const { part } = body;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (frame
|
|
47
|
+
return typeof part === 'string' ? decoded(part) : null;
|
|
48
|
+
}
|
|
49
|
+
export async function checkedPayload(frame, listed) {
|
|
50
|
+
if (frame.length !== listed.bytes)
|
|
46
51
|
return null;
|
|
47
52
|
if (frame.length < PART_HEAD_BYTES + PART_DIGEST_BYTES)
|
|
48
53
|
return null;
|
|
@@ -59,14 +64,11 @@ export async function checkedPayload(body, listed) {
|
|
|
59
64
|
}
|
|
60
65
|
return payload;
|
|
61
66
|
}
|
|
62
|
-
export
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
catch {
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
67
|
+
export function gunzipped(payload) {
|
|
68
|
+
return new Blob([payload])
|
|
69
|
+
.stream()
|
|
70
|
+
.pipeThrough(new DecompressionStream('gzip'))
|
|
71
|
+
.pipeThrough(new TextDecoderStream());
|
|
70
72
|
}
|
|
71
73
|
export function unverifiedPart(locator) {
|
|
72
74
|
return {
|
package/dist/read.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AdapterFailure, type BinaryFile, type BootstrapPage, type RefreshResult, type TransportUncertainty } from '@agentshouse/mdruntime';
|
|
1
|
+
import { type AdapterFailure, type BinaryFile, type BootstrapInventory, type BootstrapPage, type RefreshResult, type TransportUncertainty } from '@agentshouse/mdruntime';
|
|
2
2
|
import type { TrackedAuthority } from './discovery.js';
|
|
3
3
|
import { type HousePart } from './part.js';
|
|
4
4
|
import type { HouseMode } from './transport.js';
|
|
@@ -112,11 +112,12 @@ export declare function headChange(held: {
|
|
|
112
112
|
export declare function binaryFileOf(held: Readonly<Record<string, unknown>>): BinaryFile | undefined | null;
|
|
113
113
|
export declare function parseParted(body: unknown): HouseParted | null;
|
|
114
114
|
export declare function parseSiteParted(body: unknown): HouseRoomParts | null;
|
|
115
|
+
export declare function partInventory(room: HouseRoomParts): BootstrapInventory;
|
|
116
|
+
export declare function manifested(room: HouseRoomParts, inventory: BootstrapInventory, pageToken: string): BootstrapPage;
|
|
115
117
|
export declare function emptyScope(room: HouseRoomParts): HouseScope;
|
|
116
|
-
export declare function housePart(room: HouseRoomParts,
|
|
118
|
+
export declare function housePart(room: HouseRoomParts, frame: Uint8Array<ArrayBuffer>, listed: HousePart, mode: HouseMode): Promise<HouseScope | TransportUncertainty | null>;
|
|
117
119
|
export declare function parseEnumeration(body: unknown, mode: HouseMode): HouseEnumeration | null;
|
|
118
120
|
export declare function wholeView(first: HouseView, more: (page: HousePage) => Promise<HouseView | PageFailure>): Promise<HouseView | PageFailure>;
|
|
119
|
-
export declare function advancedScope(scope: HouseScope, view: HouseView): Generator<number, HouseScope, void>;
|
|
120
121
|
export declare function bootstrapping(scope: HouseScope): Generator<number, BootstrapPage, void>;
|
|
121
122
|
export type HouseSchema = {
|
|
122
123
|
schema: string | null;
|
package/dist/read.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../src/read.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../src/read.ts"],"names":[],"mappings":"AAA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AAE,gBAAgB,EAC7B,OAAO,EAAE,gBAAgB,GACxB,SAAS,GAAG,SAAS,CAEvB;AA0BD,wBAAsB,WAAW,CAC/B,IAAI,EAAE,SAAS,EACf,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,aAAa,CAAC,CAExB"}
|
package/dist/read.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { patching, ROW_WEIGHT, stepped, } from '@agentshouse/mdruntime';
|
|
1
|
+
import { paced, patching, ROW_WEIGHT, stepped, } from '@agentshouse/mdruntime';
|
|
2
2
|
import { checkedPayload, gunzipped, parsePart } from './part.js';
|
|
3
3
|
import { DECIMAL, readPosition, roomVersion } from './version.js';
|
|
4
4
|
const REVISION_FILE = /^fr_([0-9a-z]+)\.[0-9a-z]+\.[0-9a-z]$/u;
|
|
@@ -126,15 +126,12 @@ function headed(head) {
|
|
|
126
126
|
return head === undefined ? {} : { head };
|
|
127
127
|
}
|
|
128
128
|
export function binaryFileOf(held) {
|
|
129
|
-
if (held.
|
|
129
|
+
if (held.media_type === undefined)
|
|
130
130
|
return undefined;
|
|
131
|
-
const {
|
|
132
|
-
if (typeof
|
|
133
|
-
typeof bytes !== 'number' ||
|
|
134
|
-
typeof mediaType !== 'string' ||
|
|
135
|
-
typeof sha256 !== 'string')
|
|
131
|
+
const { bytes, media_type: mediaType, sha256 } = held;
|
|
132
|
+
if (typeof bytes !== 'number' || typeof mediaType !== 'string' || typeof sha256 !== 'string')
|
|
136
133
|
return null;
|
|
137
|
-
return {
|
|
134
|
+
return { byteLength: bytes, mediaType, sha256 };
|
|
138
135
|
}
|
|
139
136
|
function binaried(binary) {
|
|
140
137
|
return binary === undefined ? {} : { binary };
|
|
@@ -218,6 +215,24 @@ export function parseParted(body) {
|
|
|
218
215
|
export function parseSiteParted(body) {
|
|
219
216
|
return parseRoomParts(body);
|
|
220
217
|
}
|
|
218
|
+
export function partInventory(room) {
|
|
219
|
+
return {
|
|
220
|
+
parts: room.parts.length,
|
|
221
|
+
bytes: room.parts.reduce((sum, part) => sum + part.bytes, 0),
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
export function manifested(room, inventory, pageToken) {
|
|
225
|
+
return {
|
|
226
|
+
kind: 'bootstrap',
|
|
227
|
+
roomVersion: roomVersion(room),
|
|
228
|
+
documents: {},
|
|
229
|
+
revisions: {},
|
|
230
|
+
changes: {},
|
|
231
|
+
binaryFiles: {},
|
|
232
|
+
inventory,
|
|
233
|
+
pageToken,
|
|
234
|
+
};
|
|
235
|
+
}
|
|
221
236
|
export function emptyScope(room) {
|
|
222
237
|
return {
|
|
223
238
|
anchor: room.anchor,
|
|
@@ -227,52 +242,63 @@ export function emptyScope(room) {
|
|
|
227
242
|
contents: [],
|
|
228
243
|
};
|
|
229
244
|
}
|
|
230
|
-
function
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
245
|
+
function partLine(line, mode, read) {
|
|
246
|
+
let entry;
|
|
247
|
+
try {
|
|
248
|
+
entry = JSON.parse(line);
|
|
249
|
+
}
|
|
250
|
+
catch {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
if (folderLine(entry)) {
|
|
254
|
+
read.folders.push(entry.folder);
|
|
255
|
+
return true;
|
|
256
|
+
}
|
|
257
|
+
const file = parseFile(entry, mode);
|
|
258
|
+
if (file === null)
|
|
259
|
+
return false;
|
|
260
|
+
read.files.push(file);
|
|
261
|
+
const { content } = entry;
|
|
262
|
+
if (typeof content === 'string')
|
|
263
|
+
read.contents.push({ path: file.path, content });
|
|
264
|
+
else if (content !== undefined)
|
|
265
|
+
return false;
|
|
266
|
+
return true;
|
|
267
|
+
}
|
|
268
|
+
async function partRead(chunks, mode) {
|
|
269
|
+
const read = { files: [], contents: [], folders: [] };
|
|
270
|
+
const pace = paced();
|
|
271
|
+
const unfinished = [];
|
|
272
|
+
for (let chunk = await chunks.read(); chunk.done !== true; chunk = await chunks.read()) {
|
|
273
|
+
const text = chunk.value;
|
|
274
|
+
let start = 0;
|
|
275
|
+
for (let end = text.indexOf('\n'); end !== -1; end = text.indexOf('\n', start)) {
|
|
276
|
+
const piece = text.slice(start, end);
|
|
277
|
+
const line = unfinished.length === 0 ? piece : unfinished.splice(0).join('') + piece;
|
|
278
|
+
if (!partLine(line, mode, read)) {
|
|
279
|
+
await chunks.cancel();
|
|
280
|
+
return null;
|
|
281
|
+
}
|
|
282
|
+
start = end + 1;
|
|
283
|
+
const due = pace(line.length + ROW_WEIGHT);
|
|
284
|
+
if (due instanceof Promise)
|
|
285
|
+
await due;
|
|
251
286
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
return null;
|
|
255
|
-
files.push(file);
|
|
256
|
-
const { content } = entry;
|
|
257
|
-
if (typeof content === 'string')
|
|
258
|
-
contents.push({ path: file.path, content });
|
|
259
|
-
else if (content !== undefined)
|
|
260
|
-
return null;
|
|
261
|
-
yield ROW_WEIGHT;
|
|
287
|
+
if (start < text.length)
|
|
288
|
+
unfinished.push(text.slice(start));
|
|
262
289
|
}
|
|
263
|
-
return
|
|
290
|
+
return unfinished.length === 0 ? read : null;
|
|
264
291
|
}
|
|
265
292
|
function folderLine(entry) {
|
|
266
293
|
if (typeof entry !== 'object' || entry === null || !('folder' in entry))
|
|
267
294
|
return false;
|
|
268
295
|
return typeof entry.folder === 'string' && Object.keys(entry).length === 1;
|
|
269
296
|
}
|
|
270
|
-
export async function housePart(room,
|
|
271
|
-
const payload = await checkedPayload(
|
|
297
|
+
export async function housePart(room, frame, listed, mode) {
|
|
298
|
+
const payload = await checkedPayload(frame, listed);
|
|
272
299
|
if (payload === null)
|
|
273
300
|
return null;
|
|
274
|
-
const
|
|
275
|
-
const read = text === null ? null : await stepped(partLines(text, mode));
|
|
301
|
+
const read = await partRead(gunzipped(payload).getReader(), mode).catch(() => null);
|
|
276
302
|
return read === null ? { kind: 'transport-uncertainty' } : { ...emptyScope(room), ...read };
|
|
277
303
|
}
|
|
278
304
|
function folderChange(value) {
|
|
@@ -415,55 +441,6 @@ export async function wholeView(first, more) {
|
|
|
415
441
|
...(folders.size === 0 ? {} : { folders: [...folders.values()] }),
|
|
416
442
|
};
|
|
417
443
|
}
|
|
418
|
-
export function* advancedScope(scope, view) {
|
|
419
|
-
const files = new Map();
|
|
420
|
-
for (const file of scope.files) {
|
|
421
|
-
files.set(file.path, file);
|
|
422
|
-
yield ROW_WEIGHT;
|
|
423
|
-
}
|
|
424
|
-
const contents = new Map();
|
|
425
|
-
for (const entry of scope.contents) {
|
|
426
|
-
contents.set(entry.path, entry.content);
|
|
427
|
-
yield ROW_WEIGHT;
|
|
428
|
-
}
|
|
429
|
-
for (const change of view.changes) {
|
|
430
|
-
files.delete(change.path);
|
|
431
|
-
contents.delete(change.path);
|
|
432
|
-
yield ROW_WEIGHT;
|
|
433
|
-
if ('removed' in change)
|
|
434
|
-
continue;
|
|
435
|
-
files.set(change.path, {
|
|
436
|
-
path: change.path,
|
|
437
|
-
revision: change.revision,
|
|
438
|
-
version: change.version,
|
|
439
|
-
...headed(change.head),
|
|
440
|
-
...('binary' in change ? { binary: change.binary } : {}),
|
|
441
|
-
});
|
|
442
|
-
if ('content' in change)
|
|
443
|
-
contents.set(change.path, change.content);
|
|
444
|
-
}
|
|
445
|
-
const kept = [];
|
|
446
|
-
for (const [path, content] of contents) {
|
|
447
|
-
kept.push({ path, content });
|
|
448
|
-
yield ROW_WEIGHT;
|
|
449
|
-
}
|
|
450
|
-
const folders = new Set(scope.folders);
|
|
451
|
-
for (const folder of view.folders ?? []) {
|
|
452
|
-
if (folder.removed)
|
|
453
|
-
folders.delete(folder.path);
|
|
454
|
-
else
|
|
455
|
-
folders.add(folder.path);
|
|
456
|
-
yield ROW_WEIGHT;
|
|
457
|
-
}
|
|
458
|
-
return {
|
|
459
|
-
...scope,
|
|
460
|
-
position: view.position,
|
|
461
|
-
logEpoch: view.logEpoch,
|
|
462
|
-
files: [...files.values()],
|
|
463
|
-
contents: kept,
|
|
464
|
-
...(folders.size === 0 ? {} : { folders: [...folders] }),
|
|
465
|
-
};
|
|
466
|
-
}
|
|
467
444
|
export function* bootstrapping(scope) {
|
|
468
445
|
const contents = new Map();
|
|
469
446
|
for (const entry of scope.contents) {
|
package/dist/room-types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const INBOX_CHANNEL_KINDS: readonly ['telegram-bot'];
|
|
1
|
+
export declare const INBOX_CHANNEL_KINDS: readonly ['telegram-bot', 'whatsapp', 'messenger', 'instagram'];
|
|
2
2
|
export type InboxChannelKind = (typeof INBOX_CHANNEL_KINDS)[number];
|
|
3
3
|
export declare const INBOX_CHAT_TYPE = "inbox-chat";
|
|
4
4
|
export declare const INBOX_MESSAGE_TYPE = "inbox-message";
|
package/dist/room-types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"room-types.d.ts","sourceRoot":"","sources":["../src/room-types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,YAAI,cAAc,CAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"room-types.d.ts","sourceRoot":"","sources":["../src/room-types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,YAAI,cAAc,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,CAAU,CAAC;AAEnG,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEpE,eAAO,MAAM,eAAe,eAAe,CAAC;AAE5C,eAAO,MAAM,kBAAkB,kBAAkB,CAAC;AAalD,eAAO,MAAM,gBAAgB,QAsDjB,CAAC"}
|
package/dist/room-types.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const INBOX_CHANNEL_KINDS = ['telegram-bot'];
|
|
1
|
+
export const INBOX_CHANNEL_KINDS = ['telegram-bot', 'whatsapp', 'messenger', 'instagram'];
|
|
2
2
|
export const INBOX_CHAT_TYPE = 'inbox-chat';
|
|
3
3
|
export const INBOX_MESSAGE_TYPE = 'inbox-message';
|
|
4
4
|
const IDENTITY = "{ type: string, pattern: '^\\S+$' }";
|
package/dist/site.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,
|
|
1
|
+
{"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAWR,MAAM,wBAAwB,CAAC;AA+BhC,OAAO,EAML,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AAoCxB,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,kBAAkB,EAAE,QAAQ,UAAQ,GAAG,OAAO,CAoP1F"}
|
package/dist/site.js
CHANGED
|
@@ -2,13 +2,12 @@ import { stepped } from '@agentshouse/mdruntime';
|
|
|
2
2
|
import { actionOutcome, SITE_SUBMIT } from './actions.js';
|
|
3
3
|
import { mapDiscovery, parseSiteDiscovery, siteCapabilities, siteTracked, } from './discovery.js';
|
|
4
4
|
import { partModels, streamedModels, viewModels } from './model.js';
|
|
5
|
-
import {
|
|
6
|
-
import { PART_ATTEMPTS, unverifiedPart } from './part.js';
|
|
5
|
+
import { bootstrapping, emptyScope, housePart, manifested, parseEnumeration, parseSiteParted, partInventory, refreshFrom, viewOf, wholeView, } from './read.js';
|
|
6
|
+
import { PART_ATTEMPTS, partArrival, partFrame, unverifiedPart } from './part.js';
|
|
7
7
|
import { classifyDoor, classifyRead, discoveryFailure } from './refusal.js';
|
|
8
8
|
import { HOUSE_ROOM_TYPES } from './room-types.js';
|
|
9
9
|
import { houseNotifications } from './stream.js';
|
|
10
10
|
import { SITE_DOOR_BOOTSTRAP, SITE_DOOR_DISCOVER, SITE_DOOR_ENUMERATE, SITE_DOOR_SUBMIT, SITE_FILES, } from './transport.js';
|
|
11
|
-
import { houseReferrer } from './referrer.js';
|
|
12
11
|
import { followsVersion, logPosition, presented, reachedVersion, roomVersion, } from './version.js';
|
|
13
12
|
const UNCERTAIN = { kind: 'transport-uncertainty' };
|
|
14
13
|
function unfound() {
|
|
@@ -25,26 +24,15 @@ function siteRoom(tracked) {
|
|
|
25
24
|
providerOwnedPaths: [],
|
|
26
25
|
};
|
|
27
26
|
}
|
|
28
|
-
function settled(refused) {
|
|
29
|
-
return refused.kind === 'beyond-horizon' ? UNCERTAIN : refused;
|
|
30
|
-
}
|
|
31
27
|
export function createSiteAdapter(transport, snapshot = false) {
|
|
32
28
|
const notifications = houseNotifications(transport, 'site');
|
|
33
29
|
const tracked = new Map();
|
|
34
30
|
const expired = new Map();
|
|
35
|
-
function published(referrer) {
|
|
36
|
-
const named = houseReferrer(referrer, tracked);
|
|
37
|
-
return named === null || !tracked.has(named.locator) ? null : named;
|
|
38
|
-
}
|
|
39
31
|
function fileRoute(request) {
|
|
40
|
-
const
|
|
41
|
-
if (
|
|
42
|
-
return { kind: '
|
|
43
|
-
}
|
|
44
|
-
if (request.fileRef === undefined)
|
|
45
|
-
return unfound();
|
|
46
|
-
const { room_ref, path } = named.referrer;
|
|
47
|
-
return `${SITE_FILES}${room_ref}/${encodeURIComponent(request.fileRef)}/${encodeURIComponent(path)}`;
|
|
32
|
+
const entry = tracked.get(request.locator);
|
|
33
|
+
if (entry === undefined)
|
|
34
|
+
return { kind: 'room-not-readable', locator: request.locator };
|
|
35
|
+
return `${SITE_FILES}${entry.authority}/${encodeURIComponent(request.revision)}/${encodeURIComponent(request.path)}`;
|
|
48
36
|
}
|
|
49
37
|
async function enumerated(entry, from, page) {
|
|
50
38
|
const answer = await transport.door(SITE_DOOR_ENUMERATE, {
|
|
@@ -78,34 +66,29 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
78
66
|
const room = parseSiteParted(answer.body);
|
|
79
67
|
return room === null || room.anchor !== entry.authority ? UNCERTAIN : room;
|
|
80
68
|
}
|
|
81
|
-
async function fetchedPart(entry, room, listed) {
|
|
69
|
+
async function fetchedPart(entry, room, listed, received, arriving) {
|
|
70
|
+
if (received !== undefined) {
|
|
71
|
+
const kept = new Uint8Array(received);
|
|
72
|
+
const held = await housePart(room, kept, listed, 'site');
|
|
73
|
+
if (held !== null)
|
|
74
|
+
return 'kind' in held ? held : { scope: held, frame: kept };
|
|
75
|
+
}
|
|
82
76
|
for (let attempt = 0; attempt < PART_ATTEMPTS; attempt += 1) {
|
|
83
|
-
const answer = await transport.read(`${SITE_DOOR_BOOTSTRAP}${entry.authority}?part=${encodeURIComponent(listed.part)}
|
|
77
|
+
const answer = await transport.read(`${SITE_DOOR_BOOTSTRAP}${entry.authority}?part=${encodeURIComponent(listed.part)}`, partArrival(listed, arriving));
|
|
84
78
|
const failure = classifyRead(answer.status, answer.body, entry.locator);
|
|
85
79
|
if (failure?.kind === 'beyond-horizon')
|
|
86
80
|
expired.set(entry.locator, room.position);
|
|
87
81
|
if (failure !== null)
|
|
88
82
|
return failure;
|
|
89
|
-
const
|
|
83
|
+
const frame = partFrame(answer.body);
|
|
84
|
+
if (frame === null)
|
|
85
|
+
continue;
|
|
86
|
+
const scope = await housePart(room, frame, listed, 'site');
|
|
90
87
|
if (scope !== null)
|
|
91
|
-
return scope;
|
|
88
|
+
return 'kind' in scope ? scope : { scope, frame };
|
|
92
89
|
}
|
|
93
90
|
return unverifiedPart(entry.locator);
|
|
94
91
|
}
|
|
95
|
-
async function caughtUp(entry, continued) {
|
|
96
|
-
const listed = continued.room.parts[continued.next];
|
|
97
|
-
const scope = listed === undefined
|
|
98
|
-
? emptyScope(continued.room)
|
|
99
|
-
: await fetchedPart(entry, continued.room, listed);
|
|
100
|
-
if ('kind' in scope)
|
|
101
|
-
return scope;
|
|
102
|
-
if (continued.room.parts.length > 1 || roomVersion(scope) === roomVersion(entry))
|
|
103
|
-
return scope;
|
|
104
|
-
const view = await enumeration(entry, scope);
|
|
105
|
-
if ('kind' in view)
|
|
106
|
-
return settled(view);
|
|
107
|
-
return stepped(advancedScope(scope, view));
|
|
108
|
-
}
|
|
109
92
|
async function refreshed(entry, fromRoomVersion) {
|
|
110
93
|
const from = logPosition(fromRoomVersion);
|
|
111
94
|
if (from === null)
|
|
@@ -152,17 +135,25 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
152
135
|
if (entry === undefined)
|
|
153
136
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
154
137
|
let continued;
|
|
138
|
+
let inventory;
|
|
155
139
|
if (request.pageToken === undefined) {
|
|
156
140
|
const room = await partedRoom(entry);
|
|
157
141
|
if ('kind' in room)
|
|
158
142
|
return room;
|
|
159
143
|
continued = { room, next: 0, seen: [] };
|
|
144
|
+
inventory = partInventory(room);
|
|
145
|
+
if (inventory.parts > 0)
|
|
146
|
+
return manifested(room, inventory, JSON.stringify(continued));
|
|
160
147
|
}
|
|
161
148
|
else
|
|
162
149
|
continued = JSON.parse(request.pageToken);
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
150
|
+
const listed = continued.room.parts[continued.next];
|
|
151
|
+
const sent = listed === undefined
|
|
152
|
+
? { scope: emptyScope(continued.room), frame: null }
|
|
153
|
+
: await fetchedPart(entry, continued.room, listed, request.received, request.arriving);
|
|
154
|
+
if ('kind' in sent)
|
|
155
|
+
return sent;
|
|
156
|
+
const { scope } = sent;
|
|
166
157
|
notifications.reach(entry.authority, scope);
|
|
167
158
|
const next = continued.next + 1;
|
|
168
159
|
const more = next < continued.room.parts.length;
|
|
@@ -176,6 +167,8 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
176
167
|
...page,
|
|
177
168
|
...(models === undefined ? {} : { models }),
|
|
178
169
|
...(more ? { pageToken: JSON.stringify({ ...continued, next, seen }) } : {}),
|
|
170
|
+
...(inventory === undefined ? {} : { inventory }),
|
|
171
|
+
...(sent.frame === null ? {} : { received: sent.frame }),
|
|
179
172
|
};
|
|
180
173
|
},
|
|
181
174
|
async refresh(_authorization, request) {
|
|
@@ -218,12 +211,6 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
218
211
|
name: request.path.slice(request.path.lastIndexOf('/') + 1),
|
|
219
212
|
};
|
|
220
213
|
},
|
|
221
|
-
referrerScope(referrer) {
|
|
222
|
-
const named = published(referrer);
|
|
223
|
-
if (named === null)
|
|
224
|
-
return null;
|
|
225
|
-
return { locator: named.locator, path: named.referrer.path };
|
|
226
|
-
},
|
|
227
214
|
reached(locator, version, target) {
|
|
228
215
|
return reachedVersion(version, target, tracked.get(locator)?.logEpoch);
|
|
229
216
|
},
|
package/dist/transport.d.ts
CHANGED
|
@@ -35,7 +35,6 @@ export type HouseStreamEntry = {
|
|
|
35
35
|
revision?: string;
|
|
36
36
|
sha256?: string;
|
|
37
37
|
text?: string;
|
|
38
|
-
file?: string;
|
|
39
38
|
bytes?: number;
|
|
40
39
|
media_type?: string;
|
|
41
40
|
author?: {
|
|
@@ -165,7 +164,7 @@ export type HouseStream = {
|
|
|
165
164
|
closed(notify: (closing: HouseClosing) => void): () => void;
|
|
166
165
|
};
|
|
167
166
|
export type HouseDoor = {
|
|
168
|
-
door(route: string, body: unknown): Promise<HouseDoorAnswer>;
|
|
167
|
+
door(route: string, body: unknown, arriving?: (bytes: number) => void): Promise<HouseDoorAnswer>;
|
|
169
168
|
stream: HouseStream;
|
|
170
169
|
};
|
|
171
170
|
export type HouseTransport = HouseDoor & {
|
|
@@ -175,7 +174,7 @@ export type HouseTransport = HouseDoor & {
|
|
|
175
174
|
};
|
|
176
175
|
export type HouseSiteTransport = HouseDoor & {
|
|
177
176
|
online(): boolean;
|
|
178
|
-
read(route: string): Promise<HouseDoorAnswer>;
|
|
177
|
+
read(route: string, arriving?: (bytes: number) => void): Promise<HouseDoorAnswer>;
|
|
179
178
|
download(route: string): Promise<HouseBytesAnswer>;
|
|
180
179
|
};
|
|
181
180
|
export {};
|
package/dist/transport.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE/E,eAAO,MAAM,aAAa,mBAAmB,CAAC;AAE9C,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD,eAAO,MAAM,UAAU,gBAAgB,CAAC;AAExC,eAAO,MAAM,iBAAiB,uBAAuB,CAAC;AAEtD,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD,eAAO,MAAM,kBAAkB,0BAA0B,CAAC;AAE1D,eAAO,MAAM,mBAAmB,4BAA4B,CAAC;AAE7D,eAAO,MAAM,mBAAmB,2BAA2B,CAAC;AAE5D,eAAO,MAAM,gBAAgB,wBAAwB,CAAC;AAEtD,MAAM,MAAM,SAAS,GAAG,YAAY,GAAG,MAAM,CAAC;AAE9C,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD,eAAO,MAAM,iBAAiB,uBAAuB,CAAC;AAEtD,eAAO,MAAM,UAAU,mBAAmB,CAAC;AAE3C,MAAM,MAAM,YAAY,GAAG,uBAAuB,CAAC;AAEnD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;IACxC,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,GAAG,E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AAc,EAAE,IAAI,CAAC,CA8DzC;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,aAAa,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC;IAEjF,IAAI,EAAE,UAAU;IAChB,QAAQ;IACR,IAAI;IACJ,MAAM;QAAI,IAAI;;IACd,SAAS;EAEZ;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAM1B;AAoBD,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3C,aAAa,CAyDf"}
|
package/dist/write.js
CHANGED
|
@@ -354,17 +354,6 @@ function revisionAuthor(entry) {
|
|
|
354
354
|
}
|
|
355
355
|
return null;
|
|
356
356
|
}
|
|
357
|
-
function historyBinary(entry) {
|
|
358
|
-
if (entry.file === undefined)
|
|
359
|
-
return undefined;
|
|
360
|
-
const { file, bytes, media_type: mediaType, sha256 } = entry;
|
|
361
|
-
if (typeof file !== 'string' ||
|
|
362
|
-
typeof bytes !== 'number' ||
|
|
363
|
-
typeof mediaType !== 'string' ||
|
|
364
|
-
typeof sha256 !== 'string')
|
|
365
|
-
return null;
|
|
366
|
-
return { fileRef: file, byteLength: bytes, mediaType, sha256 };
|
|
367
|
-
}
|
|
368
357
|
export function historyOutcome(status, body, locator, request) {
|
|
369
358
|
const classified = classifyDoor(status, body, locator);
|
|
370
359
|
if (classified !== null)
|
|
@@ -395,7 +384,7 @@ export function historyOutcome(status, body, locator, request) {
|
|
|
395
384
|
retryable: false,
|
|
396
385
|
};
|
|
397
386
|
}
|
|
398
|
-
if (typeof named.
|
|
387
|
+
if (typeof named.media_type === 'string')
|
|
399
388
|
return { kind: 'no-history' };
|
|
400
389
|
if (typeof named.content !== 'string')
|
|
401
390
|
return { kind: 'transport-uncertainty' };
|
|
@@ -411,7 +400,7 @@ export function historyOutcome(status, body, locator, request) {
|
|
|
411
400
|
typeof entry.created_at !== 'string') {
|
|
412
401
|
return { kind: 'transport-uncertainty' };
|
|
413
402
|
}
|
|
414
|
-
const binaryFile =
|
|
403
|
+
const binaryFile = binaryFileOf(entry);
|
|
415
404
|
if (binaryFile === null)
|
|
416
405
|
return { kind: 'transport-uncertainty' };
|
|
417
406
|
revisions.push({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentshouse/mdruntime-adapter",
|
|
3
|
-
"version": "0.1.0-
|
|
3
|
+
"version": "0.1.0-c3fcf52802a21",
|
|
4
4
|
"description": "Agents House Adapter for the MD Runtime",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -25,6 +25,6 @@
|
|
|
25
25
|
"LICENSE"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@agentshouse/mdruntime": "0.1.0-
|
|
28
|
+
"@agentshouse/mdruntime": "0.1.0-c75a43bf2460f"
|
|
29
29
|
}
|
|
30
30
|
}
|
package/dist/referrer.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { ReferrerScope } from '@agentshouse/mdruntime';
|
|
2
|
-
import type { TrackedAuthority } from './discovery.js';
|
|
3
|
-
export type HouseReferrer = {
|
|
4
|
-
locator: string;
|
|
5
|
-
referrer: {
|
|
6
|
-
readonly room_ref: string;
|
|
7
|
-
readonly path: string;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
export declare function houseReferrer(referrer: unknown, tracked: ReadonlyMap<string, TrackedAuthority>): HouseReferrer | null;
|
|
11
|
-
export declare function houseReferrerScope(referrer: unknown): ReferrerScope | null;
|
|
12
|
-
//# sourceMappingURL=referrer.d.ts.map
|
package/dist/referrer.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"referrer.d.ts","sourceRoot":"","sources":["../src/referrer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE;QAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAChE,CAAC;AAgBF,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,OAAO,EACjB,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,GAC7C,aAAa,GAAG,IAAI,CAYtB;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,OAAO,GAAG,aAAa,GAAG,IAAI,CAK1E"}
|
package/dist/referrer.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
function fields(value) {
|
|
2
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
3
|
-
? value
|
|
4
|
-
: null;
|
|
5
|
-
}
|
|
6
|
-
function named(held, ...keys) {
|
|
7
|
-
const present = Object.keys(held);
|
|
8
|
-
return (present.length === keys.length &&
|
|
9
|
-
keys.every((key) => typeof held[key] === 'string' && held[key] !== ''));
|
|
10
|
-
}
|
|
11
|
-
export function houseReferrer(referrer, tracked) {
|
|
12
|
-
const held = fields(referrer);
|
|
13
|
-
if (held === null)
|
|
14
|
-
return null;
|
|
15
|
-
if (named(held, 'room', 'path')) {
|
|
16
|
-
const entry = tracked.get(held.room);
|
|
17
|
-
if (entry === undefined)
|
|
18
|
-
return null;
|
|
19
|
-
return {
|
|
20
|
-
locator: entry.locator,
|
|
21
|
-
referrer: { room_ref: entry.authority, path: held.path },
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
export function houseReferrerScope(referrer) {
|
|
27
|
-
const held = fields(referrer);
|
|
28
|
-
return held !== null && named(held, 'room', 'path')
|
|
29
|
-
? { locator: held.room, path: held.path }
|
|
30
|
-
: null;
|
|
31
|
-
}
|