@agentshouse/mdruntime-adapter 0.1.0-cdcec0737ac0e → 0.1.0-cdf75633ae85a
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 +15 -3
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +67 -75
- package/dist/authored-path.d.ts +11 -0
- package/dist/authored-path.d.ts.map +1 -0
- package/dist/authored-path.js +35 -0
- 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 +61 -57
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/model.d.ts +3 -7
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +3 -13
- package/dist/read.d.ts +9 -9
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +24 -143
- package/dist/refusal.d.ts +1 -0
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +4 -0
- package/dist/room-types.d.ts +0 -2
- package/dist/room-types.d.ts.map +1 -1
- package/dist/room-types.js +2 -5
- package/dist/search.js +1 -1
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +30 -40
- package/dist/stream.d.ts +4 -3
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +83 -14
- package/dist/transport.d.ts +4 -8
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +12 -12
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +3 -5
- 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 -57
package/dist/stream.js
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { ROW_WEIGHT, stepped, } from '@agentshouse/mdruntime';
|
|
2
2
|
import { acceptedMessage, cursorPosition, houseHistory } from './history.js';
|
|
3
3
|
import { keptSpaceSchemas, streamedModels } from './model.js';
|
|
4
|
-
import { answered, answering, binaryFileOf, folded, forgotten, headChange, revised, } from './read.js';
|
|
4
|
+
import { answered, answering, binaryFileOf, createdOf, folded, forgotten, headChange, revised, } from './read.js';
|
|
5
|
+
import { classifyDoor } from './refusal.js';
|
|
5
6
|
import { houseDoorRoute, } from './transport.js';
|
|
6
|
-
import { DECIMAL, roomVersion } from './version.js';
|
|
7
|
+
import { DECIMAL, logPosition, presented, roomVersion } from './version.js';
|
|
7
8
|
function turnOperation(frame) {
|
|
8
9
|
const { type: _type, conversation_id: _conversation, turn_id: _turn, ...operation } = frame;
|
|
9
10
|
return structuredClone(operation);
|
|
10
11
|
}
|
|
11
12
|
async function houseAgents(transport) {
|
|
12
|
-
const answer = await transport.door(houseDoorRoute('agents/
|
|
13
|
+
const answer = await transport.door(houseDoorRoute('agents/list'), {});
|
|
14
|
+
if (classifyDoor(answer.status, answer.body, 'agents/list')?.kind === 'transport-uncertainty') {
|
|
15
|
+
throw new Error('agents/list reached no answer');
|
|
16
|
+
}
|
|
13
17
|
const agents = answer.status === 200 ? answer.body?.agents : null;
|
|
14
18
|
if (!Array.isArray(agents))
|
|
15
19
|
return null;
|
|
@@ -72,13 +76,16 @@ function* changed(tracked, entries, version, schemas) {
|
|
|
72
76
|
const head = headChange(entry);
|
|
73
77
|
if (head)
|
|
74
78
|
answer.changes.set(entry.path, head);
|
|
79
|
+
const created = createdOf(entry);
|
|
80
|
+
if (created)
|
|
81
|
+
answer.created.set(entry.path, created);
|
|
75
82
|
}
|
|
76
83
|
return { kind: 'net-advancement', roomVersion: version, ...(yield* answered(answer)) };
|
|
77
84
|
}
|
|
78
|
-
async function changePage(tracked, entries, version, mode, spaces) {
|
|
85
|
+
async function changePage(tracked, entries, version, mode, spaces, whole) {
|
|
79
86
|
const schemas = new Map();
|
|
80
87
|
const page = await stepped(changed(tracked, entries, version, schemas));
|
|
81
|
-
const models = await streamedModels(schemas, tracked, mode, spaces);
|
|
88
|
+
const models = await streamedModels(schemas, tracked, mode, spaces, whole);
|
|
82
89
|
return models === undefined ? page : { ...page, models };
|
|
83
90
|
}
|
|
84
91
|
export function houseNotifications(transport, mode, discovering, spaces) {
|
|
@@ -87,17 +94,25 @@ export function houseNotifications(transport, mode, discovering, spaces) {
|
|
|
87
94
|
let socket = null;
|
|
88
95
|
const tracking = new Map();
|
|
89
96
|
const observers = new Set();
|
|
97
|
+
const replaying = new Map();
|
|
90
98
|
const conversationObservers = new Set();
|
|
91
99
|
const modeObservers = new Set();
|
|
92
100
|
let replicated = [];
|
|
93
101
|
let listedCursor = null;
|
|
102
|
+
const unanswered = [];
|
|
103
|
+
const heldAtZero = new Set();
|
|
94
104
|
const live = new Set();
|
|
95
105
|
let opening = null;
|
|
96
106
|
let announced = null;
|
|
97
107
|
const runtime = crypto.randomUUID();
|
|
98
108
|
function emit(event) {
|
|
99
|
-
for (const observer of observers)
|
|
100
|
-
observer
|
|
109
|
+
for (const observer of observers) {
|
|
110
|
+
const held = replaying.get(observer);
|
|
111
|
+
if (held === undefined)
|
|
112
|
+
observer(event);
|
|
113
|
+
else
|
|
114
|
+
held.push(event);
|
|
115
|
+
}
|
|
101
116
|
}
|
|
102
117
|
function emitConversation(event) {
|
|
103
118
|
if (event.kind === 'turn' ||
|
|
@@ -119,6 +134,8 @@ export function houseNotifications(transport, mode, discovering, spaces) {
|
|
|
119
134
|
announced = null;
|
|
120
135
|
socket = next;
|
|
121
136
|
staged.clear();
|
|
137
|
+
unanswered.length = 0;
|
|
138
|
+
heldAtZero.clear();
|
|
122
139
|
const gapped = new Set([...replicated, ...live]);
|
|
123
140
|
live.clear();
|
|
124
141
|
for (const conversation of gapped)
|
|
@@ -248,9 +265,13 @@ export function houseNotifications(transport, mode, discovering, spaces) {
|
|
|
248
265
|
return;
|
|
249
266
|
}
|
|
250
267
|
if (frame.type === 'caught_up') {
|
|
268
|
+
discovering.expired?.(frame.expired);
|
|
251
269
|
emit({
|
|
252
270
|
kind: 'caught-up',
|
|
253
|
-
expired:
|
|
271
|
+
expired: [
|
|
272
|
+
...frame.expired.flatMap((authority) => (tracking.get(authority) ?? []).map((tracked) => tracked.locator)),
|
|
273
|
+
...(unanswered.shift() ?? []),
|
|
274
|
+
],
|
|
254
275
|
});
|
|
255
276
|
return;
|
|
256
277
|
}
|
|
@@ -301,7 +322,9 @@ export function houseNotifications(transport, mode, discovering, spaces) {
|
|
|
301
322
|
const after = position(frame.after);
|
|
302
323
|
if (at === null || after === null || after >= at)
|
|
303
324
|
return;
|
|
304
|
-
const from =
|
|
325
|
+
const from = after === 0n && !heldAtZero.has(frame.authority)
|
|
326
|
+
? null
|
|
327
|
+
: roomVersion({ position: frame.after, logEpoch: frame.log_epoch });
|
|
305
328
|
const version = roomVersion({ position: frame.position, logEpoch: frame.log_epoch });
|
|
306
329
|
for (const tracked of tracking.get(frame.authority) ?? []) {
|
|
307
330
|
emit({
|
|
@@ -309,7 +332,7 @@ export function houseNotifications(transport, mode, discovering, spaces) {
|
|
|
309
332
|
locator: tracked.locator,
|
|
310
333
|
from,
|
|
311
334
|
roomVersion: version,
|
|
312
|
-
read: () => changePage(tracked, entries, version, mode, spaces),
|
|
335
|
+
read: () => changePage(tracked, entries, version, mode, spaces, from === null),
|
|
313
336
|
});
|
|
314
337
|
}
|
|
315
338
|
}
|
|
@@ -320,6 +343,8 @@ export function houseNotifications(transport, mode, discovering, spaces) {
|
|
|
320
343
|
announced = null;
|
|
321
344
|
socket = null;
|
|
322
345
|
staged.clear();
|
|
346
|
+
unanswered.length = 0;
|
|
347
|
+
heldAtZero.clear();
|
|
323
348
|
emit({ kind: 'closed', revoked, lost, authorityChanged });
|
|
324
349
|
});
|
|
325
350
|
return {
|
|
@@ -354,11 +379,15 @@ export function houseNotifications(transport, mode, discovering, spaces) {
|
|
|
354
379
|
},
|
|
355
380
|
observe(notify) {
|
|
356
381
|
observers.add(notify);
|
|
357
|
-
|
|
358
|
-
|
|
382
|
+
if (opening !== null) {
|
|
383
|
+
const replayed = [{ kind: 'opened' }];
|
|
384
|
+
if (announced !== null)
|
|
385
|
+
replayed.push(announced);
|
|
386
|
+
replaying.set(notify, replayed);
|
|
359
387
|
queueMicrotask(() => {
|
|
388
|
+
replaying.delete(notify);
|
|
360
389
|
for (const event of replayed)
|
|
361
|
-
if (
|
|
390
|
+
if (observers.has(notify))
|
|
362
391
|
notify(event);
|
|
363
392
|
});
|
|
364
393
|
}
|
|
@@ -369,7 +398,47 @@ export function houseNotifications(transport, mode, discovering, spaces) {
|
|
|
369
398
|
send(rooms) {
|
|
370
399
|
opening = null;
|
|
371
400
|
announced = null;
|
|
372
|
-
socket
|
|
401
|
+
if (socket === null)
|
|
402
|
+
return;
|
|
403
|
+
const entries = new Map([...tracking.values()].flat().map((tracked) => [tracked.locator, tracked]));
|
|
404
|
+
const named = rooms.flatMap((room) => {
|
|
405
|
+
const entry = entries.get(room.locator);
|
|
406
|
+
const at = room.roomVersion === null ? null : logPosition(room.roomVersion);
|
|
407
|
+
return entry === undefined || at === null ? [] : [{ entry, at }];
|
|
408
|
+
});
|
|
409
|
+
const unheld = rooms.flatMap((room) => {
|
|
410
|
+
const entry = entries.get(room.locator);
|
|
411
|
+
return entry === undefined || room.roomVersion !== null ? [] : [entry];
|
|
412
|
+
});
|
|
413
|
+
for (const { entry, at } of named) {
|
|
414
|
+
if (at.position === '0')
|
|
415
|
+
heldAtZero.add(entry.authority);
|
|
416
|
+
else
|
|
417
|
+
heldAtZero.delete(entry.authority);
|
|
418
|
+
}
|
|
419
|
+
for (const entry of unheld)
|
|
420
|
+
heldAtZero.delete(entry.authority);
|
|
421
|
+
const site = mode === 'site';
|
|
422
|
+
unanswered.push(site ? unheld.map((entry) => entry.locator) : []);
|
|
423
|
+
socket.hold([
|
|
424
|
+
...named.map(({ entry, at }) => presented(entry.authority, at)),
|
|
425
|
+
...(site ? [] : unheld).map((entry) => presented(entry.authority, { position: '0', logEpoch: entry.logEpoch })),
|
|
426
|
+
], runtime, listedCursor);
|
|
427
|
+
if (site)
|
|
428
|
+
return;
|
|
429
|
+
const made = unheld.filter((entry) => entry.position === '0');
|
|
430
|
+
queueMicrotask(() => {
|
|
431
|
+
for (const entry of made) {
|
|
432
|
+
const version = roomVersion(entry);
|
|
433
|
+
emit({
|
|
434
|
+
kind: 'room-change',
|
|
435
|
+
locator: entry.locator,
|
|
436
|
+
from: null,
|
|
437
|
+
roomVersion: version,
|
|
438
|
+
read: () => changePage(entry, [], version, mode, spaces, true),
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
});
|
|
373
442
|
},
|
|
374
443
|
track(entries) {
|
|
375
444
|
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,6 +42,7 @@ 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;
|
|
47
48
|
space?: string;
|
|
@@ -173,15 +174,11 @@ export type HouseStream = {
|
|
|
173
174
|
opened(notify: (opening: HouseOpening) => void): () => void;
|
|
174
175
|
closed(notify: (closing: HouseClosing) => void): () => void;
|
|
175
176
|
};
|
|
176
|
-
export type HouseStreamed = HouseDoorAnswer & {
|
|
177
|
-
room: ReadableStream<Uint8Array> | null;
|
|
178
|
-
};
|
|
179
177
|
export type HouseDoor = {
|
|
180
178
|
door(route: string, body: unknown): Promise<HouseDoorAnswer>;
|
|
181
179
|
stream: HouseStream;
|
|
182
180
|
};
|
|
183
181
|
export type HouseTransport = HouseDoor & {
|
|
184
|
-
streamed(route: string, body: unknown, signal: AbortSignal): Promise<HouseStreamed>;
|
|
185
182
|
transfer(request: HouseByteTransfer): Promise<HouseDoorAnswer>;
|
|
186
183
|
put(url: string, body: Blob, headers: Readonly<Record<string, string>>): Promise<number>;
|
|
187
184
|
download(url: string): Promise<HouseBytesAnswer>;
|
|
@@ -189,7 +186,6 @@ export type HouseTransport = HouseDoor & {
|
|
|
189
186
|
export type HouseSiteTransport = HouseDoor & {
|
|
190
187
|
online(): boolean;
|
|
191
188
|
read(route: string): Promise<HouseDoorAnswer>;
|
|
192
|
-
streamed(route: string, signal: AbortSignal): Promise<HouseStreamed>;
|
|
193
189
|
download(route: string): Promise<HouseBytesAnswer>;
|
|
194
190
|
};
|
|
195
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,
|
|
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,CA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AC,CAAC;IACzF,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAClD,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG;IAC3C,MAAM,IAAI,OAAO,CAAC;IAClB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC9C,QAAQ,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.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../src/write.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,WAAW,EAEhB,KAAK,aAAa,EAElB,KAAK,cAAc,EAEpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAOlD,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAE/D,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,SAAS,cAAc,EAAE,CAAA;CAAE,GACvD;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAwHrD,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,aAAa,CAQ9E;AAED,wBAAgB,UAAU,CACxB,KAAK,EAAE,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,EAAE,EACpE,MAAM,EAAE,MAAM,GACb,aAAa,CAEf;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,aAAa,CAgBhG;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OA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C;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAM1B;AA6BD,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3C,aAAa,CA+Cf"}
|
package/dist/write.js
CHANGED
|
@@ -2,7 +2,7 @@ import { departure, partsChanges, ROW_WEIGHT, } from '@agentshouse/mdruntime';
|
|
|
2
2
|
import { answered, answering, binaryFileOf, headChange, revised } from './read.js';
|
|
3
3
|
import { sha256Hex, textBytes } from './digest.js';
|
|
4
4
|
import { nativePath, roomLocalPath } from './map.js';
|
|
5
|
-
import { classifyDoor, doorRefusal, scopedRefusal } from './refusal.js';
|
|
5
|
+
import { classifyDoor, doorRefusal, resetOf, scopedRefusal } from './refusal.js';
|
|
6
6
|
import { readPosition, roomVersion } from './version.js';
|
|
7
7
|
function priorField(batch, path, name) {
|
|
8
8
|
return batch.preconditions.find((precondition) => precondition.kind === 'field' && precondition.path === path && precondition.name === name);
|
|
@@ -276,10 +276,8 @@ export function* mutationOutcome(status, body, locator, handle, move) {
|
|
|
276
276
|
return scopedRefusal(locator, 'undisclosed', refusal);
|
|
277
277
|
}
|
|
278
278
|
const classified = classifyDoor(status, body, locator);
|
|
279
|
-
const reset = refusal
|
|
280
|
-
if (refusal?.
|
|
281
|
-
typeof reset === 'string' &&
|
|
282
|
-
classified?.kind === 'transport-uncertainty') {
|
|
279
|
+
const reset = resetOf(refusal);
|
|
280
|
+
if (refusal !== null && reset !== undefined && classified?.kind === 'transport-uncertainty') {
|
|
283
281
|
return {
|
|
284
282
|
kind: 'retryable-refusal',
|
|
285
283
|
code: refusal.code,
|
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-cdf75633ae85a",
|
|
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-c9873d788cfb6"
|
|
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 { SpaceSchemas } from './space-schema.js';
|
|
5
|
-
import type { HouseMode } from './transport.js';
|
|
6
|
-
export type StreamedPart = {
|
|
7
|
-
readonly scope: HouseScope;
|
|
8
|
-
readonly first: boolean;
|
|
9
|
-
readonly ended: boolean;
|
|
10
|
-
readonly models: RoomModels | undefined;
|
|
11
|
-
readonly pageToken: string | undefined;
|
|
12
|
-
readonly bytes: number;
|
|
13
|
-
};
|
|
14
|
-
export declare function roomStreams(mode: HouseMode, spaces: SpaceSchemas): {
|
|
15
|
-
head: (entry: TrackedAuthority, room: ReadableStream<Uint8Array>, arriving: ((bytes: number) => void) | undefined, signal: AbortSignal | undefined) => Promise<BootstrapResult>;
|
|
16
|
-
part: (entry: TrackedAuthority, token: string) => Promise<StreamedPart | Exclude<BootstrapResult, {
|
|
17
|
-
kind: 'bootstrap';
|
|
18
|
-
}>>;
|
|
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;AAC1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGvD,OAAO,EAAuD,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AACjG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,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,EAAE,MAAM,EAAE,YAAY;kBAKtD,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, spaces) {
|
|
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, spaces);
|
|
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
|
-
}
|