@agentshouse/mdruntime-adapter 0.1.0-cf3b6e1c58319 → 0.1.0-cf4bfd2581b66
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/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +1 -1
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +11 -13
- package/dist/authored-path.d.ts +0 -1
- package/dist/authored-path.d.ts.map +1 -1
- package/dist/authored-path.js +1 -2
- package/dist/chunks.d.ts +2 -3
- package/dist/chunks.d.ts.map +1 -1
- package/dist/chunks.js +58 -31
- package/dist/discovery.d.ts +16 -5
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +127 -6
- package/dist/index.d.ts +3 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -6
- package/dist/model.d.ts +5 -5
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +17 -27
- package/dist/read.d.ts +5 -19
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +34 -35
- package/dist/session-content/index.d.ts +1 -1
- package/dist/session-content/parts.d.ts +4 -3
- package/dist/session-content/turn.d.ts +3 -3
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +3 -7
- package/dist/space-schema.d.ts.map +1 -1
- package/dist/space-schema.js +1 -8
- package/dist/stream.d.ts +2 -3
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +70 -86
- package/dist/transport.d.ts +25 -6
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +3 -1
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +2 -4
- package/package.json +3 -2
- package/dist/app-reference.d.ts +0 -1
- package/dist/app-reference.d.ts.map +0 -1
- package/dist/app-reference.js +0 -2
- package/dist/crockford.d.ts +0 -3
- package/dist/crockford.d.ts.map +0 -1
- package/dist/crockford.js +0 -3
- package/dist/house-model.d.ts +0 -826
- package/dist/house-model.d.ts.map +0 -1
- package/dist/house-model.js +0 -464
- package/dist/room-types.d.ts +0 -4
- package/dist/room-types.d.ts.map +0 -1
- package/dist/room-types.js +0 -136
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,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAG7F,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEtE,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AAExD,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAG7F,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEtE,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AAExD,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EAI/C,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAIhD,CAAC;AAEF,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,iBAAiB,EAAE,CAEvF;AAED,wBAAgB,WAAW,CACzB,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,YAAY,CAAC,CAIvB;AAwBD,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,YAAY,CAajG"}
|
package/dist/actions.js
CHANGED
|
@@ -2,10 +2,10 @@ import { answeredFailure, doorRefusal, resetOf } from './refusal.js';
|
|
|
2
2
|
import { refusedFor } from './uncertain.js';
|
|
3
3
|
export const HOUSE_UNKEPT_READS = [
|
|
4
4
|
'account/security/read',
|
|
5
|
+
'billing/read',
|
|
5
6
|
'clients/last-use/list',
|
|
6
7
|
];
|
|
7
8
|
export const HOUSE_LEADING_READS = [
|
|
8
|
-
'rooms/list',
|
|
9
9
|
'apps/list',
|
|
10
10
|
'sites/list',
|
|
11
11
|
'rooms/members/list',
|
package/dist/adapter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAIV,OAAO,EAIP,aAAa,EAiBd,MAAM,wBAAwB,CAAC;AAyBhC,OAAO,EAIL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAmBxB,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;AAmBrD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAsbpF"}
|
package/dist/adapter.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { HOUSE_ROOM_TYPES, HOUSE_TYPED_PATHS } from '@agentshouse/mdmodel';
|
|
1
2
|
import { stepped } from '@agentshouse/mdruntime';
|
|
2
3
|
import { capabilities, discoveredRoom, mapDiscovery, parseAuthorityChange, parseDiscovery, trackedFrom, } from './discovery.js';
|
|
3
4
|
import { createSiteAdapter } from './site.js';
|
|
4
5
|
import { parseFileAddress, parseGrant } from './read.js';
|
|
5
6
|
import { chunkedHead, chunkLister, chunkPart } from './chunks.js';
|
|
6
|
-
import { spaceSchemas } from './space-schema.js';
|
|
7
7
|
import { finishedUpload, houseUpload } from './upload.js';
|
|
8
8
|
import { houseAction, HOUSE_LEADING_READS, HOUSE_UNKEPT_READS } from './actions.js';
|
|
9
9
|
import { houseSearch } from './search.js';
|
|
@@ -13,10 +13,7 @@ import { houseNotifications, } from './stream.js';
|
|
|
13
13
|
import { houseDoorRoute, } from './transport.js';
|
|
14
14
|
import { batchPaths, deltaBody, deltaBytes, deltaDigest, historyOutcome, houseChanges, houseMove, mutationOutcome, operationHead, rejectedMapping, revisionBody, uploadable, } from './write.js';
|
|
15
15
|
import { admittedPath } from './authored-path.js';
|
|
16
|
-
import { HOUSE_TYPED_PATHS } from './house-model.js';
|
|
17
|
-
import { HOUSE_NAMEABLE_ROOM_TYPES, HOUSE_ROOM_TYPES } from './room-types.js';
|
|
18
16
|
import { followsVersion, reachedVersion, roomVersion } from './version.js';
|
|
19
|
-
const OCTET_STREAM = 'application/octet-stream';
|
|
20
17
|
const EXPIRED_ADDRESS = 403;
|
|
21
18
|
function lapsedGrant(outcome) {
|
|
22
19
|
return outcome.kind === 'rejected' && outcome.code === 'upload_unavailable';
|
|
@@ -29,14 +26,13 @@ export function createAgentsHouseAdapter(options) {
|
|
|
29
26
|
if ('site' in options)
|
|
30
27
|
return createSiteAdapter(options.site, options.snapshot === true);
|
|
31
28
|
const transport = options.transport;
|
|
32
|
-
const spaces = spaceSchemas();
|
|
33
29
|
const notifications = houseNotifications(transport, 'credential', {
|
|
34
30
|
opened: async (frame) => (frame === null ? null : opened(frame)),
|
|
35
31
|
changed,
|
|
36
|
-
expired: (
|
|
37
|
-
}
|
|
32
|
+
expired: (entries) => lister.askAll(entries),
|
|
33
|
+
});
|
|
38
34
|
const tracked = new Map();
|
|
39
|
-
const lister = chunkLister(transport, () => declared().max_prefixes);
|
|
35
|
+
const lister = chunkLister(transport, () => declared().max_prefixes, (locator) => tracked.get(locator));
|
|
40
36
|
const chunked = new Map();
|
|
41
37
|
const renewals = new WeakMap();
|
|
42
38
|
let bounds;
|
|
@@ -58,13 +54,15 @@ export function createAgentsHouseAdapter(options) {
|
|
|
58
54
|
return {
|
|
59
55
|
...mapDiscovery(document, document.authorities.map((authority) => discoveredRoom(authority)), capabilities(document.actions)),
|
|
60
56
|
member: document.member,
|
|
57
|
+
roomList: document.roomList,
|
|
61
58
|
};
|
|
62
59
|
}
|
|
63
60
|
function changed(frame) {
|
|
64
61
|
const change = parseAuthorityChange(frame);
|
|
65
62
|
if (change === null)
|
|
66
63
|
return null;
|
|
67
|
-
|
|
64
|
+
const unheld = [...change.left, ...change.listed];
|
|
65
|
+
for (const locator of unheld)
|
|
68
66
|
tracked.delete(locator);
|
|
69
67
|
for (const entry of trackedFrom(change))
|
|
70
68
|
tracked.set(entry.locator, entry);
|
|
@@ -72,15 +70,16 @@ export function createAgentsHouseAdapter(options) {
|
|
|
72
70
|
return {
|
|
73
71
|
kind: 'authority-changed',
|
|
74
72
|
rooms: change.authorities.map((authority) => discoveredRoom(authority)),
|
|
75
|
-
left:
|
|
73
|
+
left: unheld,
|
|
76
74
|
member: change.member,
|
|
75
|
+
roomList: { ...change.roomList, left: change.left },
|
|
77
76
|
};
|
|
78
77
|
}
|
|
79
78
|
async function listedRoom(entry) {
|
|
80
79
|
const listed = await lister.list(entry);
|
|
81
80
|
if ('kind' in listed)
|
|
82
81
|
return listed;
|
|
83
|
-
const head = await chunkedHead(listed, entry
|
|
82
|
+
const head = await chunkedHead(listed, entry);
|
|
84
83
|
if (head.kind === 'bootstrap')
|
|
85
84
|
chunked.set(entry.locator, listed);
|
|
86
85
|
return head;
|
|
@@ -292,7 +291,6 @@ export function createAgentsHouseAdapter(options) {
|
|
|
292
291
|
}
|
|
293
292
|
return {
|
|
294
293
|
roomTypes: HOUSE_ROOM_TYPES,
|
|
295
|
-
nameableRoomTypes: HOUSE_NAMEABLE_ROOM_TYPES,
|
|
296
294
|
typedPaths: HOUSE_TYPED_PATHS,
|
|
297
295
|
pathRule: admittedPath,
|
|
298
296
|
unkeptReads: HOUSE_UNKEPT_READS,
|
|
@@ -366,7 +364,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
366
364
|
name: request.name,
|
|
367
365
|
bytes: request.byteLength,
|
|
368
366
|
sha256: request.sha256,
|
|
369
|
-
media_type: request.mediaType
|
|
367
|
+
media_type: request.mediaType,
|
|
370
368
|
});
|
|
371
369
|
const refused = refusedAttach(declared, request.locator);
|
|
372
370
|
if (refused !== null)
|
package/dist/authored-path.d.ts
CHANGED
|
@@ -6,5 +6,4 @@ export declare const AUTHORED_SEGMENT_MAX_CHARS = 255;
|
|
|
6
6
|
export declare const AUTHORED_SEGMENT: RegExp;
|
|
7
7
|
export declare const LOCAL_COPY_MANIFEST = ".house";
|
|
8
8
|
export declare const LOCAL_COPY_ROOT_NAMES: readonly string[];
|
|
9
|
-
export declare const APP_PREFERENCES_HOME = "settings/apps";
|
|
10
9
|
export declare function admittedPath(path: string): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authored-path.d.ts","sourceRoot":"","sources":["../src/authored-path.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,oBAAoB,gBAAgB,CAAC;AAElD,eAAO,MAAM,mBAAmB,eAAe,CAAC;AAEhD,eAAO,MAAM,gBAAgB,aAAa,CAAC;AAE3C,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAMhD,CAAC;AAEF,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAO9C,eAAO,MAAM,gBAAgB,QAE5B,CAAC;AAEF,eAAO,MAAM,mBAAmB,WAAW,CAAC;AAE5C,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAIlD,CAAC;
|
|
1
|
+
{"version":3,"file":"authored-path.d.ts","sourceRoot":"","sources":["../src/authored-path.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,oBAAoB,gBAAgB,CAAC;AAElD,eAAO,MAAM,mBAAmB,eAAe,CAAC;AAEhD,eAAO,MAAM,gBAAgB,aAAa,CAAC;AAE3C,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAMhD,CAAC;AAEF,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAO9C,eAAO,MAAM,gBAAgB,QAE5B,CAAC;AAEF,eAAO,MAAM,mBAAmB,WAAW,CAAC;AAE5C,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAIlD,CAAC;AASF,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAQlD"}
|
package/dist/authored-path.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { APP_REFERENCE_PATTERN } from '
|
|
1
|
+
import { APP_PREFERENCES_HOME, APP_REFERENCE_PATTERN } from '@agentshouse/mdmodel';
|
|
2
2
|
export const GENERATED_PROVENANCE = '_provenance';
|
|
3
3
|
export const GENERATED_REVISIONS = '_revisions';
|
|
4
4
|
export const RESERVED_DERIVED = '_derived';
|
|
@@ -21,7 +21,6 @@ export const LOCAL_COPY_ROOT_NAMES = [
|
|
|
21
21
|
'.ignore',
|
|
22
22
|
LOCAL_COPY_MANIFEST,
|
|
23
23
|
];
|
|
24
|
-
export const APP_PREFERENCES_HOME = 'settings/apps';
|
|
25
24
|
function appPreferences(path) {
|
|
26
25
|
return (path.endsWith('.md') &&
|
|
27
26
|
APP_REFERENCE_PATTERN.test(path.slice(APP_PREFERENCES_HOME.length + 1, -3)));
|
package/dist/chunks.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type AdapterFailure, type BootstrapPart, type BootstrapResult } from '@agentshouse/mdruntime';
|
|
2
2
|
import type { TrackedAuthority } from './discovery.js';
|
|
3
3
|
import { type HouseModels, type HouseScope } from './read.js';
|
|
4
|
-
import type { SpaceSchemas } from './space-schema.js';
|
|
5
4
|
import { type HouseDoor, type HouseMode } from './transport.js';
|
|
6
5
|
import { type LogPosition } from './version.js';
|
|
7
6
|
export type ChunkAddress = {
|
|
@@ -25,9 +24,9 @@ type Answered = {
|
|
|
25
24
|
};
|
|
26
25
|
export declare function partId(logEpoch: string, hash: string): string;
|
|
27
26
|
export declare function siteChunkList(answer: Answered, locator: string): Listed;
|
|
28
|
-
export declare function chunkedHead(listed: ChunkedRoom, entry: TrackedAuthority
|
|
27
|
+
export declare function chunkedHead(listed: ChunkedRoom, entry: TrackedAuthority): Promise<BootstrapResult>;
|
|
29
28
|
export declare function chunkPart(body: ReadableStream<Uint8Array> | null, room: ChunkedRoom, id: string, arriving: ((bytes: number) => void) | undefined): Promise<BootstrapResult>;
|
|
30
|
-
export declare function chunkLister(transport: HouseDoor, most: () => number): {
|
|
29
|
+
export declare function chunkLister(transport: HouseDoor, most: () => number, tracked: (locator: string) => TrackedAuthority | undefined): {
|
|
31
30
|
askAll: (entries: readonly TrackedAuthority[]) => void;
|
|
32
31
|
list: (entry: TrackedAuthority) => Promise<Listed>;
|
|
33
32
|
renew(entry: TrackedAuthority, installing: readonly TrackedAuthority[]): Promise<Listed>;
|
package/dist/chunks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunks.d.ts","sourceRoot":"","sources":["../src/chunks.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,eAAe,EACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,
|
|
1
|
+
{"version":3,"file":"chunks.d.ts","sourceRoot":"","sources":["../src/chunks.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,eAAe,EACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAKL,KAAK,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AAsB,SAAS,CAC7B,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,IAAI,EACvC,IAAI,EAAE,WAAW,EACjB,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,GAC9C,OAAO,CAAC,eAAe,CAAC,CAW1B;AAiBD,wBAAgB,WAAW,CACzB,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,MAAM,MAAM,EAClB,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,gBAAgB,GAAG,SAAS;sBA0CjC,SAAS,gBAAgB,EAAE;kBA0B/B,gBAAgB,KAAG,OAAO,CAAC,MAAM,CAAC;iBAcxC,gBAAgB,cAAc,SAAS,gBAAgB,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;;EAY3F;AAqCD,wBAAsB,UAAU,CAC9B,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,EAChC,IAAI,EAAE,WAAW,EACjB,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,GAC9C,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CA4B5B"}
|
package/dist/chunks.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { paced, ROW_WEIGHT, stepped, } from '@agentshouse/mdruntime';
|
|
2
2
|
import { manifestedModels } from './model.js';
|
|
3
|
-
import { authorityRoot, bootstrapping,
|
|
3
|
+
import { authorityRoot, bootstrapping, documentEntry, } from './read.js';
|
|
4
4
|
import { classifyDoor } from './refusal.js';
|
|
5
5
|
import { failedOn, unusable } from './uncertain.js';
|
|
6
|
+
import { spaceSchemas } from './space-schema.js';
|
|
6
7
|
import { houseDoorRoute } from './transport.js';
|
|
7
8
|
import { readPosition, roomVersion } from './version.js';
|
|
8
9
|
function authorKey(author) {
|
|
@@ -27,27 +28,35 @@ function namesOf(authors) {
|
|
|
27
28
|
}
|
|
28
29
|
return names;
|
|
29
30
|
}
|
|
30
|
-
function
|
|
31
|
+
function schemaText(file, texts) {
|
|
32
|
+
const { space, revision, content } = file;
|
|
33
|
+
if (content !== undefined) {
|
|
34
|
+
if (space !== undefined && revision !== undefined)
|
|
35
|
+
texts.keep(space, revision, content);
|
|
36
|
+
return content;
|
|
37
|
+
}
|
|
38
|
+
return space === undefined || revision === undefined ? undefined : texts.held(space, revision);
|
|
39
|
+
}
|
|
40
|
+
function modelsOf(models, mode, texts) {
|
|
31
41
|
if (!Array.isArray(models))
|
|
32
42
|
return null;
|
|
33
43
|
const files = [];
|
|
34
|
-
const contents = [];
|
|
35
44
|
for (const entry of models) {
|
|
36
|
-
const file =
|
|
37
|
-
|
|
45
|
+
const file = documentEntry(entry, mode);
|
|
46
|
+
const content = file === null ? undefined : schemaText(file, texts);
|
|
47
|
+
if (file === null || content === undefined)
|
|
38
48
|
return null;
|
|
39
|
-
files.push(file);
|
|
40
|
-
contents.push({ path: file.path, content: entry.content });
|
|
49
|
+
files.push({ ...file, content });
|
|
41
50
|
}
|
|
42
|
-
return
|
|
51
|
+
return files;
|
|
43
52
|
}
|
|
44
53
|
export function partId(logEpoch, hash) {
|
|
45
54
|
return `${logEpoch}:${hash}`;
|
|
46
55
|
}
|
|
47
|
-
function chunkedRoom(room, mode) {
|
|
56
|
+
function chunkedRoom(room, mode, texts) {
|
|
48
57
|
const at = readPosition(room);
|
|
49
58
|
const names = mode === 'site' ? new Map() : namesOf(room.authors);
|
|
50
|
-
const models = modelsOf(room.models, mode);
|
|
59
|
+
const models = modelsOf(room.models, mode, texts);
|
|
51
60
|
if (at === null || names === null || models === null || !Array.isArray(room.chunks))
|
|
52
61
|
return null;
|
|
53
62
|
const chunks = new Map();
|
|
@@ -62,7 +71,7 @@ function chunkedRoom(room, mode) {
|
|
|
62
71
|
}
|
|
63
72
|
return { anchor: room.room_ref, ...at, mode, chunks, parts, names, models };
|
|
64
73
|
}
|
|
65
|
-
function listedRoom(room, mode) {
|
|
74
|
+
function listedRoom(room, mode, texts) {
|
|
66
75
|
if (typeof room !== 'object' || room === null)
|
|
67
76
|
return null;
|
|
68
77
|
const held = room;
|
|
@@ -70,15 +79,15 @@ function listedRoom(room, mode) {
|
|
|
70
79
|
return null;
|
|
71
80
|
if (held.ready === false)
|
|
72
81
|
return { kind: 'not-ready' };
|
|
73
|
-
return held.ready === true ? chunkedRoom(held, mode) : null;
|
|
82
|
+
return held.ready === true ? chunkedRoom(held, mode, texts) : null;
|
|
74
83
|
}
|
|
75
84
|
export function siteChunkList(answer, locator) {
|
|
76
85
|
const failure = classifyDoor(answer.status, answer.body, locator);
|
|
77
86
|
if (failure !== null)
|
|
78
87
|
return failure;
|
|
79
|
-
return listedRoom(answer.body, 'site') ?? unusable();
|
|
88
|
+
return listedRoom(answer.body, 'site', spaceSchemas()) ?? unusable();
|
|
80
89
|
}
|
|
81
|
-
export async function chunkedHead(listed, entry
|
|
90
|
+
export async function chunkedHead(listed, entry) {
|
|
82
91
|
if (listed.anchor !== entry.authority)
|
|
83
92
|
return unusable();
|
|
84
93
|
const models = await manifestedModels({
|
|
@@ -86,7 +95,7 @@ export async function chunkedHead(listed, entry, spaces) {
|
|
|
86
95
|
position: listed.position,
|
|
87
96
|
logEpoch: listed.logEpoch,
|
|
88
97
|
models: listed.models,
|
|
89
|
-
}, entry
|
|
98
|
+
}, entry);
|
|
90
99
|
return {
|
|
91
100
|
kind: 'bootstrap',
|
|
92
101
|
roomVersion: roomVersion(listed),
|
|
@@ -119,16 +128,18 @@ function listedRooms(answer) {
|
|
|
119
128
|
if (!Array.isArray(rooms))
|
|
120
129
|
return null;
|
|
121
130
|
const listed = new Map();
|
|
131
|
+
const texts = spaceSchemas();
|
|
122
132
|
for (const room of rooms) {
|
|
123
|
-
const held = listedRoom(room, 'credential');
|
|
133
|
+
const held = listedRoom(room, 'credential', texts);
|
|
124
134
|
if (held === null)
|
|
125
135
|
return null;
|
|
126
136
|
listed.set(room.room_ref, held);
|
|
127
137
|
}
|
|
128
138
|
return listed;
|
|
129
139
|
}
|
|
130
|
-
export function chunkLister(transport, most) {
|
|
140
|
+
export function chunkLister(transport, most, tracked) {
|
|
131
141
|
const asked = new Map();
|
|
142
|
+
const unlisted = new Set();
|
|
132
143
|
function answered(entries, whole) {
|
|
133
144
|
const prefixes = whole ? ['/'] : entries.map((entry) => authorityRoot(entry.handle));
|
|
134
145
|
return transport.door(houseDoorRoute('room-chunks/list'), { prefixes }).then((answer) => {
|
|
@@ -160,24 +171,46 @@ export function chunkLister(transport, most) {
|
|
|
160
171
|
asked.set(entry.authority, { entry, listed });
|
|
161
172
|
}
|
|
162
173
|
}
|
|
174
|
+
function current(entry) {
|
|
175
|
+
return asked.get(entry.authority)?.entry.handle === entry.handle;
|
|
176
|
+
}
|
|
177
|
+
function askTogether(entries) {
|
|
178
|
+
askAll([...new Map(entries.map((one) => [one.authority, one])).values()]);
|
|
179
|
+
}
|
|
180
|
+
function waiting() {
|
|
181
|
+
return [...unlisted].flatMap((locator) => {
|
|
182
|
+
const entry = tracked(locator);
|
|
183
|
+
if (entry === undefined)
|
|
184
|
+
unlisted.delete(locator);
|
|
185
|
+
return entry ?? [];
|
|
186
|
+
});
|
|
187
|
+
}
|
|
163
188
|
function list(entry) {
|
|
164
|
-
|
|
189
|
+
if (!current(entry))
|
|
190
|
+
askTogether([...waiting().filter((one) => !current(one)), entry]);
|
|
191
|
+
const { listed } = asked.get(entry.authority);
|
|
165
192
|
asked.delete(entry.authority);
|
|
166
|
-
return
|
|
193
|
+
return listed.then((answer) => {
|
|
194
|
+
if ('kind' in answer)
|
|
195
|
+
unlisted.add(entry.locator);
|
|
196
|
+
else
|
|
197
|
+
unlisted.delete(entry.locator);
|
|
198
|
+
return answer;
|
|
199
|
+
});
|
|
167
200
|
}
|
|
168
201
|
return {
|
|
169
202
|
askAll,
|
|
170
203
|
list,
|
|
171
204
|
renew(entry, installing) {
|
|
172
|
-
if (!
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
askAll([...due.values()]);
|
|
205
|
+
if (!current(entry)) {
|
|
206
|
+
const listed = [...asked.values()].flatMap((held) => tracked(held.entry.locator) ?? []);
|
|
207
|
+
askTogether([...listed, ...waiting(), ...installing, entry]);
|
|
176
208
|
}
|
|
177
209
|
return list(entry);
|
|
178
210
|
},
|
|
179
211
|
forget() {
|
|
180
212
|
asked.clear();
|
|
213
|
+
unlisted.clear();
|
|
181
214
|
},
|
|
182
215
|
};
|
|
183
216
|
}
|
|
@@ -208,20 +241,14 @@ function chunkEntry(line, room, read) {
|
|
|
208
241
|
return false;
|
|
209
242
|
named = { ...entry, author: { ...author, name } };
|
|
210
243
|
}
|
|
211
|
-
const file =
|
|
244
|
+
const file = documentEntry(named, room.mode);
|
|
212
245
|
if (file === null)
|
|
213
246
|
return false;
|
|
214
247
|
read.files.push(file);
|
|
215
|
-
if (typeof entry.content === 'string')
|
|
216
|
-
read.contents.push({ path: file.path, content: entry.content });
|
|
217
248
|
return true;
|
|
218
249
|
}
|
|
219
250
|
export async function chunkScope(body, room, arriving) {
|
|
220
|
-
const read = {
|
|
221
|
-
files: [],
|
|
222
|
-
contents: [],
|
|
223
|
-
folders: [],
|
|
224
|
-
};
|
|
251
|
+
const read = { files: [], folders: [] };
|
|
225
252
|
const reader = body.getReader();
|
|
226
253
|
const decoder = new TextDecoder();
|
|
227
254
|
const pace = paced();
|
package/dist/discovery.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Capability, DiscoveredRoom, Discovery, Member, ProviderLimit, Retention } from '@agentshouse/mdruntime';
|
|
1
|
+
import type { Capability, DiscoveredRoom, Discovery, Member, ProviderLimit, Retention, RoomList } from '@agentshouse/mdruntime';
|
|
2
2
|
import { type LogPosition } from './version.js';
|
|
3
3
|
export declare const PROVIDER_ACTIONS = "provider-actions";
|
|
4
4
|
export type HouseBounds = {
|
|
@@ -35,11 +35,14 @@ export type HouseDiscoveryDocument = {
|
|
|
35
35
|
bounds: HouseBounds;
|
|
36
36
|
authorities: readonly HouseAuthority[];
|
|
37
37
|
actions: readonly string[];
|
|
38
|
+
roomList: RoomList;
|
|
38
39
|
};
|
|
39
40
|
export type HouseAuthorityChange = {
|
|
40
41
|
member: Member;
|
|
41
42
|
authorities: readonly HouseAuthority[];
|
|
43
|
+
listed: readonly string[];
|
|
42
44
|
left: readonly string[];
|
|
45
|
+
roomList: RoomList;
|
|
43
46
|
};
|
|
44
47
|
export type TrackedAuthority = LogPosition & {
|
|
45
48
|
locator: string;
|
|
@@ -57,14 +60,22 @@ export type HouseSiteDiscovery = {
|
|
|
57
60
|
bounds: HouseBounds;
|
|
58
61
|
authorities: readonly HouseSiteAuthority[];
|
|
59
62
|
};
|
|
60
|
-
|
|
61
|
-
|
|
63
|
+
export declare const ROOM_OWN: {
|
|
64
|
+
readonly room_ref: true;
|
|
65
|
+
readonly room_handle: true;
|
|
66
|
+
readonly name: true;
|
|
67
|
+
readonly position: true;
|
|
68
|
+
readonly created: true;
|
|
69
|
+
readonly archived: true;
|
|
70
|
+
};
|
|
71
|
+
type RoomOwn = keyof typeof ROOM_OWN;
|
|
72
|
+
type Folded<A extends Record<'room_ref' | 'room_handle' | 'name' | 'position', unknown>> = {
|
|
62
73
|
readonly shapes: readonly Omit<A, RoomOwn>[];
|
|
63
|
-
readonly rooms: readonly (Pick<A, RoomOwn
|
|
74
|
+
readonly rooms: readonly (Pick<A, Extract<keyof A, RoomOwn>> & {
|
|
64
75
|
readonly shape: number;
|
|
65
76
|
})[];
|
|
66
77
|
};
|
|
67
|
-
export declare function foldedAuthorities<A extends Record<
|
|
78
|
+
export declare function foldedAuthorities<A extends Record<'room_ref' | 'room_handle' | 'name' | 'position', unknown>>(authorities: readonly A[]): Folded<A>;
|
|
68
79
|
export declare function parseDiscovery(body: unknown): HouseDiscoveryDocument | null;
|
|
69
80
|
export declare function parseAuthorityChange(body: unknown): HouseAuthorityChange | null;
|
|
70
81
|
export declare function parseSiteDiscovery(body: unknown): HouseSiteDiscovery | null;
|
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,
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,SAAS,EAGT,MAAM,EACN,aAAa,EACb,SAAS,EACT,QAAQ,EAGT,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAA6B,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3E,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AAEnD,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,qBAAqB,EAAE,MAAM,CAAC;IAC9B,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,wBAAwB,EAAE,MAAM,CAAC;IACjC,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAE1D,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE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,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,CAKhE;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,sBAAsB,CAAC,SAAS,CAAC,GAAG,SAAS,UAAU,EAAE,CAE9F;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
|
@@ -15,6 +15,13 @@ const BOUND_KEYS = [
|
|
|
15
15
|
];
|
|
16
16
|
const OPERATION_KEYS = ['write', 'erase'];
|
|
17
17
|
const ACCESS_LEVELS = ['search', 'open', 'keep'];
|
|
18
|
+
const ROOM_ACCESS = [
|
|
19
|
+
'owner',
|
|
20
|
+
'manage',
|
|
21
|
+
'write',
|
|
22
|
+
'read',
|
|
23
|
+
'public',
|
|
24
|
+
];
|
|
18
25
|
function stringList(value) {
|
|
19
26
|
if (!Array.isArray(value))
|
|
20
27
|
return null;
|
|
@@ -109,6 +116,89 @@ function parseAuthority(value) {
|
|
|
109
116
|
...at,
|
|
110
117
|
};
|
|
111
118
|
}
|
|
119
|
+
function parseOwner(value) {
|
|
120
|
+
if (typeof value !== 'object' || value === null)
|
|
121
|
+
return null;
|
|
122
|
+
const { user, name } = value;
|
|
123
|
+
return typeof user === 'string' && typeof name === 'string' ? { user, name } : null;
|
|
124
|
+
}
|
|
125
|
+
function parseSpaceRef(value) {
|
|
126
|
+
if (typeof value !== 'object' || value === null)
|
|
127
|
+
return null;
|
|
128
|
+
const { space_ref, name } = value;
|
|
129
|
+
return typeof space_ref === 'string' && typeof name === 'string' ? { space_ref, name } : null;
|
|
130
|
+
}
|
|
131
|
+
function parseListedRoom(value) {
|
|
132
|
+
if (typeof value !== 'object' || value === null)
|
|
133
|
+
return null;
|
|
134
|
+
const held = value;
|
|
135
|
+
const level = ACCESS_LEVELS.find((one) => one === held.level);
|
|
136
|
+
const access = ROOM_ACCESS.find((one) => one === held.access);
|
|
137
|
+
const owner = parseOwner(held.owner);
|
|
138
|
+
const space = held.space === undefined ? undefined : parseSpaceRef(held.space);
|
|
139
|
+
if (typeof held.room_ref !== 'string' ||
|
|
140
|
+
held.room_ref.length === 0 ||
|
|
141
|
+
typeof held.room_handle !== 'string' ||
|
|
142
|
+
held.room_handle.length === 0 ||
|
|
143
|
+
typeof held.name !== 'string' ||
|
|
144
|
+
typeof held.created !== 'string' ||
|
|
145
|
+
(held.archived !== undefined && typeof held.archived !== 'string') ||
|
|
146
|
+
(held.exportable !== undefined && held.exportable !== true) ||
|
|
147
|
+
level === undefined ||
|
|
148
|
+
access === undefined ||
|
|
149
|
+
owner === null ||
|
|
150
|
+
space === null)
|
|
151
|
+
return null;
|
|
152
|
+
return {
|
|
153
|
+
room_ref: held.room_ref,
|
|
154
|
+
room_handle: held.room_handle,
|
|
155
|
+
name: held.name,
|
|
156
|
+
level,
|
|
157
|
+
access,
|
|
158
|
+
owner,
|
|
159
|
+
created: held.created,
|
|
160
|
+
...(typeof held.archived === 'string' ? { archived: held.archived } : {}),
|
|
161
|
+
...(held.exportable === true ? { exportable: true } : {}),
|
|
162
|
+
...(space === undefined ? {} : { space }),
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
function parseListedSpace(value) {
|
|
166
|
+
const space = parseSpaceRef(value);
|
|
167
|
+
if (space === null)
|
|
168
|
+
return null;
|
|
169
|
+
const held = value;
|
|
170
|
+
const owner = parseOwner(held.owner);
|
|
171
|
+
if (owner === null ||
|
|
172
|
+
typeof held.created !== 'string' ||
|
|
173
|
+
(held.manages !== undefined && held.manages !== true))
|
|
174
|
+
return null;
|
|
175
|
+
return {
|
|
176
|
+
...space,
|
|
177
|
+
owner,
|
|
178
|
+
created: held.created,
|
|
179
|
+
...(held.manages === true ? { manages: true } : {}),
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
function parsedAll(value, parse) {
|
|
183
|
+
if (!Array.isArray(value))
|
|
184
|
+
return null;
|
|
185
|
+
const parsed = [];
|
|
186
|
+
for (const entry of value) {
|
|
187
|
+
const one = parse(entry);
|
|
188
|
+
if (one === null)
|
|
189
|
+
return null;
|
|
190
|
+
parsed.push(one);
|
|
191
|
+
}
|
|
192
|
+
return parsed;
|
|
193
|
+
}
|
|
194
|
+
function parseRoomList(authorities, listed, spaces) {
|
|
195
|
+
const held = parsedAll(authorities, parseListedRoom);
|
|
196
|
+
const only = parsedAll(listed, parseListedRoom);
|
|
197
|
+
const shown = parsedAll(spaces, parseListedSpace);
|
|
198
|
+
if (held === null || only === null || shown === null)
|
|
199
|
+
return null;
|
|
200
|
+
return { rooms: [...held, ...only], spaces: shown, listed: only };
|
|
201
|
+
}
|
|
112
202
|
function parseAuthorities(value) {
|
|
113
203
|
if (!Array.isArray(value))
|
|
114
204
|
return null;
|
|
@@ -121,17 +211,31 @@ function parseAuthorities(value) {
|
|
|
121
211
|
}
|
|
122
212
|
return authorities;
|
|
123
213
|
}
|
|
214
|
+
export const ROOM_OWN = {
|
|
215
|
+
room_ref: true,
|
|
216
|
+
room_handle: true,
|
|
217
|
+
name: true,
|
|
218
|
+
position: true,
|
|
219
|
+
created: true,
|
|
220
|
+
archived: true,
|
|
221
|
+
};
|
|
222
|
+
function ownKey(key) {
|
|
223
|
+
return Object.hasOwn(ROOM_OWN, key);
|
|
224
|
+
}
|
|
124
225
|
export function foldedAuthorities(authorities) {
|
|
125
226
|
const shapes = [];
|
|
126
227
|
const known = new Map();
|
|
127
|
-
const rooms = authorities.map((
|
|
228
|
+
const rooms = authorities.map((authority) => {
|
|
229
|
+
const entries = Object.entries(authority);
|
|
230
|
+
const shape = Object.fromEntries(entries.filter(([key]) => !ownKey(key)));
|
|
231
|
+
const own = Object.fromEntries(entries.filter(([key]) => ownKey(key)));
|
|
128
232
|
const key = JSON.stringify(shape);
|
|
129
233
|
let held = known.get(key);
|
|
130
234
|
if (held === undefined) {
|
|
131
235
|
held = shapes.push(shape) - 1;
|
|
132
236
|
known.set(key, held);
|
|
133
237
|
}
|
|
134
|
-
return {
|
|
238
|
+
return { ...own, shape: held };
|
|
135
239
|
});
|
|
136
240
|
return { shapes, rooms };
|
|
137
241
|
}
|
|
@@ -165,8 +269,18 @@ export function parseDiscovery(body) {
|
|
|
165
269
|
new Set(actions).size !== actions.length ||
|
|
166
270
|
actions.some((name) => name.length === 0))
|
|
167
271
|
return null;
|
|
168
|
-
const
|
|
169
|
-
|
|
272
|
+
const entries = unfolded(held.shapes, held.rooms);
|
|
273
|
+
const authorities = parseAuthorities(entries);
|
|
274
|
+
const listing = parseRoomList(entries, held.listed, held.spaces);
|
|
275
|
+
if (authorities === null || listing === null)
|
|
276
|
+
return null;
|
|
277
|
+
return {
|
|
278
|
+
member,
|
|
279
|
+
bounds,
|
|
280
|
+
authorities,
|
|
281
|
+
actions,
|
|
282
|
+
roomList: { rooms: listing.rooms, spaces: listing.spaces },
|
|
283
|
+
};
|
|
170
284
|
}
|
|
171
285
|
export function parseAuthorityChange(body) {
|
|
172
286
|
if (typeof body !== 'object' || body === null)
|
|
@@ -174,10 +288,17 @@ export function parseAuthorityChange(body) {
|
|
|
174
288
|
const held = body;
|
|
175
289
|
const member = parseMember(held.member);
|
|
176
290
|
const authorities = parseAuthorities(held.authorities);
|
|
291
|
+
const listing = parseRoomList(held.authorities, held.listed, held.spaces);
|
|
177
292
|
const left = stringList(held.left);
|
|
178
|
-
if (member === null || authorities === null || left === null)
|
|
293
|
+
if (member === null || authorities === null || listing === null || left === null)
|
|
179
294
|
return null;
|
|
180
|
-
return {
|
|
295
|
+
return {
|
|
296
|
+
member,
|
|
297
|
+
authorities,
|
|
298
|
+
listed: listing.listed.map((room) => room.room_ref),
|
|
299
|
+
left,
|
|
300
|
+
roomList: { rooms: listing.rooms, spaces: listing.spaces },
|
|
301
|
+
};
|
|
181
302
|
}
|
|
182
303
|
function parseSiteAuthority(value) {
|
|
183
304
|
if (typeof value !== 'object' || value === null)
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
export { createAgentsHouseAdapter, type AgentsHouseAdapterOptions } from './adapter.js';
|
|
2
|
-
export { foldedAuthorities } from './discovery.js';
|
|
2
|
+
export { foldedAuthorities, ROOM_OWN } from './discovery.js';
|
|
3
3
|
export { finishedUpload, houseUpload, type HouseUpload } from './upload.js';
|
|
4
4
|
export { houseAction, type HouseActDoor } from './actions.js';
|
|
5
5
|
export { HISTORY_PAGE } from './history.js';
|
|
6
6
|
export { answeredFailure } from './refusal.js';
|
|
7
|
+
export { documentEntry, type HouseManifestFile } from './read.js';
|
|
7
8
|
export { houseParts, type ChangeMapping } from './write.js';
|
|
8
|
-
export {
|
|
9
|
-
export { admittedPath, APP_PREFERENCES_HOME, AUTHORED_SEGMENT, AUTHORED_SEGMENT_MAX_CHARS, GENERATED_PROVENANCE, GENERATED_REVISIONS, LOCAL_COPY_MANIFEST, LOCAL_COPY_ROOT_NAMES, RESERVED_DERIVED, WHOLE_ESCAPED_NAMES, } from './authored-path.js';
|
|
10
|
-
export { HOUSE_MODEL_DECLARATION, HOUSE_MODEL_TYPES, HOUSE_TYPED_PATHS, type HouseDocumentFields, type HouseModelType, } from './house-model.js';
|
|
11
|
-
export { CROCKFORD_ALPHABET, CROCKFORD_CHARACTER, CROCKFORD_LEADING_CHARACTER, } from './crockford.js';
|
|
12
|
-
export { HOUSE_NAMEABLE_ROOM_TYPES, HOUSE_ROOM_TYPES, INBOX_CHANNEL_KINDS, type InboxChannelKind, } from './room-types.js';
|
|
9
|
+
export { admittedPath, AUTHORED_SEGMENT, AUTHORED_SEGMENT_MAX_CHARS, GENERATED_PROVENANCE, GENERATED_REVISIONS, LOCAL_COPY_MANIFEST, LOCAL_COPY_ROOT_NAMES, RESERVED_DERIVED, WHOLE_ESCAPED_NAMES, } from './authored-path.js';
|
|
13
10
|
export { HOUSE_RUNTIME_READS, houseDoorRoute, houseSiteRoute, type HouseRuntimeAct, type HouseRuntimeFrame, } from './transport.js';
|
|
14
11
|
export type { HouseByteTransfer, HouseBytesAnswer, HouseClosing, HouseDoorAnswer, HouseHeldRoom, HouseOpening, HouseStream, HouseStreamEntry, HouseStreamFrame, HouseSiteTransport, HouseTransport, } from './transport.js';
|
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,iBAAiB,EAAE,MAAM,gBAAgB,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,iBAAiB,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,0BAA0B,EAC1B,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,iBAAiB,GACvB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,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"}
|