@agentshouse/mdruntime-adapter 0.1.0-alpha.4 → 0.1.0-alpha.40
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 +136 -23
- package/README.md +32 -0
- package/dist/actions.d.ts +3 -11
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +176 -236
- package/dist/actions.js.map +1 -1
- package/dist/adapter.d.ts +3 -1
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +78 -137
- package/dist/adapter.js.map +1 -1
- package/dist/discovery.d.ts +39 -11
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +153 -39
- package/dist/discovery.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/model.d.ts +19 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +64 -0
- package/dist/model.js.map +1 -0
- package/dist/read.d.ts +24 -19
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +126 -55
- package/dist/read.js.map +1 -1
- package/dist/refusal.d.ts +4 -1
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +13 -1
- package/dist/refusal.js.map +1 -1
- package/dist/site.d.ts +4 -0
- package/dist/site.d.ts.map +1 -0
- package/dist/site.js +206 -0
- package/dist/site.js.map +1 -0
- package/dist/stream.d.ts +8 -5
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +232 -135
- package/dist/stream.js.map +1 -1
- package/dist/transport.d.ts +39 -29
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +5 -1
- package/dist/transport.js.map +1 -1
- package/dist/version.d.ts +14 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +29 -0
- package/dist/version.js.map +1 -0
- package/dist/write.d.ts +6 -0
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +51 -9
- package/dist/write.js.map +1 -1
- package/package.json +4 -12
package/dist/adapter.js
CHANGED
|
@@ -1,24 +1,16 @@
|
|
|
1
|
-
import { DISCOVER_PREFIXES,
|
|
2
|
-
import {
|
|
1
|
+
import { DISCOVER_PREFIXES, HOUSE_SCHEMA, capabilities, discoveredRoom, locatorOf, mapDiscovery, parseDiscovery, providerSelection, trackedFrom } from './discovery.js';
|
|
2
|
+
import { MODEL_ABSENT, failedModel, heldModel, modelKey, modelShelf } from './model.js';
|
|
3
|
+
import { createSiteAdapter } from './site.js';
|
|
4
|
+
import { bootstrapFrom, contentPrefixes, parseEnumeration, parseEnvelope, parseGrant, refreshFrom, schemaFrom, schemaPath } from './read.js';
|
|
3
5
|
import { houseAction } from './actions.js';
|
|
4
|
-
import { classifyDoor } from './refusal.js';
|
|
6
|
+
import { classifyDoor, discoveryFailure } from './refusal.js';
|
|
5
7
|
import { houseNotifications } from './stream.js';
|
|
6
|
-
import { DOOR_BATCH, DOOR_BATCH_UPLOAD, DOOR_BOOTSTRAP, DOOR_DISCOVER, DOOR_ENUMERATE, DOOR_REVISIONS,
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
const MODEL_ABSENT = {
|
|
10
|
-
kind: 'model-unavailable',
|
|
11
|
-
reason: 'not-readable'
|
|
12
|
-
};
|
|
8
|
+
import { DOOR_BATCH, DOOR_BATCH_UPLOAD, DOOR_BOOTSTRAP, DOOR_DISCOVER, DOOR_ENUMERATE, DOOR_REVISIONS, PRIVATE_LOCATOR } from './transport.js';
|
|
9
|
+
import { batchPaths, deltaBody, deltaBytes, deltaDigest, historyOutcome, houseChanges, mutationOutcome, operationHead, rejectedMapping, revisionBody, uploadable } from './write.js';
|
|
10
|
+
import { logPosition, presented } from './version.js';
|
|
13
11
|
const UNCERTAIN = {
|
|
14
12
|
kind: 'transport-uncertainty'
|
|
15
13
|
};
|
|
16
|
-
const RESOLVED_OUTCOMES = new Set([
|
|
17
|
-
'accepted',
|
|
18
|
-
'conflicted',
|
|
19
|
-
'rejected',
|
|
20
|
-
'expired'
|
|
21
|
-
]);
|
|
22
14
|
function lapsedGrant(outcome) {
|
|
23
15
|
return outcome.kind === 'rejected' && outcome.code === 'upload_unavailable';
|
|
24
16
|
}
|
|
@@ -28,86 +20,44 @@ function modelFailure(classified, envelope) {
|
|
|
28
20
|
kind: 'transport-uncertainty'
|
|
29
21
|
} : MODEL_ABSENT;
|
|
30
22
|
}
|
|
31
|
-
|
|
32
|
-
kind: 'revoked-authorization'
|
|
33
|
-
};
|
|
34
|
-
if (classified.kind === 'transport-uncertainty') return {
|
|
35
|
-
kind: 'transport-uncertainty'
|
|
36
|
-
};
|
|
37
|
-
return MODEL_ABSENT;
|
|
38
|
-
}
|
|
39
|
-
function modelVersion(revisions) {
|
|
40
|
-
return sha256Hex(JSON.stringify(revisions));
|
|
23
|
+
return failedModel(classified);
|
|
41
24
|
}
|
|
42
25
|
export function createAgentsHouseAdapter(options) {
|
|
26
|
+
if ('site' in options) return createSiteAdapter(options.site);
|
|
43
27
|
const transport = options.transport;
|
|
44
|
-
const notifications = houseNotifications(transport);
|
|
28
|
+
const notifications = houseNotifications(transport, 'credential');
|
|
45
29
|
const tracked = new Map();
|
|
46
|
-
const models =
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return `${locator} ${attached}`;
|
|
50
|
-
}
|
|
51
|
-
async function held(envelope, entry, modelRoot, identity, failure) {
|
|
52
|
-
const read = envelope === null ? null : definitionsFrom(envelope, entry, modelRoot);
|
|
53
|
-
if (read === null) return {
|
|
54
|
-
snapshot: failure,
|
|
55
|
-
identity: null
|
|
56
|
-
};
|
|
57
|
-
const version = await modelVersion(read.revisions);
|
|
58
|
-
return {
|
|
59
|
-
snapshot: {
|
|
60
|
-
kind: 'model',
|
|
61
|
-
snapshot: {
|
|
62
|
-
identity,
|
|
63
|
-
version,
|
|
64
|
-
definitions: read.definitions
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
identity: {
|
|
68
|
-
identity,
|
|
69
|
-
version
|
|
70
|
-
}
|
|
71
|
-
};
|
|
30
|
+
const models = modelShelf();
|
|
31
|
+
function held(envelope, entry, schema, failure) {
|
|
32
|
+
return heldModel(envelope === null ? null : schemaFrom(envelope, entry, schema), schemaPath(entry.handle, schema), failure);
|
|
72
33
|
}
|
|
73
34
|
async function acquireModels(entries) {
|
|
74
35
|
const acquired = new Map();
|
|
75
|
-
const privateEntry = entries.find((entry)=>entry.
|
|
76
|
-
const prefixes = entries.map((entry)=>
|
|
77
|
-
if (privateEntry !== undefined)
|
|
78
|
-
prefixes.push(`${authorityRoot(undefined)}/${PROVIDER_SELECTION_MODEL_ROOT}`);
|
|
79
|
-
}
|
|
36
|
+
const privateEntry = entries.find((entry)=>entry.locator === PRIVATE_LOCATOR);
|
|
37
|
+
const prefixes = entries.map((entry)=>schemaPath(entry.handle, entry.schema));
|
|
38
|
+
if (privateEntry !== undefined) prefixes.push(schemaPath(undefined, HOUSE_SCHEMA));
|
|
80
39
|
const answer = await transport.door(DOOR_BOOTSTRAP, {
|
|
81
40
|
prefixes
|
|
82
41
|
});
|
|
83
|
-
const classified = classifyDoor(answer.status, answer.body,
|
|
42
|
+
const classified = classifyDoor(answer.status, answer.body, PRIVATE_LOCATOR);
|
|
84
43
|
const envelope = classified === null ? parseEnvelope(await bundled(answer.body)) : null;
|
|
85
44
|
const failure = modelFailure(classified, envelope);
|
|
86
45
|
for (const entry of entries){
|
|
87
|
-
acquired.set(modelKey(entry.locator, 'collection'), await held(envelope, entry, entry.
|
|
46
|
+
acquired.set(modelKey(entry.locator, 'collection'), await held(envelope, entry, entry.schema, failure));
|
|
88
47
|
}
|
|
89
48
|
if (privateEntry !== undefined) {
|
|
90
|
-
acquired.set(modelKey(privateEntry.locator, 'typed-selection'), await held(envelope, privateEntry,
|
|
49
|
+
acquired.set(modelKey(privateEntry.locator, 'typed-selection'), await held(envelope, privateEntry, HOUSE_SCHEMA, failure));
|
|
91
50
|
}
|
|
92
51
|
return acquired;
|
|
93
52
|
}
|
|
94
|
-
function retainModel(key, acquired) {
|
|
95
|
-
if (acquired === undefined) return models.get(key);
|
|
96
|
-
if (acquired.snapshot.kind === 'transport-uncertainty') {
|
|
97
|
-
const previous = models.get(key);
|
|
98
|
-
if (previous !== undefined && previous.identity !== null) return previous;
|
|
99
|
-
}
|
|
100
|
-
models.set(key, acquired);
|
|
101
|
-
return acquired;
|
|
102
|
-
}
|
|
103
53
|
function roomOf(authority, acquired) {
|
|
104
54
|
const locator = locatorOf(authority);
|
|
105
55
|
const key = modelKey(locator, 'collection');
|
|
106
|
-
const collection =
|
|
107
|
-
if (authority.
|
|
56
|
+
const collection = models.retain(key, acquired.get(key));
|
|
57
|
+
if (authority.roomHandle !== null) {
|
|
108
58
|
return discoveredRoom(authority, collection?.identity ?? null, undefined);
|
|
109
59
|
}
|
|
110
|
-
const selection =
|
|
60
|
+
const selection = models.retain(modelKey(locator, 'typed-selection'), acquired.get(modelKey(locator, 'typed-selection')));
|
|
111
61
|
return discoveredRoom(authority, collection?.identity ?? null, providerSelection(selection?.identity ?? null));
|
|
112
62
|
}
|
|
113
63
|
function authorityFor(locator) {
|
|
@@ -120,19 +70,25 @@ export function createAgentsHouseAdapter(options) {
|
|
|
120
70
|
const answer = await transport.transfer({
|
|
121
71
|
act: 'working_copy_bundle',
|
|
122
72
|
method: 'GET',
|
|
123
|
-
url: grant.url
|
|
73
|
+
url: grant.url,
|
|
74
|
+
answer: 'json'
|
|
124
75
|
});
|
|
125
76
|
return answer.status === 200 ? answer.body : null;
|
|
126
77
|
}
|
|
127
|
-
async function uploaded(
|
|
78
|
+
async function uploaded(head, changes, delta, bytes, entry, handed, keep) {
|
|
128
79
|
const paths = batchPaths(changes);
|
|
129
80
|
const sha256 = await deltaDigest(delta);
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
81
|
+
if (handed !== undefined && handed.sha256 === sha256) {
|
|
82
|
+
return {
|
|
83
|
+
body: {
|
|
84
|
+
...head,
|
|
85
|
+
paths,
|
|
86
|
+
upload: handed
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
134
90
|
const minted = await transport.door(DOOR_BATCH_UPLOAD, {
|
|
135
|
-
|
|
91
|
+
...head,
|
|
136
92
|
paths,
|
|
137
93
|
bytes,
|
|
138
94
|
sha256
|
|
@@ -150,37 +106,35 @@ export function createAgentsHouseAdapter(options) {
|
|
|
150
106
|
act: 'authored_batch_upload',
|
|
151
107
|
method: 'POST',
|
|
152
108
|
url: grant.url,
|
|
109
|
+
answer: 'json',
|
|
153
110
|
body: `${grant.operation}\n${delta}`
|
|
154
111
|
});
|
|
155
112
|
if (delivered.status !== 200) return {
|
|
156
113
|
outcome: UNCERTAIN
|
|
157
114
|
};
|
|
158
115
|
const holding = parseGrant(delivered.body);
|
|
159
|
-
if (holding === null) return {
|
|
116
|
+
if (holding === null || holding.method !== 'POST') return {
|
|
160
117
|
outcome: UNCERTAIN
|
|
161
118
|
};
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
operation: holding.operation,
|
|
168
|
-
bytes,
|
|
169
|
-
sha256
|
|
170
|
-
}
|
|
119
|
+
const upload = {
|
|
120
|
+
url: holding.url,
|
|
121
|
+
operation: holding.operation,
|
|
122
|
+
bytes,
|
|
123
|
+
sha256
|
|
171
124
|
};
|
|
172
|
-
|
|
173
|
-
sha256,
|
|
174
|
-
body
|
|
175
|
-
});
|
|
125
|
+
await keep(upload);
|
|
176
126
|
return {
|
|
177
|
-
body
|
|
127
|
+
body: {
|
|
128
|
+
...head,
|
|
129
|
+
paths,
|
|
130
|
+
upload
|
|
131
|
+
}
|
|
178
132
|
};
|
|
179
133
|
}
|
|
180
|
-
async function submit(
|
|
181
|
-
const prepared = uploadable(bytes) ? await uploaded(
|
|
134
|
+
async function submit(head, changes, delta, bytes, entry, handed, keep) {
|
|
135
|
+
const prepared = uploadable(bytes) ? await uploaded(head, changes, delta, bytes, entry, handed, keep) : {
|
|
182
136
|
body: {
|
|
183
|
-
|
|
137
|
+
...head,
|
|
184
138
|
changes
|
|
185
139
|
}
|
|
186
140
|
};
|
|
@@ -193,7 +147,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
193
147
|
return options.authorize();
|
|
194
148
|
},
|
|
195
149
|
async model (_authorization, request) {
|
|
196
|
-
return models.
|
|
150
|
+
return models.answer(request);
|
|
197
151
|
},
|
|
198
152
|
async discover (_authorization) {
|
|
199
153
|
const answer = await transport.door(DOOR_DISCOVER, {
|
|
@@ -201,20 +155,8 @@ export function createAgentsHouseAdapter(options) {
|
|
|
201
155
|
...DISCOVER_PREFIXES
|
|
202
156
|
]
|
|
203
157
|
});
|
|
204
|
-
const classified = classifyDoor(answer.status, answer.body,
|
|
205
|
-
if (classified !== null)
|
|
206
|
-
if (classified.kind === 'revoked-authorization') return classified;
|
|
207
|
-
if (classified.kind === 'scoped-refusal') {
|
|
208
|
-
return {
|
|
209
|
-
kind: 'contract-unavailable',
|
|
210
|
-
code: classified.code,
|
|
211
|
-
fields: classified.fields
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
return {
|
|
215
|
-
kind: 'transport-uncertainty'
|
|
216
|
-
};
|
|
217
|
-
}
|
|
158
|
+
const classified = classifyDoor(answer.status, answer.body, PRIVATE_LOCATOR);
|
|
159
|
+
if (classified !== null) return discoveryFailure(classified);
|
|
218
160
|
const document = parseDiscovery(answer.body);
|
|
219
161
|
if (document === null) return {
|
|
220
162
|
kind: 'transport-uncertainty'
|
|
@@ -224,12 +166,8 @@ export function createAgentsHouseAdapter(options) {
|
|
|
224
166
|
for (const entry of entries)tracked.set(entry.locator, entry);
|
|
225
167
|
notifications.track(entries);
|
|
226
168
|
const acquired = await acquireModels(entries);
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
]){
|
|
230
|
-
if (!entries.some((entry)=>key.startsWith(`${entry.locator} `))) models.delete(key);
|
|
231
|
-
}
|
|
232
|
-
return mapDiscovery(document, document.authorities.map((authority)=>roomOf(authority, acquired)));
|
|
169
|
+
models.keep(entries.map((entry)=>entry.locator));
|
|
170
|
+
return mapDiscovery(document, document.authorities.map((authority)=>roomOf(authority, acquired)), capabilities(document.actions));
|
|
233
171
|
},
|
|
234
172
|
async bootstrap (_authorization, request) {
|
|
235
173
|
const entry = authorityFor(request.locator);
|
|
@@ -266,28 +204,29 @@ export function createAgentsHouseAdapter(options) {
|
|
|
266
204
|
if (request.pageToken !== undefined) return {
|
|
267
205
|
kind: 'transport-uncertainty'
|
|
268
206
|
};
|
|
269
|
-
const
|
|
207
|
+
const from = logPosition(request.fromRoomVersion);
|
|
208
|
+
if (from === null) return {
|
|
209
|
+
kind: 'beyond-horizon'
|
|
210
|
+
};
|
|
211
|
+
const streamed = notifications.advance(entry, from);
|
|
270
212
|
if (streamed !== null) return streamed;
|
|
271
213
|
const answer = await transport.door(DOOR_ENUMERATE, {
|
|
272
214
|
prefixes: [
|
|
273
215
|
...contentPrefixes(entry)
|
|
274
216
|
],
|
|
275
217
|
positions: [
|
|
276
|
-
|
|
277
|
-
authority: entry.authority,
|
|
278
|
-
position: request.fromRoomVersion
|
|
279
|
-
}
|
|
218
|
+
presented(entry.authority, from)
|
|
280
219
|
]
|
|
281
220
|
});
|
|
282
221
|
const classified = classifyDoor(answer.status, answer.body, entry.locator);
|
|
283
222
|
if (classified !== null) return classified;
|
|
284
|
-
const enumeration = parseEnumeration(answer.body);
|
|
223
|
+
const enumeration = parseEnumeration(answer.body, 'credential');
|
|
285
224
|
if (enumeration === null) return {
|
|
286
225
|
kind: 'transport-uncertainty'
|
|
287
226
|
};
|
|
288
227
|
return refreshFrom(enumeration, entry, request.fromRoomVersion);
|
|
289
228
|
},
|
|
290
|
-
async mutate (_authorization, request) {
|
|
229
|
+
async mutate (_authorization, request, keep) {
|
|
291
230
|
const entry = authorityFor(request.locator);
|
|
292
231
|
if (entry === undefined) return {
|
|
293
232
|
kind: 'room-not-readable',
|
|
@@ -295,17 +234,13 @@ export function createAgentsHouseAdapter(options) {
|
|
|
295
234
|
};
|
|
296
235
|
const mapped = houseChanges(request.changeBatch, entry.handle);
|
|
297
236
|
if (mapped.kind === 'unmapped') return rejectedMapping(mapped);
|
|
298
|
-
const
|
|
237
|
+
const head = operationHead(request.changeBatch);
|
|
299
238
|
const delta = deltaBody(mapped.changes);
|
|
300
239
|
const bytes = deltaBytes(delta);
|
|
301
|
-
const
|
|
302
|
-
|
|
303
|
-
if (
|
|
304
|
-
|
|
305
|
-
outcome = await submit(identity, mapped.changes, delta, bytes, entry);
|
|
306
|
-
}
|
|
307
|
-
if (RESOLVED_OUTCOMES.has(outcome.kind)) submissions.delete(identity);
|
|
308
|
-
return outcome;
|
|
240
|
+
const handed = request.upload;
|
|
241
|
+
const outcome = await submit(head, mapped.changes, delta, bytes, entry, handed, keep);
|
|
242
|
+
if (handed === undefined || !lapsedGrant(outcome)) return outcome;
|
|
243
|
+
return submit(head, mapped.changes, delta, bytes, entry, undefined, keep);
|
|
309
244
|
},
|
|
310
245
|
async history (_authorization, request) {
|
|
311
246
|
const entry = authorityFor(request.locator);
|
|
@@ -331,10 +266,16 @@ export function createAgentsHouseAdapter(options) {
|
|
|
331
266
|
});
|
|
332
267
|
},
|
|
333
268
|
async action (_authorization, request) {
|
|
334
|
-
|
|
269
|
+
const result = await houseAction(transport, request);
|
|
270
|
+
const answered = request.input?.conversation;
|
|
271
|
+
if (request.name === 'conversation.answer' && result.kind === 'action' && typeof answered === 'string') {
|
|
272
|
+
notifications.question(answered);
|
|
273
|
+
}
|
|
274
|
+
return result;
|
|
335
275
|
},
|
|
336
276
|
roomVersions: notifications,
|
|
337
|
-
conversations: notifications.conversations
|
|
277
|
+
conversations: notifications.conversations,
|
|
278
|
+
serviceMode: notifications.serviceMode
|
|
338
279
|
};
|
|
339
280
|
}
|
|
340
281
|
|
package/dist/adapter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/adapter.ts"],"sourcesContent":["import type {\n ActionRequest,\n ActionResult,\n Adapter,\n Authorization,\n BootstrapRequest,\n BootstrapResult,\n DiscoverResult,\n DiscoveredRoom,\n HistoryRequest,\n HistoryResult,\n ModelIdentity,\n ModelRequest,\n ModelResult,\n MutationRequest,\n MutationResult,\n RefreshRequest,\n RefreshResult,\n} from '@agentshouse/mdruntime';\nimport {\n DISCOVER_PREFIXES,\n PROVIDER_SELECTION_MODEL_ROOT,\n discoveredRoom,\n locatorOf,\n mapDiscovery,\n parseDiscovery,\n providerSelection,\n trackedFrom,\n type HouseAuthority,\n type TrackedAuthority,\n} from './discovery.js';\nimport {\n authorityRoot,\n bootstrapFrom,\n contentPrefixes,\n definitionsFrom,\n modelPrefix,\n parseEnumeration,\n parseEnvelope,\n parseGrant,\n refreshFrom,\n} from './read.js';\nimport { houseAction } from './actions.js';\nimport { classifyDoor } from './refusal.js';\nimport { houseNotifications } from './stream.js';\nimport {\n DOOR_BATCH,\n DOOR_BATCH_UPLOAD,\n DOOR_BOOTSTRAP,\n DOOR_DISCOVER,\n DOOR_ENUMERATE,\n DOOR_REVISIONS,\n PRIVATE_AUTHORITY,\n type HouseTransport,\n} from './transport.js';\nimport { sha256Hex } from './digest.js';\nimport {\n batchPaths,\n deltaBody,\n deltaBytes,\n deltaDigest,\n historyOutcome,\n houseChanges,\n mutationOutcome,\n rejectedMapping,\n revisionBody,\n uploadable,\n} from './write.js';\n\nexport type AgentsHouseAdapterOptions = {\n transport: HouseTransport;\n authorize(): Promise<Authorization>;\n};\n\ntype HeldModel = { snapshot: ModelResult; identity: ModelIdentity | null };\n\nconst MODEL_ABSENT: ModelResult = { kind: 'model-unavailable', reason: 'not-readable' };\n\nconst UNCERTAIN: MutationResult = { kind: 'transport-uncertainty' };\n\nconst RESOLVED_OUTCOMES: ReadonlySet<MutationResult['kind']> = new Set([\n 'accepted',\n 'conflicted',\n 'rejected',\n 'expired',\n]);\n\ntype Submission = { body: Record<string, unknown> } | { outcome: MutationResult };\n\nfunction lapsedGrant(outcome: MutationResult): boolean {\n return outcome.kind === 'rejected' && outcome.code === 'upload_unavailable';\n}\n\nfunction modelFailure(\n classified: ReturnType<typeof classifyDoor>,\n envelope: ReturnType<typeof parseEnvelope>,\n): ModelResult {\n if (classified === null) {\n return envelope === null ? { kind: 'transport-uncertainty' } : MODEL_ABSENT;\n }\n if (classified.kind === 'revoked-authorization') return { kind: 'revoked-authorization' };\n if (classified.kind === 'transport-uncertainty') return { kind: 'transport-uncertainty' };\n return MODEL_ABSENT;\n}\n\nfunction modelVersion(revisions: readonly string[]): Promise<string> {\n return sha256Hex(JSON.stringify(revisions));\n}\n\nexport function createAgentsHouseAdapter(options: AgentsHouseAdapterOptions): Adapter {\n const transport = options.transport;\n const notifications = houseNotifications(transport);\n const tracked = new Map<string, TrackedAuthority>();\n const models = new Map<string, HeldModel>();\n const submissions = new Map<string, { sha256: string; body: Record<string, unknown> }>();\n\n function modelKey(locator: string, attached: ModelRequest['attached']): string {\n return `${locator} ${attached}`;\n }\n\n async function held(\n envelope: ReturnType<typeof parseEnvelope>,\n entry: TrackedAuthority,\n modelRoot: string,\n identity: string,\n failure: ModelResult,\n ): Promise<HeldModel> {\n const read = envelope === null ? null : definitionsFrom(envelope, entry, modelRoot);\n if (read === null) return { snapshot: failure, identity: null };\n const version = await modelVersion(read.revisions);\n return {\n snapshot: { kind: 'model', snapshot: { identity, version, definitions: read.definitions } },\n identity: { identity, version },\n };\n }\n\n async function acquireModels(\n entries: readonly TrackedAuthority[],\n ): Promise<Map<string, HeldModel>> {\n const acquired = new Map<string, HeldModel>();\n const privateEntry = entries.find((entry) => entry.authority === PRIVATE_AUTHORITY);\n const prefixes = entries.map((entry) => modelPrefix(entry, entry.modelRoot));\n if (privateEntry !== undefined) {\n prefixes.push(`${authorityRoot(undefined)}/${PROVIDER_SELECTION_MODEL_ROOT}`);\n }\n const answer = await transport.door(DOOR_BOOTSTRAP, { prefixes });\n const classified = classifyDoor(answer.status, answer.body, PRIVATE_AUTHORITY);\n const envelope = classified === null ? parseEnvelope(await bundled(answer.body)) : null;\n const failure: ModelResult = modelFailure(classified, envelope);\n for (const entry of entries) {\n acquired.set(\n modelKey(entry.locator, 'collection'),\n await held(\n envelope,\n entry,\n entry.modelRoot,\n `${authorityRoot(entry.handle)}/${entry.modelRoot}`,\n failure,\n ),\n );\n }\n if (privateEntry !== undefined) {\n acquired.set(\n modelKey(privateEntry.locator, 'typed-selection'),\n await held(\n envelope,\n privateEntry,\n PROVIDER_SELECTION_MODEL_ROOT,\n `${authorityRoot(undefined)}/${PROVIDER_SELECTION_MODEL_ROOT}`,\n failure,\n ),\n );\n }\n return acquired;\n }\n\n function retainModel(key: string, acquired: HeldModel | undefined): HeldModel | undefined {\n if (acquired === undefined) return models.get(key);\n if (acquired.snapshot.kind === 'transport-uncertainty') {\n const previous = models.get(key);\n if (previous !== undefined && previous.identity !== null) return previous;\n }\n models.set(key, acquired);\n return acquired;\n }\n\n function roomOf(authority: HouseAuthority, acquired: Map<string, HeldModel>): DiscoveredRoom {\n const locator = locatorOf(authority);\n const key = modelKey(locator, 'collection');\n const collection = retainModel(key, acquired.get(key));\n if (authority.kind !== 'private') {\n return discoveredRoom(authority, collection?.identity ?? null, undefined);\n }\n const selection = retainModel(\n modelKey(locator, 'typed-selection'),\n acquired.get(modelKey(locator, 'typed-selection')),\n );\n return discoveredRoom(\n authority,\n collection?.identity ?? null,\n providerSelection(selection?.identity ?? null),\n );\n }\n\n function authorityFor(locator: string): TrackedAuthority | undefined {\n return tracked.get(locator);\n }\n\n async function bundled(body: unknown): Promise<unknown> {\n const grant = parseGrant(body);\n if (grant === null) return body;\n if (grant.method !== 'GET') return null;\n const answer = await transport.transfer({\n act: 'working_copy_bundle',\n method: 'GET',\n url: grant.url,\n });\n return answer.status === 200 ? answer.body : null;\n }\n\n async function uploaded(\n identity: string,\n changes: readonly Readonly<Record<string, unknown>>[],\n delta: string,\n bytes: number,\n entry: TrackedAuthority,\n ): Promise<Submission> {\n const paths = batchPaths(changes);\n const sha256 = await deltaDigest(delta);\n const retained = submissions.get(identity);\n if (retained !== undefined && retained.sha256 === sha256) return { body: retained.body };\n const minted = await transport.door(DOOR_BATCH_UPLOAD, {\n operation_id: identity,\n paths,\n bytes,\n sha256,\n });\n if (minted.status !== 200) {\n return { outcome: mutationOutcome(minted.status, minted.body, entry.locator, entry.handle) };\n }\n const grant = parseGrant(minted.body);\n if (grant === null || grant.method !== 'POST') return { outcome: UNCERTAIN };\n const delivered = await transport.transfer({\n act: 'authored_batch_upload',\n method: 'POST',\n url: grant.url,\n body: `${grant.operation}\\n${delta}`,\n });\n if (delivered.status !== 200) return { outcome: UNCERTAIN };\n const holding = parseGrant(delivered.body);\n if (holding === null) return { outcome: UNCERTAIN };\n const body = {\n operation_id: identity,\n paths,\n upload: { url: holding.url, operation: holding.operation, bytes, sha256 },\n };\n submissions.set(identity, { sha256, body });\n return { body };\n }\n\n async function submit(\n identity: string,\n changes: readonly Readonly<Record<string, unknown>>[],\n delta: string,\n bytes: number,\n entry: TrackedAuthority,\n ): Promise<MutationResult> {\n const prepared: Submission = uploadable(bytes)\n ? await uploaded(identity, changes, delta, bytes, entry)\n : { body: { operation_id: identity, changes } };\n if ('outcome' in prepared) return prepared.outcome;\n const answer = await transport.door(DOOR_BATCH, prepared.body);\n return mutationOutcome(answer.status, answer.body, entry.locator, entry.handle);\n }\n\n return {\n async authorize() {\n return options.authorize();\n },\n\n async model(_authorization: Authorization, request: ModelRequest): Promise<ModelResult> {\n return models.get(modelKey(request.locator, request.attached))?.snapshot ?? MODEL_ABSENT;\n },\n\n async discover(_authorization: Authorization): Promise<DiscoverResult> {\n const answer = await transport.door(DOOR_DISCOVER, { prefixes: [...DISCOVER_PREFIXES] });\n const classified = classifyDoor(answer.status, answer.body, PRIVATE_AUTHORITY);\n if (classified !== null) {\n if (classified.kind === 'revoked-authorization') return classified;\n if (classified.kind === 'scoped-refusal') {\n return { kind: 'contract-unavailable', code: classified.code, fields: classified.fields };\n }\n return { kind: 'transport-uncertainty' };\n }\n const document = parseDiscovery(answer.body);\n if (document === null) return { kind: 'transport-uncertainty' };\n const entries = trackedFrom(document);\n tracked.clear();\n for (const entry of entries) tracked.set(entry.locator, entry);\n notifications.track(entries);\n const acquired = await acquireModels(entries);\n for (const key of [...models.keys()]) {\n if (!entries.some((entry) => key.startsWith(`${entry.locator} `))) models.delete(key);\n }\n return mapDiscovery(\n document,\n document.authorities.map((authority) => roomOf(authority, acquired)),\n );\n },\n\n async bootstrap(\n _authorization: Authorization,\n request: BootstrapRequest,\n ): Promise<BootstrapResult> {\n const entry = authorityFor(request.locator);\n if (entry === undefined) return { kind: 'room-not-readable', locator: request.locator };\n if (request.pageToken !== undefined) return { kind: 'transport-uncertainty' };\n const answer = await transport.door(DOOR_BOOTSTRAP, {\n prefixes: [...contentPrefixes(entry)],\n });\n const classified = classifyDoor(answer.status, answer.body, entry.locator);\n if (classified !== null) {\n return classified.kind === 'beyond-horizon'\n ? { kind: 'transport-uncertainty' }\n : classified;\n }\n const envelope = parseEnvelope(await bundled(answer.body));\n if (envelope === null) return { kind: 'transport-uncertainty' };\n return bootstrapFrom(envelope, entry);\n },\n\n async refresh(_authorization: Authorization, request: RefreshRequest): Promise<RefreshResult> {\n const entry = authorityFor(request.locator);\n if (entry === undefined) return { kind: 'room-not-readable', locator: request.locator };\n if (request.pageToken !== undefined) return { kind: 'transport-uncertainty' };\n const streamed = notifications.advance(entry, request.fromRoomVersion);\n if (streamed !== null) return streamed;\n const answer = await transport.door(DOOR_ENUMERATE, {\n prefixes: [...contentPrefixes(entry)],\n positions: [{ authority: entry.authority, position: request.fromRoomVersion }],\n });\n const classified = classifyDoor(answer.status, answer.body, entry.locator);\n if (classified !== null) return classified;\n const enumeration = parseEnumeration(answer.body);\n if (enumeration === null) return { kind: 'transport-uncertainty' };\n return refreshFrom(enumeration, entry, request.fromRoomVersion);\n },\n\n async mutate(_authorization: Authorization, request: MutationRequest): Promise<MutationResult> {\n const entry = authorityFor(request.locator);\n if (entry === undefined) return { kind: 'room-not-readable', locator: request.locator };\n const mapped = houseChanges(request.changeBatch, entry.handle);\n if (mapped.kind === 'unmapped') return rejectedMapping(mapped);\n const identity = request.changeBatch.id;\n const delta = deltaBody(mapped.changes);\n const bytes = deltaBytes(delta);\n const resent = submissions.has(identity);\n let outcome = await submit(identity, mapped.changes, delta, bytes, entry);\n if (resent && lapsedGrant(outcome)) {\n submissions.delete(identity);\n outcome = await submit(identity, mapped.changes, delta, bytes, entry);\n }\n if (RESOLVED_OUTCOMES.has(outcome.kind)) submissions.delete(identity);\n return outcome;\n },\n\n async history(_authorization: Authorization, request: HistoryRequest): Promise<HistoryResult> {\n const entry = authorityFor(request.locator);\n if (entry === undefined) return { kind: 'room-not-readable', locator: request.locator };\n const answer = await transport.door(\n DOOR_REVISIONS,\n revisionBody({\n path: request.path,\n handle: entry.handle,\n ...(request.revision === undefined ? {} : { revision: request.revision }),\n ...(request.pageToken === undefined ? {} : { pageToken: request.pageToken }),\n }),\n );\n return historyOutcome(answer.status, answer.body, entry.locator, {\n path: request.path,\n ...(request.revision === undefined ? {} : { revision: request.revision }),\n });\n },\n\n async action(_authorization: Authorization, request: ActionRequest): Promise<ActionResult> {\n return houseAction(transport, request);\n },\n\n roomVersions: notifications,\n conversations: notifications.conversations,\n };\n}\n"],"names":["DISCOVER_PREFIXES","PROVIDER_SELECTION_MODEL_ROOT","discoveredRoom","locatorOf","mapDiscovery","parseDiscovery","providerSelection","trackedFrom","authorityRoot","bootstrapFrom","contentPrefixes","definitionsFrom","modelPrefix","parseEnumeration","parseEnvelope","parseGrant","refreshFrom","houseAction","classifyDoor","houseNotifications","DOOR_BATCH","DOOR_BATCH_UPLOAD","DOOR_BOOTSTRAP","DOOR_DISCOVER","DOOR_ENUMERATE","DOOR_REVISIONS","PRIVATE_AUTHORITY","sha256Hex","batchPaths","deltaBody","deltaBytes","deltaDigest","historyOutcome","houseChanges","mutationOutcome","rejectedMapping","revisionBody","uploadable","MODEL_ABSENT","kind","reason","UNCERTAIN","RESOLVED_OUTCOMES","Set","lapsedGrant","outcome","code","modelFailure","classified","envelope","modelVersion","revisions","JSON","stringify","createAgentsHouseAdapter","options","transport","notifications","tracked","Map","models","submissions","modelKey","locator","attached","held","entry","modelRoot","identity","failure","read","snapshot","version","definitions","acquireModels","entries","acquired","privateEntry","find","authority","prefixes","map","undefined","push","answer","door","status","body","bundled","set","handle","retainModel","key","get","previous","roomOf","collection","selection","authorityFor","grant","method","transfer","act","url","uploaded","changes","delta","bytes","paths","sha256","retained","minted","operation_id","delivered","operation","holding","upload","submit","prepared","authorize","model","_authorization","request","discover","fields","document","clear","track","keys","some","startsWith","delete","authorities","bootstrap","pageToken","refresh","streamed","advance","fromRoomVersion","positions","position","enumeration","mutate","mapped","changeBatch","id","resent","has","history","path","revision","action","roomVersions","conversations"],"mappings":"AAmBA,SACEA,iBAAiB,EACjBC,6BAA6B,EAC7BC,cAAc,EACdC,SAAS,EACTC,YAAY,EACZC,cAAc,EACdC,iBAAiB,EACjBC,WAAW,QAGN,iBAAiB;AACxB,SACEC,aAAa,EACbC,aAAa,EACbC,eAAe,EACfC,eAAe,EACfC,WAAW,EACXC,gBAAgB,EAChBC,aAAa,EACbC,UAAU,EACVC,WAAW,QACN,YAAY;AACnB,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAASC,YAAY,QAAQ,eAAe;AAC5C,SAASC,kBAAkB,QAAQ,cAAc;AACjD,SACEC,UAAU,EACVC,iBAAiB,EACjBC,cAAc,EACdC,aAAa,EACbC,cAAc,EACdC,cAAc,EACdC,iBAAiB,QAEZ,iBAAiB;AACxB,SAASC,SAAS,QAAQ,cAAc;AACxC,SACEC,UAAU,EACVC,SAAS,EACTC,UAAU,EACVC,WAAW,EACXC,cAAc,EACdC,YAAY,EACZC,eAAe,EACfC,eAAe,EACfC,YAAY,EACZC,UAAU,QACL,aAAa;AASpB,MAAMC,eAA4B;IAAEC,MAAM;IAAqBC,QAAQ;AAAe;AAEtF,MAAMC,YAA4B;IAAEF,MAAM;AAAw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xB,kBAAkByG,GAAG,CAACtG,QAAQN,IAAI,GAAGsB,YAAYsE,MAAM,CAAC/D;YAC5D,OAAOvB;QACT;QAEA,MAAMuG,SAAQ3B,cAA6B,EAAEC,OAAuB;YAClE,MAAMxD,QAAQgC,aAAawB,QAAQ3D,OAAO;YAC1C,IAAIG,UAAUgB,WAAW,OAAO;gBAAE3C,MAAM;gBAAqBwB,SAAS2D,QAAQ3D,OAAO;YAAC;YACtF,MAAMqB,SAAS,MAAM5B,UAAU6B,IAAI,CACjC5D,gBACAW,aAAa;gBACXiH,MAAM3B,QAAQ2B,IAAI;gBAClB3D,QAAQxB,MAAMwB,MAAM;gBACpB,GAAIgC,QAAQ4B,QAAQ,KAAKpE,YAAY,CAAC,IAAI;oBAAEoE,UAAU5B,QAAQ4B,QAAQ;gBAAC,CAAC;gBACxE,GAAI5B,QAAQY,SAAS,KAAKpD,YAAY,CAAC,IAAI;oBAAEoD,WAAWZ,QAAQY,SAAS;gBAAC,CAAC;YAC7E;YAEF,OAAOtG,eAAeoD,OAAOE,MAAM,EAAEF,OAAOG,IAAI,EAAErB,MAAMH,OAAO,EAAE;gBAC/DsF,MAAM3B,QAAQ2B,IAAI;gBAClB,GAAI3B,QAAQ4B,QAAQ,KAAKpE,YAAY,CAAC,IAAI;oBAAEoE,UAAU5B,QAAQ4B,QAAQ;gBAAC,CAAC;YAC1E;QACF;QAEA,MAAMC,QAAO9B,cAA6B,EAAEC,OAAsB;YAChE,OAAOzG,YAAYuC,WAAWkE;QAChC;QAEA8B,cAAc/F;QACdgG,eAAehG,cAAcgG,aAAa;IAC5C;AACF"}
|
|
1
|
+
{"version":3,"sources":["/workspace/packages/mdruntime-adapter/src/adapter.ts"],"sourcesContent":["import type {\n ActionRequest,\n ActionResult,\n Adapter,\n Authorization,\n BootstrapRequest,\n BootstrapResult,\n DiscoverResult,\n DiscoveredRoom,\n HistoryRequest,\n HistoryResult,\n ModelRequest,\n ModelResult,\n MutationRequest,\n MutationResult,\n RefreshRequest,\n RefreshResult,\n} from '@agentshouse/mdruntime';\nimport {\n DISCOVER_PREFIXES,\n HOUSE_SCHEMA,\n capabilities,\n discoveredRoom,\n locatorOf,\n mapDiscovery,\n parseDiscovery,\n providerSelection,\n trackedFrom,\n type HouseAuthority,\n type TrackedAuthority,\n} from './discovery.js';\nimport {\n MODEL_ABSENT,\n failedModel,\n heldModel,\n modelKey,\n modelShelf,\n type HeldModel,\n} from './model.js';\nimport { createSiteAdapter } from './site.js';\nimport {\n bootstrapFrom,\n contentPrefixes,\n parseEnumeration,\n parseEnvelope,\n parseGrant,\n refreshFrom,\n schemaFrom,\n schemaPath,\n} from './read.js';\nimport { houseAction } from './actions.js';\nimport { classifyDoor, discoveryFailure } from './refusal.js';\nimport { houseNotifications } from './stream.js';\nimport {\n DOOR_BATCH,\n DOOR_BATCH_UPLOAD,\n DOOR_BOOTSTRAP,\n DOOR_DISCOVER,\n DOOR_ENUMERATE,\n DOOR_REVISIONS,\n PRIVATE_LOCATOR,\n type HouseSiteTransport,\n type HouseTransport,\n} from './transport.js';\nimport {\n batchPaths,\n deltaBody,\n deltaBytes,\n deltaDigest,\n historyOutcome,\n houseChanges,\n mutationOutcome,\n operationHead,\n rejectedMapping,\n revisionBody,\n uploadable,\n type OperationHead,\n} from './write.js';\nimport { logPosition, presented } from './version.js';\n\nexport type AgentsHouseAdapterOptions =\n | {\n transport: HouseTransport;\n authorize(): Promise<Authorization>;\n }\n | { site: HouseSiteTransport };\n\nconst UNCERTAIN: MutationResult = { kind: 'transport-uncertainty' };\n\ntype Submission = { body: Record<string, unknown> } | { outcome: MutationResult };\n\ntype Upload = { url: string; operation: string; bytes: number; sha256: string };\n\ntype Keep = (upload: unknown) => Promise<void>;\n\nfunction lapsedGrant(outcome: MutationResult): boolean {\n return outcome.kind === 'rejected' && outcome.code === 'upload_unavailable';\n}\n\nfunction modelFailure(\n classified: ReturnType<typeof classifyDoor>,\n envelope: ReturnType<typeof parseEnvelope>,\n): ModelResult {\n if (classified === null) {\n return envelope === null ? { kind: 'transport-uncertainty' } : MODEL_ABSENT;\n }\n return failedModel(classified);\n}\n\nexport function createAgentsHouseAdapter(options: AgentsHouseAdapterOptions): Adapter {\n if ('site' in options) return createSiteAdapter(options.site);\n const transport = options.transport;\n const notifications = houseNotifications(transport, 'credential');\n const tracked = new Map<string, TrackedAuthority>();\n const models = modelShelf();\n\n function held(\n envelope: ReturnType<typeof parseEnvelope>,\n entry: TrackedAuthority,\n schema: string,\n failure: ModelResult,\n ): Promise<HeldModel> {\n return heldModel(\n envelope === null ? null : schemaFrom(envelope, entry, schema),\n schemaPath(entry.handle, schema),\n failure,\n );\n }\n\n async function acquireModels(\n entries: readonly TrackedAuthority[],\n ): Promise<Map<string, HeldModel>> {\n const acquired = new Map<string, HeldModel>();\n const privateEntry = entries.find((entry) => entry.locator === PRIVATE_LOCATOR);\n const prefixes = entries.map((entry) => schemaPath(entry.handle, entry.schema));\n if (privateEntry !== undefined) prefixes.push(schemaPath(undefined, HOUSE_SCHEMA));\n const answer = await transport.door(DOOR_BOOTSTRAP, { prefixes });\n const classified = classifyDoor(answer.status, answer.body, PRIVATE_LOCATOR);\n const envelope = classified === null ? parseEnvelope(await bundled(answer.body)) : null;\n const failure: ModelResult = modelFailure(classified, envelope);\n for (const entry of entries) {\n acquired.set(\n modelKey(entry.locator, 'collection'),\n await held(envelope, entry, entry.schema, failure),\n );\n }\n if (privateEntry !== undefined) {\n acquired.set(\n modelKey(privateEntry.locator, 'typed-selection'),\n await held(envelope, privateEntry, HOUSE_SCHEMA, failure),\n );\n }\n return acquired;\n }\n\n function roomOf(authority: HouseAuthority, acquired: Map<string, HeldModel>): DiscoveredRoom {\n const locator = locatorOf(authority);\n const key = modelKey(locator, 'collection');\n const collection = models.retain(key, acquired.get(key));\n if (authority.roomHandle !== null) {\n return discoveredRoom(authority, collection?.identity ?? null, undefined);\n }\n const selection = models.retain(\n modelKey(locator, 'typed-selection'),\n acquired.get(modelKey(locator, 'typed-selection')),\n );\n return discoveredRoom(\n authority,\n collection?.identity ?? null,\n providerSelection(selection?.identity ?? null),\n );\n }\n\n function authorityFor(locator: string): TrackedAuthority | undefined {\n return tracked.get(locator);\n }\n\n async function bundled(body: unknown): Promise<unknown> {\n const grant = parseGrant(body);\n if (grant === null) return body;\n if (grant.method !== 'GET') return null;\n const answer = await transport.transfer({\n act: 'working_copy_bundle',\n method: 'GET',\n url: grant.url,\n answer: 'json',\n });\n return answer.status === 200 ? answer.body : null;\n }\n\n async function uploaded(\n head: OperationHead,\n changes: readonly Readonly<Record<string, unknown>>[],\n delta: string,\n bytes: number,\n entry: TrackedAuthority,\n handed: Upload | undefined,\n keep: Keep,\n ): Promise<Submission> {\n const paths = batchPaths(changes);\n const sha256 = await deltaDigest(delta);\n if (handed !== undefined && handed.sha256 === sha256) {\n return { body: { ...head, paths, upload: handed } };\n }\n const minted = await transport.door(DOOR_BATCH_UPLOAD, { ...head, paths, bytes, sha256 });\n if (minted.status !== 200) {\n return { outcome: mutationOutcome(minted.status, minted.body, entry.locator, entry.handle) };\n }\n const grant = parseGrant(minted.body);\n if (grant === null || grant.method !== 'POST') return { outcome: UNCERTAIN };\n const delivered = await transport.transfer({\n act: 'authored_batch_upload',\n method: 'POST',\n url: grant.url,\n answer: 'json',\n body: `${grant.operation}\\n${delta}`,\n });\n if (delivered.status !== 200) return { outcome: UNCERTAIN };\n const holding = parseGrant(delivered.body);\n if (holding === null || holding.method !== 'POST') return { outcome: UNCERTAIN };\n const upload: Upload = { url: holding.url, operation: holding.operation, bytes, sha256 };\n await keep(upload);\n return { body: { ...head, paths, upload } };\n }\n\n async function submit(\n head: OperationHead,\n changes: readonly Readonly<Record<string, unknown>>[],\n delta: string,\n bytes: number,\n entry: TrackedAuthority,\n handed: Upload | undefined,\n keep: Keep,\n ): Promise<MutationResult> {\n const prepared: Submission = uploadable(bytes)\n ? await uploaded(head, changes, delta, bytes, entry, handed, keep)\n : { body: { ...head, changes } };\n if ('outcome' in prepared) return prepared.outcome;\n const answer = await transport.door(DOOR_BATCH, prepared.body);\n return mutationOutcome(answer.status, answer.body, entry.locator, entry.handle);\n }\n\n return {\n async authorize() {\n return options.authorize();\n },\n\n async model(_authorization: Authorization, request: ModelRequest): Promise<ModelResult> {\n return models.answer(request);\n },\n\n async discover(_authorization: Authorization): Promise<DiscoverResult> {\n const answer = await transport.door(DOOR_DISCOVER, { prefixes: [...DISCOVER_PREFIXES] });\n const classified = classifyDoor(answer.status, answer.body, PRIVATE_LOCATOR);\n if (classified !== null) return discoveryFailure(classified);\n const document = parseDiscovery(answer.body);\n if (document === null) return { kind: 'transport-uncertainty' };\n const entries = trackedFrom(document);\n tracked.clear();\n for (const entry of entries) tracked.set(entry.locator, entry);\n notifications.track(entries);\n const acquired = await acquireModels(entries);\n models.keep(entries.map((entry) => entry.locator));\n return mapDiscovery(\n document,\n document.authorities.map((authority) => roomOf(authority, acquired)),\n capabilities(document.actions),\n );\n },\n\n async bootstrap(\n _authorization: Authorization,\n request: BootstrapRequest,\n ): Promise<BootstrapResult> {\n const entry = authorityFor(request.locator);\n if (entry === undefined) return { kind: 'room-not-readable', locator: request.locator };\n if (request.pageToken !== undefined) return { kind: 'transport-uncertainty' };\n const answer = await transport.door(DOOR_BOOTSTRAP, {\n prefixes: [...contentPrefixes(entry)],\n });\n const classified = classifyDoor(answer.status, answer.body, entry.locator);\n if (classified !== null) {\n return classified.kind === 'beyond-horizon'\n ? { kind: 'transport-uncertainty' }\n : classified;\n }\n const envelope = parseEnvelope(await bundled(answer.body));\n if (envelope === null) return { kind: 'transport-uncertainty' };\n return bootstrapFrom(envelope, entry);\n },\n\n async refresh(_authorization: Authorization, request: RefreshRequest): Promise<RefreshResult> {\n const entry = authorityFor(request.locator);\n if (entry === undefined) return { kind: 'room-not-readable', locator: request.locator };\n if (request.pageToken !== undefined) return { kind: 'transport-uncertainty' };\n const from = logPosition(request.fromRoomVersion);\n if (from === null) return { kind: 'beyond-horizon' };\n const streamed = notifications.advance(entry, from);\n if (streamed !== null) return streamed;\n const answer = await transport.door(DOOR_ENUMERATE, {\n prefixes: [...contentPrefixes(entry)],\n positions: [presented(entry.authority, from)],\n });\n const classified = classifyDoor(answer.status, answer.body, entry.locator);\n if (classified !== null) return classified;\n const enumeration = parseEnumeration(answer.body, 'credential');\n if (enumeration === null) return { kind: 'transport-uncertainty' };\n return refreshFrom(enumeration, entry, request.fromRoomVersion);\n },\n\n async mutate(\n _authorization: Authorization,\n request: MutationRequest,\n keep: Keep,\n ): Promise<MutationResult> {\n const entry = authorityFor(request.locator);\n if (entry === undefined) return { kind: 'room-not-readable', locator: request.locator };\n const mapped = houseChanges(request.changeBatch, entry.handle);\n if (mapped.kind === 'unmapped') return rejectedMapping(mapped);\n const head = operationHead(request.changeBatch);\n const delta = deltaBody(mapped.changes);\n const bytes = deltaBytes(delta);\n const handed = request.upload as Upload | undefined;\n const outcome = await submit(head, mapped.changes, delta, bytes, entry, handed, keep);\n if (handed === undefined || !lapsedGrant(outcome)) return outcome;\n return submit(head, mapped.changes, delta, bytes, entry, undefined, keep);\n },\n\n async history(_authorization: Authorization, request: HistoryRequest): Promise<HistoryResult> {\n const entry = authorityFor(request.locator);\n if (entry === undefined) return { kind: 'room-not-readable', locator: request.locator };\n const answer = await transport.door(\n DOOR_REVISIONS,\n revisionBody({\n path: request.path,\n handle: entry.handle,\n ...(request.revision === undefined ? {} : { revision: request.revision }),\n ...(request.pageToken === undefined ? {} : { pageToken: request.pageToken }),\n }),\n );\n return historyOutcome(answer.status, answer.body, entry.locator, {\n path: request.path,\n ...(request.revision === undefined ? {} : { revision: request.revision }),\n });\n },\n\n async action(_authorization: Authorization, request: ActionRequest): Promise<ActionResult> {\n const result = await houseAction(transport, request);\n const answered = (request.input as { conversation?: unknown } | null)?.conversation;\n if (\n request.name === 'conversation.answer' &&\n result.kind === 'action' &&\n typeof answered === 'string'\n ) {\n notifications.question(answered);\n }\n return result;\n },\n\n roomVersions: notifications,\n conversations: notifications.conversations,\n serviceMode: notifications.serviceMode,\n };\n}\n"],"names":["DISCOVER_PREFIXES","HOUSE_SCHEMA","capabilities","discoveredRoom","locatorOf","mapDiscovery","parseDiscovery","providerSelection","trackedFrom","MODEL_ABSENT","failedModel","heldModel","modelKey","modelShelf","createSiteAdapter","bootstrapFrom","contentPrefixes","parseEnumeration","parseEnvelope","parseGrant","refreshFrom","schemaFrom","schemaPath","houseAction","classifyDoor","discoveryFailure","houseNotifications","DOOR_BATCH","DOOR_BATCH_UPLOAD","DOOR_BOOTSTRAP","DOOR_DISCOVER","DOOR_ENUMERATE","DOOR_REVISIONS","PRIVATE_LOCATOR","batchPaths","deltaBody","deltaBytes","deltaDigest","historyOutcome","houseChanges","mutationOutcome","operationHead","rejectedMapping","revisionBody","uploadable","logPosition","presented","UNCERTAIN","kind","lapsedGrant","outcome","code","modelFailure","classified","envelope","createAgentsHouseAdapter","options","site","transport","notifications","tracked","Map","models","held","entry","schema","failure","handle","acquireModels","entries","acquired","privateEntry","find","locator","prefixes","map","undefined","push","answer","door","status","body","bundled","set","roomOf","authority","key","collection","retain","get","roomHandle","identity","selection","authorityFor","grant","method","transfer","act","url","uploaded","head","changes","delta","bytes","handed","keep","paths","sha256","upload","minted","delivered","operation","holding","submit","prepared","authorize","model","_authorization","request","discover","document","clear","track","authorities","actions","bootstrap","pageToken","refresh","from","fromRoomVersion","streamed","advance","positions","enumeration","mutate","mapped","changeBatch","history","path","revision","action","result","answered","input","conversation","name","question","roomVersions","conversations","serviceMode"],"mappings":"AAkBA,SACEA,iBAAiB,EACjBC,YAAY,EACZC,YAAY,EACZC,cAAc,EACdC,SAAS,EACTC,YAAY,EACZC,cAAc,EACdC,iBAAiB,EACjBC,WAAW,QAGN,iBAAiB;AACxB,SACEC,YAAY,EACZC,WAAW,EACXC,SAAS,EACTC,QAAQ,EACRC,UAAU,QAEL,aAAa;AACpB,SAASC,iBAAiB,QAAQ,YAAY;AAC9C,SACEC,aAAa,EACbC,eAAe,EACfC,gBAAgB,EAChBC,aAAa,EACbC,UA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B,EAAEC,OAAsB;YAChE,MAAMuB,SAAS,MAAMtH,YAAYmC,WAAW4D;YAC5C,MAAMwB,WAAYxB,QAAQyB,KAAK,EAAwCC;YACvE,IACE1B,QAAQ2B,IAAI,KAAK,yBACjBJ,OAAO7F,IAAI,KAAK,YAChB,OAAO8F,aAAa,UACpB;gBACAnF,cAAcuF,QAAQ,CAACJ;YACzB;YACA,OAAOD;QACT;QAEAM,cAAcxF;QACdyF,eAAezF,cAAcyF,aAAa;QAC1CC,aAAa1F,cAAc0F,WAAW;IACxC;AACF"}
|
package/dist/discovery.d.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import type { Capability, DiscoveredRoom, Discovery, ProviderLimit, Retention, TypedSelection } from '@agentshouse/mdruntime';
|
|
2
|
+
import { type LogPosition } from './version.js';
|
|
2
3
|
export declare const ROOM_CONTRACT_VERSION = 1;
|
|
3
4
|
export declare const MD_MODEL_IDENTITY = "@agentshouse/mdmodel";
|
|
4
5
|
export declare const ROOM_VERSION_NOTIFICATIONS = "room-version-notifications";
|
|
5
6
|
export declare const PROVIDER_ACTIONS = "provider-actions";
|
|
7
|
+
export declare const MOVE_REFERENCE_REWRITES = "move-reference-rewrites";
|
|
6
8
|
export declare const DISCOVER_PREFIXES: readonly string[];
|
|
7
9
|
export declare const PROVIDER_SELECTION_ROOTS: readonly string[];
|
|
8
|
-
export declare const
|
|
10
|
+
export declare const HOUSE_SCHEMA = "house/schema.yaml";
|
|
9
11
|
export type HouseBounds = {
|
|
10
12
|
max_authored_file_bytes: number;
|
|
11
13
|
max_batch_operations: number;
|
|
14
|
+
max_batch_documents: number;
|
|
12
15
|
max_path_length: number;
|
|
13
16
|
max_path_depth: number;
|
|
14
17
|
max_mount_files: number;
|
|
@@ -22,39 +25,64 @@ export type HouseOperations = {
|
|
|
22
25
|
write: readonly string[];
|
|
23
26
|
delete: readonly string[];
|
|
24
27
|
};
|
|
25
|
-
export type HouseAuthority = {
|
|
26
|
-
kind: 'room' | 'private';
|
|
28
|
+
export type HouseAuthority = LogPosition & {
|
|
27
29
|
roomRef: string;
|
|
28
30
|
roomHandle: string | null;
|
|
29
31
|
name: string;
|
|
30
32
|
collectionRoot: string;
|
|
31
|
-
|
|
33
|
+
schema: string;
|
|
32
34
|
managedReplication: 'admitted' | 'unavailable';
|
|
33
35
|
protectedPaths: readonly string[];
|
|
34
36
|
operations: HouseOperations;
|
|
35
|
-
position: string;
|
|
36
37
|
};
|
|
37
38
|
export type HouseDiscoveryDocument = {
|
|
38
39
|
bounds: HouseBounds;
|
|
39
40
|
mdModelVersion: string;
|
|
40
41
|
authorities: readonly HouseAuthority[];
|
|
42
|
+
actions: readonly string[];
|
|
41
43
|
};
|
|
42
|
-
export type TrackedAuthority = {
|
|
44
|
+
export type TrackedAuthority = LogPosition & {
|
|
43
45
|
locator: string;
|
|
44
46
|
authority: string;
|
|
45
47
|
handle: string | undefined;
|
|
46
48
|
collectionRoot: string;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
schema: string;
|
|
50
|
+
schemas: readonly string[];
|
|
51
|
+
};
|
|
52
|
+
export type HouseSiteEntry = {
|
|
53
|
+
roomRef: string;
|
|
54
|
+
segment: string;
|
|
55
|
+
};
|
|
56
|
+
export type HouseSiteSlot = {
|
|
57
|
+
slot: string;
|
|
58
|
+
entries: readonly HouseSiteEntry[];
|
|
59
|
+
};
|
|
60
|
+
export type HouseSiteAuthority = LogPosition & {
|
|
61
|
+
roomRef: string;
|
|
62
|
+
roomHandle: string;
|
|
63
|
+
collectionRoot: string;
|
|
64
|
+
schema: string;
|
|
65
|
+
};
|
|
66
|
+
export type HouseSiteDiscovery = {
|
|
67
|
+
bounds: HouseBounds;
|
|
68
|
+
mdModelVersion: string;
|
|
69
|
+
slots: readonly HouseSiteSlot[];
|
|
70
|
+
authorities: readonly HouseSiteAuthority[];
|
|
71
|
+
};
|
|
72
|
+
export type SiteTracked = TrackedAuthority & {
|
|
73
|
+
handle: string;
|
|
50
74
|
};
|
|
51
75
|
export declare function parseDiscovery(body: unknown): HouseDiscoveryDocument | null;
|
|
76
|
+
export declare function parseSiteDiscovery(body: unknown): HouseSiteDiscovery | null;
|
|
77
|
+
export declare function siteTracked(document: HouseSiteDiscovery): SiteTracked[];
|
|
78
|
+
export declare function siteSlots(document: HouseSiteDiscovery): Discovery['slots'];
|
|
52
79
|
export declare function locatorOf(authority: HouseAuthority): string;
|
|
53
80
|
export declare function trackedFrom(document: HouseDiscoveryDocument): TrackedAuthority[];
|
|
54
81
|
export declare function providerLimits(bounds: HouseBounds): readonly ProviderLimit[];
|
|
55
82
|
export declare function declaredRetention(bounds: HouseBounds): Retention;
|
|
56
|
-
export declare function capabilities(): readonly Capability[];
|
|
83
|
+
export declare function capabilities(actions: readonly string[]): readonly Capability[];
|
|
84
|
+
export declare function siteCapabilities(): readonly Capability[];
|
|
57
85
|
export declare function providerSelection(attachedModel: TypedSelection['attachedModel']): TypedSelection;
|
|
58
86
|
export declare function discoveredRoom(authority: HouseAuthority, attachedModel: DiscoveredRoom['attachedModel'], typedSelection: TypedSelection | undefined): DiscoveredRoom;
|
|
59
|
-
export declare function mapDiscovery(document: HouseDiscoveryDocument, rooms: readonly DiscoveredRoom[]): Discovery;
|
|
87
|
+
export declare function mapDiscovery(document: Pick<HouseDiscoveryDocument, 'bounds' | 'mdModelVersion'>, rooms: readonly DiscoveredRoom[], declared: readonly Capability[]): Discovery;
|
|
60
88
|
//# 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,SAAS,EACT,cAAc,EACf,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":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