@agentshouse/mdruntime-adapter 0.1.0-cb42b23b5d2fb → 0.1.0-cb6436097e8a2
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 +258 -258
- package/dist/actions.d.ts +20 -0
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +26 -28
- package/dist/adapter.d.ts +1 -0
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +127 -34
- package/dist/discovery.d.ts +1 -0
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +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 +23 -1
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +90 -4
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +2 -1
- package/dist/site.d.ts +1 -1
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +122 -43
- package/dist/stream.d.ts +5 -4
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +289 -9
- package/dist/transport.d.ts +33 -4
- package/dist/transport.d.ts.map +1 -1
- package/dist/version.d.ts +1 -0
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +7 -3
- package/package.json +2 -3
package/dist/read.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import { readPosition, roomVersion } from './version.js';
|
|
1
|
+
import { DECIMAL, readPosition, roomVersion } from './version.js';
|
|
2
|
+
const REVISION_FILE = /^fr_([0-9a-z]+)\.[0-9a-z]+\.[0-9a-z]$/u;
|
|
3
|
+
export function identities(revisions) {
|
|
4
|
+
const fileIds = Object.fromEntries(Object.entries(revisions).flatMap(([path, revision]) => {
|
|
5
|
+
const file = REVISION_FILE.exec(revision)?.[1];
|
|
6
|
+
return file === undefined ? [] : [[path, file]];
|
|
7
|
+
}));
|
|
8
|
+
return Object.keys(fileIds).length === 0 ? {} : { fileIds };
|
|
9
|
+
}
|
|
2
10
|
export function authorityRoot(handle) {
|
|
3
11
|
return `/rooms/${handle}`;
|
|
4
12
|
}
|
|
@@ -92,6 +100,7 @@ function parseFile(value, mode) {
|
|
|
92
100
|
path: file.path,
|
|
93
101
|
revision: file.revision,
|
|
94
102
|
version: file.revision,
|
|
103
|
+
...(typeof file.sha256 === 'string' ? { sha256: file.sha256 } : {}),
|
|
95
104
|
...headed(head),
|
|
96
105
|
...binaried(binary),
|
|
97
106
|
};
|
|
@@ -132,13 +141,26 @@ function parseScope(value, mode) {
|
|
|
132
141
|
}
|
|
133
142
|
return { anchor: manifest.anchor, ...at, files, contents };
|
|
134
143
|
}
|
|
144
|
+
function parseCut(value) {
|
|
145
|
+
if (value === undefined)
|
|
146
|
+
return undefined;
|
|
147
|
+
if (typeof value !== 'object' || value === null)
|
|
148
|
+
return null;
|
|
149
|
+
const { position, log_epoch: logEpoch } = value;
|
|
150
|
+
if (typeof position !== 'string' || typeof logEpoch !== 'string')
|
|
151
|
+
return null;
|
|
152
|
+
return { position, log_epoch: logEpoch };
|
|
153
|
+
}
|
|
135
154
|
function parseCursor(value) {
|
|
136
155
|
if (typeof value !== 'object' || value === null)
|
|
137
156
|
return null;
|
|
138
|
-
const { room, path } = value;
|
|
157
|
+
const { room, path, cut } = value;
|
|
139
158
|
if (typeof room !== 'string' || (path !== null && typeof path !== 'string'))
|
|
140
159
|
return null;
|
|
141
|
-
|
|
160
|
+
const parsed = parseCut(cut);
|
|
161
|
+
if (parsed === null)
|
|
162
|
+
return null;
|
|
163
|
+
return { room, path, ...(parsed === undefined ? {} : { cut: parsed }) };
|
|
142
164
|
}
|
|
143
165
|
export function parseEnvelope(body) {
|
|
144
166
|
if (typeof body !== 'object' || body === null)
|
|
@@ -160,6 +182,18 @@ export function parseEnvelope(body) {
|
|
|
160
182
|
export function parseSiteBootstrap(body) {
|
|
161
183
|
return parseScope(body, 'site');
|
|
162
184
|
}
|
|
185
|
+
export function siteBootstrapNext(body) {
|
|
186
|
+
if (typeof body !== 'object' || body === null || !('next' in body))
|
|
187
|
+
return null;
|
|
188
|
+
return typeof body.next === 'string' && body.next.length > 0 ? body.next : null;
|
|
189
|
+
}
|
|
190
|
+
export function siteBootstrapOffset(body) {
|
|
191
|
+
if (typeof body !== 'object' || body === null || !('offset' in body))
|
|
192
|
+
return null;
|
|
193
|
+
return Number.isSafeInteger(body.offset) && body.offset > 0
|
|
194
|
+
? body.offset
|
|
195
|
+
: null;
|
|
196
|
+
}
|
|
163
197
|
function parseChange(value, mode) {
|
|
164
198
|
if (typeof value !== 'object' || value === null)
|
|
165
199
|
return null;
|
|
@@ -222,10 +256,60 @@ export function parseEnumeration(body, mode) {
|
|
|
222
256
|
return null;
|
|
223
257
|
changes.push(mapped);
|
|
224
258
|
}
|
|
225
|
-
|
|
259
|
+
const next = held.next === undefined ? undefined : readPage(held.next);
|
|
260
|
+
if (next === null)
|
|
261
|
+
return null;
|
|
262
|
+
authorities.push({
|
|
263
|
+
authority: held.authority,
|
|
264
|
+
...at,
|
|
265
|
+
changes,
|
|
266
|
+
...(next === undefined ? {} : { next }),
|
|
267
|
+
});
|
|
226
268
|
}
|
|
227
269
|
return { authorities };
|
|
228
270
|
}
|
|
271
|
+
function readPage(held) {
|
|
272
|
+
if (typeof held !== 'object' || held === null)
|
|
273
|
+
return null;
|
|
274
|
+
const { after, through, read } = held;
|
|
275
|
+
if (typeof after !== 'string' || !DECIMAL.test(after))
|
|
276
|
+
return null;
|
|
277
|
+
if (typeof through !== 'string' || !DECIMAL.test(through))
|
|
278
|
+
return null;
|
|
279
|
+
if (typeof read !== 'number' || !Number.isSafeInteger(read) || read < 0)
|
|
280
|
+
return null;
|
|
281
|
+
return { after, through, read };
|
|
282
|
+
}
|
|
283
|
+
function advances(asked, next) {
|
|
284
|
+
const moved = BigInt(next.through) - BigInt(asked.through);
|
|
285
|
+
return moved > 0n || (moved === 0n && next.after === asked.after && next.read > asked.read);
|
|
286
|
+
}
|
|
287
|
+
export async function wholeView(first, more) {
|
|
288
|
+
const changes = new Map(first.changes.map((change) => [change.path, change]));
|
|
289
|
+
let view = first;
|
|
290
|
+
while (view.next !== undefined) {
|
|
291
|
+
const asked = view.next;
|
|
292
|
+
const page = await more(asked);
|
|
293
|
+
if ('kind' in page)
|
|
294
|
+
return page;
|
|
295
|
+
if (page.position !== asked.through ||
|
|
296
|
+
page.logEpoch !== first.logEpoch ||
|
|
297
|
+
(page.next !== undefined && !advances(asked, page.next))) {
|
|
298
|
+
return { kind: 'transport-uncertainty' };
|
|
299
|
+
}
|
|
300
|
+
for (const change of page.changes) {
|
|
301
|
+
changes.delete(change.path);
|
|
302
|
+
changes.set(change.path, change);
|
|
303
|
+
}
|
|
304
|
+
view = page;
|
|
305
|
+
}
|
|
306
|
+
return {
|
|
307
|
+
authority: first.authority,
|
|
308
|
+
position: view.position,
|
|
309
|
+
logEpoch: first.logEpoch,
|
|
310
|
+
changes: [...changes.values()],
|
|
311
|
+
};
|
|
312
|
+
}
|
|
229
313
|
export function advancedScope(scope, view) {
|
|
230
314
|
const files = new Map(scope.files.map((file) => [file.path, file]));
|
|
231
315
|
const contents = new Map(scope.contents.map((entry) => [entry.path, entry.content]));
|
|
@@ -277,6 +361,7 @@ export function bootstrapOf(scope) {
|
|
|
277
361
|
roomVersion: roomVersion(scope),
|
|
278
362
|
documents,
|
|
279
363
|
revisions,
|
|
364
|
+
...identities(revisions),
|
|
280
365
|
changes,
|
|
281
366
|
binaryFiles,
|
|
282
367
|
};
|
|
@@ -320,6 +405,7 @@ export function refreshFrom(view, fromRoomVersion) {
|
|
|
320
405
|
roomVersion: roomVersion(view),
|
|
321
406
|
documents,
|
|
322
407
|
revisions,
|
|
408
|
+
...identities(revisions),
|
|
323
409
|
changes,
|
|
324
410
|
binaryFiles,
|
|
325
411
|
removals: removals.sort(),
|
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
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Adapter } from '@agentshouse/mdruntime';
|
|
2
2
|
import { type HouseSiteTransport } from './transport.js';
|
|
3
|
-
export declare function createSiteAdapter(transport: HouseSiteTransport): Adapter;
|
|
3
|
+
export declare function createSiteAdapter(transport: HouseSiteTransport, snapshot?: boolean): Adapter;
|
|
4
4
|
//# sourceMappingURL=site.d.ts.map
|
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,EAOR,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAOR,MAAM,wBAAwB,CAAC;AA2BhC,OAAO,EAOL,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AAmCxB,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,kBAAkB,EAAE,QAAQ,UAAQ,GAAG,OAAO,CA+Q1F"}
|
package/dist/site.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
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, wholeView, } 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
8
|
import { SITE_DOOR_BOOTSTRAP, SITE_DOOR_DISCOVER, SITE_DOOR_ENUMERATE, SITE_DOOR_SUBMIT, SITE_FILE_RECORD, SITE_FILES, } from './transport.js';
|
|
@@ -22,39 +23,97 @@ function siteRoom(tracked) {
|
|
|
22
23
|
function settled(refused) {
|
|
23
24
|
return refused.kind === 'beyond-horizon' ? UNCERTAIN : refused;
|
|
24
25
|
}
|
|
25
|
-
export function createSiteAdapter(transport) {
|
|
26
|
+
export function createSiteAdapter(transport, snapshot = false) {
|
|
26
27
|
const notifications = houseNotifications(transport, 'site');
|
|
27
28
|
const tracked = new Map();
|
|
28
29
|
function published(referrer) {
|
|
29
30
|
const named = houseReferrer(referrer, tracked);
|
|
30
31
|
return named === null || !tracked.has(named.locator) ? null : named;
|
|
31
32
|
}
|
|
32
|
-
async function
|
|
33
|
+
async function enumerated(entry, from, page) {
|
|
33
34
|
const answer = await transport.door(SITE_DOOR_ENUMERATE, {
|
|
34
|
-
positions: [
|
|
35
|
+
positions: [
|
|
36
|
+
page === undefined
|
|
37
|
+
? presented(entry.authority, from)
|
|
38
|
+
: {
|
|
39
|
+
...presented(entry.authority, { position: page.after, logEpoch: from.logEpoch }),
|
|
40
|
+
page: { through: page.through, read: page.read },
|
|
41
|
+
},
|
|
42
|
+
],
|
|
35
43
|
});
|
|
36
44
|
const classified = classifyRead(answer.status, answer.body, entry.locator);
|
|
37
45
|
if (classified !== null)
|
|
38
46
|
return classified;
|
|
39
|
-
|
|
47
|
+
const found = parseEnumeration(answer.body, 'site');
|
|
48
|
+
if (found === null)
|
|
49
|
+
return UNCERTAIN;
|
|
50
|
+
return viewOf(found, entry) ?? { kind: 'room-not-readable', locator: entry.locator };
|
|
51
|
+
}
|
|
52
|
+
async function enumeration(entry, from) {
|
|
53
|
+
const first = await enumerated(entry, from);
|
|
54
|
+
return 'kind' in first ? first : wholeView(first, (page) => enumerated(entry, from, page));
|
|
40
55
|
}
|
|
41
|
-
async function
|
|
42
|
-
const
|
|
56
|
+
async function bootstrapPart(entry, after, offset) {
|
|
57
|
+
const query = [
|
|
58
|
+
...(after === null ? [] : [`after=${encodeURIComponent(after)}`]),
|
|
59
|
+
...(offset === null ? [] : [`offset=${offset}`]),
|
|
60
|
+
];
|
|
61
|
+
const answer = await transport.read(`${SITE_DOOR_BOOTSTRAP}${entry.authority}${query.length === 0 ? '' : `?${query.join('&')}`}`);
|
|
43
62
|
const classified = classifyDoor(answer.status, answer.body, entry.locator);
|
|
44
63
|
if (classified !== null)
|
|
45
64
|
return { failure: classified };
|
|
46
65
|
const scope = parseSiteBootstrap(answer.body);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
66
|
+
return scope === null ? { failure: UNCERTAIN } : { body: answer.body, scope };
|
|
67
|
+
}
|
|
68
|
+
async function assembled(entry, scope, path, offset) {
|
|
69
|
+
const opened = scope.contents.at(-1);
|
|
70
|
+
if (opened === undefined || opened.path !== path || opened.content.length !== offset) {
|
|
71
|
+
return UNCERTAIN;
|
|
72
|
+
}
|
|
73
|
+
let text = opened.content;
|
|
74
|
+
for (;;) {
|
|
75
|
+
const part = await bootstrapPart(entry, path, text.length);
|
|
76
|
+
if ('failure' in part)
|
|
77
|
+
return part.failure;
|
|
78
|
+
const [piece] = part.scope.contents;
|
|
79
|
+
if (piece === undefined ||
|
|
80
|
+
part.scope.contents.length !== 1 ||
|
|
81
|
+
piece.path !== path ||
|
|
82
|
+
piece.content.length === 0) {
|
|
83
|
+
return UNCERTAIN;
|
|
84
|
+
}
|
|
85
|
+
text += piece.content;
|
|
86
|
+
const more = siteBootstrapOffset(part.body);
|
|
87
|
+
if (more === null)
|
|
88
|
+
break;
|
|
89
|
+
if (more !== text.length)
|
|
90
|
+
return UNCERTAIN;
|
|
91
|
+
}
|
|
92
|
+
const file = scope.files.find((held) => held.path === path);
|
|
93
|
+
if (file === undefined || (await sha256Hex(text)) !== file.version)
|
|
94
|
+
return UNCERTAIN;
|
|
95
|
+
return { ...scope, contents: [...scope.contents.slice(0, -1), { path, content: text }] };
|
|
96
|
+
}
|
|
97
|
+
async function caughtUp(entry, after) {
|
|
98
|
+
const part = await bootstrapPart(entry, after, null);
|
|
99
|
+
if ('failure' in part)
|
|
100
|
+
return part;
|
|
101
|
+
const next = siteBootstrapNext(part.body);
|
|
102
|
+
const offset = siteBootstrapOffset(part.body);
|
|
103
|
+
if (offset !== null) {
|
|
104
|
+
if (next === null)
|
|
105
|
+
return { failure: UNCERTAIN };
|
|
106
|
+
const scope = await assembled(entry, part.scope, next, offset);
|
|
107
|
+
return 'kind' in scope ? { failure: scope } : { scope, next };
|
|
108
|
+
}
|
|
109
|
+
const { scope } = part;
|
|
110
|
+
if (after !== null || next !== null || roomVersion(scope) === roomVersion(entry)) {
|
|
111
|
+
return { scope, next };
|
|
112
|
+
}
|
|
113
|
+
const view = await enumeration(entry, scope);
|
|
114
|
+
if ('kind' in view)
|
|
115
|
+
return { failure: settled(view) };
|
|
116
|
+
return { scope: advancedScope(scope, view), next: null };
|
|
58
117
|
}
|
|
59
118
|
async function refreshed(entry, fromRoomVersion) {
|
|
60
119
|
const from = logPosition(fromRoomVersion);
|
|
@@ -65,12 +124,9 @@ export function createSiteAdapter(transport) {
|
|
|
65
124
|
const models = await streamedModels(streamed.schemas, entry, 'site');
|
|
66
125
|
return models === undefined ? streamed.page : { ...streamed.page, models };
|
|
67
126
|
}
|
|
68
|
-
const
|
|
69
|
-
if ('kind' in
|
|
70
|
-
return
|
|
71
|
-
const view = viewOf(found, entry);
|
|
72
|
-
if (view === undefined)
|
|
73
|
-
return { kind: 'room-not-readable', locator: entry.locator };
|
|
127
|
+
const view = await enumeration(entry, from);
|
|
128
|
+
if ('kind' in view)
|
|
129
|
+
return view;
|
|
74
130
|
notifications.reach(entry.authority, view);
|
|
75
131
|
const answer = refreshFrom(view, fromRoomVersion);
|
|
76
132
|
if (answer.kind !== 'net-advancement')
|
|
@@ -80,6 +136,7 @@ export function createSiteAdapter(transport) {
|
|
|
80
136
|
}
|
|
81
137
|
return {
|
|
82
138
|
localSaves: true,
|
|
139
|
+
exhaustiveDiscovery: true,
|
|
83
140
|
async authorize() {
|
|
84
141
|
return {};
|
|
85
142
|
},
|
|
@@ -102,14 +159,24 @@ export function createSiteAdapter(transport) {
|
|
|
102
159
|
const entry = tracked.get(request.locator);
|
|
103
160
|
if (entry === undefined)
|
|
104
161
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
162
|
+
const continued = request.pageToken === undefined
|
|
163
|
+
? null
|
|
164
|
+
: JSON.parse(request.pageToken);
|
|
165
|
+
const held = await caughtUp(entry, continued?.after ?? null);
|
|
108
166
|
if ('failure' in held)
|
|
109
167
|
return held.failure;
|
|
110
168
|
notifications.reach(entry.authority, held.scope);
|
|
111
|
-
const
|
|
112
|
-
|
|
169
|
+
const seen = [
|
|
170
|
+
...(continued?.seen ?? []),
|
|
171
|
+
...entry.schemas.filter((schema) => held.scope.files.some((file) => file.path === schema)),
|
|
172
|
+
];
|
|
173
|
+
const models = await partModels(held.scope, entry, new Set(seen), held.next === null);
|
|
174
|
+
const continuation = held.next === null ? null : { after: held.next, seen };
|
|
175
|
+
return {
|
|
176
|
+
...bootstrapOf(held.scope),
|
|
177
|
+
...(models === undefined ? {} : { models }),
|
|
178
|
+
...(continuation === null ? {} : { pageToken: JSON.stringify(continuation) }),
|
|
179
|
+
};
|
|
113
180
|
},
|
|
114
181
|
async refresh(_authorization, request) {
|
|
115
182
|
const entry = tracked.get(request.locator);
|
|
@@ -117,6 +184,11 @@ export function createSiteAdapter(transport) {
|
|
|
117
184
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
118
185
|
if (request.pageToken !== undefined)
|
|
119
186
|
return UNCERTAIN;
|
|
187
|
+
if (snapshot) {
|
|
188
|
+
return request.fromRoomVersion === roomVersion(entry)
|
|
189
|
+
? { kind: 'still-current' }
|
|
190
|
+
: { kind: 'beyond-horizon' };
|
|
191
|
+
}
|
|
120
192
|
return refreshed(entry, request.fromRoomVersion);
|
|
121
193
|
},
|
|
122
194
|
async mutate() {
|
|
@@ -170,20 +242,27 @@ export function createSiteAdapter(transport) {
|
|
|
170
242
|
return UNCERTAIN;
|
|
171
243
|
return actionOutcome(await transport.door(SITE_DOOR_SUBMIT, request.input), SITE_SUBMIT);
|
|
172
244
|
},
|
|
173
|
-
roomStream:
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
245
|
+
roomStream: snapshot
|
|
246
|
+
? undefined
|
|
247
|
+
: {
|
|
248
|
+
hold(rooms) {
|
|
249
|
+
notifications.send(rooms.flatMap((room) => {
|
|
250
|
+
const entry = tracked.get(room.locator);
|
|
251
|
+
const at = logPosition(room.roomVersion);
|
|
252
|
+
if (entry === undefined || at === null)
|
|
253
|
+
return [];
|
|
254
|
+
notifications.reach(entry.authority, at);
|
|
255
|
+
return [presented(entry.authority, at)];
|
|
256
|
+
}), null);
|
|
257
|
+
},
|
|
258
|
+
reopen: notifications.reopen,
|
|
259
|
+
observe: notifications.observe,
|
|
260
|
+
published(locator, roomVersion) {
|
|
261
|
+
const at = logPosition(roomVersion);
|
|
262
|
+
if (at !== null)
|
|
263
|
+
notifications.published(locator, at);
|
|
264
|
+
},
|
|
183
265
|
},
|
|
184
|
-
reopen: notifications.reopen,
|
|
185
|
-
observe: notifications.observe,
|
|
186
|
-
},
|
|
187
266
|
serviceMode: notifications.serviceMode,
|
|
188
267
|
};
|
|
189
268
|
}
|
package/dist/stream.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ConversationStream, RefreshPage, RoomStreamEvent, ServiceModeSignal } from '@agentshouse/mdruntime';
|
|
1
|
+
import type { ConversationStream, RefreshPage, RoomStreamEvent, ServiceModeSignal, StreamReceipts } from '@agentshouse/mdruntime';
|
|
2
2
|
import type { TrackedAuthority } from './discovery.js';
|
|
3
|
-
import type { HouseDoor, HouseHeldRoom, HouseMode, HouseStreamEntry } from './transport.js';
|
|
3
|
+
import type { HouseDemand, HouseDoor, HouseHeldRoom, HouseMode, HouseStreamEntry } from './transport.js';
|
|
4
4
|
import { type LogPosition } from './version.js';
|
|
5
5
|
export type HeldRevision = (path: string, revision: string) => boolean;
|
|
6
6
|
export type StreamedAdvancement = {
|
|
@@ -10,8 +10,9 @@ export type StreamedAdvancement = {
|
|
|
10
10
|
};
|
|
11
11
|
export type HouseNotifications = {
|
|
12
12
|
runtime: string;
|
|
13
|
-
observe(notify: (event: RoomStreamEvent) => void): () => void;
|
|
14
|
-
send(rooms: readonly HouseHeldRoom[]): void;
|
|
13
|
+
observe(notify: (event: RoomStreamEvent) => void, receipts: StreamReceipts): () => void;
|
|
14
|
+
send(rooms: readonly HouseHeldRoom[], demand: HouseDemand | null): void;
|
|
15
|
+
published(locator: string, at: LogPosition): void;
|
|
15
16
|
reopen(): void;
|
|
16
17
|
track(authorities: readonly TrackedAuthority[]): void;
|
|
17
18
|
reach(authority: string, at: LogPosition): void;
|
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,EAGV,kBAAkB,EAElB,WAAW,EACX,eAAe,EAEf,iBAAiB,
|
|
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,EACjB,cAAc,EAEf,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,KAAK,EACV,WAAW,EACX,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,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,EAAE,QAAQ,EAAE,cAAc,GAAG,MAAM,IAAI,CAAC;IACxF,IAAI,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI,GAAG,IAAI,CAAC;IACxE,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,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;AAkFF,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,GAAG,kBAAkB,CAohB5F"}
|