@agentshouse/mdruntime-adapter 0.1.0-cc7da2d4669a3 → 0.1.0-cc881e28be5a5
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/dist/actions.d.ts +1 -1
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +7 -3
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +12 -3
- package/dist/discovery.d.ts +10 -2
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +32 -5
- package/dist/history.d.ts.map +1 -1
- package/dist/history.js +2 -1
- package/dist/house-model.d.ts +232 -2534
- package/dist/house-model.d.ts.map +1 -1
- package/dist/house-model.js +156 -1417
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/model.d.ts +4 -2
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +28 -6
- package/dist/read.d.ts +11 -1
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +23 -1
- package/dist/room-stream.d.ts +2 -1
- package/dist/room-stream.d.ts.map +1 -1
- package/dist/room-stream.js +2 -2
- package/dist/room-types.d.ts +2 -2
- package/dist/room-types.d.ts.map +1 -1
- package/dist/room-types.js +6 -9
- package/dist/search.d.ts +5 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +47 -0
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +8 -4
- package/dist/space-schema.d.ts +7 -0
- package/dist/space-schema.d.ts.map +1 -0
- package/dist/space-schema.js +18 -0
- package/dist/stream.d.ts +2 -1
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +38 -9
- package/dist/transport.d.ts +17 -5
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +2 -0
- package/dist/write.d.ts +2 -1
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +8 -23
- package/package.json +2 -2
package/dist/actions.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ import type { HouseDoorAnswer, HouseTransport } from './transport.js';
|
|
|
3
3
|
export type HouseActDoor = Pick<HouseTransport, 'door'>;
|
|
4
4
|
export declare function declaredActions(routes: readonly string[]): readonly ActionDeclaration[];
|
|
5
5
|
export declare function houseAction(transport: HouseActDoor, request: ActionRequest): Promise<ActionResult>;
|
|
6
|
-
export declare function actionOutcome(answer: HouseDoorAnswer, name: string): ActionResult;
|
|
6
|
+
export declare function actionOutcome(answer: HouseDoorAnswer, name: string, input: unknown): ActionResult;
|
|
7
7
|
//# sourceMappingURL=actions.d.ts.map
|
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;AAE7F,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEtE,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AAExD,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;
|
|
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;AAE7F,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEtE,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AAExD,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,CAUjG"}
|
package/dist/actions.js
CHANGED
|
@@ -25,12 +25,16 @@ function malformed() {
|
|
|
25
25
|
function unimplemented(name) {
|
|
26
26
|
return { kind: 'rejected', code: 'action-unimplemented', fields: { name }, retryable: false };
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
function numbered(input) {
|
|
29
|
+
return typeof input?.operation_id === 'string';
|
|
30
|
+
}
|
|
31
|
+
export function actionOutcome(answer, name, input) {
|
|
29
32
|
if (answer.status === 401)
|
|
30
33
|
return { kind: 'revoked-authorization' };
|
|
31
34
|
const refusal = doorRefusal(answer.body);
|
|
32
|
-
if (refusal?.code === 'operation_contended')
|
|
35
|
+
if (refusal?.code === 'operation_contended' && numbered(input)) {
|
|
33
36
|
return { kind: 'transport-uncertainty' };
|
|
37
|
+
}
|
|
34
38
|
if (refusal !== null)
|
|
35
39
|
return { kind: 'rejected', ...refusal };
|
|
36
40
|
if (answer.status === 404)
|
|
@@ -40,5 +44,5 @@ export function actionOutcome(answer, name) {
|
|
|
40
44
|
return { kind: 'action', result: answer.body };
|
|
41
45
|
}
|
|
42
46
|
async function carry(transport, route, name, input) {
|
|
43
|
-
return actionOutcome(await transport.door(route, input), name);
|
|
47
|
+
return actionOutcome(await transport.door(route, input), name, input);
|
|
44
48
|
}
|
package/dist/adapter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,OAAO,EAIP,aAAa,
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,OAAO,EAIP,aAAa,EAgBd,MAAM,wBAAwB,CAAC;AAiChC,OAAO,EAGL,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;AA6DrD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAqapF"}
|
package/dist/adapter.js
CHANGED
|
@@ -3,13 +3,16 @@ import { capabilities, discoveredRoom, mapDiscovery, parseAuthorityChange, parse
|
|
|
3
3
|
import { createSiteAdapter } from './site.js';
|
|
4
4
|
import { authorityRoot, bootstrapping, parseFileAddress, parseGrant, } from './read.js';
|
|
5
5
|
import { roomStreams } from './room-stream.js';
|
|
6
|
+
import { spaceSchemas } from './space-schema.js';
|
|
6
7
|
import { sha256Hex } from './digest.js';
|
|
7
8
|
import { finishedUpload, houseUpload } from './upload.js';
|
|
8
9
|
import { houseAction } from './actions.js';
|
|
10
|
+
import { houseSearch } from './search.js';
|
|
9
11
|
import { classifyDoor, doorRefusal } from './refusal.js';
|
|
10
12
|
import { houseNotifications, } from './stream.js';
|
|
11
13
|
import { houseDoorRoute, } from './transport.js';
|
|
12
14
|
import { batchPaths, deltaBody, deltaBytes, deltaDigest, historyOutcome, houseChanges, houseMove, mutationOutcome, operationHead, rejectedMapping, revisionBody, uploadable, } from './write.js';
|
|
15
|
+
import { HOUSE_TYPED_PATHS } from './house-model.js';
|
|
13
16
|
import { HOUSE_NAMEABLE_ROOM_TYPES, HOUSE_ROOM_TYPES } from './room-types.js';
|
|
14
17
|
import { followsVersion, logPosition, presented, reachedVersion, roomVersion } from './version.js';
|
|
15
18
|
const UNCERTAIN = { kind: 'transport-uncertainty' };
|
|
@@ -49,12 +52,13 @@ export function createAgentsHouseAdapter(options) {
|
|
|
49
52
|
if ('site' in options)
|
|
50
53
|
return createSiteAdapter(options.site, options.snapshot === true);
|
|
51
54
|
const transport = options.transport;
|
|
55
|
+
const spaces = spaceSchemas();
|
|
52
56
|
const notifications = houseNotifications(transport, 'credential', {
|
|
53
57
|
opened: async (frame) => (frame === null ? null : opened(frame)),
|
|
54
58
|
changed,
|
|
55
|
-
});
|
|
59
|
+
}, spaces);
|
|
56
60
|
const tracked = new Map();
|
|
57
|
-
const rooms = roomStreams('credential');
|
|
61
|
+
const rooms = roomStreams('credential', spaces);
|
|
58
62
|
const unreused = new Set();
|
|
59
63
|
let bounds;
|
|
60
64
|
function declared() {
|
|
@@ -114,6 +118,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
114
118
|
? null
|
|
115
119
|
: await heldFiles(entry.authority, reusing, declared().max_held_files);
|
|
116
120
|
const answered = await transport.streamed(houseDoorRoute('bootstrap'), {
|
|
121
|
+
room_ref: entry.authority,
|
|
117
122
|
prefixes: [authorityRoot(entry.handle)],
|
|
118
123
|
...(files === null ? {} : { held: [files] }),
|
|
119
124
|
}, request.signal ?? new AbortController().signal);
|
|
@@ -285,6 +290,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
285
290
|
return {
|
|
286
291
|
roomTypes: HOUSE_ROOM_TYPES,
|
|
287
292
|
nameableRoomTypes: HOUSE_NAMEABLE_ROOM_TYPES,
|
|
293
|
+
typedPaths: HOUSE_TYPED_PATHS,
|
|
288
294
|
async authorize() {
|
|
289
295
|
return options.authorize();
|
|
290
296
|
},
|
|
@@ -311,7 +317,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
311
317
|
: houseMove(batch, entry.handle, into.handle);
|
|
312
318
|
if (mapped.kind === 'unmapped')
|
|
313
319
|
return rejectedMapping(mapped);
|
|
314
|
-
const head = operationHead(batch);
|
|
320
|
+
const head = operationHead(batch, entry.authority);
|
|
315
321
|
const delta = deltaBody(mapped.changes);
|
|
316
322
|
const bytes = deltaBytes(delta);
|
|
317
323
|
const handed = request.upload;
|
|
@@ -386,6 +392,9 @@ export function createAgentsHouseAdapter(options) {
|
|
|
386
392
|
async action(_authorization, request) {
|
|
387
393
|
return withAt(await houseAction(transport, request));
|
|
388
394
|
},
|
|
395
|
+
search(_authorization, request) {
|
|
396
|
+
return houseSearch(transport, [...tracked.values()], request);
|
|
397
|
+
},
|
|
389
398
|
roomStream: {
|
|
390
399
|
hold: held,
|
|
391
400
|
observe: notifications.observe,
|
package/dist/discovery.d.ts
CHANGED
|
@@ -14,12 +14,11 @@ export type HouseBounds = {
|
|
|
14
14
|
max_prefixes: number;
|
|
15
15
|
max_held_files: number;
|
|
16
16
|
change_retention_seconds: number;
|
|
17
|
-
operation_retention_seconds: number;
|
|
18
17
|
max_move_documents?: number;
|
|
19
18
|
};
|
|
20
19
|
export type HouseOperations = {
|
|
21
20
|
write: readonly string[];
|
|
22
|
-
|
|
21
|
+
erase: readonly string[];
|
|
23
22
|
};
|
|
24
23
|
export type HouseAccessLevel = 'search' | 'open' | 'keep';
|
|
25
24
|
export type HouseAuthority = LogPosition & {
|
|
@@ -60,6 +59,14 @@ export type HouseSiteDiscovery = {
|
|
|
60
59
|
bounds: HouseBounds;
|
|
61
60
|
authorities: readonly HouseSiteAuthority[];
|
|
62
61
|
};
|
|
62
|
+
type RoomOwn = 'room_ref' | 'room_handle' | 'name' | 'position';
|
|
63
|
+
type Folded<A extends Record<RoomOwn, unknown>> = {
|
|
64
|
+
readonly shapes: readonly Omit<A, RoomOwn>[];
|
|
65
|
+
readonly rooms: readonly (Pick<A, RoomOwn> & {
|
|
66
|
+
readonly shape: number;
|
|
67
|
+
})[];
|
|
68
|
+
};
|
|
69
|
+
export declare function foldedAuthorities<A extends Record<RoomOwn, unknown>>(authorities: readonly A[]): Folded<A>;
|
|
63
70
|
export declare function parseDiscovery(body: unknown): HouseDiscoveryDocument | null;
|
|
64
71
|
export declare function parseAuthorityChange(body: unknown): HouseAuthorityChange | null;
|
|
65
72
|
export declare function parseSiteDiscovery(body: unknown): HouseSiteDiscovery | null;
|
|
@@ -71,4 +78,5 @@ export declare function capabilities(actions: HouseDiscoveryDocument['actions'])
|
|
|
71
78
|
export declare function siteCapabilities(): readonly Capability[];
|
|
72
79
|
export declare function discoveredRoom(authority: HouseAuthority): DiscoveredRoom;
|
|
73
80
|
export declare function mapDiscovery(document: Pick<HouseDiscoveryDocument, 'bounds'>, rooms: readonly DiscoveredRoom[], declared: readonly Capability[]): Discovery;
|
|
81
|
+
export {};
|
|
74
82
|
//# sourceMappingURL=discovery.d.ts.map
|
package/dist/discovery.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,SAAS,EACT,MAAM,EACN,aAAa,EACb,SAAS,EACV,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAA6B,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3E,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AAEnD,MAAM,MAAM,WAAW,GAAG;IACxB,uBAAuB,EAAE,MAAM,CAAC;IAChC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,wBAAwB,EAAE,MAAM,CAAC;IACjC,
|
|
1
|
+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+15,8 @@ const BOUND_KEYS = [
|
|
|
15
15
|
'max_prefixes',
|
|
16
16
|
'max_held_files',
|
|
17
17
|
'change_retention_seconds',
|
|
18
|
-
'operation_retention_seconds',
|
|
19
18
|
];
|
|
20
|
-
const OPERATION_KEYS = ['write', '
|
|
19
|
+
const OPERATION_KEYS = ['write', 'erase'];
|
|
21
20
|
const ACCESS_LEVELS = ['search', 'open', 'keep'];
|
|
22
21
|
function stringList(value) {
|
|
23
22
|
if (!Array.isArray(value))
|
|
@@ -122,6 +121,35 @@ function parseAuthorities(value) {
|
|
|
122
121
|
}
|
|
123
122
|
return authorities;
|
|
124
123
|
}
|
|
124
|
+
export function foldedAuthorities(authorities) {
|
|
125
|
+
const shapes = [];
|
|
126
|
+
const known = new Map();
|
|
127
|
+
const rooms = authorities.map(({ room_ref, room_handle, name, position, ...shape }) => {
|
|
128
|
+
const key = JSON.stringify(shape);
|
|
129
|
+
let held = known.get(key);
|
|
130
|
+
if (held === undefined) {
|
|
131
|
+
held = shapes.push(shape) - 1;
|
|
132
|
+
known.set(key, held);
|
|
133
|
+
}
|
|
134
|
+
return { room_ref, room_handle, name, position, shape: held };
|
|
135
|
+
});
|
|
136
|
+
return { shapes, rooms };
|
|
137
|
+
}
|
|
138
|
+
function unfolded(shapes, rooms) {
|
|
139
|
+
if (!Array.isArray(shapes) || !Array.isArray(rooms))
|
|
140
|
+
return null;
|
|
141
|
+
const authorities = [];
|
|
142
|
+
for (const room of rooms) {
|
|
143
|
+
if (typeof room !== 'object' || room === null)
|
|
144
|
+
return null;
|
|
145
|
+
const { shape, ...own } = room;
|
|
146
|
+
const held = typeof shape === 'number' ? shapes[shape] : undefined;
|
|
147
|
+
if (typeof held !== 'object' || held === null)
|
|
148
|
+
return null;
|
|
149
|
+
authorities.push({ ...held, ...own });
|
|
150
|
+
}
|
|
151
|
+
return authorities;
|
|
152
|
+
}
|
|
125
153
|
export function parseDiscovery(body) {
|
|
126
154
|
if (typeof body !== 'object' || body === null)
|
|
127
155
|
return null;
|
|
@@ -137,7 +165,7 @@ export function parseDiscovery(body) {
|
|
|
137
165
|
new Set(actions).size !== actions.length ||
|
|
138
166
|
actions.some((name) => name.length === 0))
|
|
139
167
|
return null;
|
|
140
|
-
const authorities = parseAuthorities(held.
|
|
168
|
+
const authorities = parseAuthorities(unfolded(held.shapes, held.rooms));
|
|
141
169
|
return authorities === null ? null : { member, bounds, authorities, actions };
|
|
142
170
|
}
|
|
143
171
|
export function parseAuthorityChange(body) {
|
|
@@ -230,7 +258,6 @@ export function providerLimits(bounds) {
|
|
|
230
258
|
export function declaredRetention(bounds) {
|
|
231
259
|
return {
|
|
232
260
|
history: { kind: 'no-declared-time-bound' },
|
|
233
|
-
outcome: bounds.operation_retention_seconds,
|
|
234
261
|
refreshHorizon: bounds.change_retention_seconds,
|
|
235
262
|
};
|
|
236
263
|
}
|
|
@@ -254,7 +281,7 @@ export function discoveredRoom(authority) {
|
|
|
254
281
|
roomVersion: roomVersion(authority),
|
|
255
282
|
operations: {
|
|
256
283
|
write: [...authority.operations.write],
|
|
257
|
-
|
|
284
|
+
erase: [...authority.operations.erase],
|
|
258
285
|
},
|
|
259
286
|
replica: {
|
|
260
287
|
selection: locator,
|
package/dist/history.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../src/history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EAGZ,0BAA0B,EAC3B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAkB,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhE,eAAO,MAAM,YAAY,MAAM,CAAC;AAIhC,KAAK,aAAa,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAkBjE,wBAAgB,cAAc,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAE5D;AAUD,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAUtE;AA8BD,wBAAsB,YAAY,CAChC,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../src/history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EAGZ,0BAA0B,EAC3B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAkB,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhE,eAAO,MAAM,YAAY,MAAM,CAAC;AAIhC,KAAK,aAAa,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAkBjE,wBAAgB,cAAc,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAE5D;AAUD,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAUtE;AA8BD,wBAAsB,YAAY,CAChC,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,YAAY,CAAC,CAqBvB"}
|
package/dist/history.js
CHANGED
|
@@ -73,7 +73,8 @@ export async function houseHistory(transport, request) {
|
|
|
73
73
|
const asks = historyAsks(request);
|
|
74
74
|
if (asks === null)
|
|
75
75
|
return { kind: 'rejected', code: 'invalid_request', fields: {}, retryable: false };
|
|
76
|
-
const
|
|
76
|
+
const asked = { conversations: asks, limit: HISTORY_PAGE };
|
|
77
|
+
const outcome = actionOutcome(await transport.door(houseDoorRoute(HISTORY), asked), HISTORY, asked);
|
|
77
78
|
if (outcome.kind !== 'action')
|
|
78
79
|
return outcome;
|
|
79
80
|
const answered = record(outcome.result).histories;
|