@agentshouse/mdruntime-adapter 0.1.0-ce1149641691d → 0.1.0-ce3ced044cab5
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 +6 -26
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +18 -150
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +167 -223
- package/dist/app-reference.d.ts +2 -0
- package/dist/app-reference.d.ts.map +1 -0
- package/dist/app-reference.js +2 -0
- package/dist/crockford.d.ts +4 -0
- package/dist/crockford.d.ts.map +1 -0
- package/dist/crockford.js +3 -0
- package/dist/discovery.d.ts +5 -10
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +18 -32
- package/dist/gather.d.ts +0 -1
- package/dist/gather.d.ts.map +1 -1
- package/dist/gather.js +1 -1
- package/dist/house-model.d.ts +2 -0
- package/dist/house-model.d.ts.map +1 -0
- package/dist/house-model.js +486 -0
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/model.d.ts +5 -1
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +11 -13
- package/dist/part.d.ts +12 -11
- package/dist/part.d.ts.map +1 -1
- package/dist/part.js +66 -56
- package/dist/read.d.ts +33 -17
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +187 -122
- package/dist/room-stream.d.ts +19 -0
- package/dist/room-stream.d.ts.map +1 -0
- package/dist/room-stream.js +57 -0
- package/dist/room-types.d.ts +7 -0
- package/dist/room-types.d.ts.map +1 -0
- package/dist/room-types.js +125 -0
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +43 -92
- package/dist/stream.d.ts +1 -0
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +17 -2
- package/dist/transport.d.ts +14 -8
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +2 -1
- package/dist/upload.d.ts +12 -0
- package/dist/upload.d.ts.map +1 -0
- package/dist/upload.js +63 -0
- package/dist/write.d.ts +4 -0
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +22 -18
- package/package.json +8 -4
- package/AGENTS.md +0 -304
- package/dist/handed.d.ts +0 -15
- package/dist/handed.d.ts.map +0 -1
- package/dist/handed.js +0 -45
- package/dist/referrer.d.ts +0 -7
- package/dist/referrer.d.ts.map +0 -1
- package/dist/referrer.js +0 -35
package/dist/site.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { stepped } from '@agentshouse/mdruntime';
|
|
2
2
|
import { actionOutcome, SITE_SUBMIT } from './actions.js';
|
|
3
3
|
import { mapDiscovery, parseSiteDiscovery, siteCapabilities, siteTracked, } from './discovery.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { streamedModels, viewModels } from './model.js';
|
|
5
|
+
import { bootstrapping, parseEnumeration, refreshFrom, viewOf, wholeView, } from './read.js';
|
|
6
|
+
import { roomStreams } from './room-stream.js';
|
|
7
7
|
import { classifyDoor, classifyRead, discoveryFailure } from './refusal.js';
|
|
8
|
+
import { HOUSE_NAMEABLE_ROOM_TYPES, HOUSE_ROOM_TYPES } from './room-types.js';
|
|
8
9
|
import { houseNotifications } from './stream.js';
|
|
9
|
-
import { SITE_DOOR_BOOTSTRAP, SITE_DOOR_DISCOVER, SITE_DOOR_ENUMERATE, SITE_DOOR_SUBMIT,
|
|
10
|
-
import { houseReferrer } from './referrer.js';
|
|
10
|
+
import { SITE_DOOR_BOOTSTRAP, SITE_DOOR_DISCOVER, SITE_DOOR_ENUMERATE, SITE_DOOR_SUBMIT, SITE_FILES, } from './transport.js';
|
|
11
11
|
import { followsVersion, logPosition, presented, reachedVersion, roomVersion, } from './version.js';
|
|
12
12
|
const UNCERTAIN = { kind: 'transport-uncertainty' };
|
|
13
13
|
function unfound() {
|
|
@@ -24,28 +24,16 @@ function siteRoom(tracked) {
|
|
|
24
24
|
providerOwnedPaths: [],
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
function settled(refused) {
|
|
28
|
-
return refused.kind === 'beyond-horizon' ? UNCERTAIN : refused;
|
|
29
|
-
}
|
|
30
27
|
export function createSiteAdapter(transport, snapshot = false) {
|
|
31
28
|
const notifications = houseNotifications(transport, 'site');
|
|
32
29
|
const tracked = new Map();
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
const named = houseReferrer(referrer, tracked);
|
|
36
|
-
return named === null || !tracked.has(named.locator) ? null : named;
|
|
37
|
-
}
|
|
30
|
+
const read = new Map();
|
|
31
|
+
const rooms = roomStreams('site');
|
|
38
32
|
function fileRoute(request) {
|
|
39
|
-
const
|
|
40
|
-
if (
|
|
41
|
-
return { kind: '
|
|
42
|
-
}
|
|
43
|
-
if (request.fileRef === undefined)
|
|
44
|
-
return unfound();
|
|
45
|
-
const { room_ref, path, record } = named.referrer;
|
|
46
|
-
return `${SITE_FILES}${room_ref}/${encodeURIComponent(request.fileRef)}/${path === undefined
|
|
47
|
-
? `${SITE_FILE_RECORD}/${encodeURIComponent(record)}`
|
|
48
|
-
: encodeURIComponent(path)}`;
|
|
33
|
+
const entry = tracked.get(request.locator);
|
|
34
|
+
if (entry === undefined)
|
|
35
|
+
return { kind: 'room-not-readable', locator: request.locator };
|
|
36
|
+
return `${SITE_FILES}${entry.authority}/${encodeURIComponent(request.revision)}/${encodeURIComponent(request.path)}`;
|
|
49
37
|
}
|
|
50
38
|
async function enumerated(entry, from, page) {
|
|
51
39
|
const answer = await transport.door(SITE_DOOR_ENUMERATE, {
|
|
@@ -70,42 +58,29 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
70
58
|
const first = await enumerated(entry, from);
|
|
71
59
|
return 'kind' in first ? first : wholeView(first, (page) => enumerated(entry, from, page));
|
|
72
60
|
}
|
|
73
|
-
async function
|
|
74
|
-
const cut =
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
|
|
61
|
+
async function openedRoom(entry, arriving, signal) {
|
|
62
|
+
const cut = read.get(entry.locator);
|
|
63
|
+
const answered = await transport.streamed(`${SITE_DOOR_BOOTSTRAP}${entry.authority}${cut === undefined ? '' : `?expired=${cut}`}`, signal ?? new AbortController().signal);
|
|
64
|
+
if (answered.room === null)
|
|
65
|
+
return classifyDoor(answered.status, answered.body, entry.locator) ?? UNCERTAIN;
|
|
66
|
+
const head = await rooms.head(entry, answered.room, arriving, signal);
|
|
67
|
+
const at = head.kind === 'bootstrap' ? logPosition(head.roomVersion) : null;
|
|
68
|
+
if (at !== null)
|
|
69
|
+
read.set(entry.locator, at.position);
|
|
70
|
+
return head;
|
|
81
71
|
}
|
|
82
|
-
async function
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
return unverifiedPart(entry.locator);
|
|
95
|
-
}
|
|
96
|
-
async function caughtUp(entry, continued) {
|
|
97
|
-
const listed = continued.room.parts[continued.next];
|
|
98
|
-
const scope = listed === undefined
|
|
99
|
-
? emptyScope(continued.room)
|
|
100
|
-
: await fetchedPart(entry, continued.room, listed);
|
|
101
|
-
if ('kind' in scope)
|
|
102
|
-
return scope;
|
|
103
|
-
if (continued.room.parts.length > 1 || roomVersion(scope) === roomVersion(entry))
|
|
104
|
-
return scope;
|
|
105
|
-
const view = await enumeration(entry, scope);
|
|
106
|
-
if ('kind' in view)
|
|
107
|
-
return settled(view);
|
|
108
|
-
return stepped(advancedScope(scope, view));
|
|
72
|
+
async function streamedPage(entry, token) {
|
|
73
|
+
const part = await rooms.part(entry, token);
|
|
74
|
+
if ('kind' in part)
|
|
75
|
+
return part;
|
|
76
|
+
notifications.reach(entry.authority, part.scope);
|
|
77
|
+
const { folders: _folders, ...page } = await stepped(bootstrapping(part.scope));
|
|
78
|
+
return {
|
|
79
|
+
...page,
|
|
80
|
+
...(part.models === undefined ? {} : { models: part.models }),
|
|
81
|
+
...(part.pageToken === undefined ? {} : { pageToken: part.pageToken }),
|
|
82
|
+
bytes: part.bytes,
|
|
83
|
+
};
|
|
109
84
|
}
|
|
110
85
|
async function refreshed(entry, fromRoomVersion) {
|
|
111
86
|
const from = logPosition(fromRoomVersion);
|
|
@@ -129,6 +104,8 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
129
104
|
return {
|
|
130
105
|
localSaves: true,
|
|
131
106
|
exhaustiveDiscovery: true,
|
|
107
|
+
roomTypes: HOUSE_ROOM_TYPES,
|
|
108
|
+
nameableRoomTypes: HOUSE_NAMEABLE_ROOM_TYPES,
|
|
132
109
|
async authorize() {
|
|
133
110
|
return {};
|
|
134
111
|
},
|
|
@@ -151,31 +128,9 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
151
128
|
const entry = tracked.get(request.locator);
|
|
152
129
|
if (entry === undefined)
|
|
153
130
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
if ('kind' in room)
|
|
158
|
-
return room;
|
|
159
|
-
continued = { room, next: 0, seen: [] };
|
|
160
|
-
}
|
|
161
|
-
else
|
|
162
|
-
continued = JSON.parse(request.pageToken);
|
|
163
|
-
const scope = await caughtUp(entry, continued);
|
|
164
|
-
if ('kind' in scope)
|
|
165
|
-
return scope;
|
|
166
|
-
notifications.reach(entry.authority, scope);
|
|
167
|
-
const next = continued.next + 1;
|
|
168
|
-
const more = next < continued.room.parts.length;
|
|
169
|
-
const seen = [
|
|
170
|
-
...continued.seen,
|
|
171
|
-
...entry.schemas.filter((schema) => scope.files.some((file) => file.path === schema)),
|
|
172
|
-
];
|
|
173
|
-
const models = await partModels(scope, entry, new Set(seen), !more);
|
|
174
|
-
return {
|
|
175
|
-
...(await stepped(bootstrapping(scope))),
|
|
176
|
-
...(models === undefined ? {} : { models }),
|
|
177
|
-
...(more ? { pageToken: JSON.stringify({ ...continued, next, seen }) } : {}),
|
|
178
|
-
};
|
|
131
|
+
return request.pageToken === undefined
|
|
132
|
+
? openedRoom(entry, request.arriving, request.signal)
|
|
133
|
+
: streamedPage(entry, request.pageToken);
|
|
179
134
|
},
|
|
180
135
|
async refresh(_authorization, request) {
|
|
181
136
|
const entry = tracked.get(request.locator);
|
|
@@ -193,6 +148,9 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
193
148
|
async mutate() {
|
|
194
149
|
return { kind: 'rejected', affected: {}, code: 'write-grant', fields: {}, retryable: false };
|
|
195
150
|
},
|
|
151
|
+
async attach() {
|
|
152
|
+
return { kind: 'rejected', code: 'write-grant', fields: {}, retryable: false };
|
|
153
|
+
},
|
|
196
154
|
async history() {
|
|
197
155
|
return { kind: 'no-history' };
|
|
198
156
|
},
|
|
@@ -203,8 +161,8 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
203
161
|
const read = await transport.download(route);
|
|
204
162
|
if (read.status === 404)
|
|
205
163
|
return unfound();
|
|
206
|
-
return read.status === 200 && read.
|
|
207
|
-
? { kind: 'binary',
|
|
164
|
+
return read.status === 200 && read.body !== null
|
|
165
|
+
? { kind: 'binary', body: read.body, mediaType: read.mediaType }
|
|
208
166
|
: UNCERTAIN;
|
|
209
167
|
},
|
|
210
168
|
async link(_authorization, request) {
|
|
@@ -217,13 +175,6 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
217
175
|
name: request.path.slice(request.path.lastIndexOf('/') + 1),
|
|
218
176
|
};
|
|
219
177
|
},
|
|
220
|
-
referrerScope(referrer) {
|
|
221
|
-
const named = published(referrer);
|
|
222
|
-
if (named === null)
|
|
223
|
-
return null;
|
|
224
|
-
const { path } = named.referrer;
|
|
225
|
-
return { kind: 'room', locator: named.locator, ...(path === undefined ? {} : { path }) };
|
|
226
|
-
},
|
|
227
178
|
reached(locator, version, target) {
|
|
228
179
|
return reachedVersion(version, target, tracked.get(locator)?.logEpoch);
|
|
229
180
|
},
|
package/dist/stream.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export type HouseNotifications = {
|
|
|
15
15
|
reopen(): void;
|
|
16
16
|
track(authorities: readonly TrackedAuthority[]): void;
|
|
17
17
|
reach(authority: string, at: LogPosition): void;
|
|
18
|
+
edited(tracked: TrackedAuthority, from: LogPosition): readonly string[];
|
|
18
19
|
advance(tracked: TrackedAuthority, from: LogPosition, holds?: HeldRevision): Generator<number, StreamedAdvancement | null, void>;
|
|
19
20
|
conversations: ConversationStream;
|
|
20
21
|
serviceMode: ServiceModeSignal;
|
package/dist/stream.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,kBAAkB,EAEvB,KAAK,WAAW,EAChB,KAAK,eAAe,EAEpB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAEpB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,kBAAkB,EAEvB,KAAK,WAAW,EAChB,KAAK,eAAe,EAEpB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAEpB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAUvD,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EAEb,SAAS,EAET,gBAAgB,EAEjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AA0C7D,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;AAEvE,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,EAAE,QAAQ,EAAE,cAAc,GAAG,MAAM,IAAI,CAAC;IACxF,IAAI,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,GAAG,IAAI,CAAC;IAC5C,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW,GAAG,IAAI,CAAC;IAClD,MAAM,IAAI,IAAI,CAAC;IACf,KAAK,CAAC,WAAW,EAAE,SAAS,gBAAgB,EAAE,GAAG,IAAI,CAAC;IACtD,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW,GAAG,IAAI,CAAC;IAChD,MAAM,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,WAAW,GAAG,SAAS,MAAM,EAAE,CAAC;IACxE,OAAO,CACL,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,WAAW,EACjB,KAAK,CAAC,EAAE,YAAY,GACnB,SAAS,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI,EAAE,IAAI,CAAC,CAAC;IACvD,aAAa,EAAE,kBAAkB,CAAC;IAClC,WAAW,EAAE,iBAAiB,CAAC;CAChC,CAAC;AAmFF,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,GAAG,kBAAkB,CA8jB5F"}
|
package/dist/stream.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ROW_WEIGHT, } from '@agentshouse/mdruntime';
|
|
2
2
|
import { acceptedMessage } from './actions.js';
|
|
3
3
|
import { sha256Hex } from './digest.js';
|
|
4
|
-
import { answered, answering, binaryFileOf, forgotten, headChange, revised } from './read.js';
|
|
4
|
+
import { answered, answering, binaryFileOf, folded, forgotten, headChange, revised, } from './read.js';
|
|
5
5
|
import { roomVersion } from './version.js';
|
|
6
6
|
const HELD_FRAMES_MAX = 256;
|
|
7
7
|
function turnOperation(frame) {
|
|
@@ -556,6 +556,17 @@ export function houseNotifications(transport, mode) {
|
|
|
556
556
|
held,
|
|
557
557
|
});
|
|
558
558
|
},
|
|
559
|
+
edited(tracked, from) {
|
|
560
|
+
const line = lines.get(tracked.authority);
|
|
561
|
+
const start = position(from.position);
|
|
562
|
+
if (line === undefined || start === null || line.logEpoch !== from.logEpoch)
|
|
563
|
+
return [];
|
|
564
|
+
return [
|
|
565
|
+
...new Set(line.frames
|
|
566
|
+
.filter((frame) => frame.position > start)
|
|
567
|
+
.flatMap((frame) => frame.entries.flatMap((entry) => entry.kind === 'edited' && entry.revision !== undefined ? [entry.path] : []))),
|
|
568
|
+
];
|
|
569
|
+
},
|
|
559
570
|
*advance(tracked, from, holds) {
|
|
560
571
|
const line = lines.get(tracked.authority);
|
|
561
572
|
const start = position(from.position);
|
|
@@ -570,13 +581,17 @@ export function houseNotifications(transport, mode) {
|
|
|
570
581
|
for (const frame of pending) {
|
|
571
582
|
for (const entry of frame.entries) {
|
|
572
583
|
yield ROW_WEIGHT + (entry.text?.length ?? 0);
|
|
584
|
+
if (entry.kind === 'folder') {
|
|
585
|
+
folded(answer, entry.path, entry.removed === true);
|
|
586
|
+
continue;
|
|
587
|
+
}
|
|
573
588
|
if (entry.kind === 'edited' &&
|
|
574
589
|
entry.revision !== undefined &&
|
|
575
590
|
holds?.(entry.path, entry.revision) === true) {
|
|
576
591
|
forgotten(answer, entry.path);
|
|
577
592
|
continue;
|
|
578
593
|
}
|
|
579
|
-
if (
|
|
594
|
+
if (entry.path === tracked.schema)
|
|
580
595
|
schemas.set(entry.path, entry);
|
|
581
596
|
if (entry.kind === 'removed') {
|
|
582
597
|
forgotten(answer, entry.path);
|
package/dist/transport.d.ts
CHANGED
|
@@ -15,27 +15,27 @@ export type HouseDoorAnswer = {
|
|
|
15
15
|
body: unknown;
|
|
16
16
|
};
|
|
17
17
|
export declare const DOOR_FILES_GET = "/door/files/get";
|
|
18
|
+
export declare const DOOR_FILES_ATTACH = "/door/files/attach";
|
|
19
|
+
export declare const DOOR_FILES_FINISH = "/door/files/finish";
|
|
18
20
|
export declare const SITE_FILES = "/_house/files/";
|
|
19
|
-
export
|
|
20
|
-
export type HouseByteAct = 'authored_batch_upload' | 'conversation_file_upload' | 'binary_stage';
|
|
21
|
-
export type HouseByteBody = string | ArrayBuffer | Uint8Array | Blob;
|
|
21
|
+
export type HouseByteAct = 'authored_batch_upload';
|
|
22
22
|
export type HouseBytesAnswer = {
|
|
23
23
|
status: number;
|
|
24
|
-
|
|
24
|
+
body: ReadableStream<Uint8Array> | null;
|
|
25
|
+
mediaType: string;
|
|
25
26
|
};
|
|
26
27
|
export type HouseByteTransfer = {
|
|
27
28
|
act: HouseByteAct;
|
|
28
29
|
url: string;
|
|
29
|
-
body:
|
|
30
|
-
operation?: string;
|
|
30
|
+
body: string;
|
|
31
31
|
};
|
|
32
32
|
export type HouseStreamEntry = {
|
|
33
33
|
path: string;
|
|
34
|
-
kind: 'edited' | 'removed' | 'piece';
|
|
34
|
+
kind: 'edited' | 'removed' | 'piece' | 'folder';
|
|
35
|
+
removed?: true;
|
|
35
36
|
revision?: string;
|
|
36
37
|
sha256?: string;
|
|
37
38
|
text?: string;
|
|
38
|
-
file?: string;
|
|
39
39
|
bytes?: number;
|
|
40
40
|
media_type?: string;
|
|
41
41
|
author?: {
|
|
@@ -164,17 +164,23 @@ export type HouseStream = {
|
|
|
164
164
|
opened(notify: (opening: HouseOpening) => void): () => void;
|
|
165
165
|
closed(notify: (closing: HouseClosing) => void): () => void;
|
|
166
166
|
};
|
|
167
|
+
export type HouseStreamed = HouseDoorAnswer & {
|
|
168
|
+
room: ReadableStream<Uint8Array> | null;
|
|
169
|
+
};
|
|
167
170
|
export type HouseDoor = {
|
|
168
171
|
door(route: string, body: unknown): Promise<HouseDoorAnswer>;
|
|
169
172
|
stream: HouseStream;
|
|
170
173
|
};
|
|
171
174
|
export type HouseTransport = HouseDoor & {
|
|
175
|
+
streamed(route: string, body: unknown, signal: AbortSignal): Promise<HouseStreamed>;
|
|
172
176
|
transfer(request: HouseByteTransfer): Promise<HouseDoorAnswer>;
|
|
177
|
+
put(url: string, body: Blob, headers: Readonly<Record<string, string>>): Promise<number>;
|
|
173
178
|
download(url: string): Promise<HouseBytesAnswer>;
|
|
174
179
|
};
|
|
175
180
|
export type HouseSiteTransport = HouseDoor & {
|
|
176
181
|
online(): boolean;
|
|
177
182
|
read(route: string): Promise<HouseDoorAnswer>;
|
|
183
|
+
streamed(route: string, signal: AbortSignal): Promise<HouseStreamed>;
|
|
178
184
|
download(route: string): Promise<HouseBytesAnswer>;
|
|
179
185
|
};
|
|
180
186
|
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;AAE/E,eAAO,MAAM,aAAa,mBAAmB,CAAC;AAE9C,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD,eAAO,MAAM,UAAU,gBAAgB,CAAC;AAExC,eAAO,MAAM,iBAAiB,uBAAuB,CAAC;AAEtD,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD,eAAO,MAAM,kBAAkB,0BAA0B,CAAC;AAE1D,eAAO,MAAM,mBAAmB,4BAA4B,CAAC;AAE7D,eAAO,MAAM,mBAAmB,2BAA2B,CAAC;AAE5D,eAAO,MAAM,gBAAgB,wBAAwB,CAAC;AAEtD,MAAM,MAAM,SAAS,GAAG,YAAY,GAAG,MAAM,CAAC;AAE9C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GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,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,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IACrE,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACpD,CAAC"}
|
package/dist/transport.js
CHANGED
|
@@ -9,5 +9,6 @@ export const SITE_DOOR_BOOTSTRAP = '/_house/door/bootstrap/';
|
|
|
9
9
|
export const SITE_DOOR_ENUMERATE = '/_house/door/enumerate';
|
|
10
10
|
export const SITE_DOOR_SUBMIT = '/_house/door/submit';
|
|
11
11
|
export const DOOR_FILES_GET = '/door/files/get';
|
|
12
|
+
export const DOOR_FILES_ATTACH = '/door/files/attach';
|
|
13
|
+
export const DOOR_FILES_FINISH = '/door/files/finish';
|
|
12
14
|
export const SITE_FILES = '/_house/files/';
|
|
13
|
-
export const SITE_FILE_RECORD = 'record';
|
package/dist/upload.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type HouseDoorAnswer, type HouseTransport } from './transport.js';
|
|
2
|
+
export type HouseUpload = {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly partBytes: number;
|
|
5
|
+
readonly parts: readonly {
|
|
6
|
+
readonly part: number;
|
|
7
|
+
readonly url: string;
|
|
8
|
+
}[];
|
|
9
|
+
};
|
|
10
|
+
export declare function houseUpload(value: unknown): HouseUpload | null;
|
|
11
|
+
export declare function finishedUpload(transport: HouseTransport, first: HouseUpload, blob: Blob): Promise<HouseDoorAnswer | null>;
|
|
12
|
+
//# sourceMappingURL=upload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../src/upload.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAE9F,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,SAAS;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC5E,CAAC;AAeF,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,CAQ9D;AA8BD,wBAAsB,cAAc,CAClC,SAAS,EAAE,cAAc,EACzB,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAejC"}
|
package/dist/upload.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { sha256 } from '@agentshouse/mdruntime/digest';
|
|
2
|
+
import { DOOR_FILES_FINISH } from './transport.js';
|
|
3
|
+
const FINISHING_ROUNDS = 24;
|
|
4
|
+
function record(value) {
|
|
5
|
+
return value !== null && typeof value === 'object' ? value : {};
|
|
6
|
+
}
|
|
7
|
+
function part(value) {
|
|
8
|
+
const { part: number, url } = record(value);
|
|
9
|
+
return Number.isSafeInteger(number) && number > 0 && typeof url === 'string'
|
|
10
|
+
? { part: number, url }
|
|
11
|
+
: null;
|
|
12
|
+
}
|
|
13
|
+
export function houseUpload(value) {
|
|
14
|
+
const { id, part_bytes: partBytes, parts = [] } = record(value);
|
|
15
|
+
if (typeof id !== 'string' || !Number.isSafeInteger(partBytes) || partBytes <= 0)
|
|
16
|
+
return null;
|
|
17
|
+
if (!Array.isArray(parts))
|
|
18
|
+
return null;
|
|
19
|
+
const named = parts.map(part);
|
|
20
|
+
if (named.some((one) => one === null))
|
|
21
|
+
return null;
|
|
22
|
+
return { id, partBytes: partBytes, parts: named };
|
|
23
|
+
}
|
|
24
|
+
function checksum(hex) {
|
|
25
|
+
let bytes = '';
|
|
26
|
+
for (let at = 0; at < hex.length; at += 2)
|
|
27
|
+
bytes += String.fromCharCode(Number.parseInt(hex.slice(at, at + 2), 16));
|
|
28
|
+
return { 'x-amz-checksum-sha256': btoa(bytes) };
|
|
29
|
+
}
|
|
30
|
+
async function partSha256(blob, partBytes) {
|
|
31
|
+
const parts = [];
|
|
32
|
+
for (let start = 0; start === 0 || start < blob.size; start += partBytes)
|
|
33
|
+
parts.push(await sha256(blob.slice(start, start + partBytes)));
|
|
34
|
+
return parts;
|
|
35
|
+
}
|
|
36
|
+
async function sent(transport, upload, blob, digests) {
|
|
37
|
+
for (const { part: number, url } of upload.parts) {
|
|
38
|
+
const start = (number - 1) * upload.partBytes;
|
|
39
|
+
const slice = blob.slice(start, start + upload.partBytes);
|
|
40
|
+
if ((await transport.put(url, slice, checksum(digests[number - 1]))) !== 200)
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
export async function finishedUpload(transport, first, blob) {
|
|
46
|
+
const digests = await partSha256(blob, first.partBytes);
|
|
47
|
+
let upload = first;
|
|
48
|
+
for (let round = 0; round < FINISHING_ROUNDS; round += 1) {
|
|
49
|
+
if (!(await sent(transport, upload, blob, digests)))
|
|
50
|
+
return null;
|
|
51
|
+
const answer = await transport.door(DOOR_FILES_FINISH, {
|
|
52
|
+
upload: upload.id,
|
|
53
|
+
part_sha256: digests,
|
|
54
|
+
});
|
|
55
|
+
if (answer.status !== 200)
|
|
56
|
+
return answer;
|
|
57
|
+
const missing = houseUpload(record(answer.body).upload);
|
|
58
|
+
if (missing === null)
|
|
59
|
+
return answer;
|
|
60
|
+
upload = missing;
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
package/dist/write.d.ts
CHANGED
|
@@ -10,6 +10,10 @@ export type ChangeMapping = {
|
|
|
10
10
|
rule: string;
|
|
11
11
|
};
|
|
12
12
|
export declare function houseChanges(batch: ChangeBatch, handle: string): ChangeMapping;
|
|
13
|
+
export declare function houseParts(saved: readonly {
|
|
14
|
+
readonly path: string;
|
|
15
|
+
readonly parts: unknown;
|
|
16
|
+
}[], handle: string): ChangeMapping;
|
|
13
17
|
export declare function houseMove(batch: ChangeBatch, source: string, destination: string): ChangeMapping;
|
|
14
18
|
export type OperationHead = {
|
|
15
19
|
readonly operation_id: string;
|
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,
|
|
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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AAC,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACzE,QAAQ,CAAC,WAAW,EAAE;QAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC/E,CAAC;AAkCF,wBAAiB,eAAe,CAC9B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,eAAe,GACrB,SAAS,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,CAAC,CA8DzC;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,aAAa,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC;IAEjF,IAAI,EAAE,UAAU;IAChB,QAAQ;IACR,IAAI;IACJ,MAAM;QAAI,IAAI;;IACd,SAAS;EAEZ;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAM1B;AA2BD,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,CAyDf"}
|
package/dist/write.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { departure, ROW_WEIGHT, } from '@agentshouse/mdruntime';
|
|
1
|
+
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';
|
|
@@ -120,6 +120,9 @@ export function houseChanges(batch, handle) {
|
|
|
120
120
|
}
|
|
121
121
|
return { kind: 'changes', changes };
|
|
122
122
|
}
|
|
123
|
+
export function houseParts(saved, handle) {
|
|
124
|
+
return houseChanges({ id: '', baseRoomVersion: '', ...partsChanges(saved) }, handle);
|
|
125
|
+
}
|
|
123
126
|
export function houseMove(batch, source, destination) {
|
|
124
127
|
const changes = [];
|
|
125
128
|
for (const { path, to } of batch.between?.moves ?? []) {
|
|
@@ -338,26 +341,27 @@ export function revisionBody(input) {
|
|
|
338
341
|
function revisionAuthor(entry) {
|
|
339
342
|
const user = entry.author_user;
|
|
340
343
|
const site = entry.author_site;
|
|
341
|
-
const
|
|
342
|
-
|
|
344
|
+
const siteName = entry.author_site_name;
|
|
345
|
+
const inbox = entry.author_inbox;
|
|
346
|
+
const inboxName = entry.author_inbox_name;
|
|
347
|
+
const app = entry.author_app;
|
|
348
|
+
const appName = entry.author_app_name;
|
|
349
|
+
const named = [site, siteName, inbox, inboxName, app, appName].filter((held) => held !== undefined);
|
|
350
|
+
if (typeof user === 'string' && named.length === 0)
|
|
343
351
|
return { kind: 'user', id: user };
|
|
352
|
+
if (user !== null || named.length !== 2)
|
|
353
|
+
return null;
|
|
354
|
+
if (typeof site === 'string' && typeof siteName === 'string') {
|
|
355
|
+
return { kind: 'site', id: site, name: siteName };
|
|
356
|
+
}
|
|
357
|
+
if (typeof inbox === 'string' && typeof inboxName === 'string') {
|
|
358
|
+
return { kind: 'inbox', id: inbox, name: inboxName };
|
|
344
359
|
}
|
|
345
|
-
if (
|
|
346
|
-
return { kind: '
|
|
360
|
+
if (typeof app === 'string' && typeof appName === 'string') {
|
|
361
|
+
return { kind: 'app', id: app, name: appName };
|
|
347
362
|
}
|
|
348
363
|
return null;
|
|
349
364
|
}
|
|
350
|
-
function historyBinary(entry) {
|
|
351
|
-
if (entry.file === undefined)
|
|
352
|
-
return undefined;
|
|
353
|
-
const { file, bytes, media_type: mediaType, sha256 } = entry;
|
|
354
|
-
if (typeof file !== 'string' ||
|
|
355
|
-
typeof bytes !== 'number' ||
|
|
356
|
-
typeof mediaType !== 'string' ||
|
|
357
|
-
typeof sha256 !== 'string')
|
|
358
|
-
return null;
|
|
359
|
-
return { fileRef: file, byteLength: bytes, mediaType, sha256 };
|
|
360
|
-
}
|
|
361
365
|
export function historyOutcome(status, body, locator, request) {
|
|
362
366
|
const classified = classifyDoor(status, body, locator);
|
|
363
367
|
if (classified !== null)
|
|
@@ -388,7 +392,7 @@ export function historyOutcome(status, body, locator, request) {
|
|
|
388
392
|
retryable: false,
|
|
389
393
|
};
|
|
390
394
|
}
|
|
391
|
-
if (typeof named.
|
|
395
|
+
if (typeof named.media_type === 'string')
|
|
392
396
|
return { kind: 'no-history' };
|
|
393
397
|
if (typeof named.content !== 'string')
|
|
394
398
|
return { kind: 'transport-uncertainty' };
|
|
@@ -404,7 +408,7 @@ export function historyOutcome(status, body, locator, request) {
|
|
|
404
408
|
typeof entry.created_at !== 'string') {
|
|
405
409
|
return { kind: 'transport-uncertainty' };
|
|
406
410
|
}
|
|
407
|
-
const binaryFile =
|
|
411
|
+
const binaryFile = binaryFileOf(entry);
|
|
408
412
|
if (binaryFile === null)
|
|
409
413
|
return { kind: 'transport-uncertainty' };
|
|
410
414
|
revisions.push({
|
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-ce3ced044cab5",
|
|
4
4
|
"description": "Agents House Adapter for the MD Runtime",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"access": "public"
|
|
10
10
|
},
|
|
11
11
|
"engines": {
|
|
12
|
-
"node": ">=24.
|
|
12
|
+
"node": ">=24.22.1"
|
|
13
13
|
},
|
|
14
14
|
"exports": {
|
|
15
15
|
".": {
|
|
@@ -20,11 +20,15 @@
|
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
22
|
"dist",
|
|
23
|
-
"AGENTS.md",
|
|
24
23
|
"README.md",
|
|
25
24
|
"LICENSE"
|
|
26
25
|
],
|
|
27
26
|
"dependencies": {
|
|
28
|
-
"@agentshouse/mdruntime": "0.1.0-
|
|
27
|
+
"@agentshouse/mdruntime": "0.1.0-c1e8a8738a009"
|
|
28
|
+
},
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+https://github.com/agentshouse/core.git",
|
|
32
|
+
"directory": "mdruntime/packages/mdruntime-adapter"
|
|
29
33
|
}
|
|
30
34
|
}
|