@agentshouse/mdruntime-adapter 0.1.0-c341663d60099 → 0.1.0-c343dc02413f9

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 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/open` opens.
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;
@@ -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
  }
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAIV,OAAO,EAIP,aAAa,EAoBd,MAAM,wBAAwB,CAAC;AA0BhC,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,CA8cpF"}
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, doorRefusal, keyedFailure } from './refusal.js';
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('files/batch-upload'), {
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 answer = await transport.door(houseDoorRoute('files/batch'), prepared.body);
210
- const unstaged = unstagedRefusal(answer);
211
- if (unstaged !== null) {
212
- const staging = await staged(unstaged.fields.upload, request);
213
- if (staging !== null)
214
- return staging;
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
  },
@@ -2,8 +2,64 @@ 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";
8
6
  export declare const LOCAL_COPY_ROOT_NAMES: readonly string[];
7
+ export declare const AUTHORED_NAME_MAX_BYTES = 255;
8
+ export declare const AUTHORED_PATH_MAX_BYTES = 768;
9
+ export declare const AUTHORED_NAME_RULE: {
10
+ readonly refusedCharacters: '/\\:*?"<>|';
11
+ readonly controlCharacters: 'Cc';
12
+ readonly refusedEnds: ' .';
13
+ readonly refusedStart: '-';
14
+ readonly gitNames: readonly ['.git', 'git~1'];
15
+ readonly windowsNames: readonly ["CON", "PRN", "AUX", "NUL", ...string[]];
16
+ readonly generatedNames: readonly ["_provenance", "_revisions", "_derived"];
17
+ readonly nameMaxBytes: 255;
18
+ readonly pathMaxBytes: 768;
19
+ };
20
+ export type NameRefusal = {
21
+ readonly rule: 'unicode';
22
+ } | {
23
+ readonly rule: 'character';
24
+ readonly character: string;
25
+ } | {
26
+ readonly rule: 'empty';
27
+ } | {
28
+ readonly rule: 'dots';
29
+ } | {
30
+ readonly rule: 'end';
31
+ readonly character: string;
32
+ } | {
33
+ readonly rule: 'git';
34
+ } | {
35
+ readonly rule: 'windows';
36
+ readonly reserved: string;
37
+ } | {
38
+ readonly rule: 'name_bytes';
39
+ readonly bytes: number;
40
+ } | {
41
+ readonly rule: 'start';
42
+ } | {
43
+ readonly rule: 'generated';
44
+ } | {
45
+ readonly rule: 'nfc';
46
+ };
47
+ export type PathRefusal = (NameRefusal & {
48
+ readonly name: string;
49
+ }) | {
50
+ readonly rule: 'root';
51
+ readonly name: string;
52
+ } | {
53
+ readonly rule: 'path_bytes';
54
+ readonly bytes: number;
55
+ };
56
+ export declare function utf8Bytes(text: string): number;
57
+ export declare function nameRefusal(name: string): NameRefusal | null;
58
+ export declare function pathRefusal(path: string): PathRefusal | null;
9
59
  export declare function admittedPath(path: string): boolean;
60
+ export declare function sameName(left: string, right: string): boolean;
61
+ export declare function nameParts(name: string): {
62
+ readonly stem: string;
63
+ readonly extension: string;
64
+ };
65
+ 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,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"}
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;AAE5C,eAA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AAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,GACzC;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAChD;IAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAsB5D,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO9C;AAYD,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAiB5D;AASD,wBAAgB,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;AAyBD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAK7F;AAWD,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,SAAI,EAAE,IAAI,SAAK,GAAG,MAAM,CAUrE"}
@@ -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,156 @@ 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';
19
13
  export const LOCAL_COPY_ROOT_NAMES = [
20
14
  '.gitignore',
21
15
  '.ignore',
22
16
  LOCAL_COPY_MANIFEST,
23
17
  ];
18
+ export const AUTHORED_NAME_MAX_BYTES = 255;
19
+ export const AUTHORED_PATH_MAX_BYTES = 768;
20
+ const FITTED_STEM = 'file';
21
+ export const AUTHORED_NAME_RULE = {
22
+ refusedCharacters: '/\\:*?"<>|',
23
+ controlCharacters: 'Cc',
24
+ refusedEnds: ' .',
25
+ refusedStart: '-',
26
+ gitNames: ['.git', 'git~1'],
27
+ windowsNames: [
28
+ 'CON',
29
+ 'PRN',
30
+ 'AUX',
31
+ 'NUL',
32
+ ...['1', '2', '3', '4', '5', '6', '7', '8', '9', '¹', '²', '³'].flatMap((digit) => [
33
+ `COM${digit}`,
34
+ `LPT${digit}`,
35
+ ]),
36
+ ],
37
+ generatedNames: [GENERATED_PROVENANCE, GENERATED_REVISIONS, RESERVED_DERIVED],
38
+ nameMaxBytes: AUTHORED_NAME_MAX_BYTES,
39
+ pathMaxBytes: AUTHORED_PATH_MAX_BYTES,
40
+ };
41
+ const LONE_SURROGATE = /\p{Cs}/u;
42
+ const LONE_SURROGATES = /\p{Cs}/gu;
43
+ const CONTROL = /\p{Cc}/u;
44
+ const MAC_IGNORED = /[\u200C-\u200F\u202A-\u202E\u206A-\u206F\uFEFF]/gu;
45
+ const FOLDED_GIT_NAMES = new Set(AUTHORED_NAME_RULE.gitNames.map(foldedName));
46
+ const FOLDED_WINDOWS_NAMES = new Set(AUTHORED_NAME_RULE.windowsNames.map(foldedName));
47
+ const FOLDED_GENERATED_NAMES = new Set(AUTHORED_NAME_RULE.generatedNames.map(foldedName));
48
+ const FOLDED_ROOT_NAMES = new Set(LOCAL_COPY_ROOT_NAMES.map(foldedName));
49
+ export function utf8Bytes(text) {
50
+ let bytes = 0;
51
+ for (const point of text) {
52
+ const code = point.codePointAt(0);
53
+ bytes += code < 0x80 ? 1 : code < 0x800 ? 2 : code < 0x10000 ? 3 : 4;
54
+ }
55
+ return bytes;
56
+ }
57
+ function refusedCharacter(point) {
58
+ return AUTHORED_NAME_RULE.refusedCharacters.includes(point) || CONTROL.test(point);
59
+ }
60
+ function windowsName(name) {
61
+ const dot = name.indexOf('.');
62
+ const base = dot < 0 ? name : name.slice(0, dot);
63
+ return FOLDED_WINDOWS_NAMES.has(foldedName(base)) ? base : null;
64
+ }
65
+ export function nameRefusal(name) {
66
+ if (LONE_SURROGATE.test(name))
67
+ return { rule: 'unicode' };
68
+ for (const point of name)
69
+ if (refusedCharacter(point))
70
+ return { rule: 'character', character: point };
71
+ if (name === '')
72
+ return { rule: 'empty' };
73
+ if (name === '.' || name === '..')
74
+ return { rule: 'dots' };
75
+ const last = name.at(-1);
76
+ if (AUTHORED_NAME_RULE.refusedEnds.includes(last))
77
+ return { rule: 'end', character: last };
78
+ if (FOLDED_GIT_NAMES.has(foldedName(name.replace(MAC_IGNORED, ''))))
79
+ return { rule: 'git' };
80
+ const reserved = windowsName(name);
81
+ if (reserved !== null)
82
+ return { rule: 'windows', reserved };
83
+ const bytes = utf8Bytes(name);
84
+ if (bytes > AUTHORED_NAME_MAX_BYTES)
85
+ return { rule: 'name_bytes', bytes };
86
+ if (name.startsWith(AUTHORED_NAME_RULE.refusedStart))
87
+ return { rule: 'start' };
88
+ if (FOLDED_GENERATED_NAMES.has(foldedName(name)))
89
+ return { rule: 'generated' };
90
+ if (name.normalize('NFC') !== name)
91
+ return { rule: 'nfc' };
92
+ return null;
93
+ }
24
94
  function appPreferences(path) {
25
95
  return (path.endsWith('.md') &&
26
96
  APP_REFERENCE_PATTERN.test(path.slice(APP_PREFERENCES_HOME.length + 1, -3)));
27
97
  }
28
- export function admittedPath(path) {
98
+ export function pathRefusal(path) {
29
99
  const names = path.split('/');
30
100
  const [root] = names;
31
- return (!LOCAL_COPY_ROOT_NAMES.includes(root.toLowerCase()) &&
32
- names.every((name) => AUTHORED_SEGMENT.test(name)) &&
101
+ if (FOLDED_ROOT_NAMES.has(foldedName(root)))
102
+ return { rule: 'root', name: root };
103
+ for (const name of names) {
104
+ const refused = nameRefusal(name);
105
+ if (refused !== null)
106
+ return { ...refused, name };
107
+ }
108
+ const bytes = utf8Bytes(path);
109
+ return bytes > AUTHORED_PATH_MAX_BYTES ? { rule: 'path_bytes', bytes } : null;
110
+ }
111
+ export function admittedPath(path) {
112
+ return (pathRefusal(path) === null &&
33
113
  (!path.startsWith(`${APP_PREFERENCES_HOME}/`) || appPreferences(path)));
34
114
  }
115
+ export function sameName(left, right) {
116
+ return foldedName(left) === foldedName(right);
117
+ }
118
+ function cutToBytes(text, bytes) {
119
+ let kept = '';
120
+ let used = 0;
121
+ for (const point of text) {
122
+ used += utf8Bytes(point);
123
+ if (used > bytes)
124
+ break;
125
+ kept += point;
126
+ }
127
+ return kept;
128
+ }
129
+ function trimmedEnd(text) {
130
+ let end = text.length;
131
+ while (end > 0 && AUTHORED_NAME_RULE.refusedEnds.includes(text[end - 1]))
132
+ end -= 1;
133
+ return text.slice(0, end);
134
+ }
135
+ function trimmedStart(text) {
136
+ let start = 0;
137
+ while (start < text.length && text[start] === AUTHORED_NAME_RULE.refusedStart)
138
+ start += 1;
139
+ return text.slice(start);
140
+ }
141
+ export function nameParts(name) {
142
+ const dot = name.lastIndexOf('.');
143
+ return dot <= 0
144
+ ? { stem: name, extension: '' }
145
+ : { stem: name.slice(0, dot), extension: name.slice(dot) };
146
+ }
147
+ function fitted(stem, extension, tail, count) {
148
+ const suffix = count > 1 ? `-${count}` : '';
149
+ const room = AUTHORED_NAME_MAX_BYTES - utf8Bytes(suffix);
150
+ const whole = utf8Bytes(`${extension}${tail}`) < room;
151
+ const kept = whole ? `${extension}${tail}` : tail;
152
+ const cut = cutToBytes(whole ? stem : `${stem}${extension}`, room - utf8Bytes(kept));
153
+ return `${suffix === '' && kept === '' ? trimmedEnd(cut) : cut}${suffix}${kept}`;
154
+ }
155
+ export function fittedName(name, count = 1, tail = '') {
156
+ let replaced = '';
157
+ for (const point of name.replace(LONE_SURROGATES, '\uFFFD').normalize('NFC'))
158
+ replaced += refusedCharacter(point) ? '-' : point;
159
+ const { stem: typed, extension } = nameParts(trimmedEnd(replaced));
160
+ const stem = trimmedStart(typed);
161
+ const named = stem !== '' && nameRefusal(fitted(stem, extension, tail, 1)) === null ? stem : FITTED_STEM;
162
+ const counted = fitted(named, extension, tail, count);
163
+ return nameRefusal(counted) === null ? counted : fitted(FITTED_STEM, extension, tail, count);
164
+ }
package/dist/chunks.js CHANGED
@@ -103,7 +103,7 @@ export async function chunkedHead(listed, entry) {
103
103
  facts: {},
104
104
  revisions: {},
105
105
  changes: {},
106
- binaryFiles: {},
106
+ attachments: {},
107
107
  parts: listed.parts,
108
108
  ...(models === undefined ? {} : { models }),
109
109
  };
@@ -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[];
@@ -58,9 +60,14 @@ export type HouseSiteAuthority = LogPosition & {
58
60
  roomHandle: string;
59
61
  schema: string;
60
62
  };
63
+ export type HouseSiteQueried = {
64
+ roomRef: string;
65
+ roomHandle: string;
66
+ };
61
67
  export type HouseSiteDiscovery = {
62
68
  bounds: HouseBounds;
63
69
  authorities: readonly HouseSiteAuthority[];
70
+ queriesOnly: readonly HouseSiteQueried[];
64
71
  };
65
72
  export declare const RO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AAC,IAAI,EAAE,OAAO,GAAG,sBAAsB,GAAG,IAAI,CA0B3E;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,OAAO,GAAG,oBAAoB,GAAG,IAAI,CAgB/E;AA2BD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,kBAAkB,GAAG,IAAI,CAU3E;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,kBAAkB,GAAG,gBAAgB,EAAE,CAU5E;AAED,wBAAgB,WAAW,CACzB,QAAQ,EAAE,IAAI,CAAC,sBAAsB,EAAE,aAAa,CAAC,GACpD,gBAAgB,EAAE,CAUpB;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,aAAa,EAAE,CAmB5E;AAED,wBAAgB,iBAAiB,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,CAWxD;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
@@ -1,5 +1,5 @@
1
1
  import { declaredActions } from './actions.js';
2
- import { SITES_SUBMISSIONS_CREATE } from './transport.js';
2
+ import { SITE_DOOR_ACTS } from './transport.js';
3
3
  import { readPosition, roomVersion } from './version.js';
4
4
  export const PROVIDER_ACTIONS = 'provider-actions';
5
5
  const BOUND_KEYS = [
@@ -13,6 +13,11 @@ const BOUND_KEYS = [
13
13
  'max_prefixes',
14
14
  'change_retention_seconds',
15
15
  ];
16
+ const MEMBER_BOUND_KEYS = [
17
+ 'max_move_documents',
18
+ 'max_indexed_fields',
19
+ 'max_indexed_text_length',
20
+ ];
16
21
  const OPERATION_KEYS = ['write', 'erase'];
17
22
  const ACCESS_LEVELS = ['search', 'open', 'keep'];
18
23
  const ROOM_ACCESS = [
@@ -38,11 +43,13 @@ function parseBounds(value) {
38
43
  return null;
39
44
  bounds[key] = amount;
40
45
  }
41
- const moves = held.max_move_documents;
42
- if (moves !== undefined) {
43
- if (typeof moves !== 'number' || !Number.isFinite(moves))
46
+ for (const key of MEMBER_BOUND_KEYS) {
47
+ const amount = held[key];
48
+ if (amount === undefined)
49
+ continue;
50
+ if (typeof amount !== 'number' || !Number.isFinite(amount))
44
51
  return null;
45
- bounds.max_move_documents = moves;
52
+ bounds[key] = amount;
46
53
  }
47
54
  return bounds;
48
55
  }
@@ -327,6 +334,16 @@ function parseSiteAuthority(value) {
327
334
  ...at,
328
335
  };
329
336
  }
337
+ function parseSiteQueried(value) {
338
+ if (typeof value !== 'object' || value === null)
339
+ return null;
340
+ const { room_ref, room_handle } = value;
341
+ if (typeof room_ref !== 'string' || room_ref.length === 0)
342
+ return null;
343
+ if (typeof room_handle !== 'string' || room_handle.length === 0)
344
+ return null;
345
+ return { roomRef: room_ref, roomHandle: room_handle };
346
+ }
330
347
  export function parseSiteDiscovery(body) {
331
348
  if (typeof body !== 'object' || body === null)
332
349
  return null;
@@ -334,16 +351,11 @@ export function parseSiteDiscovery(body) {
334
351
  const bounds = parseBounds(held.bounds);
335
352
  if (bounds === null)
336
353
  return null;
337
- if (!Array.isArray(held.authorities))
354
+ const authorities = parsedAll(held.authorities, parseSiteAuthority);
355
+ const queriesOnly = held.queries_only === undefined ? [] : parsedAll(held.queries_only, parseSiteQueried);
356
+ if (authorities === null || queriesOnly === null)
338
357
  return null;
339
- const authorities = [];
340
- for (const entry of held.authorities) {
341
- const authority = parseSiteAuthority(entry);
342
- if (authority === null)
343
- return null;
344
- authorities.push(authority);
345
- }
346
- return { bounds, authorities };
358
+ return { bounds, authorities, queriesOnly };
347
359
  }
348
360
  export function siteTracked(document) {
349
361
  return document.authorities.map((authority) => ({
@@ -377,6 +389,12 @@ export function providerLimits(bounds) {
377
389
  ...(bounds.max_move_documents === undefined
378
390
  ? []
379
391
  : [{ name: 'move-documents', value: bounds.max_move_documents }]),
392
+ ...(bounds.max_indexed_fields === undefined
393
+ ? []
394
+ : [{ name: 'indexed-fields', value: bounds.max_indexed_fields }]),
395
+ ...(bounds.max_indexed_text_length === undefined
396
+ ? []
397
+ : [{ name: 'indexed-text-length', value: bounds.max_indexed_text_length }]),
380
398
  { name: 'write-rate' },
381
399
  { name: 'storage-limit' },
382
400
  ];
@@ -394,7 +412,11 @@ export function siteCapabilities() {
394
412
  return [
395
413
  {
396
414
  name: PROVIDER_ACTIONS,
397
- actions: [{ name: SITES_SUBMISSIONS_CREATE, inputShape: {}, resultKind: 'house' }],
415
+ actions: Object.keys(SITE_DOOR_ACTS).map((name) => ({
416
+ name,
417
+ inputShape: {},
418
+ resultKind: 'house',
419
+ })),
398
420
  },
399
421
  ];
400
422
  }
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, 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_RUNTIME_READS, houseDoorRoute, houseSiteRoute, 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, nameRefusal, pathRefusal, RESERVED_DERIVED, 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';
@@ -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;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,SAAS,EAAE,aAAa,EAAE,IAAI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5D,OAAO,EACL,YAAY,EACZ,uBAAuB,EACvB,kBAAkB,EAClB,uBAAuB,EACvB,UAAU,EACV,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,QAAQ,EACR,SAAS,EACT,mBAAmB,EACnB,KAAK,WAAW,EAChB,KAAK,WAAW,GACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,wBAAwB,EACxB,UAAU,EACV,2BAA2B,EAC3B,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"}
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, 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_RUNTIME_READS, houseDoorRoute, houseSiteRoute, } 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, nameRefusal, pathRefusal, RESERVED_DERIVED, 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 BinaryFile, type BootstrapPage, type SavedFacts } from '@agentshouse/mdruntime';
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 binaryFiles: Map<string, BinaryFile>;
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
- binaryFiles: Readonly<Record<string, BinaryFile>>;
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?: BinaryFile;
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 binaryFileOf(held: Readonly<Record<string, unknown>>): BinaryFile | undefined | null;
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;