@agentshouse/mdruntime-adapter 0.1.0-cedb8e57837a7 → 0.1.0-cefdbbefd37e5
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 +3 -3
- package/dist/actions.d.ts +6 -70
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +22 -360
- package/dist/adapter.d.ts +0 -1
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +212 -429
- package/dist/app-reference.d.ts +1 -0
- package/dist/app-reference.d.ts.map +1 -0
- package/dist/app-reference.js +2 -0
- package/dist/authored-path.d.ts +10 -0
- package/dist/authored-path.d.ts.map +1 -0
- package/dist/authored-path.js +35 -0
- package/dist/chunks.d.ts +37 -0
- package/dist/chunks.d.ts.map +1 -0
- package/dist/chunks.js +247 -0
- package/dist/crockford.d.ts +3 -0
- package/dist/crockford.d.ts.map +1 -0
- package/dist/crockford.js +3 -0
- package/dist/digest.d.ts +0 -1
- package/dist/discovery.d.ts +23 -18
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +78 -59
- package/dist/history.d.ts +6 -0
- package/dist/history.d.ts.map +1 -0
- package/dist/history.js +84 -0
- package/dist/house-model.d.ts +830 -0
- package/dist/house-model.d.ts.map +1 -0
- package/dist/house-model.js +465 -0
- package/dist/index.d.ts +12 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -1
- package/dist/map.d.ts +0 -1
- package/dist/model.d.ts +5 -5
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +34 -41
- package/dist/read.d.ts +38 -61
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +104 -300
- package/dist/refusal.d.ts +1 -4
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +5 -6
- package/dist/room-types.d.ts +4 -0
- package/dist/room-types.d.ts.map +1 -0
- package/dist/room-types.js +135 -0
- package/dist/search.d.ts +4 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +47 -0
- package/dist/session-content/bounds.d.ts +7 -0
- package/dist/session-content/check.d.ts +18 -0
- package/dist/session-content/index.d.ts +7 -0
- package/dist/session-content/parts.d.ts +102 -0
- package/dist/session-content/state.d.ts +61 -0
- package/dist/session-content/turn.d.ts +328 -0
- package/dist/site.d.ts +0 -1
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +85 -201
- package/dist/space-schema.d.ts +6 -0
- package/dist/space-schema.d.ts.map +1 -0
- package/dist/space-schema.js +18 -0
- package/dist/stream.d.ts +16 -15
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +240 -411
- package/dist/transport.d.ts +57 -44
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +54 -11
- package/dist/upload.d.ts +11 -0
- package/dist/upload.d.ts.map +1 -0
- package/dist/upload.js +63 -0
- package/dist/version.d.ts +0 -1
- package/dist/write.d.ts +6 -3
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +31 -44
- package/package.json +8 -4
- package/AGENTS.md +0 -304
- package/dist/gather.d.ts +0 -4
- package/dist/gather.d.ts.map +0 -1
- package/dist/gather.js +0 -35
- 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,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { actionOutcome } from './actions.js';
|
|
2
|
+
import { chunkedHead, chunkPart, siteChunkList } from './chunks.js';
|
|
3
3
|
import { mapDiscovery, parseSiteDiscovery, siteCapabilities, siteTracked, } from './discovery.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { spaceSchemas } from './space-schema.js';
|
|
5
|
+
import { discoveryFailure } from './refusal.js';
|
|
6
|
+
import { admittedPath } from './authored-path.js';
|
|
7
|
+
import { HOUSE_TYPED_PATHS } from './house-model.js';
|
|
8
|
+
import { HOUSE_NAMEABLE_ROOM_TYPES, HOUSE_ROOM_TYPES } from './room-types.js';
|
|
8
9
|
import { houseNotifications } from './stream.js';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { followsVersion, logPosition, presented, reachedVersion, roomVersion, } from './version.js';
|
|
10
|
+
import { houseSiteRoute, SITE_DOOR_SUBMIT, SITE_FILES, SITES_SUBMISSIONS_CREATE, } from './transport.js';
|
|
11
|
+
import { followsVersion, reachedVersion, roomVersion } from './version.js';
|
|
12
12
|
const UNCERTAIN = { kind: 'transport-uncertainty' };
|
|
13
13
|
function unfound() {
|
|
14
|
-
return { kind: 'rejected', code: '
|
|
14
|
+
return { kind: 'rejected', code: 'not_found', fields: {}, retryable: false };
|
|
15
15
|
}
|
|
16
16
|
function siteRoom(tracked) {
|
|
17
17
|
return {
|
|
@@ -19,197 +19,103 @@ function siteRoom(tracked) {
|
|
|
19
19
|
locator: tracked.locator,
|
|
20
20
|
handle: tracked.handle,
|
|
21
21
|
roomVersion: roomVersion(tracked),
|
|
22
|
-
operations: { write: [],
|
|
22
|
+
operations: { write: [], erase: [] },
|
|
23
23
|
replica: { selection: tracked.locator, admission: 'admitted', offline: 'open' },
|
|
24
|
+
typedSelection: null,
|
|
24
25
|
providerOwnedPaths: [],
|
|
26
|
+
authoredPaths: ['**'],
|
|
25
27
|
};
|
|
26
28
|
}
|
|
27
|
-
function settled(refused) {
|
|
28
|
-
return refused.kind === 'beyond-horizon' ? UNCERTAIN : refused;
|
|
29
|
-
}
|
|
30
29
|
export function createSiteAdapter(transport, snapshot = false) {
|
|
31
|
-
const
|
|
30
|
+
const spaces = spaceSchemas();
|
|
31
|
+
const notifications = houseNotifications(transport, 'site', {
|
|
32
|
+
opened: async () => {
|
|
33
|
+
const found = await discovered();
|
|
34
|
+
return found.kind === 'discovery' ? found : null;
|
|
35
|
+
},
|
|
36
|
+
changed: () => null,
|
|
37
|
+
}, spaces);
|
|
32
38
|
const tracked = new Map();
|
|
33
|
-
|
|
34
|
-
const named = houseReferrer(referrer, tracked);
|
|
35
|
-
return named === null || !tracked.has(named.locator) ? null : named;
|
|
36
|
-
}
|
|
39
|
+
const chunked = new Map();
|
|
37
40
|
function fileRoute(request) {
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
40
|
-
return { kind: '
|
|
41
|
-
}
|
|
42
|
-
if (request.fileRef === undefined)
|
|
43
|
-
return unfound();
|
|
44
|
-
const { room_ref, path, record } = named.referrer;
|
|
45
|
-
return `${SITE_FILES}${room_ref}/${encodeURIComponent(request.fileRef)}/${path === undefined
|
|
46
|
-
? `${SITE_FILE_RECORD}/${encodeURIComponent(record)}`
|
|
47
|
-
: encodeURIComponent(path)}`;
|
|
41
|
+
const entry = tracked.get(request.locator);
|
|
42
|
+
if (entry === undefined)
|
|
43
|
+
return { kind: 'room-not-readable', locator: request.locator };
|
|
44
|
+
return `${SITE_FILES}${entry.authority}/${encodeURIComponent(request.revision)}/${encodeURIComponent(request.path)}`;
|
|
48
45
|
}
|
|
49
|
-
async function
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
],
|
|
59
|
-
});
|
|
60
|
-
const classified = classifyRead(answer.status, answer.body, entry.locator);
|
|
61
|
-
if (classified !== null)
|
|
62
|
-
return classified;
|
|
63
|
-
const found = parseEnumeration(answer.body, 'site');
|
|
64
|
-
if (found === null)
|
|
65
|
-
return UNCERTAIN;
|
|
66
|
-
return viewOf(found, entry) ?? { kind: 'room-not-readable', locator: entry.locator };
|
|
46
|
+
async function listedRoom(entry) {
|
|
47
|
+
const past = chunked.get(entry.locator)?.position;
|
|
48
|
+
const listed = siteChunkList(await transport.read(`${houseSiteRoute('chunks')}/${entry.authority}${past === undefined ? '' : `?expired=${past}`}`), entry.locator);
|
|
49
|
+
if ('kind' in listed)
|
|
50
|
+
return listed;
|
|
51
|
+
const head = await chunkedHead(listed, entry, spaces);
|
|
52
|
+
if (head.kind === 'bootstrap')
|
|
53
|
+
chunked.set(entry.locator, listed);
|
|
54
|
+
return head;
|
|
67
55
|
}
|
|
68
|
-
async function
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
async function bootstrapPart(entry, after, offset) {
|
|
73
|
-
const query = [
|
|
74
|
-
...(after === null ? [] : [`after=${encodeURIComponent(after)}`]),
|
|
75
|
-
...(offset === null ? [] : [`offset=${offset}`]),
|
|
76
|
-
];
|
|
77
|
-
const answer = await transport.read(`${SITE_DOOR_BOOTSTRAP}${entry.authority}${query.length === 0 ? '' : `?${query.join('&')}`}`);
|
|
78
|
-
const classified = classifyDoor(answer.status, answer.body, entry.locator);
|
|
79
|
-
if (classified !== null)
|
|
80
|
-
return { failure: classified };
|
|
81
|
-
const scope = await stepped(parseSiteBootstrap(answer.body));
|
|
82
|
-
return scope === null ? { failure: UNCERTAIN } : { body: answer.body, scope };
|
|
83
|
-
}
|
|
84
|
-
async function assembled(entry, scope, path, offset) {
|
|
85
|
-
const opened = scope.contents.at(-1);
|
|
86
|
-
if (opened === undefined || opened.path !== path || opened.content.length !== offset) {
|
|
56
|
+
async function chunkPage(entry, id, arriving) {
|
|
57
|
+
const room = chunked.get(entry.locator);
|
|
58
|
+
const address = room?.chunks.get(id);
|
|
59
|
+
if (room === undefined || address === undefined)
|
|
87
60
|
return UNCERTAIN;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
for (;;) {
|
|
91
|
-
const part = await bootstrapPart(entry, path, text.length);
|
|
92
|
-
if ('failure' in part)
|
|
93
|
-
return part.failure;
|
|
94
|
-
const [piece] = part.scope.contents;
|
|
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;
|
|
107
|
-
}
|
|
108
|
-
const file = scope.files.find((held) => held.path === path);
|
|
109
|
-
if (file === undefined || (await sha256Hex(text)) !== file.version)
|
|
61
|
+
const read = await transport.download(address.url);
|
|
62
|
+
if (read.status !== 200)
|
|
110
63
|
return UNCERTAIN;
|
|
111
|
-
return
|
|
112
|
-
}
|
|
113
|
-
async function caughtUp(entry, after) {
|
|
114
|
-
const part = await bootstrapPart(entry, after, null);
|
|
115
|
-
if ('failure' in part)
|
|
116
|
-
return part;
|
|
117
|
-
const next = siteBootstrapNext(part.body);
|
|
118
|
-
const offset = siteBootstrapOffset(part.body);
|
|
119
|
-
if (offset !== null) {
|
|
120
|
-
if (next === null)
|
|
121
|
-
return { failure: UNCERTAIN };
|
|
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
|
-
}
|
|
129
|
-
const view = await enumeration(entry, scope);
|
|
130
|
-
if ('kind' in view)
|
|
131
|
-
return { failure: settled(view) };
|
|
132
|
-
return { scope: await stepped(advancedScope(scope, view)), next: null };
|
|
64
|
+
return chunkPart(read.body, room, id, arriving);
|
|
133
65
|
}
|
|
134
|
-
async function
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
return
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
notifications.
|
|
147
|
-
|
|
148
|
-
if (answer.kind !== 'net-advancement')
|
|
149
|
-
return answer;
|
|
150
|
-
const models = await viewModels(view, entry);
|
|
151
|
-
return models === undefined ? answer : { ...answer, models };
|
|
66
|
+
async function discovered() {
|
|
67
|
+
const answer = await transport.read(houseSiteRoute('discover'));
|
|
68
|
+
const failed = discoveryFailure(answer.status, answer.body);
|
|
69
|
+
if (failed !== null)
|
|
70
|
+
return failed;
|
|
71
|
+
const document = parseSiteDiscovery(answer.body);
|
|
72
|
+
if (document === null)
|
|
73
|
+
return UNCERTAIN;
|
|
74
|
+
const entries = siteTracked(document);
|
|
75
|
+
tracked.clear();
|
|
76
|
+
for (const entry of entries)
|
|
77
|
+
tracked.set(entry.locator, entry);
|
|
78
|
+
notifications.track(entries);
|
|
79
|
+
return mapDiscovery(document, entries.map(siteRoom), siteCapabilities());
|
|
152
80
|
}
|
|
153
81
|
return {
|
|
154
82
|
localSaves: true,
|
|
155
|
-
|
|
83
|
+
roomTypes: HOUSE_ROOM_TYPES,
|
|
84
|
+
nameableRoomTypes: HOUSE_NAMEABLE_ROOM_TYPES,
|
|
85
|
+
typedPaths: HOUSE_TYPED_PATHS,
|
|
86
|
+
pathRule: admittedPath,
|
|
156
87
|
async authorize() {
|
|
157
88
|
return {};
|
|
158
89
|
},
|
|
159
|
-
async discover() {
|
|
160
|
-
const answer = await transport.read(SITE_DOOR_DISCOVER);
|
|
161
|
-
const failed = discoveryFailure(answer.status, answer.body);
|
|
162
|
-
if (failed !== null)
|
|
163
|
-
return failed;
|
|
164
|
-
const document = parseSiteDiscovery(answer.body);
|
|
165
|
-
if (document === null)
|
|
166
|
-
return UNCERTAIN;
|
|
167
|
-
const entries = siteTracked(document);
|
|
168
|
-
tracked.clear();
|
|
169
|
-
for (const entry of entries)
|
|
170
|
-
tracked.set(entry.locator, entry);
|
|
171
|
-
notifications.track(entries);
|
|
172
|
-
return mapDiscovery(document, entries.map(siteRoom), siteCapabilities());
|
|
173
|
-
},
|
|
174
90
|
async bootstrap(_authorization, request) {
|
|
175
91
|
const entry = tracked.get(request.locator);
|
|
176
92
|
if (entry === undefined)
|
|
177
93
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
178
|
-
|
|
179
|
-
?
|
|
180
|
-
:
|
|
181
|
-
const held = await caughtUp(entry, continued?.after ?? null);
|
|
182
|
-
if ('failure' in held)
|
|
183
|
-
return held.failure;
|
|
184
|
-
notifications.reach(entry.authority, held.scope);
|
|
185
|
-
const seen = [
|
|
186
|
-
...(continued?.seen ?? []),
|
|
187
|
-
...entry.schemas.filter((schema) => held.scope.files.some((file) => file.path === schema)),
|
|
188
|
-
];
|
|
189
|
-
const models = await partModels(held.scope, entry, new Set(seen), held.next === null);
|
|
190
|
-
const continuation = held.next === null ? null : { after: held.next, seen };
|
|
191
|
-
return {
|
|
192
|
-
...(await stepped(bootstrapping(held.scope))),
|
|
193
|
-
...(models === undefined ? {} : { models }),
|
|
194
|
-
...(continuation === null ? {} : { pageToken: JSON.stringify(continuation) }),
|
|
195
|
-
};
|
|
94
|
+
return request.pageToken === undefined
|
|
95
|
+
? listedRoom(entry)
|
|
96
|
+
: chunkPage(entry, request.pageToken, request.arriving);
|
|
196
97
|
},
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
98
|
+
...(snapshot
|
|
99
|
+
? {
|
|
100
|
+
discover: discovered,
|
|
101
|
+
async refresh(_authorization, request) {
|
|
102
|
+
const entry = tracked.get(request.locator);
|
|
103
|
+
if (entry === undefined)
|
|
104
|
+
return { kind: 'room-not-readable', locator: request.locator };
|
|
105
|
+
if (request.pageToken !== undefined)
|
|
106
|
+
return UNCERTAIN;
|
|
107
|
+
return request.fromRoomVersion === roomVersion(entry)
|
|
108
|
+
? { kind: 'still-current' }
|
|
109
|
+
: { kind: 'beyond-horizon' };
|
|
110
|
+
},
|
|
207
111
|
}
|
|
208
|
-
|
|
209
|
-
},
|
|
112
|
+
: {}),
|
|
210
113
|
async mutate() {
|
|
211
114
|
return { kind: 'rejected', affected: {}, code: 'write-grant', fields: {}, retryable: false };
|
|
212
115
|
},
|
|
116
|
+
async attach() {
|
|
117
|
+
return { kind: 'rejected', code: 'write-grant', fields: {}, retryable: false };
|
|
118
|
+
},
|
|
213
119
|
async history() {
|
|
214
120
|
return { kind: 'no-history' };
|
|
215
121
|
},
|
|
@@ -220,8 +126,8 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
220
126
|
const read = await transport.download(route);
|
|
221
127
|
if (read.status === 404)
|
|
222
128
|
return unfound();
|
|
223
|
-
return read.status === 200 && read.
|
|
224
|
-
? { kind: 'binary',
|
|
129
|
+
return read.status === 200 && read.body !== null
|
|
130
|
+
? { kind: 'binary', body: read.body, mediaType: read.mediaType }
|
|
225
131
|
: UNCERTAIN;
|
|
226
132
|
},
|
|
227
133
|
async link(_authorization, request) {
|
|
@@ -234,13 +140,6 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
234
140
|
name: request.path.slice(request.path.lastIndexOf('/') + 1),
|
|
235
141
|
};
|
|
236
142
|
},
|
|
237
|
-
referrerScope(referrer) {
|
|
238
|
-
const named = published(referrer);
|
|
239
|
-
if (named === null)
|
|
240
|
-
return null;
|
|
241
|
-
const { path } = named.referrer;
|
|
242
|
-
return { kind: 'room', locator: named.locator, ...(path === undefined ? {} : { path }) };
|
|
243
|
-
},
|
|
244
143
|
reached(locator, version, target) {
|
|
245
144
|
return reachedVersion(version, target, tracked.get(locator)?.logEpoch);
|
|
246
145
|
},
|
|
@@ -248,7 +147,7 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
248
147
|
return followsVersion(version, next);
|
|
249
148
|
},
|
|
250
149
|
async action(_authorization, request) {
|
|
251
|
-
if (request.name !==
|
|
150
|
+
if (request.name !== SITES_SUBMISSIONS_CREATE) {
|
|
252
151
|
return {
|
|
253
152
|
kind: 'rejected',
|
|
254
153
|
code: 'action-unimplemented',
|
|
@@ -258,28 +157,13 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
258
157
|
}
|
|
259
158
|
if (!transport.online())
|
|
260
159
|
return UNCERTAIN;
|
|
261
|
-
return actionOutcome(await transport.door(SITE_DOOR_SUBMIT, request.input),
|
|
160
|
+
return actionOutcome(await transport.door(SITE_DOOR_SUBMIT, request.input), SITES_SUBMISSIONS_CREATE, request.input);
|
|
262
161
|
},
|
|
263
162
|
roomStream: snapshot
|
|
264
163
|
? undefined
|
|
265
164
|
: {
|
|
266
|
-
hold
|
|
267
|
-
notifications.send(rooms.flatMap((room) => {
|
|
268
|
-
const entry = tracked.get(room.locator);
|
|
269
|
-
const at = logPosition(room.roomVersion);
|
|
270
|
-
if (entry === undefined || at === null)
|
|
271
|
-
return [];
|
|
272
|
-
notifications.reach(entry.authority, at);
|
|
273
|
-
return [presented(entry.authority, at)];
|
|
274
|
-
}));
|
|
275
|
-
},
|
|
276
|
-
reopen: notifications.reopen,
|
|
165
|
+
hold: notifications.send,
|
|
277
166
|
observe: notifications.observe,
|
|
278
|
-
published(locator, roomVersion) {
|
|
279
|
-
const at = logPosition(roomVersion);
|
|
280
|
-
if (at !== null)
|
|
281
|
-
notifications.published(locator, at);
|
|
282
|
-
},
|
|
283
167
|
},
|
|
284
168
|
serviceMode: notifications.serviceMode,
|
|
285
169
|
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type SpaceSchemas = {
|
|
2
|
+
held(space: string, revision: string): string | undefined;
|
|
3
|
+
keep(space: string, revision: string, text: string): void;
|
|
4
|
+
};
|
|
5
|
+
export declare function spaceSchemas(): SpaceSchemas;
|
|
6
|
+
export declare function spaceIdentity(space: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"space-schema.d.ts","sourceRoot":"","sources":["../src/space-schema.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAC1D,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3D,CAAC;AAEF,wBAAgB,YAAY,IAAI,YAAY,CAY3C;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEnD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const HELD_TEXTS = 16;
|
|
2
|
+
export function spaceSchemas() {
|
|
3
|
+
const texts = new Map();
|
|
4
|
+
const key = (space, revision) => `${space} ${revision}`;
|
|
5
|
+
return {
|
|
6
|
+
held: (space, revision) => texts.get(key(space, revision)),
|
|
7
|
+
keep(space, revision, text) {
|
|
8
|
+
const named = key(space, revision);
|
|
9
|
+
texts.delete(named);
|
|
10
|
+
texts.set(named, text);
|
|
11
|
+
if (texts.size > HELD_TEXTS)
|
|
12
|
+
texts.delete(texts.keys().next().value);
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export function spaceIdentity(space) {
|
|
17
|
+
return `space:${space}`;
|
|
18
|
+
}
|
package/dist/stream.d.ts
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type AuthorityChange, type Discovery, type ConversationStream, type HeldRoom, type RoomStreamEvent, type ServiceModeSignal } from '@agentshouse/mdruntime';
|
|
2
2
|
import type { TrackedAuthority } from './discovery.js';
|
|
3
|
-
import type {
|
|
4
|
-
import { type
|
|
5
|
-
export type
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
import type { SpaceSchemas } from './space-schema.js';
|
|
4
|
+
import { type HouseDoor, type HouseMode, type HouseStreamFrame } from './transport.js';
|
|
5
|
+
export type HouseOpeningFrame = Extract<HouseStreamFrame, {
|
|
6
|
+
type: 'opening';
|
|
7
|
+
}>;
|
|
8
|
+
export type HouseAuthorityChangedFrame = Extract<HouseStreamFrame, {
|
|
9
|
+
type: 'authority_changed';
|
|
10
|
+
}>;
|
|
11
|
+
export type HouseDiscovering = {
|
|
12
|
+
opened(frame: HouseOpeningFrame | null): Promise<Discovery | null>;
|
|
13
|
+
changed(frame: HouseAuthorityChangedFrame): AuthorityChange | null;
|
|
14
|
+
expired?(authorities: readonly string[]): void;
|
|
9
15
|
};
|
|
10
16
|
export type HouseNotifications = {
|
|
11
17
|
runtime: string;
|
|
12
|
-
observe(notify: (event: RoomStreamEvent) => void
|
|
13
|
-
send(rooms: readonly
|
|
14
|
-
published(locator: string, at: LogPosition): void;
|
|
15
|
-
reopen(): void;
|
|
18
|
+
observe(notify: (event: RoomStreamEvent) => void): () => void;
|
|
19
|
+
send(rooms: readonly HeldRoom[]): void;
|
|
16
20
|
track(authorities: readonly TrackedAuthority[]): void;
|
|
17
|
-
reach(authority: string, at: LogPosition): void;
|
|
18
|
-
advance(tracked: TrackedAuthority, from: LogPosition, holds?: HeldRevision): Generator<number, StreamedAdvancement | null, void>;
|
|
19
21
|
conversations: ConversationStream;
|
|
20
22
|
serviceMode: ServiceModeSignal;
|
|
21
23
|
};
|
|
22
|
-
export declare function houseNotifications(transport: HouseDoor, mode: HouseMode): HouseNotifications;
|
|
23
|
-
//# sourceMappingURL=stream.d.ts.map
|
|
24
|
+
export declare function houseNotifications(transport: HouseDoor, mode: HouseMode, discovering: HouseDiscovering, spaces: SpaceSchemas): HouseNotifications;
|
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,
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,eAAe,EAEpB,KAAK,SAAS,EACd,KAAK,kBAAkB,EAEvB,KAAK,QAAQ,EAGb,KAAK,eAAe,EAEpB,KAAK,iBAAiB,EAEvB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAYtD,OAAO,EAEL,KAAK,SAAS,EAEd,KAAK,SAAS,EAGd,KAAK,gBAAgB,EACtB,MAAM,gBAAgB,CAAC;AAaxB,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,EAAE;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC,CAAC;AAE/E,MAAM,MAAM,0BAA0B,GAAG,OAAO,CAAC,gBAAgB,EAAE;IAAE,IAAI,EAAE,mBAAmB,CAAA;CAAE,CAAC,CAAC;AAElG,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC;IACnE,OAAO,CAAC,KAAK,EAAE,0BAA0B,GAAG,eAAe,GAAG,IAAI,CAAC;IACnE,OAAO,CAAC,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,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,QAAQ,EAAE,GAAG,IAAI,CAAC;IACvC,KAAK,CAAC,WAAW,EAAE,SAAS,gBAAgB,EAAE,GAAG,IAAI,CAAC;IACtD,aAAa,EAAE,kBAAkB,CAAC;IAClC,WAAW,EAAE,iBAAiB,CAAC;CAChC,CAAC;AA+FF,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,SAAS,EACf,WAAW,EAAE,gBAAgB,EAC7B,MAAM,EAAE,YAAY,GACnB,kBAAkB,CA+XpB"}
|