@agentshouse/mdruntime-adapter 0.1.0-c17fae3d012d0 → 0.1.0-c26cd225263b7
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 +8 -0
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +64 -98
- package/dist/discovery.d.ts +2 -2
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +5 -10
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/links.d.ts +9 -1
- package/dist/links.d.ts.map +1 -1
- package/dist/links.js +40 -2
- package/dist/model.d.ts +7 -18
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +48 -41
- package/dist/read.d.ts +1 -1
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +5 -8
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +38 -72
- package/dist/stream.d.ts +7 -4
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +59 -36
- package/dist/transport.d.ts +14 -1
- 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 +9 -0
- package/dist/write.d.ts +9 -2
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +5 -0
- package/package.json +3 -3
package/AGENTS.md
CHANGED
|
@@ -12,6 +12,14 @@ the reported persistence answer, reauthorization, conversation, the chat draft,
|
|
|
12
12
|
and Presentation State. Sync Status, the Service Mode, the storage-loss
|
|
13
13
|
statement and the deployment facts are observations only.
|
|
14
14
|
|
|
15
|
+
The host attaches each port with its reach, and every member and observation
|
|
16
|
+
answers within it: a Room outside it answers as one the replica does not hold, a
|
|
17
|
+
Room reached for single Documents shows only those Documents, the Types of the
|
|
18
|
+
models that govern them and no attachments, and without conversations the
|
|
19
|
+
conversation members, the chat draft and the conversation observation hold none.
|
|
20
|
+
A change of the reach reaches every open observation as its new value, a query
|
|
21
|
+
keeping every unchanged Document the same object.
|
|
22
|
+
|
|
15
23
|
Every `observe` resolves, once its first value has arrived, to a handle:
|
|
16
24
|
`current()` is the latest complete value, `subscribe(listener)` hears each later
|
|
17
25
|
value whole and returns its unsubscribe, and `close()` ends the observation.
|
package/dist/adapter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,OAAO,EACP,aAAa,
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,OAAO,EACP,aAAa,EAWd,MAAM,wBAAwB,CAAC;AAqChC,OAAO,EAQL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAyBxB,MAAM,MAAM,yBAAyB,GACjC;IACE,SAAS,EAAE,cAAc,CAAC;IAC1B,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;CACrC,GACD;IAAE,IAAI,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAsBjC,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CA0WpF"}
|
package/dist/adapter.js
CHANGED
|
@@ -1,26 +1,20 @@
|
|
|
1
|
-
import { DISCOVER_PREFIXES, capabilities, discoveredRoom,
|
|
2
|
-
import {
|
|
1
|
+
import { DISCOVER_PREFIXES, capabilities, discoveredRoom, mapDiscovery, parseDiscovery, trackedFrom, } from './discovery.js';
|
|
2
|
+
import { scopeModels, streamedModels, viewModels } from './model.js';
|
|
3
3
|
import { gathered, selections } from './gather.js';
|
|
4
4
|
import { createSiteAdapter } from './site.js';
|
|
5
|
-
import { bootstrapOf, contentPrefixes, matchesScope, parseEnumeration, parseEnvelope, parseGrant, refreshFrom,
|
|
6
|
-
import { enumeratedLinks, scopeLinks, streamedLinks } from './links.js';
|
|
5
|
+
import { bootstrapOf, contentPrefixes, matchesScope, parseEnumeration, parseEnvelope, parseGrant, refreshFrom, viewOf, } from './read.js';
|
|
6
|
+
import { acceptedLinks, enumeratedLinks, heldLinks, scopeLinks, streamedLinks, } from './links.js';
|
|
7
7
|
import { houseAction } from './actions.js';
|
|
8
8
|
import { classifyDoor, discoveryFailure, doorRefusal } from './refusal.js';
|
|
9
9
|
import { houseNotifications } from './stream.js';
|
|
10
10
|
import { DOOR_BATCH, DOOR_BATCH_UPLOAD, DOOR_BOOTSTRAP, DOOR_DISCOVER, DOOR_ENUMERATE, DOOR_REVISIONS, PRIVATE_LOCATOR, } from './transport.js';
|
|
11
11
|
import { batchPaths, deltaBody, deltaBytes, deltaDigest, historyOutcome, houseChanges, mutationOutcome, operationHead, rejectedMapping, revisionBody, uploadable, } from './write.js';
|
|
12
|
-
import { logPosition, presented, reachedVersion, roomVersion, } from './version.js';
|
|
12
|
+
import { followsVersion, logPosition, presented, reachedVersion, roomVersion, } from './version.js';
|
|
13
13
|
const UNCERTAIN = { kind: 'transport-uncertainty' };
|
|
14
14
|
const UNCERTAIN_READ = { kind: 'transport-uncertainty' };
|
|
15
15
|
function lapsedGrant(outcome) {
|
|
16
16
|
return outcome.kind === 'rejected' && outcome.code === 'upload_unavailable';
|
|
17
17
|
}
|
|
18
|
-
function modelFailure(classified, envelope) {
|
|
19
|
-
if (classified === null) {
|
|
20
|
-
return envelope === null ? { kind: 'transport-uncertainty' } : MODEL_ABSENT;
|
|
21
|
-
}
|
|
22
|
-
return failedModel(classified);
|
|
23
|
-
}
|
|
24
18
|
export function createAgentsHouseAdapter(options) {
|
|
25
19
|
if ('site' in options)
|
|
26
20
|
return createSiteAdapter(options.site);
|
|
@@ -28,80 +22,75 @@ export function createAgentsHouseAdapter(options) {
|
|
|
28
22
|
const notifications = houseNotifications(transport, 'credential');
|
|
29
23
|
const tracked = new Map();
|
|
30
24
|
const handed = new Map();
|
|
31
|
-
const models = modelShelf();
|
|
32
25
|
let bounds;
|
|
33
26
|
function declared() {
|
|
34
27
|
if (bounds === undefined)
|
|
35
28
|
throw new Error('no Discovery declared the bounds');
|
|
36
29
|
return bounds;
|
|
37
30
|
}
|
|
38
|
-
function bootstrappedRoom(envelope, entry) {
|
|
31
|
+
async function bootstrappedRoom(envelope, entry) {
|
|
39
32
|
const scope = envelope.scopes.find((candidate) => matchesScope(candidate, entry));
|
|
40
33
|
if (scope === undefined)
|
|
41
34
|
return { kind: 'room-not-readable', locator: entry.locator };
|
|
42
35
|
handed.set(entry.locator, scopeLinks(scope));
|
|
43
|
-
notifications.
|
|
44
|
-
|
|
36
|
+
notifications.reach(entry.authority, scope);
|
|
37
|
+
const models = await scopeModels(scope, entry);
|
|
38
|
+
return { ...bootstrapOf(scope), ...(models === undefined ? {} : { models }) };
|
|
45
39
|
}
|
|
46
|
-
function enumeratedRoom(enumeration, ask) {
|
|
40
|
+
async function enumeratedRoom(enumeration, ask) {
|
|
47
41
|
const view = viewOf(enumeration, ask.entry);
|
|
48
42
|
if (view === undefined)
|
|
49
43
|
return { kind: 'room-not-readable', locator: ask.entry.locator };
|
|
50
|
-
notifications.
|
|
44
|
+
notifications.reach(ask.entry.authority, view);
|
|
51
45
|
const answer = refreshFrom(view, ask.fromRoomVersion);
|
|
52
|
-
if (answer.kind
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
if (answer.kind !== 'net-advancement')
|
|
47
|
+
return answer;
|
|
48
|
+
handed.set(ask.entry.locator, enumeratedLinks(view, handed.get(ask.entry.locator)));
|
|
49
|
+
const models = await viewModels(view, ask.entry);
|
|
50
|
+
return models === undefined ? answer : { ...answer, models };
|
|
56
51
|
}
|
|
57
|
-
function streamed(entry, request, from) {
|
|
52
|
+
async function streamed(entry, request, from) {
|
|
58
53
|
const links = handed.get(entry.locator);
|
|
59
54
|
if (links?.roomVersion !== request.fromRoomVersion)
|
|
60
55
|
return null;
|
|
61
56
|
const advanced = notifications.advance(entry, from, (path, revision) => links.revisions.get(path) === revision);
|
|
62
57
|
if (advanced === null)
|
|
63
58
|
return null;
|
|
64
|
-
if (request.minPosition !== undefined &&
|
|
65
|
-
!reachedVersion(advanced.page.roomVersion, request.minPosition, entry.logEpoch))
|
|
66
|
-
return null;
|
|
67
59
|
const relinked = streamedLinks(links, advanced);
|
|
68
60
|
if (relinked === null)
|
|
69
61
|
return null;
|
|
70
62
|
handed.set(entry.locator, relinked);
|
|
71
|
-
|
|
63
|
+
const models = await streamedModels(advanced.schemas, entry, 'credential');
|
|
64
|
+
return models === undefined ? advanced.page : { ...advanced.page, models };
|
|
72
65
|
}
|
|
73
|
-
function held(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
});
|
|
85
|
-
const classified = classifyDoor(answer.status, answer.body, PRIVATE_LOCATOR);
|
|
86
|
-
const envelope = classified === null ? parseEnvelope(await bundled(answer.body)) : null;
|
|
87
|
-
const failure = modelFailure(classified, envelope);
|
|
88
|
-
for (const entry of part) {
|
|
89
|
-
acquired.set(modelKey(entry.locator, 'collection'), await held(envelope, entry, entry.schema, failure));
|
|
90
|
-
if (entry.houseModel === null)
|
|
91
|
-
continue;
|
|
92
|
-
acquired.set(modelKey(entry.locator, 'typed-selection'), await held(envelope, entry, entry.houseModel.root, failure));
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return acquired;
|
|
66
|
+
function held(rooms) {
|
|
67
|
+
const kept = rooms.flatMap((room) => {
|
|
68
|
+
const entry = tracked.get(room.locator);
|
|
69
|
+
const at = logPosition(room.roomVersion);
|
|
70
|
+
if (entry === undefined || at === null)
|
|
71
|
+
return [];
|
|
72
|
+
handed.set(room.locator, heldLinks(room));
|
|
73
|
+
notifications.reach(entry.authority, at);
|
|
74
|
+
return [presented(entry.authority, at)];
|
|
75
|
+
});
|
|
76
|
+
notifications.send(kept);
|
|
96
77
|
}
|
|
97
|
-
function
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
78
|
+
function adopted(entry, outcome) {
|
|
79
|
+
if (outcome.kind !== 'accepted')
|
|
80
|
+
return outcome;
|
|
81
|
+
const { originals, ...accepted } = outcome;
|
|
82
|
+
const links = handed.get(entry.locator);
|
|
83
|
+
if (links === undefined)
|
|
84
|
+
return accepted;
|
|
85
|
+
const follows = followsVersion(links.roomVersion, accepted.roomVersion);
|
|
86
|
+
const relinked = acceptedLinks(links, accepted, follows ? accepted.roomVersion : links.roomVersion, originals);
|
|
87
|
+
handed.set(entry.locator, relinked.links);
|
|
88
|
+
const at = logPosition(accepted.roomVersion);
|
|
89
|
+
if (follows && at !== null)
|
|
90
|
+
notifications.reach(entry.authority, at);
|
|
91
|
+
return relinked.attachments === undefined
|
|
92
|
+
? accepted
|
|
93
|
+
: { ...accepted, attachments: relinked.attachments };
|
|
105
94
|
}
|
|
106
95
|
function authorityFor(locator) {
|
|
107
96
|
return tracked.get(locator);
|
|
@@ -147,14 +136,14 @@ export function createAgentsHouseAdapter(options) {
|
|
|
147
136
|
});
|
|
148
137
|
const classified = part.map((entry) => classifyDoor(answer.status, answer.body, entry.locator));
|
|
149
138
|
const envelope = classified[0] === null ? parseEnvelope(await bundled(answer.body)) : null;
|
|
150
|
-
part.
|
|
139
|
+
for (const [index, entry] of part.entries()) {
|
|
151
140
|
const failure = classified[index];
|
|
152
141
|
if (failure === null || failure === undefined) {
|
|
153
|
-
answers.push(envelope === null ? UNCERTAIN_READ : bootstrappedRoom(envelope, entry));
|
|
154
|
-
|
|
142
|
+
answers.push(envelope === null ? UNCERTAIN_READ : await bootstrappedRoom(envelope, entry));
|
|
143
|
+
continue;
|
|
155
144
|
}
|
|
156
145
|
answers.push(failure.kind === 'beyond-horizon' ? UNCERTAIN_READ : failure);
|
|
157
|
-
}
|
|
146
|
+
}
|
|
158
147
|
}
|
|
159
148
|
return answers;
|
|
160
149
|
}
|
|
@@ -176,23 +165,8 @@ export function createAgentsHouseAdapter(options) {
|
|
|
176
165
|
while (open.length > 0) {
|
|
177
166
|
const answer = await transport.door(DOOR_ENUMERATE, {
|
|
178
167
|
prefixes: open.flatMap((ask) => contentPrefixes(ask.entry)),
|
|
179
|
-
positions: open.map((ask) => (
|
|
180
|
-
...presented(ask.entry.authority, ask.from),
|
|
181
|
-
...(ask.minPosition === undefined ? {} : { min_position: ask.minPosition }),
|
|
182
|
-
})),
|
|
168
|
+
positions: open.map((ask) => presented(ask.entry.authority, ask.from)),
|
|
183
169
|
});
|
|
184
|
-
const refusal = doorRefusal(answer.body);
|
|
185
|
-
if (refusal?.code === 'replica_behind') {
|
|
186
|
-
const named = open.filter((ask) => ask.entry.authority === refusal.fields.authority);
|
|
187
|
-
const behind = named.length === 0 ? open : named;
|
|
188
|
-
for (const ask of behind) {
|
|
189
|
-
answers.set(ask, refusal.retryable
|
|
190
|
-
? { kind: 'retryable-refusal', code: refusal.code, fields: refusal.fields }
|
|
191
|
-
: (classifyDoor(answer.status, answer.body, ask.entry.locator) ?? UNCERTAIN_READ));
|
|
192
|
-
}
|
|
193
|
-
open = open.filter((ask) => !behind.includes(ask));
|
|
194
|
-
continue;
|
|
195
|
-
}
|
|
196
170
|
const classified = open.map((ask) => classifyDoor(answer.status, answer.body, ask.entry.locator));
|
|
197
171
|
if (classified[0]?.kind === 'beyond-horizon') {
|
|
198
172
|
const named = doorRefusal(answer.body)?.fields.authority;
|
|
@@ -205,14 +179,14 @@ export function createAgentsHouseAdapter(options) {
|
|
|
205
179
|
continue;
|
|
206
180
|
}
|
|
207
181
|
const enumeration = classified[0] === null ? parseEnumeration(answer.body, 'credential') : null;
|
|
208
|
-
open.
|
|
182
|
+
for (const [index, ask] of open.entries()) {
|
|
209
183
|
const failure = classified[index];
|
|
210
184
|
if (failure !== null && failure !== undefined) {
|
|
211
185
|
answers.set(ask, failure);
|
|
212
|
-
|
|
186
|
+
continue;
|
|
213
187
|
}
|
|
214
|
-
answers.set(ask, enumeration === null ? UNCERTAIN_READ : enumeratedRoom(enumeration, ask));
|
|
215
|
-
}
|
|
188
|
+
answers.set(ask, enumeration === null ? UNCERTAIN_READ : await enumeratedRoom(enumeration, ask));
|
|
189
|
+
}
|
|
216
190
|
open = [];
|
|
217
191
|
}
|
|
218
192
|
}
|
|
@@ -263,9 +237,6 @@ export function createAgentsHouseAdapter(options) {
|
|
|
263
237
|
async authorize() {
|
|
264
238
|
return options.authorize();
|
|
265
239
|
},
|
|
266
|
-
async model(_authorization, request) {
|
|
267
|
-
return models.answer(request);
|
|
268
|
-
},
|
|
269
240
|
async discover(_authorization) {
|
|
270
241
|
const answer = await transport.door(DOOR_DISCOVER, { prefixes: [...DISCOVER_PREFIXES] });
|
|
271
242
|
const classified = classifyDoor(answer.status, answer.body, PRIVATE_LOCATOR);
|
|
@@ -283,9 +254,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
283
254
|
if (!tracked.has(locator))
|
|
284
255
|
handed.delete(locator);
|
|
285
256
|
notifications.track(entries);
|
|
286
|
-
|
|
287
|
-
models.keep(entries.map((entry) => entry.locator));
|
|
288
|
-
return mapDiscovery(document, document.authorities.map((authority) => roomOf(authority, acquired)), capabilities(document.actions));
|
|
257
|
+
return mapDiscovery(document, document.authorities.map((authority) => discoveredRoom(authority)), capabilities(document.actions));
|
|
289
258
|
},
|
|
290
259
|
async bootstrap(_authorization, request) {
|
|
291
260
|
const entry = authorityFor(request.locator);
|
|
@@ -304,16 +273,10 @@ export function createAgentsHouseAdapter(options) {
|
|
|
304
273
|
const from = logPosition(request.fromRoomVersion);
|
|
305
274
|
if (from === null)
|
|
306
275
|
return { kind: 'beyond-horizon' };
|
|
307
|
-
const answered = streamed(entry, request, from);
|
|
276
|
+
const answered = await streamed(entry, request, from);
|
|
308
277
|
if (answered !== null)
|
|
309
278
|
return answered;
|
|
310
|
-
|
|
311
|
-
return enumerateTogether({
|
|
312
|
-
entry,
|
|
313
|
-
from,
|
|
314
|
-
fromRoomVersion: request.fromRoomVersion,
|
|
315
|
-
...(minPosition?.logEpoch === from.logEpoch ? { minPosition: minPosition.position } : {}),
|
|
316
|
-
});
|
|
279
|
+
return enumerateTogether({ entry, from, fromRoomVersion: request.fromRoomVersion });
|
|
317
280
|
},
|
|
318
281
|
async mutate(_authorization, request, keep) {
|
|
319
282
|
const entry = authorityFor(request.locator);
|
|
@@ -328,8 +291,8 @@ export function createAgentsHouseAdapter(options) {
|
|
|
328
291
|
const handed = request.upload;
|
|
329
292
|
const outcome = await submit(head, mapped.changes, delta, bytes, entry, handed, keep);
|
|
330
293
|
if (handed === undefined || !lapsedGrant(outcome))
|
|
331
|
-
return outcome;
|
|
332
|
-
return submit(head, mapped.changes, delta, bytes, entry, undefined, keep);
|
|
294
|
+
return adopted(entry, outcome);
|
|
295
|
+
return adopted(entry, await submit(head, mapped.changes, delta, bytes, entry, undefined, keep));
|
|
333
296
|
},
|
|
334
297
|
async history(_authorization, request) {
|
|
335
298
|
const entry = authorityFor(request.locator);
|
|
@@ -349,10 +312,13 @@ export function createAgentsHouseAdapter(options) {
|
|
|
349
312
|
reached(locator, version, target) {
|
|
350
313
|
return reachedVersion(version, target, authorityFor(locator)?.logEpoch);
|
|
351
314
|
},
|
|
315
|
+
follows(_locator, version, next) {
|
|
316
|
+
return followsVersion(version, next);
|
|
317
|
+
},
|
|
352
318
|
async action(_authorization, request) {
|
|
353
319
|
return withAt(await houseAction(transport, request));
|
|
354
320
|
},
|
|
355
|
-
|
|
321
|
+
roomStream: { hold: held, observe: notifications.observe },
|
|
356
322
|
conversations: notifications.conversations,
|
|
357
323
|
serviceMode: notifications.serviceMode,
|
|
358
324
|
};
|
package/dist/discovery.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Capability, DiscoveredRoom, Discovery,
|
|
1
|
+
import type { Capability, DiscoveredRoom, Discovery, ProviderLimit, Retention } from '@agentshouse/mdruntime';
|
|
2
2
|
import { type LogPosition } from './version.js';
|
|
3
3
|
export declare const ROOM_CONTRACT_VERSION = 1;
|
|
4
4
|
export declare const MD_MODEL_IDENTITY = "@agentshouse/mdmodel";
|
|
@@ -74,6 +74,6 @@ export declare function providerLimits(bounds: HouseBounds): readonly ProviderLi
|
|
|
74
74
|
export declare function declaredRetention(bounds: HouseBounds): Retention;
|
|
75
75
|
export declare function capabilities(actions: readonly string[]): readonly Capability[];
|
|
76
76
|
export declare function siteCapabilities(): readonly Capability[];
|
|
77
|
-
export declare function discoveredRoom(authority: HouseAuthority
|
|
77
|
+
export declare function discoveredRoom(authority: HouseAuthority): DiscoveredRoom;
|
|
78
78
|
export declare function mapDiscovery(document: Pick<HouseDiscoveryDocument, 'bounds' | 'mdModelVersion'>, rooms: readonly DiscoveredRoom[], declared: readonly Capability[]): Discovery;
|
|
79
79
|
//# sourceMappingURL=discovery.d.ts.map
|
package/dist/discovery.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,SAAS,EACT,aAAa,EACb,
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"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"}
|
package/dist/discovery.js
CHANGED
|
@@ -234,10 +234,11 @@ export function siteCapabilities() {
|
|
|
234
234
|
{ name: PROVIDER_ACTIONS, actions: [{ name: 'submit', inputShape: {}, resultKind: 'house' }] },
|
|
235
235
|
];
|
|
236
236
|
}
|
|
237
|
-
export function discoveredRoom(authority
|
|
237
|
+
export function discoveredRoom(authority) {
|
|
238
|
+
const locator = locatorOf(authority);
|
|
238
239
|
return {
|
|
239
240
|
name: authority.name,
|
|
240
|
-
locator
|
|
241
|
+
locator,
|
|
241
242
|
roomVersion: roomVersion(authority),
|
|
242
243
|
operations: {
|
|
243
244
|
read: [...authority.operations.read],
|
|
@@ -245,16 +246,10 @@ export function discoveredRoom(authority, attachedModel, selectionModel) {
|
|
|
245
246
|
write: [...authority.operations.write],
|
|
246
247
|
delete: [...authority.operations.delete],
|
|
247
248
|
},
|
|
248
|
-
replica: { selection:
|
|
249
|
-
attachedModel,
|
|
249
|
+
replica: { selection: locator, admission: authority.managedReplication },
|
|
250
250
|
...(authority.houseModel === null
|
|
251
251
|
? {}
|
|
252
|
-
: {
|
|
253
|
-
typedSelection: {
|
|
254
|
-
roots: [...authority.houseModel.paths],
|
|
255
|
-
attachedModel: selectionModel,
|
|
256
|
-
},
|
|
257
|
-
}),
|
|
252
|
+
: { typedSelection: { roots: [...authority.houseModel.paths] } }),
|
|
258
253
|
providerOwnedPaths: [...authority.protectedPaths, ...schemasOf(authority)],
|
|
259
254
|
};
|
|
260
255
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { createAgentsHouseAdapter, type AgentsHouseAdapterOptions } from './adapter.js';
|
|
2
|
-
export
|
|
2
|
+
export { PRIVATE_LOCATOR } from './transport.js';
|
|
3
|
+
export type { HouseByteAct, HouseByteAnswer, HouseByteTransfer, HouseDoorAnswer, HouseHeldRoom, HouseOpening, HouseStream, HouseStreamEntry, HouseStreamFrame, HouseSiteTransport, HouseTransport, } from './transport.js';
|
|
3
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,KAAK,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACxF,YAAY,EACV,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,GACf,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,KAAK,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,YAAY,EACV,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,GACf,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/links.d.ts
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
|
+
import type { HeldRoom, MutationResult, RoomAttachment } from '@agentshouse/mdruntime';
|
|
1
2
|
import type { HouseScope, HouseView } from './read.js';
|
|
2
3
|
import type { StreamedAdvancement } from './stream.js';
|
|
3
4
|
export type RoomLinks = {
|
|
4
5
|
roomVersion: string;
|
|
5
|
-
handed:
|
|
6
|
+
handed: ReadonlyMap<string, RoomAttachment>;
|
|
6
7
|
paths: ReadonlyMap<string, ReadonlySet<string>>;
|
|
7
8
|
revisions: ReadonlyMap<string, string>;
|
|
8
9
|
};
|
|
9
10
|
export declare function scopeLinks(scope: HouseScope): RoomLinks;
|
|
11
|
+
export declare function heldLinks(held: HeldRoom): RoomLinks;
|
|
12
|
+
export declare function acceptedLinks(held: RoomLinks, accepted: Extract<MutationResult, {
|
|
13
|
+
kind: 'accepted';
|
|
14
|
+
}>, roomVersion: string, originals: readonly RoomAttachment[]): {
|
|
15
|
+
links: RoomLinks;
|
|
16
|
+
attachments?: readonly RoomAttachment[];
|
|
17
|
+
};
|
|
10
18
|
export declare function enumeratedLinks(view: HouseView, earlier: RoomLinks | undefined): RoomLinks;
|
|
11
19
|
export declare function streamedLinks(held: RoomLinks, advanced: StreamedAdvancement): RoomLinks | null;
|
|
12
20
|
//# sourceMappingURL=links.d.ts.map
|
package/dist/links.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../src/links.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../src/links.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACvF,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAOvD,MAAM,MAAM,SAAS,GAAG;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC5C,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;IAChD,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC,CAAC;AAcF,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,CAWvD;AAOD,wBAAgB,SAAS,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,CAOnD;AAED,wBAAgB,aAAa,CAC3B,IAAI,EAAE,SAAS,EACf,QAAQ,EAAE,OAAO,CAAC,cAAc,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,EACvD,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,SAAS,cAAc,EAAE,GACnC;IAAE,KAAK,EAAE,SAAS,CAAC;IAAC,WAAW,CAAC,EAAE,SAAS,cAAc,EAAE,CAAA;CAAE,CA2B/D;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAgB1F;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,mBAAmB,GAAG,SAAS,GAAG,IAAI,CAoB9F"}
|
package/dist/links.js
CHANGED
|
@@ -8,7 +8,7 @@ function linkedBy(text) {
|
|
|
8
8
|
return references.size === 0 ? NONE : references;
|
|
9
9
|
}
|
|
10
10
|
function handedOf(attachments) {
|
|
11
|
-
return new
|
|
11
|
+
return new Map((attachments ?? []).map((attachment) => [attachment.reference, attachment]));
|
|
12
12
|
}
|
|
13
13
|
export function scopeLinks(scope) {
|
|
14
14
|
return {
|
|
@@ -24,6 +24,44 @@ function revised(revisions, path, revision) {
|
|
|
24
24
|
else
|
|
25
25
|
revisions.set(path, revision);
|
|
26
26
|
}
|
|
27
|
+
export function heldLinks(held) {
|
|
28
|
+
return {
|
|
29
|
+
roomVersion: held.roomVersion,
|
|
30
|
+
handed: handedOf(held.attachments),
|
|
31
|
+
paths: new Map(Object.entries(held.documents).map(([path, text]) => [path, linkedBy(text)])),
|
|
32
|
+
revisions: new Map(Object.entries(held.revisions)),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export function acceptedLinks(held, accepted, roomVersion, originals) {
|
|
36
|
+
const paths = new Map(held.paths);
|
|
37
|
+
const revisions = new Map(held.revisions);
|
|
38
|
+
const handed = new Map(held.handed);
|
|
39
|
+
const answered = handedOf(originals);
|
|
40
|
+
for (const [path, text] of Object.entries(accepted.documents)) {
|
|
41
|
+
const linked = linkedBy(text);
|
|
42
|
+
for (const reference of linked) {
|
|
43
|
+
const original = answered.get(reference);
|
|
44
|
+
if (!handed.has(reference) && original !== undefined)
|
|
45
|
+
handed.set(reference, original);
|
|
46
|
+
}
|
|
47
|
+
paths.set(path, linked);
|
|
48
|
+
}
|
|
49
|
+
for (const [path, revision] of Object.entries(accepted.revisions))
|
|
50
|
+
revisions.set(path, revision);
|
|
51
|
+
for (const path of accepted.removals) {
|
|
52
|
+
paths.delete(path);
|
|
53
|
+
revisions.delete(path);
|
|
54
|
+
}
|
|
55
|
+
const linked = new Set([...paths.values()].flatMap((references) => [...references]));
|
|
56
|
+
for (const reference of held.handed.keys()) {
|
|
57
|
+
const before = [...held.paths.values()].some((references) => references.has(reference));
|
|
58
|
+
if (before && !linked.has(reference))
|
|
59
|
+
handed.delete(reference);
|
|
60
|
+
}
|
|
61
|
+
const links = { roomVersion, handed, paths, revisions };
|
|
62
|
+
const changed = handed.size !== held.handed.size || [...handed.keys()].some((key) => !held.handed.has(key));
|
|
63
|
+
return changed ? { links, attachments: [...handed.values()] } : { links };
|
|
64
|
+
}
|
|
27
65
|
export function enumeratedLinks(view, earlier) {
|
|
28
66
|
const paths = new Map(earlier?.paths);
|
|
29
67
|
const revisions = new Map(earlier?.revisions);
|
|
@@ -50,7 +88,7 @@ export function streamedLinks(held, advanced) {
|
|
|
50
88
|
for (const reference of linked)
|
|
51
89
|
if (!held.handed.has(reference))
|
|
52
90
|
return null;
|
|
53
|
-
for (const reference of paths.get(entry.path) ?? held.handed) {
|
|
91
|
+
for (const reference of paths.get(entry.path) ?? held.handed.keys()) {
|
|
54
92
|
if (held.handed.has(reference) && !linked.has(reference))
|
|
55
93
|
dropped.add(reference);
|
|
56
94
|
}
|
package/dist/model.d.ts
CHANGED
|
@@ -1,19 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export declare
|
|
8
|
-
export declare function failedModel(failure: AdapterFailure | {
|
|
9
|
-
kind: 'beyond-horizon';
|
|
10
|
-
}): ModelResult;
|
|
11
|
-
export declare function modelKey(locator: string, attached: ModelRequest['attached']): string;
|
|
12
|
-
export declare function heldModel(read: HouseSchema | null, identity: string, failure: ModelResult): Promise<HeldModel>;
|
|
13
|
-
export type ModelShelf = {
|
|
14
|
-
retain(key: string, acquired: HeldModel | undefined): HeldModel | undefined;
|
|
15
|
-
answer(request: ModelRequest): ModelResult;
|
|
16
|
-
keep(locators: readonly string[]): void;
|
|
17
|
-
};
|
|
18
|
-
export declare function modelShelf(): ModelShelf;
|
|
1
|
+
import type { RoomModels } from '@agentshouse/mdruntime';
|
|
2
|
+
import type { TrackedAuthority } from './discovery.js';
|
|
3
|
+
import { type HouseScope, type HouseView } from './read.js';
|
|
4
|
+
import type { HouseMode, HouseStreamEntry } from './transport.js';
|
|
5
|
+
export declare function scopeModels(scope: HouseScope, tracked: TrackedAuthority): Promise<RoomModels | undefined>;
|
|
6
|
+
export declare function viewModels(view: HouseView, tracked: TrackedAuthority): Promise<RoomModels | undefined>;
|
|
7
|
+
export declare function streamedModels(schemas: ReadonlyMap<string, HouseStreamEntry>, tracked: TrackedAuthority, mode: HouseMode): Promise<RoomModels | undefined>;
|
|
19
8
|
//# sourceMappingURL=model.d.ts.map
|
package/dist/model.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAA0C,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AACpG,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAiClE,wBAAgB,WAAW,CACzB,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAEjC;AAED,wBAAgB,UAAU,CACxB,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAQjC;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,EAC9C,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,SAAS,GACd,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CASjC"}
|
package/dist/model.js
CHANGED
|
@@ -1,46 +1,53 @@
|
|
|
1
1
|
import { sha256Hex } from './digest.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (failure.kind === 'transport-uncertainty')
|
|
7
|
-
return { kind: 'transport-uncertainty' };
|
|
8
|
-
return MODEL_ABSENT;
|
|
9
|
-
}
|
|
10
|
-
export function modelKey(locator, attached) {
|
|
11
|
-
return `${locator} ${attached}`;
|
|
12
|
-
}
|
|
13
|
-
export async function heldModel(read, identity, failure) {
|
|
2
|
+
import { schemaOf, schemaPath } from './read.js';
|
|
3
|
+
const MODEL_ABSENT = { kind: 'model-unavailable', reason: 'not-readable' };
|
|
4
|
+
const ABSENT_SCHEMA = { schema: null, version: null };
|
|
5
|
+
async function heldModel(read, identity) {
|
|
14
6
|
if (read === null)
|
|
15
|
-
return
|
|
7
|
+
return MODEL_ABSENT;
|
|
16
8
|
const version = await sha256Hex(JSON.stringify(read.version));
|
|
17
|
-
return {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
9
|
+
return { kind: 'model', snapshot: { identity, version, schema: read.schema } };
|
|
10
|
+
}
|
|
11
|
+
async function modelsOf(tracked, read) {
|
|
12
|
+
const models = {};
|
|
13
|
+
const collection = read(tracked.schema);
|
|
14
|
+
if (collection !== undefined) {
|
|
15
|
+
models.collection = await heldModel(collection, schemaPath(tracked.handle, tracked.schema));
|
|
16
|
+
}
|
|
17
|
+
if (tracked.houseModel !== null) {
|
|
18
|
+
const root = tracked.houseModel.root;
|
|
19
|
+
const selection = read(root);
|
|
20
|
+
if (selection !== undefined) {
|
|
21
|
+
models.selection = await heldModel(selection, schemaPath(tracked.handle, root));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return models.collection === undefined && models.selection === undefined ? undefined : models;
|
|
25
|
+
}
|
|
26
|
+
export function scopeModels(scope, tracked) {
|
|
27
|
+
return modelsOf(tracked, (schema) => schemaOf(scope, schema));
|
|
28
|
+
}
|
|
29
|
+
export function viewModels(view, tracked) {
|
|
30
|
+
return modelsOf(tracked, (schema) => {
|
|
31
|
+
const change = view.changes.find((candidate) => candidate.path === schema);
|
|
32
|
+
if (change === undefined)
|
|
33
|
+
return undefined;
|
|
34
|
+
if ('removed' in change)
|
|
35
|
+
return ABSENT_SCHEMA;
|
|
36
|
+
if ('content' in change)
|
|
37
|
+
return { schema: change.content, version: change.version };
|
|
38
|
+
return null;
|
|
39
|
+
});
|
|
21
40
|
}
|
|
22
|
-
export function
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return acquired;
|
|
35
|
-
},
|
|
36
|
-
answer(request) {
|
|
37
|
-
return models.get(modelKey(request.locator, request.attached))?.snapshot ?? MODEL_ABSENT;
|
|
38
|
-
},
|
|
39
|
-
keep(locators) {
|
|
40
|
-
for (const key of [...models.keys()]) {
|
|
41
|
-
if (!locators.some((locator) => key.startsWith(`${locator} `)))
|
|
42
|
-
models.delete(key);
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
};
|
|
41
|
+
export function streamedModels(schemas, tracked, mode) {
|
|
42
|
+
return modelsOf(tracked, (schema) => {
|
|
43
|
+
const entry = schemas.get(schema);
|
|
44
|
+
if (entry === undefined)
|
|
45
|
+
return undefined;
|
|
46
|
+
if (entry.kind === 'removed')
|
|
47
|
+
return ABSENT_SCHEMA;
|
|
48
|
+
if (entry.text === undefined)
|
|
49
|
+
return null;
|
|
50
|
+
const version = mode === 'site' ? entry.sha256 : entry.revision;
|
|
51
|
+
return version === undefined ? null : { schema: entry.text, version };
|
|
52
|
+
});
|
|
46
53
|
}
|
package/dist/read.d.ts
CHANGED
|
@@ -61,6 +61,7 @@ export declare function headChange(held: {
|
|
|
61
61
|
readonly author?: unknown;
|
|
62
62
|
readonly created_at?: unknown;
|
|
63
63
|
}): HeadChange | undefined | null;
|
|
64
|
+
export declare function parseOriginals(value: unknown): readonly RoomAttachment[] | null;
|
|
64
65
|
export declare function parseEnvelope(body: unknown): HouseEnvelope | null;
|
|
65
66
|
export declare function parseSiteBootstrap(body: unknown): HouseScope | null;
|
|
66
67
|
export declare function parseEnumeration(body: unknown, mode: HouseMode): HouseEnumeration | null;
|
|
@@ -71,7 +72,6 @@ export type HouseSchema = {
|
|
|
71
72
|
schema: string | null;
|
|
72
73
|
version: string | null;
|
|
73
74
|
};
|
|
74
|
-
export declare function schemaFrom(envelope: HouseEnvelope, tracked: TrackedAuthority, schema: string): HouseSchema | null;
|
|
75
75
|
export declare function schemaOf(scope: HouseScope, schema: string): HouseSchema | null;
|
|
76
76
|
export declare function viewOf(enumeration: HouseEnumeration, tracked: TrackedAuthority): HouseView | undefined;
|
|
77
77
|
export declare function refreshFrom(view: HouseView, fromRoomVersion: string): RefreshResult;
|