@agentshouse/mdruntime-adapter 0.1.0-c57620a2c643e → 0.1.0-c57c76f615a7b

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.
Files changed (69) hide show
  1. package/README.md +1 -1
  2. package/dist/actions.d.ts +4 -0
  3. package/dist/actions.d.ts.map +1 -1
  4. package/dist/actions.js +48 -3
  5. package/dist/adapter.d.ts.map +1 -1
  6. package/dist/adapter.js +108 -111
  7. package/dist/authored-path.d.ts +59 -3
  8. package/dist/authored-path.d.ts.map +1 -1
  9. package/dist/authored-path.js +142 -11
  10. package/dist/chunks.d.ts +2 -3
  11. package/dist/chunks.d.ts.map +1 -1
  12. package/dist/chunks.js +47 -35
  13. package/dist/discovery.d.ts +25 -5
  14. package/dist/discovery.d.ts.map +1 -1
  15. package/dist/discovery.js +169 -21
  16. package/dist/index.d.ts +5 -8
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +5 -8
  19. package/dist/model.d.ts +5 -5
  20. package/dist/model.d.ts.map +1 -1
  21. package/dist/model.js +17 -27
  22. package/dist/read.d.ts +11 -24
  23. package/dist/read.d.ts.map +1 -1
  24. package/dist/read.js +71 -44
  25. package/dist/refusal.d.ts +4 -1
  26. package/dist/refusal.d.ts.map +1 -1
  27. package/dist/refusal.js +11 -0
  28. package/dist/renamed.d.ts +10 -0
  29. package/dist/renamed.d.ts.map +1 -0
  30. package/dist/renamed.js +29 -0
  31. package/dist/room-query.d.ts +4 -0
  32. package/dist/room-query.d.ts.map +1 -0
  33. package/dist/room-query.js +63 -0
  34. package/dist/session-content/check.d.ts +0 -1
  35. package/dist/session-content/index.d.ts +2 -3
  36. package/dist/session-content/parts.d.ts +10 -83
  37. package/dist/session-content/state.d.ts +4 -6
  38. package/dist/session-content/turn.d.ts +28 -219
  39. package/dist/site.d.ts.map +1 -1
  40. package/dist/site.js +45 -13
  41. package/dist/space-schema.d.ts +1 -1
  42. package/dist/space-schema.d.ts.map +1 -1
  43. package/dist/space-schema.js +2 -9
  44. package/dist/stream.d.ts +2 -3
  45. package/dist/stream.d.ts.map +1 -1
  46. package/dist/stream.js +73 -93
  47. package/dist/transport.d.ts +43 -12
  48. package/dist/transport.d.ts.map +1 -1
  49. package/dist/transport.js +47 -7
  50. package/dist/upload.d.ts +4 -0
  51. package/dist/upload.d.ts.map +1 -1
  52. package/dist/upload.js +41 -0
  53. package/dist/write.d.ts +1 -2
  54. package/dist/write.d.ts.map +1 -1
  55. package/dist/write.js +13 -15
  56. package/package.json +4 -3
  57. package/dist/app-reference.d.ts +0 -1
  58. package/dist/app-reference.d.ts.map +0 -1
  59. package/dist/app-reference.js +0 -2
  60. package/dist/crockford.d.ts +0 -3
  61. package/dist/crockford.d.ts.map +0 -1
  62. package/dist/crockford.js +0 -3
  63. package/dist/house-model.d.ts +0 -826
  64. package/dist/house-model.d.ts.map +0 -1
  65. package/dist/house-model.js +0 -464
  66. package/dist/room-types.d.ts +0 -4
  67. package/dist/room-types.d.ts.map +0 -1
  68. package/dist/room-types.js +0 -136
  69. package/dist/session-content/bounds.d.ts +0 -7
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,10 @@ 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>;
7
+ export declare const HOUSE_REWRITTEN_UNTIL_2026_12_19: ReadonlyMap<string, (input: unknown) => unknown>;
8
+ export declare const HOUSE_RENAMED_UNTIL_2026_12_21: ReadonlyMap<string, string>;
9
+ export declare const HOUSE_REWRITTEN_UNTIL_2026_12_21: ReadonlyMap<string, (input: unknown) => unknown>;
6
10
  export declare function declaredActions(routes: readonly string[]): readonly ActionDeclaration[];
