@agentshouse/mdruntime-adapter 0.1.0-c50b979d9313f → 0.1.0-c51fa73c21cdb
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 +281 -276
- package/dist/actions.d.ts +12 -5
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +82 -109
- package/dist/adapter.d.ts +1 -0
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +294 -106
- package/dist/digest.d.ts +1 -1
- package/dist/digest.d.ts.map +1 -1
- package/dist/digest.js +1 -1
- package/dist/discovery.d.ts +5 -3
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +29 -10
- package/dist/gather.d.ts +1 -1
- package/dist/gather.d.ts.map +1 -1
- package/dist/gather.js +4 -14
- package/dist/handed.d.ts +6 -6
- package/dist/handed.d.ts.map +1 -1
- package/dist/handed.js +36 -29
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/part.d.ts +13 -0
- package/dist/part.d.ts.map +1 -0
- package/dist/part.js +80 -0
- package/dist/read.d.ts +52 -20
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +232 -107
- package/dist/referrer.d.ts.map +1 -1
- package/dist/referrer.js +0 -2
- package/dist/room-types.d.ts +6 -0
- package/dist/room-types.d.ts.map +1 -0
- package/dist/room-types.js +34 -0
- package/dist/site.d.ts +1 -1
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +139 -116
- package/dist/stream.d.ts +4 -4
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +260 -77
- package/dist/transport.d.ts +39 -2
- package/dist/transport.d.ts.map +1 -1
- package/dist/version.d.ts +1 -0
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/write.d.ts +12 -1
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +96 -44
- package/package.json +2 -2
package/dist/actions.d.ts
CHANGED
|
@@ -6,10 +6,11 @@ type Operated = {
|
|
|
6
6
|
type ConversationControl = Operated & {
|
|
7
7
|
readonly conversation: string;
|
|
8
8
|
};
|
|
9
|
-
type SentFile = FileDeclaration & {
|
|
10
|
-
readonly blob: Blob;
|
|
11
|
-
};
|
|
12
9
|
export type AppInputs = {
|
|
10
|
+
readonly 'conversation.attach': FileDeclaration & {
|
|
11
|
+
readonly room: string;
|
|
12
|
+
readonly blob: Blob;
|
|
13
|
+
};
|
|
13
14
|
readonly 'conversation.answer': ConversationControl & {
|
|
14
15
|
readonly answer: {
|
|
15
16
|
readonly interaction_id: string;
|
|
@@ -24,11 +25,17 @@ export type AppInputs = {
|
|
|
24
25
|
readonly 'conversation.interrupt': ConversationControl;
|
|
25
26
|
readonly 'conversation.kill': ConversationControl;
|
|
26
27
|
readonly 'conversation.send': ConversationControl & {
|
|
27
|
-
readonly
|
|
28
|
-
readonly
|
|
28
|
+
readonly operation_id: string;
|
|
29
|
+
readonly text: string;
|
|
30
|
+
};
|
|
31
|
+
readonly 'trigger.list': {
|
|
32
|
+
readonly room_refs: readonly string[];
|
|
29
33
|
};
|
|
30
34
|
};
|
|
31
35
|
export type AppAnswers = {
|
|
36
|
+
readonly 'conversation.attach': {
|
|
37
|
+
readonly path: string;
|
|
38
|
+
};
|
|
32
39
|
readonly 'conversation.history': ConversationHistories;
|
|
33
40
|
};
|
|
34
41
|
export type AppAnswerAdditions = {
|
package/dist/actions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAE1B,KAAK,0BAA0B,EAC/B,KAAK,eAAe,EACrB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,eAAe,EAAE,c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O,MAAM,WAAW,WAAW,CAAC;AAEpC,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAE5D,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,CAKhF,CAAC;AAYJ,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB,CAE3E;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,iBAAiB,EAAE,CAKvF;AAED,wBAAgB,WAAW,CACzB,SAAS,EAAE,cAAc,EACzB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,YAAY,CAAC,CAQvB;AA6ED,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,CAQjF;AAyID,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAUtE"}
|
package/dist/actions.js
CHANGED
|
@@ -2,6 +2,7 @@ import { changeBatchIdentity, } from '@agentshouse/mdruntime';
|
|
|
2
2
|
import { doorRefusal } from './refusal.js';
|
|
3
3
|
const HISTORY_PAGE = 100;
|
|
4
4
|
const HISTORY_CONVERSATIONS = 64;
|
|
5
|
+
const TRIGGER_ROOMS = 100;
|
|
5
6
|
const OCTET_STREAM = 'application/octet-stream';
|
|
6
7
|
function mapped(door, input = (given) => given) {
|
|
7
8
|
return {
|
|
@@ -11,16 +12,18 @@ function mapped(door, input = (given) => given) {
|
|
|
11
12
|
},
|
|
12
13
|
};
|
|
13
14
|
}
|
|
14
|
-
function carried(door, carry, batched) {
|
|
15
|
+
function carried(door, carry, batched, room) {
|
|
15
16
|
return {
|
|
16
17
|
door,
|
|
17
18
|
...(batched === undefined ? {} : { batched }),
|
|
19
|
+
...(room === undefined ? {} : { room }),
|
|
18
20
|
carry: (transport, input, name) => carry(transport, `/door/${door}`, input, name),
|
|
19
21
|
};
|
|
20
22
|
}
|
|
21
23
|
const APP_ACTS = {
|
|
22
24
|
'access.read': mapped('rooms/access/read'),
|
|
23
25
|
'conversation.answer': mapped('conversations/interaction/answer', answerBody),
|
|
26
|
+
'conversation.attach': carried('conversations/attach', attachAction, undefined, 'room'),
|
|
24
27
|
'conversation.create': carried('conversations/create', createAction),
|
|
25
28
|
'conversation.delete': mapped('conversations/delete', controlBody),
|
|
26
29
|
'conversation.history': carried('conversations/history', historyAction, ['conversations']),
|
|
@@ -28,6 +31,7 @@ const APP_ACTS = {
|
|
|
28
31
|
'conversation.kill': mapped('conversations/kill', controlBody),
|
|
29
32
|
'conversation.markDone': mapped('conversations/done'),
|
|
30
33
|
'conversation.rename': mapped('conversations/rename'),
|
|
34
|
+
'conversation.retry': mapped('conversations/retry'),
|
|
31
35
|
'conversation.send': carried('conversations/send', sendAction),
|
|
32
36
|
'conversation.setOption': mapped('conversations/option'),
|
|
33
37
|
'feature.list': mapped('apps/features/read'),
|
|
@@ -43,7 +47,7 @@ const APP_ACTS = {
|
|
|
43
47
|
'routineAllowance.list': mapped('routines/allowance'),
|
|
44
48
|
'routineRequest.list': mapped('routines/requests'),
|
|
45
49
|
'storage.read': mapped('storage/inventory'),
|
|
46
|
-
'trigger.list':
|
|
50
|
+
'trigger.list': carried('triggers/read', triggersAction, ['room_refs'], 'room_refs'),
|
|
47
51
|
'triggerOccurrence.list': mapped('triggers/fired'),
|
|
48
52
|
};
|
|
49
53
|
export const HOUSE_APP_ACTS = Object.fromEntries(Object.entries(APP_ACTS).map(([name, act]) => [name, act.door]));
|
|
@@ -53,15 +57,15 @@ export const HOUSE_SITE_ACTS = {
|
|
|
53
57
|
};
|
|
54
58
|
export const HOUSE_APP_BATCHES = Object.fromEntries(Object.entries(APP_ACTS).flatMap(([name, act]) => act.batched === undefined ? [] : [[name, act.batched]]));
|
|
55
59
|
const APP_NAMES = new Map(Object.entries(APP_ACTS).map(([name, act]) => [act.door, name]));
|
|
60
|
+
const APP_ROOMS = new Map(Object.entries(APP_ACTS).flatMap(([name, act]) => act.room === undefined ? [] : [[name, act.room]]));
|
|
56
61
|
export function houseConversationAgents(locator) {
|
|
57
62
|
return { locator, type: 'house-agent', identity: 'agent', name: 'name', retired: 'retired' };
|
|
58
63
|
}
|
|
59
64
|
export function declaredActions(routes) {
|
|
60
|
-
return routes.map((route) =>
|
|
61
|
-
name
|
|
62
|
-
inputShape: {},
|
|
63
|
-
|
|
64
|
-
}));
|
|
65
|
+
return routes.map((route) => {
|
|
66
|
+
const name = APP_NAMES.get(route) ?? route;
|
|
67
|
+
return { name, inputShape: {}, resultKind: 'house', room: APP_ROOMS.get(name) ?? 'room_ref' };
|
|
68
|
+
});
|
|
65
69
|
}
|
|
66
70
|
export function houseAction(transport, request) {
|
|
67
71
|
if (Object.hasOwn(APP_ACTS, request.name)) {
|
|
@@ -140,6 +144,8 @@ export function actionOutcome(answer, name) {
|
|
|
140
144
|
if (answer.status === 401)
|
|
141
145
|
return { kind: 'revoked-authorization' };
|
|
142
146
|
const refusal = doorRefusal(answer.body);
|
|
147
|
+
if (refusal?.code === 'operation_contended')
|
|
148
|
+
return { kind: 'transport-uncertainty' };
|
|
143
149
|
if (refusal !== null)
|
|
144
150
|
return { kind: 'rejected', ...refusal };
|
|
145
151
|
if (answer.status === 404)
|
|
@@ -177,116 +183,74 @@ async function recordsAction(transport, route, input, name) {
|
|
|
177
183
|
async function carry(transport, route, name, input) {
|
|
178
184
|
return actionOutcome(await transport.door(route, input), name);
|
|
179
185
|
}
|
|
180
|
-
function
|
|
181
|
-
const
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
const sha256 = text(file, 'contentHash');
|
|
185
|
-
if (name === undefined || typeof bytes !== 'number' || sha256 === undefined)
|
|
186
|
+
function sendBody(input) {
|
|
187
|
+
const operation = text(input, 'operation_id');
|
|
188
|
+
const said = text(input, 'text');
|
|
189
|
+
if (operation === undefined || said === undefined)
|
|
186
190
|
return null;
|
|
187
|
-
|
|
188
|
-
const width = file.width;
|
|
189
|
-
const height = file.height;
|
|
190
|
-
return {
|
|
191
|
-
name,
|
|
192
|
-
media_type: mediaType !== undefined && mediaType.length > 0 ? mediaType : OCTET_STREAM,
|
|
193
|
-
bytes,
|
|
194
|
-
sha256,
|
|
195
|
-
...(typeof width === 'number' && typeof height === 'number'
|
|
196
|
-
? { dimensions: { width, height } }
|
|
197
|
-
: {}),
|
|
198
|
-
};
|
|
191
|
+
return { conversation_id: text(input, 'conversation'), operation_id: operation, text: said };
|
|
199
192
|
}
|
|
200
|
-
function
|
|
201
|
-
const
|
|
202
|
-
if (
|
|
203
|
-
return
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
const file = sendFile(entry);
|
|
209
|
-
if (file === null)
|
|
210
|
-
return null;
|
|
211
|
-
declared.push(file);
|
|
212
|
-
}
|
|
213
|
-
return declared;
|
|
193
|
+
async function sendAction(transport, route, input, name) {
|
|
194
|
+
const body = sendBody(input);
|
|
195
|
+
if (body === null)
|
|
196
|
+
return malformed();
|
|
197
|
+
const outcome = actionOutcome(await transport.door(route, body), name);
|
|
198
|
+
if (outcome.kind !== 'action')
|
|
199
|
+
return outcome;
|
|
200
|
+
return { ...outcome, result: withTurn(outcome.result) };
|
|
214
201
|
}
|
|
215
|
-
function
|
|
216
|
-
const
|
|
217
|
-
|
|
202
|
+
function attachBody(input) {
|
|
203
|
+
const room = text(input, 'room');
|
|
204
|
+
const name = text(input, 'name');
|
|
205
|
+
const sha256 = text(input, 'contentHash');
|
|
206
|
+
const bytes = record(input).byteLength;
|
|
207
|
+
if (room === undefined || name === undefined || sha256 === undefined)
|
|
218
208
|
return null;
|
|
219
|
-
|
|
209
|
+
if (typeof bytes !== 'number')
|
|
210
|
+
return null;
|
|
211
|
+
const mediaType = text(input, 'mediaType');
|
|
220
212
|
return {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
213
|
+
room_ref: room,
|
|
214
|
+
name,
|
|
215
|
+
bytes,
|
|
216
|
+
sha256,
|
|
217
|
+
media_type: mediaType !== undefined && mediaType.length > 0 ? mediaType : OCTET_STREAM,
|
|
225
218
|
};
|
|
226
219
|
}
|
|
227
|
-
|
|
228
|
-
const
|
|
229
|
-
if (blob === undefined || typeof blob !== 'object' || blob === null)
|
|
230
|
-
return null;
|
|
231
|
-
if (!('arrayBuffer' in blob) || typeof blob.arrayBuffer !== 'function')
|
|
232
|
-
return null;
|
|
233
|
-
return new Uint8Array(await blob.arrayBuffer());
|
|
234
|
-
}
|
|
235
|
-
function delivered(answer, name) {
|
|
236
|
-
return answer.status === 200 ? null : actionOutcome(answer, name);
|
|
237
|
-
}
|
|
238
|
-
function uploadGrant(entry) {
|
|
239
|
-
if (!('upload' in record(entry)))
|
|
240
|
-
return 'absent';
|
|
241
|
-
const upload = record(record(entry).upload);
|
|
220
|
+
function uploadGrant(answer) {
|
|
221
|
+
const upload = record(record(answer).upload);
|
|
242
222
|
if (upload.method !== 'POST')
|
|
243
223
|
return null;
|
|
244
224
|
if (typeof upload.operation !== 'string' || typeof upload.url !== 'string')
|
|
245
225
|
return null;
|
|
246
|
-
return {
|
|
226
|
+
return { operation: upload.operation, url: upload.url };
|
|
247
227
|
}
|
|
248
|
-
async function
|
|
249
|
-
const
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
const files = Array.isArray(record(input).files) ? record(input).files : [];
|
|
253
|
-
for (const [index, entry] of sent.entries()) {
|
|
254
|
-
const grant = uploadGrant(entry);
|
|
255
|
-
if (grant === 'absent')
|
|
256
|
-
continue;
|
|
257
|
-
if (grant === null)
|
|
258
|
-
return malformed();
|
|
259
|
-
const bytes = index < files.length ? await fileBytes(files[index]) : null;
|
|
260
|
-
if (bytes === null) {
|
|
261
|
-
return {
|
|
262
|
-
kind: 'rejected',
|
|
263
|
-
code: 'conversation_file_descriptor_required',
|
|
264
|
-
fields: {},
|
|
265
|
-
retryable: false,
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
const failed = delivered(await transport.transfer({
|
|
269
|
-
act: 'conversation_file_upload',
|
|
270
|
-
url: grant.url,
|
|
271
|
-
body: bytes,
|
|
272
|
-
operation: grant.operation,
|
|
273
|
-
}), name);
|
|
274
|
-
if (failed !== null)
|
|
275
|
-
return failed;
|
|
276
|
-
}
|
|
277
|
-
return null;
|
|
278
|
-
}
|
|
279
|
-
async function sendAction(transport, route, input, name) {
|
|
280
|
-
const body = sendBody(input);
|
|
281
|
-
if (body === null)
|
|
228
|
+
async function attachAction(transport, route, input, name) {
|
|
229
|
+
const body = attachBody(input);
|
|
230
|
+
const blob = record(input).blob;
|
|
231
|
+
if (body === null || !(blob instanceof Blob))
|
|
282
232
|
return malformed();
|
|
283
233
|
const outcome = actionOutcome(await transport.door(route, body), name);
|
|
284
234
|
if (outcome.kind !== 'action')
|
|
285
235
|
return outcome;
|
|
286
|
-
const
|
|
287
|
-
if (
|
|
288
|
-
return
|
|
289
|
-
|
|
236
|
+
const grant = uploadGrant(outcome.result);
|
|
237
|
+
if (grant === null)
|
|
238
|
+
return { kind: 'transport-uncertainty' };
|
|
239
|
+
const sent = await transport.transfer({
|
|
240
|
+
act: 'file_upload',
|
|
241
|
+
url: grant.url,
|
|
242
|
+
body: new Uint8Array(await blob.arrayBuffer()),
|
|
243
|
+
operation: grant.operation,
|
|
244
|
+
});
|
|
245
|
+
if (sent.status !== 200) {
|
|
246
|
+
const refusal = doorRefusal(sent.body);
|
|
247
|
+
return refusal === null ? { kind: 'transport-uncertainty' } : { kind: 'rejected', ...refusal };
|
|
248
|
+
}
|
|
249
|
+
const path = text(sent.body, 'path');
|
|
250
|
+
if (path === undefined)
|
|
251
|
+
return { kind: 'transport-uncertainty' };
|
|
252
|
+
const result = { path };
|
|
253
|
+
return { kind: 'action', result };
|
|
290
254
|
}
|
|
291
255
|
function historyCursor(value) {
|
|
292
256
|
const acceptedAt = text(value, 'accepted_at');
|
|
@@ -310,19 +274,12 @@ export function acceptedMessage(entry) {
|
|
|
310
274
|
const cursor = historyCursor(entry);
|
|
311
275
|
if (cursor === null)
|
|
312
276
|
return null;
|
|
313
|
-
const message = structuredClone(record(entry));
|
|
314
|
-
const referrer = { message: cursor.message_id };
|
|
315
277
|
return {
|
|
316
278
|
identity: cursor.message_id,
|
|
317
279
|
turn: text(entry, 'turn_id') ?? cursor.message_id,
|
|
318
280
|
position: position(cursor),
|
|
319
281
|
text: text(entry, 'text') ?? '',
|
|
320
|
-
message:
|
|
321
|
-
? {
|
|
322
|
-
...message,
|
|
323
|
-
files: message.files.map((file) => ({ ...record(file), referrer })),
|
|
324
|
-
}
|
|
325
|
-
: message,
|
|
282
|
+
message: structuredClone(record(entry)),
|
|
326
283
|
};
|
|
327
284
|
}
|
|
328
285
|
function historyPage(entry) {
|
|
@@ -359,6 +316,22 @@ function historyAsks(input) {
|
|
|
359
316
|
}
|
|
360
317
|
return asks;
|
|
361
318
|
}
|
|
319
|
+
async function triggersAction(transport, route, input, name) {
|
|
320
|
+
const asked = record(input).room_refs;
|
|
321
|
+
if (!Array.isArray(asked) || asked.length === 0)
|
|
322
|
+
return malformed();
|
|
323
|
+
const rooms = [];
|
|
324
|
+
for (let at = 0; at < asked.length; at += TRIGGER_ROOMS) {
|
|
325
|
+
const outcome = actionOutcome(await transport.door(route, { room_refs: asked.slice(at, at + TRIGGER_ROOMS) }), name);
|
|
326
|
+
if (outcome.kind !== 'action')
|
|
327
|
+
return outcome;
|
|
328
|
+
const answered = record(outcome.result).rooms;
|
|
329
|
+
if (!Array.isArray(answered))
|
|
330
|
+
return { kind: 'transport-uncertainty' };
|
|
331
|
+
rooms.push(...answered);
|
|
332
|
+
}
|
|
333
|
+
return { kind: 'action', result: { rooms } };
|
|
334
|
+
}
|
|
362
335
|
async function historyAction(transport, route, input, name) {
|
|
363
336
|
const asks = historyAsks(input);
|
|
364
337
|
if (asks === null)
|
package/dist/adapter.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export type AgentsHouseAdapterOptions = {
|
|
|
5
5
|
authorize(): Promise<Authorization>;
|
|
6
6
|
} | {
|
|
7
7
|
site: HouseSiteTransport;
|
|
8
|
+
snapshot?: boolean;
|
|
8
9
|
};
|
|
9
10
|
export declare function createAgentsHouseAdapter(options: AgentsHouseAdapterOptions): Adapter;
|
|
10
11
|
//# sourceMappingURL=adapter.d.ts.map
|
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,
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,OAAO,EACP,aAAa,EAkBd,MAAM,wBAAwB,CAAC;AA+ChC,OAAO,EASL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AA2BxB,MAAM,MAAM,yBAAyB,GACjC;IACE,SAAS,EAAE,cAAc,CAAC;IAC1B,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;CACrC,GACD;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAyFrD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CA+nBpF"}
|