@agentshouse/mdruntime-adapter 0.1.0-c0a168d2cd8cc → 0.1.0-c0a3a92c6ef52
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/adapter.d.ts.map +1 -1
- package/dist/adapter.js +64 -82
- package/dist/chunks.d.ts +38 -0
- package/dist/chunks.d.ts.map +1 -0
- package/dist/chunks.js +247 -0
- package/dist/discovery.d.ts +1 -2
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +4 -5
- package/dist/history.js +1 -1
- package/dist/house-model.d.ts +63 -302
- package/dist/house-model.d.ts.map +1 -1
- package/dist/house-model.js +43 -167
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/model.d.ts +5 -7
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +30 -18
- package/dist/read.d.ts +19 -13
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +46 -169
- package/dist/room-types.d.ts.map +1 -1
- package/dist/room-types.js +0 -2
- package/dist/search.js +1 -1
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +31 -49
- 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 +6 -4
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +92 -25
- package/dist/transport.d.ts +7 -10
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +12 -12
- package/dist/write.js +1 -1
- package/package.json +2 -2
- 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 -20
- package/dist/room-stream.d.ts.map +0 -1
- package/dist/room-stream.js +0 -78
package/dist/stream.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { ROW_WEIGHT, stepped, } from '@agentshouse/mdruntime';
|
|
2
2
|
import { acceptedMessage, cursorPosition, houseHistory } from './history.js';
|
|
3
|
-
import { streamedModels } from './model.js';
|
|
4
|
-
import { answered, answering, binaryFileOf, folded, forgotten, headChange,
|
|
3
|
+
import { keptSpaceSchemas, streamedModels } from './model.js';
|
|
4
|
+
import { answered, answering, binaryFileOf, createdOf, folded, forgotten, headChange, revised, } from './read.js';
|
|
5
5
|
import { houseDoorRoute, } from './transport.js';
|
|
6
|
-
import { DECIMAL, roomVersion } from './version.js';
|
|
6
|
+
import { DECIMAL, logPosition, presented, roomVersion } from './version.js';
|
|
7
7
|
function turnOperation(frame) {
|
|
8
8
|
const { type: _type, conversation_id: _conversation, turn_id: _turn, ...operation } = frame;
|
|
9
9
|
return structuredClone(operation);
|
|
10
10
|
}
|
|
11
11
|
async function houseAgents(transport) {
|
|
12
|
-
const answer = await transport.door(houseDoorRoute('agents/
|
|
12
|
+
const answer = await transport.door(houseDoorRoute('agents/list'), {});
|
|
13
13
|
const agents = answer.status === 200 ? answer.body?.agents : null;
|
|
14
14
|
if (!Array.isArray(agents))
|
|
15
15
|
return null;
|
|
@@ -51,52 +51,64 @@ function* changed(tracked, entries, version, schemas) {
|
|
|
51
51
|
if (entry.path === tracked.schema)
|
|
52
52
|
schemas.set(entry.path, entry);
|
|
53
53
|
forgotten(answer, entry.path);
|
|
54
|
+
if (entry.space !== undefined) {
|
|
55
|
+
answer.removals.add(entry.path);
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
54
58
|
if (entry.kind === 'removed') {
|
|
55
59
|
answer.removals.add(entry.path);
|
|
56
60
|
continue;
|
|
57
61
|
}
|
|
58
62
|
const binary = binaryFileOf(entry);
|
|
59
|
-
|
|
60
|
-
if (binary !== undefined) {
|
|
61
|
-
if (binary !== null)
|
|
62
|
-
answer.binaryFiles.set(entry.path, binary);
|
|
63
|
-
}
|
|
64
|
-
else if (outline !== undefined && outline !== null)
|
|
65
|
-
answer.outlines.set(entry.path, outline);
|
|
66
|
-
else
|
|
63
|
+
if (binary === undefined)
|
|
67
64
|
answer.documents.set(entry.path, entry.text ?? '');
|
|
68
|
-
|
|
65
|
+
else if (binary !== null)
|
|
66
|
+
answer.binaryFiles.set(entry.path, binary);
|
|
67
|
+
if (binary === undefined && entry.facts !== undefined)
|
|
68
|
+
answer.facts.set(entry.path, entry.facts);
|
|
69
|
+
const revision = entry.revision ?? binary?.sha256;
|
|
69
70
|
if (revision !== undefined)
|
|
70
71
|
revised(answer, entry.path, revision);
|
|
71
72
|
const head = headChange(entry);
|
|
72
73
|
if (head)
|
|
73
74
|
answer.changes.set(entry.path, head);
|
|
75
|
+
const created = createdOf(entry);
|
|
76
|
+
if (created)
|
|
77
|
+
answer.created.set(entry.path, created);
|
|
74
78
|
}
|
|
75
79
|
return { kind: 'net-advancement', roomVersion: version, ...(yield* answered(answer)) };
|
|
76
80
|
}
|
|
77
|
-
async function changePage(tracked, entries, version, mode) {
|
|
81
|
+
async function changePage(tracked, entries, version, mode, spaces, whole) {
|
|
78
82
|
const schemas = new Map();
|
|
79
83
|
const page = await stepped(changed(tracked, entries, version, schemas));
|
|
80
|
-
const models = await streamedModels(schemas, tracked, mode);
|
|
84
|
+
const models = await streamedModels(schemas, tracked, mode, spaces, whole);
|
|
81
85
|
return models === undefined ? page : { ...page, models };
|
|
82
86
|
}
|
|
83
|
-
export function houseNotifications(transport, mode, discovering) {
|
|
87
|
+
export function houseNotifications(transport, mode, discovering, spaces) {
|
|
84
88
|
const stream = transport.stream;
|
|
85
89
|
const staged = new Map();
|
|
86
90
|
let socket = null;
|
|
87
91
|
const tracking = new Map();
|
|
88
92
|
const observers = new Set();
|
|
93
|
+
const replaying = new Map();
|
|
89
94
|
const conversationObservers = new Set();
|
|
90
95
|
const modeObservers = new Set();
|
|
91
96
|
let replicated = [];
|
|
92
97
|
let listedCursor = null;
|
|
98
|
+
const unanswered = [];
|
|
99
|
+
const heldAtZero = new Set();
|
|
93
100
|
const live = new Set();
|
|
94
101
|
let opening = null;
|
|
95
102
|
let announced = null;
|
|
96
103
|
const runtime = crypto.randomUUID();
|
|
97
104
|
function emit(event) {
|
|
98
|
-
for (const observer of observers)
|
|
99
|
-
observer
|
|
105
|
+
for (const observer of observers) {
|
|
106
|
+
const held = replaying.get(observer);
|
|
107
|
+
if (held === undefined)
|
|
108
|
+
observer(event);
|
|
109
|
+
else
|
|
110
|
+
held.push(event);
|
|
111
|
+
}
|
|
100
112
|
}
|
|
101
113
|
function emitConversation(event) {
|
|
102
114
|
if (event.kind === 'turn' ||
|
|
@@ -118,6 +130,8 @@ export function houseNotifications(transport, mode, discovering) {
|
|
|
118
130
|
announced = null;
|
|
119
131
|
socket = next;
|
|
120
132
|
staged.clear();
|
|
133
|
+
unanswered.length = 0;
|
|
134
|
+
heldAtZero.clear();
|
|
121
135
|
const gapped = new Set([...replicated, ...live]);
|
|
122
136
|
live.clear();
|
|
123
137
|
for (const conversation of gapped)
|
|
@@ -219,6 +233,7 @@ export function houseNotifications(transport, mode, discovering) {
|
|
|
219
233
|
}
|
|
220
234
|
}
|
|
221
235
|
const next = held ?? { authority: frame.authority, parts: 0, entries: [] };
|
|
236
|
+
keptSpaceSchemas(frame.entries, spaces);
|
|
222
237
|
next.entries.push(...frame.entries);
|
|
223
238
|
next.parts += 1;
|
|
224
239
|
staged.set(frame.carry, next);
|
|
@@ -246,9 +261,13 @@ export function houseNotifications(transport, mode, discovering) {
|
|
|
246
261
|
return;
|
|
247
262
|
}
|
|
248
263
|
if (frame.type === 'caught_up') {
|
|
264
|
+
discovering.expired?.(frame.expired);
|
|
249
265
|
emit({
|
|
250
266
|
kind: 'caught-up',
|
|
251
|
-
expired:
|
|
267
|
+
expired: [
|
|
268
|
+
...frame.expired.flatMap((authority) => (tracking.get(authority) ?? []).map((tracked) => tracked.locator)),
|
|
269
|
+
...(unanswered.shift() ?? []),
|
|
270
|
+
],
|
|
252
271
|
});
|
|
253
272
|
return;
|
|
254
273
|
}
|
|
@@ -299,7 +318,9 @@ export function houseNotifications(transport, mode, discovering) {
|
|
|
299
318
|
const after = position(frame.after);
|
|
300
319
|
if (at === null || after === null || after >= at)
|
|
301
320
|
return;
|
|
302
|
-
const from =
|
|
321
|
+
const from = after === 0n && !heldAtZero.has(frame.authority)
|
|
322
|
+
? null
|
|
323
|
+
: roomVersion({ position: frame.after, logEpoch: frame.log_epoch });
|
|
303
324
|
const version = roomVersion({ position: frame.position, logEpoch: frame.log_epoch });
|
|
304
325
|
for (const tracked of tracking.get(frame.authority) ?? []) {
|
|
305
326
|
emit({
|
|
@@ -307,7 +328,7 @@ export function houseNotifications(transport, mode, discovering) {
|
|
|
307
328
|
locator: tracked.locator,
|
|
308
329
|
from,
|
|
309
330
|
roomVersion: version,
|
|
310
|
-
read: () => changePage(tracked, entries, version, mode),
|
|
331
|
+
read: () => changePage(tracked, entries, version, mode, spaces, from === null),
|
|
311
332
|
});
|
|
312
333
|
}
|
|
313
334
|
}
|
|
@@ -318,6 +339,8 @@ export function houseNotifications(transport, mode, discovering) {
|
|
|
318
339
|
announced = null;
|
|
319
340
|
socket = null;
|
|
320
341
|
staged.clear();
|
|
342
|
+
unanswered.length = 0;
|
|
343
|
+
heldAtZero.clear();
|
|
321
344
|
emit({ kind: 'closed', revoked, lost, authorityChanged });
|
|
322
345
|
});
|
|
323
346
|
return {
|
|
@@ -352,11 +375,15 @@ export function houseNotifications(transport, mode, discovering) {
|
|
|
352
375
|
},
|
|
353
376
|
observe(notify) {
|
|
354
377
|
observers.add(notify);
|
|
355
|
-
|
|
356
|
-
|
|
378
|
+
if (opening !== null) {
|
|
379
|
+
const replayed = [{ kind: 'opened' }];
|
|
380
|
+
if (announced !== null)
|
|
381
|
+
replayed.push(announced);
|
|
382
|
+
replaying.set(notify, replayed);
|
|
357
383
|
queueMicrotask(() => {
|
|
384
|
+
replaying.delete(notify);
|
|
358
385
|
for (const event of replayed)
|
|
359
|
-
if (
|
|
386
|
+
if (observers.has(notify))
|
|
360
387
|
notify(event);
|
|
361
388
|
});
|
|
362
389
|
}
|
|
@@ -367,7 +394,47 @@ export function houseNotifications(transport, mode, discovering) {
|
|
|
367
394
|
send(rooms) {
|
|
368
395
|
opening = null;
|
|
369
396
|
announced = null;
|
|
370
|
-
socket
|
|
397
|
+
if (socket === null)
|
|
398
|
+
return;
|
|
399
|
+
const entries = new Map([...tracking.values()].flat().map((tracked) => [tracked.locator, tracked]));
|
|
400
|
+
const named = rooms.flatMap((room) => {
|
|
401
|
+
const entry = entries.get(room.locator);
|
|
402
|
+
const at = room.roomVersion === null ? null : logPosition(room.roomVersion);
|
|
403
|
+
return entry === undefined || at === null ? [] : [{ entry, at }];
|
|
404
|
+
});
|
|
405
|
+
const unheld = rooms.flatMap((room) => {
|
|
406
|
+
const entry = entries.get(room.locator);
|
|
407
|
+
return entry === undefined || room.roomVersion !== null ? [] : [entry];
|
|
408
|
+
});
|
|
409
|
+
for (const { entry, at } of named) {
|
|
410
|
+
if (at.position === '0')
|
|
411
|
+
heldAtZero.add(entry.authority);
|
|
412
|
+
else
|
|
413
|
+
heldAtZero.delete(entry.authority);
|
|
414
|
+
}
|
|
415
|
+
for (const entry of unheld)
|
|
416
|
+
heldAtZero.delete(entry.authority);
|
|
417
|
+
const site = mode === 'site';
|
|
418
|
+
unanswered.push(site ? unheld.map((entry) => entry.locator) : []);
|
|
419
|
+
socket.hold([
|
|
420
|
+
...named.map(({ entry, at }) => presented(entry.authority, at)),
|
|
421
|
+
...(site ? [] : unheld).map((entry) => presented(entry.authority, { position: '0', logEpoch: entry.logEpoch })),
|
|
422
|
+
], runtime, listedCursor);
|
|
423
|
+
if (site)
|
|
424
|
+
return;
|
|
425
|
+
const made = unheld.filter((entry) => entry.position === '0');
|
|
426
|
+
queueMicrotask(() => {
|
|
427
|
+
for (const entry of made) {
|
|
428
|
+
const version = roomVersion(entry);
|
|
429
|
+
emit({
|
|
430
|
+
kind: 'room-change',
|
|
431
|
+
locator: entry.locator,
|
|
432
|
+
from: null,
|
|
433
|
+
roomVersion: version,
|
|
434
|
+
read: () => changePage(entry, [], version, mode, spaces, true),
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
});
|
|
371
438
|
},
|
|
372
439
|
track(entries) {
|
|
373
440
|
tracking.clear();
|
package/dist/transport.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type { ConversationEvent, TurnOperation } from '@agentshouse/mdruntime';
|
|
1
|
+
import type { ConversationEvent, SavedFacts, TurnOperation } from '@agentshouse/mdruntime';
|
|
2
2
|
export declare const HOUSE_RUNTIME_READS: {
|
|
3
|
-
readonly acts: readonly ['account/push', 'agents/
|
|
3
|
+
readonly acts: readonly ['account/push/set', 'agents/list', 'apps/features/set', 'apps/source/download', 'apps/source/top/read', 'conversations/history/list', 'files/attach', 'files/batch', 'files/batch-upload', 'files/finish', 'files/read', 'files/revisions/list', 'room-chunks/list', 'rooms/discover', 'rooms/search', 'sites/screenshot/read'];
|
|
4
4
|
readonly frames: readonly ['app-message', 'authority_changed', 'carried', 'caught_up', 'commands', 'conversation', 'conversation_deleted', 'conversations', 'deliveries', 'deployment', 'held', 'interactions', 'link', 'message', 'opening', 'options', 'part', 'process', 'received', 'signal', 'site', 'starting', 'subagents', 'tab-icon', 'turn'];
|
|
5
5
|
};
|
|
6
6
|
export type HouseRuntimeAct = (typeof HOUSE_RUNTIME_READS.acts)[number];
|
|
7
7
|
export type HouseRuntimeFrame = (typeof HOUSE_RUNTIME_READS.frames)[number];
|
|
8
8
|
export declare function houseDoorRoute(act: HouseRuntimeAct): string;
|
|
9
|
-
export declare function houseSiteRoute(act:
|
|
10
|
-
export declare const
|
|
9
|
+
export declare function houseSiteRoute(act: 'chunks' | 'discover'): string;
|
|
10
|
+
export declare const SITES_SUBMISSIONS_CREATE = "sites/submissions/create";
|
|
11
11
|
export declare const SITE_DOOR_SUBMIT = "/_house/door/submit";
|
|
12
12
|
export type HouseMode = 'credential' | 'site';
|
|
13
13
|
export type HouseDoorAnswer = {
|
|
@@ -33,7 +33,6 @@ export type HouseStreamEntry = {
|
|
|
33
33
|
revision?: string;
|
|
34
34
|
sha256?: string;
|
|
35
35
|
text?: string;
|
|
36
|
-
outline?: unknown;
|
|
37
36
|
bytes?: number;
|
|
38
37
|
media_type?: string;
|
|
39
38
|
author?: {
|
|
@@ -43,7 +42,10 @@ export type HouseStreamEntry = {
|
|
|
43
42
|
site: string;
|
|
44
43
|
name: string;
|
|
45
44
|
};
|
|
45
|
+
changed_at?: string;
|
|
46
46
|
created_at?: string;
|
|
47
|
+
facts?: SavedFacts;
|
|
48
|
+
space?: string;
|
|
47
49
|
};
|
|
48
50
|
type LiveFact<K extends ConversationEvent['kind']> = Extract<ConversationEvent, {
|
|
49
51
|
kind: K;
|
|
@@ -172,15 +174,11 @@ export type HouseStream = {
|
|
|
172
174
|
opened(notify: (opening: HouseOpening) => void): () => void;
|
|
173
175
|
closed(notify: (closing: HouseClosing) => void): () => void;
|
|
174
176
|
};
|
|
175
|
-
export type HouseStreamed = HouseDoorAnswer & {
|
|
176
|
-
room: ReadableStream<Uint8Array> | null;
|
|
177
|
-
};
|
|
178
177
|
export type HouseDoor = {
|
|
179
178
|
door(route: string, body: unknown): Promise<HouseDoorAnswer>;
|
|
180
179
|
stream: HouseStream;
|
|
181
180
|
};
|
|
182
181
|
export type HouseTransport = HouseDoor & {
|
|
183
|
-
streamed(route: string, body: unknown, signal: AbortSignal): Promise<HouseStreamed>;
|
|
184
182
|
transfer(request: HouseByteTransfer): Promise<HouseDoorAnswer>;
|
|
185
183
|
put(url: string, body: Blob, headers: Readonly<Record<string, string>>): Promise<number>;
|
|
186
184
|
download(url: string): Promise<HouseBytesAnswer>;
|
|
@@ -188,7 +186,6 @@ export type HouseTransport = HouseDoor & {
|
|
|
188
186
|
export type HouseSiteTransport = HouseDoor & {
|
|
189
187
|
online(): boolean;
|
|
190
188
|
read(route: string): Promise<HouseDoorAnswer>;
|
|
191
|
-
streamed(route: string, signal: AbortSignal): Promise<HouseStreamed>;
|
|
192
189
|
download(route: string): Promise<HouseBytesAnswer>;
|
|
193
190
|
};
|
|
194
191
|
export {};
|
package/dist/transport.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE3F,eAAO,MAAM,mBAAmB;aAC9B,IAAI,YACF,kBAAkB,EAClB,aAAa,EACb,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACtB,4BAA4B,EAC5B,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,YAAY,EACZ,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,uBAAuB;aAEzB,MAAM,YACJ,aAAa,EACb,mBAAmB,EACnB,SAAS,EACT,WAAW,EACX,UAAU,EACV,cAAc,EACd,sBAAsB,EACtB,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,MAAM,EACN,cAAc,EACd,MAAM,EACN,SAAS,EACT,SAAS,EACT,SAAS,EACT,MAAM,EACN,SAAS,EACT,UAAU,EACV,QAAQ,EACR,MAAM,EACN,UAAU,EACV,WAAW,EACX,UAAU,EACV,MAAM;CAEA,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;AAExE,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5E,wBAAgB,cAAc,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CAE3D;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,QAAQ,GAAG,UAAU,GA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,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACpD,CAAC"}
|
package/dist/transport.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
export const HOUSE_RUNTIME_READS = {
|
|
2
2
|
acts: [
|
|
3
|
-
'account/push',
|
|
4
|
-
'agents/
|
|
3
|
+
'account/push/set',
|
|
4
|
+
'agents/list',
|
|
5
5
|
'apps/features/set',
|
|
6
6
|
'apps/source/download',
|
|
7
|
-
'apps/source/top',
|
|
8
|
-
'
|
|
9
|
-
'batch-upload',
|
|
10
|
-
'bootstrap',
|
|
11
|
-
'conversations/history',
|
|
12
|
-
'discover',
|
|
7
|
+
'apps/source/top/read',
|
|
8
|
+
'conversations/history/list',
|
|
13
9
|
'files/attach',
|
|
10
|
+
'files/batch',
|
|
11
|
+
'files/batch-upload',
|
|
14
12
|
'files/finish',
|
|
15
|
-
'files/
|
|
16
|
-
'revisions',
|
|
17
|
-
'
|
|
13
|
+
'files/read',
|
|
14
|
+
'files/revisions/list',
|
|
15
|
+
'room-chunks/list',
|
|
16
|
+
'rooms/discover',
|
|
17
|
+
'rooms/search',
|
|
18
18
|
'sites/screenshot/read',
|
|
19
19
|
],
|
|
20
20
|
frames: [
|
|
@@ -51,6 +51,6 @@ export function houseDoorRoute(act) {
|
|
|
51
51
|
export function houseSiteRoute(act) {
|
|
52
52
|
return `/_house/door/${act}`;
|
|
53
53
|
}
|
|
54
|
-
export const
|
|
54
|
+
export const SITES_SUBMISSIONS_CREATE = 'sites/submissions/create';
|
|
55
55
|
export const SITE_DOOR_SUBMIT = '/_house/door/submit';
|
|
56
56
|
export const SITE_FILES = '/_house/files/';
|
package/dist/write.js
CHANGED
|
@@ -230,7 +230,7 @@ function* acceptedOf(at, contents) {
|
|
|
230
230
|
answer.changes.set(entry.path, entry.head);
|
|
231
231
|
}
|
|
232
232
|
const unbinaried = answer.binaryFiles.size === 0;
|
|
233
|
-
const { binaryFiles, ...room } = yield* answered(answer);
|
|
233
|
+
const { binaryFiles, facts: _facts, ...room } = yield* answered(answer);
|
|
234
234
|
return { roomVersion: roomVersion(at), ...room, ...(unbinaried ? {} : { binaryFiles }) };
|
|
235
235
|
}
|
|
236
236
|
function* movedOutcome(held, move) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentshouse/mdruntime-adapter",
|
|
3
|
-
"version": "0.1.0-
|
|
3
|
+
"version": "0.1.0-c0a3a92c6ef52",
|
|
4
4
|
"description": "Agents House Adapter for the MD Runtime",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"LICENSE"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@agentshouse/mdruntime": "0.1.0-
|
|
27
|
+
"@agentshouse/mdruntime": "0.1.0-c3a5b012b4a8c"
|
|
28
28
|
},
|
|
29
29
|
"repository": {
|
|
30
30
|
"type": "git",
|
package/dist/part.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export type RoomFrame = {
|
|
2
|
-
readonly kind: 'frame';
|
|
3
|
-
readonly payload: Uint8Array<ArrayBuffer>;
|
|
4
|
-
readonly bytes: number;
|
|
5
|
-
} | {
|
|
6
|
-
readonly kind: 'ended';
|
|
7
|
-
} | {
|
|
8
|
-
readonly kind: 'broken';
|
|
9
|
-
};
|
|
10
|
-
export type RoomFrames = () => Promise<RoomFrame>;
|
|
11
|
-
export declare function checkedPayload(frame: Uint8Array<ArrayBuffer>): Promise<Uint8Array<ArrayBuffer> | null>;
|
|
12
|
-
export declare function roomFrames(room: ReadableStream<Uint8Array>, arrived?: (bytes: number) => void, signal?: AbortSignal): RoomFrames;
|
|
13
|
-
export declare function gunzipped(payload: Uint8Array<ArrayBuffer>): ReadableStream<string>;
|
|
14
|
-
//# sourceMappingURL=part.d.ts.map
|
package/dist/part.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"part.d.ts","sourceRoot":"","sources":["../src/part.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,SAAS,GACjB;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC7F;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAC1B;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC;AAEhC,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,CAAC;AAQlD,wBAAsB,cAAc,CAClC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,GAC7B,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,CASzC;AAED,wBAAgB,UAAU,CACxB,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,EAChC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,EACjC,MAAM,CAAC,EAAE,WAAW,GACnB,UAAU,CAwDZ;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,cAAc,CAAC,MAAM,CAAC,CAKlF"}
|
package/dist/part.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
const PART_MAGIC = 0x48505431;
|
|
2
|
-
const PART_HEAD_BYTES = 8;
|
|
3
|
-
const PART_DIGEST_BYTES = 32;
|
|
4
|
-
function hex(bytes) {
|
|
5
|
-
let text = '';
|
|
6
|
-
for (const byte of bytes)
|
|
7
|
-
text += byte.toString(16).padStart(2, '0');
|
|
8
|
-
return text;
|
|
9
|
-
}
|
|
10
|
-
export async function checkedPayload(frame) {
|
|
11
|
-
if (frame.length < PART_HEAD_BYTES + PART_DIGEST_BYTES)
|
|
12
|
-
return null;
|
|
13
|
-
const view = new DataView(frame.buffer, frame.byteOffset, frame.byteLength);
|
|
14
|
-
if (view.getUint32(0) !== PART_MAGIC)
|
|
15
|
-
return null;
|
|
16
|
-
const length = view.getUint32(4);
|
|
17
|
-
if (PART_HEAD_BYTES + length + PART_DIGEST_BYTES !== frame.length)
|
|
18
|
-
return null;
|
|
19
|
-
const payload = frame.subarray(PART_HEAD_BYTES, PART_HEAD_BYTES + length);
|
|
20
|
-
const digest = hex(new Uint8Array(await crypto.subtle.digest('SHA-256', payload)));
|
|
21
|
-
return hex(frame.subarray(PART_HEAD_BYTES + length)) === digest ? payload : null;
|
|
22
|
-
}
|
|
23
|
-
export function roomFrames(room, arrived, signal) {
|
|
24
|
-
const reader = room.getReader();
|
|
25
|
-
signal?.addEventListener('abort', () => void reader.cancel().catch(() => { }), { once: true });
|
|
26
|
-
const chunks = [];
|
|
27
|
-
let held = 0;
|
|
28
|
-
let received = 0;
|
|
29
|
-
let ended = false;
|
|
30
|
-
async function filled(bytes) {
|
|
31
|
-
while (held < bytes && !ended) {
|
|
32
|
-
const read = await reader.read();
|
|
33
|
-
if (read.done) {
|
|
34
|
-
ended = true;
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
chunks.push(read.value);
|
|
38
|
-
held += read.value.byteLength;
|
|
39
|
-
received += read.value.byteLength;
|
|
40
|
-
arrived?.(received);
|
|
41
|
-
}
|
|
42
|
-
return held >= bytes;
|
|
43
|
-
}
|
|
44
|
-
function taken(bytes) {
|
|
45
|
-
const out = new Uint8Array(bytes);
|
|
46
|
-
let at = 0;
|
|
47
|
-
while (at < bytes) {
|
|
48
|
-
const chunk = chunks[0];
|
|
49
|
-
const used = Math.min(chunk.byteLength, bytes - at);
|
|
50
|
-
out.set(chunk.subarray(0, used), at);
|
|
51
|
-
at += used;
|
|
52
|
-
if (used === chunk.byteLength)
|
|
53
|
-
chunks.shift();
|
|
54
|
-
else
|
|
55
|
-
chunks[0] = chunk.subarray(used);
|
|
56
|
-
}
|
|
57
|
-
held -= bytes;
|
|
58
|
-
return out;
|
|
59
|
-
}
|
|
60
|
-
return async () => {
|
|
61
|
-
try {
|
|
62
|
-
if (!(await filled(PART_HEAD_BYTES)))
|
|
63
|
-
return held === 0 ? { kind: 'ended' } : { kind: 'broken' };
|
|
64
|
-
const head = taken(PART_HEAD_BYTES);
|
|
65
|
-
const view = new DataView(head.buffer);
|
|
66
|
-
if (view.getUint32(0) !== PART_MAGIC)
|
|
67
|
-
return { kind: 'broken' };
|
|
68
|
-
const length = view.getUint32(4);
|
|
69
|
-
const rest = length + PART_DIGEST_BYTES;
|
|
70
|
-
if (!(await filled(rest)))
|
|
71
|
-
return { kind: 'broken' };
|
|
72
|
-
const frame = new Uint8Array(PART_HEAD_BYTES + rest);
|
|
73
|
-
frame.set(head, 0);
|
|
74
|
-
frame.set(taken(rest), PART_HEAD_BYTES);
|
|
75
|
-
const payload = await checkedPayload(frame);
|
|
76
|
-
return payload === null
|
|
77
|
-
? { kind: 'broken' }
|
|
78
|
-
: { kind: 'frame', payload, bytes: frame.byteLength };
|
|
79
|
-
}
|
|
80
|
-
catch {
|
|
81
|
-
return { kind: 'broken' };
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
export function gunzipped(payload) {
|
|
86
|
-
return new Blob([payload])
|
|
87
|
-
.stream()
|
|
88
|
-
.pipeThrough(new DecompressionStream('gzip'))
|
|
89
|
-
.pipeThrough(new TextDecoderStream());
|
|
90
|
-
}
|
package/dist/room-stream.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { BootstrapResult, RoomModels } from '@agentshouse/mdruntime';
|
|
2
|
-
import type { TrackedAuthority } from './discovery.js';
|
|
3
|
-
import { type HouseScope } from './read.js';
|
|
4
|
-
import type { HouseMode } from './transport.js';
|
|
5
|
-
export type StreamedPart = {
|
|
6
|
-
readonly scope: HouseScope;
|
|
7
|
-
readonly first: boolean;
|
|
8
|
-
readonly ended: boolean;
|
|
9
|
-
readonly models: RoomModels | undefined;
|
|
10
|
-
readonly pageToken: string | undefined;
|
|
11
|
-
readonly bytes: number;
|
|
12
|
-
};
|
|
13
|
-
export declare function roomStreams(mode: HouseMode): {
|
|
14
|
-
head: (entry: TrackedAuthority, room: ReadableStream<Uint8Array>, arriving: ((bytes: number) => void) | undefined, signal: AbortSignal | undefined) => Promise<BootstrapResult>;
|
|
15
|
-
part: (entry: TrackedAuthority, token: string) => Promise<StreamedPart | Exclude<BootstrapResult, {
|
|
16
|
-
kind: 'bootstrap';
|
|
17
|
-
}>>;
|
|
18
|
-
named: (entry: TrackedAuthority, room: ReadableStream<Uint8Array>, signal: AbortSignal | undefined) => Promise<BootstrapResult>;
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=room-stream.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"room-stream.d.ts","sourceRoot":"","sources":["../src/room-stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAE1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGvD,OAAO,EAML,KAAK,UAAU,EAChB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAYhD,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,SAAS,CAAC;IACxC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS;kBAKhC,gBAAgB,QACjB,cAAc,CAAC,UAAU,CAAC,YACtB,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,UACvC,WAAW,GAAG,SAAS,KAC9B,OAAO,CAAC,eAAe,CAAC;kBAelB,gBAAgB,SAChB,MAAM,KACZ,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC,eAAe,EAAE;QAAE,IAAI,EAAE,WAAW,CAAA;KAAE,CAAC,CAAC;mBAkCjE,gBAAgB,QACjB,cAAc,CAAC,UAAU,CAAC,UACxB,WAAW,GAAG,SAAS,KAC9B,OAAO,CAAC,eAAe,CAAC;EAmB5B"}
|
package/dist/room-stream.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { stepped } from '@agentshouse/mdruntime';
|
|
2
|
-
import { manifestedModels, partModels } from './model.js';
|
|
3
|
-
import { roomFrames } from './part.js';
|
|
4
|
-
import { bootstrapping, housePart, manifested, roomHead, } from './read.js';
|
|
5
|
-
const UNCERTAIN = { kind: 'transport-uncertainty' };
|
|
6
|
-
export function roomStreams(mode) {
|
|
7
|
-
const open = new Map();
|
|
8
|
-
let opened = 0;
|
|
9
|
-
async function head(entry, room, arriving, signal) {
|
|
10
|
-
const frames = roomFrames(room, arriving, signal);
|
|
11
|
-
const first = await frames();
|
|
12
|
-
if (first.kind !== 'frame')
|
|
13
|
-
return UNCERTAIN;
|
|
14
|
-
const held = await roomHead(first.payload, mode);
|
|
15
|
-
if (held === null || held.anchor !== entry.authority)
|
|
16
|
-
return UNCERTAIN;
|
|
17
|
-
const { models, seen } = await manifestedModels(held, entry);
|
|
18
|
-
opened += 1;
|
|
19
|
-
const id = String(opened);
|
|
20
|
-
open.set(id, { entry, head: held, frames, next: 1, seen });
|
|
21
|
-
signal?.addEventListener('abort', () => open.delete(id), { once: true });
|
|
22
|
-
return { ...manifested(held, `${id}:1`, models), bytes: first.bytes };
|
|
23
|
-
}
|
|
24
|
-
async function part(entry, token) {
|
|
25
|
-
const [id = '', at = ''] = token.split(':');
|
|
26
|
-
const room = open.get(id);
|
|
27
|
-
if (room === undefined || room.entry.locator !== entry.locator || String(room.next) !== at)
|
|
28
|
-
return UNCERTAIN;
|
|
29
|
-
const frame = await room.frames();
|
|
30
|
-
if (frame.kind !== 'frame') {
|
|
31
|
-
open.delete(id);
|
|
32
|
-
return UNCERTAIN;
|
|
33
|
-
}
|
|
34
|
-
const read = await housePart(room.head, frame.payload, mode);
|
|
35
|
-
if ('kind' in read) {
|
|
36
|
-
open.delete(id);
|
|
37
|
-
return read;
|
|
38
|
-
}
|
|
39
|
-
const { scope, ended } = read;
|
|
40
|
-
const first = room.next === 1;
|
|
41
|
-
room.next += 1;
|
|
42
|
-
room.seen = [
|
|
43
|
-
...room.seen,
|
|
44
|
-
...(scope.files.some((file) => file.path === entry.schema) ? [entry.schema] : []),
|
|
45
|
-
];
|
|
46
|
-
if (ended)
|
|
47
|
-
open.delete(id);
|
|
48
|
-
return {
|
|
49
|
-
scope,
|
|
50
|
-
first,
|
|
51
|
-
ended,
|
|
52
|
-
models: await partModels(scope, entry, new Set(room.seen), ended),
|
|
53
|
-
pageToken: ended ? undefined : `${id}:${room.next}`,
|
|
54
|
-
bytes: frame.bytes,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
async function named(entry, room, signal) {
|
|
58
|
-
const opened = await head(entry, room, undefined, signal);
|
|
59
|
-
if (opened.kind !== 'bootstrap')
|
|
60
|
-
return opened;
|
|
61
|
-
const files = [];
|
|
62
|
-
const contents = [];
|
|
63
|
-
let last = null;
|
|
64
|
-
for (let token = opened.pageToken; token !== undefined;) {
|
|
65
|
-
const read = await part(entry, token);
|
|
66
|
-
if ('kind' in read)
|
|
67
|
-
return read;
|
|
68
|
-
files.push(...read.scope.files);
|
|
69
|
-
contents.push(...read.scope.contents);
|
|
70
|
-
last = read.scope;
|
|
71
|
-
token = read.pageToken;
|
|
72
|
-
}
|
|
73
|
-
if (last === null)
|
|
74
|
-
return UNCERTAIN;
|
|
75
|
-
return stepped(bootstrapping({ ...last, files, contents }));
|
|
76
|
-
}
|
|
77
|
-
return { head, part, named };
|
|
78
|
-
}
|