@agentshouse/mdruntime-adapter 0.1.0-ca47c2e51c195 → 0.1.0-ca5b5175ac20a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/actions.d.ts +9 -0
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +179 -5
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +109 -108
- package/dist/authored-path.d.ts +54 -2
- package/dist/authored-path.d.ts.map +1 -1
- package/dist/authored-path.js +142 -10
- package/dist/chunks.d.ts +2 -3
- package/dist/chunks.d.ts.map +1 -1
- package/dist/chunks.js +47 -35
- package/dist/discovery.d.ts +25 -5
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +169 -21
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -5
- 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 +11 -24
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +74 -47
- package/dist/refusal.d.ts +4 -1
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +11 -0
- package/dist/renamed.d.ts +10 -0
- package/dist/renamed.d.ts.map +1 -0
- package/dist/renamed.js +20 -0
- package/dist/room-query.d.ts +4 -0
- package/dist/room-query.d.ts.map +1 -0
- package/dist/room-query.js +63 -0
- package/dist/session-content/check.d.ts +4 -2
- package/dist/session-content/index.d.ts +3 -4
- package/dist/session-content/parts.d.ts +14 -87
- package/dist/session-content/state.d.ts +21 -23
- package/dist/session-content/turn.d.ts +82 -258
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +44 -10
- package/dist/space-schema.d.ts +1 -1
- package/dist/space-schema.d.ts.map +1 -1
- package/dist/space-schema.js +2 -9
- package/dist/stream.d.ts +4 -4
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +114 -53
- package/dist/transport.d.ts +62 -11
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +46 -8
- package/dist/upload.d.ts +4 -0
- package/dist/upload.d.ts.map +1 -1
- package/dist/upload.js +41 -0
- package/dist/write.d.ts +3 -8
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +72 -92
- package/package.json +4 -4
- package/dist/session-content/bounds.d.ts +0 -7
|
@@ -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,
|
|
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,mBAAmB,WAAW,CAAC;AAI5C,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAKlD,CAAC;AAEF,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAI3C,eAAO,MAAM,kBAAkB;aAC7B,iBAAiB,EAAE,YAAY;aAC/B,iBAAiB,EAAE,IAAI;aACvB,WAAW,EAAE,IAAI;aACjB,YAAY,EAAE,GAAG;aACjB,QAAQ,YAAG,MAAM,EAAE,OAAO;aAC1B,YAAY;aAUZ,cAAc;aACd,YAAY;aACZ,YAAY;CACJ,CAAC;AAEX,MAAM,MAAM,WAAW,GACnB;IAAE,QAAQ,CAAC,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B,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAU5D;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAKlD;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAE7D;AAyCD,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,SAAI,EAAE,IAAI,SAAK,GAAG,MAAM,CAUrE"}
|
package/dist/authored-path.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { APP_PREFERENCES_HOME, APP_REFERENCE_PATTERN } from '@agentshouse/mdmodel';
|
|
1
|
+
import { APP_PREFERENCES_HOME, APP_REFERENCE_PATTERN, foldedName } from '@agentshouse/mdmodel';
|
|
2
2
|
export const GENERATED_PROVENANCE = '_provenance';
|
|
3
3
|
export const GENERATED_REVISIONS = '_revisions';
|
|
4
4
|
export const RESERVED_DERIVED = '_derived';
|
|
@@ -9,26 +9,158 @@ export const WHOLE_ESCAPED_NAMES = [
|
|
|
9
9
|
GENERATED_REVISIONS,
|
|
10
10
|
RESERVED_DERIVED,
|
|
11
11
|
];
|
|
12
|
-
export const AUTHORED_SEGMENT_MAX_CHARS = 255;
|
|
13
|
-
const REFUSED_SEGMENTS = [
|
|
14
|
-
...WHOLE_ESCAPED_NAMES.map((name) => name.split('.').join('[.]')),
|
|
15
|
-
'[.][Gg][Ii][Tt][.]*',
|
|
16
|
-
].join('|');
|
|
17
|
-
export const AUTHORED_SEGMENT = new RegExp(`^(?!(?:${REFUSED_SEGMENTS})(?:/|$))[A-Za-z0-9._][A-Za-z0-9._-]{0,${AUTHORED_SEGMENT_MAX_CHARS - 1}}$`);
|
|
18
12
|
export const LOCAL_COPY_MANIFEST = '.house';
|
|
13
|
+
const ROOM_FOLDER_FILES = ['AGENTS.md', 'CLAUDE.md'];
|
|
19
14
|
export const LOCAL_COPY_ROOT_NAMES = [
|
|
20
15
|
'.gitignore',
|
|
21
16
|
'.ignore',
|
|
22
17
|
LOCAL_COPY_MANIFEST,
|
|
18
|
+
...ROOM_FOLDER_FILES,
|
|
23
19
|
];
|
|
20
|
+
export const AUTHORED_NAME_MAX_BYTES = 255;
|
|
21
|
+
export const AUTHORED_PATH_MAX_BYTES = 768;
|
|
22
|
+
const FITTED_STEM = 'file';
|
|
23
|
+
export const AUTHORED_NAME_RULE = {
|
|
24
|
+
refusedCharacters: '/\\:*?"<>|',
|
|
25
|
+
controlCharacters: 'Cc',
|
|
26
|
+
refusedEnds: ' .',
|
|
27
|
+
refusedStart: '-',
|
|
28
|
+
gitNames: ['.git', 'git~1'],
|
|
29
|
+
windowsNames: [
|
|
30
|
+
'CON',
|
|
31
|
+
'PRN',
|
|
32
|
+
'AUX',
|
|
33
|
+
'NUL',
|
|
34
|
+
...['1', '2', '3', '4', '5', '6', '7', '8', '9', '¹', '²', '³'].flatMap((digit) => [
|
|
35
|
+
`COM${digit}`,
|
|
36
|
+
`LPT${digit}`,
|
|
37
|
+
]),
|
|
38
|
+
],
|
|
39
|
+
generatedNames: [GENERATED_PROVENANCE, GENERATED_REVISIONS, RESERVED_DERIVED],
|
|
40
|
+
nameMaxBytes: AUTHORED_NAME_MAX_BYTES,
|
|
41
|
+
pathMaxBytes: AUTHORED_PATH_MAX_BYTES,
|
|
42
|
+
};
|
|
43
|
+
const LONE_SURROGATE = /\p{Cs}/u;
|
|
44
|
+
const LONE_SURROGATES = /\p{Cs}/gu;
|
|
45
|
+
const CONTROL = /\p{Cc}/u;
|
|
46
|
+
const MAC_IGNORED = /[\u200C-\u200F\u202A-\u202E\u206A-\u206F\uFEFF]/gu;
|
|
47
|
+
const FOLDED_GIT_NAMES = new Set(AUTHORED_NAME_RULE.gitNames.map(foldedName));
|
|
48
|
+
const FOLDED_WINDOWS_NAMES = new Set(AUTHORED_NAME_RULE.windowsNames.map(foldedName));
|
|
49
|
+
const FOLDED_GENERATED_NAMES = new Set(AUTHORED_NAME_RULE.generatedNames.map(foldedName));
|
|
50
|
+
const FOLDED_ROOT_NAMES = new Set(LOCAL_COPY_ROOT_NAMES.map(foldedName));
|
|
51
|
+
export function utf8Bytes(text) {
|
|
52
|
+
let bytes = 0;
|
|
53
|
+
for (const point of text) {
|
|
54
|
+
const code = point.codePointAt(0);
|
|
55
|
+
bytes += code < 0x80 ? 1 : code < 0x800 ? 2 : code < 0x10000 ? 3 : 4;
|
|
56
|
+
}
|
|
57
|
+
return bytes;
|
|
58
|
+
}
|
|
59
|
+
function refusedCharacter(point) {
|
|
60
|
+
return AUTHORED_NAME_RULE.refusedCharacters.includes(point) || CONTROL.test(point);
|
|
61
|
+
}
|
|
62
|
+
function windowsName(name) {
|
|
63
|
+
const dot = name.indexOf('.');
|
|
64
|
+
const base = dot < 0 ? name : name.slice(0, dot);
|
|
65
|
+
return FOLDED_WINDOWS_NAMES.has(foldedName(base)) ? base : null;
|
|
66
|
+
}
|
|
67
|
+
export function nameRefusal(name) {
|
|
68
|
+
if (LONE_SURROGATE.test(name))
|
|
69
|
+
return { rule: 'unicode' };
|
|
70
|
+
for (const point of name)
|
|
71
|
+
if (refusedCharacter(point))
|
|
72
|
+
return { rule: 'character', character: point };
|
|
73
|
+
if (name === '')
|
|
74
|
+
return { rule: 'empty' };
|
|
75
|
+
if (name === '.' || name === '..')
|
|
76
|
+
return { rule: 'dots' };
|
|
77
|
+
const last = name.at(-1);
|
|
78
|
+
if (AUTHORED_NAME_RULE.refusedEnds.includes(last))
|
|
79
|
+
return { rule: 'end', character: last };
|
|
80
|
+
if (FOLDED_GIT_NAMES.has(foldedName(name.replace(MAC_IGNORED, ''))))
|
|
81
|
+
return { rule: 'git' };
|
|
82
|
+
const reserved = windowsName(name);
|
|
83
|
+
if (reserved !== null)
|
|
84
|
+
return { rule: 'windows', reserved };
|
|
85
|
+
const bytes = utf8Bytes(name);
|
|
86
|
+
if (bytes > AUTHORED_NAME_MAX_BYTES)
|
|
87
|
+
return { rule: 'name_bytes', bytes };
|
|
88
|
+
if (name.startsWith(AUTHORED_NAME_RULE.refusedStart))
|
|
89
|
+
return { rule: 'start' };
|
|
90
|
+
if (FOLDED_GENERATED_NAMES.has(foldedName(name)))
|
|
91
|
+
return { rule: 'generated' };
|
|
92
|
+
if (name.normalize('NFC') !== name)
|
|
93
|
+
return { rule: 'nfc' };
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
24
96
|
function appPreferences(path) {
|
|
25
97
|
return (path.endsWith('.md') &&
|
|
26
98
|
APP_REFERENCE_PATTERN.test(path.slice(APP_PREFERENCES_HOME.length + 1, -3)));
|
|
27
99
|
}
|
|
28
|
-
export function
|
|
100
|
+
export function pathRefusal(path) {
|
|
29
101
|
const names = path.split('/');
|
|
30
102
|
const [root] = names;
|
|
31
|
-
|
|
32
|
-
|
|
103
|
+
if (FOLDED_ROOT_NAMES.has(foldedName(root)))
|
|
104
|
+
return { rule: 'root', name: root };
|
|
105
|
+
for (const name of names) {
|
|
106
|
+
const refused = nameRefusal(name);
|
|
107
|
+
if (refused !== null)
|
|
108
|
+
return { ...refused, name };
|
|
109
|
+
}
|
|
110
|
+
const bytes = utf8Bytes(path);
|
|
111
|
+
return bytes > AUTHORED_PATH_MAX_BYTES ? { rule: 'path_bytes', bytes } : null;
|
|
112
|
+
}
|
|
113
|
+
export function admittedPath(path) {
|
|
114
|
+
return (pathRefusal(path) === null &&
|
|
33
115
|
(!path.startsWith(`${APP_PREFERENCES_HOME}/`) || appPreferences(path)));
|
|
34
116
|
}
|
|
117
|
+
export function sameName(left, right) {
|
|
118
|
+
return foldedName(left) === foldedName(right);
|
|
119
|
+
}
|
|
120
|
+
function cutToBytes(text, bytes) {
|
|
121
|
+
let kept = '';
|
|
122
|
+
let used = 0;
|
|
123
|
+
for (const point of text) {
|
|
124
|
+
used += utf8Bytes(point);
|
|
125
|
+
if (used > bytes)
|
|
126
|
+
break;
|
|
127
|
+
kept += point;
|
|
128
|
+
}
|
|
129
|
+
return kept;
|
|
130
|
+
}
|
|
131
|
+
function trimmedEnd(text) {
|
|
132
|
+
let end = text.length;
|
|
133
|
+
while (end > 0 && AUTHORED_NAME_RULE.refusedEnds.includes(text[end - 1]))
|
|
134
|
+
end -= 1;
|
|
135
|
+
return text.slice(0, end);
|
|
136
|
+
}
|
|
137
|
+
function trimmedStart(text) {
|
|
138
|
+
let start = 0;
|
|
139
|
+
while (start < text.length && text[start] === AUTHORED_NAME_RULE.refusedStart)
|
|
140
|
+
start += 1;
|
|
141
|
+
return text.slice(start);
|
|
142
|
+
}
|
|
143
|
+
function nameParts(name) {
|
|
144
|
+
const dot = name.lastIndexOf('.');
|
|
145
|
+
return dot <= 0
|
|
146
|
+
? { stem: name, extension: '' }
|
|
147
|
+
: { stem: name.slice(0, dot), extension: name.slice(dot) };
|
|
148
|
+
}
|
|
149
|
+
function fitted(stem, extension, tail, count) {
|
|
150
|
+
const suffix = count > 1 ? `-${count}` : '';
|
|
151
|
+
const room = AUTHORED_NAME_MAX_BYTES - utf8Bytes(suffix);
|
|
152
|
+
const whole = utf8Bytes(`${extension}${tail}`) < room;
|
|
153
|
+
const kept = whole ? `${extension}${tail}` : tail;
|
|
154
|
+
const cut = cutToBytes(whole ? stem : `${stem}${extension}`, room - utf8Bytes(kept));
|
|
155
|
+
return `${suffix === '' && kept === '' ? trimmedEnd(cut) : cut}${suffix}${kept}`;
|
|
156
|
+
}
|
|
157
|
+
export function fittedName(name, count = 1, tail = '') {
|
|
158
|
+
let replaced = '';
|
|
159
|
+
for (const point of name.replace(LONE_SURROGATES, '\uFFFD').normalize('NFC'))
|
|
160
|
+
replaced += refusedCharacter(point) ? '-' : point;
|
|
161
|
+
const { stem: typed, extension } = nameParts(trimmedEnd(replaced));
|
|
162
|
+
const stem = trimmedStart(typed);
|
|
163
|
+
const named = stem !== '' && nameRefusal(fitted(stem, extension, tail, 1)) === null ? stem : FITTED_STEM;
|
|
164
|
+
const counted = fitted(named, extension, tail, count);
|
|
165
|
+
return nameRefusal(counted) === null ? counted : fitted(FITTED_STEM, extension, tail, count);
|
|
166
|
+
}
|
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;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
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
6
|
import { spaceSchemas } from './space-schema.js';
|
|
@@ -28,32 +28,27 @@ function namesOf(authors) {
|
|
|
28
28
|
}
|
|
29
29
|
return names;
|
|
30
30
|
}
|
|
31
|
-
function schemaText(
|
|
32
|
-
const { space, revision } = file;
|
|
33
|
-
if (
|
|
31
|
+
function schemaText(file, texts) {
|
|
32
|
+
const { space, revision, content } = file;
|
|
33
|
+
if (content !== undefined) {
|
|
34
34
|
if (space !== undefined && revision !== undefined)
|
|
35
|
-
texts.keep(space, revision,
|
|
36
|
-
return
|
|
35
|
+
texts.keep(space, revision, content);
|
|
36
|
+
return content;
|
|
37
37
|
}
|
|
38
38
|
return space === undefined || revision === undefined ? undefined : texts.held(space, revision);
|
|
39
39
|
}
|
|
40
|
-
function answerTexts() {
|
|
41
|
-
return spaceSchemas(Number.POSITIVE_INFINITY);
|
|
42
|
-
}
|
|
43
40
|
function modelsOf(models, mode, texts) {
|
|
44
41
|
if (!Array.isArray(models))
|
|
45
42
|
return null;
|
|
46
43
|
const files = [];
|
|
47
|
-
const contents = [];
|
|
48
44
|
for (const entry of models) {
|
|
49
|
-
const file =
|
|
50
|
-
const content = file === null ? undefined : schemaText(
|
|
45
|
+
const file = documentEntry(entry, mode);
|
|
46
|
+
const content = file === null ? undefined : schemaText(file, texts);
|
|
51
47
|
if (file === null || content === undefined)
|
|
52
48
|
return null;
|
|
53
|
-
files.push(file);
|
|
54
|
-
contents.push({ path: file.path, content });
|
|
49
|
+
files.push({ ...file, content });
|
|
55
50
|
}
|
|
56
|
-
return
|
|
51
|
+
return files;
|
|
57
52
|
}
|
|
58
53
|
export function partId(logEpoch, hash) {
|
|
59
54
|
return `${logEpoch}:${hash}`;
|
|
@@ -90,9 +85,9 @@ export function siteChunkList(answer, locator) {
|
|
|
90
85
|
const failure = classifyDoor(answer.status, answer.body, locator);
|
|
91
86
|
if (failure !== null)
|
|
92
87
|
return failure;
|
|
93
|
-
return listedRoom(answer.body, 'site',
|
|
88
|
+
return listedRoom(answer.body, 'site', spaceSchemas()) ?? unusable();
|
|
94
89
|
}
|
|
95
|
-
export async function chunkedHead(listed, entry
|
|
90
|
+
export async function chunkedHead(listed, entry) {
|
|
96
91
|
if (listed.anchor !== entry.authority)
|
|
97
92
|
return unusable();
|
|
98
93
|
const models = await manifestedModels({
|
|
@@ -100,7 +95,7 @@ export async function chunkedHead(listed, entry, spaces) {
|
|
|
100
95
|
position: listed.position,
|
|
101
96
|
logEpoch: listed.logEpoch,
|
|
102
97
|
models: listed.models,
|
|
103
|
-
}, entry
|
|
98
|
+
}, entry);
|
|
104
99
|
return {
|
|
105
100
|
kind: 'bootstrap',
|
|
106
101
|
roomVersion: roomVersion(listed),
|
|
@@ -108,7 +103,7 @@ export async function chunkedHead(listed, entry, spaces) {
|
|
|
108
103
|
facts: {},
|
|
109
104
|
revisions: {},
|
|
110
105
|
changes: {},
|
|
111
|
-
|
|
106
|
+
attachments: {},
|
|
112
107
|
parts: listed.parts,
|
|
113
108
|
...(models === undefined ? {} : { models }),
|
|
114
109
|
};
|
|
@@ -133,7 +128,7 @@ function listedRooms(answer) {
|
|
|
133
128
|
if (!Array.isArray(rooms))
|
|
134
129
|
return null;
|
|
135
130
|
const listed = new Map();
|
|
136
|
-
const texts =
|
|
131
|
+
const texts = spaceSchemas();
|
|
137
132
|
for (const room of rooms) {
|
|
138
133
|
const held = listedRoom(room, 'credential', texts);
|
|
139
134
|
if (held === null)
|
|
@@ -142,8 +137,9 @@ function listedRooms(answer) {
|
|
|
142
137
|
}
|
|
143
138
|
return listed;
|
|
144
139
|
}
|
|
145
|
-
export function chunkLister(transport, most) {
|
|
140
|
+
export function chunkLister(transport, most, tracked) {
|
|
146
141
|
const asked = new Map();
|
|
142
|
+
const unlisted = new Set();
|
|
147
143
|
function answered(entries, whole) {
|
|
148
144
|
const prefixes = whole ? ['/'] : entries.map((entry) => authorityRoot(entry.handle));
|
|
149
145
|
return transport.door(houseDoorRoute('room-chunks/list'), { prefixes }).then((answer) => {
|
|
@@ -175,24 +171,46 @@ export function chunkLister(transport, most) {
|
|
|
175
171
|
asked.set(entry.authority, { entry, listed });
|
|
176
172
|
}
|
|
177
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
|
+
}
|
|
178
188
|
function list(entry) {
|
|
179
|
-
|
|
189
|
+
if (!current(entry))
|
|
190
|
+
askTogether([...waiting().filter((one) => !current(one)), entry]);
|
|
191
|
+
const { listed } = asked.get(entry.authority);
|
|
180
192
|
asked.delete(entry.authority);
|
|
181
|
-
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
|
+
});
|
|
182
200
|
}
|
|
183
201
|
return {
|
|
184
202
|
askAll,
|
|
185
203
|
list,
|
|
186
204
|
renew(entry, installing) {
|
|
187
|
-
if (!
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
askAll([...due.values()]);
|
|
205
|
+
if (!current(entry)) {
|
|
206
|
+
const listed = [...asked.values()].flatMap((held) => tracked(held.entry.locator) ?? []);
|
|
207
|
+
askTogether([...listed, ...waiting(), ...installing, entry]);
|
|
191
208
|
}
|
|
192
209
|
return list(entry);
|
|
193
210
|
},
|
|
194
211
|
forget() {
|
|
195
212
|
asked.clear();
|
|
213
|
+
unlisted.clear();
|
|
196
214
|
},
|
|
197
215
|
};
|
|
198
216
|
}
|
|
@@ -223,20 +241,14 @@ function chunkEntry(line, room, read) {
|
|
|
223
241
|
return false;
|
|
224
242
|
named = { ...entry, author: { ...author, name } };
|
|
225
243
|
}
|
|
226
|
-
const file =
|
|
244
|
+
const file = documentEntry(named, room.mode);
|
|
227
245
|
if (file === null)
|
|
228
246
|
return false;
|
|
229
247
|
read.files.push(file);
|
|
230
|
-
if (typeof entry.content === 'string')
|
|
231
|
-
read.contents.push({ path: file.path, content: entry.content });
|
|
232
248
|
return true;
|
|
233
249
|
}
|
|
234
250
|
export async function chunkScope(body, room, arriving) {
|
|
235
|
-
const read = {
|
|
236
|
-
files: [],
|
|
237
|
-
contents: [],
|
|
238
|
-
folders: [],
|
|
239
|
-
};
|
|
251
|
+
const read = { files: [], folders: [] };
|
|
240
252
|
const reader = body.getReader();
|
|
241
253
|
const decoder = new TextDecoder();
|
|
242
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 = {
|
|
@@ -12,6 +12,8 @@ export type HouseBounds = {
|
|
|
12
12
|
max_prefixes: number;
|
|
13
13
|
change_retention_seconds: number;
|
|
14
14
|
max_move_documents?: number;
|
|
15
|
+
max_indexed_fields?: number;
|
|
16
|
+
max_indexed_text_length?: number;
|
|
15
17
|
};
|
|
16
18
|
export type HouseOperations = {
|
|
17
19
|
write: readonly string[];
|
|
@@ -32,14 +34,19 @@ export type HouseAuthority = LogPosition & {
|
|
|
32
34
|
};
|
|
33
35
|
export type HouseDiscoveryDocument = {
|
|
34
36
|
member: Member;
|
|
37
|
+
timeZone: string | null;
|
|
35
38
|
bounds: HouseBounds;
|
|
36
39
|
authorities: readonly HouseAuthority[];
|
|
37
40
|
actions: readonly string[];
|
|
41
|
+
roomList: RoomList;
|
|
38
42
|
};
|
|
39
43
|
export type HouseAuthorityChange = {
|
|
40
44
|
member: Member;
|
|
45
|
+
timeZone: string | null;
|
|
41
46
|
authorities: readonly HouseAuthority[];
|
|
47
|
+
listed: readonly string[];
|
|
42
48
|
left: readonly string[];
|
|
49
|
+
roomList: RoomList;
|
|
43
50
|
};
|
|
44
51
|
export type TrackedAuthority = LogPosition & {
|
|
45
52
|
locator: string;
|
|
@@ -53,18 +60,31 @@ export type HouseSiteAuthority = LogPosition & {
|
|
|
53
60
|
roomHandle: string;
|
|
54
61
|
schema: string;
|
|
55
62
|
};
|
|
63
|
+
export type HouseSiteQueried = {
|
|
64
|
+
roomRef: string;
|
|
65
|
+
roomHandle: string;
|
|
66
|
+
};
|
|
56
67
|
export type HouseSiteDiscovery = {
|
|
57
68
|
bounds: HouseBounds;
|
|
58
69
|
authorities: readonly HouseSiteAuthority[];
|
|
70
|
+
queriesOnly: readonly HouseSiteQueried[];
|
|
71
|
+
};
|
|
72
|
+
export declare const ROOM_OWN: {
|
|
73
|
+
readonly room_ref: true;
|
|
74
|
+
readonly room_handle: true;
|
|
75
|
+
readonly name: true;
|
|
76
|
+
readonly position: true;
|
|
77
|
+
readonly created: true;
|
|
78
|
+
readonly archived: true;
|
|
59
79
|
};
|
|
60
|
-
type RoomOwn =
|
|
61
|
-
type Folded<A extends Record<
|
|
80
|
+
type RoomOwn = keyof typeof ROOM_OWN;
|
|
81
|
+
type Folded<A extends Record<'room_ref' | 'room_handle' | 'name' | 'position', unknown>> = {
|
|
62
82
|
readonly shapes: readonly Omit<A, RoomOwn>[];
|
|
63
|
-
readonly rooms: readonly (Pick<A, RoomOwn
|
|
83
|
+
readonly rooms: readonly (Pick<A, Extract<keyof A, RoomOwn>> & {
|
|
64
84
|
readonly shape: number;
|
|
65
85
|
})[];
|
|
66
86
|
};
|
|
67
|
-
export declare function foldedAuthorities<A extends Record<
|
|
87
|
+
export declare function foldedAuthorities<A extends Record<'room_ref' | 'room_handle' | 'name' | 'position', unknown>>(authorities: readonly A[]): Folded<A>;
|
|
68
88
|
export declare function parseDiscovery(body: unknown): HouseDiscoveryDocument | null;
|
|
69
89
|
export declare function parseAuthorityChange(body: unknown): HouseAuthorityChange | null;
|
|
70
90
|
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,CAA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