@agentshouse/mdruntime-adapter 0.1.0-cb89e0425af50 → 0.1.0-cbbc9b36e7fd4
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 +256 -226
- package/dist/actions.d.ts +61 -1
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +80 -86
- package/dist/adapter.d.ts +1 -0
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +229 -63
- package/dist/discovery.d.ts +1 -0
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +6 -2
- package/dist/handed.d.ts +15 -0
- package/dist/handed.d.ts.map +1 -0
- package/dist/handed.js +38 -0
- 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 +0 -1
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +0 -3
- package/dist/read.d.ts +26 -7
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +136 -78
- package/dist/referrer.d.ts +7 -0
- package/dist/referrer.d.ts.map +1 -0
- package/dist/referrer.js +35 -0
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +2 -1
- package/dist/site.d.ts +1 -1
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +157 -47
- package/dist/stream.d.ts +5 -4
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +300 -14
- package/dist/transport.d.ts +48 -10
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +3 -0
- 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 +2 -9
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +59 -10
- package/package.json +2 -3
- package/dist/links.d.ts +0 -20
- package/dist/links.d.ts.map +0 -1
- package/dist/links.js +0 -104
package/dist/actions.d.ts
CHANGED
|
@@ -1,9 +1,69 @@
|
|
|
1
|
-
import { type AcceptedMessage, type ActionDeclaration, type ActionRequest, type ActionResult, type ConversationAgents } from '@agentshouse/mdruntime';
|
|
1
|
+
import { type AcceptedMessage, type ActionDeclaration, type ActionRequest, type ActionResult, type ConversationAgents, type ConversationHistories, type ConversationHistoryRequest, type FileDeclaration } from '@agentshouse/mdruntime';
|
|
2
2
|
import type { HouseDoorAnswer, HouseTransport } from './transport.js';
|
|
3
|
+
type Operated = {
|
|
4
|
+
readonly operation_id?: string;
|
|
5
|
+
};
|
|
6
|
+
type ConversationControl = Operated & {
|
|
7
|
+
readonly conversation: string;
|
|
8
|
+
};
|
|
9
|
+
type SentFile = FileDeclaration & {
|
|
10
|
+
readonly blob: Blob;
|
|
11
|
+
};
|
|
12
|
+
export type AppInputs = {
|
|
13
|
+
readonly 'conversation.answer': ConversationControl & {
|
|
14
|
+
readonly answer: {
|
|
15
|
+
readonly interaction_id: string;
|
|
16
|
+
readonly response: unknown;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
readonly 'conversation.create': Operated & {
|
|
20
|
+
readonly agent_id: string;
|
|
21
|
+
};
|
|
22
|
+
readonly 'conversation.delete': ConversationControl;
|
|
23
|
+
readonly 'conversation.history': ConversationHistoryRequest;
|
|
24
|
+
readonly 'conversation.interrupt': ConversationControl;
|
|
25
|
+
readonly 'conversation.kill': ConversationControl;
|
|
26
|
+
readonly 'conversation.send': ConversationControl & {
|
|
27
|
+
readonly operation_id: string;
|
|
28
|
+
readonly text?: string;
|
|
29
|
+
readonly files?: readonly SentFile[];
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export type AppAnswers = {
|
|
33
|
+
readonly 'conversation.history': ConversationHistories;
|
|
34
|
+
};
|
|
35
|
+
export type AppAnswerAdditions = {
|
|
36
|
+
readonly 'conversation.create': {
|
|
37
|
+
readonly conversation: string;
|
|
38
|
+
};
|
|
39
|
+
readonly 'conversation.send': {
|
|
40
|
+
readonly turn: string;
|
|
41
|
+
};
|
|
42
|
+
readonly 'record.list': {
|
|
43
|
+
readonly attachments: readonly {
|
|
44
|
+
readonly referrer: {
|
|
45
|
+
readonly room_ref: string;
|
|
46
|
+
readonly record: string;
|
|
47
|
+
};
|
|
48
|
+
}[];
|
|
49
|
+
readonly records: readonly {
|
|
50
|
+
readonly attachments: readonly {
|
|
51
|
+
readonly referrer: {
|
|
52
|
+
readonly room_ref: string;
|
|
53
|
+
readonly record: string;
|
|
54
|
+
};
|
|
55
|
+
}[];
|
|
56
|
+
}[];
|
|
57
|
+
};
|
|
58
|
+
};
|
|
3
59
|
export declare const HOUSE_APP_ACTS: Readonly<Record<string, string>>;
|
|
60
|
+
export declare const SITE_SUBMIT = "submit";
|
|
61
|
+
export declare const HOUSE_SITE_ACTS: Readonly<Record<string, string>>;
|
|
62
|
+
export declare const HOUSE_APP_BATCHES: Readonly<Partial<Record<string, readonly string[]>>>;
|
|
4
63
|
export declare function houseConversationAgents(locator: string): ConversationAgents;
|
|
5
64
|
export declare function declaredActions(routes: readonly string[]): readonly ActionDeclaration[];
|
|
6
65
|
export declare function houseAction(transport: HouseTransport, request: ActionRequest): Promise<ActionResult>;
|
|
7
66
|
export declare function actionOutcome(answer: HouseDoorAnswer, name: string): ActionResult;
|
|
8
67
|
export declare function acceptedMessage(entry: unknown): AcceptedMessage | null;
|
|
68
|
+
export {};
|
|
9
69
|
//# sourceMappingURL=actions.d.ts.map
|
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,
|
|
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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E,GAAG,SAAS,iBAAiB,EAAE,CAMvF;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,CAOjF;AAuKD,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAiBtE"}
|
package/dist/actions.js
CHANGED
|
@@ -11,20 +11,19 @@ function mapped(door, input = (given) => given) {
|
|
|
11
11
|
},
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
function carried(door, carry) {
|
|
14
|
+
function carried(door, carry, batched) {
|
|
15
15
|
return {
|
|
16
16
|
door,
|
|
17
|
+
...(batched === undefined ? {} : { batched }),
|
|
17
18
|
carry: (transport, input, name) => carry(transport, `/door/${door}`, input, name),
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
21
|
const APP_ACTS = {
|
|
21
22
|
'access.read': mapped('rooms/access/read'),
|
|
22
|
-
'attachment.read': carried('attachments/get', openAction),
|
|
23
|
-
'attachment.upload': carried('attachments/upload', attachAction),
|
|
24
23
|
'conversation.answer': mapped('conversations/interaction/answer', answerBody),
|
|
25
|
-
'conversation.create':
|
|
24
|
+
'conversation.create': carried('conversations/create', createAction),
|
|
26
25
|
'conversation.delete': mapped('conversations/delete', controlBody),
|
|
27
|
-
'conversation.history': carried('conversations/history', historyAction),
|
|
26
|
+
'conversation.history': carried('conversations/history', historyAction, ['conversations']),
|
|
28
27
|
'conversation.interrupt': mapped('conversations/interrupt', controlBody),
|
|
29
28
|
'conversation.kill': mapped('conversations/kill', controlBody),
|
|
30
29
|
'conversation.markDone': mapped('conversations/done'),
|
|
@@ -37,7 +36,7 @@ const APP_ACTS = {
|
|
|
37
36
|
'member.list': mapped('rooms/members'),
|
|
38
37
|
'message.send': mapped('apps/messages/send'),
|
|
39
38
|
'processing.read': mapped('rooms/settings/processing/read'),
|
|
40
|
-
'record.list':
|
|
39
|
+
'record.list': carried('records/read', recordsAction),
|
|
41
40
|
'relay.read': mapped('apps/relay'),
|
|
42
41
|
'routine.list': mapped('routines/access'),
|
|
43
42
|
'routineAccess.list': mapped('routines/granted'),
|
|
@@ -48,9 +47,14 @@ const APP_ACTS = {
|
|
|
48
47
|
'triggerOccurrence.list': mapped('triggers/fired'),
|
|
49
48
|
};
|
|
50
49
|
export const HOUSE_APP_ACTS = Object.fromEntries(Object.entries(APP_ACTS).map(([name, act]) => [name, act.door]));
|
|
50
|
+
export const SITE_SUBMIT = 'submit';
|
|
51
|
+
export const HOUSE_SITE_ACTS = {
|
|
52
|
+
[SITE_SUBMIT]: 'site/submission',
|
|
53
|
+
};
|
|
54
|
+
export const HOUSE_APP_BATCHES = Object.fromEntries(Object.entries(APP_ACTS).flatMap(([name, act]) => act.batched === undefined ? [] : [[name, act.batched]]));
|
|
51
55
|
const APP_NAMES = new Map(Object.entries(APP_ACTS).map(([name, act]) => [act.door, name]));
|
|
52
56
|
export function houseConversationAgents(locator) {
|
|
53
|
-
return { locator, type: 'house-agent', identity: 'agent', name: 'name' };
|
|
57
|
+
return { locator, type: 'house-agent', identity: 'agent', name: 'name', retired: 'retired' };
|
|
54
58
|
}
|
|
55
59
|
export function declaredActions(routes) {
|
|
56
60
|
return routes.map((route) => ({
|
|
@@ -112,10 +116,25 @@ function answerBody(input) {
|
|
|
112
116
|
response: nested.response,
|
|
113
117
|
};
|
|
114
118
|
}
|
|
119
|
+
async function createAction(transport, route, input, name) {
|
|
120
|
+
const outcome = actionOutcome(await transport.door(route, createBody(input)), name);
|
|
121
|
+
if (outcome.kind !== 'action')
|
|
122
|
+
return outcome;
|
|
123
|
+
const held = record(outcome.result);
|
|
124
|
+
const conversation = text(held, 'conversation_id');
|
|
125
|
+
return conversation === undefined
|
|
126
|
+
? outcome
|
|
127
|
+
: {
|
|
128
|
+
...outcome,
|
|
129
|
+
result: { ...held, conversation },
|
|
130
|
+
};
|
|
131
|
+
}
|
|
115
132
|
function withTurn(body) {
|
|
116
133
|
const held = record(body);
|
|
117
134
|
const turn = text(held, 'message_id');
|
|
118
|
-
return turn === undefined
|
|
135
|
+
return turn === undefined
|
|
136
|
+
? body
|
|
137
|
+
: { ...held, turn };
|
|
119
138
|
}
|
|
120
139
|
export function actionOutcome(answer, name) {
|
|
121
140
|
if (answer.status === 401)
|
|
@@ -129,6 +148,32 @@ export function actionOutcome(answer, name) {
|
|
|
129
148
|
return { kind: 'transport-uncertainty' };
|
|
130
149
|
return { kind: 'action', result: answer.body };
|
|
131
150
|
}
|
|
151
|
+
function referredRecord(view, roomRef) {
|
|
152
|
+
const held = record(view);
|
|
153
|
+
if (roomRef === undefined || typeof held.record !== 'string' || !Array.isArray(held.attachments))
|
|
154
|
+
return view;
|
|
155
|
+
const referrer = {
|
|
156
|
+
room_ref: roomRef,
|
|
157
|
+
record: held.record,
|
|
158
|
+
};
|
|
159
|
+
return {
|
|
160
|
+
...held,
|
|
161
|
+
attachments: held.attachments.map((attachment) => ({ ...record(attachment), referrer })),
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
async function recordsAction(transport, route, input, name) {
|
|
165
|
+
const outcome = actionOutcome(await transport.door(route, input), name);
|
|
166
|
+
if (outcome.kind !== 'action')
|
|
167
|
+
return outcome;
|
|
168
|
+
const roomRef = text(input, 'room_ref');
|
|
169
|
+
const read = record(outcome.result);
|
|
170
|
+
return {
|
|
171
|
+
...outcome,
|
|
172
|
+
result: Array.isArray(read.records)
|
|
173
|
+
? { ...read, records: read.records.map((view) => referredRecord(view, roomRef)) }
|
|
174
|
+
: referredRecord(outcome.result, roomRef),
|
|
175
|
+
};
|
|
176
|
+
}
|
|
132
177
|
async function carry(transport, route, name, input) {
|
|
133
178
|
return actionOutcome(await transport.door(route, input), name);
|
|
134
179
|
}
|
|
@@ -169,12 +214,13 @@ function sendFiles(input) {
|
|
|
169
214
|
}
|
|
170
215
|
function sendBody(input) {
|
|
171
216
|
const files = sendFiles(input);
|
|
172
|
-
|
|
217
|
+
const operation = text(input, 'operation_id');
|
|
218
|
+
if (files === null || operation === undefined)
|
|
173
219
|
return null;
|
|
174
220
|
const textValue = text(input, 'text');
|
|
175
221
|
return {
|
|
176
222
|
conversation_id: text(input, 'conversation'),
|
|
177
|
-
operation_id:
|
|
223
|
+
operation_id: operation,
|
|
178
224
|
...(textValue !== undefined && textValue.length > 0 ? { text: textValue } : {}),
|
|
179
225
|
...(files.length === 0 ? {} : { files }),
|
|
180
226
|
};
|
|
@@ -187,9 +233,6 @@ async function fileBytes(file) {
|
|
|
187
233
|
return null;
|
|
188
234
|
return new Uint8Array(await blob.arrayBuffer());
|
|
189
235
|
}
|
|
190
|
-
function delivered(answer, name) {
|
|
191
|
-
return answer.status === 200 ? null : actionOutcome(answer, name);
|
|
192
|
-
}
|
|
193
236
|
function uploadGrant(entry) {
|
|
194
237
|
if (!('upload' in record(entry)))
|
|
195
238
|
return 'absent';
|
|
@@ -200,84 +243,28 @@ function uploadGrant(entry) {
|
|
|
200
243
|
return null;
|
|
201
244
|
return { method: 'POST', operation: upload.operation, url: upload.url };
|
|
202
245
|
}
|
|
203
|
-
async function
|
|
204
|
-
const
|
|
205
|
-
if (!Array.isArray(
|
|
206
|
-
return
|
|
246
|
+
async function uploadFiles(transport, input, result) {
|
|
247
|
+
const sent = record(result).files;
|
|
248
|
+
if (!Array.isArray(sent))
|
|
249
|
+
return true;
|
|
207
250
|
const files = Array.isArray(record(input).files) ? record(input).files : [];
|
|
208
|
-
for (const [index, entry] of
|
|
251
|
+
for (const [index, entry] of sent.entries()) {
|
|
209
252
|
const grant = uploadGrant(entry);
|
|
210
253
|
if (grant === 'absent')
|
|
211
254
|
continue;
|
|
212
|
-
if (grant === null)
|
|
213
|
-
return malformed();
|
|
214
255
|
const bytes = index < files.length ? await fileBytes(files[index]) : null;
|
|
215
|
-
if (bytes === null)
|
|
216
|
-
return
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
fields: {},
|
|
220
|
-
retryable: false,
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
const failed = delivered(await transport.transfer({
|
|
224
|
-
act: 'conversation_original_upload',
|
|
225
|
-
method: 'POST',
|
|
256
|
+
if (grant === null || bytes === null)
|
|
257
|
+
return false;
|
|
258
|
+
const answer = await transport.transfer({
|
|
259
|
+
act: 'conversation_file_upload',
|
|
226
260
|
url: grant.url,
|
|
227
|
-
answer: 'json',
|
|
228
261
|
body: bytes,
|
|
229
262
|
operation: grant.operation,
|
|
230
|
-
})
|
|
231
|
-
if (
|
|
232
|
-
return
|
|
263
|
+
});
|
|
264
|
+
if (answer.status !== 200)
|
|
265
|
+
return false;
|
|
233
266
|
}
|
|
234
|
-
return
|
|
235
|
-
}
|
|
236
|
-
async function attachAction(transport, route, input, name) {
|
|
237
|
-
const { blob, ...descriptor } = record(input);
|
|
238
|
-
const bytes = await fileBytes({ blob });
|
|
239
|
-
if (bytes === null)
|
|
240
|
-
return malformed();
|
|
241
|
-
const outcome = actionOutcome(await transport.door(route, descriptor), name);
|
|
242
|
-
if (outcome.kind !== 'action')
|
|
243
|
-
return outcome;
|
|
244
|
-
const grant = uploadGrant(outcome.result);
|
|
245
|
-
if (grant === 'absent')
|
|
246
|
-
return outcome;
|
|
247
|
-
if (grant === null)
|
|
248
|
-
return malformed();
|
|
249
|
-
const stored = await transport.transfer({
|
|
250
|
-
act: 'original_upload',
|
|
251
|
-
method: 'POST',
|
|
252
|
-
url: grant.url,
|
|
253
|
-
answer: 'json',
|
|
254
|
-
body: bytes,
|
|
255
|
-
operation: grant.operation,
|
|
256
|
-
});
|
|
257
|
-
return delivered(stored, name) ?? { kind: 'action', result: stored.body };
|
|
258
|
-
}
|
|
259
|
-
async function openAction(transport, route, input, name) {
|
|
260
|
-
const outcome = actionOutcome(await transport.door(route, input), name);
|
|
261
|
-
if (outcome.kind !== 'action')
|
|
262
|
-
return outcome;
|
|
263
|
-
const { download, ...opened } = record(outcome.result);
|
|
264
|
-
if (download === undefined)
|
|
265
|
-
return outcome;
|
|
266
|
-
const grant = record(download);
|
|
267
|
-
if (grant.method !== 'GET' || typeof grant.url !== 'string')
|
|
268
|
-
return malformed();
|
|
269
|
-
const read = await transport.transfer({
|
|
270
|
-
act: 'original_download',
|
|
271
|
-
method: 'GET',
|
|
272
|
-
url: grant.url,
|
|
273
|
-
answer: 'bytes',
|
|
274
|
-
});
|
|
275
|
-
const failed = delivered(read, name);
|
|
276
|
-
if (failed !== null)
|
|
277
|
-
return failed;
|
|
278
|
-
if (!(read.body instanceof Blob))
|
|
279
|
-
return { kind: 'transport-uncertainty' };
|
|
280
|
-
return { kind: 'action', result: { ...opened, blob: read.body } };
|
|
267
|
+
return true;
|
|
281
268
|
}
|
|
282
269
|
async function sendAction(transport, route, input, name) {
|
|
283
270
|
const body = sendBody(input);
|
|
@@ -286,9 +273,9 @@ async function sendAction(transport, route, input, name) {
|
|
|
286
273
|
const outcome = actionOutcome(await transport.door(route, body), name);
|
|
287
274
|
if (outcome.kind !== 'action')
|
|
288
275
|
return outcome;
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
276
|
+
if (!(await uploadFiles(transport, input, outcome.result))) {
|
|
277
|
+
return { kind: 'transport-uncertainty' };
|
|
278
|
+
}
|
|
292
279
|
return { ...outcome, result: withTurn(outcome.result) };
|
|
293
280
|
}
|
|
294
281
|
function historyCursor(value) {
|
|
@@ -313,12 +300,19 @@ export function acceptedMessage(entry) {
|
|
|
313
300
|
const cursor = historyCursor(entry);
|
|
314
301
|
if (cursor === null)
|
|
315
302
|
return null;
|
|
303
|
+
const message = structuredClone(record(entry));
|
|
304
|
+
const referrer = { message: cursor.message_id };
|
|
316
305
|
return {
|
|
317
306
|
identity: cursor.message_id,
|
|
318
307
|
turn: text(entry, 'turn_id') ?? cursor.message_id,
|
|
319
308
|
position: position(cursor),
|
|
320
309
|
text: text(entry, 'text') ?? '',
|
|
321
|
-
message:
|
|
310
|
+
message: Array.isArray(message.files)
|
|
311
|
+
? {
|
|
312
|
+
...message,
|
|
313
|
+
files: message.files.map((file) => ({ ...record(file), referrer })),
|
|
314
|
+
}
|
|
315
|
+
: message,
|
|
322
316
|
};
|
|
323
317
|
}
|
|
324
318
|
function historyPage(entry) {
|
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,EAKV,OAAO,EACP,aAAa,EAiBd,MAAM,wBAAwB,CAAC;AA4ChC,OAAO,EASL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAyBxB,MAAM,MAAM,yBAAyB,GACjC;IACE,SAAS,EAAE,cAAc,CAAC;IAC1B,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;CACrC,GACD;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAsErD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CA0hBpF"}
|