@agentshouse/mdruntime-adapter 0.1.0-c65e490a04837 → 0.1.0-c661422fdfe5e
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 +4 -1
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +76 -87
- 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.d.ts.map +1 -1
- package/dist/chunks.js +13 -21
- package/dist/discovery.d.ts +25 -5
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +169 -21
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -4
- package/dist/model.d.ts +3 -3
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +9 -18
- package/dist/read.d.ts +11 -24
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +69 -42
- package/dist/refusal.d.ts +4 -1
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +11 -0
- package/dist/room-query.d.ts +4 -0
- package/dist/room-query.d.ts.map +1 -0
- package/dist/room-query.js +58 -0
- package/dist/session-content/check.d.ts +0 -1
- package/dist/session-content/index.d.ts +2 -3
- package/dist/session-content/parts.d.ts +10 -83
- package/dist/session-content/state.d.ts +4 -6
- package/dist/session-content/turn.d.ts +28 -219
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +33 -5
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +23 -35
- package/dist/transport.d.ts +33 -9
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +39 -3
- package/dist/upload.d.ts +4 -0
- package/dist/upload.d.ts.map +1 -1
- package/dist/upload.js +41 -0
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +11 -13
- package/package.json +4 -4
- 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
|
|
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,
|
|
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
|
@@ -2,14 +2,17 @@ import { answeredFailure, doorRefusal, resetOf } from './refusal.js';
|
|
|
2
2
|
import { refusedFor } from './uncertain.js';
|
|
3
3
|
export const HOUSE_UNKEPT_READS = [
|
|
4
4
|
'account/security/read',
|
|
5
|
+
'billing/read',
|
|
5
6
|
'clients/last-use/list',
|
|
6
7
|
];
|
|
7
8
|
export const HOUSE_LEADING_READS = [
|
|
8
|
-
'rooms/list',
|
|
9
9
|
'apps/list',
|
|
10
10
|
'sites/list',
|
|
11
11
|
'rooms/members/list',
|
|
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,10 +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
|
+
import { houseQuery } from './room-query.js';
|
|
9
10
|
import { houseSearch } from './search.js';
|
|
10
|
-
import { answeredFailure, classifyDoor,
|
|
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';
|
|
@@ -18,10 +19,6 @@ const EXPIRED_ADDRESS = 403;
|
|
|
18
19
|
function lapsedGrant(outcome) {
|
|
19
20
|
return outcome.kind === 'rejected' && outcome.code === 'upload_unavailable';
|
|
20
21
|
}
|
|
21
|
-
function unstagedRefusal(answer) {
|
|
22
|
-
const refusal = doorRefusal(answer.body);
|
|
23
|
-
return refusal?.code === 'files_unstaged' ? refusal : null;
|
|
24
|
-
}
|
|
25
22
|
export function createAgentsHouseAdapter(options) {
|
|
26
23
|
if ('site' in options)
|
|
27
24
|
return createSiteAdapter(options.site, options.snapshot === true);
|
|
@@ -54,13 +51,16 @@ export function createAgentsHouseAdapter(options) {
|
|
|
54
51
|
return {
|
|
55
52
|
...mapDiscovery(document, document.authorities.map((authority) => discoveredRoom(authority)), capabilities(document.actions)),
|
|
56
53
|
member: document.member,
|
|
54
|
+
timeZone: document.timeZone,
|
|
55
|
+
roomList: document.roomList,
|
|
57
56
|
};
|
|
58
57
|
}
|
|
59
58
|
function changed(frame) {
|
|
60
59
|
const change = parseAuthorityChange(frame);
|
|
61
60
|
if (change === null)
|
|
62
61
|
return null;
|
|
63
|
-
|
|
62
|
+
const unheld = [...change.left, ...change.listed];
|
|
63
|
+
for (const locator of unheld)
|
|
64
64
|
tracked.delete(locator);
|
|
65
65
|
for (const entry of trackedFrom(change))
|
|
66
66
|
tracked.set(entry.locator, entry);
|
|
@@ -68,8 +68,10 @@ export function createAgentsHouseAdapter(options) {
|
|
|
68
68
|
return {
|
|
69
69
|
kind: 'authority-changed',
|
|
70
70
|
rooms: change.authorities.map((authority) => discoveredRoom(authority)),
|
|
71
|
-
left:
|
|
71
|
+
left: unheld,
|
|
72
72
|
member: change.member,
|
|
73
|
+
timeZone: change.timeZone,
|
|
74
|
+
roomList: { ...change.roomList, left: change.left },
|
|
73
75
|
};
|
|
74
76
|
}
|
|
75
77
|
async function listedRoom(entry) {
|
|
@@ -147,8 +149,9 @@ export function createAgentsHouseAdapter(options) {
|
|
|
147
149
|
if (handed !== undefined && handed.sha256 === sha256) {
|
|
148
150
|
return { body: { ...head, paths, upload: handed, runtime: notifications.runtime } };
|
|
149
151
|
}
|
|
150
|
-
const minted = await transport.door(houseDoorRoute('
|
|
152
|
+
const minted = await transport.door(houseDoorRoute('update'), {
|
|
151
153
|
...head,
|
|
154
|
+
op: 'stage',
|
|
152
155
|
paths,
|
|
153
156
|
bytes,
|
|
154
157
|
sha256,
|
|
@@ -175,24 +178,6 @@ export function createAgentsHouseAdapter(options) {
|
|
|
175
178
|
await keep(upload);
|
|
176
179
|
return { body: { ...head, paths, upload, runtime: notifications.runtime } };
|
|
177
180
|
}
|
|
178
|
-
async function staged(uploads, { changeBatch: batch, file }) {
|
|
179
|
-
if (!Array.isArray(uploads))
|
|
180
|
-
return unusable();
|
|
181
|
-
for (const named of uploads) {
|
|
182
|
-
const upload = houseUpload(named);
|
|
183
|
-
const change = batch.changes.find((held) => held.kind === 'binary' && held.sha256 === named.sha256);
|
|
184
|
-
if (upload === null || change === undefined)
|
|
185
|
-
return unusable();
|
|
186
|
-
const finished = await finishedUpload(transport, upload, await file(change.localId));
|
|
187
|
-
if ('unfinished' in finished)
|
|
188
|
-
return answeredFailure(finished.unfinished, null);
|
|
189
|
-
if (finished.status !== 200)
|
|
190
|
-
return answeredFailure(finished.status, finished.body);
|
|
191
|
-
if (finished.body?.staged !== true)
|
|
192
|
-
return unusable();
|
|
193
|
-
}
|
|
194
|
-
return null;
|
|
195
|
-
}
|
|
196
181
|
async function submit(request, head, changes, delta, bytes, entry, handed, keep, into) {
|
|
197
182
|
const inline = { ...head, changes, runtime: notifications.runtime };
|
|
198
183
|
const prepared = uploadable(inline, bytes, declared())
|
|
@@ -200,19 +185,12 @@ export function createAgentsHouseAdapter(options) {
|
|
|
200
185
|
: { body: inline };
|
|
201
186
|
if ('outcome' in prepared)
|
|
202
187
|
return prepared.outcome;
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
const settled = unstaged === null
|
|
211
|
-
? answer
|
|
212
|
-
: await transport.door(houseDoorRoute('files/batch'), prepared.body);
|
|
213
|
-
if (unstaged !== null && unstagedRefusal(settled) !== null) {
|
|
214
|
-
return answeredFailure(settled.status, settled.body);
|
|
215
|
-
}
|
|
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;
|
|
216
194
|
return stepped(mutationOutcome(settled.status, settled.body, entry.locator, entry.handle, into === undefined
|
|
217
195
|
? undefined
|
|
218
196
|
: {
|
|
@@ -220,28 +198,9 @@ export function createAgentsHouseAdapter(options) {
|
|
|
220
198
|
destination: { authority: into.authority, handle: into.handle },
|
|
221
199
|
}));
|
|
222
200
|
}
|
|
223
|
-
function
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
return failure.kind === 'scoped-refusal'
|
|
227
|
-
? {
|
|
228
|
-
kind: 'rejected',
|
|
229
|
-
code: failure.code,
|
|
230
|
-
fields: failure.fields,
|
|
231
|
-
retryable: failure.retryable,
|
|
232
|
-
}
|
|
233
|
-
: failure;
|
|
234
|
-
}
|
|
235
|
-
const address = parseFileAddress(answer.body);
|
|
236
|
-
return address === null ? unusable() : { kind: 'address', ...address };
|
|
237
|
-
}
|
|
238
|
-
function linked(answer, locator) {
|
|
239
|
-
const address = addressed(answer, locator);
|
|
240
|
-
return address.kind === 'address'
|
|
241
|
-
? { kind: 'link', url: address.url, name: address.name, mediaType: address.mediaType }
|
|
242
|
-
: address;
|
|
243
|
-
}
|
|
244
|
-
function refusedAttach(answer, locator) {
|
|
201
|
+
function refusedOn(answer, locator) {
|
|
202
|
+
if (locator === null)
|
|
203
|
+
return keyedFailure(answer.status, answer.body);
|
|
245
204
|
const failure = classifyDoor(answer.status, answer.body, locator);
|
|
246
205
|
if (failure === null)
|
|
247
206
|
return null;
|
|
@@ -254,6 +213,48 @@ export function createAgentsHouseAdapter(options) {
|
|
|
254
213
|
}
|
|
255
214
|
: failure;
|
|
256
215
|
}
|
|
216
|
+
function addressed(answer, locator) {
|
|
217
|
+
const failure = refusedOn(answer, locator);
|
|
218
|
+
if (failure !== null)
|
|
219
|
+
return failure;
|
|
220
|
+
const address = parseFileAddress(answer.body);
|
|
221
|
+
return address === null ? unusable() : { kind: 'address', ...address };
|
|
222
|
+
}
|
|
223
|
+
function linked(answer, locator) {
|
|
224
|
+
const address = addressed(answer, locator);
|
|
225
|
+
return address.kind === 'address'
|
|
226
|
+
? { kind: 'link', url: address.url, name: address.name, mediaType: address.mediaType }
|
|
227
|
+
: address;
|
|
228
|
+
}
|
|
229
|
+
async function attached(request, into) {
|
|
230
|
+
const locator = into?.locator ?? null;
|
|
231
|
+
const declared = await transport.door(houseDoorRoute('files/attach'), {
|
|
232
|
+
...(into === null ? {} : { room_ref: into.authority }),
|
|
233
|
+
name: request.name,
|
|
234
|
+
bytes: request.byteLength,
|
|
235
|
+
sha256: request.sha256,
|
|
236
|
+
media_type: request.mediaType,
|
|
237
|
+
});
|
|
238
|
+
const refused = refusedOn(declared, locator);
|
|
239
|
+
if (refused !== null)
|
|
240
|
+
return refused;
|
|
241
|
+
const upload = houseUpload(declared.body?.upload);
|
|
242
|
+
if (upload === null)
|
|
243
|
+
return unusable();
|
|
244
|
+
const finished = await finishedUpload(transport, upload, request.blob);
|
|
245
|
+
if ('unfinished' in finished)
|
|
246
|
+
return answeredFailure(finished.unfinished, null);
|
|
247
|
+
const unfinished = refusedOn(finished, locator);
|
|
248
|
+
if (unfinished !== null)
|
|
249
|
+
return unfinished;
|
|
250
|
+
const { path, revision, link } = (finished.body ?? {});
|
|
251
|
+
if (into === null)
|
|
252
|
+
return typeof link === 'string' ? { kind: 'linked', link } : unusable();
|
|
253
|
+
const root = `/rooms/${into.handle}/`;
|
|
254
|
+
return typeof path === 'string' && path.startsWith(root) && typeof revision === 'string'
|
|
255
|
+
? { kind: 'attached', path: path.slice(root.length), revision }
|
|
256
|
+
: unusable();
|
|
257
|
+
}
|
|
257
258
|
async function downloaded(ask, locator) {
|
|
258
259
|
let address = addressed(await ask(), locator);
|
|
259
260
|
if (address.kind !== 'address')
|
|
@@ -274,6 +275,8 @@ export function createAgentsHouseAdapter(options) {
|
|
|
274
275
|
body: read.body,
|
|
275
276
|
mediaType: address.mediaType,
|
|
276
277
|
sha256: address.sha256,
|
|
278
|
+
url: address.url,
|
|
279
|
+
copies: address.copies,
|
|
277
280
|
};
|
|
278
281
|
}
|
|
279
282
|
function pathAddress(request) {
|
|
@@ -292,6 +295,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
292
295
|
pathRule: admittedPath,
|
|
293
296
|
unkeptReads: HOUSE_UNKEPT_READS,
|
|
294
297
|
leadingReads: HOUSE_LEADING_READS,
|
|
298
|
+
renamedActions: HOUSE_RENAMED_UNTIL_2026_12_18,
|
|
295
299
|
async authorize() {
|
|
296
300
|
return options.authorize();
|
|
297
301
|
},
|
|
@@ -347,39 +351,21 @@ export function createAgentsHouseAdapter(options) {
|
|
|
347
351
|
return downloaded(ask, request.locator);
|
|
348
352
|
},
|
|
349
353
|
async link(_authorization, request) {
|
|
354
|
+
if (request.kind === 'key') {
|
|
355
|
+
return linked(await transport.door(houseDoorRoute('files/read'), { link: request.link }), null);
|
|
356
|
+
}
|
|
350
357
|
const ask = pathAddress(request);
|
|
351
358
|
if (ask === null)
|
|
352
359
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
353
360
|
return linked(await ask(), request.locator);
|
|
354
361
|
},
|
|
355
362
|
async attach(_authorization, request) {
|
|
363
|
+
if (request.locator === undefined)
|
|
364
|
+
return attached(request, null);
|
|
356
365
|
const entry = authorityFor(request.locator);
|
|
357
366
|
if (entry === undefined)
|
|
358
367
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
359
|
-
|
|
360
|
-
room_ref: entry.authority,
|
|
361
|
-
name: request.name,
|
|
362
|
-
bytes: request.byteLength,
|
|
363
|
-
sha256: request.sha256,
|
|
364
|
-
media_type: request.mediaType,
|
|
365
|
-
});
|
|
366
|
-
const refused = refusedAttach(declared, request.locator);
|
|
367
|
-
if (refused !== null)
|
|
368
|
-
return refused;
|
|
369
|
-
const upload = houseUpload(declared.body?.upload);
|
|
370
|
-
if (upload === null)
|
|
371
|
-
return unusable();
|
|
372
|
-
const finished = await finishedUpload(transport, upload, request.blob);
|
|
373
|
-
if ('unfinished' in finished)
|
|
374
|
-
return answeredFailure(finished.unfinished, null);
|
|
375
|
-
const unfinished = refusedAttach(finished, request.locator);
|
|
376
|
-
if (unfinished !== null)
|
|
377
|
-
return unfinished;
|
|
378
|
-
const { path, revision } = (finished.body ?? {});
|
|
379
|
-
const root = `/rooms/${entry.handle}/`;
|
|
380
|
-
return typeof path === 'string' && path.startsWith(root) && typeof revision === 'string'
|
|
381
|
-
? { kind: 'attached', path: path.slice(root.length), revision }
|
|
382
|
-
: unusable();
|
|
368
|
+
return attached(request, entry);
|
|
383
369
|
},
|
|
384
370
|
reached(locator, version, target) {
|
|
385
371
|
return reachedVersion(version, target, authorityFor(locator)?.logEpoch);
|
|
@@ -393,6 +379,9 @@ export function createAgentsHouseAdapter(options) {
|
|
|
393
379
|
search(_authorization, request) {
|
|
394
380
|
return houseSearch(transport, [...tracked.values()], request);
|
|
395
381
|
},
|
|
382
|
+
queryHouse(_authorization, request) {
|
|
383
|
+
return houseQuery(transport, request);
|
|
384
|
+
},
|
|
396
385
|
roomStream: {
|
|
397
386
|
hold,
|
|
398
387
|
observe: notifications.observe,
|
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":[],"mappings":"AAEA,eAAO,MAAM,oBAAoB,gBAAgB,CAAC;AAElD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
|
|
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.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunks.d.ts","sourceRoot":"","sources":["../src/chunks.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,eAAe,EACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,
|
|
1
|
+
{"version":3,"file":"chunks.d.ts","sourceRoot":"","sources":["../src/chunks.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,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AAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAIvE;AAED,wBAAsB,WAAW,CAC/B,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,gBAAgB,GACtB,OAAO,CAAC,eAAe,CAAC,CAsB1B;AAED,wBAAsB,SAAS,CAC7B,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,IAAI,EACvC,IAAI,EAAE,WAAW,EACjB,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,GAC9C,OAAO,CAAC,eAAe,CAAC,CAW1B;AAiBD,wBAAgB,WAAW,CACzB,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,MAAM,MAAM,EAClB,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,gBAAgB,GAAG,SAAS;sBA0CjC,SAAS,gBAAgB,EAAE;kBA0B/B,gBAAgB,KAAG,OAAO,CAAC,MAAM,CAAC;iBAcxC,gBAAgB,cAAc,SAAS,gBAAgB,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;;EAY3F;AAqCD,wBAAsB,UAAU,CAC9B,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,EAChC,IAAI,EAAE,WAAW,EACjB,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,GAC9C,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CA4B5B"}
|
package/dist/chunks.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { paced, ROW_WEIGHT, stepped, } from '@agentshouse/mdruntime';
|
|
2
2
|
import { manifestedModels } from './model.js';
|
|
3
|
-
import { authorityRoot, bootstrapping,
|
|
3
|
+
import { authorityRoot, bootstrapping, documentEntry, } from './read.js';
|
|
4
4
|
import { classifyDoor } from './refusal.js';
|
|
5
5
|
import { failedOn, unusable } from './uncertain.js';
|
|
6
6
|
import { spaceSchemas } from './space-schema.js';
|
|
@@ -28,12 +28,12 @@ function namesOf(authors) {
|
|
|
28
28
|
}
|
|
29
29
|
return names;
|
|
30
30
|
}
|
|
31
|
-
function schemaText(
|
|
32
|
-
const { space, revision } = file;
|
|
33
|
-
if (
|
|
31
|
+
function schemaText(file, texts) {
|
|
32
|
+
const { space, revision, content } = file;
|
|
33
|
+
if (content !== undefined) {
|
|
34
34
|
if (space !== undefined && revision !== undefined)
|
|
35
|
-
texts.keep(space, revision,
|
|
36
|
-
return
|
|
35
|
+
texts.keep(space, revision, content);
|
|
36
|
+
return content;
|
|
37
37
|
}
|
|
38
38
|
return space === undefined || revision === undefined ? undefined : texts.held(space, revision);
|
|
39
39
|
}
|
|
@@ -41,16 +41,14 @@ function modelsOf(models, mode, texts) {
|
|
|
41
41
|
if (!Array.isArray(models))
|
|
42
42
|
return null;
|
|
43
43
|
const files = [];
|
|
44
|
-
const contents = [];
|
|
45
44
|
for (const entry of models) {
|
|
46
|
-
const file =
|
|
47
|
-
const content = file === null ? undefined : schemaText(
|
|
45
|
+
const file = documentEntry(entry, mode);
|
|
46
|
+
const content = file === null ? undefined : schemaText(file, texts);
|
|
48
47
|
if (file === null || content === undefined)
|
|
49
48
|
return null;
|
|
50
|
-
files.push(file);
|
|
51
|
-
contents.push({ path: file.path, content });
|
|
49
|
+
files.push({ ...file, content });
|
|
52
50
|
}
|
|
53
|
-
return
|
|
51
|
+
return files;
|
|
54
52
|
}
|
|
55
53
|
export function partId(logEpoch, hash) {
|
|
56
54
|
return `${logEpoch}:${hash}`;
|
|
@@ -105,7 +103,7 @@ export async function chunkedHead(listed, entry) {
|
|
|
105
103
|
facts: {},
|
|
106
104
|
revisions: {},
|
|
107
105
|
changes: {},
|
|
108
|
-
|
|
106
|
+
attachments: {},
|
|
109
107
|
parts: listed.parts,
|
|
110
108
|
...(models === undefined ? {} : { models }),
|
|
111
109
|
};
|
|
@@ -243,20 +241,14 @@ function chunkEntry(line, room, read) {
|
|
|
243
241
|
return false;
|
|
244
242
|
named = { ...entry, author: { ...author, name } };
|
|
245
243
|
}
|
|
246
|
-
const file =
|
|
244
|
+
const file = documentEntry(named, room.mode);
|
|
247
245
|
if (file === null)
|
|
248
246
|
return false;
|
|
249
247
|
read.files.push(file);
|
|
250
|
-
if (typeof entry.content === 'string')
|
|
251
|
-
read.contents.push({ path: file.path, content: entry.content });
|
|
252
248
|
return true;
|
|
253
249
|
}
|
|
254
250
|
export async function chunkScope(body, room, arriving) {
|
|
255
|
-
const read = {
|
|
256
|
-
files: [],
|
|
257
|
-
contents: [],
|
|
258
|
-
folders: [],
|
|
259
|
-
};
|
|
251
|
+
const read = { files: [], folders: [] };
|
|
260
252
|
const reader = body.getReader();
|
|
261
253
|
const decoder = new TextDecoder();
|
|
262
254
|
const pace = paced();
|