7
11
  export declare function houseAction(transport: HouseActDoor, request: ActionRequest): Promise<ActionResult>;
8
12
  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,EAG/C,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAKhD,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;AAI7F,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,EAKhD,CAAC;AAEF,eAAO,MAAM,8BAA8B,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAErE,CAAC;AAQH,eAAO,MAAM,gCAAgC,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CACvD,CAAC;AAExC,eAAO,MAAM,8BAA8B,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAGrE,CAAC;AAiBH,eAAO,MAAM,gCAAgC,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAI1F,CAAC;AAQL,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,iBAAiB,EAAE,CAOvF;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
@@ -1,17 +1,57 @@
1
1
  import { answeredFailure, doorRefusal, resetOf } from './refusal.js';
2
+ import { movedPaths, renamedHandle } from './renamed.js';
2
3
  import { refusedFor } from './uncertain.js';
3
4
  export const HOUSE_UNKEPT_READS = [
4
5
  'account/security/read',
6
+ 'billing/read',
5
7
  'clients/last-use/list',
6
8
  ];
7
9
  export const HOUSE_LEADING_READS = [
8
- 'rooms/list',
10
+ 'app.list',
9
11
  'apps/list',
10
12
  'sites/list',
11
13
  'rooms/members/list',
12
14
  ];
15
+ export const HOUSE_RENAMED_UNTIL_2026_12_18 = new Map([
16
+ ['files/batch', 'update'],
17
+ ]);
18
+ function withoutRoomRef(input) {
19
+ if (typeof input !== 'object' || input === null || !('room_ref' in input))
20
+ return input;
21
+ const { room_ref: _room, ...paths } = input;
22
+ return paths;
23
+ }
24
+ export const HOUSE_REWRITTEN_UNTIL_2026_12_19 = new Map([['update', withoutRoomRef]]);
25
+ export const HOUSE_RENAMED_UNTIL_2026_12_21 = new Map([
26
+ ['apps/create', 'app_update'],
27
+ ['apps/upload', 'app_update'],
28
+ ]);
29
+ function held(input) {
30
+ return typeof input === 'object' && input !== null
31
+ ? { ...input }
32
+ : {};
33
+ }
34
+ function created(input) {
35
+ return { op: 'create', ...held(input) };
36
+ }
37
+ function uploaded(input) {
38
+ const { app_ref: app, ...files } = held(input);
39
+ return { op: 'publish', app, ...files };
40
+ }
41
+ export const HOUSE_REWRITTEN_UNTIL_2026_12_21 = new Map([
42
+ ['apps/create', created],
43
+ ['apps/upload', uploaded],
44
+ ]);
45
+ const ROOM_SELECTORS = new Map([
46
+ ['update', { room: 'changes.room', roomPaths: ['changes.path', 'changes.to', 'paths', 'mount'] }],
47
+ ]);
13
48
  export function declaredActions(routes) {
14
- return routes.map((name) => ({ name, inputShape: {}, resultKind: 'house', room: 'room_ref' }));
49
+ return routes.map((name) => ({
50
+ name,
51
+ inputShape: {},
52
+ resultKind: 'house',
53
+ ...(ROOM_SELECTORS.get(name) ?? { room: 'room_ref' }),
54
+ }));
15
55
  }
