@agentshouse/mdruntime-adapter 0.1.0-c330745735a75 → 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 +1 -1
- package/dist/actions.d.ts +1 -0
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +11 -7
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +102 -103
- package/dist/authored-path.d.ts +58 -3
- package/dist/authored-path.d.ts.map +1 -1
- package/dist/authored-path.js +140 -11
- package/dist/chunks.d.ts +2 -3
- package/dist/chunks.d.ts.map +1 -1
- package/dist/chunks.js +72 -38
- package/dist/discovery.d.ts +25 -5
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +169 -21
- package/dist/history.d.ts +1 -6
- package/dist/history.d.ts.map +1 -1
- package/dist/history.js +21 -28
- package/dist/index.d.ts +6 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -8
- package/dist/model.d.ts +5 -5
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +17 -27
- package/dist/read.d.ts +11 -24
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +71 -44
- package/dist/refusal.d.ts +5 -1
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +23 -6
- package/dist/room-query.d.ts +4 -0
- package/dist/room-query.d.ts.map +1 -0
- package/dist/room-query.js +51 -0
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +4 -4
- 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 +12 -84
- 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 +47 -21
- package/dist/space-schema.d.ts.map +1 -1
- package/dist/space-schema.js +1 -8
- package/dist/stream.d.ts +2 -3
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +79 -79
- package/dist/transport.d.ts +41 -17
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +40 -4
- package/dist/uncertain.d.ts +5 -0
- package/dist/uncertain.d.ts.map +1 -0
- package/dist/uncertain.js +11 -0
- package/dist/upload.d.ts +7 -1
- package/dist/upload.d.ts.map +1 -1
- package/dist/upload.js +49 -6
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +28 -28
- package/package.json +3 -2
- package/dist/app-reference.d.ts +0 -1
- package/dist/app-reference.d.ts.map +0 -1
- package/dist/app-reference.js +0 -2
- package/dist/crockford.d.ts +0 -3
- package/dist/crockford.d.ts.map +0 -1
- package/dist/crockford.js +0 -3
- package/dist/house-model.d.ts +0 -830
- package/dist/house-model.d.ts.map +0 -1
- package/dist/house-model.js +0 -465
- package/dist/room-types.d.ts +0 -4
- package/dist/room-types.d.ts.map +0 -1
- package/dist/room-types.js +0 -135
- 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;
|
|
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
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import { doorRefusal, resetOf } from './refusal.js';
|
|
1
|
+
import { answeredFailure, doorRefusal, resetOf } from './refusal.js';
|
|
2
|
+
import { refusedFor } from './uncertain.js';
|
|
2
3
|
export const HOUSE_UNKEPT_READS = [
|
|
3
4
|
'account/security/read',
|
|
5
|
+
'billing/read',
|
|
4
6
|
'clients/last-use/list',
|
|
5
7
|
];
|
|
6
8
|
export const HOUSE_LEADING_READS = [
|
|
7
|
-
'rooms/list',
|
|
8
9
|
'apps/list',
|
|
9
10
|
'sites/list',
|
|
10
11
|
'rooms/members/list',
|
|
11
12
|
];
|
|
13
|
+
export const HOUSE_RENAMED_UNTIL_2026_12_18 = new Map([
|
|
14
|
+
['files/batch', 'update'],
|
|
15
|
+
]);
|
|
12
16
|
export function declaredActions(routes) {
|
|
13
17
|
return routes.map((name) => ({ name, inputShape: {}, resultKind: 'house', room: 'room_ref' }));
|
|
14
18
|
}
|
|
@@ -42,17 +46,17 @@ export function actionOutcome(answer, name, input) {
|
|
|
42
46
|
if (answer.status === 401)
|
|
43
47
|
return { kind: 'revoked-authorization' };
|
|
44
48
|
const refusal = doorRefusal(answer.body);
|
|
45
|
-
if (refusal?.code === 'operation_contended' && numbered(input))
|
|
46
|
-
return
|
|
47
|
-
}
|
|
49
|
+
if (refusal?.code === 'operation_contended' && numbered(input))
|
|
50
|
+
return refusedFor(refusal);
|
|
48
51
|
if (refusal !== null) {
|
|
49
52
|
const reset = resetOf(refusal);
|
|
50
53
|
return { kind: 'rejected', ...refusal, ...(reset === undefined ? {} : { reset }) };
|
|
51
54
|
}
|
|
52
55
|
if (answer.status === 404)
|
|
53
56
|
return unimplemented(name);
|
|
54
|
-
if (answer.status === 0 || answer.status >= 400)
|
|
55
|
-
return
|
|
57
|
+
if (answer.status === 0 || answer.status >= 400) {
|
|
58
|
+
return answeredFailure(answer.status, answer.body);
|
|
59
|
+
}
|
|
56
60
|
return { kind: 'action', result: answer.body };
|
|
57
61
|
}
|
|
58
62
|
async function carry(transport, route, name, input) {
|
package/dist/adapter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"
|
|
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
|
@@ -1,23 +1,20 @@
|
|
|
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 {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
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 { classifyDoor,
|
|
11
|
+
import { answeredFailure, classifyDoor, keyedFailure } from './refusal.js';
|
|
12
|
+
import { UNANSWERED, unusable } from './uncertain.js';
|
|
11
13
|
import { houseNotifications, } from './stream.js';
|
|
12
14
|
import { houseDoorRoute, } from './transport.js';
|
|
13
15
|
import { batchPaths, deltaBody, deltaBytes, deltaDigest, historyOutcome, houseChanges, houseMove, mutationOutcome, operationHead, rejectedMapping, revisionBody, uploadable, } from './write.js';
|
|
14
16
|
import { admittedPath } from './authored-path.js';
|
|
15
|
-
import { HOUSE_TYPED_PATHS } from './house-model.js';
|
|
16
|
-
import { HOUSE_NAMEABLE_ROOM_TYPES, HOUSE_ROOM_TYPES } from './room-types.js';
|
|
17
17
|
import { followsVersion, reachedVersion, roomVersion } from './version.js';
|
|
18
|
-
const UNCERTAIN = { kind: 'transport-uncertainty' };
|
|
19
|
-
const UNCERTAIN_READ = { kind: 'transport-uncertainty' };
|
|
20
|
-
const OCTET_STREAM = 'application/octet-stream';
|
|
21
18
|
const EXPIRED_ADDRESS = 403;
|
|
22
19
|
function lapsedGrant(outcome) {
|
|
23
20
|
return outcome.kind === 'rejected' && outcome.code === 'upload_unavailable';
|
|
@@ -26,14 +23,13 @@ export function createAgentsHouseAdapter(options) {
|
|
|
26
23
|
if ('site' in options)
|
|
27
24
|
return createSiteAdapter(options.site, options.snapshot === true);
|
|
28
25
|
const transport = options.transport;
|
|
29
|
-
const spaces = spaceSchemas();
|
|
30
26
|
const notifications = houseNotifications(transport, 'credential', {
|
|
31
27
|
opened: async (frame) => (frame === null ? null : opened(frame)),
|
|
32
28
|
changed,
|
|
33
|
-
expired: (
|
|
34
|
-
}
|
|
29
|
+
expired: (entries) => lister.askAll(entries),
|
|
30
|
+
});
|
|
35
31
|
const tracked = new Map();
|
|
36
|
-
const lister = chunkLister(transport, () => declared().max_prefixes);
|
|
32
|
+
const lister = chunkLister(transport, () => declared().max_prefixes, (locator) => tracked.get(locator));
|
|
37
33
|
const chunked = new Map();
|
|
38
34
|
const renewals = new WeakMap();
|
|
39
35
|
let bounds;
|
|
@@ -55,13 +51,16 @@ export function createAgentsHouseAdapter(options) {
|
|
|
55
51
|
return {
|
|
56
52
|
...mapDiscovery(document, document.authorities.map((authority) => discoveredRoom(authority)), capabilities(document.actions)),
|
|
57
53
|
member: document.member,
|
|
54
|
+
timeZone: document.timeZone,
|
|
55
|
+
roomList: document.roomList,
|
|
58
56
|
};
|
|
59
57
|
}
|
|
60
58
|
function changed(frame) {
|
|
61
59
|
const change = parseAuthorityChange(frame);
|
|
62
60
|
if (change === null)
|
|
63
61
|
return null;
|
|
64
|
-
|
|
62
|
+
const unheld = [...change.left, ...change.listed];
|
|
63
|
+
for (const locator of unheld)
|
|
65
64
|
tracked.delete(locator);
|
|
66
65
|
for (const entry of trackedFrom(change))
|
|
67
66
|
tracked.set(entry.locator, entry);
|
|
@@ -69,15 +68,17 @@ export function createAgentsHouseAdapter(options) {
|
|
|
69
68
|
return {
|
|
70
69
|
kind: 'authority-changed',
|
|
71
70
|
rooms: change.authorities.map((authority) => discoveredRoom(authority)),
|
|
72
|
-
left:
|
|
71
|
+
left: unheld,
|
|
73
72
|
member: change.member,
|
|
73
|
+
timeZone: change.timeZone,
|
|
74
|
+
roomList: { ...change.roomList, left: change.left },
|
|
74
75
|
};
|
|
75
76
|
}
|
|
76
77
|
async function listedRoom(entry) {
|
|
77
78
|
const listed = await lister.list(entry);
|
|
78
79
|
if ('kind' in listed)
|
|
79
80
|
return listed;
|
|
80
|
-
const head = await chunkedHead(listed, entry
|
|
81
|
+
const head = await chunkedHead(listed, entry);
|
|
81
82
|
if (head.kind === 'bootstrap')
|
|
82
83
|
chunked.set(entry.locator, listed);
|
|
83
84
|
return head;
|
|
@@ -86,15 +87,18 @@ export function createAgentsHouseAdapter(options) {
|
|
|
86
87
|
const room = chunked.get(entry.locator);
|
|
87
88
|
const address = room?.chunks.get(id);
|
|
88
89
|
if (room === undefined || address === undefined)
|
|
89
|
-
return
|
|
90
|
+
return UNANSWERED;
|
|
90
91
|
const read = await transport.download(address.url);
|
|
91
92
|
if (read.status !== EXPIRED_ADDRESS)
|
|
92
93
|
return { room, read };
|
|
93
94
|
const renewed = await renewal(entry, room);
|
|
94
|
-
if ('kind' in renewed
|
|
95
|
-
return
|
|
95
|
+
if ('kind' in renewed)
|
|
96
|
+
return renewed;
|
|
97
|
+
const renewedAddress = renewed.chunks.get(id);
|
|
98
|
+
if (renewedAddress === undefined)
|
|
99
|
+
return unusable();
|
|
96
100
|
chunked.set(entry.locator, renewed);
|
|
97
|
-
return { room: renewed, read: await transport.download(
|
|
101
|
+
return { room: renewed, read: await transport.download(renewedAddress.url) };
|
|
98
102
|
}
|
|
99
103
|
function renewal(entry, stale) {
|
|
100
104
|
const held = renewals.get(stale);
|
|
@@ -116,8 +120,10 @@ export function createAgentsHouseAdapter(options) {
|
|
|
116
120
|
}
|
|
117
121
|
async function chunkPage(entry, id, arriving) {
|
|
118
122
|
const fetched = await chunkRead(entry, id);
|
|
119
|
-
if (
|
|
120
|
-
return
|
|
123
|
+
if ('kind' in fetched)
|
|
124
|
+
return fetched;
|
|
125
|
+
if (fetched.read.status !== 200)
|
|
126
|
+
return answeredFailure(fetched.read.status, null);
|
|
121
127
|
return chunkPart(fetched.read.body, fetched.room, id, arriving);
|
|
122
128
|
}
|
|
123
129
|
function authorityFor(locator) {
|
|
@@ -143,8 +149,9 @@ export function createAgentsHouseAdapter(options) {
|
|
|
143
149
|
if (handed !== undefined && handed.sha256 === sha256) {
|
|
144
150
|
return { body: { ...head, paths, upload: handed, runtime: notifications.runtime } };
|
|
145
151
|
}
|
|
146
|
-
const minted = await transport.door(houseDoorRoute('
|
|
152
|
+
const minted = await transport.door(houseDoorRoute('update'), {
|
|
147
153
|
...head,
|
|
154
|
+
op: 'stage',
|
|
148
155
|
paths,
|
|
149
156
|
bytes,
|
|
150
157
|
sha256,
|
|
@@ -156,38 +163,21 @@ export function createAgentsHouseAdapter(options) {
|
|
|
156
163
|
}
|
|
157
164
|
const grant = parseGrant(minted.body);
|
|
158
165
|
if (grant === null)
|
|
159
|
-
return { outcome:
|
|
166
|
+
return { outcome: unusable() };
|
|
160
167
|
const delivered = await transport.transfer({
|
|
161
168
|
url: grant.url,
|
|
162
169
|
body: `${grant.operation}\n${delta}`,
|
|
163
170
|
});
|
|
164
|
-
if (delivered.status !== 200)
|
|
165
|
-
return { outcome:
|
|
171
|
+
if (delivered.status !== 200) {
|
|
172
|
+
return { outcome: answeredFailure(delivered.status, delivered.body) };
|
|
173
|
+
}
|
|
166
174
|
const holding = parseGrant(delivered.body);
|
|
167
175
|
if (holding === null)
|
|
168
|
-
return { outcome:
|
|
176
|
+
return { outcome: unusable() };
|
|
169
177
|
const upload = { url: holding.url, operation: holding.operation, bytes, sha256 };
|
|
170
178
|
await keep(upload);
|
|
171
179
|
return { body: { ...head, paths, upload, runtime: notifications.runtime } };
|
|
172
180
|
}
|
|
173
|
-
async function staged(answer, { changeBatch: batch, file }) {
|
|
174
|
-
const refusal = doorRefusal(answer.body);
|
|
175
|
-
if (refusal?.code !== 'files_unstaged')
|
|
176
|
-
return null;
|
|
177
|
-
const uploads = refusal.fields.upload;
|
|
178
|
-
if (!Array.isArray(uploads))
|
|
179
|
-
return false;
|
|
180
|
-
for (const named of uploads) {
|
|
181
|
-
const upload = houseUpload(named);
|
|
182
|
-
const change = batch.changes.find((held) => held.kind === 'binary' && held.sha256 === named.sha256);
|
|
183
|
-
if (upload === null || change === undefined)
|
|
184
|
-
return false;
|
|
185
|
-
const finished = await finishedUpload(transport, upload, await file(change.localId));
|
|
186
|
-
if (finished?.body?.staged !== true)
|
|
187
|
-
return false;
|
|
188
|
-
}
|
|
189
|
-
return true;
|
|
190
|
-
}
|
|
191
181
|
async function submit(request, head, changes, delta, bytes, entry, handed, keep, into) {
|
|
192
182
|
const inline = { ...head, changes, runtime: notifications.runtime };
|
|
193
183
|
const prepared = uploadable(inline, bytes, declared())
|
|
@@ -195,15 +185,12 @@ export function createAgentsHouseAdapter(options) {
|
|
|
195
185
|
: { body: inline };
|
|
196
186
|
if ('outcome' in prepared)
|
|
197
187
|
return prepared.outcome;
|
|
198
|
-
const
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
: await transport.door(houseDoorRoute('files/batch'), prepared.body);
|
|
205
|
-
if (stagedFiles === true && (await staged(settled, request)) !== null)
|
|
206
|
-
return UNCERTAIN;
|
|
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;
|
|
207
194
|
return stepped(mutationOutcome(settled.status, settled.body, entry.locator, entry.handle, into === undefined
|
|
208
195
|
? undefined
|
|
209
196
|
: {
|
|
@@ -211,28 +198,9 @@ export function createAgentsHouseAdapter(options) {
|
|
|
211
198
|
destination: { authority: into.authority, handle: into.handle },
|
|
212
199
|
}));
|
|
213
200
|
}
|
|
214
|
-
function
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
return failure.kind === 'scoped-refusal'
|
|
218
|
-
? {
|
|
219
|
-
kind: 'rejected',
|
|
220
|
-
code: failure.code,
|
|
221
|
-
fields: failure.fields,
|
|
222
|
-
retryable: failure.retryable,
|
|
223
|
-
}
|
|
224
|
-
: failure;
|
|
225
|
-
}
|
|
226
|
-
const address = parseFileAddress(answer.body);
|
|
227
|
-
return address === null ? UNCERTAIN_READ : { kind: 'address', ...address };
|
|
228
|
-
}
|
|
229
|
-
function linked(answer, locator) {
|
|
230
|
-
const address = addressed(answer, locator);
|
|
231
|
-
return address.kind === 'address'
|
|
232
|
-
? { kind: 'link', url: address.url, name: address.name, mediaType: address.mediaType }
|
|
233
|
-
: address;
|
|
234
|
-
}
|
|
235
|
-
function refusedAttach(answer, locator) {
|
|
201
|
+
function refusedOn(answer, locator) {
|
|
202
|
+
if (locator === null)
|
|
203
|
+
return keyedFailure(answer.status, answer.body);
|
|
236
204
|
const failure = classifyDoor(answer.status, answer.body, locator);
|
|
237
205
|
if (failure === null)
|
|
238
206
|
return null;
|
|
@@ -245,6 +213,48 @@ export function createAgentsHouseAdapter(options) {
|
|
|
245
213
|
}
|
|
246
214
|
: failure;
|
|
247
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
|
+
}
|
|
248
258
|
async function downloaded(ask, locator) {
|
|
249
259
|
let address = addressed(await ask(), locator);
|
|
250
260
|
if (address.kind !== 'address')
|
|
@@ -256,13 +266,17 @@ export function createAgentsHouseAdapter(options) {
|
|
|
256
266
|
return address;
|
|
257
267
|
read = await transport.download(address.url);
|
|
258
268
|
}
|
|
259
|
-
if (read.status !== 200
|
|
260
|
-
return
|
|
269
|
+
if (read.status !== 200)
|
|
270
|
+
return answeredFailure(read.status, null);
|
|
271
|
+
if (read.body === null)
|
|
272
|
+
return unusable();
|
|
261
273
|
return {
|
|
262
274
|
kind: 'binary',
|
|
263
275
|
body: read.body,
|
|
264
276
|
mediaType: address.mediaType,
|
|
265
277
|
sha256: address.sha256,
|
|
278
|
+
url: address.url,
|
|
279
|
+
copies: address.copies,
|
|
266
280
|
};
|
|
267
281
|
}
|
|
268
282
|
function pathAddress(request) {
|
|
@@ -277,11 +291,11 @@ export function createAgentsHouseAdapter(options) {
|
|
|
277
291
|
}
|
|
278
292
|
return {
|
|
279
293
|
roomTypes: HOUSE_ROOM_TYPES,
|
|
280
|
-
nameableRoomTypes: HOUSE_NAMEABLE_ROOM_TYPES,
|
|
281
294
|
typedPaths: HOUSE_TYPED_PATHS,
|
|
282
295
|
pathRule: admittedPath,
|
|
283
296
|
unkeptReads: HOUSE_UNKEPT_READS,
|
|
284
297
|
leadingReads: HOUSE_LEADING_READS,
|
|
298
|
+
renamedActions: HOUSE_RENAMED_UNTIL_2026_12_18,
|
|
285
299
|
async authorize() {
|
|
286
300
|
return options.authorize();
|
|
287
301
|
},
|
|
@@ -337,39 +351,21 @@ export function createAgentsHouseAdapter(options) {
|
|
|
337
351
|
return downloaded(ask, request.locator);
|
|
338
352
|
},
|
|
339
353
|
async link(_authorization, request) {
|
|
354
|
+
if (request.kind === 'key') {
|
|
355
|
+
return linked(await transport.door(houseDoorRoute('files/read'), { link: request.link }), null);
|
|
356
|
+
}
|
|
340
357
|
const ask = pathAddress(request);
|
|
341
358
|
if (ask === null)
|
|
342
359
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
343
360
|
return linked(await ask(), request.locator);
|
|
344
361
|
},
|
|
345
362
|
async attach(_authorization, request) {
|
|
363
|
+
if (request.locator === undefined)
|
|
364
|
+
return attached(request, null);
|
|
346
365
|
const entry = authorityFor(request.locator);
|
|
347
366
|
if (entry === undefined)
|
|
348
367
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
349
|
-
|
|
350
|
-
room_ref: entry.authority,
|
|
351
|
-
name: request.name,
|
|
352
|
-
bytes: request.byteLength,
|
|
353
|
-
sha256: request.sha256,
|
|
354
|
-
media_type: request.mediaType.length > 0 ? request.mediaType : OCTET_STREAM,
|
|
355
|
-
});
|
|
356
|
-
const refused = refusedAttach(declared, request.locator);
|
|
357
|
-
if (refused !== null)
|
|
358
|
-
return refused;
|
|
359
|
-
const upload = houseUpload(declared.body?.upload);
|
|
360
|
-
if (upload === null)
|
|
361
|
-
return UNCERTAIN_READ;
|
|
362
|
-
const finished = await finishedUpload(transport, upload, request.blob);
|
|
363
|
-
if (finished === null)
|
|
364
|
-
return UNCERTAIN_READ;
|
|
365
|
-
const unfinished = refusedAttach(finished, request.locator);
|
|
366
|
-
if (unfinished !== null)
|
|
367
|
-
return unfinished;
|
|
368
|
-
const { path, revision } = (finished.body ?? {});
|
|
369
|
-
const root = `/rooms/${entry.handle}/`;
|
|
370
|
-
return typeof path === 'string' && path.startsWith(root) && typeof revision === 'string'
|
|
371
|
-
? { kind: 'attached', path: path.slice(root.length), revision }
|
|
372
|
-
: UNCERTAIN_READ;
|
|
368
|
+
return attached(request, entry);
|
|
373
369
|
},
|
|
374
370
|
reached(locator, version, target) {
|
|
375
371
|
return reachedVersion(version, target, authorityFor(locator)?.logEpoch);
|
|
@@ -383,6 +379,9 @@ export function createAgentsHouseAdapter(options) {
|
|
|
383
379
|
search(_authorization, request) {
|
|
384
380
|
return houseSearch(transport, [...tracked.values()], request);
|
|
385
381
|
},
|
|
382
|
+
queryHouse(_authorization, request) {
|
|
383
|
+
return houseQuery(transport, request);
|
|
384
|
+
},
|
|
386
385
|
roomStream: {
|
|
387
386
|
hold,
|
|
388
387
|
observe: notifications.observe,
|
package/dist/authored-path.d.ts
CHANGED
|
@@ -2,9 +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[];
|
|
9
|
-
export declare const
|
|
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;
|
|
10
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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