@agentshouse/mdruntime-adapter 0.1.0-cd59fd8945dcb → 0.1.0-cda5b3be3317e
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 +271 -262
- package/dist/actions.d.ts +23 -0
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +68 -31
- package/dist/adapter.d.ts +1 -0
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +261 -64
- package/dist/discovery.d.ts +2 -1
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +10 -6
- package/dist/handed.d.ts +15 -0
- package/dist/handed.d.ts.map +1 -0
- package/dist/handed.js +38 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/model.d.ts +0 -1
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +0 -3
- package/dist/read.d.ts +29 -6
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +150 -52
- package/dist/referrer.d.ts +7 -0
- package/dist/referrer.d.ts.map +1 -0
- package/dist/referrer.js +35 -0
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +2 -1
- package/dist/site.d.ts +1 -1
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +174 -47
- package/dist/stream.d.ts +3 -2
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +325 -16
- package/dist/transport.d.ts +62 -6
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +3 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/write.d.ts +2 -9
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +61 -8
- package/package.json +2 -3
- package/dist/links.d.ts +0 -20
- package/dist/links.d.ts.map +0 -1
- package/dist/links.js +0 -104
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { createAgentsHouseAdapter, type AgentsHouseAdapterOptions } from './adapter.js';
|
|
2
|
-
export { HOUSE_APP_ACTS } from './actions.js';
|
|
3
|
-
export type { HouseByteAct, HouseByteTransfer, HouseDoorAnswer, HouseHeldRoom, HouseOpening, HouseStream, HouseStreamEntry, HouseStreamFrame, HouseSiteTransport, HouseTransport, } from './transport.js';
|
|
2
|
+
export { HOUSE_APP_ACTS, HOUSE_APP_BATCHES, HOUSE_SITE_ACTS } from './actions.js';
|
|
3
|
+
export type { HouseByteAct, HouseByteTransfer, HouseBytesAnswer, HouseClosing, HouseDoorAnswer, HouseHeldRoom, HouseOpening, HouseStream, HouseStreamEntry, HouseStreamFrame, HouseSiteTransport, HouseTransport, } from './transport.js';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,KAAK,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,KAAK,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAClF,YAAY,EACV,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,aAAa,EACb,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,GACf,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { createAgentsHouseAdapter } from './adapter.js';
|
|
2
|
-
export { HOUSE_APP_ACTS } from './actions.js';
|
|
2
|
+
export { HOUSE_APP_ACTS, HOUSE_APP_BATCHES, HOUSE_SITE_ACTS } from './actions.js';
|
package/dist/model.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import type { TrackedAuthority } from './discovery.js';
|
|
|
3
3
|
import { type HouseScope, type HouseView } from './read.js';
|
|
4
4
|
import type { HouseMode, HouseStreamEntry } from './transport.js';
|
|
5
5
|
export declare function partModels(scope: HouseScope, tracked: TrackedAuthority, seen: ReadonlySet<string>, final: boolean): Promise<RoomModels | undefined>;
|
|
6
|
-
export declare function scopeModels(scope: HouseScope, tracked: TrackedAuthority): Promise<RoomModels | undefined>;
|
|
7
6
|
export declare function viewModels(view: HouseView, tracked: TrackedAuthority): Promise<RoomModels | undefined>;
|
|
8
7
|
export declare function streamedModels(schemas: ReadonlyMap<string, HouseStreamEntry>, tracked: TrackedAuthority, mode: HouseMode): Promise<RoomModels | undefined>;
|
|
9
8
|
//# sourceMappingURL=model.d.ts.map
|
package/dist/model.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAA0C,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AACpG,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAoClE,wBAAgB,UAAU,CACxB,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,EACzB,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAKjC;AAED,wBAAgB,
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAA0C,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AACpG,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAoClE,wBAAgB,UAAU,CACxB,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,EACzB,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAKjC;AAED,wBAAgB,UAAU,CACxB,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAcjC;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,EAC9C,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,SAAS,GACd,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAWjC"}
|
package/dist/model.js
CHANGED
|
@@ -33,9 +33,6 @@ export function partModels(scope, tracked, seen, final) {
|
|
|
33
33
|
return final && !seen.has(schema) ? ABSENT_SCHEMA : undefined;
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
|
-
export function scopeModels(scope, tracked) {
|
|
37
|
-
return partModels(scope, tracked, new Set(), true);
|
|
38
|
-
}
|
|
39
36
|
export function viewModels(view, tracked) {
|
|
40
37
|
return modelsOf(tracked, (schema) => {
|
|
41
38
|
const change = view.changes.find((candidate) => candidate.path === schema);
|
package/dist/read.d.ts
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import type { BootstrapPage, RefreshResult
|
|
1
|
+
import type { AdapterFailure, BinaryFile, BootstrapPage, RefreshResult } from '@agentshouse/mdruntime';
|
|
2
2
|
import type { TrackedAuthority } from './discovery.js';
|
|
3
3
|
import type { HouseMode } from './transport.js';
|
|
4
4
|
import { type LogPosition } from './version.js';
|
|
5
5
|
export type HeadChange = BootstrapPage['changes'][string];
|
|
6
|
+
export declare function identities(revisions: Readonly<Record<string, string>>): {
|
|
7
|
+
fileIds?: Record<string, string>;
|
|
8
|
+
};
|
|
6
9
|
export type HouseManifestFile = {
|
|
7
10
|
path: string;
|
|
8
11
|
revision: string | undefined;
|
|
9
12
|
version: string;
|
|
13
|
+
sha256?: string;
|
|
10
14
|
head?: HeadChange;
|
|
15
|
+
binary?: BinaryFile;
|
|
11
16
|
};
|
|
12
17
|
export type HouseContent = {
|
|
13
18
|
path: string;
|
|
@@ -17,11 +22,15 @@ export type HouseScope = LogPosition & {
|
|
|
17
22
|
anchor: string;
|
|
18
23
|
files: readonly HouseManifestFile[];
|
|
19
24
|
contents: readonly HouseContent[];
|
|
20
|
-
|
|
25
|
+
};
|
|
26
|
+
export type HouseCut = {
|
|
27
|
+
position: string;
|
|
28
|
+
log_epoch: string;
|
|
21
29
|
};
|
|
22
30
|
export type HouseCursor = {
|
|
23
31
|
room: string;
|
|
24
32
|
path: string | null;
|
|
33
|
+
cut?: HouseCut;
|
|
25
34
|
};
|
|
26
35
|
export type HouseEnvelope = {
|
|
27
36
|
scopes: readonly HouseScope[];
|
|
@@ -46,14 +55,23 @@ export type HouseChange = {
|
|
|
46
55
|
head?: HeadChange;
|
|
47
56
|
} | {
|
|
48
57
|
path: string;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
58
|
+
binary: BinaryFile;
|
|
59
|
+
revision: string | undefined;
|
|
60
|
+
version: string;
|
|
61
|
+
head?: HeadChange;
|
|
62
|
+
};
|
|
63
|
+
export type HousePage = {
|
|
64
|
+
after: string;
|
|
65
|
+
through: string;
|
|
66
|
+
read: number;
|
|
52
67
|
};
|
|
53
68
|
export type HouseView = LogPosition & {
|
|
54
69
|
authority: string;
|
|
55
70
|
changes: readonly HouseChange[];
|
|
56
|
-
|
|
71
|
+
next?: HousePage;
|
|
72
|
+
};
|
|
73
|
+
type PageFailure = AdapterFailure | {
|
|
74
|
+
kind: 'beyond-horizon';
|
|
57
75
|
};
|
|
58
76
|
export type HouseEnumeration = {
|
|
59
77
|
authorities: readonly HouseView[];
|
|
@@ -66,9 +84,13 @@ export declare function headChange(held: {
|
|
|
66
84
|
readonly author?: unknown;
|
|
67
85
|
readonly created_at?: unknown;
|
|
68
86
|
}): HeadChange | undefined | null;
|
|
87
|
+
export declare function binaryFileOf(held: Readonly<Record<string, unknown>>): BinaryFile | undefined | null;
|
|
69
88
|
export declare function parseEnvelope(body: unknown): HouseEnvelope | null;
|
|
70
89
|
export declare function parseSiteBootstrap(body: unknown): HouseScope | null;
|
|
90
|
+
export declare function siteBootstrapNext(body: unknown): string | null;
|
|
91
|
+
export declare function siteBootstrapOffset(body: unknown): number | null;
|
|
71
92
|
export declare function parseEnumeration(body: unknown, mode: HouseMode): HouseEnumeration | null;
|
|
93
|
+
export declare function wholeView(first: HouseView, more: (page: HousePage) => Promise<HouseView | PageFailure>): Promise<HouseView | PageFailure>;
|
|
72
94
|
export declare function advancedScope(scope: HouseScope, view: HouseView): HouseScope;
|
|
73
95
|
export declare function matchesScope(scope: HouseScope, tracked: TrackedAuthority): boolean;
|
|
74
96
|
export declare function bootstrapOf(scope: HouseScope): BootstrapPage;
|
|
@@ -80,4 +102,5 @@ export type HouseSchema = {
|
|
|
80
102
|
export declare function schemaOf(scope: HouseScope, schema: string): HouseSchema | null;
|
|
81
103
|
export declare function viewOf(enumeration: HouseEnumeration, tracked: TrackedAuthority): HouseView | undefined;
|
|
82
104
|
export declare function refreshFrom(view: HouseView, fromRoomVersion: string): RefreshResult;
|
|
105
|
+
export {};
|
|
83
106
|
//# sourceMappingURL=read.d.ts.map
|
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,KAAK,EACV,aAAa,EAEb,aAAa,
|
|
1
|
+
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../src/read.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,UAAU,EACV,aAAa,EAEb,aAAa,EACd,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAsC,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAEpF,MAAM,MAAM,UAAU,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAI1D,wBAAgB,UAAU,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG;IACvE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC,CAQA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACpC,QAAQ,EAAE,SAAS,YAAY,EAAE,CAAC;CACnC,CAAC;AAEF,MAAM,MAA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CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,GAAG,gBAAgB,GAAG,IAAI,CA0BxF;AAgBD,wBAAsB,SAAS,CAC7B,KAAK,EAAE,SAAS,EAChB,IAAI,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,OAAO,CAAC,SAAS,GAAG,WAAW,CAAC,GAC1D,OAAO,CAAC,SAAS,GAAG,WAAW,CAAC,CA0BlC;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,GAAG,UAAU,CAuB5E;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAElF;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,aAAa,CAsB5D;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,CAAC;AAEF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAO9E;AAED,wBAAgB,MAAM,CACpB,WAAW,EAAE,gBAAgB,EAC7B,OAAO,EAAE,gBAAgB,GACxB,SAAS,GAAG,SAAS,CAEvB;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,GAAG,aAAa,CA2BnF"}
|
package/dist/read.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import { readPosition, roomVersion } from './version.js';
|
|
1
|
+
import { DECIMAL, readPosition, roomVersion } from './version.js';
|
|
2
|
+
const REVISION_FILE = /^fr_([0-9a-z]+)\.[0-9a-z]+\.[0-9a-z]$/u;
|
|
3
|
+
export function identities(revisions) {
|
|
4
|
+
const fileIds = Object.fromEntries(Object.entries(revisions).flatMap(([path, revision]) => {
|
|
5
|
+
const file = REVISION_FILE.exec(revision)?.[1];
|
|
6
|
+
return file === undefined ? [] : [[path, file]];
|
|
7
|
+
}));
|
|
8
|
+
return Object.keys(fileIds).length === 0 ? {} : { fileIds };
|
|
9
|
+
}
|
|
2
10
|
export function authorityRoot(handle) {
|
|
3
11
|
return `/rooms/${handle}`;
|
|
4
12
|
}
|
|
@@ -51,8 +59,19 @@ export function headChange(held) {
|
|
|
51
59
|
function headed(head) {
|
|
52
60
|
return head === undefined ? {} : { head };
|
|
53
61
|
}
|
|
54
|
-
function
|
|
55
|
-
|
|
62
|
+
export function binaryFileOf(held) {
|
|
63
|
+
if (held.file === undefined)
|
|
64
|
+
return undefined;
|
|
65
|
+
const { file, bytes, media_type: mediaType, sha256 } = held;
|
|
66
|
+
if (typeof file !== 'string' ||
|
|
67
|
+
typeof bytes !== 'number' ||
|
|
68
|
+
typeof mediaType !== 'string' ||
|
|
69
|
+
typeof sha256 !== 'string')
|
|
70
|
+
return null;
|
|
71
|
+
return { fileRef: file, byteLength: bytes, mediaType, sha256 };
|
|
72
|
+
}
|
|
73
|
+
function binaried(binary) {
|
|
74
|
+
return binary === undefined ? {} : { binary };
|
|
56
75
|
}
|
|
57
76
|
function parseFile(value, mode) {
|
|
58
77
|
if (typeof value !== 'object' || value === null)
|
|
@@ -61,16 +80,30 @@ function parseFile(value, mode) {
|
|
|
61
80
|
if (typeof file.path !== 'string')
|
|
62
81
|
return null;
|
|
63
82
|
const head = headChange(file);
|
|
64
|
-
|
|
83
|
+
const binary = binaryFileOf(file);
|
|
84
|
+
if (head === null || binary === null)
|
|
65
85
|
return null;
|
|
66
86
|
if (mode === 'site') {
|
|
67
87
|
if (typeof file.sha256 !== 'string')
|
|
68
88
|
return null;
|
|
69
|
-
return {
|
|
89
|
+
return {
|
|
90
|
+
path: file.path,
|
|
91
|
+
revision: binary?.sha256,
|
|
92
|
+
version: file.sha256,
|
|
93
|
+
...headed(head),
|
|
94
|
+
...binaried(binary),
|
|
95
|
+
};
|
|
70
96
|
}
|
|
71
97
|
if (typeof file.revision !== 'string')
|
|
72
98
|
return null;
|
|
73
|
-
return {
|
|
99
|
+
return {
|
|
100
|
+
path: file.path,
|
|
101
|
+
revision: file.revision,
|
|
102
|
+
version: file.revision,
|
|
103
|
+
...(typeof file.sha256 === 'string' ? { sha256: file.sha256 } : {}),
|
|
104
|
+
...headed(head),
|
|
105
|
+
...binaried(binary),
|
|
106
|
+
};
|
|
74
107
|
}
|
|
75
108
|
function parseScope(value, mode) {
|
|
76
109
|
if (typeof value !== 'object' || value === null)
|
|
@@ -106,17 +139,28 @@ function parseScope(value, mode) {
|
|
|
106
139
|
return null;
|
|
107
140
|
contents.push({ path: content.path, content: content.content });
|
|
108
141
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
142
|
+
return { anchor: manifest.anchor, ...at, files, contents };
|
|
143
|
+
}
|
|
144
|
+
function parseCut(value) {
|
|
145
|
+
if (value === undefined)
|
|
146
|
+
return undefined;
|
|
147
|
+
if (typeof value !== 'object' || value === null)
|
|
148
|
+
return null;
|
|
149
|
+
const { position, log_epoch: logEpoch } = value;
|
|
150
|
+
if (typeof position !== 'string' || typeof logEpoch !== 'string')
|
|
151
|
+
return null;
|
|
152
|
+
return { position, log_epoch: logEpoch };
|
|
112
153
|
}
|
|
113
154
|
function parseCursor(value) {
|
|
114
155
|
if (typeof value !== 'object' || value === null)
|
|
115
156
|
return null;
|
|
116
|
-
const { room, path } = value;
|
|
157
|
+
const { room, path, cut } = value;
|
|
117
158
|
if (typeof room !== 'string' || (path !== null && typeof path !== 'string'))
|
|
118
159
|
return null;
|
|
119
|
-
|
|
160
|
+
const parsed = parseCut(cut);
|
|
161
|
+
if (parsed === null)
|
|
162
|
+
return null;
|
|
163
|
+
return { room, path, ...(parsed === undefined ? {} : { cut: parsed }) };
|
|
120
164
|
}
|
|
121
165
|
export function parseEnvelope(body) {
|
|
122
166
|
if (typeof body !== 'object' || body === null)
|
|
@@ -138,6 +182,18 @@ export function parseEnvelope(body) {
|
|
|
138
182
|
export function parseSiteBootstrap(body) {
|
|
139
183
|
return parseScope(body, 'site');
|
|
140
184
|
}
|
|
185
|
+
export function siteBootstrapNext(body) {
|
|
186
|
+
if (typeof body !== 'object' || body === null || !('next' in body))
|
|
187
|
+
return null;
|
|
188
|
+
return typeof body.next === 'string' && body.next.length > 0 ? body.next : null;
|
|
189
|
+
}
|
|
190
|
+
export function siteBootstrapOffset(body) {
|
|
191
|
+
if (typeof body !== 'object' || body === null || !('offset' in body))
|
|
192
|
+
return null;
|
|
193
|
+
return Number.isSafeInteger(body.offset) && body.offset > 0
|
|
194
|
+
? body.offset
|
|
195
|
+
: null;
|
|
196
|
+
}
|
|
141
197
|
function parseChange(value, mode) {
|
|
142
198
|
if (typeof value !== 'object' || value === null)
|
|
143
199
|
return null;
|
|
@@ -147,8 +203,15 @@ function parseChange(value, mode) {
|
|
|
147
203
|
if (held.removed === true)
|
|
148
204
|
return { path: held.path, removed: true };
|
|
149
205
|
const head = headChange(held);
|
|
150
|
-
|
|
206
|
+
const binary = binaryFileOf(held);
|
|
207
|
+
if (head === null || binary === null)
|
|
151
208
|
return null;
|
|
209
|
+
if (binary !== undefined) {
|
|
210
|
+
if (mode === 'credential' && typeof held.revision !== 'string')
|
|
211
|
+
return null;
|
|
212
|
+
const revision = typeof held.revision === 'string' ? held.revision : binary.sha256;
|
|
213
|
+
return { path: held.path, binary, revision, version: revision, ...headed(head) };
|
|
214
|
+
}
|
|
152
215
|
if (mode === 'site') {
|
|
153
216
|
if (typeof held.content !== 'string' || typeof held.sha256 !== 'string')
|
|
154
217
|
return null;
|
|
@@ -169,12 +232,6 @@ function parseChange(value, mode) {
|
|
|
169
232
|
...headed(head),
|
|
170
233
|
};
|
|
171
234
|
}
|
|
172
|
-
if (typeof held.reference === 'object' && held.reference !== null) {
|
|
173
|
-
const reference = held.reference;
|
|
174
|
-
if (typeof reference.revision !== 'string')
|
|
175
|
-
return null;
|
|
176
|
-
return { path: held.path, reference: { revision: reference.revision } };
|
|
177
|
-
}
|
|
178
235
|
return null;
|
|
179
236
|
}
|
|
180
237
|
export function parseEnumeration(body, mode) {
|
|
@@ -199,14 +256,60 @@ export function parseEnumeration(body, mode) {
|
|
|
199
256
|
return null;
|
|
200
257
|
changes.push(mapped);
|
|
201
258
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
259
|
+
const next = held.next === undefined ? undefined : readPage(held.next);
|
|
260
|
+
if (next === null)
|
|
261
|
+
return null;
|
|
262
|
+
authorities.push({
|
|
263
|
+
authority: held.authority,
|
|
264
|
+
...at,
|
|
265
|
+
changes,
|
|
266
|
+
...(next === undefined ? {} : { next }),
|
|
267
|
+
});
|
|
207
268
|
}
|
|
208
269
|
return { authorities };
|
|
209
270
|
}
|
|
271
|
+
function readPage(held) {
|
|
272
|
+
if (typeof held !== 'object' || held === null)
|
|
273
|
+
return null;
|
|
274
|
+
const { after, through, read } = held;
|
|
275
|
+
if (typeof after !== 'string' || !DECIMAL.test(after))
|
|
276
|
+
return null;
|
|
277
|
+
if (typeof through !== 'string' || !DECIMAL.test(through))
|
|
278
|
+
return null;
|
|
279
|
+
if (typeof read !== 'number' || !Number.isSafeInteger(read) || read < 0)
|
|
280
|
+
return null;
|
|
281
|
+
return { after, through, read };
|
|
282
|
+
}
|
|
283
|
+
function advances(asked, next) {
|
|
284
|
+
const moved = BigInt(next.through) - BigInt(asked.through);
|
|
285
|
+
return moved > 0n || (moved === 0n && next.after === asked.after && next.read > asked.read);
|
|
286
|
+
}
|
|
287
|
+
export async function wholeView(first, more) {
|
|
288
|
+
const changes = new Map(first.changes.map((change) => [change.path, change]));
|
|
289
|
+
let view = first;
|
|
290
|
+
while (view.next !== undefined) {
|
|
291
|
+
const asked = view.next;
|
|
292
|
+
const page = await more(asked);
|
|
293
|
+
if ('kind' in page)
|
|
294
|
+
return page;
|
|
295
|
+
if (page.position !== asked.through ||
|
|
296
|
+
page.logEpoch !== first.logEpoch ||
|
|
297
|
+
(page.next !== undefined && !advances(asked, page.next))) {
|
|
298
|
+
return { kind: 'transport-uncertainty' };
|
|
299
|
+
}
|
|
300
|
+
for (const change of page.changes) {
|
|
301
|
+
changes.delete(change.path);
|
|
302
|
+
changes.set(change.path, change);
|
|
303
|
+
}
|
|
304
|
+
view = page;
|
|
305
|
+
}
|
|
306
|
+
return {
|
|
307
|
+
authority: first.authority,
|
|
308
|
+
position: view.position,
|
|
309
|
+
logEpoch: first.logEpoch,
|
|
310
|
+
changes: [...changes.values()],
|
|
311
|
+
};
|
|
312
|
+
}
|
|
210
313
|
export function advancedScope(scope, view) {
|
|
211
314
|
const files = new Map(scope.files.map((file) => [file.path, file]));
|
|
212
315
|
const contents = new Map(scope.contents.map((entry) => [entry.path, entry.content]));
|
|
@@ -215,18 +318,15 @@ export function advancedScope(scope, view) {
|
|
|
215
318
|
contents.delete(change.path);
|
|
216
319
|
if ('removed' in change)
|
|
217
320
|
continue;
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
321
|
+
files.set(change.path, {
|
|
322
|
+
path: change.path,
|
|
323
|
+
revision: change.revision,
|
|
324
|
+
version: change.version,
|
|
325
|
+
...headed(change.head),
|
|
326
|
+
...('binary' in change ? { binary: change.binary } : {}),
|
|
327
|
+
});
|
|
328
|
+
if ('content' in change)
|
|
225
329
|
contents.set(change.path, change.content);
|
|
226
|
-
continue;
|
|
227
|
-
}
|
|
228
|
-
const { revision } = change.reference;
|
|
229
|
-
files.set(change.path, { path: change.path, revision, version: revision });
|
|
230
330
|
}
|
|
231
331
|
return {
|
|
232
332
|
...scope,
|
|
@@ -244,16 +344,16 @@ export function bootstrapOf(scope) {
|
|
|
244
344
|
const documents = {};
|
|
245
345
|
const revisions = {};
|
|
246
346
|
const changes = {};
|
|
247
|
-
const
|
|
347
|
+
const binaryFiles = {};
|
|
248
348
|
for (const file of scope.files) {
|
|
249
349
|
if (file.revision !== undefined)
|
|
250
350
|
revisions[file.path] = file.revision;
|
|
251
351
|
if (file.head !== undefined)
|
|
252
352
|
changes[file.path] = file.head;
|
|
253
353
|
const content = contents.get(file.path);
|
|
254
|
-
if (
|
|
255
|
-
|
|
256
|
-
else
|
|
354
|
+
if (file.binary !== undefined)
|
|
355
|
+
binaryFiles[file.path] = file.binary;
|
|
356
|
+
else if (content !== undefined)
|
|
257
357
|
documents[file.path] = content;
|
|
258
358
|
}
|
|
259
359
|
return {
|
|
@@ -261,9 +361,9 @@ export function bootstrapOf(scope) {
|
|
|
261
361
|
roomVersion: roomVersion(scope),
|
|
262
362
|
documents,
|
|
263
363
|
revisions,
|
|
364
|
+
...identities(revisions),
|
|
264
365
|
changes,
|
|
265
|
-
|
|
266
|
-
...declared(scope.attachments),
|
|
366
|
+
binaryFiles,
|
|
267
367
|
};
|
|
268
368
|
}
|
|
269
369
|
export function schemaOf(scope, schema) {
|
|
@@ -284,32 +384,30 @@ export function refreshFrom(view, fromRoomVersion) {
|
|
|
284
384
|
const documents = {};
|
|
285
385
|
const revisions = {};
|
|
286
386
|
const changes = {};
|
|
287
|
-
const
|
|
387
|
+
const binaryFiles = {};
|
|
288
388
|
const removals = [];
|
|
289
389
|
for (const change of view.changes) {
|
|
290
390
|
if ('removed' in change) {
|
|
291
391
|
removals.push(change.path);
|
|
292
392
|
continue;
|
|
293
393
|
}
|
|
294
|
-
if ('content' in change)
|
|
394
|
+
if ('content' in change)
|
|
295
395
|
documents[change.path] = change.content;
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
binaryTargets.push(change.path);
|
|
303
|
-
revisions[change.path] = change.reference.revision;
|
|
396
|
+
else
|
|
397
|
+
binaryFiles[change.path] = change.binary;
|
|
398
|
+
if (change.revision !== undefined)
|
|
399
|
+
revisions[change.path] = change.revision;
|
|
400
|
+
if (change.head !== undefined)
|
|
401
|
+
changes[change.path] = change.head;
|
|
304
402
|
}
|
|
305
403
|
return {
|
|
306
404
|
kind: 'net-advancement',
|
|
307
405
|
roomVersion: roomVersion(view),
|
|
308
406
|
documents,
|
|
309
407
|
revisions,
|
|
408
|
+
...identities(revisions),
|
|
310
409
|
changes,
|
|
311
|
-
|
|
410
|
+
binaryFiles,
|
|
312
411
|
removals: removals.sort(),
|
|
313
|
-
...declared(view.attachments),
|
|
314
412
|
};
|
|
315
413
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TrackedAuthority } from './discovery.js';
|
|
2
|
+
export type HouseReferrer = {
|
|
3
|
+
locator: string;
|
|
4
|
+
referrer: Readonly<Record<string, string>>;
|
|
5
|
+
};
|
|
6
|
+
export declare function houseReferrer(referrer: unknown, tracked: ReadonlyMap<string, TrackedAuthority>): HouseReferrer | null;
|
|
7
|
+
//# sourceMappingURL=referrer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"referrer.d.ts","sourceRoot":"","sources":["../src/referrer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,MAAM,MAAM,aAAa,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CAAE,CAAC;AAgB5F,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,OAAO,EACjB,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,GAC7C,aAAa,GAAG,IAAI,CAqBtB"}
|
package/dist/referrer.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
if (named(held, 'room_ref', 'record')) {
|
|
25
|
+
const roomRef = held.room_ref;
|
|
26
|
+
const entry = [...tracked.values()].find((candidate) => candidate.authority === roomRef);
|
|
27
|
+
return {
|
|
28
|
+
locator: entry?.locator ?? roomRef,
|
|
29
|
+
referrer: { room_ref: roomRef, record: held.record },
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
if (named(held, 'message'))
|
|
33
|
+
return { locator: '', referrer: { message: held.message } };
|
|
34
|
+
return null;
|
|
35
|
+
}
|
package/dist/refusal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refusal.d.ts","sourceRoot":"","sources":["../src/refusal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,aAAa,EACd,MAAM,wBAAwB,CAAC;AAEhC,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAOjE;AAED,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,EAC7B,OAAO,EAAE,eAAe,GACvB,aAAa,CAEf;
|
|
1
|
+
{"version":3,"file":"refusal.d.ts","sourceRoot":"","sources":["../src/refusal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,aAAa,EACd,MAAM,wBAAwB,CAAC;AAEhC,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAOjE;AAED,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,EAC7B,OAAO,EAAE,eAAe,GACvB,aAAa,CAEf;AAqBD,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,GACd,cAAc,GAAG,IAAI,CAMvB;AAED,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,GACd,cAAc,GAAG;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAAG,IAAI,CAGpD;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,cAAc,GAAG,IAAI,CAQrF"}
|
package/dist/refusal.js
CHANGED
|
@@ -18,8 +18,9 @@ function doorFailure(status, body) {
|
|
|
18
18
|
const refusal = doorRefusal(body);
|
|
19
19
|
if (status === 401)
|
|
20
20
|
return { kind: 'revoked-authorization' };
|
|
21
|
-
if (refusal?.retryable === true)
|
|
21
|
+
if (refusal?.retryable === true || refusal?.code === 'update_required') {
|
|
22
22
|
return { kind: 'transport-uncertainty' };
|
|
23
|
+
}
|
|
23
24
|
if (status === 404 || refusal?.code === 'room_not_found')
|
|
24
25
|
return { kind: 'room-not-readable' };
|
|
25
26
|
if (status < 400)
|
package/dist/site.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Adapter } from '@agentshouse/mdruntime';
|
|
2
2
|
import { type HouseSiteTransport } from './transport.js';
|
|
3
|
-
export declare function createSiteAdapter(transport: HouseSiteTransport): Adapter;
|
|
3
|
+
export declare function createSiteAdapter(transport: HouseSiteTransport, snapshot?: boolean): Adapter;
|
|
4
4
|
//# sourceMappingURL=site.d.ts.map
|
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,EAUR,MAAM,wBAAwB,CAAC;AA2BhC,OAAO,EAOL,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AAyCxB,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,kBAAkB,EAAE,QAAQ,UAAQ,GAAG,OAAO,CAwR1F"}
|