@agentshouse/mdruntime-adapter 0.1.0-cdc4dd63f526f → 0.1.0-cdd0cc6758437
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 +1 -0
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +3 -0
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +14 -39
- package/dist/authored-path.d.ts +59 -2
- package/dist/authored-path.d.ts.map +1 -1
- package/dist/authored-path.js +142 -10
- package/dist/chunks.js +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/read.d.ts +6 -5
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +38 -10
- package/dist/room-query.d.ts.map +1 -1
- package/dist/room-query.js +32 -10
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +16 -2
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +0 -7
- package/dist/transport.d.ts +6 -8
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +7 -6
- package/dist/upload.d.ts +4 -0
- package/dist/upload.d.ts.map +1 -1
- package/dist/upload.js +41 -0
- package/dist/write.js +9 -9
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ host.attach(port, { app: 'my-app' });
|
|
|
25
25
|
|
|
26
26
|
App code never imports this package; it reaches the Runtime only through the
|
|
27
27
|
client its host hands it. The rules an App's agent follows are the `apps/` pages
|
|
28
|
-
of House's Guide, which House's `guide
|
|
28
|
+
of House's Guide, which House's `guide` tool opens.
|
|
29
29
|
|
|
30
30
|
## License
|
|
31
31
|
|
package/dist/actions.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { HouseDoorAnswer, HouseTransport } from './transport.js';
|
|
|
3
3
|
export type HouseActDoor = Pick<HouseTransport, 'door'>;
|
|
4
4
|
export declare const HOUSE_UNKEPT_READS: readonly string[];
|
|
5
5
|
export declare const HOUSE_LEADING_READS: readonly string[];
|
|
6
|
+
export declare const HOUSE_RENAMED_UNTIL_2026_12_18: ReadonlyMap<string, string>;
|
|
6
7
|
export declare function declaredActions(routes: readonly string[]): readonly ActionDeclaration[];
|
|
7
8
|
export declare function houseAction(transport: HouseActDoor, request: ActionRequest): Promise<ActionResult>;
|
|
8
9
|
export declare function actionOutcome(answer: HouseDoorAnswer, name: string, input: unknown): ActionResult;
|
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,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"}
|
|
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,eAAO,MAAM,8BAA8B,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAErE,CAAC;AAEH,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
|
@@ -10,6 +10,9 @@ export const HOUSE_LEADING_READS = [
|
|
|
10
10
|
'sites/list',
|
|
11
11
|
'rooms/members/list',
|
|
12
12
|
];
|
|
13
|
+
export const HOUSE_RENAMED_UNTIL_2026_12_18 = new Map([
|
|
14
|
+
['files/batch', 'update'],
|
|
15
|
+
]);
|
|
13
16
|
export function declaredActions(routes) {
|
|
14
17
|
return routes.map((name) => ({ name, inputShape: {}, resultKind: 'house', room: 'room_ref' }));
|
|
15
18
|
}
|
package/dist/adapter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAIV,OAAO,EAIP,aAAa,
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAIV,OAAO,EAIP,aAAa,EAkBd,MAAM,wBAAwB,CAAC;AA+BhC,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;AAcrD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAybpF"}
|
package/dist/adapter.js
CHANGED
|
@@ -4,11 +4,11 @@ import { capabilities, discoveredRoom, mapDiscovery, parseAuthorityChange, parse
|
|
|
4
4
|
import { createSiteAdapter } from './site.js';
|
|
5
5
|
import { parseFileAddress, parseGrant } from './read.js';
|
|
6
6
|
import { chunkedHead, chunkLister, chunkPart } from './chunks.js';
|
|
7
|
-
import { finishedUpload, houseUpload } from './upload.js';
|
|
8
|
-
import { houseAction, HOUSE_LEADING_READS, HOUSE_UNKEPT_READS } from './actions.js';
|
|
7
|
+
import { finishedUpload, houseUpload, stagedBatch } from './upload.js';
|
|
8
|
+
import { houseAction, HOUSE_LEADING_READS, HOUSE_RENAMED_UNTIL_2026_12_18, HOUSE_UNKEPT_READS, } from './actions.js';
|
|
9
9
|
import { houseQuery } from './room-query.js';
|
|
10
10
|
import { houseSearch } from './search.js';
|
|
11
|
-
import { answeredFailure, classifyDoor,
|
|
11
|
+
import { answeredFailure, classifyDoor, keyedFailure } from './refusal.js';
|
|
12
12
|
import { UNANSWERED, unusable } from './uncertain.js';
|
|
13
13
|
import { houseNotifications, } from './stream.js';
|
|
14
14
|
import { houseDoorRoute, } from './transport.js';
|
|
@@ -19,10 +19,6 @@ const EXPIRED_ADDRESS = 403;
|
|
|
19
19
|
function lapsedGrant(outcome) {
|
|
20
20
|
return outcome.kind === 'rejected' && outcome.code === 'upload_unavailable';
|
|
21
21
|
}
|
|
22
|
-
function unstagedRefusal(answer) {
|
|
23
|
-
const refusal = doorRefusal(answer.body);
|
|
24
|
-
return refusal?.code === 'files_unstaged' ? refusal : null;
|
|
25
|
-
}
|
|
26
22
|
export function createAgentsHouseAdapter(options) {
|
|
27
23
|
if ('site' in options)
|
|
28
24
|
return createSiteAdapter(options.site, options.snapshot === true);
|
|
@@ -153,8 +149,9 @@ export function createAgentsHouseAdapter(options) {
|
|
|
153
149
|
if (handed !== undefined && handed.sha256 === sha256) {
|
|
154
150
|
return { body: { ...head, paths, upload: handed, runtime: notifications.runtime } };
|
|
155
151
|
}
|
|
156
|
-
const minted = await transport.door(houseDoorRoute('
|
|
152
|
+
const minted = await transport.door(houseDoorRoute('update'), {
|
|
157
153
|
...head,
|
|
154
|
+
op: 'stage',
|
|
158
155
|
paths,
|
|
159
156
|
bytes,
|
|
160
157
|
sha256,
|
|
@@ -181,24 +178,6 @@ export function createAgentsHouseAdapter(options) {
|
|
|
181
178
|
await keep(upload);
|
|
182
179
|
return { body: { ...head, paths, upload, runtime: notifications.runtime } };
|
|
183
180
|
}
|
|
184
|
-
async function staged(uploads, { changeBatch: batch, file }) {
|
|
185
|
-
if (!Array.isArray(uploads))
|
|
186
|
-
return unusable();
|
|
187
|
-
for (const named of uploads) {
|
|
188
|
-
const upload = houseUpload(named);
|
|
189
|
-
const change = batch.changes.find((held) => held.kind === 'binary' && held.sha256 === named.sha256);
|
|
190
|
-
if (upload === null || change === undefined)
|
|
191
|
-
return unusable();
|
|
192
|
-
const finished = await finishedUpload(transport, upload, await file(change.localId));
|
|
193
|
-
if ('unfinished' in finished)
|
|
194
|
-
return answeredFailure(finished.unfinished, null);
|
|
195
|
-
if (finished.status !== 200)
|
|
196
|
-
return answeredFailure(finished.status, finished.body);
|
|
197
|
-
if (finished.body?.staged !== true)
|
|
198
|
-
return unusable();
|
|
199
|
-
}
|
|
200
|
-
return null;
|
|
201
|
-
}
|
|
202
181
|
async function submit(request, head, changes, delta, bytes, entry, handed, keep, into) {
|
|
203
182
|
const inline = { ...head, changes, runtime: notifications.runtime };
|
|
204
183
|
const prepared = uploadable(inline, bytes, declared())
|
|
@@ -206,19 +185,12 @@ export function createAgentsHouseAdapter(options) {
|
|
|
206
185
|
: { body: inline };
|
|
207
186
|
if ('outcome' in prepared)
|
|
208
187
|
return prepared.outcome;
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}
|
|
216
|
-
const settled = unstaged === null
|
|
217
|
-
? answer
|
|
218
|
-
: await transport.door(houseDoorRoute('files/batch'), prepared.body);
|
|
219
|
-
if (unstaged !== null && unstagedRefusal(settled) !== null) {
|
|
220
|
-
return answeredFailure(settled.status, settled.body);
|
|
221
|
-
}
|
|
188
|
+
const settled = await stagedBatch(transport, prepared.body, (sha256) => {
|
|
189
|
+
const change = request.changeBatch.changes.find((held) => held.kind === 'binary' && held.sha256 === sha256);
|
|
190
|
+
return change === undefined ? null : request.file(change.localId);
|
|
191
|
+
});
|
|
192
|
+
if ('kind' in settled)
|
|
193
|
+
return settled;
|
|
222
194
|
return stepped(mutationOutcome(settled.status, settled.body, entry.locator, entry.handle, into === undefined
|
|
223
195
|
? undefined
|
|
224
196
|
: {
|
|
@@ -303,6 +275,8 @@ export function createAgentsHouseAdapter(options) {
|
|
|
303
275
|
body: read.body,
|
|
304
276
|
mediaType: address.mediaType,
|
|
305
277
|
sha256: address.sha256,
|
|
278
|
+
url: address.url,
|
|
279
|
+
copies: address.copies,
|
|
306
280
|
};
|
|
307
281
|
}
|
|
308
282
|
function pathAddress(request) {
|
|
@@ -321,6 +295,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
321
295
|
pathRule: admittedPath,
|
|
322
296
|
unkeptReads: HOUSE_UNKEPT_READS,
|
|
323
297
|
leadingReads: HOUSE_LEADING_READS,
|
|
298
|
+
renamedActions: HOUSE_RENAMED_UNTIL_2026_12_18,
|
|
324
299
|
async authorize() {
|
|
325
300
|
return options.authorize();
|
|
326
301
|
},
|
package/dist/authored-path.d.ts
CHANGED
|
@@ -2,8 +2,65 @@ export declare const GENERATED_PROVENANCE = "_provenance";
|
|
|
2
2
|
export declare const GENERATED_REVISIONS = "_revisions";
|
|
3
3
|
export declare const RESERVED_DERIVED = "_derived";
|
|
4
4
|
export declare const WHOLE_ESCAPED_NAMES: readonly string[];
|
|
5
|
-
export declare const AUTHORED_SEGMENT_MAX_CHARS = 255;
|
|
6
|
-
export declare const AUTHORED_SEGMENT: RegExp;
|
|
7
5
|
export declare const LOCAL_COPY_MANIFEST = ".house";
|
|
6
|
+
export declare const ROOM_FOLDER_FILES: readonly string[];
|
|
8
7
|
export declare const LOCAL_COPY_ROOT_NAMES: readonly string[];
|
|
8
|
+
export declare const AUTHORED_NAME_MAX_BYTES = 255;
|
|
9
|
+
export declare const AUTHORED_PATH_MAX_BYTES = 768;
|
|
10
|
+
export declare const AUTHORED_NAME_RULE: {
|
|
11
|
+
readonly refusedCharacters: '/\\:*?"<>|';
|
|
12
|
+
readonly controlCharacters: 'Cc';
|
|
13
|
+
readonly refusedEnds: ' .';
|
|
14
|
+
readonly refusedStart: '-';
|
|
15
|
+
readonly gitNames: readonly ['.git', 'git~1'];
|
|
16
|
+
readonly windowsNames: readonly ["CON", "PRN", "AUX", "NUL", ...string[]];
|
|
17
|
+
readonly generatedNames: readonly ["_provenance", "_revisions", "_derived"];
|
|
18
|
+
readonly nameMaxBytes: 255;
|
|
19
|
+
readonly pathMaxBytes: 768;
|
|
20
|
+
};
|
|
21
|
+
export type NameRefusal = {
|
|
22
|
+
readonly rule: 'unicode';
|
|
23
|
+
} | {
|
|
24
|
+
readonly rule: 'character';
|
|
25
|
+
readonly character: string;
|
|
26
|
+
} | {
|
|
27
|
+
readonly rule: 'empty';
|
|
28
|
+
} | {
|
|
29
|
+
readonly rule: 'dots';
|
|
30
|
+
} | {
|
|
31
|
+
readonly rule: 'end';
|
|
32
|
+
readonly character: string;
|
|
33
|
+
} | {
|
|
34
|
+
readonly rule: 'git';
|
|
35
|
+
} | {
|
|
36
|
+
readonly rule: 'windows';
|
|
37
|
+
readonly reserved: string;
|
|
38
|
+
} | {
|
|
39
|
+
readonly rule: 'name_bytes';
|
|
40
|
+
readonly bytes: number;
|
|
41
|
+
} | {
|
|
42
|
+
readonly rule: 'start';
|
|
43
|
+
} | {
|
|
44
|
+
readonly rule: 'generated';
|
|
45
|
+
} | {
|
|
46
|
+
readonly rule: 'nfc';
|
|
47
|
+
};
|
|
48
|
+
export type PathRefusal = (NameRefusal & {
|
|
49
|
+
readonly name: string;
|
|
50
|
+
}) | {
|
|
51
|
+
readonly rule: 'root';
|
|
52
|
+
readonly name: string;
|
|
53
|
+
} | {
|
|
54
|
+
readonly rule: 'path_bytes';
|
|
55
|
+
readonly bytes: number;
|
|
56
|
+
};
|
|
57
|
+
export declare function utf8Bytes(text: string): number;
|
|
58
|
+
export declare function nameRefusal(name: string): NameRefusal | null;
|
|
59
|
+
export declare function pathRefusal(path: string): PathRefusal | null;
|
|
9
60
|
export declare function admittedPath(path: string): boolean;
|
|
61
|
+
export declare function sameName(left: string, right: string): boolean;
|
|
62
|
+
export declare function nameParts(name: string): {
|
|
63
|
+
readonly stem: string;
|
|
64
|
+
readonly extension: string;
|
|
65
|
+
};
|
|
66
|
+
export declare function fittedName(name: string, count?: number, tail?: string): string;
|
|
@@ -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":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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
|
+
export 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
|
+
export 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.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export { createAgentsHouseAdapter, type AgentsHouseAdapterOptions } from './adapter.js';
|
|
2
2
|
export { foldedAuthorities, ROOM_OWN } from './discovery.js';
|
|
3
|
-
export { finishedUpload, houseUpload, type HouseUpload } from './upload.js';
|
|
3
|
+
export { finishedUpload, houseUpload, stagedBatch, 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
7
|
export { answering, documentEntry, kept, type Answered, type HouseManifestFile } from './read.js';
|
|
8
8
|
export { houseParts, type ChangeMapping } from './write.js';
|
|
9
|
-
export { admittedPath,
|
|
10
|
-
export { HOUSE_RUNTIME_READS, houseDoorRoute, houseSiteRoute, SITE_QUERY, SITE_QUERY_ROUTE_CHARACTERS, siteQueryAsked, siteQueryRoute, type HouseRuntimeAct, type HouseRuntimeFrame, } from './transport.js';
|
|
9
|
+
export { admittedPath, AUTHORED_NAME_MAX_BYTES, AUTHORED_NAME_RULE, AUTHORED_PATH_MAX_BYTES, fittedName, GENERATED_PROVENANCE, GENERATED_REVISIONS, LOCAL_COPY_MANIFEST, LOCAL_COPY_ROOT_NAMES, nameParts, nameRefusal, pathRefusal, RESERVED_DERIVED, ROOM_FOLDER_FILES, sameName, utf8Bytes, WHOLE_ESCAPED_NAMES, type NameRefusal, type PathRefusal, } from './authored-path.js';
|
|
10
|
+
export { HOUSE_RUNTIME_READS, houseDoorRoute, houseSiteRoute, SITE_FRESH_QUERY, SITE_IMAGE_COPIES_HEADER, SITE_QUERY, SITE_QUERY_ROUTE_CHARACTERS, siteQueryAsked, siteQueryRoute, type HouseRuntimeAct, type HouseRuntimeFrame, } from './transport.js';
|
|
11
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,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AA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iB,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,10 +1,10 @@
|
|
|
1
1
|
export { createAgentsHouseAdapter } from './adapter.js';
|
|
2
2
|
export { foldedAuthorities, ROOM_OWN } from './discovery.js';
|
|
3
|
-
export { finishedUpload, houseUpload } from './upload.js';
|
|
3
|
+
export { finishedUpload, houseUpload, stagedBatch } from './upload.js';
|
|
4
4
|
export { houseAction } from './actions.js';
|
|
5
5
|
export { HISTORY_PAGE } from './history.js';
|
|
6
6
|
export { answeredFailure } from './refusal.js';
|
|
7
7
|
export { answering, documentEntry, kept } from './read.js';
|
|
8
8
|
export { houseParts } from './write.js';
|
|
9
|
-
export { admittedPath,
|
|
10
|
-
export { HOUSE_RUNTIME_READS, houseDoorRoute, houseSiteRoute, SITE_QUERY, SITE_QUERY_ROUTE_CHARACTERS, siteQueryAsked, siteQueryRoute, } from './transport.js';
|
|
9
|
+
export { admittedPath, AUTHORED_NAME_MAX_BYTES, AUTHORED_NAME_RULE, AUTHORED_PATH_MAX_BYTES, fittedName, GENERATED_PROVENANCE, GENERATED_REVISIONS, LOCAL_COPY_MANIFEST, LOCAL_COPY_ROOT_NAMES, nameParts, nameRefusal, pathRefusal, RESERVED_DERIVED, ROOM_FOLDER_FILES, sameName, utf8Bytes, WHOLE_ESCAPED_NAMES, } from './authored-path.js';
|
|
10
|
+
export { HOUSE_RUNTIME_READS, houseDoorRoute, houseSiteRoute, SITE_FRESH_QUERY, SITE_IMAGE_COPIES_HEADER, SITE_QUERY, SITE_QUERY_ROUTE_CHARACTERS, siteQueryAsked, siteQueryRoute, } from './transport.js';
|
package/dist/read.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type BinaryCopy, type Attachment, type BootstrapPage, type SavedFacts } from '@agentshouse/mdruntime';
|
|
2
2
|
import type { HouseMode } from './transport.js';
|
|
3
3
|
import { type LogPosition } from './version.js';
|
|
4
4
|
export type HeadChange = BootstrapPage['changes'][string];
|
|
@@ -9,7 +9,7 @@ export type Answered = {
|
|
|
9
9
|
readonly fileIds: Map<string, string>;
|
|
10
10
|
readonly created: Map<string, string>;
|
|
11
11
|
readonly changes: Map<string, HeadChange>;
|
|
12
|
-
readonly
|
|
12
|
+
readonly attachments: Map<string, Attachment>;
|
|
13
13
|
readonly removals: Set<string>;
|
|
14
14
|
readonly folders: Set<string>;
|
|
15
15
|
readonly folderRemovals: Set<string>;
|
|
@@ -25,7 +25,7 @@ export declare function answered(answer: Answered): Generator<number, {
|
|
|
25
25
|
fileIds?: Readonly<Record<string, string>>;
|
|
26
26
|
created?: Readonly<Record<string, string>>;
|
|
27
27
|
changes: Readonly<Record<string, HeadChange>>;
|
|
28
|
-
|
|
28
|
+
attachments: Readonly<Record<string, Attachment>>;
|
|
29
29
|
removals: readonly string[];
|
|
30
30
|
folders?: readonly string[];
|
|
31
31
|
folderRemovals?: readonly string[];
|
|
@@ -36,7 +36,7 @@ export type HouseManifestFile = {
|
|
|
36
36
|
version: string;
|
|
37
37
|
head?: HeadChange;
|
|
38
38
|
created?: string;
|
|
39
|
-
binary?:
|
|
39
|
+
binary?: Attachment;
|
|
40
40
|
facts?: SavedFacts;
|
|
41
41
|
space?: string;
|
|
42
42
|
content?: string;
|
|
@@ -60,6 +60,7 @@ export type HouseFileAddress = {
|
|
|
60
60
|
name: string;
|
|
61
61
|
sha256: string;
|
|
62
62
|
mediaType: string;
|
|
63
|
+
copies: readonly BinaryCopy[];
|
|
63
64
|
};
|
|
64
65
|
export declare function authorityRoot(handle: string): string;
|
|
65
66
|
export declare function schemaPath(handle: string, schema: string): string;
|
|
@@ -69,7 +70,7 @@ export declare function headChange(held: {
|
|
|
69
70
|
readonly author?: unknown;
|
|
70
71
|
readonly changed_at?: unknown;
|
|
71
72
|
}): HeadChange | undefined | null;
|
|
72
|
-
export declare function
|
|
73
|
+
export declare function attachmentOf(held: Readonly<Record<string, unknown>>): Attachment | undefined | null;
|
|
73
74
|
export declare function documentEntry(value: unknown, mode: HouseMode): HouseManifestFile | null;
|
|
74
75
|
export declare function kept(answer: Answered, file: HouseManifestFile): void;
|
|
75
76
|
export declare function modelScope(room: HouseRoomHead): HouseScope;
|
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,EAGL,KAAK,UAAU,EACf,KAAK,aAAa,EAElB,KAAK,UAAU,EAChB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAA6B,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3E,MAAM,MAAM,UAAU,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAM1D,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACxC,QAAQ,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAC1C,QAAQ,CAAC,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAC9C,QAAQ,CAAC,Q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,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,GAAG,iBAAiB,GAAG,IAAI,CAkCvF;AAED,wBAAgB,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,iBAAiB,GAAG,IAAI,CAQpE;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,aAAa,GAAG,UAAU,CAO1D;AAED,wBAAiB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,CAAC,CASxF;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;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAgB,UAAU,CAAC,IAAI,EAAE,iBAAiB,GAAG,WAAW,GAAG,IAAI,CAStE;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAG9E"}
|
package/dist/read.js
CHANGED
|
@@ -12,7 +12,7 @@ export function answering() {
|
|
|
12
12
|
fileIds: new Map(),
|
|
13
13
|
created: new Map(),
|
|
14
14
|
changes: new Map(),
|
|
15
|
-
|
|
15
|
+
attachments: new Map(),
|
|
16
16
|
removals: new Set(),
|
|
17
17
|
folders: new Set(),
|
|
18
18
|
folderRemovals: new Set(),
|
|
@@ -31,7 +31,7 @@ export function forgotten(answer, path) {
|
|
|
31
31
|
answer.fileIds.delete(path);
|
|
32
32
|
answer.created.delete(path);
|
|
33
33
|
answer.changes.delete(path);
|
|
34
|
-
answer.
|
|
34
|
+
answer.attachments.delete(path);
|
|
35
35
|
answer.removals.delete(path);
|
|
36
36
|
}
|
|
37
37
|
export function folded(answer, path, removed) {
|
|
@@ -61,7 +61,7 @@ export function* answered(answer) {
|
|
|
61
61
|
...(answer.fileIds.size === 0 ? {} : { fileIds: yield* patching({}, answer.fileIds) }),
|
|
62
62
|
...(answer.created.size === 0 ? {} : { created: yield* patching({}, answer.created) }),
|
|
63
63
|
changes: yield* patching({}, answer.changes),
|
|
64
|
-
|
|
64
|
+
attachments: yield* patching({}, answer.attachments),
|
|
65
65
|
removals,
|
|
66
66
|
...(answer.folders.size === 0 ? {} : { folders: yield* pathsOf(answer.folders) }),
|
|
67
67
|
...(answer.folderRemovals.size === 0
|
|
@@ -88,17 +88,34 @@ export function parseGrant(body) {
|
|
|
88
88
|
return null;
|
|
89
89
|
return { operation: transfer.operation, url: transfer.url };
|
|
90
90
|
}
|
|
91
|
+
function fileCopies(copies) {
|
|
92
|
+
if (copies === undefined)
|
|
93
|
+
return [];
|
|
94
|
+
if (!Array.isArray(copies))
|
|
95
|
+
return null;
|
|
96
|
+
const read = copies.map((copy) => {
|
|
97
|
+
if (typeof copy !== 'object' || copy === null)
|
|
98
|
+
return null;
|
|
99
|
+
const { download, width } = copy;
|
|
100
|
+
return typeof download === 'string' && typeof width === 'number'
|
|
101
|
+
? { url: download, width }
|
|
102
|
+
: null;
|
|
103
|
+
});
|
|
104
|
+
return read.every((copy) => copy !== null) ? read : null;
|
|
105
|
+
}
|
|
91
106
|
export function parseFileAddress(body) {
|
|
92
107
|
if (typeof body !== 'object' || body === null)
|
|
93
108
|
return null;
|
|
94
|
-
const { download, name, sha256, media_type: mediaType } = body;
|
|
109
|
+
const { download, name, sha256, media_type: mediaType, copies } = body;
|
|
110
|
+
const offered = fileCopies(copies);
|
|
95
111
|
if (typeof download !== 'string' ||
|
|
96
112
|
typeof name !== 'string' ||
|
|
97
113
|
typeof sha256 !== 'string' ||
|
|
98
|
-
typeof mediaType !== 'string'
|
|
114
|
+
typeof mediaType !== 'string' ||
|
|
115
|
+
offered === null) {
|
|
99
116
|
return null;
|
|
100
117
|
}
|
|
101
|
-
return { url: download, name, sha256, mediaType };
|
|
118
|
+
return { url: download, name, sha256, mediaType, copies: offered };
|
|
102
119
|
}
|
|
103
120
|
function changeAuthor(value) {
|
|
104
121
|
if (typeof value !== 'object' || value === null)
|
|
@@ -140,13 +157,24 @@ function createdHeld(created) {
|
|
|
140
157
|
function headed(head) {
|
|
141
158
|
return head === undefined ? {} : { head };
|
|
142
159
|
}
|
|
143
|
-
|
|
160
|
+
function side(value) {
|
|
161
|
+
return Number.isInteger(value) && value > 0;
|
|
162
|
+
}
|
|
163
|
+
function imageSize(width, height) {
|
|
164
|
+
if (width === undefined && height === undefined)
|
|
165
|
+
return { width: null, height: null };
|
|
166
|
+
return side(width) && side(height) ? { width, height } : null;
|
|
167
|
+
}
|
|
168
|
+
export function attachmentOf(held) {
|
|
144
169
|
if (held.media_type === undefined)
|
|
145
170
|
return undefined;
|
|
146
171
|
const { bytes, media_type: mediaType, sha256 } = held;
|
|
147
172
|
if (typeof bytes !== 'number' || typeof mediaType !== 'string' || typeof sha256 !== 'string')
|
|
148
173
|
return null;
|
|
149
|
-
|
|
174
|
+
const size = imageSize(held.width, held.height);
|
|
175
|
+
if (size === null)
|
|
176
|
+
return null;
|
|
177
|
+
return { byteLength: bytes, mediaType, sha256, ...size };
|
|
150
178
|
}
|
|
151
179
|
function binaried(binary) {
|
|
152
180
|
return binary === undefined ? {} : { binary };
|
|
@@ -167,7 +195,7 @@ export function documentEntry(value, mode) {
|
|
|
167
195
|
return null;
|
|
168
196
|
const head = headChange(file);
|
|
169
197
|
const created = createdOf(file);
|
|
170
|
-
const binary =
|
|
198
|
+
const binary = attachmentOf(file);
|
|
171
199
|
if (head === null || created === null || binary === null)
|
|
172
200
|
return null;
|
|
173
201
|
const content = file.content === undefined ? {} : { content: file.content };
|
|
@@ -204,7 +232,7 @@ export function kept(answer, file) {
|
|
|
204
232
|
if (file.created !== undefined)
|
|
205
233
|
answer.created.set(file.path, file.created);
|
|
206
234
|
if (file.binary !== undefined)
|
|
207
|
-
answer.
|
|
235
|
+
answer.attachments.set(file.path, file.binary);
|
|
208
236
|
else if (file.content !== undefined)
|
|
209
237
|
answer.documents.set(file.path, file.content);
|
|
210
238
|
if (file.binary === undefined && file.facts !== undefined)
|
package/dist/room-query.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"room-query.d.ts","sourceRoot":"","sources":["../src/room-query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,
|
|
1
|
+
{"version":3,"file":"room-query.d.ts","sourceRoot":"","sources":["../src/room-query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EAId,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAKL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAmBxB,wBAAsB,UAAU,CAC9B,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,EACvC,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,gBAAgB,CAAC,CAK3B;AAED,wBAAsB,SAAS,CAC7B,SAAS,EAAE,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC,EAC3C,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,gBAAgB,CAAC,CAQ3B"}
|
package/dist/room-query.js
CHANGED
|
@@ -6,31 +6,53 @@ const TOO_LONG_FOR_AN_ADDRESS = {
|
|
|
6
6
|
fields: {},
|
|
7
7
|
retryable: false,
|
|
8
8
|
};
|
|
9
|
+
function infoAsked(request) {
|
|
10
|
+
const root = `/rooms/${request.room}`;
|
|
11
|
+
if (!('query' in request)) {
|
|
12
|
+
const { path, after } = request;
|
|
13
|
+
return { path: `${root}/${path}`, ...(after === undefined ? {} : { cursor: after }) };
|
|
14
|
+
}
|
|
15
|
+
const { after, ...query } = request.query;
|
|
16
|
+
return { path: root, query, ...(after === undefined ? {} : { cursor: after }) };
|
|
17
|
+
}
|
|
9
18
|
export async function houseQuery(transport, request) {
|
|
10
|
-
return
|
|
11
|
-
room_ref: request.room,
|
|
12
|
-
query: request.query,
|
|
13
|
-
}));
|
|
19
|
+
return queriedPage(await transport.door(houseDoorRoute('info'), infoAsked(request)), 'next_cursor');
|
|
14
20
|
}
|
|
15
21
|
export async function siteQuery(transport, request) {
|
|
16
|
-
const
|
|
22
|
+
const asked = 'query' in request
|
|
23
|
+
? request.query
|
|
24
|
+
: { path: request.path, ...(request.after === undefined ? {} : { after: request.after }) };
|
|
25
|
+
const route = siteQueryRoute(request.room, asked, request.fresh);
|
|
17
26
|
if (route.length > SITE_QUERY_ROUTE_CHARACTERS)
|
|
18
27
|
return TOO_LONG_FOR_AN_ADDRESS;
|
|
19
|
-
return
|
|
28
|
+
return queriedPage(await transport.read(route), 'next');
|
|
20
29
|
}
|
|
21
|
-
function
|
|
30
|
+
function queriedPage(answer, named) {
|
|
22
31
|
if (answer.status === 401)
|
|
23
32
|
return { kind: 'revoked-authorization' };
|
|
24
33
|
const refusal = doorRefusal(answer.body);
|
|
25
34
|
if (refusal !== null)
|
|
26
35
|
return { kind: 'rejected', ...refusal };
|
|
27
|
-
const
|
|
28
|
-
|
|
36
|
+
const body = (answer.body ?? {});
|
|
37
|
+
const { documents, groups, total, totalCapped, capped } = body;
|
|
38
|
+
const next = body[named];
|
|
39
|
+
if (answer.status !== 200 || !(Array.isArray(documents) || Array.isArray(groups))) {
|
|
29
40
|
return answeredFailure(answer.status, answer.body);
|
|
30
41
|
}
|
|
42
|
+
const continued = typeof next === 'string' ? { next } : {};
|
|
43
|
+
if (Array.isArray(groups)) {
|
|
44
|
+
return {
|
|
45
|
+
kind: 'groups',
|
|
46
|
+
groups: groups,
|
|
47
|
+
...continued,
|
|
48
|
+
...(capped === true ? { capped } : {}),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
31
51
|
return {
|
|
32
52
|
kind: 'rows',
|
|
33
53
|
documents: documents,
|
|
34
|
-
...
|
|
54
|
+
...continued,
|
|
55
|
+
...(typeof total === 'number' ? { total } : {}),
|
|
56
|
+
...(totalCapped === true ? { totalCapped } : {}),
|
|
35
57
|
};
|
|
36
58
|
}
|
package/dist/site.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,OAAO,
|
|
1
|
+
{"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,OAAO,EASR,MAAM,wBAAwB,CAAC;AAchC,OAAO,EAIL,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AAgCxB,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,kBAAkB,EAAE,QAAQ,UAAQ,GAAG,OAAO,CA0K1F"}
|
package/dist/site.js
CHANGED
|
@@ -12,6 +12,14 @@ import { followsVersion, reachedVersion, roomVersion } from './version.js';
|
|
|
12
12
|
function unfound() {
|
|
13
13
|
return { kind: 'rejected', code: 'not_found', fields: {}, retryable: false };
|
|
14
14
|
}
|
|
15
|
+
function siteCopies(copies) {
|
|
16
|
+
if (copies === null || copies === undefined)
|
|
17
|
+
return [];
|
|
18
|
+
return copies.split(', ').map((offered) => {
|
|
19
|
+
const [url = '', width = ''] = offered.split(' ');
|
|
20
|
+
return { url, width: Number.parseInt(width, 10) };
|
|
21
|
+
});
|
|
22
|
+
}
|
|
15
23
|
function siteRoom(tracked) {
|
|
16
24
|
return {
|
|
17
25
|
name: tracked.handle,
|
|
@@ -123,7 +131,7 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
123
131
|
async history() {
|
|
124
132
|
return { kind: 'no-history' };
|
|
125
133
|
},
|
|
126
|
-
queryHouse:
|
|
134
|
+
queryHouse: (_authorization, request) => siteQuery(transport, request),
|
|
127
135
|
async binary(_authorization, request) {
|
|
128
136
|
const route = fileRoute(request);
|
|
129
137
|
if (typeof route !== 'string')
|
|
@@ -135,7 +143,13 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
135
143
|
return answeredFailure(read.status, null);
|
|
136
144
|
if (read.body === null)
|
|
137
145
|
return unusable();
|
|
138
|
-
return {
|
|
146
|
+
return {
|
|
147
|
+
kind: 'binary',
|
|
148
|
+
body: read.body,
|
|
149
|
+
mediaType: read.mediaType,
|
|
150
|
+
url: route,
|
|
151
|
+
copies: siteCopies(read.copies),
|
|
152
|
+
};
|
|
139
153
|
},
|
|
140
154
|
async link(_authorization, request) {
|
|
141
155
|
if (request.kind === 'key')
|
package/dist/stream.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,eAAe,EAEpB,KAAK,SAAS,EACd,KAAK,kBAAkB,EAEvB,KAAK,QAAQ,EAGb,KAAK,eAAe,EAEpB,KAAK,iBAAiB,EAEvB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAYvD,OAAO,EACL,KAAK,SAAS,EAEd,KAAK,SAAS,EAGd,KAAK,gBAAgB,EACtB,MAAM,gBAAgB,CAAC;AAaxB,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,EAAE;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC,CAAC;AAE/E,MAAM,MAAM,0BAA0B,GAAG,OAAO,CAAC,gBAAgB,EAAE;IAAE,IAAI,EAAE,mBAAmB,CAAA;CAAE,CAAC,CAAC;AAElG,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC;IACnE,OAAO,CAAC,KAAK,EAAE,0BAA0B,GAAG,eAAe,GAAG,IAAI,CAAC;IACnE,OAAO,CAAC,CAAC,OAAO,EAAE,SAAS,gBAA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,CAAC,OAAO,EAAE,SAAS,gBAAgB,EAAE,GAAG,IAAI,CAAC;CACtD,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAC9D,IAAI,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,GAAG,IAAI,CAAC;IACvC,KAAK,CAAC,WAAW,EAAE,SAAS,gBAAgB,EAAE,GAAG,IAAI,CAAC;IACtD,aAAa,EAAE,kBAAkB,CAAC;IAClC,WAAW,EAAE,iBAAiB,CAAC;CAChC,CAAC;AAwFF,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,SAAS,EACf,WAAW,EAAE,gBAAgB,GAC5B,kBAAkB,CA6XpB"}
|
package/dist/stream.js
CHANGED
|
@@ -32,7 +32,6 @@ function listedConversation(listed) {
|
|
|
32
32
|
agent: listed.agent_id,
|
|
33
33
|
name: listed.name,
|
|
34
34
|
created: listed.created_at,
|
|
35
|
-
finished: listed.finished_at,
|
|
36
35
|
outcome: listed.outcome,
|
|
37
36
|
waiting: listed.waiting,
|
|
38
37
|
newest: listed.newest === null ? null : changeCursor(listed.newest),
|
|
@@ -115,7 +114,6 @@ export function houseNotifications(transport, mode, discovering) {
|
|
|
115
114
|
event.kind === 'options' ||
|
|
116
115
|
event.kind === 'starting' ||
|
|
117
116
|
event.kind === 'state' ||
|
|
118
|
-
event.kind === 'link' ||
|
|
119
117
|
event.kind === 'deliveries') {
|
|
120
118
|
live.add(event.conversation);
|
|
121
119
|
}
|
|
@@ -193,10 +191,6 @@ export function houseNotifications(transport, mode, discovering) {
|
|
|
193
191
|
emitConversation({ kind: 'state', conversation, state: structuredClone(frame.state) });
|
|
194
192
|
return;
|
|
195
193
|
}
|
|
196
|
-
if (frame.type === 'link') {
|
|
197
|
-
emitConversation({ kind: 'link', conversation, connected: frame.connected });
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
194
|
if (frame.type === 'deliveries') {
|
|
201
195
|
emitConversation({
|
|
202
196
|
kind: 'deliveries',
|
|
@@ -307,7 +301,6 @@ export function houseNotifications(transport, mode, discovering) {
|
|
|
307
301
|
frame.type === 'options' ||
|
|
308
302
|
frame.type === 'starting' ||
|
|
309
303
|
frame.type === 'state' ||
|
|
310
|
-
frame.type === 'link' ||
|
|
311
304
|
frame.type === 'deliveries' ||
|
|
312
305
|
frame.type === 'interactions' ||
|
|
313
306
|
frame.type === 'message') {
|
package/dist/transport.d.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import type { ConversationEvent, ListedAgent, SavedFacts } from '@agentshouse/mdruntime';
|
|
2
2
|
import type { Operation, SessionState } from './session-content/index.js';
|
|
3
3
|
export declare const HOUSE_RUNTIME_READS: {
|
|
4
|
-
readonly acts: readonly ['account/push/set', 'account/time-zone/set', 'apps/features/set', 'apps/source/download', 'apps/source/top/read', 'conversations/history/list', 'files/attach', 'files/
|
|
5
|
-
readonly frames: readonly ['agent', 'app-message', 'app-rooms', 'authority_changed', 'carried', 'caught_up', 'commands', 'conversation', 'conversation_deleted', 'conversations', 'deliveries', 'deployment', 'held', 'interactions', '
|
|
4
|
+
readonly acts: readonly ['account/push/set', 'account/time-zone/set', 'apps/features/set', 'apps/source/download', 'apps/source/top/read', 'conversations/history/list', 'files/attach', 'files/finish', 'files/read', 'files/revisions/list', 'info', 'room-chunks/list', 'rooms/discover', 'rooms/search', 'sites/screenshot/read', 'update'];
|
|
5
|
+
readonly frames: readonly ['agent', 'app-message', 'app-rooms', 'authority_changed', 'carried', 'caught_up', 'commands', 'conversation', 'conversation_deleted', 'conversations', 'deliveries', 'deployment', 'held', 'interactions', 'message', 'opening', 'options', 'part', 'process', 'received', 'report', 'signal', 'site', 'starting', 'state', 'tab-icon', 'turn'];
|
|
6
6
|
};
|
|
7
7
|
export type HouseRuntimeAct = (typeof HOUSE_RUNTIME_READS.acts)[number];
|
|
8
8
|
export type HouseRuntimeFrame = (typeof HOUSE_RUNTIME_READS.frames)[number];
|
|
9
9
|
export declare function houseDoorRoute(act: HouseRuntimeAct): string;
|
|
10
10
|
export declare function houseSiteRoute(act: 'chunks' | 'discover' | 'query'): string;
|
|
11
11
|
export declare const SITE_QUERY = "query";
|
|
12
|
+
export declare const SITE_FRESH_QUERY = "fresh";
|
|
12
13
|
export declare const SITE_QUERY_ROUTE_CHARACTERS = 12000;
|
|
13
|
-
export declare function siteQueryRoute(room: string, query: Readonly<Record<string, unknown
|
|
14
|
+
export declare function siteQueryRoute(room: string, query: Readonly<Record<string, unknown>>, fresh?: boolean): string;
|
|
14
15
|
export declare function siteQueryAsked(address: string): Readonly<Record<string, unknown>> | null;
|
|
15
16
|
export declare const SITES_SUBMISSIONS_CREATE = "sites/submissions/create";
|
|
16
17
|
export declare const SITE_DOOR_SUBMIT = "/_house/door/submit";
|
|
@@ -23,10 +24,12 @@ export type HouseDoorAnswer = {
|
|
|
23
24
|
body: unknown;
|
|
24
25
|
};
|
|
25
26
|
export declare const SITE_FILES = "/_house/files/";
|
|
27
|
+
export declare const SITE_IMAGE_COPIES_HEADER = "X-House-Image-Copies";
|
|
26
28
|
export type HouseBytesAnswer = {
|
|
27
29
|
status: number;
|
|
28
30
|
body: ReadableStream<Uint8Array> | null;
|
|
29
31
|
mediaType: string;
|
|
32
|
+
copies?: string | null;
|
|
30
33
|
};
|
|
31
34
|
export type HouseByteTransfer = {
|
|
32
35
|
url: string;
|
|
@@ -71,7 +74,6 @@ export type HouseListedConversation = {
|
|
|
71
74
|
agent_id: string;
|
|
72
75
|
name: string;
|
|
73
76
|
created_at: string;
|
|
74
|
-
finished_at: string | null;
|
|
75
77
|
outcome: string | null;
|
|
76
78
|
waiting: boolean;
|
|
77
79
|
newest: number | null;
|
|
@@ -159,10 +161,6 @@ export type HouseStreamFrame = Listed<{
|
|
|
159
161
|
type: 'state';
|
|
160
162
|
conversation_id: string;
|
|
161
163
|
state: SessionState;
|
|
162
|
-
} | {
|
|
163
|
-
type: 'link';
|
|
164
|
-
conversation_id: string;
|
|
165
|
-
connected: boolean;
|
|
166
164
|
} | {
|
|
167
165
|
type: 'conversations';
|
|
168
166
|
agents: readonly ListedAgent[];
|
package/dist/transport.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzF,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5E,eAAO,MAAM,mBAAmB;aAC9B,IAAI,YACF,kBAAkB,EAClB,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACtB,4BAA4B,EAC5B,cAAc,EACd,
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzF,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5E,eAAO,MAAM,mBAAmB;aAC9B,IAAI,YACF,kBAAkB,EAClB,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACtB,4BAA4B,EAC5B,cAAc,EACd,cAAc,EACd,YAAY,EACZ,sBAAsB,EACtB,MAAM,EACN,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,uBAAuB,EACvB,QAAQ;aAEV,MAAM,YACJ,OAAO,EACP,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,SAAS,EACT,WAAW,EACX,UAAU,EACV,cAAc,EACd,sBAAsB,EACtB,eAAe,EACf,YAAY,EACZ,Y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,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC/D,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACzF,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAClD,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG;IAC3C,MAAM,IAAI,OAAO,CAAC;IAClB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC9C,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACpD,CAAC"}
|
package/dist/transport.js
CHANGED
|
@@ -8,16 +8,15 @@ export const HOUSE_RUNTIME_READS = {
|
|
|
8
8
|
'apps/source/top/read',
|
|
9
9
|
'conversations/history/list',
|
|
10
10
|
'files/attach',
|
|
11
|
-
'files/batch',
|
|
12
|
-
'files/batch-upload',
|
|
13
11
|
'files/finish',
|
|
14
12
|
'files/read',
|
|
15
13
|
'files/revisions/list',
|
|
14
|
+
'info',
|
|
16
15
|
'room-chunks/list',
|
|
17
16
|
'rooms/discover',
|
|
18
|
-
'rooms/query',
|
|
19
17
|
'rooms/search',
|
|
20
18
|
'sites/screenshot/read',
|
|
19
|
+
'update',
|
|
21
20
|
],
|
|
22
21
|
frames: [
|
|
23
22
|
'agent',
|
|
@@ -34,7 +33,6 @@ export const HOUSE_RUNTIME_READS = {
|
|
|
34
33
|
'deployment',
|
|
35
34
|
'held',
|
|
36
35
|
'interactions',
|
|
37
|
-
'link',
|
|
38
36
|
'message',
|
|
39
37
|
'opening',
|
|
40
38
|
'options',
|
|
@@ -57,6 +55,7 @@ export function houseSiteRoute(act) {
|
|
|
57
55
|
return `/_house/door/${act}`;
|
|
58
56
|
}
|
|
59
57
|
export const SITE_QUERY = 'query';
|
|
58
|
+
export const SITE_FRESH_QUERY = 'fresh';
|
|
60
59
|
export const SITE_QUERY_ROUTE_CHARACTERS = 12_000;
|
|
61
60
|
function addressed(text) {
|
|
62
61
|
let binary = '';
|
|
@@ -64,9 +63,10 @@ function addressed(text) {
|
|
|
64
63
|
binary += String.fromCharCode(byte);
|
|
65
64
|
return btoa(binary).replaceAll('+', '-').replaceAll('/', '_').replace(/=+$/u, '');
|
|
66
65
|
}
|
|
67
|
-
export function siteQueryRoute(room, query) {
|
|
66
|
+
export function siteQueryRoute(room, query, fresh = false) {
|
|
68
67
|
const canonical = queryKey(JSON.parse(JSON.stringify(query)));
|
|
69
|
-
|
|
68
|
+
const named = fresh ? SITE_FRESH_QUERY : SITE_QUERY;
|
|
69
|
+
return `${houseSiteRoute('query')}/${room}?${named}=${addressed(canonical)}`;
|
|
70
70
|
}
|
|
71
71
|
export function siteQueryAsked(address) {
|
|
72
72
|
let asked;
|
|
@@ -89,3 +89,4 @@ export const SITE_DOOR_ACTS = {
|
|
|
89
89
|
[SITES_FUNCTIONS_CALL]: SITE_DOOR_FUNCTION,
|
|
90
90
|
};
|
|
91
91
|
export const SITE_FILES = '/_house/files/';
|
|
92
|
+
export const SITE_IMAGE_COPIES_HEADER = 'X-House-Image-Copies';
|
package/dist/upload.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { TransportUncertainty } from '@agentshouse/mdruntime';
|
|
1
2
|
import { type HouseDoorAnswer, type HouseTransport } from './transport.js';
|
|
2
3
|
export type HouseUpload = {
|
|
3
4
|
readonly id: string;
|
|
@@ -11,3 +12,6 @@ export declare function houseUpload(value: unknown): HouseUpload | null;
|
|
|
11
12
|
export declare function finishedUpload(transport: HouseTransport, first: HouseUpload, blob: Blob): Promise<HouseDoorAnswer | {
|
|
12
13
|
readonly unfinished: number;
|
|
13
14
|
}>;
|
|
15
|
+
type StagedFile = (sha256: unknown) => Promise<Blob> | null;
|
|
16
|
+
export declare function stagedBatch(transport: HouseTransport, body: Readonly<Record<string, unknown>>, file: StagedFile): Promise<HouseDoorAnswer | TransportUncertainty>;
|
|
17
|
+
export {};
|
package/dist/upload.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../src/upload.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../src/upload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAGpF,OAAO,EAAkB,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAG3F,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,SAAS;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC5E,CAAC;AAeF,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,CAQ9D;AA+BD,wBAAsB,cAAc,CAClC,SAAS,EAAE,cAAc,EACzB,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,eAAe,GAAG;IAAE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAgB5D;AAED,KAAK,UAAU,GAAG,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAsB5D,wBAAsB,WAAW,CAC/B,SAAS,EAAE,cAAc,EACzB,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACvC,IAAI,EAAE,UAAU,GACf,OAAO,CAAC,eAAe,GAAG,oBAAoB,CAAC,CAoBjD"}
|
package/dist/upload.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { sha256 } from '@agentshouse/mdruntime/digest';
|
|
2
|
+
import { answeredFailure, doorRefusal } from './refusal.js';
|
|
2
3
|
import { houseDoorRoute } from './transport.js';
|
|
4
|
+
import { unusable } from './uncertain.js';
|
|
3
5
|
const FINISHING_ROUNDS = 24;
|
|
4
6
|
function record(value) {
|
|
5
7
|
return value !== null && typeof value === 'object' ? value : {};
|
|
@@ -63,3 +65,42 @@ export async function finishedUpload(transport, first, blob) {
|
|
|
63
65
|
}
|
|
64
66
|
return { unfinished: 200 };
|
|
65
67
|
}
|
|
68
|
+
function unstagedRefusal(answer) {
|
|
69
|
+
const refusal = doorRefusal(answer.body);
|
|
70
|
+
return refusal?.code === 'files_unstaged' ? refusal : null;
|
|
71
|
+
}
|
|
72
|
+
async function staged(transport, named, file) {
|
|
73
|
+
const upload = houseUpload(named);
|
|
74
|
+
if (upload === null)
|
|
75
|
+
return unusable();
|
|
76
|
+
const blob = file(record(named).sha256);
|
|
77
|
+
if (blob === null)
|
|
78
|
+
return unusable();
|
|
79
|
+
const sent = await finishedUpload(transport, upload, await blob);
|
|
80
|
+
if ('unfinished' in sent)
|
|
81
|
+
return answeredFailure(sent.unfinished, null);
|
|
82
|
+
if (sent.status !== 200)
|
|
83
|
+
return answeredFailure(sent.status, sent.body);
|
|
84
|
+
return record(sent.body).staged === true ? null : unusable();
|
|
85
|
+
}
|
|
86
|
+
export async function stagedBatch(transport, body, file) {
|
|
87
|
+
let answer = await transport.door(houseDoorRoute('update'), body);
|
|
88
|
+
const finished = new Set();
|
|
89
|
+
for (let unstaged = unstagedRefusal(answer); unstaged !== null; unstaged = unstagedRefusal(answer)) {
|
|
90
|
+
const named = unstaged.fields.upload;
|
|
91
|
+
if (!Array.isArray(named))
|
|
92
|
+
return unusable();
|
|
93
|
+
const fresh = named.filter((upload) => !finished.has(record(upload).id));
|
|
94
|
+
if (fresh.length === 0)
|
|
95
|
+
return answeredFailure(answer.status, answer.body);
|
|
96
|
+
for (const upload of fresh) {
|
|
97
|
+
const staging = await staged(transport, upload, file);
|
|
98
|
+
if (staging !== null)
|
|
99
|
+
return staging;
|
|
100
|
+
}
|
|
101
|
+
for (const upload of fresh)
|
|
102
|
+
finished.add(record(upload).id);
|
|
103
|
+
answer = await transport.door(houseDoorRoute('update'), body);
|
|
104
|
+
}
|
|
105
|
+
return answer;
|
|
106
|
+
}
|
package/dist/write.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { departure, partsChanges, ROW_WEIGHT, } from '@agentshouse/mdruntime';
|
|
2
|
-
import { answered, answering,
|
|
2
|
+
import { answered, answering, attachmentOf, headChange, revised } from './read.js';
|
|
3
3
|
import { sha256Hex, textBytes } from './digest.js';
|
|
4
4
|
import { nativePath, roomLocalPath } from './map.js';
|
|
5
5
|
import { answeredFailure, classifyDoor, doorRefusal, resetOf, scopedRefusal } from './refusal.js';
|
|
@@ -182,7 +182,7 @@ function* material(value, handle, within = () => true) {
|
|
|
182
182
|
return null;
|
|
183
183
|
if (file.revision !== null && file.revision !== undefined && typeof file.revision !== 'string')
|
|
184
184
|
return null;
|
|
185
|
-
const binary =
|
|
185
|
+
const binary = attachmentOf(file);
|
|
186
186
|
if (binary === null)
|
|
187
187
|
return null;
|
|
188
188
|
const head = headChange(file);
|
|
@@ -225,14 +225,14 @@ function* acceptedOf(at, contents) {
|
|
|
225
225
|
if (entry.content !== null)
|
|
226
226
|
answer.documents.set(entry.path, entry.content);
|
|
227
227
|
if (entry.binary !== undefined)
|
|
228
|
-
answer.
|
|
228
|
+
answer.attachments.set(entry.path, entry.binary);
|
|
229
229
|
revised(answer, entry.path, entry.revision);
|
|
230
230
|
if (entry.head !== undefined)
|
|
231
231
|
answer.changes.set(entry.path, entry.head);
|
|
232
232
|
}
|
|
233
|
-
const unbinaried = answer.
|
|
234
|
-
const {
|
|
235
|
-
return { roomVersion: roomVersion(at), ...room, ...(unbinaried ? {} : {
|
|
233
|
+
const unbinaried = answer.attachments.size === 0;
|
|
234
|
+
const { attachments, facts: _facts, ...room } = yield* answered(answer);
|
|
235
|
+
return { roomVersion: roomVersion(at), ...room, ...(unbinaried ? {} : { attachments }) };
|
|
236
236
|
}
|
|
237
237
|
function* movedOutcome(held, move) {
|
|
238
238
|
const authorities = Array.isArray(held.authorities) ? held.authorities : [];
|
|
@@ -391,14 +391,14 @@ export function historyOutcome(status, body, locator, request) {
|
|
|
391
391
|
typeof entry.created_at !== 'string') {
|
|
392
392
|
return unusable();
|
|
393
393
|
}
|
|
394
|
-
const
|
|
395
|
-
if (
|
|
394
|
+
const attachment = attachmentOf(entry);
|
|
395
|
+
if (attachment === null)
|
|
396
396
|
return unusable();
|
|
397
397
|
revisions.push({
|
|
398
398
|
revision: entry.revision,
|
|
399
399
|
author,
|
|
400
400
|
time: entry.created_at,
|
|
401
|
-
...(
|
|
401
|
+
...(attachment === undefined ? {} : { attachment }),
|
|
402
402
|
});
|
|
403
403
|
}
|
|
404
404
|
const next = held.next_before;
|
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-cdd0cc6758437",
|
|
4
4
|
"description": "Agents House Adapter for the MD Runtime",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"LICENSE"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@agentshouse/mdmodel": "0.1.0-
|
|
28
|
-
"@agentshouse/mdruntime": "0.1.0-
|
|
27
|
+
"@agentshouse/mdmodel": "0.1.0-c91b41b1477d7",
|
|
28
|
+
"@agentshouse/mdruntime": "0.1.0-c3b445fa731c0"
|
|
29
29
|
},
|
|
30
30
|
"repository": {
|
|
31
31
|
"type": "git",
|