@agentshouse/mdruntime-adapter 0.1.0-cd59fd8945dcb → 0.1.0-ce3fe65a95f49
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 +139 -127
- package/dist/actions.d.ts +22 -0
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +49 -5
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +102 -27
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +5 -2
- package/dist/handed.d.ts +15 -0
- package/dist/handed.d.ts.map +1 -0
- package/dist/handed.js +38 -0
- 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 +0 -1
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +0 -3
- package/dist/read.d.ts +9 -6
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +73 -49
- package/dist/referrer.d.ts +7 -0
- package/dist/referrer.d.ts.map +1 -0
- package/dist/referrer.js +35 -0
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +2 -1
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +107 -18
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +125 -10
- package/dist/transport.d.ts +25 -5
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +3 -0
- package/dist/write.d.ts +2 -9
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +54 -5
- package/package.json +2 -3
- package/dist/links.d.ts +0 -20
- package/dist/links.d.ts.map +0 -1
- package/dist/links.js +0 -104
package/dist/referrer.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
function fields(value) {
|
|
2
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
3
|
+
? value
|
|
4
|
+
: null;
|
|
5
|
+
}
|
|
6
|
+
function named(held, ...keys) {
|
|
7
|
+
const present = Object.keys(held);
|
|
8
|
+
return (present.length === keys.length &&
|
|
9
|
+
keys.every((key) => typeof held[key] === 'string' && held[key] !== ''));
|
|
10
|
+
}
|
|
11
|
+
export function houseReferrer(referrer, tracked) {
|
|
12
|
+
const held = fields(referrer);
|
|
13
|
+
if (held === null)
|
|
14
|
+
return null;
|
|
15
|
+
if (named(held, 'room', 'path')) {
|
|
16
|
+
const entry = tracked.get(held.room);
|
|
17
|
+
if (entry === undefined)
|
|
18
|
+
return null;
|
|
19
|
+
return {
|
|
20
|
+
locator: entry.locator,
|
|
21
|
+
referrer: { room_ref: entry.authority, path: held.path },
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
if (named(held, 'room_ref', 'record')) {
|
|
25
|
+
const roomRef = held.room_ref;
|
|
26
|
+
const entry = [...tracked.values()].find((candidate) => candidate.authority === roomRef);
|
|
27
|
+
return {
|
|
28
|
+
locator: entry?.locator ?? roomRef,
|
|
29
|
+
referrer: { room_ref: roomRef, record: held.record },
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
if (named(held, 'message'))
|
|
33
|
+
return { locator: '', referrer: { message: held.message } };
|
|
34
|
+
return null;
|
|
35
|
+
}
|
package/dist/refusal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refusal.d.ts","sourceRoot":"","sources":["../src/refusal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,aAAa,EACd,MAAM,wBAAwB,CAAC;AAEhC,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAOjE;AAED,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,EAC7B,OAAO,EAAE,eAAe,GACvB,aAAa,CAEf;
|
|
1
|
+
{"version":3,"file":"refusal.d.ts","sourceRoot":"","sources":["../src/refusal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,aAAa,EACd,MAAM,wBAAwB,CAAC;AAEhC,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAOjE;AAED,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,EAC7B,OAAO,EAAE,eAAe,GACvB,aAAa,CAEf;AAqBD,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,GACd,cAAc,GAAG,IAAI,CAMvB;AAED,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,GACd,cAAc,GAAG;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAAG,IAAI,CAGpD;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,cAAc,GAAG,IAAI,CAQrF"}
|
package/dist/refusal.js
CHANGED
|
@@ -18,8 +18,9 @@ function doorFailure(status, body) {
|
|
|
18
18
|
const refusal = doorRefusal(body);
|
|
19
19
|
if (status === 401)
|
|
20
20
|
return { kind: 'revoked-authorization' };
|
|
21
|
-
if (refusal?.retryable === true)
|
|
21
|
+
if (refusal?.retryable === true || refusal?.code === 'update_required') {
|
|
22
22
|
return { kind: 'transport-uncertainty' };
|
|
23
|
+
}
|
|
23
24
|
if (status === 404 || refusal?.code === 'room_not_found')
|
|
24
25
|
return { kind: 'room-not-readable' };
|
|
25
26
|
if (status < 400)
|
package/dist/site.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,
|
|
1
|
+
{"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAOR,MAAM,wBAAwB,CAAC;AAyBhC,OAAO,EAOL,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AAmCxB,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,kBAAkB,GAAG,OAAO,CAqPxE"}
|
package/dist/site.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { actionOutcome } from './actions.js';
|
|
1
|
+
import { actionOutcome, SITE_SUBMIT } from './actions.js';
|
|
2
2
|
import { mapDiscovery, parseSiteDiscovery, siteCapabilities, siteTracked, } from './discovery.js';
|
|
3
|
-
import {
|
|
4
|
-
import { advancedScope, bootstrapOf, parseEnumeration, parseSiteBootstrap, refreshFrom, viewOf, } from './read.js';
|
|
3
|
+
import { partModels, streamedModels, viewModels } from './model.js';
|
|
4
|
+
import { advancedScope, bootstrapOf, parseEnumeration, parseSiteBootstrap, refreshFrom, siteBootstrapNext, siteBootstrapOffset, viewOf, } from './read.js';
|
|
5
|
+
import { sha256Hex } from './digest.js';
|
|
5
6
|
import { classifyDoor, classifyRead, discoveryFailure } from './refusal.js';
|
|
6
7
|
import { houseNotifications } from './stream.js';
|
|
7
|
-
import { SITE_DOOR_BOOTSTRAP, SITE_DOOR_DISCOVER, SITE_DOOR_ENUMERATE, SITE_DOOR_SUBMIT, } from './transport.js';
|
|
8
|
+
import { SITE_DOOR_BOOTSTRAP, SITE_DOOR_DISCOVER, SITE_DOOR_ENUMERATE, SITE_DOOR_SUBMIT, SITE_FILE_RECORD, SITE_FILES, } from './transport.js';
|
|
9
|
+
import { houseReferrer } from './referrer.js';
|
|
8
10
|
import { followsVersion, logPosition, presented, reachedVersion, roomVersion, } from './version.js';
|
|
9
11
|
const UNCERTAIN = { kind: 'transport-uncertainty' };
|
|
10
12
|
function siteRoom(tracked) {
|
|
@@ -24,6 +26,10 @@ function settled(refused) {
|
|
|
24
26
|
export function createSiteAdapter(transport) {
|
|
25
27
|
const notifications = houseNotifications(transport, 'site');
|
|
26
28
|
const tracked = new Map();
|
|
29
|
+
function published(referrer) {
|
|
30
|
+
const named = houseReferrer(referrer, tracked);
|
|
31
|
+
return named === null || !tracked.has(named.locator) ? null : named;
|
|
32
|
+
}
|
|
27
33
|
async function enumeration(entry, from) {
|
|
28
34
|
const answer = await transport.door(SITE_DOOR_ENUMERATE, {
|
|
29
35
|
positions: [presented(entry.authority, from)],
|
|
@@ -33,23 +39,70 @@ export function createSiteAdapter(transport) {
|
|
|
33
39
|
return classified;
|
|
34
40
|
return parseEnumeration(answer.body, 'site') ?? UNCERTAIN;
|
|
35
41
|
}
|
|
36
|
-
async function
|
|
37
|
-
const
|
|
42
|
+
async function bootstrapPart(entry, after, offset) {
|
|
43
|
+
const query = [
|
|
44
|
+
...(after === null ? [] : [`after=${encodeURIComponent(after)}`]),
|
|
45
|
+
...(offset === null ? [] : [`offset=${offset}`]),
|
|
46
|
+
];
|
|
47
|
+
const answer = await transport.read(`${SITE_DOOR_BOOTSTRAP}${entry.authority}${query.length === 0 ? '' : `?${query.join('&')}`}`);
|
|
38
48
|
const classified = classifyDoor(answer.status, answer.body, entry.locator);
|
|
39
49
|
if (classified !== null)
|
|
40
50
|
return { failure: classified };
|
|
41
51
|
const scope = parseSiteBootstrap(answer.body);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
52
|
+
return scope === null ? { failure: UNCERTAIN } : { body: answer.body, scope };
|
|
53
|
+
}
|
|
54
|
+
async function assembled(entry, scope, path, offset) {
|
|
55
|
+
const opened = scope.contents.at(-1);
|
|
56
|
+
if (opened === undefined || opened.path !== path || opened.content.length !== offset) {
|
|
57
|
+
return UNCERTAIN;
|
|
58
|
+
}
|
|
59
|
+
let text = opened.content;
|
|
60
|
+
for (;;) {
|
|
61
|
+
const part = await bootstrapPart(entry, path, text.length);
|
|
62
|
+
if ('failure' in part)
|
|
63
|
+
return part.failure;
|
|
64
|
+
const [piece] = part.scope.contents;
|
|
65
|
+
if (piece === undefined ||
|
|
66
|
+
part.scope.contents.length !== 1 ||
|
|
67
|
+
piece.path !== path ||
|
|
68
|
+
piece.content.length === 0) {
|
|
69
|
+
return UNCERTAIN;
|
|
70
|
+
}
|
|
71
|
+
text += piece.content;
|
|
72
|
+
const more = siteBootstrapOffset(part.body);
|
|
73
|
+
if (more === null)
|
|
74
|
+
break;
|
|
75
|
+
if (more !== text.length)
|
|
76
|
+
return UNCERTAIN;
|
|
77
|
+
}
|
|
78
|
+
const file = scope.files.find((held) => held.path === path);
|
|
79
|
+
if (file === undefined || (await sha256Hex(text)) !== file.version)
|
|
80
|
+
return UNCERTAIN;
|
|
81
|
+
return { ...scope, contents: [...scope.contents.slice(0, -1), { path, content: text }] };
|
|
82
|
+
}
|
|
83
|
+
async function caughtUp(entry, after) {
|
|
84
|
+
const part = await bootstrapPart(entry, after, null);
|
|
85
|
+
if ('failure' in part)
|
|
86
|
+
return part;
|
|
87
|
+
const next = siteBootstrapNext(part.body);
|
|
88
|
+
const offset = siteBootstrapOffset(part.body);
|
|
89
|
+
if (offset !== null) {
|
|
90
|
+
if (next === null)
|
|
91
|
+
return { failure: UNCERTAIN };
|
|
92
|
+
const scope = await assembled(entry, part.scope, next, offset);
|
|
93
|
+
return 'kind' in scope ? { failure: scope } : { scope, next };
|
|
94
|
+
}
|
|
95
|
+
const { scope } = part;
|
|
96
|
+
if (after !== null || next !== null || roomVersion(scope) === roomVersion(entry)) {
|
|
97
|
+
return { scope, next };
|
|
98
|
+
}
|
|
46
99
|
const found = await enumeration(entry, scope);
|
|
47
100
|
if ('kind' in found)
|
|
48
101
|
return { failure: settled(found) };
|
|
49
102
|
const view = viewOf(found, entry);
|
|
50
103
|
if (view === undefined)
|
|
51
104
|
return { failure: { kind: 'room-not-readable', locator: entry.locator } };
|
|
52
|
-
return { scope: advancedScope(scope, view) };
|
|
105
|
+
return { scope: advancedScope(scope, view), next: null };
|
|
53
106
|
}
|
|
54
107
|
async function refreshed(entry, fromRoomVersion) {
|
|
55
108
|
const from = logPosition(fromRoomVersion);
|
|
@@ -97,14 +150,24 @@ export function createSiteAdapter(transport) {
|
|
|
97
150
|
const entry = tracked.get(request.locator);
|
|
98
151
|
if (entry === undefined)
|
|
99
152
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
153
|
+
const continued = request.pageToken === undefined
|
|
154
|
+
? null
|
|
155
|
+
: JSON.parse(request.pageToken);
|
|
156
|
+
const held = await caughtUp(entry, continued?.after ?? null);
|
|
103
157
|
if ('failure' in held)
|
|
104
158
|
return held.failure;
|
|
105
159
|
notifications.reach(entry.authority, held.scope);
|
|
106
|
-
const
|
|
107
|
-
|
|
160
|
+
const seen = [
|
|
161
|
+
...(continued?.seen ?? []),
|
|
162
|
+
...entry.schemas.filter((schema) => held.scope.files.some((file) => file.path === schema)),
|
|
163
|
+
];
|
|
164
|
+
const models = await partModels(held.scope, entry, new Set(seen), held.next === null);
|
|
165
|
+
const continuation = held.next === null ? null : { after: held.next, seen };
|
|
166
|
+
return {
|
|
167
|
+
...bootstrapOf(held.scope),
|
|
168
|
+
...(models === undefined ? {} : { models }),
|
|
169
|
+
...(continuation === null ? {} : { pageToken: JSON.stringify(continuation) }),
|
|
170
|
+
};
|
|
108
171
|
},
|
|
109
172
|
async refresh(_authorization, request) {
|
|
110
173
|
const entry = tracked.get(request.locator);
|
|
@@ -120,6 +183,32 @@ export function createSiteAdapter(transport) {
|
|
|
120
183
|
async history() {
|
|
121
184
|
return { kind: 'no-history' };
|
|
122
185
|
},
|
|
186
|
+
async binary(_authorization, request) {
|
|
187
|
+
const named = published(request.kind === 'path' ? { room: request.locator, path: request.path } : request.referrer);
|
|
188
|
+
if (named === null) {
|
|
189
|
+
return { kind: 'rejected', code: 'referrer_unknown', fields: {}, retryable: false };
|
|
190
|
+
}
|
|
191
|
+
if (request.fileRef === undefined) {
|
|
192
|
+
return { kind: 'rejected', code: 'file_not_found', fields: {}, retryable: false };
|
|
193
|
+
}
|
|
194
|
+
const { room_ref, path, record } = named.referrer;
|
|
195
|
+
const read = await transport.download(`${SITE_FILES}${room_ref}/${encodeURIComponent(request.fileRef)}/${path === undefined
|
|
196
|
+
? `${SITE_FILE_RECORD}/${encodeURIComponent(record)}`
|
|
197
|
+
: encodeURIComponent(path)}`);
|
|
198
|
+
if (read.status === 404) {
|
|
199
|
+
return { kind: 'rejected', code: 'file_not_found', fields: {}, retryable: false };
|
|
200
|
+
}
|
|
201
|
+
return read.status === 200 && read.blob !== null
|
|
202
|
+
? { kind: 'binary', blob: read.blob }
|
|
203
|
+
: UNCERTAIN;
|
|
204
|
+
},
|
|
205
|
+
referrerScope(referrer) {
|
|
206
|
+
const named = published(referrer);
|
|
207
|
+
if (named === null)
|
|
208
|
+
return null;
|
|
209
|
+
const { path } = named.referrer;
|
|
210
|
+
return { kind: 'room', locator: named.locator, ...(path === undefined ? {} : { path }) };
|
|
211
|
+
},
|
|
123
212
|
reached(locator, version, target) {
|
|
124
213
|
return reachedVersion(version, target, tracked.get(locator)?.logEpoch);
|
|
125
214
|
},
|
|
@@ -127,7 +216,7 @@ export function createSiteAdapter(transport) {
|
|
|
127
216
|
return followsVersion(version, next);
|
|
128
217
|
},
|
|
129
218
|
async action(_authorization, request) {
|
|
130
|
-
if (request.name !==
|
|
219
|
+
if (request.name !== SITE_SUBMIT) {
|
|
131
220
|
return {
|
|
132
221
|
kind: 'rejected',
|
|
133
222
|
code: 'action-unimplemented',
|
|
@@ -137,7 +226,7 @@ export function createSiteAdapter(transport) {
|
|
|
137
226
|
}
|
|
138
227
|
if (!transport.online())
|
|
139
228
|
return UNCERTAIN;
|
|
140
|
-
return actionOutcome(await transport.door(SITE_DOOR_SUBMIT, request.input),
|
|
229
|
+
return actionOutcome(await transport.door(SITE_DOOR_SUBMIT, request.input), SITE_SUBMIT);
|
|
141
230
|
},
|
|
142
231
|
roomStream: {
|
|
143
232
|
hold(rooms) {
|
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,KAAK,
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,kBAAkB,EAElB,WAAW,EACX,eAAe,EAEf,iBAAiB,EAElB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EAEb,SAAS,EAET,gBAAgB,EAEjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAwB7D,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,SAAS,gBAAgB,EAAE,CAAC;IACrC,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,GAAG,MAAM,IAAI,CAAC;IAC9D,IAAI,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,GAAG,IAAI,CAAC;IAC5C,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,OAAO,CACL,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,WAAW,EACjB,KAAK,CAAC,EAAE,YAAY,GACnB,mBAAmB,GAAG,IAAI,CAAC;IAC9B,aAAa,EAAE,kBAAkB,CAAC;IAClC,WAAW,EAAE,iBAAiB,CAAC;CAChC,CAAC;AA0DF,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,GAAG,kBAAkB,CAoX5F"}
|
package/dist/stream.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { acceptedMessage } from './actions.js';
|
|
2
|
-
import {
|
|
2
|
+
import { sha256Hex } from './digest.js';
|
|
3
|
+
import { binaryFileOf, headChange } from './read.js';
|
|
3
4
|
import { roomVersion } from './version.js';
|
|
4
5
|
const HELD_FRAMES_MAX = 256;
|
|
5
6
|
function turnOperation(frame) {
|
|
@@ -21,9 +22,52 @@ function position(value) {
|
|
|
21
22
|
return null;
|
|
22
23
|
return BigInt(value);
|
|
23
24
|
}
|
|
25
|
+
function assembled(entries) {
|
|
26
|
+
const whole = [];
|
|
27
|
+
let open = null;
|
|
28
|
+
for (const entry of entries) {
|
|
29
|
+
if (entry.kind === 'piece') {
|
|
30
|
+
if (open === null || open.entry.path !== entry.path || entry.text === undefined)
|
|
31
|
+
return null;
|
|
32
|
+
open.texts.push(entry.text);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
if (open !== null)
|
|
36
|
+
return null;
|
|
37
|
+
if (entry.continued !== true) {
|
|
38
|
+
whole.push(entry);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (entry.text === undefined)
|
|
42
|
+
return null;
|
|
43
|
+
open = { entry, texts: [entry.text] };
|
|
44
|
+
}
|
|
45
|
+
if (entry.continued === true)
|
|
46
|
+
continue;
|
|
47
|
+
const { continued: _continued, ...head } = open.entry;
|
|
48
|
+
whole.push({ ...head, text: open.texts.join('') });
|
|
49
|
+
open = null;
|
|
50
|
+
}
|
|
51
|
+
return open === null ? whole : null;
|
|
52
|
+
}
|
|
53
|
+
async function verified(entries) {
|
|
54
|
+
try {
|
|
55
|
+
for (const entry of entries) {
|
|
56
|
+
if ((await sha256Hex(entry.text ?? '')) !== entry.sha256)
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
24
65
|
export function houseNotifications(transport, mode) {
|
|
25
66
|
const stream = transport.stream;
|
|
26
67
|
const lines = new Map();
|
|
68
|
+
const staged = new Map();
|
|
69
|
+
let receiving = Promise.resolve();
|
|
70
|
+
let verifying = 0;
|
|
27
71
|
const locators = new Map();
|
|
28
72
|
const observers = new Set();
|
|
29
73
|
const conversationObservers = new Set();
|
|
@@ -49,6 +93,7 @@ export function houseNotifications(transport, mode) {
|
|
|
49
93
|
}
|
|
50
94
|
function reopened(next) {
|
|
51
95
|
opening = next;
|
|
96
|
+
staged.clear();
|
|
52
97
|
const gapped = new Set([...replicated, ...live]);
|
|
53
98
|
live.clear();
|
|
54
99
|
for (const conversation of gapped)
|
|
@@ -110,7 +155,46 @@ export function houseNotifications(transport, mode) {
|
|
|
110
155
|
if (line !== undefined)
|
|
111
156
|
lines.set(authority, { ...line, frames: [] });
|
|
112
157
|
}
|
|
113
|
-
function
|
|
158
|
+
function stage(frame) {
|
|
159
|
+
const held = staged.get(frame.authority);
|
|
160
|
+
if (frame.index === 0) {
|
|
161
|
+
staged.set(frame.authority, { carry: frame.carry, parts: 1, entries: [...frame.entries] });
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (held?.carry !== frame.carry || held.parts !== frame.index) {
|
|
165
|
+
staged.delete(frame.authority);
|
|
166
|
+
interrupt(frame.authority);
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
held.parts += 1;
|
|
170
|
+
held.entries.push(...frame.entries);
|
|
171
|
+
}
|
|
172
|
+
function carried(frame) {
|
|
173
|
+
const held = staged.get(frame.authority);
|
|
174
|
+
staged.delete(frame.authority);
|
|
175
|
+
const parts = frame.parts === 0
|
|
176
|
+
? []
|
|
177
|
+
: held?.carry === frame.carry && held.parts === frame.parts
|
|
178
|
+
? held.entries
|
|
179
|
+
: null;
|
|
180
|
+
const entries = parts === null ? null : assembled(parts);
|
|
181
|
+
if (entries === null) {
|
|
182
|
+
interrupt(frame.authority);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
const digested = entries.filter((entry) => entry.text !== undefined && entry.sha256 !== undefined);
|
|
186
|
+
if (digested.length === 0) {
|
|
187
|
+
publish(frame, entries);
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
return verified(digested).then((whole) => {
|
|
191
|
+
if (whole)
|
|
192
|
+
publish(frame, entries);
|
|
193
|
+
else
|
|
194
|
+
interrupt(frame.authority);
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
function handle(frame) {
|
|
114
198
|
if (frame.type === 'signal') {
|
|
115
199
|
const mode = frame.service_mode;
|
|
116
200
|
if (mode !== 'open' && mode !== 'write-halted')
|
|
@@ -147,8 +231,14 @@ export function houseNotifications(transport, mode) {
|
|
|
147
231
|
converse(frame);
|
|
148
232
|
return;
|
|
149
233
|
}
|
|
150
|
-
if (frame.type
|
|
234
|
+
if (frame.type === 'part') {
|
|
235
|
+
stage(frame);
|
|
151
236
|
return;
|
|
237
|
+
}
|
|
238
|
+
if (frame.type === 'carried')
|
|
239
|
+
return carried(frame);
|
|
240
|
+
}
|
|
241
|
+
function publish(frame, entries) {
|
|
152
242
|
const at = position(frame.position);
|
|
153
243
|
const after = position(frame.after);
|
|
154
244
|
if (at === null || after === null || after >= at) {
|
|
@@ -162,7 +252,7 @@ export function houseNotifications(transport, mode) {
|
|
|
162
252
|
const last = line.frames.at(-1);
|
|
163
253
|
if (last !== undefined && at <= last.position)
|
|
164
254
|
return;
|
|
165
|
-
const held = { after, position: at, entries
|
|
255
|
+
const held = { after, position: at, entries };
|
|
166
256
|
const next = last !== undefined && after <= last.position ? [...line.frames, held] : [held];
|
|
167
257
|
lines.set(frame.authority, { ...line, frames: next.length > HELD_FRAMES_MAX ? [] : next });
|
|
168
258
|
}
|
|
@@ -171,10 +261,28 @@ export function houseNotifications(transport, mode) {
|
|
|
171
261
|
}
|
|
172
262
|
announce(frame.authority, { position: frame.position, logEpoch: frame.log_epoch });
|
|
173
263
|
}
|
|
174
|
-
stream.observe(
|
|
264
|
+
stream.observe((frame) => {
|
|
265
|
+
if (verifying === 0) {
|
|
266
|
+
const handled = handle(frame);
|
|
267
|
+
if (handled === undefined)
|
|
268
|
+
return;
|
|
269
|
+
verifying += 1;
|
|
270
|
+
receiving = handled.finally(() => {
|
|
271
|
+
verifying -= 1;
|
|
272
|
+
});
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
verifying += 1;
|
|
276
|
+
receiving = receiving
|
|
277
|
+
.then(() => handle(frame))
|
|
278
|
+
.finally(() => {
|
|
279
|
+
verifying -= 1;
|
|
280
|
+
});
|
|
281
|
+
});
|
|
175
282
|
stream.opened(reopened);
|
|
176
283
|
stream.closed((revoked) => {
|
|
177
284
|
opening = null;
|
|
285
|
+
staged.clear();
|
|
178
286
|
emit({ kind: 'closed', revoked });
|
|
179
287
|
});
|
|
180
288
|
return {
|
|
@@ -265,6 +373,7 @@ export function houseNotifications(transport, mode) {
|
|
|
265
373
|
const documents = {};
|
|
266
374
|
const revisions = {};
|
|
267
375
|
const changes = {};
|
|
376
|
+
const binaryFiles = {};
|
|
268
377
|
const removals = [];
|
|
269
378
|
const applied = [];
|
|
270
379
|
const schemas = new Map();
|
|
@@ -272,6 +381,7 @@ export function houseNotifications(transport, mode) {
|
|
|
272
381
|
delete documents[path];
|
|
273
382
|
delete revisions[path];
|
|
274
383
|
delete changes[path];
|
|
384
|
+
delete binaryFiles[path];
|
|
275
385
|
const removed = removals.indexOf(path);
|
|
276
386
|
if (removed !== -1)
|
|
277
387
|
removals.splice(removed, 1);
|
|
@@ -292,7 +402,8 @@ export function houseNotifications(transport, mode) {
|
|
|
292
402
|
removals.push(entry.path);
|
|
293
403
|
continue;
|
|
294
404
|
}
|
|
295
|
-
|
|
405
|
+
const binary = binaryFileOf(entry);
|
|
406
|
+
if (binary === null || (binary === undefined && entry.text === undefined))
|
|
296
407
|
return null;
|
|
297
408
|
if (mode === 'credential' && entry.revision === undefined)
|
|
298
409
|
return null;
|
|
@@ -300,9 +411,13 @@ export function houseNotifications(transport, mode) {
|
|
|
300
411
|
if (head === null)
|
|
301
412
|
return null;
|
|
302
413
|
forget(entry.path);
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
414
|
+
if (binary === undefined)
|
|
415
|
+
documents[entry.path] = entry.text;
|
|
416
|
+
else
|
|
417
|
+
binaryFiles[entry.path] = binary;
|
|
418
|
+
const revision = entry.revision ?? binary?.sha256;
|
|
419
|
+
if (revision !== undefined)
|
|
420
|
+
revisions[entry.path] = revision;
|
|
306
421
|
if (head !== undefined)
|
|
307
422
|
changes[entry.path] = head;
|
|
308
423
|
}
|
|
@@ -316,7 +431,7 @@ export function houseNotifications(transport, mode) {
|
|
|
316
431
|
documents,
|
|
317
432
|
revisions,
|
|
318
433
|
changes,
|
|
319
|
-
|
|
434
|
+
binaryFiles,
|
|
320
435
|
removals: removals.sort(),
|
|
321
436
|
},
|
|
322
437
|
entries: applied,
|
package/dist/transport.d.ts
CHANGED
|
@@ -14,8 +14,15 @@ export type HouseDoorAnswer = {
|
|
|
14
14
|
status: number;
|
|
15
15
|
body: unknown;
|
|
16
16
|
};
|
|
17
|
-
export
|
|
18
|
-
export
|
|
17
|
+
export declare const DOOR_FILES_GET = "/door/files/get";
|
|
18
|
+
export declare const SITE_FILES = "/_house/files/";
|
|
19
|
+
export declare const SITE_FILE_RECORD = "record";
|
|
20
|
+
export type HouseByteAct = 'authored_batch_upload' | 'conversation_file_upload' | 'binary_stage';
|
|
21
|
+
export type HouseByteBody = string | ArrayBuffer | Uint8Array | Blob;
|
|
22
|
+
export type HouseBytesAnswer = {
|
|
23
|
+
status: number;
|
|
24
|
+
blob: Blob | null;
|
|
25
|
+
};
|
|
19
26
|
export type HouseByteTransfer = {
|
|
20
27
|
act: HouseByteAct;
|
|
21
28
|
url: string;
|
|
@@ -24,10 +31,13 @@ export type HouseByteTransfer = {
|
|
|
24
31
|
};
|
|
25
32
|
export type HouseStreamEntry = {
|
|
26
33
|
path: string;
|
|
27
|
-
kind: 'edited' | 'removed';
|
|
34
|
+
kind: 'edited' | 'removed' | 'piece';
|
|
28
35
|
revision?: string;
|
|
29
36
|
sha256?: string;
|
|
30
37
|
text?: string;
|
|
38
|
+
file?: string;
|
|
39
|
+
bytes?: number;
|
|
40
|
+
media_type?: string;
|
|
31
41
|
author?: {
|
|
32
42
|
user: string;
|
|
33
43
|
name: string;
|
|
@@ -36,6 +46,7 @@ export type HouseStreamEntry = {
|
|
|
36
46
|
name: string;
|
|
37
47
|
};
|
|
38
48
|
created_at?: string;
|
|
49
|
+
continued?: true;
|
|
39
50
|
};
|
|
40
51
|
type LiveFact<K extends ConversationEvent['kind']> = Extract<ConversationEvent, {
|
|
41
52
|
kind: K;
|
|
@@ -49,12 +60,19 @@ export type HouseListedConversation = {
|
|
|
49
60
|
outcome: string | null;
|
|
50
61
|
};
|
|
51
62
|
export type HouseStreamFrame = {
|
|
52
|
-
type: '
|
|
63
|
+
type: 'part';
|
|
64
|
+
authority: string;
|
|
65
|
+
carry: string;
|
|
66
|
+
index: number;
|
|
67
|
+
entries: readonly HouseStreamEntry[];
|
|
68
|
+
} | {
|
|
69
|
+
type: 'carried';
|
|
53
70
|
authority: string;
|
|
71
|
+
carry: string;
|
|
72
|
+
parts: number;
|
|
54
73
|
after: string;
|
|
55
74
|
position: string;
|
|
56
75
|
log_epoch: string;
|
|
57
|
-
entries: readonly HouseStreamEntry[];
|
|
58
76
|
} | {
|
|
59
77
|
type: 'opening';
|
|
60
78
|
expired: readonly string[];
|
|
@@ -115,10 +133,12 @@ export type HouseDoor = {
|
|
|
115
133
|
};
|
|
116
134
|
export type HouseTransport = HouseDoor & {
|
|
117
135
|
transfer(request: HouseByteTransfer): Promise<HouseDoorAnswer>;
|
|
136
|
+
download(url: string): Promise<HouseBytesAnswer>;
|
|
118
137
|
};
|
|
119
138
|
export type HouseSiteTransport = HouseDoor & {
|
|
120
139
|
online(): boolean;
|
|
121
140
|
read(route: string): Promise<HouseDoorAnswer>;
|
|
141
|
+
download(route: string): Promise<HouseBytesAnswer>;
|
|
122
142
|
};
|
|
123
143
|
export {};
|
|
124
144
|
//# sourceMappingURL=transport.d.ts.map
|
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,MAAM,MAAM,YAAY,GAAG,uBAAuB,GAAG,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"m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gB,CAAC,CAAC;CACpD,CAAC"}
|
package/dist/transport.js
CHANGED
|
@@ -8,3 +8,6 @@ export const SITE_DOOR_DISCOVER = '/_house/door/discover';
|
|
|
8
8
|
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
|
+
export const DOOR_FILES_GET = '/door/files/get';
|
|
12
|
+
export const SITE_FILES = '/_house/files/';
|
|
13
|
+
export const SITE_FILE_RECORD = 'record';
|
package/dist/write.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ChangeBatch, type HistoryResult, type MutationResult } from '@agentshouse/mdruntime';
|
|
2
2
|
import type { HouseBounds } from './discovery.js';
|
|
3
3
|
export type HouseOperation = Readonly<Record<string, unknown>>;
|
|
4
4
|
export type ChangeMapping = {
|
|
@@ -21,14 +21,7 @@ export declare function deltaBody(changes: readonly HouseOperation[]): string;
|
|
|
21
21
|
export declare function deltaBytes(delta: string): number;
|
|
22
22
|
export declare function uploadable(inline: Readonly<Record<string, unknown>>, bytes: number, bounds: Pick<HouseBounds, 'max_inline_body_bytes' | 'max_upload_bytes'>): boolean;
|
|
23
23
|
export declare function deltaDigest(delta: string): Promise<string>;
|
|
24
|
-
export
|
|
25
|
-
kind: 'accepted';
|
|
26
|
-
}> | (Extract<MutationResult, {
|
|
27
|
-
kind: 'accepted';
|
|
28
|
-
}> & {
|
|
29
|
-
originals: readonly RoomAttachment[];
|
|
30
|
-
});
|
|
31
|
-
export declare function mutationOutcome(status: number, body: unknown, locator: string, handle: string): SubmittedOutcome;
|
|
24
|
+
export declare function mutationOutcome(status: number, body: unknown, locator: string, handle: string): MutationResult;
|
|
32
25
|
export declare function rejectedMapping(mapping: Extract<ChangeMapping, {
|
|
33
26
|
kind: 'unmapped';
|
|
34
27
|
}>): {
|
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,KAAK,
|
|
1
|
+
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../src/write.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,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,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/D;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,GAAG,SAAS,MAAM,EAAE,CAQhF;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,GAAG,MAAM,CAEpE;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED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