@agentshouse/mdruntime-adapter 0.1.0-cca5d676bc88e → 0.1.0-cd59fd8945dcb
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 +88 -29
- package/dist/actions.d.ts +40 -2
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +104 -122
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +77 -52
- package/dist/discovery.d.ts +3 -4
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +22 -12
- package/dist/gather.d.ts +1 -0
- package/dist/gather.d.ts.map +1 -1
- package/dist/gather.js +11 -6
- 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 +1 -0
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +23 -6
- package/dist/read.d.ts +6 -1
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +17 -34
- package/dist/refusal.d.ts +5 -9
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +30 -17
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +17 -9
- package/dist/stream.d.ts +1 -0
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +5 -0
- package/dist/transport.d.ts +3 -6
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +0 -1
- package/dist/write.d.ts +1 -0
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +39 -15
- package/package.json +4 -4
package/dist/adapter.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { DISCOVER_PREFIXES, capabilities, discoveredRoom, mapDiscovery, parseDiscovery, trackedFrom, } from './discovery.js';
|
|
2
|
-
import {
|
|
3
|
-
import { gathered, selections } from './gather.js';
|
|
2
|
+
import { partModels, streamedModels, viewModels } from './model.js';
|
|
3
|
+
import { gathered, gatheredEach, selections } from './gather.js';
|
|
4
4
|
import { createSiteAdapter } from './site.js';
|
|
5
5
|
import { bootstrapOf, contentPrefixes, matchesScope, parseEnumeration, parseEnvelope, parseGrant, refreshFrom, viewOf, } from './read.js';
|
|
6
6
|
import { acceptedLinks, enumeratedLinks, heldLinks, scopeLinks, streamedLinks, } from './links.js';
|
|
7
7
|
import { houseAction } from './actions.js';
|
|
8
|
-
import { classifyDoor, discoveryFailure, doorRefusal } from './refusal.js';
|
|
8
|
+
import { classifyDoor, classifyRead, discoveryFailure, doorRefusal } from './refusal.js';
|
|
9
9
|
import { houseNotifications } from './stream.js';
|
|
10
|
-
import { DOOR_BATCH, DOOR_BATCH_UPLOAD, DOOR_BOOTSTRAP, DOOR_DISCOVER, DOOR_ENUMERATE, DOOR_REVISIONS,
|
|
10
|
+
import { DOOR_BATCH, DOOR_BATCH_UPLOAD, DOOR_BOOTSTRAP, DOOR_DISCOVER, DOOR_ENUMERATE, DOOR_REVISIONS, } from './transport.js';
|
|
11
11
|
import { batchPaths, deltaBody, deltaBytes, deltaDigest, historyOutcome, houseChanges, mutationOutcome, operationHead, rejectedMapping, revisionBody, uploadable, } from './write.js';
|
|
12
12
|
import { followsVersion, logPosition, presented, reachedVersion, roomVersion, } from './version.js';
|
|
13
13
|
const UNCERTAIN = { kind: 'transport-uncertainty' };
|
|
@@ -28,14 +28,26 @@ export function createAgentsHouseAdapter(options) {
|
|
|
28
28
|
throw new Error('no Discovery declared the bounds');
|
|
29
29
|
return bounds;
|
|
30
30
|
}
|
|
31
|
-
async function bootstrappedRoom(envelope, entry) {
|
|
32
|
-
const scope = envelope.scopes.find((candidate) => matchesScope(candidate, entry));
|
|
31
|
+
async function bootstrappedRoom(envelope, scope, entry, continued) {
|
|
33
32
|
if (scope === undefined)
|
|
34
33
|
return { kind: 'room-not-readable', locator: entry.locator };
|
|
35
|
-
|
|
34
|
+
const next = envelope.next?.room === entry.authority ? envelope.next.path : null;
|
|
35
|
+
if (continued === null && next === null)
|
|
36
|
+
handed.set(entry.locator, scopeLinks(scope));
|
|
37
|
+
else
|
|
38
|
+
handed.delete(entry.locator);
|
|
36
39
|
notifications.reach(entry.authority, scope);
|
|
37
|
-
const
|
|
38
|
-
|
|
40
|
+
const seen = [
|
|
41
|
+
...(continued?.seen ?? []),
|
|
42
|
+
...entry.schemas.filter((schema) => scope.files.some((file) => file.path === schema)),
|
|
43
|
+
];
|
|
44
|
+
const models = await partModels(scope, entry, new Set(seen), next === null);
|
|
45
|
+
const continuation = next === null ? null : { after: next, seen };
|
|
46
|
+
return {
|
|
47
|
+
...bootstrapOf(scope),
|
|
48
|
+
...(models === undefined ? {} : { models }),
|
|
49
|
+
...(continuation === null ? {} : { pageToken: JSON.stringify(continuation) }),
|
|
50
|
+
};
|
|
39
51
|
}
|
|
40
52
|
async function enumeratedRoom(enumeration, ask) {
|
|
41
53
|
const view = viewOf(enumeration, ask.entry);
|
|
@@ -104,48 +116,59 @@ export function createAgentsHouseAdapter(options) {
|
|
|
104
116
|
const { authority, position, log_epoch: logEpoch } = body;
|
|
105
117
|
if (typeof position !== 'string' || typeof logEpoch !== 'string')
|
|
106
118
|
return result;
|
|
107
|
-
const locator = authority ===
|
|
108
|
-
? PRIVATE_LOCATOR
|
|
109
|
-
: [...tracked.values()].find((entry) => entry.authority === authority)?.locator;
|
|
119
|
+
const locator = [...tracked.values()].find((entry) => entry.authority === authority)?.locator;
|
|
110
120
|
if (locator === undefined)
|
|
111
121
|
return result;
|
|
112
122
|
return { ...result, at: { locator, roomVersion: roomVersion({ position, logEpoch }) } };
|
|
113
123
|
}
|
|
114
|
-
async function bundled(body) {
|
|
115
|
-
const grant = parseGrant(body);
|
|
116
|
-
if (grant === null)
|
|
117
|
-
return body;
|
|
118
|
-
if (grant.method !== 'GET')
|
|
119
|
-
return null;
|
|
120
|
-
const answer = await transport.transfer({
|
|
121
|
-
act: 'local_copy_bundle',
|
|
122
|
-
method: 'GET',
|
|
123
|
-
url: grant.url,
|
|
124
|
-
answer: 'json',
|
|
125
|
-
});
|
|
126
|
-
return answer.status === 200 ? answer.body : null;
|
|
127
|
-
}
|
|
128
124
|
function weight(entry) {
|
|
129
125
|
return contentPrefixes(entry).length;
|
|
130
126
|
}
|
|
131
|
-
async function bootstrapped(entries) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
127
|
+
async function bootstrapped(entries, answer) {
|
|
128
|
+
let open = entries.map((entry, ask) => ({ entry, ask }));
|
|
129
|
+
while (open.length > 0) {
|
|
130
|
+
const unreached = [];
|
|
131
|
+
for (const part of selections(open, ({ entry }) => weight(entry), declared().max_prefixes)) {
|
|
132
|
+
const answered = await transport.door(DOOR_BOOTSTRAP, {
|
|
133
|
+
prefixes: part.flatMap(({ entry }) => contentPrefixes(entry)),
|
|
134
|
+
});
|
|
135
|
+
const classified = part.map(({ entry }) => classifyDoor(answered.status, answered.body, entry.locator));
|
|
136
|
+
const envelope = classified[0] === null ? parseEnvelope(answered.body) : null;
|
|
137
|
+
for (const [index, asked] of part.entries()) {
|
|
138
|
+
const failure = classified[index];
|
|
139
|
+
if (failure !== null && failure !== undefined) {
|
|
140
|
+
answer(asked.ask, failure);
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
if (envelope === null) {
|
|
144
|
+
answer(asked.ask, UNCERTAIN_READ);
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
const scope = envelope.scopes.find((candidate) => matchesScope(candidate, asked.entry));
|
|
148
|
+
if (scope === undefined && envelope.next !== undefined) {
|
|
149
|
+
unreached.push(asked);
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
answer(asked.ask, await bootstrappedRoom(envelope, scope, asked.entry, null));
|
|
144
153
|
}
|
|
145
|
-
answers.push(failure.kind === 'beyond-horizon' ? UNCERTAIN_READ : failure);
|
|
146
154
|
}
|
|
155
|
+
open = unreached;
|
|
147
156
|
}
|
|
148
|
-
|
|
157
|
+
}
|
|
158
|
+
async function continuedBootstrap(entry, continued) {
|
|
159
|
+
const after = { room: entry.authority, path: continued.after };
|
|
160
|
+
const answered = await transport.door(DOOR_BOOTSTRAP, {
|
|
161
|
+
prefixes: contentPrefixes(entry),
|
|
162
|
+
after,
|
|
163
|
+
});
|
|
164
|
+
const failure = classifyDoor(answered.status, answered.body, entry.locator);
|
|
165
|
+
if (failure !== null)
|
|
166
|
+
return failure;
|
|
167
|
+
const envelope = parseEnvelope(answered.body);
|
|
168
|
+
if (envelope === null)
|
|
169
|
+
return UNCERTAIN_READ;
|
|
170
|
+
const scope = envelope.scopes.find((candidate) => matchesScope(candidate, entry));
|
|
171
|
+
return bootstrappedRoom(envelope, scope, entry, continued);
|
|
149
172
|
}
|
|
150
173
|
function layered(asks) {
|
|
151
174
|
const depths = new Map();
|
|
@@ -167,7 +190,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
167
190
|
prefixes: open.flatMap((ask) => contentPrefixes(ask.entry)),
|
|
168
191
|
positions: open.map((ask) => presented(ask.entry.authority, ask.from)),
|
|
169
192
|
});
|
|
170
|
-
const classified = open.map((ask) =>
|
|
193
|
+
const classified = open.map((ask) => classifyRead(answer.status, answer.body, ask.entry.locator));
|
|
171
194
|
if (classified[0]?.kind === 'beyond-horizon') {
|
|
172
195
|
const named = doorRefusal(answer.body)?.fields.authority;
|
|
173
196
|
const expired = open.filter((ask) => ask.entry.authority === named);
|
|
@@ -192,7 +215,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
192
215
|
}
|
|
193
216
|
return asks.map((ask) => answers.get(ask) ?? UNCERTAIN_READ);
|
|
194
217
|
}
|
|
195
|
-
const bootstrapTogether =
|
|
218
|
+
const bootstrapTogether = gatheredEach(bootstrapped);
|
|
196
219
|
const enumerateTogether = gathered(enumerated);
|
|
197
220
|
async function uploaded(head, changes, delta, bytes, entry, handed, keep) {
|
|
198
221
|
const paths = batchPaths(changes);
|
|
@@ -209,9 +232,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
209
232
|
return { outcome: UNCERTAIN };
|
|
210
233
|
const delivered = await transport.transfer({
|
|
211
234
|
act: 'authored_batch_upload',
|
|
212
|
-
method: 'POST',
|
|
213
235
|
url: grant.url,
|
|
214
|
-
answer: 'json',
|
|
215
236
|
body: `${grant.operation}\n${delta}`,
|
|
216
237
|
});
|
|
217
238
|
if (delivered.status !== 200)
|
|
@@ -239,9 +260,9 @@ export function createAgentsHouseAdapter(options) {
|
|
|
239
260
|
},
|
|
240
261
|
async discover(_authorization) {
|
|
241
262
|
const answer = await transport.door(DOOR_DISCOVER, { prefixes: [...DISCOVER_PREFIXES] });
|
|
242
|
-
const
|
|
243
|
-
if (
|
|
244
|
-
return
|
|
263
|
+
const failed = discoveryFailure(answer.status, answer.body);
|
|
264
|
+
if (failed !== null)
|
|
265
|
+
return failed;
|
|
245
266
|
const document = parseDiscovery(answer.body);
|
|
246
267
|
if (document === null)
|
|
247
268
|
return { kind: 'transport-uncertainty' };
|
|
@@ -254,14 +275,18 @@ export function createAgentsHouseAdapter(options) {
|
|
|
254
275
|
if (!tracked.has(locator))
|
|
255
276
|
handed.delete(locator);
|
|
256
277
|
notifications.track(entries);
|
|
257
|
-
return
|
|
278
|
+
return {
|
|
279
|
+
...mapDiscovery(document, document.authorities.map((authority) => discoveredRoom(authority)), capabilities(document)),
|
|
280
|
+
member: document.member,
|
|
281
|
+
};
|
|
258
282
|
},
|
|
259
283
|
async bootstrap(_authorization, request) {
|
|
260
284
|
const entry = authorityFor(request.locator);
|
|
261
285
|
if (entry === undefined)
|
|
262
286
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
263
|
-
if (request.pageToken !== undefined)
|
|
264
|
-
return
|
|
287
|
+
if (request.pageToken !== undefined) {
|
|
288
|
+
return continuedBootstrap(entry, JSON.parse(request.pageToken));
|
|
289
|
+
}
|
|
265
290
|
return bootstrapTogether(entry);
|
|
266
291
|
},
|
|
267
292
|
async refresh(_authorization, request) {
|
|
@@ -318,7 +343,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
318
343
|
async action(_authorization, request) {
|
|
319
344
|
return withAt(await houseAction(transport, request));
|
|
320
345
|
},
|
|
321
|
-
roomStream: { hold: held, observe: notifications.observe },
|
|
346
|
+
roomStream: { hold: held, reopen: notifications.reopen, observe: notifications.observe },
|
|
322
347
|
conversations: notifications.conversations,
|
|
323
348
|
serviceMode: notifications.serviceMode,
|
|
324
349
|
};
|
package/dist/discovery.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { Capability, DiscoveredRoom, Discovery, ProviderLimit, Retention } from '@agentshouse/mdruntime';
|
|
1
|
+
import type { Capability, DiscoveredRoom, Discovery, Member, ProviderLimit, Retention } from '@agentshouse/mdruntime';
|
|
2
2
|
import { type LogPosition } from './version.js';
|
|
3
3
|
export declare const PROVIDER_ACTIONS = "provider-actions";
|
|
4
4
|
export declare const DISCOVER_PREFIXES: readonly string[];
|
|
5
|
-
export declare const PRIVATE_HANDLE = "private";
|
|
6
5
|
export type HouseBounds = {
|
|
7
6
|
max_authored_file_bytes: number;
|
|
8
7
|
max_batch_operations: number;
|
|
@@ -38,6 +37,7 @@ export type HouseAuthority = LogPosition & {
|
|
|
38
37
|
operations: HouseOperations;
|
|
39
38
|
};
|
|
40
39
|
export type HouseDiscoveryDocument = {
|
|
40
|
+
member: Member;
|
|
41
41
|
bounds: HouseBounds;
|
|
42
42
|
authorities: readonly HouseAuthority[];
|
|
43
43
|
actions: readonly string[];
|
|
@@ -62,11 +62,10 @@ export type HouseSiteDiscovery = {
|
|
|
62
62
|
export declare function parseDiscovery(body: unknown): HouseDiscoveryDocument | null;
|
|
63
63
|
export declare function parseSiteDiscovery(body: unknown): HouseSiteDiscovery | null;
|
|
64
64
|
export declare function siteTracked(document: HouseSiteDiscovery): TrackedAuthority[];
|
|
65
|
-
export declare function locatorOf(authority: HouseAuthority): string;
|
|
66
65
|
export declare function trackedFrom(document: HouseDiscoveryDocument): TrackedAuthority[];
|
|
67
66
|
export declare function providerLimits(bounds: HouseBounds): readonly ProviderLimit[];
|
|
68
67
|
export declare function declaredRetention(bounds: HouseBounds): Retention;
|
|
69
|
-
export declare function capabilities(
|
|
68
|
+
export declare function capabilities(document: HouseDiscoveryDocument): readonly Capability[];
|
|
70
69
|
export declare function siteCapabilities(): readonly Capability[];
|
|
71
70
|
export declare function discoveredRoom(authority: HouseAuthority): DiscoveredRoom;
|
|
72
71
|
export declare function mapDiscovery(document: Pick<HouseDiscoveryDocument, 'bounds'>, rooms: readonly DiscoveredRoom[], declared: readonly Capability[]): Discovery;
|
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,SAAS,EACV,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,SAAS,EACT,MAAM,EACN,aAAa,EACb,SAAS,EACV,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAA6B,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3E,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AAEnD,eAAO,MAAM,iBAAiB,EAAE,SAAS,MAAM,EAAU,CAAC;AAE1D,MAAM,MAAM,WAAW,GAAG;IACxB,uBAAuB,EAAE,MAAM,CAAC;IAChC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,qBAAqB,EAAE,MAAM,CAA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
|
+
import { declaredActions, houseConversationAgents } from './actions.js';
|
|
3
2
|
import { readPosition, roomVersion } from './version.js';
|
|
4
3
|
export const PROVIDER_ACTIONS = 'provider-actions';
|
|
5
4
|
export const DISCOVER_PREFIXES = ['/'];
|
|
6
|
-
export const PRIVATE_HANDLE = 'private';
|
|
7
5
|
const BOUND_KEYS = [
|
|
8
6
|
'max_authored_file_bytes',
|
|
9
7
|
'max_batch_operations',
|
|
@@ -48,6 +46,14 @@ function parseHouseModel(value) {
|
|
|
48
46
|
return undefined;
|
|
49
47
|
return { root: held.root, paths };
|
|
50
48
|
}
|
|
49
|
+
function parseMember(value) {
|
|
50
|
+
if (typeof value !== 'object' || value === null)
|
|
51
|
+
return null;
|
|
52
|
+
const { user, name } = value;
|
|
53
|
+
if (typeof user !== 'string' || typeof name !== 'string')
|
|
54
|
+
return null;
|
|
55
|
+
return { kind: 'user', id: user, name };
|
|
56
|
+
}
|
|
51
57
|
function parseOperations(value) {
|
|
52
58
|
if (typeof value !== 'object' || value === null)
|
|
53
59
|
return null;
|
|
@@ -100,6 +106,9 @@ export function parseDiscovery(body) {
|
|
|
100
106
|
if (typeof body !== 'object' || body === null)
|
|
101
107
|
return null;
|
|
102
108
|
const held = body;
|
|
109
|
+
const member = parseMember(held.member);
|
|
110
|
+
if (member === null)
|
|
111
|
+
return null;
|
|
103
112
|
const bounds = parseBounds(held.bounds);
|
|
104
113
|
if (bounds === null)
|
|
105
114
|
return null;
|
|
@@ -117,7 +126,7 @@ export function parseDiscovery(body) {
|
|
|
117
126
|
return null;
|
|
118
127
|
authorities.push(authority);
|
|
119
128
|
}
|
|
120
|
-
return { bounds, authorities, actions };
|
|
129
|
+
return { member, bounds, authorities, actions };
|
|
121
130
|
}
|
|
122
131
|
function parseSiteAuthority(value) {
|
|
123
132
|
if (typeof value !== 'object' || value === null)
|
|
@@ -171,9 +180,6 @@ export function siteTracked(document) {
|
|
|
171
180
|
logEpoch: authority.logEpoch,
|
|
172
181
|
}));
|
|
173
182
|
}
|
|
174
|
-
export function locatorOf(authority) {
|
|
175
|
-
return authority.roomHandle === PRIVATE_HANDLE ? PRIVATE_LOCATOR : authority.roomRef;
|
|
176
|
-
}
|
|
177
183
|
function schemasOf(authority) {
|
|
178
184
|
return authority.houseModel === null
|
|
179
185
|
? [authority.schema]
|
|
@@ -181,7 +187,7 @@ function schemasOf(authority) {
|
|
|
181
187
|
}
|
|
182
188
|
export function trackedFrom(document) {
|
|
183
189
|
return document.authorities.map((authority) => ({
|
|
184
|
-
locator:
|
|
190
|
+
locator: authority.roomRef,
|
|
185
191
|
authority: authority.roomRef,
|
|
186
192
|
handle: authority.roomHandle,
|
|
187
193
|
schema: authority.schema,
|
|
@@ -209,12 +215,15 @@ export function declaredRetention(bounds) {
|
|
|
209
215
|
refreshHorizon: bounds.change_retention_seconds,
|
|
210
216
|
};
|
|
211
217
|
}
|
|
212
|
-
export function capabilities(
|
|
218
|
+
export function capabilities(document) {
|
|
219
|
+
const house = document.authorities.find((authority) => authority.houseModel !== null);
|
|
213
220
|
return [
|
|
214
221
|
{
|
|
215
222
|
name: PROVIDER_ACTIONS,
|
|
216
|
-
actions: declaredActions(actions),
|
|
217
|
-
|
|
223
|
+
actions: declaredActions(document.actions),
|
|
224
|
+
...(house === undefined
|
|
225
|
+
? {}
|
|
226
|
+
: { conversationAgents: houseConversationAgents(house.roomRef) }),
|
|
218
227
|
},
|
|
219
228
|
];
|
|
220
229
|
}
|
|
@@ -224,10 +233,11 @@ export function siteCapabilities() {
|
|
|
224
233
|
];
|
|
225
234
|
}
|
|
226
235
|
export function discoveredRoom(authority) {
|
|
227
|
-
const locator =
|
|
236
|
+
const locator = authority.roomRef;
|
|
228
237
|
return {
|
|
229
238
|
name: authority.name,
|
|
230
239
|
locator,
|
|
240
|
+
handle: authority.roomHandle,
|
|
231
241
|
roomVersion: roomVersion(authority),
|
|
232
242
|
operations: {
|
|
233
243
|
read: [...authority.operations.read],
|
package/dist/gather.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare function gatheredEach<A, R>(send: (asks: readonly A[], answer: (ask: number, result: R) => void) => Promise<void>): (ask: A) => Promise<R>;
|
|
1
2
|
export declare function gathered<A, R>(send: (asks: readonly A[]) => Promise<readonly R[]>): (ask: A) => Promise<R>;
|
|
2
3
|
export declare function selections<T>(items: readonly T[], weight: (item: T) => number, limit: number): readonly (readonly T[])[];
|
|
3
4
|
//# sourceMappingURL=gather.d.ts.map
|
package/dist/gather.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gather.d.ts","sourceRoot":"","sources":["../src/gather.ts"],"names":[],"mappings":"AAMA,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAC3B,IAAI,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,KAAK,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,GAClD,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"gather.d.ts","sourceRoot":"","sources":["../src/gather.ts"],"names":[],"mappings":"AAMA,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,EAC/B,IAAI,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,KAAK,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,GACpF,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAwBxB;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAC3B,IAAI,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,KAAK,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,GAClD,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAMxB;AAED,wBAAgB,UAAU,CAAC,CAAC,EAC1B,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,EAC3B,KAAK,EAAE,MAAM,GACZ,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAgB3B"}
|
package/dist/gather.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
export function
|
|
1
|
+
export function gatheredEach(send) {
|
|
2
2
|
let held = [];
|
|
3
3
|
function flush() {
|
|
4
4
|
const taken = held;
|
|
5
5
|
held = [];
|
|
6
|
-
send(taken.map((entry) => entry.ask)
|
|
7
|
-
taken
|
|
8
|
-
|
|
9
|
-
});
|
|
10
|
-
}, (reason) => {
|
|
6
|
+
send(taken.map((entry) => entry.ask), (ask, result) => {
|
|
7
|
+
taken[ask]?.resolve(result);
|
|
8
|
+
}).catch((reason) => {
|
|
11
9
|
for (const entry of taken)
|
|
12
10
|
entry.reject(reason);
|
|
13
11
|
});
|
|
@@ -20,6 +18,13 @@ export function gathered(send) {
|
|
|
20
18
|
held.push({ ask, resolve, reject });
|
|
21
19
|
});
|
|
22
20
|
}
|
|
21
|
+
export function gathered(send) {
|
|
22
|
+
return gatheredEach(async (asks, answer) => {
|
|
23
|
+
(await send(asks)).forEach((result, ask) => {
|
|
24
|
+
answer(ask, result);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
23
28
|
export function selections(items, weight, limit) {
|
|
24
29
|
const parts = [];
|
|
25
30
|
let part = [];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { createAgentsHouseAdapter, type AgentsHouseAdapterOptions } from './adapter.js';
|
|
2
|
-
export {
|
|
3
|
-
export type { HouseByteAct,
|
|
2
|
+
export { HOUSE_APP_ACTS } from './actions.js';
|
|
3
|
+
export type { HouseByteAct, HouseByteTransfer, HouseDoorAnswer, HouseHeldRoom, HouseOpening, HouseStream, HouseStreamEntry, HouseStreamFrame, HouseSiteTransport, HouseTransport, } from './transport.js';
|
|
4
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,OAAO,EAAE,
|
|
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,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,YAAY,EACV,YAAY,EACZ,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
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { createAgentsHouseAdapter } from './adapter.js';
|
|
2
|
-
export {
|
|
2
|
+
export { HOUSE_APP_ACTS } from './actions.js';
|
package/dist/model.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { RoomModels } from '@agentshouse/mdruntime';
|
|
|
2
2
|
import type { TrackedAuthority } from './discovery.js';
|
|
3
3
|
import { type HouseScope, type HouseView } from './read.js';
|
|
4
4
|
import type { HouseMode, HouseStreamEntry } from './transport.js';
|
|
5
|
+
export declare function partModels(scope: HouseScope, tracked: TrackedAuthority, seen: ReadonlySet<string>, final: boolean): Promise<RoomModels | undefined>;
|
|
5
6
|
export declare function scopeModels(scope: HouseScope, tracked: TrackedAuthority): Promise<RoomModels | undefined>;
|
|
6
7
|
export declare function viewModels(view: HouseView, tracked: TrackedAuthority): Promise<RoomModels | undefined>;
|
|
7
8
|
export declare function streamedModels(schemas: ReadonlyMap<string, HouseStreamEntry>, tracked: TrackedAuthority, mode: HouseMode): Promise<RoomModels | undefined>;
|
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,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;
|
|
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;AAoClE,wBAAgB,UAAU,CACxB,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,EACzB,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAKjC;AAED,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,CAcjC;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,CAWjC"}
|
package/dist/model.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { sha256Hex } from './digest.js';
|
|
2
2
|
import { schemaOf, schemaPath } from './read.js';
|
|
3
3
|
const MODEL_ABSENT = { kind: 'model-unavailable', reason: 'not-readable' };
|
|
4
|
-
const ABSENT_SCHEMA = { schema: null, version: null };
|
|
4
|
+
const ABSENT_SCHEMA = { schema: null, version: null, revision: null };
|
|
5
5
|
async function heldModel(read, identity) {
|
|
6
6
|
if (read === null)
|
|
7
7
|
return MODEL_ABSENT;
|
|
8
8
|
const version = await sha256Hex(JSON.stringify(read.version));
|
|
9
|
-
return {
|
|
9
|
+
return {
|
|
10
|
+
kind: 'model',
|
|
11
|
+
snapshot: { identity, version, schema: read.schema, revision: read.revision },
|
|
12
|
+
};
|
|
10
13
|
}
|
|
11
14
|
async function modelsOf(tracked, read) {
|
|
12
15
|
const models = {};
|
|
@@ -23,8 +26,15 @@ async function modelsOf(tracked, read) {
|
|
|
23
26
|
}
|
|
24
27
|
return models.collection === undefined && models.selection === undefined ? undefined : models;
|
|
25
28
|
}
|
|
29
|
+
export function partModels(scope, tracked, seen, final) {
|
|
30
|
+
return modelsOf(tracked, (schema) => {
|
|
31
|
+
if (scope.files.some((file) => file.path === schema))
|
|
32
|
+
return schemaOf(scope, schema);
|
|
33
|
+
return final && !seen.has(schema) ? ABSENT_SCHEMA : undefined;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
26
36
|
export function scopeModels(scope, tracked) {
|
|
27
|
-
return
|
|
37
|
+
return partModels(scope, tracked, new Set(), true);
|
|
28
38
|
}
|
|
29
39
|
export function viewModels(view, tracked) {
|
|
30
40
|
return modelsOf(tracked, (schema) => {
|
|
@@ -33,8 +43,13 @@ export function viewModels(view, tracked) {
|
|
|
33
43
|
return undefined;
|
|
34
44
|
if ('removed' in change)
|
|
35
45
|
return ABSENT_SCHEMA;
|
|
36
|
-
if ('content' in change)
|
|
37
|
-
return {
|
|
46
|
+
if ('content' in change) {
|
|
47
|
+
return {
|
|
48
|
+
schema: change.content,
|
|
49
|
+
version: change.version,
|
|
50
|
+
revision: change.revision ?? null,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
38
53
|
return null;
|
|
39
54
|
});
|
|
40
55
|
}
|
|
@@ -48,6 +63,8 @@ export function streamedModels(schemas, tracked, mode) {
|
|
|
48
63
|
if (entry.text === undefined)
|
|
49
64
|
return null;
|
|
50
65
|
const version = mode === 'site' ? entry.sha256 : entry.revision;
|
|
51
|
-
return version === undefined
|
|
66
|
+
return version === undefined
|
|
67
|
+
? null
|
|
68
|
+
: { schema: entry.text, version, revision: mode === 'site' ? null : version };
|
|
52
69
|
});
|
|
53
70
|
}
|
package/dist/read.d.ts
CHANGED
|
@@ -19,8 +19,13 @@ export type HouseScope = LogPosition & {
|
|
|
19
19
|
contents: readonly HouseContent[];
|
|
20
20
|
attachments?: readonly RoomAttachment[];
|
|
21
21
|
};
|
|
22
|
+
export type HouseCursor = {
|
|
23
|
+
room: string;
|
|
24
|
+
path: string | null;
|
|
25
|
+
};
|
|
22
26
|
export type HouseEnvelope = {
|
|
23
27
|
scopes: readonly HouseScope[];
|
|
28
|
+
next?: HouseCursor;
|
|
24
29
|
};
|
|
25
30
|
export type HouseGrant = {
|
|
26
31
|
method: 'GET';
|
|
@@ -61,7 +66,6 @@ export declare function headChange(held: {
|
|
|
61
66
|
readonly author?: unknown;
|
|
62
67
|
readonly created_at?: unknown;
|
|
63
68
|
}): HeadChange | undefined | null;
|
|
64
|
-
export declare function parseOriginals(value: unknown): readonly RoomAttachment[] | null;
|
|
65
69
|
export declare function parseEnvelope(body: unknown): HouseEnvelope | null;
|
|
66
70
|
export declare function parseSiteBootstrap(body: unknown): HouseScope | null;
|
|
67
71
|
export declare function parseEnumeration(body: unknown, mode: HouseMode): HouseEnumeration | null;
|
|
@@ -71,6 +75,7 @@ export declare function bootstrapOf(scope: HouseScope): BootstrapPage;
|
|
|
71
75
|
export type HouseSchema = {
|
|
72
76
|
schema: string | null;
|
|
73
77
|
version: string | null;
|
|
78
|
+
revision: string | null;
|
|
74
79
|
};
|
|
75
80
|
export declare function schemaOf(scope: HouseScope, schema: string): HouseSchema | null;
|
|
76
81
|
export declare function viewOf(enumeration: HouseEnumeration, tracked: TrackedAuthority): HouseView | undefined;
|
package/dist/read.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../src/read.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAEb,aAAa,EACb,cAAc,EACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAA6B,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3E,MAAM,MAAM,UAAU,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1D,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACpC,QAAQ,EAAE,SAAS,YAAY,EAAE,CAAC;IAClC,WAAW,CAAC,EAAE,SAAS,cAAc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AM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;CAC/B,GAAG,UAAU,GAAG,SAAS,GAAG,IAAI,CAMhC;AA4DD,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,aAAa,GAAG,IAAI,CAYjE;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,UAAU,GAAG,IAAI,CAEnE;AAoCD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,GAAG,gBAAgB,GAAG,IAAI,CAuBxF;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,GAAG,UAAU,CA2B5E;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAElF;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,aAAa,CAsB5D;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,CAAC;AAEF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAO9E;AAED,wBAAgB,MAAM,CACpB,WAAW,EAAE,gBAAgB,EAC7B,OAAO,EAAE,gBAAgB,GACxB,SAAS,GAAG,SAAS,CAEvB;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,GAAG,aAAa,CA+BnF"}
|
package/dist/read.js
CHANGED
|
@@ -51,30 +51,6 @@ export function headChange(held) {
|
|
|
51
51
|
function headed(head) {
|
|
52
52
|
return head === undefined ? {} : { head };
|
|
53
53
|
}
|
|
54
|
-
function parseOriginal(value) {
|
|
55
|
-
if (typeof value !== 'object' || value === null)
|
|
56
|
-
return null;
|
|
57
|
-
const { attachment, name, bytes, media_type: mediaType } = value;
|
|
58
|
-
if (typeof attachment !== 'string' || typeof name !== 'string')
|
|
59
|
-
return null;
|
|
60
|
-
if (typeof bytes !== 'number' || !Number.isSafeInteger(bytes) || bytes < 0)
|
|
61
|
-
return null;
|
|
62
|
-
if (mediaType !== null && typeof mediaType !== 'string')
|
|
63
|
-
return null;
|
|
64
|
-
return { reference: attachment, name, byteLength: bytes, mediaType, entry: value };
|
|
65
|
-
}
|
|
66
|
-
export function parseOriginals(value) {
|
|
67
|
-
if (!Array.isArray(value))
|
|
68
|
-
return null;
|
|
69
|
-
const attachments = [];
|
|
70
|
-
for (const entry of value) {
|
|
71
|
-
const attachment = parseOriginal(entry);
|
|
72
|
-
if (attachment === null)
|
|
73
|
-
return null;
|
|
74
|
-
attachments.push(attachment);
|
|
75
|
-
}
|
|
76
|
-
return attachments;
|
|
77
|
-
}
|
|
78
54
|
function declared(attachments) {
|
|
79
55
|
return attachments === undefined ? {} : { attachments };
|
|
80
56
|
}
|
|
@@ -132,10 +108,15 @@ function parseScope(value, mode) {
|
|
|
132
108
|
}
|
|
133
109
|
if (mode === 'site')
|
|
134
110
|
return { anchor: manifest.anchor, ...at, files, contents };
|
|
135
|
-
|
|
136
|
-
|
|
111
|
+
return { anchor: manifest.anchor, ...at, files, contents, attachments: [] };
|
|
112
|
+
}
|
|
113
|
+
function parseCursor(value) {
|
|
114
|
+
if (typeof value !== 'object' || value === null)
|
|
115
|
+
return null;
|
|
116
|
+
const { room, path } = value;
|
|
117
|
+
if (typeof room !== 'string' || (path !== null && typeof path !== 'string'))
|
|
137
118
|
return null;
|
|
138
|
-
return {
|
|
119
|
+
return { room, path };
|
|
139
120
|
}
|
|
140
121
|
export function parseEnvelope(body) {
|
|
141
122
|
if (typeof body !== 'object' || body === null)
|
|
@@ -149,7 +130,10 @@ export function parseEnvelope(body) {
|
|
|
149
130
|
return null;
|
|
150
131
|
scopes.push(scope);
|
|
151
132
|
}
|
|
152
|
-
|
|
133
|
+
if (!('next' in body) || body.next === undefined)
|
|
134
|
+
return { scopes };
|
|
135
|
+
const next = parseCursor(body.next);
|
|
136
|
+
return next === null ? null : { scopes, next };
|
|
153
137
|
}
|
|
154
138
|
export function parseSiteBootstrap(body) {
|
|
155
139
|
return parseScope(body, 'site');
|
|
@@ -219,10 +203,7 @@ export function parseEnumeration(body, mode) {
|
|
|
219
203
|
authorities.push({ authority: held.authority, ...at, changes });
|
|
220
204
|
continue;
|
|
221
205
|
}
|
|
222
|
-
|
|
223
|
-
if (attachments === null)
|
|
224
|
-
return null;
|
|
225
|
-
authorities.push({ authority: held.authority, ...at, changes, attachments });
|
|
206
|
+
authorities.push({ authority: held.authority, ...at, changes, attachments: [] });
|
|
226
207
|
}
|
|
227
208
|
return { authorities };
|
|
228
209
|
}
|
|
@@ -288,9 +269,11 @@ export function bootstrapOf(scope) {
|
|
|
288
269
|
export function schemaOf(scope, schema) {
|
|
289
270
|
const file = scope.files.find((entry) => entry.path === schema);
|
|
290
271
|
if (file === undefined)
|
|
291
|
-
return { schema: null, version: null };
|
|
272
|
+
return { schema: null, version: null, revision: null };
|
|
292
273
|
const content = scope.contents.find((entry) => entry.path === schema);
|
|
293
|
-
return content === undefined
|
|
274
|
+
return content === undefined
|
|
275
|
+
? null
|
|
276
|
+
: { schema: content.content, version: file.version, revision: file.revision ?? null };
|
|
294
277
|
}
|
|
295
278
|
export function viewOf(enumeration, tracked) {
|
|
296
279
|
return enumeration.authorities.find((entry) => entry.authority === tracked.authority);
|