16
56
  export function houseAction(transport, request) {
17
57
  const route = routeOf(request.name);
@@ -57,5 +97,10 @@ export function actionOutcome(answer, name, input) {
57
97
  return { kind: 'action', result: answer.body };
58
98
  }
59
99
  async function carry(transport, route, name, input) {
60
- return actionOutcome(await transport.door(route, input), name, input);
100
+ const answered = actionOutcome(await transport.door(route, input), name, input);
101
+ const renamed = renamedHandle(answered);
102
+ if (renamed === null)
103
+ return answered;
104
+ const moved = movedPaths(input, renamed);
105
+ return actionOutcome(await transport.door(route, moved), name, moved);
61
106
  }
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,OAAO,EAIP,aAAa,EAiBd,MAAM,wBAAwB,CAAC;AA0BhC,OAAO,EAIL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAqBxB,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;AAqBrD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CA2bpF"}
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;AAkChC,OAAO,EAIL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAoBxB,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,CA2cpF"}
package/dist/adapter.js CHANGED
@@ -1,42 +1,36 @@
1
+ import { HOUSE_ROOM_TYPES, HOUSE_TYPED_PATHS } from '@agentshouse/mdmodel';
1
2
  import { stepped } from '@agentshouse/mdruntime';
2
3
  import { capabilities, discoveredRoom, mapDiscovery, parseAuthorityChange, parseDiscovery, trackedFrom, } from './discovery.js';
3
4
  import { createSiteAdapter } from './site.js';
4
5
  import { parseFileAddress, parseGrant } from './read.js';
5
6
  import { chunkedHead, chunkLister, chunkPart } from './chunks.js';
6
- import { spaceSchemas } from './space-schema.js';
7
- 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_RENAMED_UNTIL_2026_12_21, HOUSE_REWRITTEN_UNTIL_2026_12_19, HOUSE_REWRITTEN_UNTIL_2026_12_21, HOUSE_UNKEPT_READS, } from './actions.js';
9
+ import { houseQuery } from './room-query.js';
9
10
  import { houseSearch } from './search.js';
10
- import { answeredFailure, classifyDoor, doorRefusal } from './refusal.js';
11
+ import { answeredFailure, classifyDoor, keyedFailure } from './refusal.js';
11
12
  import { UNANSWERED, unusable } from './uncertain.js';
12
13
  import { houseNotifications, } from './stream.js';
13
14
  import { houseDoorRoute, } from './transport.js';
15
+ import { renamedHandle } from './renamed.js';
14
16
  import { batchPaths, deltaBody, deltaBytes, deltaDigest, historyOutcome, houseChanges, houseMove, mutationOutcome, operationHead, rejectedMapping, revisionBody, uploadable, } from './write.js';
15
17
  import { admittedPath } from './authored-path.js';
16
- import { HOUSE_TYPED_PATHS } from './house-model.js';
17
- import { HOUSE_NAMEABLE_ROOM_TYPES, HOUSE_ROOM_TYPES } from './room-types.js';
18
18
  import { followsVersion, reachedVersion, roomVersion } from './version.js';
19
- const OCTET_STREAM = 'application/octet-stream';
20
19
  const EXPIRED_ADDRESS = 403;
21
20
  function lapsedGrant(outcome) {
22
21
  return outcome.kind === 'rejected' && outcome.code === 'upload_unavailable';
23
22
  }
24
- function unstagedRefusal(answer) {
25
- const refusal = doorRefusal(answer.body);
26
- return refusal?.code === 'files_unstaged' ? refusal : null;
27
- }
28
23
  export function createAgentsHouseAdapter(options) {
29
24
  if ('site' in options)
30
25
  return createSiteAdapter(options.site, options.snapshot === true);
31
26
  const transport = options.transport;
32
- const spaces = spaceSchemas();
33
27
  const notifications = houseNotifications(transport, 'credential', {
34
28
  opened: async (frame) => (frame === null ? null : opened(frame)),
35
29
  changed,
36
- expired: (authorities) => lister.askAll(authorities.flatMap((authority) => [...tracked.values()].filter((entry) => entry.authority === authority))),
37
- }, spaces);
30
+ expired: (entries) => lister.askAll(entries),
31
+ });
38
32
  const tracked = new Map();
