@agentshouse/mdruntime-adapter 0.1.0-c3a7788c02a90 → 0.1.0-c3b13eeb8d40f
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 +2 -2
- package/dist/actions.d.ts +3 -2
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +26 -9
- package/dist/adapter.d.ts +0 -1
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +175 -154
- package/dist/authored-path.d.ts +9 -0
- package/dist/authored-path.d.ts.map +1 -0
- package/dist/authored-path.js +34 -0
- package/dist/chunks.d.ts +36 -0
- package/dist/chunks.d.ts.map +1 -0
- package/dist/chunks.js +281 -0
- package/dist/digest.d.ts +0 -1
- package/dist/discovery.d.ts +25 -7
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +168 -16
- package/dist/history.d.ts +1 -7
- package/dist/history.d.ts.map +1 -1
- package/dist/history.js +24 -30
- package/dist/index.d.ts +5 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/map.d.ts +0 -1
- package/dist/model.d.ts +6 -9
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +28 -26
- package/dist/read.d.ts +15 -20
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +66 -164
- package/dist/refusal.d.ts +6 -2
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +28 -7
- package/dist/room-query.d.ts +3 -0
- package/dist/room-query.d.ts.map +1 -0
- package/dist/room-query.js +22 -0
- package/dist/search.d.ts +4 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +47 -0
- package/dist/session-content/bounds.d.ts +7 -0
- package/dist/session-content/check.d.ts +18 -0
- package/dist/session-content/index.d.ts +7 -0
- package/dist/session-content/parts.d.ts +103 -0
- package/dist/session-content/state.d.ts +61 -0
- package/dist/session-content/turn.d.ts +328 -0
- package/dist/site.d.ts +0 -1
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +46 -50
- package/dist/space-schema.d.ts +6 -0
- package/dist/space-schema.d.ts.map +1 -0
- package/dist/space-schema.js +11 -0
- package/dist/stream.d.ts +4 -4
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +149 -70
- package/dist/transport.d.ts +50 -26
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +17 -12
- 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 +3 -2
- package/dist/upload.d.ts.map +1 -1
- package/dist/upload.js +8 -6
- package/dist/version.d.ts +0 -1
- package/dist/write.d.ts +2 -3
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +29 -46
- package/package.json +3 -2
- package/dist/app-reference.d.ts +0 -2
- package/dist/app-reference.d.ts.map +0 -1
- package/dist/app-reference.js +0 -2
- package/dist/crockford.d.ts +0 -4
- package/dist/crockford.d.ts.map +0 -1
- package/dist/crockford.js +0 -3
- package/dist/house-model.d.ts +0 -1883
- package/dist/house-model.d.ts.map +0 -1
- package/dist/house-model.js +0 -1025
- package/dist/part.d.ts +0 -14
- package/dist/part.d.ts.map +0 -1
- package/dist/part.js +0 -90
- package/dist/room-stream.d.ts +0 -19
- package/dist/room-stream.d.ts.map +0 -1
- package/dist/room-stream.js +0 -57
- package/dist/room-types.d.ts +0 -7
- package/dist/room-types.d.ts.map +0 -1
- package/dist/room-types.js +0 -126
package/dist/discovery.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { declaredActions } from './actions.js';
|
|
2
|
-
import {
|
|
2
|
+
import { SITES_SUBMISSIONS_CREATE } from './transport.js';
|
|
3
3
|
import { readPosition, roomVersion } from './version.js';
|
|
4
4
|
export const PROVIDER_ACTIONS = 'provider-actions';
|
|
5
5
|
const BOUND_KEYS = [
|
|
@@ -8,17 +8,20 @@ const BOUND_KEYS = [
|
|
|
8
8
|
'max_batch_documents',
|
|
9
9
|
'max_path_length',
|
|
10
10
|
'max_path_depth',
|
|
11
|
-
'max_mount_files',
|
|
12
|
-
'max_mount_bytes',
|
|
13
11
|
'max_inline_body_bytes',
|
|
14
12
|
'max_upload_bytes',
|
|
15
13
|
'max_prefixes',
|
|
16
|
-
'max_held_files',
|
|
17
14
|
'change_retention_seconds',
|
|
18
|
-
'operation_retention_seconds',
|
|
19
15
|
];
|
|
20
|
-
const OPERATION_KEYS = ['write', '
|
|
16
|
+
const OPERATION_KEYS = ['write', 'erase'];
|
|
21
17
|
const ACCESS_LEVELS = ['search', 'open', 'keep'];
|
|
18
|
+
const ROOM_ACCESS = [
|
|
19
|
+
'owner',
|
|
20
|
+
'manage',
|
|
21
|
+
'write',
|
|
22
|
+
'read',
|
|
23
|
+
'public',
|
|
24
|
+
];
|
|
22
25
|
function stringList(value) {
|
|
23
26
|
if (!Array.isArray(value))
|
|
24
27
|
return null;
|
|
@@ -48,6 +51,9 @@ function parseTypedSelection(value) {
|
|
|
48
51
|
return null;
|
|
49
52
|
return stringList(value) ?? undefined;
|
|
50
53
|
}
|
|
54
|
+
function parseTimeZone(value) {
|
|
55
|
+
return typeof value === 'string' ? value : null;
|
|
56
|
+
}
|
|
51
57
|
function parseMember(value) {
|
|
52
58
|
if (typeof value !== 'object' || value === null)
|
|
53
59
|
return null;
|
|
@@ -85,11 +91,13 @@ function parseAuthority(value) {
|
|
|
85
91
|
const at = readPosition(held);
|
|
86
92
|
const typedSelection = parseTypedSelection(held.typed_selection);
|
|
87
93
|
const protectedPaths = stringList(held.protected_paths);
|
|
94
|
+
const writtenHomes = stringList(held.written_homes);
|
|
88
95
|
const operations = parseOperations(held.operations);
|
|
89
96
|
const level = ACCESS_LEVELS.find((one) => one === held.level);
|
|
90
97
|
if (at === null ||
|
|
91
98
|
typedSelection === undefined ||
|
|
92
99
|
protectedPaths === null ||
|
|
100
|
+
writtenHomes === null ||
|
|
93
101
|
level === undefined ||
|
|
94
102
|
operations === null)
|
|
95
103
|
return null;
|
|
@@ -105,11 +113,95 @@ function parseAuthority(value) {
|
|
|
105
113
|
typedSelection,
|
|
106
114
|
managedReplication: held.managed_replication,
|
|
107
115
|
protectedPaths,
|
|
116
|
+
writtenHomes,
|
|
108
117
|
level,
|
|
109
118
|
operations,
|
|
110
119
|
...at,
|
|
111
120
|
};
|
|
112
121
|
}
|
|
122
|
+
function parseOwner(value) {
|
|
123
|
+
if (typeof value !== 'object' || value === null)
|
|
124
|
+
return null;
|
|
125
|
+
const { user, name } = value;
|
|
126
|
+
return typeof user === 'string' && typeof name === 'string' ? { user, name } : null;
|
|
127
|
+
}
|
|
128
|
+
function parseSpaceRef(value) {
|
|
129
|
+
if (typeof value !== 'object' || value === null)
|
|
130
|
+
return null;
|
|
131
|
+
const { space_ref, name } = value;
|
|
132
|
+
return typeof space_ref === 'string' && typeof name === 'string' ? { space_ref, name } : null;
|
|
133
|
+
}
|
|
134
|
+
function parseListedRoom(value) {
|
|
135
|
+
if (typeof value !== 'object' || value === null)
|
|
136
|
+
return null;
|
|
137
|
+
const held = value;
|
|
138
|
+
const level = ACCESS_LEVELS.find((one) => one === held.level);
|
|
139
|
+
const access = ROOM_ACCESS.find((one) => one === held.access);
|
|
140
|
+
const owner = parseOwner(held.owner);
|
|
141
|
+
const space = held.space === undefined ? undefined : parseSpaceRef(held.space);
|
|
142
|
+
if (typeof held.room_ref !== 'string' ||
|
|
143
|
+
held.room_ref.length === 0 ||
|
|
144
|
+
typeof held.room_handle !== 'string' ||
|
|
145
|
+
held.room_handle.length === 0 ||
|
|
146
|
+
typeof held.name !== 'string' ||
|
|
147
|
+
typeof held.created !== 'string' ||
|
|
148
|
+
(held.archived !== undefined && typeof held.archived !== 'string') ||
|
|
149
|
+
(held.exportable !== undefined && held.exportable !== true) ||
|
|
150
|
+
level === undefined ||
|
|
151
|
+
access === undefined ||
|
|
152
|
+
owner === null ||
|
|
153
|
+
space === null)
|
|
154
|
+
return null;
|
|
155
|
+
return {
|
|
156
|
+
room_ref: held.room_ref,
|
|
157
|
+
room_handle: held.room_handle,
|
|
158
|
+
name: held.name,
|
|
159
|
+
level,
|
|
160
|
+
access,
|
|
161
|
+
owner,
|
|
162
|
+
created: held.created,
|
|
163
|
+
...(typeof held.archived === 'string' ? { archived: held.archived } : {}),
|
|
164
|
+
...(held.exportable === true ? { exportable: true } : {}),
|
|
165
|
+
...(space === undefined ? {} : { space }),
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
function parseListedSpace(value) {
|
|
169
|
+
const space = parseSpaceRef(value);
|
|
170
|
+
if (space === null)
|
|
171
|
+
return null;
|
|
172
|
+
const held = value;
|
|
173
|
+
const owner = parseOwner(held.owner);
|
|
174
|
+
if (owner === null ||
|
|
175
|
+
typeof held.created !== 'string' ||
|
|
176
|
+
(held.manages !== undefined && held.manages !== true))
|
|
177
|
+
return null;
|
|
178
|
+
return {
|
|
179
|
+
...space,
|
|
180
|
+
owner,
|
|
181
|
+
created: held.created,
|
|
182
|
+
...(held.manages === true ? { manages: true } : {}),
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function parsedAll(value, parse) {
|
|
186
|
+
if (!Array.isArray(value))
|
|
187
|
+
return null;
|
|
188
|
+
const parsed = [];
|
|
189
|
+
for (const entry of value) {
|
|
190
|
+
const one = parse(entry);
|
|
191
|
+
if (one === null)
|
|
192
|
+
return null;
|
|
193
|
+
parsed.push(one);
|
|
194
|
+
}
|
|
195
|
+
return parsed;
|
|
196
|
+
}
|
|
197
|
+
function parseRoomList(authorities, listed, spaces) {
|
|
198
|
+
const held = parsedAll(authorities, parseListedRoom);
|
|
199
|
+
const only = parsedAll(listed, parseListedRoom);
|
|
200
|
+
const shown = parsedAll(spaces, parseListedSpace);
|
|
201
|
+
if (held === null || only === null || shown === null)
|
|
202
|
+
return null;
|
|
203
|
+
return { rooms: [...held, ...only], spaces: shown, listed: only };
|
|
204
|
+
}
|
|
113
205
|
function parseAuthorities(value) {
|
|
114
206
|
if (!Array.isArray(value))
|
|
115
207
|
return null;
|
|
@@ -122,6 +214,49 @@ function parseAuthorities(value) {
|
|
|
122
214
|
}
|
|
123
215
|
return authorities;
|
|
124
216
|
}
|
|
217
|
+
export const ROOM_OWN = {
|
|
218
|
+
room_ref: true,
|
|
219
|
+
room_handle: true,
|
|
220
|
+
name: true,
|
|
221
|
+
position: true,
|
|
222
|
+
created: true,
|
|
223
|
+
archived: true,
|
|
224
|
+
};
|
|
225
|
+
function ownKey(key) {
|
|
226
|
+
return Object.hasOwn(ROOM_OWN, key);
|
|
227
|
+
}
|
|
228
|
+
export function foldedAuthorities(authorities) {
|
|
229
|
+
const shapes = [];
|
|
230
|
+
const known = new Map();
|
|
231
|
+
const rooms = authorities.map((authority) => {
|
|
232
|
+
const entries = Object.entries(authority);
|
|
233
|
+
const shape = Object.fromEntries(entries.filter(([key]) => !ownKey(key)));
|
|
234
|
+
const own = Object.fromEntries(entries.filter(([key]) => ownKey(key)));
|
|
235
|
+
const key = JSON.stringify(shape);
|
|
236
|
+
let held = known.get(key);
|
|
237
|
+
if (held === undefined) {
|
|
238
|
+
held = shapes.push(shape) - 1;
|
|
239
|
+
known.set(key, held);
|
|
240
|
+
}
|
|
241
|
+
return { ...own, shape: held };
|
|
242
|
+
});
|
|
243
|
+
return { shapes, rooms };
|
|
244
|
+
}
|
|
245
|
+
function unfolded(shapes, rooms) {
|
|
246
|
+
if (!Array.isArray(shapes) || !Array.isArray(rooms))
|
|
247
|
+
return null;
|
|
248
|
+
const authorities = [];
|
|
249
|
+
for (const room of rooms) {
|
|
250
|
+
if (typeof room !== 'object' || room === null)
|
|
251
|
+
return null;
|
|
252
|
+
const { shape, ...own } = room;
|
|
253
|
+
const held = typeof shape === 'number' ? shapes[shape] : undefined;
|
|
254
|
+
if (typeof held !== 'object' || held === null)
|
|
255
|
+
return null;
|
|
256
|
+
authorities.push({ ...held, ...own });
|
|
257
|
+
}
|
|
258
|
+
return authorities;
|
|
259
|
+
}
|
|
125
260
|
export function parseDiscovery(body) {
|
|
126
261
|
if (typeof body !== 'object' || body === null)
|
|
127
262
|
return null;
|
|
@@ -137,8 +272,19 @@ export function parseDiscovery(body) {
|
|
|
137
272
|
new Set(actions).size !== actions.length ||
|
|
138
273
|
actions.some((name) => name.length === 0))
|
|
139
274
|
return null;
|
|
140
|
-
const
|
|
141
|
-
|
|
275
|
+
const entries = unfolded(held.shapes, held.rooms);
|
|
276
|
+
const authorities = parseAuthorities(entries);
|
|
277
|
+
const listing = parseRoomList(entries, held.listed, held.spaces);
|
|
278
|
+
if (authorities === null || listing === null)
|
|
279
|
+
return null;
|
|
280
|
+
return {
|
|
281
|
+
member,
|
|
282
|
+
timeZone: parseTimeZone(held.time_zone),
|
|
283
|
+
bounds,
|
|
284
|
+
authorities,
|
|
285
|
+
actions,
|
|
286
|
+
roomList: { rooms: listing.rooms, spaces: listing.spaces },
|
|
287
|
+
};
|
|
142
288
|
}
|
|
143
289
|
export function parseAuthorityChange(body) {
|
|
144
290
|
if (typeof body !== 'object' || body === null)
|
|
@@ -146,10 +292,18 @@ export function parseAuthorityChange(body) {
|
|
|
146
292
|
const held = body;
|
|
147
293
|
const member = parseMember(held.member);
|
|
148
294
|
const authorities = parseAuthorities(held.authorities);
|
|
295
|
+
const listing = parseRoomList(held.authorities, held.listed, held.spaces);
|
|
149
296
|
const left = stringList(held.left);
|
|
150
|
-
if (member === null || authorities === null || left === null)
|
|
297
|
+
if (member === null || authorities === null || listing === null || left === null)
|
|
151
298
|
return null;
|
|
152
|
-
return {
|
|
299
|
+
return {
|
|
300
|
+
member,
|
|
301
|
+
timeZone: parseTimeZone(held.time_zone),
|
|
302
|
+
authorities,
|
|
303
|
+
listed: listing.listed.map((room) => room.room_ref),
|
|
304
|
+
left,
|
|
305
|
+
roomList: { rooms: listing.rooms, spaces: listing.spaces },
|
|
306
|
+
};
|
|
153
307
|
}
|
|
154
308
|
function parseSiteAuthority(value) {
|
|
155
309
|
if (typeof value !== 'object' || value === null)
|
|
@@ -230,7 +384,6 @@ export function providerLimits(bounds) {
|
|
|
230
384
|
export function declaredRetention(bounds) {
|
|
231
385
|
return {
|
|
232
386
|
history: { kind: 'no-declared-time-bound' },
|
|
233
|
-
outcome: bounds.operation_retention_seconds,
|
|
234
387
|
refreshHorizon: bounds.change_retention_seconds,
|
|
235
388
|
};
|
|
236
389
|
}
|
|
@@ -241,7 +394,7 @@ export function siteCapabilities() {
|
|
|
241
394
|
return [
|
|
242
395
|
{
|
|
243
396
|
name: PROVIDER_ACTIONS,
|
|
244
|
-
actions: [{ name:
|
|
397
|
+
actions: [{ name: SITES_SUBMISSIONS_CREATE, inputShape: {}, resultKind: 'house' }],
|
|
245
398
|
},
|
|
246
399
|
];
|
|
247
400
|
}
|
|
@@ -254,17 +407,16 @@ export function discoveredRoom(authority) {
|
|
|
254
407
|
roomVersion: roomVersion(authority),
|
|
255
408
|
operations: {
|
|
256
409
|
write: [...authority.operations.write],
|
|
257
|
-
|
|
410
|
+
erase: [...authority.operations.erase],
|
|
258
411
|
},
|
|
259
412
|
replica: {
|
|
260
413
|
selection: locator,
|
|
261
414
|
admission: authority.managedReplication,
|
|
262
415
|
offline: authority.level === 'open' ? 'locked' : 'open',
|
|
263
416
|
},
|
|
264
|
-
|
|
265
|
-
? {}
|
|
266
|
-
: { typedSelection: { roots: [...authority.typedSelection] } }),
|
|
417
|
+
typedSelection: authority.typedSelection === null ? null : { roots: [...authority.typedSelection] },
|
|
267
418
|
providerOwnedPaths: [...authority.protectedPaths, authority.schema],
|
|
419
|
+
authoredPaths: [...authority.writtenHomes],
|
|
268
420
|
};
|
|
269
421
|
}
|
|
270
422
|
export function mapDiscovery(document, rooms, declared) {
|
package/dist/history.d.ts
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import type { AcceptedMessage, ActionResult, ConversationHistoryRequest } from '@agentshouse/mdruntime';
|
|
2
2
|
import { type HouseDoor } from './transport.js';
|
|
3
3
|
export declare const HISTORY_PAGE = 100;
|
|
4
|
-
|
|
5
|
-
accepted_at: string;
|
|
6
|
-
message_id: string;
|
|
7
|
-
};
|
|
8
|
-
export declare function cursorPosition(cursor: HistoryCursor): string;
|
|
4
|
+
export declare function changeCursor(change: number): string;
|
|
9
5
|
export declare function acceptedMessage(entry: unknown): AcceptedMessage | null;
|
|
10
6
|
export declare function houseHistory(transport: HouseDoor, request: ConversationHistoryRequest): Promise<ActionResult>;
|
|
11
|
-
export {};
|
|
12
|
-
//# sourceMappingURL=history.d.ts.map
|
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;
|
|
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;AAGhE,eAAO,MAAM,YAAY,MAAM,CAAC;AAqBhC,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAatE;AA6BD,wBAAsB,YAAY,CAChC,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,YAAY,CAAC,CAqBvB"}
|
package/dist/history.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { actionOutcome } from './actions.js';
|
|
2
2
|
import { houseDoorRoute } from './transport.js';
|
|
3
|
+
import { unusable } from './uncertain.js';
|
|
3
4
|
export const HISTORY_PAGE = 100;
|
|
4
|
-
const HISTORY = 'conversations/history';
|
|
5
|
+
const HISTORY = 'conversations/history/list';
|
|
6
|
+
const CHANGE_DIGITS = 16;
|
|
7
|
+
const CHANGE = new RegExp(`^[0-9]{${CHANGE_DIGITS}}$`);
|
|
5
8
|
function record(value) {
|
|
6
9
|
return typeof value === 'object' && value !== null ? value : {};
|
|
7
10
|
}
|
|
@@ -9,32 +12,23 @@ function text(value, name) {
|
|
|
9
12
|
const held = record(value)[name];
|
|
10
13
|
return typeof held === 'string' ? held : undefined;
|
|
11
14
|
}
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
const messageId = text(value, 'message_id');
|
|
15
|
-
if (acceptedAt === undefined || messageId === undefined)
|
|
16
|
-
return null;
|
|
17
|
-
return { accepted_at: acceptedAt, message_id: messageId };
|
|
18
|
-
}
|
|
19
|
-
export function cursorPosition(cursor) {
|
|
20
|
-
return JSON.stringify({ accepted_at: cursor.accepted_at, message_id: cursor.message_id });
|
|
15
|
+
function changeOf(value) {
|
|
16
|
+
return Number.isSafeInteger(value) && value > 0 ? value : null;
|
|
21
17
|
}
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
return historyCursor(JSON.parse(value));
|
|
25
|
-
}
|
|
26
|
-
catch {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
18
|
+
export function changeCursor(change) {
|
|
19
|
+
return String(change).padStart(CHANGE_DIGITS, '0');
|
|
29
20
|
}
|
|
30
21
|
export function acceptedMessage(entry) {
|
|
31
|
-
const
|
|
32
|
-
|
|
22
|
+
const identity = text(entry, 'message_id');
|
|
23
|
+
const acceptedAt = text(entry, 'accepted_at');
|
|
24
|
+
const change = changeOf(record(entry).change);
|
|
25
|
+
if (identity === undefined || acceptedAt === undefined || change === null)
|
|
33
26
|
return null;
|
|
34
27
|
return {
|
|
35
|
-
identity
|
|
36
|
-
turn: text(entry, 'turn_id') ??
|
|
37
|
-
position:
|
|
28
|
+
identity,
|
|
29
|
+
turn: text(entry, 'turn_id') ?? identity,
|
|
30
|
+
position: JSON.stringify({ accepted_at: acceptedAt, message_id: identity }),
|
|
31
|
+
change: changeCursor(change),
|
|
38
32
|
text: text(entry, 'text') ?? '',
|
|
39
33
|
message: structuredClone(record(entry)),
|
|
40
34
|
};
|
|
@@ -51,20 +45,19 @@ function historyPage(entry) {
|
|
|
51
45
|
return null;
|
|
52
46
|
messages.push(message);
|
|
53
47
|
}
|
|
54
|
-
const next = held.next === null || held.next === undefined ? undefined :
|
|
48
|
+
const next = held.next === null || held.next === undefined ? undefined : changeOf(held.next);
|
|
55
49
|
if (next === null)
|
|
56
50
|
return null;
|
|
57
|
-
return { conversation, messages, ...(next === undefined ? {} : { next:
|
|
51
|
+
return { conversation, messages, ...(next === undefined ? {} : { next: changeCursor(next) }) };
|
|
58
52
|
}
|
|
59
53
|
function historyAsks(request) {
|
|
60
54
|
const asks = [];
|
|
61
55
|
for (const { conversation, after } of request.conversations) {
|
|
62
|
-
|
|
63
|
-
if (cursor === null)
|
|
56
|
+
if (after !== undefined && !CHANGE.test(after))
|
|
64
57
|
return null;
|
|
65
58
|
asks.push({
|
|
66
59
|
conversation_id: conversation,
|
|
67
|
-
...(
|
|
60
|
+
...(after === undefined ? {} : { after: Number(after) }),
|
|
68
61
|
});
|
|
69
62
|
}
|
|
70
63
|
return asks;
|
|
@@ -73,17 +66,18 @@ export async function houseHistory(transport, request) {
|
|
|
73
66
|
const asks = historyAsks(request);
|
|
74
67
|
if (asks === null)
|
|
75
68
|
return { kind: 'rejected', code: 'invalid_request', fields: {}, retryable: false };
|
|
76
|
-
const
|
|
69
|
+
const asked = { conversations: asks, limit: HISTORY_PAGE };
|
|
70
|
+
const outcome = actionOutcome(await transport.door(houseDoorRoute(HISTORY), asked), HISTORY, asked);
|
|
77
71
|
if (outcome.kind !== 'action')
|
|
78
72
|
return outcome;
|
|
79
73
|
const answered = record(outcome.result).histories;
|
|
80
74
|
if (!Array.isArray(answered))
|
|
81
|
-
return
|
|
75
|
+
return unusable();
|
|
82
76
|
const histories = [];
|
|
83
77
|
for (const entry of answered) {
|
|
84
78
|
const page = historyPage(entry);
|
|
85
79
|
if (page === null)
|
|
86
|
-
return
|
|
80
|
+
return unusable();
|
|
87
81
|
histories.push(page);
|
|
88
82
|
}
|
|
89
83
|
const result = { histories };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
export { createAgentsHouseAdapter, type AgentsHouseAdapterOptions } from './adapter.js';
|
|
2
|
+
export { foldedAuthorities, ROOM_OWN } from './discovery.js';
|
|
2
3
|
export { finishedUpload, houseUpload, type HouseUpload } from './upload.js';
|
|
3
4
|
export { houseAction, type HouseActDoor } from './actions.js';
|
|
4
5
|
export { HISTORY_PAGE } from './history.js';
|
|
6
|
+
export { answeredFailure } from './refusal.js';
|
|
7
|
+
export { answering, documentEntry, kept, type Answered, type HouseManifestFile } from './read.js';
|
|
5
8
|
export { houseParts, type ChangeMapping } from './write.js';
|
|
6
|
-
export {
|
|
7
|
-
export { HOUSE_MODEL_DECLARATION, HOUSE_MODEL_TYPES, type HouseDocumentFields, type HouseModelType, } from './house-model.js';
|
|
8
|
-
export { CROCKFORD_ALPHABET, CROCKFORD_CHARACTER, CROCKFORD_LEADING_CHARACTER, } from './crockford.js';
|
|
9
|
-
export { HOUSE_NAMEABLE_ROOM_TYPES, HOUSE_ROOM_TYPES, INBOX_CHANNEL_KINDS, INBOX_CHAT_TYPE, INBOX_MESSAGE_TYPE, type InboxChannelKind, } from './room-types.js';
|
|
9
|
+
export { admittedPath, AUTHORED_SEGMENT, AUTHORED_SEGMENT_MAX_CHARS, GENERATED_PROVENANCE, GENERATED_REVISIONS, LOCAL_COPY_MANIFEST, LOCAL_COPY_ROOT_NAMES, RESERVED_DERIVED, WHOLE_ESCAPED_NAMES, } from './authored-path.js';
|
|
10
10
|
export { HOUSE_RUNTIME_READS, houseDoorRoute, houseSiteRoute, type HouseRuntimeAct, type HouseRuntimeFrame, } from './transport.js';
|
|
11
|
-
export type {
|
|
12
|
-
//# sourceMappingURL=index.d.ts.map
|
|
11
|
+
export type { HouseByteTransfer, HouseBytesAnswer, HouseClosing, HouseDoorAnswer, HouseHeldRoom, HouseOpening, HouseStream, HouseStreamEntry, HouseStreamFrame, HouseSiteTransport, HouseTransport, } from './transport.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,KAAK,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,KAAK,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,IAAI,EAAE,KAAK,QAAQ,EAAE,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAClG,OAAO,EAAE,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,0BAA0B,EAC1B,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,iBAAiB,GACvB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,aAAa,EACb,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,GACf,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { createAgentsHouseAdapter } from './adapter.js';
|
|
2
|
+
export { foldedAuthorities, ROOM_OWN } from './discovery.js';
|
|
2
3
|
export { finishedUpload, houseUpload } from './upload.js';
|
|
3
4
|
export { houseAction } from './actions.js';
|
|
4
5
|
export { HISTORY_PAGE } from './history.js';
|
|
6
|
+
export { answeredFailure } from './refusal.js';
|
|
7
|
+
export { answering, documentEntry, kept } from './read.js';
|
|
5
8
|
export { houseParts } from './write.js';
|
|
6
|
-
export {
|
|
7
|
-
export { HOUSE_MODEL_DECLARATION, HOUSE_MODEL_TYPES, } from './house-model.js';
|
|
8
|
-
export { CROCKFORD_ALPHABET, CROCKFORD_CHARACTER, CROCKFORD_LEADING_CHARACTER, } from './crockford.js';
|
|
9
|
-
export { HOUSE_NAMEABLE_ROOM_TYPES, HOUSE_ROOM_TYPES, INBOX_CHANNEL_KINDS, INBOX_CHAT_TYPE, INBOX_MESSAGE_TYPE, } from './room-types.js';
|
|
9
|
+
export { admittedPath, AUTHORED_SEGMENT, AUTHORED_SEGMENT_MAX_CHARS, GENERATED_PROVENANCE, GENERATED_REVISIONS, LOCAL_COPY_MANIFEST, LOCAL_COPY_ROOT_NAMES, RESERVED_DERIVED, WHOLE_ESCAPED_NAMES, } from './authored-path.js';
|
|
10
10
|
export { HOUSE_RUNTIME_READS, houseDoorRoute, houseSiteRoute, } from './transport.js';
|
package/dist/map.d.ts
CHANGED
package/dist/model.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import type { RoomModels } from '@agentshouse/mdruntime';
|
|
2
2
|
import type { TrackedAuthority } from './discovery.js';
|
|
3
|
-
import { type
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
export declare function manifestedModels(room: HouseRoomHead, tracked: TrackedAuthority): Promise<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}>;
|
|
10
|
-
export declare function streamedModels(schemas: ReadonlyMap<string, HouseStreamEntry>, tracked: TrackedAuthority, mode: HouseMode): Promise<RoomModels | undefined>;
|
|
11
|
-
//# sourceMappingURL=model.d.ts.map
|
|
3
|
+
import { type HouseManifestFile, type HouseRoomHead } from './read.js';
|
|
4
|
+
import { type SpaceSchemas } from './space-schema.js';
|
|
5
|
+
import type { HouseStreamEntry } from './transport.js';
|
|
6
|
+
export declare function manifestedModels(room: HouseRoomHead, tracked: TrackedAuthority): Promise<RoomModels | undefined>;
|
|
7
|
+
export declare function spaceSchemaTexts(entries: readonly HouseStreamEntry[], spaces: SpaceSchemas): HouseStreamEntry[];
|
|
8
|
+
export declare function streamedModels(schemas: ReadonlyMap<string, HouseManifestFile | null>, tracked: TrackedAuthority, whole: boolean): Promise<RoomModels | undefined>;
|
package/dist/model.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAKL,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAEnB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAiB,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AA+BvD,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAGjC;AAYD,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,SAAS,gBAAgB,EAAE,EACpC,MAAM,EAAE,YAAY,GACnB,gBAAgB,EAAE,CAEpB;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC,EACtD,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAMjC"}
|
package/dist/model.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { sha256Hex } from './digest.js';
|
|
2
|
-
import { modelScope, schemaOf, schemaPath, } from './read.js';
|
|
2
|
+
import { modelScope, schemaFile, schemaOf, schemaPath, } from './read.js';
|
|
3
|
+
import { spaceIdentity } from './space-schema.js';
|
|
3
4
|
const MODEL_ABSENT = { kind: 'model-unavailable', reason: 'not-readable' };
|
|
4
5
|
const ABSENT_SCHEMA = { schema: null, version: null, revision: null };
|
|
5
6
|
async function heldModel(read, identity) {
|
|
@@ -8,7 +9,12 @@ async function heldModel(read, identity) {
|
|
|
8
9
|
const version = await sha256Hex(JSON.stringify(read.version));
|
|
9
10
|
return {
|
|
10
11
|
kind: 'model',
|
|
11
|
-
snapshot: {
|
|
12
|
+
snapshot: {
|
|
13
|
+
identity: read.space === undefined ? identity : spaceIdentity(read.space),
|
|
14
|
+
version,
|
|
15
|
+
schema: read.schema,
|
|
16
|
+
revision: read.revision,
|
|
17
|
+
},
|
|
12
18
|
};
|
|
13
19
|
}
|
|
14
20
|
async function modelsOf(tracked, read) {
|
|
@@ -17,32 +23,28 @@ async function modelsOf(tracked, read) {
|
|
|
17
23
|
return undefined;
|
|
18
24
|
return { collection: await heldModel(collection, schemaPath(tracked.handle, tracked.schema)) };
|
|
19
25
|
}
|
|
20
|
-
export function partModels(scope, tracked, seen, final) {
|
|
21
|
-
return modelsOf(tracked, (schema) => {
|
|
22
|
-
if (scope.files.some((file) => file.path === schema))
|
|
23
|
-
return schemaOf(scope, schema);
|
|
24
|
-
return final && !seen.has(schema) ? ABSENT_SCHEMA : undefined;
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
26
|
export async function manifestedModels(room, tracked) {
|
|
28
|
-
const
|
|
29
|
-
return
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
const held = schemaOf(modelScope(room), tracked.schema);
|
|
28
|
+
return modelsOf(tracked, () => held);
|
|
29
|
+
}
|
|
30
|
+
function spaceSchemaText(entry, spaces) {
|
|
31
|
+
if (entry.space === undefined || entry.revision === undefined)
|
|
32
|
+
return entry;
|
|
33
|
+
if (entry.content !== undefined) {
|
|
34
|
+
spaces.keep(entry.space, entry.revision, entry.content);
|
|
35
|
+
return entry;
|
|
36
|
+
}
|
|
37
|
+
const content = spaces.held(entry.space, entry.revision);
|
|
38
|
+
return content === undefined ? entry : { ...entry, content };
|
|
39
|
+
}
|
|
40
|
+
export function spaceSchemaTexts(entries, spaces) {
|
|
41
|
+
return entries.map((entry) => spaceSchemaText(entry, spaces));
|
|
33
42
|
}
|
|
34
|
-
export function streamedModels(schemas, tracked,
|
|
43
|
+
export function streamedModels(schemas, tracked, whole) {
|
|
35
44
|
return modelsOf(tracked, (schema) => {
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
38
|
-
return undefined;
|
|
39
|
-
|
|
40
|
-
return ABSENT_SCHEMA;
|
|
41
|
-
if (entry.text === undefined)
|
|
42
|
-
return null;
|
|
43
|
-
const version = mode === 'site' ? entry.sha256 : entry.revision;
|
|
44
|
-
return version === undefined
|
|
45
|
-
? null
|
|
46
|
-
: { schema: entry.text, version, revision: mode === 'site' ? null : version };
|
|
45
|
+
const file = schemas.get(schema);
|
|
46
|
+
if (file === undefined)
|
|
47
|
+
return whole ? ABSENT_SCHEMA : undefined;
|
|
48
|
+
return file === null ? ABSENT_SCHEMA : schemaFile(file);
|
|
47
49
|
});
|
|
48
50
|
}
|
package/dist/read.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { type BinaryFile, type BootstrapPage, type
|
|
1
|
+
import { type BinaryFile, type BootstrapPage, type SavedFacts } from '@agentshouse/mdruntime';
|
|
2
2
|
import type { HouseMode } from './transport.js';
|
|
3
3
|
import { type LogPosition } from './version.js';
|
|
4
4
|
export type HeadChange = BootstrapPage['changes'][string];
|
|
5
5
|
export type Answered = {
|
|
6
6
|
readonly documents: Map<string, string>;
|
|
7
|
+
readonly facts: Map<string, SavedFacts>;
|
|
7
8
|
readonly revisions: Map<string, string>;
|
|
8
9
|
readonly fileIds: Map<string, string>;
|
|
10
|
+
readonly created: Map<string, string>;
|
|
9
11
|
readonly changes: Map<string, HeadChange>;
|
|
10
12
|
readonly binaryFiles: Map<string, BinaryFile>;
|
|
11
13
|
readonly removals: Set<string>;
|
|
@@ -18,8 +20,10 @@ export declare function forgotten(answer: Answered, path: string): void;
|
|
|
18
20
|
export declare function folded(answer: Answered, path: string, removed: boolean): void;
|
|
19
21
|
export declare function answered(answer: Answered): Generator<number, {
|
|
20
22
|
documents: Readonly<Record<string, string>>;
|
|
23
|
+
facts: Readonly<Record<string, SavedFacts>>;
|
|
21
24
|
revisions: Readonly<Record<string, string>>;
|
|
22
25
|
fileIds?: Readonly<Record<string, string>>;
|
|
26
|
+
created?: Readonly<Record<string, string>>;
|
|
23
27
|
changes: Readonly<Record<string, HeadChange>>;
|
|
24
28
|
binaryFiles: Readonly<Record<string, BinaryFile>>;
|
|
25
29
|
removals: readonly string[];
|
|
@@ -30,24 +34,19 @@ export type HouseManifestFile = {
|
|
|
30
34
|
path: string;
|
|
31
35
|
revision: string | undefined;
|
|
32
36
|
version: string;
|
|
33
|
-
sha256?: string;
|
|
34
37
|
head?: HeadChange;
|
|
38
|
+
created?: string;
|
|
35
39
|
binary?: BinaryFile;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
content: string;
|
|
40
|
+
facts?: SavedFacts;
|
|
41
|
+
space?: string;
|
|
42
|
+
content?: string;
|
|
40
43
|
};
|
|
41
44
|
export type HouseScope = LogPosition & {
|
|
42
45
|
anchor: string;
|
|
43
46
|
files: readonly HouseManifestFile[];
|
|
44
|
-
contents: readonly HouseContent[];
|
|
45
47
|
folders?: readonly string[];
|
|
46
48
|
};
|
|
47
|
-
export type HouseModels =
|
|
48
|
-
files: readonly HouseManifestFile[];
|
|
49
|
-
contents: readonly HouseContent[];
|
|
50
|
-
};
|
|
49
|
+
export type HouseModels = readonly HouseManifestFile[];
|
|
51
50
|
export type HouseRoomHead = LogPosition & {
|
|
52
51
|
anchor: string;
|
|
53
52
|
models: HouseModels;
|
|
@@ -68,22 +67,18 @@ export declare function parseGrant(body: unknown): HouseGrant | null;
|
|
|
68
67
|
export declare function parseFileAddress(body: unknown): HouseFileAddress | null;
|
|
69
68
|
export declare function headChange(held: {
|
|
70
69
|
readonly author?: unknown;
|
|
71
|
-
readonly
|
|
70
|
+
readonly changed_at?: unknown;
|
|
72
71
|
}): HeadChange | undefined | null;
|
|
73
72
|
export declare function binaryFileOf(held: Readonly<Record<string, unknown>>): BinaryFile | undefined | null;
|
|
74
|
-
export declare function
|
|
75
|
-
export declare function
|
|
73
|
+
export declare function documentEntry(value: unknown, mode: HouseMode): HouseManifestFile | null;
|
|
74
|
+
export declare function kept(answer: Answered, file: HouseManifestFile): void;
|
|
76
75
|
export declare function modelScope(room: HouseRoomHead): HouseScope;
|
|
77
|
-
export declare function emptyScope(room: HouseRoomHead): HouseScope;
|
|
78
|
-
export declare function housePart(room: HouseRoomHead, payload: Uint8Array<ArrayBuffer>, mode: HouseMode): Promise<{
|
|
79
|
-
scope: HouseScope;
|
|
80
|
-
ended: boolean;
|
|
81
|
-
} | TransportUncertainty>;
|
|
82
76
|
export declare function bootstrapping(scope: HouseScope): Generator<number, BootstrapPage, void>;
|
|
83
77
|
export type HouseSchema = {
|
|
84
78
|
schema: string | null;
|
|
85
79
|
version: string | null;
|
|
86
80
|
revision: string | null;
|
|
81
|
+
space?: string;
|
|
87
82
|
};
|
|
83
|
+
export declare function schemaFile(file: HouseManifestFile): HouseSchema | null;
|
|
88
84
|
export declare function schemaOf(scope: HouseScope, schema: string): HouseSchema | null;
|
|
89
|
-
//# sourceMappingURL=read.d.ts.map
|