@agentshouse/mdruntime-adapter 0.1.0-cd0511bd2d033 → 0.1.0-cd0b0339c1003
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 +2 -0
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +10 -0
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +68 -76
- 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 +70 -107
- package/dist/house-model.d.ts.map +1 -1
- package/dist/house-model.js +59 -56
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +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 +11 -9
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +36 -144
- package/dist/room-types.d.ts +0 -2
- package/dist/room-types.d.ts.map +1 -1
- package/dist/room-types.js +2 -7
- package/dist/search.js +1 -1
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +31 -41
- 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 +86 -16
- package/dist/transport.d.ts +5 -8
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +12 -12
- 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 -19
- package/dist/room-stream.d.ts.map +0 -1
- package/dist/room-stream.js +0 -57
package/dist/stream.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { type AuthorityChange, type Discovery, type ConversationStream, type RoomStreamEvent, type ServiceModeSignal } from '@agentshouse/mdruntime';
|
|
1
|
+
import { type AuthorityChange, type Discovery, type ConversationStream, type HeldRoom, type RoomStreamEvent, type ServiceModeSignal } from '@agentshouse/mdruntime';
|
|
2
2
|
import type { TrackedAuthority } from './discovery.js';
|
|
3
|
-
import
|
|
3
|
+
import type { SpaceSchemas } from './space-schema.js';
|
|
4
|
+
import { type HouseDoor, type HouseMode, type HouseStreamFrame } from './transport.js';
|
|
4
5
|
export type HouseOpeningFrame = Extract<HouseStreamFrame, {
|
|
5
6
|
type: 'opening';
|
|
6
7
|
}>;
|
|
@@ -10,14 +11,15 @@ export type HouseAuthorityChangedFrame = Extract<HouseStreamFrame, {
|
|
|
10
11
|
export type HouseDiscovering = {
|
|
11
12
|
opened(frame: HouseOpeningFrame | null): Promise<Discovery | null>;
|
|
12
13
|
changed(frame: HouseAuthorityChangedFrame): AuthorityChange | null;
|
|
14
|
+
expired?(authorities: readonly string[]): void;
|
|
13
15
|
};
|
|
14
16
|
export type HouseNotifications = {
|
|
15
17
|
runtime: string;
|
|
16
18
|
observe(notify: (event: RoomStreamEvent) => void): () => void;
|
|
17
|
-
send(rooms: readonly
|
|
19
|
+
send(rooms: readonly HeldRoom[]): void;
|
|
18
20
|
track(authorities: readonly TrackedAuthority[]): void;
|
|
19
21
|
conversations: ConversationStream;
|
|
20
22
|
serviceMode: ServiceModeSignal;
|
|
21
23
|
};
|
|
22
|
-
export declare function houseNotifications(transport: HouseDoor, mode: HouseMode, discovering: HouseDiscovering): HouseNotifications;
|
|
24
|
+
export declare function houseNotifications(transport: HouseDoor, mode: HouseMode, discovering: HouseDiscovering, spaces: SpaceSchemas): HouseNotifications;
|
|
23
25
|
//# sourceMappingURL=stream.d.ts.map
|
package/dist/stream.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/st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AAQ,EAAE,GAAG,IAAI,CAAC;IACvC,KAAK,CAAC,WAAW,EAAE,SAAS,gBAAgB,EAAE,GAAG,IAAI,CAAC;IACtD,aAAa,EAAE,kBAAkB,CAAC;IAClC,WAAW,EAAE,iBAAiB,CAAC;CAChC,CAAC;AA6FF,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,SAAS,EACf,WAAW,EAAE,gBAAgB,EAC7B,MAAM,EAAE,YAAY,GACnB,kBAAkB,CA8XpB"}
|
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, revised, } from './read.js';
|
|
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,6 +51,10 @@ 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;
|
|
@@ -68,32 +72,43 @@ function* changed(tracked, entries, version, schemas) {
|
|
|
68
72
|
const head = headChange(entry);
|
|
69
73
|
if (head)
|
|
70
74
|
answer.changes.set(entry.path, head);
|
|
75
|
+
const created = createdOf(entry);
|
|
76
|
+
if (created)
|
|
77
|
+
answer.created.set(entry.path, created);
|
|
71
78
|
}
|
|
72
79
|
return { kind: 'net-advancement', roomVersion: version, ...(yield* answered(answer)) };
|
|
73
80
|
}
|
|
74
|
-
async function changePage(tracked, entries, version, mode) {
|
|
81
|
+
async function changePage(tracked, entries, version, mode, spaces, whole) {
|
|
75
82
|
const schemas = new Map();
|
|
76
83
|
const page = await stepped(changed(tracked, entries, version, schemas));
|
|
77
|
-
const models = await streamedModels(schemas, tracked, mode);
|
|
84
|
+
const models = await streamedModels(schemas, tracked, mode, spaces, whole);
|
|
78
85
|
return models === undefined ? page : { ...page, models };
|
|
79
86
|
}
|
|
80
|
-
export function houseNotifications(transport, mode, discovering) {
|
|
87
|
+
export function houseNotifications(transport, mode, discovering, spaces) {
|
|
81
88
|
const stream = transport.stream;
|
|
82
89
|
const staged = new Map();
|
|
83
90
|
let socket = null;
|
|
84
91
|
const tracking = new Map();
|
|
85
92
|
const observers = new Set();
|
|
93
|
+
const replaying = new Map();
|
|
86
94
|
const conversationObservers = new Set();
|
|
87
95
|
const modeObservers = new Set();
|
|
88
96
|
let replicated = [];
|
|
89
97
|
let listedCursor = null;
|
|
98
|
+
const unanswered = [];
|
|
99
|
+
const heldAtZero = new Set();
|
|
90
100
|
const live = new Set();
|
|
91
101
|
let opening = null;
|
|
92
102
|
let announced = null;
|
|
93
103
|
const runtime = crypto.randomUUID();
|
|
94
104
|
function emit(event) {
|
|
95
|
-
for (const observer of observers)
|
|
96
|
-
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
|
+
}
|
|
97
112
|
}
|
|
98
113
|
function emitConversation(event) {
|
|
99
114
|
if (event.kind === 'turn' ||
|
|
@@ -115,6 +130,8 @@ export function houseNotifications(transport, mode, discovering) {
|
|
|
115
130
|
announced = null;
|
|
116
131
|
socket = next;
|
|
117
132
|
staged.clear();
|
|
133
|
+
unanswered.length = 0;
|
|
134
|
+
heldAtZero.clear();
|
|
118
135
|
const gapped = new Set([...replicated, ...live]);
|
|
119
136
|
live.clear();
|
|
120
137
|
for (const conversation of gapped)
|
|
@@ -216,6 +233,7 @@ export function houseNotifications(transport, mode, discovering) {
|
|
|
216
233
|
}
|
|
217
234
|
}
|
|
218
235
|
const next = held ?? { authority: frame.authority, parts: 0, entries: [] };
|
|
236
|
+
keptSpaceSchemas(frame.entries, spaces);
|
|
219
237
|
next.entries.push(...frame.entries);
|
|
220
238
|
next.parts += 1;
|
|
221
239
|
staged.set(frame.carry, next);
|
|
@@ -243,9 +261,13 @@ export function houseNotifications(transport, mode, discovering) {
|
|
|
243
261
|
return;
|
|
244
262
|
}
|
|
245
263
|
if (frame.type === 'caught_up') {
|
|
264
|
+
discovering.expired?.(frame.expired);
|
|
246
265
|
emit({
|
|
247
266
|
kind: 'caught-up',
|
|
248
|
-
expired:
|
|
267
|
+
expired: [
|
|
268
|
+
...frame.expired.flatMap((authority) => (tracking.get(authority) ?? []).map((tracked) => tracked.locator)),
|
|
269
|
+
...(unanswered.shift() ?? []),
|
|
270
|
+
],
|
|
249
271
|
});
|
|
250
272
|
return;
|
|
251
273
|
}
|
|
@@ -296,7 +318,9 @@ export function houseNotifications(transport, mode, discovering) {
|
|
|
296
318
|
const after = position(frame.after);
|
|
297
319
|
if (at === null || after === null || after >= at)
|
|
298
320
|
return;
|
|
299
|
-
const from =
|
|
321
|
+
const from = after === 0n && !heldAtZero.has(frame.authority)
|
|
322
|
+
? null
|
|
323
|
+
: roomVersion({ position: frame.after, logEpoch: frame.log_epoch });
|
|
300
324
|
const version = roomVersion({ position: frame.position, logEpoch: frame.log_epoch });
|
|
301
325
|
for (const tracked of tracking.get(frame.authority) ?? []) {
|
|
302
326
|
emit({
|
|
@@ -304,7 +328,7 @@ export function houseNotifications(transport, mode, discovering) {
|
|
|
304
328
|
locator: tracked.locator,
|
|
305
329
|
from,
|
|
306
330
|
roomVersion: version,
|
|
307
|
-
read: () => changePage(tracked, entries, version, mode),
|
|
331
|
+
read: () => changePage(tracked, entries, version, mode, spaces, from === null),
|
|
308
332
|
});
|
|
309
333
|
}
|
|
310
334
|
}
|
|
@@ -315,6 +339,8 @@ export function houseNotifications(transport, mode, discovering) {
|
|
|
315
339
|
announced = null;
|
|
316
340
|
socket = null;
|
|
317
341
|
staged.clear();
|
|
342
|
+
unanswered.length = 0;
|
|
343
|
+
heldAtZero.clear();
|
|
318
344
|
emit({ kind: 'closed', revoked, lost, authorityChanged });
|
|
319
345
|
});
|
|
320
346
|
return {
|
|
@@ -349,11 +375,15 @@ export function houseNotifications(transport, mode, discovering) {
|
|
|
349
375
|
},
|
|
350
376
|
observe(notify) {
|
|
351
377
|
observers.add(notify);
|
|
352
|
-
|
|
353
|
-
|
|
378
|
+
if (opening !== null) {
|
|
379
|
+
const replayed = [{ kind: 'opened' }];
|
|
380
|
+
if (announced !== null)
|
|
381
|
+
replayed.push(announced);
|
|
382
|
+
replaying.set(notify, replayed);
|
|
354
383
|
queueMicrotask(() => {
|
|
384
|
+
replaying.delete(notify);
|
|
355
385
|
for (const event of replayed)
|
|
356
|
-
if (
|
|
386
|
+
if (observers.has(notify))
|
|
357
387
|
notify(event);
|
|
358
388
|
});
|
|
359
389
|
}
|
|
@@ -364,7 +394,47 @@ export function houseNotifications(transport, mode, discovering) {
|
|
|
364
394
|
send(rooms) {
|
|
365
395
|
opening = null;
|
|
366
396
|
announced = null;
|
|
367
|
-
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
|
+
});
|
|
368
438
|
},
|
|
369
439
|
track(entries) {
|
|
370
440
|
tracking.clear();
|
package/dist/transport.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
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 = {
|
|
@@ -42,8 +42,10 @@ export type HouseStreamEntry = {
|
|
|
42
42
|
site: string;
|
|
43
43
|
name: string;
|
|
44
44
|
};
|
|
45
|
+
changed_at?: string;
|
|
45
46
|
created_at?: string;
|
|
46
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,UAAU,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE3F,eAAO,MAAM,mBAAmB;aAC9B,IAAI,YACF,
|
|
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
'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/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-cd0b0339c1003",
|
|
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-c95f0f04f2113"
|
|
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,19 +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
|
-
};
|
|
19
|
-
//# 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;AAC1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGvD,OAAO,EAAuD,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AACjG,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;EAkC3E"}
|
package/dist/room-stream.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { manifestedModels, partModels } from './model.js';
|
|
2
|
-
import { roomFrames } from './part.js';
|
|
3
|
-
import { housePart, manifested, roomHead } from './read.js';
|
|
4
|
-
const UNCERTAIN = { kind: 'transport-uncertainty' };
|
|
5
|
-
export function roomStreams(mode) {
|
|
6
|
-
const open = new Map();
|
|
7
|
-
let opened = 0;
|
|
8
|
-
async function head(entry, room, arriving, signal) {
|
|
9
|
-
const frames = roomFrames(room, arriving, signal);
|
|
10
|
-
const first = await frames();
|
|
11
|
-
if (first.kind !== 'frame')
|
|
12
|
-
return UNCERTAIN;
|
|
13
|
-
const held = await roomHead(first.payload, mode);
|
|
14
|
-
if (held === null || held.anchor !== entry.authority)
|
|
15
|
-
return UNCERTAIN;
|
|
16
|
-
const { models, seen } = await manifestedModels(held, entry);
|
|
17
|
-
opened += 1;
|
|
18
|
-
const id = String(opened);
|
|
19
|
-
open.set(id, { entry, head: held, frames, next: 1, seen });
|
|
20
|
-
signal?.addEventListener('abort', () => open.delete(id), { once: true });
|
|
21
|
-
return { ...manifested(held, `${id}:1`, models), bytes: first.bytes };
|
|
22
|
-
}
|
|
23
|
-
async function part(entry, token) {
|
|
24
|
-
const [id = '', at = ''] = token.split(':');
|
|
25
|
-
const room = open.get(id);
|
|
26
|
-
if (room === undefined || room.entry.locator !== entry.locator || String(room.next) !== at)
|
|
27
|
-
return UNCERTAIN;
|
|
28
|
-
const frame = await room.frames();
|
|
29
|
-
if (frame.kind !== 'frame') {
|
|
30
|
-
open.delete(id);
|
|
31
|
-
return UNCERTAIN;
|
|
32
|
-
}
|
|
33
|
-
const read = await housePart(room.head, frame.payload, mode);
|
|
34
|
-
if ('kind' in read) {
|
|
35
|
-
open.delete(id);
|
|
36
|
-
return read;
|
|
37
|
-
}
|
|
38
|
-
const { scope, ended } = read;
|
|
39
|
-
const first = room.next === 1;
|
|
40
|
-
room.next += 1;
|
|
41
|
-
room.seen = [
|
|
42
|
-
...room.seen,
|
|
43
|
-
...(scope.files.some((file) => file.path === entry.schema) ? [entry.schema] : []),
|
|
44
|
-
];
|
|
45
|
-
if (ended)
|
|
46
|
-
open.delete(id);
|
|
47
|
-
return {
|
|
48
|
-
scope,
|
|
49
|
-
first,
|
|
50
|
-
ended,
|
|
51
|
-
models: await partModels(scope, entry, new Set(room.seen), ended),
|
|
52
|
-
pageToken: ended ? undefined : `${id}:${room.next}`,
|
|
53
|
-
bytes: frame.bytes,
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
return { head, part };
|
|
57
|
-
}
|