39
- const lister = chunkLister(transport, () => declared().max_prefixes);
33
+ const lister = chunkLister(transport, () => declared().max_prefixes, (locator) => tracked.get(locator));
40
34
  const chunked = new Map();
41
35
  const renewals = new WeakMap();
42
36
  let bounds;
@@ -58,13 +52,16 @@ export function createAgentsHouseAdapter(options) {
58
52
  return {
59
53
  ...mapDiscovery(document, document.authorities.map((authority) => discoveredRoom(authority)), capabilities(document.actions)),
60
54
  member: document.member,
55
+ timeZone: document.timeZone,
56
+ roomList: document.roomList,
61
57
  };
62
58
  }
63
59
  function changed(frame) {
64
60
  const change = parseAuthorityChange(frame);
65
61
  if (change === null)
66
62
  return null;
67
- for (const locator of change.left)
63
+ const unheld = [...change.left, ...change.listed];
64
+ for (const locator of unheld)
68
65
  tracked.delete(locator);
69
66
  for (const entry of trackedFrom(change))
70
67
  tracked.set(entry.locator, entry);
@@ -72,15 +69,17 @@ export function createAgentsHouseAdapter(options) {
72
69
  return {
73
70
  kind: 'authority-changed',
74
71
  rooms: change.authorities.map((authority) => discoveredRoom(authority)),
75
- left: change.left,
72
+ left: unheld,
76
73
  member: change.member,
74
+ timeZone: change.timeZone,
75
+ roomList: { ...change.roomList, left: change.left },
77
76
  };
78
77
  }
79
78
  async function listedRoom(entry) {
80
79
  const listed = await lister.list(entry);
81
80
  if ('kind' in listed)
82
81
  return listed;
83
- const head = await chunkedHead(listed, entry, spaces);
82
+ const head = await chunkedHead(listed, entry);
84
83
  if (head.kind === 'bootstrap')
85
84
  chunked.set(entry.locator, listed);
86
85
  return head;
@@ -151,8 +150,9 @@ export function createAgentsHouseAdapter(options) {
151
150
  if (handed !== undefined && handed.sha256 === sha256) {
152
151
  return { body: { ...head, paths, upload: handed, runtime: notifications.runtime } };
153
152
  }
154
- const minted = await transport.door(houseDoorRoute('files/batch-upload'), {
153
+ const minted = await transport.door(houseDoorRoute('update'), {
155
154
  ...head,
155
+ op: 'stage',
156
156
  paths,
157
157
  bytes,
158
158
  sha256,
@@ -179,24 +179,6 @@ export function createAgentsHouseAdapter(options) {
179
179
  await keep(upload);
180
180
  return { body: { ...head, paths, upload, runtime: notifications.runtime } };
181
181
  }
182
- async function staged(uploads, { changeBatch: batch, file }) {
183
- if (!Array.isArray(uploads))
184
- return unusable();
185
- for (const named of uploads) {
186
- const upload = houseUpload(named);
187
- const change = batch.changes.find((held) => held.kind === 'binary' && held.sha256 === named.sha256);
188
- if (upload === null || change === undefined)
189
- return unusable();
190
- const finished = await finishedUpload(transport, upload, await file(change.localId));
191
- if ('unfinished' in finished)
192
- return answeredFailure(finished.unfinished, null);
193
- if (finished.status !== 200)
194
- return answeredFailure(finished.status, finished.body);
195
- if (finished.body?.staged !== true)
196
- return unusable();
197
- }
198
- return null;
199
- }
200
182
  async function submit(request, head, changes, delta, bytes, entry, handed, keep, into) {
201
183
  const inline = { ...head, changes, runtime: notifications.runtime };
202
184
  const prepared = uploadable(inline, bytes, declared())
@@ -204,19 +186,12 @@ export function createAgentsHouseAdapter(options) {
204
186
  : { body: inline };
205
187
  if ('outcome' in prepared)
206
188
  return prepared.outcome;
207
- const answer = await transport.door(houseDoorRoute('files/batch'), prepared.body);
208
- const unstaged = unstagedRefusal(answer);
209
- if (unstaged !== null) {
210
- const staging = await staged(unstaged.fields.upload, request);
211
- if (staging !== null)
212
- return staging;
213
- }
214
- const settled = unstaged === null
215
- ? answer
216
- : await transport.door(houseDoorRoute('files/batch'), prepared.body);
217
- if (unstaged !== null && unstagedRefusal(settled) !== null) {
218
- return answeredFailure(settled.status, settled.body);
219
- }
189
+ const settled = await stagedBatch(transport, prepared.body, (sha256) => {
190
+ const change = request.changeBatch.changes.find((held) => held.kind === 'binary' && held.sha256 === sha256);
191
+ return change === undefined ? null : request.file(change.localId);
192
+ });
193
+ if ('kind' in settled)
194
+ return settled;
220
195
  return stepped(mutationOutcome(settled.status, settled.body, entry.locator, entry.handle, into === undefined
221
196
  ? undefined
222
197
  : {
@@ -224,28 +199,26 @@ export function createAgentsHouseAdapter(options) {
224
199
  destination: { authority: into.authority, handle: into.handle },
225
200
  }));
226
201
  }
227
- function addressed(answer, locator) {
228
- const failure = classifyDoor(answer.status, answer.body, locator);
229
- if (failure !== null) {
230
- return failure.kind === 'scoped-refusal'
231
- ? {
232
- kind: 'rejected',
233
- code: failure.code,
234
- fields: failure.fields,
235
- retryable: failure.retryable,
236
- }
237
- : failure;
238
- }
239
- const address = parseFileAddress(answer.body);
240
- return address === null ? unusable() : { kind: 'address', ...address };
202
+ async function mutated(request, keep, entry, into) {
203
+ const batch = request.changeBatch;
204
+ const mapped = into === undefined
205
+ ? houseChanges(batch, entry.handle)
206
+ : houseMove(batch, entry.handle, into.handle);
207
+ if (mapped.kind === 'unmapped')
208
+ return rejectedMapping(mapped);
209
+ const head = operationHead(batch);
210
+ const delta = deltaBody(mapped.changes);
211
+ const bytes = deltaBytes(delta);
212
+ const handed = request.upload;
213
+ const answer = (upload) => submit(request, head, mapped.changes, delta, bytes, entry, upload, keep, into);
214
+ const outcome = await answer(handed);
215
+ if (handed === undefined || !lapsedGrant(outcome))
216
+ return outcome;
217
+ return answer(undefined);
241
218
  }
242
- function linked(answer, locator) {
243
- const address = addressed(answer, locator);
244
- return address.kind === 'address'
245
- ? { kind: 'link', url: address.url, name: address.name, mediaType: address.mediaType }
246
- : address;
247
- }
248
- function refusedAttach(answer, locator) {
219
+ function refusedOn(answer, locator) {
220
+ if (locator === null)
221
+ return keyedFailure(answer.status, answer.body);
249
222
  const failure = classifyDoor(answer.status, answer.body, locator);
250
223
  if (failure === null)
251
224
  return null;
@@ -258,6 +231,48 @@ export function createAgentsHouseAdapter(options) {
258
231
  }
259
232
  : failure;
260
233
  }
234
+ function addressed(answer, locator) {
235
+ const failure = refusedOn(answer, locator);
236
+ if (failure !== null)
237
+ return failure;
238
+ const address = parseFileAddress(answer.body);
239
+ return address === null ? unusable() : { kind: 'address', ...address };
240
+ }
241
+ function linked(answer, locator) {
242
+ const address = addressed(answer, locator);
243
+ return address.kind === 'address'
244
+ ? { kind: 'link', url: address.url, name: address.name, mediaType: address.mediaType }
245
+ : address;
246
+ }
247
+ async function attached(request, into) {
248
+ const locator = into?.locator ?? null;
249
+ const declared = await transport.door(houseDoorRoute('files/attach'), {
250
+ ...(into === null ? {} : { room_ref: into.authority }),
251
+ name: request.name,
252
+ bytes: request.byteLength,
253
+ sha256: request.sha256,
254
+ media_type: request.mediaType,
255
+ });
256
+ const refused = refusedOn(declared, locator);
257
+ if (refused !== null)
258
+ return refused;
259
+ const upload = houseUpload(declared.body?.upload);
260
+ if (upload === null)
261
+ return unusable();
262
+ const finished = await finishedUpload(transport, upload, request.blob);
263
+ if ('unfinished' in finished)
264
+ return answeredFailure(finished.unfinished, null);
265
+ const unfinished = refusedOn(finished, locator);
266
+ if (unfinished !== null)
267
+ return unfinished;
268
+ const { path, revision, link } = (finished.body ?? {});
269
+ if (into === null)
270
+ return typeof link === 'string' ? { kind: 'linked', link } : unusable();
271
+ const root = `/rooms/${into.handle}/`;
272
+ return typeof path === 'string' && path.startsWith(root) && typeof revision === 'string'
273
+ ? { kind: 'attached', path: path.slice(root.length), revision }
274
+ : unusable();
275
+ }
261
276
  async function downloaded(ask, locator) {
262
277
  let address = addressed(await ask(), locator);
263
278
  if (address.kind !== 'address')
@@ -278,6 +293,8 @@ export function createAgentsHouseAdapter(options) {
278
293
  body: read.body,
279
294
  mediaType: address.mediaType,
280
295
  sha256: address.sha256,
296
+ url: address.url,
297
+ copies: address.copies,
281
298
  };
282
299
  }
283
300
  function pathAddress(request) {
@@ -292,11 +309,15 @@ export function createAgentsHouseAdapter(options) {
292
309
  }
293
310
  return {
294
311
  roomTypes: HOUSE_ROOM_TYPES,
295
- nameableRoomTypes: HOUSE_NAMEABLE_ROOM_TYPES,
296
312
  typedPaths: HOUSE_TYPED_PATHS,
297
313
  pathRule: admittedPath,
298
314
  unkeptReads: HOUSE_UNKEPT_READS,
299
315
  leadingReads: HOUSE_LEADING_READS,
316
+ renamedActions: new Map([...HOUSE_RENAMED_UNTIL_2026_12_18, ...HOUSE_RENAMED_UNTIL_2026_12_21]),
317
+ rewrittenInputs: new Map([
318
+ ...HOUSE_REWRITTEN_UNTIL_2026_12_19,
319
+ ...HOUSE_REWRITTEN_UNTIL_2026_12_21,
320
+ ]),
300
321
  async authorize() {
301
322
  return options.authorize();
302
323
  },
@@ -312,26 +333,17 @@ export function createAgentsHouseAdapter(options) {
312
333
  const entry = authorityFor(request.locator);
313
334
  if (entry === undefined)
314
335
  return { kind: 'room-not-readable', locator: request.locator };
315
- const batch = request.changeBatch;
316
- const destination = batch.between?.destination.room;
336
+ const destination = request.changeBatch.between?.destination.room;
317
337
  const into = destination === undefined ? undefined : authorityFor(destination);
318
338
  if (destination !== undefined && into === undefined) {
319
339
  return { kind: 'room-not-readable', locator: destination };
320
340
  }
321
- const mapped = into === undefined
322
- ? houseChanges(batch, entry.handle)
323
- : houseMove(batch, entry.handle, into.handle);
324
- if (mapped.kind === 'unmapped')
325
- return rejectedMapping(mapped);
326
- const head = operationHead(batch, entry.authority);
327
- const delta = deltaBody(mapped.changes);
328
- const bytes = deltaBytes(delta);
329
- const handed = request.upload;
330
- const answer = (upload) => submit(request, head, mapped.changes, delta, bytes, entry, upload, keep, into);
331
- const outcome = await answer(handed);
332
- if (handed === undefined || !lapsedGrant(outcome))
341
+ const outcome = await mutated(request, keep, entry, into);
342
+ const renamed = renamedHandle(outcome);
343
+ if (renamed === null)
333
344
  return outcome;
334
- return answer(undefined);
345
+ const moved = (held) => held.handle === renamed.from ? { ...held, handle: renamed.to } : held;
346
+ return mutated(request, keep, moved(entry), into === undefined ? undefined : moved(into));
335
347
  },
336
348
  async history(_authorization, request) {
337
349
  const entry = authorityFor(request.locator);
@@ -352,39 +364,21 @@ export function createAgentsHouseAdapter(options) {
352
364
  return downloaded(ask, request.locator);
353
365
  },
354
366
  async link(_authorization, request) {
367
+ if (request.kind === 'key') {
368
+ return linked(await transport.door(houseDoorRoute('files/read'), { link: request.link }), null);
369
+ }
355
370
  const ask = pathAddress(request);
356
371
  if (ask === null)
357
372
  return { kind: 'room-not-readable', locator: request.locator };
358
373
  return linked(await ask(), request.locator);
359
374
  },
360
375
  async attach(_authorization, request) {
376
+ if (request.locator === undefined)
377
+ return attached(request, null);
361
378
  const entry = authorityFor(request.locator);
362
379
  if (entry === undefined)
363
380
  return { kind: 'room-not-readable', locator: request.locator };
364
- const declared = await transport.door(houseDoorRoute('files/attach'), {
365
- room_ref: entry.authority,
366
- name: request.name,
367
- bytes: request.byteLength,
368
- sha256: request.sha256,
369
- media_type: request.mediaType.length > 0 ? request.mediaType : OCTET_STREAM,
370
- });
371
- const refused = refusedAttach(declared, request.locator);
372
- if (refused !== null)
373
- return refused;
374
- const upload = houseUpload(declared.body?.upload);
375
- if (upload === null)
376
- return unusable();
377
- const finished = await finishedUpload(transport, upload, request.blob);
378
- if ('unfinished' in finished)
379
- return answeredFailure(finished.unfinished, null);
380
- const unfinished = refusedAttach(finished, request.locator);
381
- if (unfinished !== null)
382
- return unfinished;
383
- const { path, revision } = (finished.body ?? {});
384
- const root = `/rooms/${entry.handle}/`;
385
- return typeof path === 'string' && path.startsWith(root) && typeof revision === 'string'
386
- ? { kind: 'attached', path: path.slice(root.length), revision }
387
- : unusable();
381
+ return attached(request, entry);
388
382
  },
389
383
  reached(locator, version, target) {
390
384
  return reachedVersion(version, target, authorityFor(locator)?.logEpoch);
@@ -398,6 +392,9 @@ export function createAgentsHouseAdapter(options) {
398
392
  search(_authorization, request) {
399
393
  return houseSearch(transport, [...tracked.values()], request);
400
394
  },
395
+ queryHouse(_authorization, request) {
396
+ return houseQuery(transport, request);
397
+ },
401
398
  roomStream: {
402
399
  hold,
403
400
  observe: notifications.observe,
@@ -2,9 +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[];
9
- export declare const APP_PREFERENCES_HOME = "settings/apps";
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;
10
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,0BAA0B,MAAM,CAAC;AAO9C,eAAO,MAAM,gBAAgB,QAE5B,CAAC;AAEF,eAAO,MAAM,mBAAmB,WAAW,CAAC;AAE5C,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAIlD,CAAC;AAEF,eAAO,MAAM,oBAAoB,kBAAkB,CAAC;AASpD,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;A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