@agentshouse/mdruntime-adapter 0.1.0-c13e5bc38b145 → 0.1.0-c159093d95310
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/AGENTS.md +61 -46
- package/dist/actions.d.ts +9 -5
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +55 -96
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +141 -164
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/part.d.ts +13 -0
- package/dist/part.d.ts.map +1 -0
- package/dist/part.js +80 -0
- package/dist/read.d.ts +30 -21
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +161 -76
- package/dist/referrer.d.ts +2 -0
- package/dist/referrer.d.ts.map +1 -1
- package/dist/referrer.js +8 -2
- package/dist/room-types.d.ts +6 -0
- package/dist/room-types.d.ts.map +1 -0
- package/dist/room-types.js +66 -0
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +58 -72
- package/dist/stream.d.ts +1 -0
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +16 -1
- package/dist/transport.d.ts +8 -6
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +1 -0
- package/dist/upload.d.ts +12 -0
- package/dist/upload.d.ts.map +1 -0
- package/dist/upload.js +52 -0
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +11 -4
- package/package.json +2 -2
- package/dist/handed.d.ts +0 -15
- package/dist/handed.d.ts.map +0 -1
- package/dist/handed.js +0 -45
package/dist/site.js
CHANGED
|
@@ -2,9 +2,10 @@ 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
4
|
import { partModels, streamedModels, viewModels } from './model.js';
|
|
5
|
-
import { advancedScope, bootstrapping,
|
|
6
|
-
import {
|
|
5
|
+
import { advancedScope, bootstrapping, emptyScope, housePart, parseEnumeration, parseSiteParted, refreshFrom, viewOf, wholeView, } from './read.js';
|
|
6
|
+
import { PART_ATTEMPTS, unverifiedPart } from './part.js';
|
|
7
7
|
import { classifyDoor, classifyRead, discoveryFailure } from './refusal.js';
|
|
8
|
+
import { HOUSE_ROOM_TYPES } from './room-types.js';
|
|
8
9
|
import { houseNotifications } from './stream.js';
|
|
9
10
|
import { SITE_DOOR_BOOTSTRAP, SITE_DOOR_DISCOVER, SITE_DOOR_ENUMERATE, SITE_DOOR_SUBMIT, SITE_FILE_RECORD, SITE_FILES, } from './transport.js';
|
|
10
11
|
import { houseReferrer } from './referrer.js';
|
|
@@ -30,6 +31,7 @@ function settled(refused) {
|
|
|
30
31
|
export function createSiteAdapter(transport, snapshot = false) {
|
|
31
32
|
const notifications = houseNotifications(transport, 'site');
|
|
32
33
|
const tracked = new Map();
|
|
34
|
+
const expired = new Map();
|
|
33
35
|
function published(referrer) {
|
|
34
36
|
const named = houseReferrer(referrer, tracked);
|
|
35
37
|
return named === null || !tracked.has(named.locator) ? null : named;
|
|
@@ -69,67 +71,42 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
69
71
|
const first = await enumerated(entry, from);
|
|
70
72
|
return 'kind' in first ? first : wholeView(first, (page) => enumerated(entry, from, page));
|
|
71
73
|
}
|
|
72
|
-
async function
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
...(offset === null ? [] : [`offset=${offset}`]),
|
|
76
|
-
];
|
|
77
|
-
const answer = await transport.read(`${SITE_DOOR_BOOTSTRAP}${entry.authority}${query.length === 0 ? '' : `?${query.join('&')}`}`);
|
|
74
|
+
async function partedRoom(entry) {
|
|
75
|
+
const cut = expired.get(entry.locator);
|
|
76
|
+
const answer = await transport.read(`${SITE_DOOR_BOOTSTRAP}${entry.authority}${cut === undefined ? '' : `?expired=${cut}`}`);
|
|
78
77
|
const classified = classifyDoor(answer.status, answer.body, entry.locator);
|
|
79
78
|
if (classified !== null)
|
|
80
|
-
return
|
|
81
|
-
const
|
|
82
|
-
return
|
|
79
|
+
return classified;
|
|
80
|
+
const room = parseSiteParted(answer.body);
|
|
81
|
+
return room === null || room.anchor !== entry.authority ? UNCERTAIN : room;
|
|
83
82
|
}
|
|
84
|
-
async function
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (piece === undefined ||
|
|
96
|
-
part.scope.contents.length !== 1 ||
|
|
97
|
-
piece.path !== path ||
|
|
98
|
-
piece.content.length === 0) {
|
|
99
|
-
return UNCERTAIN;
|
|
100
|
-
}
|
|
101
|
-
text += piece.content;
|
|
102
|
-
const more = siteBootstrapOffset(part.body);
|
|
103
|
-
if (more === null)
|
|
104
|
-
break;
|
|
105
|
-
if (more !== text.length)
|
|
106
|
-
return UNCERTAIN;
|
|
83
|
+
async function fetchedPart(entry, room, listed) {
|
|
84
|
+
for (let attempt = 0; attempt < PART_ATTEMPTS; attempt += 1) {
|
|
85
|
+
const answer = await transport.read(`${SITE_DOOR_BOOTSTRAP}${entry.authority}?part=${encodeURIComponent(listed.part)}`);
|
|
86
|
+
const failure = classifyRead(answer.status, answer.body, entry.locator);
|
|
87
|
+
if (failure?.kind === 'beyond-horizon')
|
|
88
|
+
expired.set(entry.locator, room.position);
|
|
89
|
+
if (failure !== null)
|
|
90
|
+
return failure;
|
|
91
|
+
const scope = await housePart(room, answer.body, listed, 'site');
|
|
92
|
+
if (scope !== null)
|
|
93
|
+
return scope;
|
|
107
94
|
}
|
|
108
|
-
|
|
109
|
-
if (file === undefined || (await sha256Hex(text)) !== file.version)
|
|
110
|
-
return UNCERTAIN;
|
|
111
|
-
return { ...scope, contents: [...scope.contents.slice(0, -1), { path, content: text }] };
|
|
95
|
+
return unverifiedPart(entry.locator);
|
|
112
96
|
}
|
|
113
|
-
async function caughtUp(entry,
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const scope = await assembled(entry, part.scope, next, offset);
|
|
123
|
-
return 'kind' in scope ? { failure: scope } : { scope, next };
|
|
124
|
-
}
|
|
125
|
-
const { scope } = part;
|
|
126
|
-
if (after !== null || next !== null || roomVersion(scope) === roomVersion(entry)) {
|
|
127
|
-
return { scope, next };
|
|
128
|
-
}
|
|
97
|
+
async function caughtUp(entry, continued) {
|
|
98
|
+
const listed = continued.room.parts[continued.next];
|
|
99
|
+
const scope = listed === undefined
|
|
100
|
+
? emptyScope(continued.room)
|
|
101
|
+
: await fetchedPart(entry, continued.room, listed);
|
|
102
|
+
if ('kind' in scope)
|
|
103
|
+
return scope;
|
|
104
|
+
if (continued.room.parts.length > 1 || roomVersion(scope) === roomVersion(entry))
|
|
105
|
+
return scope;
|
|
129
106
|
const view = await enumeration(entry, scope);
|
|
130
107
|
if ('kind' in view)
|
|
131
|
-
return
|
|
132
|
-
return
|
|
108
|
+
return settled(view);
|
|
109
|
+
return stepped(advancedScope(scope, view));
|
|
133
110
|
}
|
|
134
111
|
async function refreshed(entry, fromRoomVersion) {
|
|
135
112
|
const from = logPosition(fromRoomVersion);
|
|
@@ -153,6 +130,7 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
153
130
|
return {
|
|
154
131
|
localSaves: true,
|
|
155
132
|
exhaustiveDiscovery: true,
|
|
133
|
+
roomTypes: HOUSE_ROOM_TYPES,
|
|
156
134
|
async authorize() {
|
|
157
135
|
return {};
|
|
158
136
|
},
|
|
@@ -175,23 +153,31 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
175
153
|
const entry = tracked.get(request.locator);
|
|
176
154
|
if (entry === undefined)
|
|
177
155
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
156
|
+
let continued;
|
|
157
|
+
if (request.pageToken === undefined) {
|
|
158
|
+
const room = await partedRoom(entry);
|
|
159
|
+
if ('kind' in room)
|
|
160
|
+
return room;
|
|
161
|
+
continued = { room, next: 0, seen: [] };
|
|
162
|
+
}
|
|
163
|
+
else
|
|
164
|
+
continued = JSON.parse(request.pageToken);
|
|
165
|
+
const scope = await caughtUp(entry, continued);
|
|
166
|
+
if ('kind' in scope)
|
|
167
|
+
return scope;
|
|
168
|
+
notifications.reach(entry.authority, scope);
|
|
169
|
+
const next = continued.next + 1;
|
|
170
|
+
const more = next < continued.room.parts.length;
|
|
185
171
|
const seen = [
|
|
186
|
-
...
|
|
187
|
-
...entry.schemas.filter((schema) =>
|
|
172
|
+
...continued.seen,
|
|
173
|
+
...entry.schemas.filter((schema) => scope.files.some((file) => file.path === schema)),
|
|
188
174
|
];
|
|
189
|
-
const models = await partModels(
|
|
190
|
-
const
|
|
175
|
+
const models = await partModels(scope, entry, new Set(seen), !more);
|
|
176
|
+
const { folders: _folders, ...page } = await stepped(bootstrapping(scope));
|
|
191
177
|
return {
|
|
192
|
-
...
|
|
178
|
+
...page,
|
|
193
179
|
...(models === undefined ? {} : { models }),
|
|
194
|
-
...(
|
|
180
|
+
...(more ? { pageToken: JSON.stringify({ ...continued, next, seen }) } : {}),
|
|
195
181
|
};
|
|
196
182
|
},
|
|
197
183
|
async refresh(_authorization, request) {
|
|
@@ -220,8 +206,8 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
220
206
|
const read = await transport.download(route);
|
|
221
207
|
if (read.status === 404)
|
|
222
208
|
return unfound();
|
|
223
|
-
return read.status === 200 && read.
|
|
224
|
-
? { kind: 'binary',
|
|
209
|
+
return read.status === 200 && read.body !== null
|
|
210
|
+
? { kind: 'binary', body: read.body, mediaType: read.mediaType }
|
|
225
211
|
: UNCERTAIN;
|
|
226
212
|
},
|
|
227
213
|
async link(_authorization, request) {
|
|
@@ -239,7 +225,7 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
239
225
|
if (named === null)
|
|
240
226
|
return null;
|
|
241
227
|
const { path } = named.referrer;
|
|
242
|
-
return {
|
|
228
|
+
return { locator: named.locator, ...(path === undefined ? {} : { path }) };
|
|
243
229
|
},
|
|
244
230
|
reached(locator, version, target) {
|
|
245
231
|
return reachedVersion(version, target, tracked.get(locator)?.logEpoch);
|
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,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E,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,6 +581,10 @@ 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) {
|
package/dist/transport.d.ts
CHANGED
|
@@ -15,23 +15,24 @@ 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_FINISH = "/door/files/finish";
|
|
18
19
|
export declare const SITE_FILES = "/_house/files/";
|
|
19
20
|
export declare const SITE_FILE_RECORD = "record";
|
|
20
|
-
export type HouseByteAct = 'authored_batch_upload'
|
|
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;
|
|
@@ -170,6 +171,7 @@ export type HouseDoor = {
|
|
|
170
171
|
};
|
|
171
172
|
export type HouseTransport = HouseDoor & {
|
|
172
173
|
transfer(request: HouseByteTransfer): Promise<HouseDoorAnswer>;
|
|
174
|
+
put(url: string, body: Blob): Promise<number>;
|
|
173
175
|
download(url: string): Promise<HouseBytesAnswer>;
|
|
174
176
|
};
|
|
175
177
|
export type HouseSiteTransport = HouseDoor & {
|
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,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD,eAAO,MAAM,UAAU,mBAAmB,CAAC;AAE3C,eAAO,MAAM,gBAAgB,WAAW,CAAC;AAEzC,MAAM,MAAM,YAAY,GAAG,uBAAuB,
|
|
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,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MAAM,IAAI,CAAC;IAChE,MAAM,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAC5D,MAAM,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CAC7D,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC7D,MAAM,EAAE,WAAW,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG;IACvC,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC/D,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC9C,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
|
@@ -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_FINISH = '/door/files/finish';
|
|
12
13
|
export const SITE_FILES = '/_house/files/';
|
|
13
14
|
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":"AAAA,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;AAkBF,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,CAQ9D;AAWD,wBAAsB,cAAc,CAClC,SAAS,EAAE,cAAc,EACzB,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAgBjC"}
|
package/dist/upload.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { DOOR_FILES_FINISH } from './transport.js';
|
|
2
|
+
// A finishing call that finds House still reading the stored bytes back answers checking; the runtime asks again after five seconds, as the Kit does.
|
|
3
|
+
const CHECKING_WAIT_MS = 5_000;
|
|
4
|
+
const FINISHING_ROUNDS = 24;
|
|
5
|
+
function record(value) {
|
|
6
|
+
return value !== null && typeof value === 'object' ? value : {};
|
|
7
|
+
}
|
|
8
|
+
function part(value) {
|
|
9
|
+
const { part: number, url } = record(value);
|
|
10
|
+
return Number.isSafeInteger(number) && number > 0 && typeof url === 'string'
|
|
11
|
+
? { part: number, url }
|
|
12
|
+
: null;
|
|
13
|
+
}
|
|
14
|
+
export function houseUpload(value) {
|
|
15
|
+
const { id, part_bytes: partBytes, parts } = record(value);
|
|
16
|
+
if (typeof id !== 'string' || !Number.isSafeInteger(partBytes) || partBytes <= 0)
|
|
17
|
+
return null;
|
|
18
|
+
if (!Array.isArray(parts))
|
|
19
|
+
return null;
|
|
20
|
+
const named = parts.map(part);
|
|
21
|
+
if (named.some((one) => one === null))
|
|
22
|
+
return null;
|
|
23
|
+
return { id, partBytes: partBytes, parts: named };
|
|
24
|
+
}
|
|
25
|
+
async function sent(transport, upload, blob) {
|
|
26
|
+
for (const { part: number, url } of upload.parts) {
|
|
27
|
+
const start = (number - 1) * upload.partBytes;
|
|
28
|
+
if ((await transport.put(url, blob.slice(start, start + upload.partBytes))) !== 200)
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
export async function finishedUpload(transport, first, blob) {
|
|
34
|
+
let upload = first;
|
|
35
|
+
for (let round = 0; round < FINISHING_ROUNDS; round += 1) {
|
|
36
|
+
if (!(await sent(transport, upload, blob)))
|
|
37
|
+
return null;
|
|
38
|
+
const answer = await transport.door(DOOR_FILES_FINISH, { upload: upload.id });
|
|
39
|
+
if (answer.status !== 200)
|
|
40
|
+
return answer;
|
|
41
|
+
const missing = houseUpload(record(answer.body).upload);
|
|
42
|
+
if (missing !== null) {
|
|
43
|
+
upload = missing;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (record(answer.body).checking !== true)
|
|
47
|
+
return answer;
|
|
48
|
+
upload = { ...upload, parts: [] };
|
|
49
|
+
await new Promise((resolve) => setTimeout(resolve, CHECKING_WAIT_MS));
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
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,EAML,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,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,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,wBAAgB,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,aAAa,CAK/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AI,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;AAiCD,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
|
@@ -338,12 +338,19 @@ export function revisionBody(input) {
|
|
|
338
338
|
function revisionAuthor(entry) {
|
|
339
339
|
const user = entry.author_user;
|
|
340
340
|
const site = entry.author_site;
|
|
341
|
-
const
|
|
342
|
-
|
|
341
|
+
const siteName = entry.author_site_name;
|
|
342
|
+
const inbox = entry.author_inbox;
|
|
343
|
+
const inboxName = entry.author_inbox_name;
|
|
344
|
+
const named = [site, siteName, inbox, inboxName].filter((held) => held !== undefined);
|
|
345
|
+
if (typeof user === 'string' && named.length === 0)
|
|
343
346
|
return { kind: 'user', id: user };
|
|
347
|
+
if (user !== null || named.length !== 2)
|
|
348
|
+
return null;
|
|
349
|
+
if (typeof site === 'string' && typeof siteName === 'string') {
|
|
350
|
+
return { kind: 'site', id: site, name: siteName };
|
|
344
351
|
}
|
|
345
|
-
if (
|
|
346
|
-
return { kind: '
|
|
352
|
+
if (typeof inbox === 'string' && typeof inboxName === 'string') {
|
|
353
|
+
return { kind: 'inbox', id: inbox, name: inboxName };
|
|
347
354
|
}
|
|
348
355
|
return null;
|
|
349
356
|
}
|
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-c159093d95310",
|
|
4
4
|
"description": "Agents House Adapter for the MD Runtime",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -25,6 +25,6 @@
|
|
|
25
25
|
"LICENSE"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@agentshouse/mdruntime": "0.1.0-
|
|
28
|
+
"@agentshouse/mdruntime": "0.1.0-cf890bb538119"
|
|
29
29
|
}
|
|
30
30
|
}
|
package/dist/handed.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { type HeldRoom, type MutationResult } from '@agentshouse/mdruntime';
|
|
2
|
-
import type { HouseScope, HouseView } from './read.js';
|
|
3
|
-
import type { StreamedAdvancement } from './stream.js';
|
|
4
|
-
export type HandedRoom = {
|
|
5
|
-
roomVersion: string;
|
|
6
|
-
revisions: Readonly<Record<string, string>>;
|
|
7
|
-
};
|
|
8
|
-
export declare function scopeHanded(scope: HouseScope): Generator<number, HandedRoom, void>;
|
|
9
|
-
export declare function heldHanded(held: HeldRoom): HandedRoom;
|
|
10
|
-
export declare function acceptedHanded(held: HandedRoom, accepted: Extract<MutationResult, {
|
|
11
|
-
kind: 'accepted';
|
|
12
|
-
}>, roomVersion: string): Generator<number, HandedRoom, void>;
|
|
13
|
-
export declare function enumeratedHanded(view: HouseView, earlier: HandedRoom | undefined): Generator<number, HandedRoom, void>;
|
|
14
|
-
export declare function streamedHanded(held: HandedRoom, advanced: StreamedAdvancement): Generator<number, HandedRoom, void>;
|
|
15
|
-
//# sourceMappingURL=handed.d.ts.map
|
package/dist/handed.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handed.d.ts","sourceRoot":"","sources":["../src/handed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,QAAQ,EAAE,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACjG,OAAO,KAAK,EAAqB,UAAU,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGvD,MAAM,MAAM,UAAU,GAAG;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAC7C,CAAC;AAMF,wBAAiB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,CAEnF;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,QAAQ,GAAG,UAAU,CAErD;AAED,wBAAiB,cAAc,CAC7B,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,OAAO,CAAC,cAAc,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,EACvD,WAAW,EAAE,MAAM,GAClB,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,CAKrC;AAgBD,wBAAiB,gBAAgB,CAC/B,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,UAAU,GAAG,SAAS,GAC9B,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,CAKrC;AAED,wBAAiB,cAAc,CAC7B,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,mBAAmB,GAC5B,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,CAMrC"}
|
package/dist/handed.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { entriesIn, patching } from '@agentshouse/mdruntime';
|
|
2
|
-
import { roomVersion } from './version.js';
|
|
3
|
-
function* revised(files) {
|
|
4
|
-
for (const { path, revision } of files)
|
|
5
|
-
if (revision !== undefined)
|
|
6
|
-
yield [path, revision];
|
|
7
|
-
}
|
|
8
|
-
export function* scopeHanded(scope) {
|
|
9
|
-
return { roomVersion: roomVersion(scope), revisions: yield* patching({}, revised(scope.files)) };
|
|
10
|
-
}
|
|
11
|
-
export function heldHanded(held) {
|
|
12
|
-
return { roomVersion: held.roomVersion, revisions: held.revisions };
|
|
13
|
-
}
|
|
14
|
-
export function* acceptedHanded(held, accepted, roomVersion) {
|
|
15
|
-
return {
|
|
16
|
-
roomVersion,
|
|
17
|
-
revisions: yield* patching(held.revisions, entriesIn(accepted.revisions), accepted.removals),
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
function* kept(view) {
|
|
21
|
-
for (const change of view.changes) {
|
|
22
|
-
if (!('removed' in change) && change.revision !== undefined) {
|
|
23
|
-
yield [change.path, change.revision];
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
function* dropped(view) {
|
|
28
|
-
for (const change of view.changes) {
|
|
29
|
-
if ('removed' in change || change.revision === undefined)
|
|
30
|
-
yield change.path;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
export function* enumeratedHanded(view, earlier) {
|
|
34
|
-
return {
|
|
35
|
-
roomVersion: roomVersion(view),
|
|
36
|
-
revisions: yield* patching(earlier?.revisions ?? {}, kept(view), dropped(view)),
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
export function* streamedHanded(held, advanced) {
|
|
40
|
-
const { page } = advanced;
|
|
41
|
-
return {
|
|
42
|
-
roomVersion: page.roomVersion,
|
|
43
|
-
revisions: yield* patching(held.revisions, entriesIn(page.revisions), page.removals),
|
|
44
|
-
};
|
|
45
|
-
}
|