@agentshouse/mdruntime-adapter 0.1.0-c6eb3c1455065 → 0.1.0-c70bcc8f878b7
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/README.md +2 -2
- package/dist/actions.d.ts +10 -28
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +17 -111
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +134 -197
- package/dist/app-reference.d.ts +2 -0
- package/dist/app-reference.d.ts.map +1 -0
- package/dist/app-reference.js +2 -0
- package/dist/crockford.d.ts +4 -0
- package/dist/crockford.d.ts.map +1 -0
- package/dist/crockford.js +3 -0
- 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 -10
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +18 -32
- package/dist/gather.d.ts +0 -1
- package/dist/gather.d.ts.map +1 -1
- package/dist/gather.js +1 -1
- package/dist/house-model.d.ts +2 -0
- package/dist/house-model.d.ts.map +1 -0
- package/dist/house-model.js +490 -0
- package/dist/index.d.ts +8 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -2
- package/dist/model.d.ts +5 -1
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +11 -13
- package/dist/part.d.ts +12 -11
- package/dist/part.d.ts.map +1 -1
- package/dist/part.js +66 -56
- package/dist/read.d.ts +27 -13
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +174 -121
- package/dist/room-stream.d.ts +19 -0
- package/dist/room-stream.d.ts.map +1 -0
- package/dist/room-stream.js +57 -0
- package/dist/room-types.d.ts +2 -1
- package/dist/room-types.d.ts.map +1 -1
- package/dist/room-types.js +98 -3
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +42 -93
- package/dist/stream.d.ts +1 -0
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +24 -5
- package/dist/transport.d.ts +18 -8
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +2 -1
- package/dist/upload.d.ts +12 -0
- package/dist/upload.d.ts.map +1 -0
- package/dist/upload.js +63 -0
- package/dist/write.d.ts +4 -0
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +12 -15
- package/package.json +8 -4
- package/AGENTS.md +0 -304
- package/dist/handed.d.ts +0 -15
- package/dist/handed.d.ts.map +0 -1
- package/dist/handed.js +0 -45
- package/dist/referrer.d.ts +0 -7
- package/dist/referrer.d.ts.map +0 -1
- package/dist/referrer.js +0 -33
package/README.md
CHANGED
|
@@ -24,8 +24,8 @@ host.attach(port, 'my-app');
|
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
App code never imports this package; it reaches the Runtime only through the
|
|
27
|
-
client its host hands it. The rules an App's agent follows are
|
|
28
|
-
|
|
27
|
+
client its host hands it. The rules an App's agent follows are the `apps/` pages
|
|
28
|
+
of House's Guide, which House's `open_guide` opens.
|
|
29
29
|
|
|
30
30
|
## License
|
|
31
31
|
|
package/dist/actions.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { type AcceptedMessage, type ActionDeclaration, type ActionRequest, type ActionResult, type ConversationAgents, type ConversationHistories, type ConversationHistoryRequest
|
|
1
|
+
import { type AcceptedMessage, type ActionDeclaration, type ActionRequest, type ActionResult, type ConversationAgents, type ConversationHistories, type ConversationHistoryRequest } from '@agentshouse/mdruntime';
|
|
2
2
|
import type { HouseDoorAnswer, HouseTransport } from './transport.js';
|
|
3
|
+
export type HouseActDoor = Pick<HouseTransport, 'door'>;
|
|
4
|
+
export declare const HISTORY_PAGE = 100;
|
|
3
5
|
type Operated = {
|
|
4
6
|
readonly operation_id?: string;
|
|
5
7
|
};
|
|
@@ -7,10 +9,6 @@ type ConversationControl = Operated & {
|
|
|
7
9
|
readonly conversation: string;
|
|
8
10
|
};
|
|
9
11
|
export type AppInputs = {
|
|
10
|
-
readonly 'conversation.attach': FileDeclaration & {
|
|
11
|
-
readonly room: string;
|
|
12
|
-
readonly blob: Blob;
|
|
13
|
-
};
|
|
14
12
|
readonly 'conversation.answer': ConversationControl & {
|
|
15
13
|
readonly answer: {
|
|
16
14
|
readonly interaction_id: string;
|
|
@@ -19,6 +17,7 @@ export type AppInputs = {
|
|
|
19
17
|
};
|
|
20
18
|
readonly 'conversation.create': Operated & {
|
|
21
19
|
readonly agent_id: string;
|
|
20
|
+
readonly replaces?: string;
|
|
22
21
|
};
|
|
23
22
|
readonly 'conversation.delete': ConversationControl;
|
|
24
23
|
readonly 'conversation.history': ConversationHistoryRequest;
|
|
@@ -28,14 +27,8 @@ export type AppInputs = {
|
|
|
28
27
|
readonly operation_id: string;
|
|
29
28
|
readonly text: string;
|
|
30
29
|
};
|
|
31
|
-
readonly 'trigger.list': {
|
|
32
|
-
readonly room_refs: readonly string[];
|
|
33
|
-
};
|
|
34
30
|
};
|
|
35
31
|
export type AppAnswers = {
|
|
36
|
-
readonly 'conversation.attach': {
|
|
37
|
-
readonly path: string;
|
|
38
|
-
};
|
|
39
32
|
readonly 'conversation.history': ConversationHistories;
|
|
40
33
|
};
|
|
41
34
|
export type AppAnswerAdditions = {
|
|
@@ -45,22 +38,6 @@ export type AppAnswerAdditions = {
|
|
|
45
38
|
readonly 'conversation.send': {
|
|
46
39
|
readonly turn: string;
|
|
47
40
|
};
|
|
48
|
-
readonly 'record.list': {
|
|
49
|
-
readonly attachments: readonly {
|
|
50
|
-
readonly referrer: {
|
|
51
|
-
readonly room_ref: string;
|
|
52
|
-
readonly record: string;
|
|
53
|
-
};
|
|
54
|
-
}[];
|
|
55
|
-
readonly records: readonly {
|
|
56
|
-
readonly attachments: readonly {
|
|
57
|
-
readonly referrer: {
|
|
58
|
-
readonly room_ref: string;
|
|
59
|
-
readonly record: string;
|
|
60
|
-
};
|
|
61
|
-
}[];
|
|
62
|
-
}[];
|
|
63
|
-
};
|
|
64
41
|
};
|
|
65
42
|
export declare const HOUSE_APP_ACTS: Readonly<Record<string, string>>;
|
|
66
43
|
export declare const SITE_SUBMIT = "submit";
|
|
@@ -68,8 +45,13 @@ export declare const HOUSE_SITE_ACTS: Readonly<Record<string, string>>;
|
|
|
68
45
|
export declare const HOUSE_APP_BATCHES: Readonly<Partial<Record<string, readonly string[]>>>;
|
|
69
46
|
export declare function houseConversationAgents(locator: string): ConversationAgents;
|
|
70
47
|
export declare function declaredActions(routes: readonly string[]): readonly ActionDeclaration[];
|
|
71
|
-
export declare function houseAction(transport:
|
|
48
|
+
export declare function houseAction(transport: HouseActDoor, request: ActionRequest): Promise<ActionResult>;
|
|
72
49
|
export declare function actionOutcome(answer: HouseDoorAnswer, name: string): ActionResult;
|
|
50
|
+
type HistoryCursor = {
|
|
51
|
+
accepted_at: string;
|
|
52
|
+
message_id: string;
|
|
53
|
+
};
|
|
54
|
+
export declare function cursorPosition(cursor: HistoryCursor): string;
|
|
73
55
|
export declare function acceptedMessage(entry: unknown): AcceptedMessage | null;
|
|
74
56
|
export {};
|
|
75
57
|
//# 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,
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"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"}
|
package/dist/actions.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { changeBatchIdentity, } from '@agentshouse/mdruntime';
|
|
1
|
+
import { changeBatchIdentity, HISTORY_CONVERSATIONS, } from '@agentshouse/mdruntime';
|
|
2
2
|
import { doorRefusal } from './refusal.js';
|
|
3
|
-
const HISTORY_PAGE = 100;
|
|
4
|
-
const HISTORY_CONVERSATIONS = 64;
|
|
5
|
-
const TRIGGER_ROOMS = 100;
|
|
6
|
-
const OCTET_STREAM = 'application/octet-stream';
|
|
3
|
+
export const HISTORY_PAGE = 100;
|
|
7
4
|
function mapped(door, input = (given) => given) {
|
|
8
5
|
return {
|
|
9
6
|
door,
|
|
@@ -12,18 +9,16 @@ function mapped(door, input = (given) => given) {
|
|
|
12
9
|
},
|
|
13
10
|
};
|
|
14
11
|
}
|
|
15
|
-
function carried(door, carry, batched
|
|
12
|
+
function carried(door, carry, batched) {
|
|
16
13
|
return {
|
|
17
14
|
door,
|
|
18
15
|
...(batched === undefined ? {} : { batched }),
|
|
19
|
-
...(room === undefined ? {} : { room }),
|
|
20
16
|
carry: (transport, input, name) => carry(transport, `/door/${door}`, input, name),
|
|
21
17
|
};
|
|
22
18
|
}
|
|
23
19
|
const APP_ACTS = {
|
|
24
20
|
'access.read': mapped('rooms/access/read'),
|
|
25
21
|
'conversation.answer': mapped('conversations/interaction/answer', answerBody),
|
|
26
|
-
'conversation.attach': carried('conversations/attach', attachAction, undefined, 'room'),
|
|
27
22
|
'conversation.create': carried('conversations/create', createAction),
|
|
28
23
|
'conversation.delete': mapped('conversations/delete', controlBody),
|
|
29
24
|
'conversation.history': carried('conversations/history', historyAction, ['conversations']),
|
|
@@ -37,17 +32,19 @@ const APP_ACTS = {
|
|
|
37
32
|
'feature.list': mapped('apps/features/read'),
|
|
38
33
|
'holder.list': mapped('apps/holders'),
|
|
39
34
|
'holder.ring': mapped('apps/ring'),
|
|
35
|
+
'inboxChat.assign': mapped('chats/assign'),
|
|
36
|
+
'inboxChat.return': mapped('chats/return'),
|
|
37
|
+
'inboxChat.takeControl': mapped('chats/take-control'),
|
|
40
38
|
'member.list': mapped('rooms/members'),
|
|
41
39
|
'message.send': mapped('apps/messages/send'),
|
|
42
40
|
'processing.read': mapped('rooms/settings/processing/read'),
|
|
43
|
-
'record.list':
|
|
41
|
+
'record.list': mapped('records/read'),
|
|
44
42
|
'relay.read': mapped('apps/relay'),
|
|
45
43
|
'routine.list': mapped('routines/access'),
|
|
46
44
|
'routineAccess.list': mapped('routines/granted'),
|
|
47
45
|
'routineAllowance.list': mapped('routines/allowance'),
|
|
48
46
|
'routineRequest.list': mapped('routines/requests'),
|
|
49
47
|
'storage.read': mapped('storage/inventory'),
|
|
50
|
-
'trigger.list': carried('triggers/read', triggersAction, ['room_refs'], 'room_refs'),
|
|
51
48
|
'triggerOccurrence.list': mapped('triggers/fired'),
|
|
52
49
|
};
|
|
53
50
|
export const HOUSE_APP_ACTS = Object.fromEntries(Object.entries(APP_ACTS).map(([name, act]) => [name, act.door]));
|
|
@@ -57,14 +54,13 @@ export const HOUSE_SITE_ACTS = {
|
|
|
57
54
|
};
|
|
58
55
|
export const HOUSE_APP_BATCHES = Object.fromEntries(Object.entries(APP_ACTS).flatMap(([name, act]) => act.batched === undefined ? [] : [[name, act.batched]]));
|
|
59
56
|
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]]));
|
|
61
57
|
export function houseConversationAgents(locator) {
|
|
62
58
|
return { locator, type: 'house-agent', identity: 'agent', name: 'name', retired: 'retired' };
|
|
63
59
|
}
|
|
64
60
|
export function declaredActions(routes) {
|
|
65
61
|
return routes.map((route) => {
|
|
66
62
|
const name = APP_NAMES.get(route) ?? route;
|
|
67
|
-
return { name, inputShape: {}, resultKind: 'house', room:
|
|
63
|
+
return { name, inputShape: {}, resultKind: 'house', room: 'room_ref' };
|
|
68
64
|
});
|
|
69
65
|
}
|
|
70
66
|
export function houseAction(transport, request) {
|
|
@@ -106,7 +102,12 @@ function unimplemented(name) {
|
|
|
106
102
|
return { kind: 'rejected', code: 'action-unimplemented', fields: { name }, retryable: false };
|
|
107
103
|
}
|
|
108
104
|
function createBody(input) {
|
|
109
|
-
|
|
105
|
+
const replaces = text(input, 'replaces');
|
|
106
|
+
return {
|
|
107
|
+
agent_id: text(input, 'agent_id'),
|
|
108
|
+
operation_id: operationId(input),
|
|
109
|
+
...(replaces === undefined ? {} : { replaces }),
|
|
110
|
+
};
|
|
110
111
|
}
|
|
111
112
|
function controlBody(input) {
|
|
112
113
|
return { conversation_id: text(input, 'conversation'), operation_id: operationId(input) };
|
|
@@ -154,32 +155,6 @@ export function actionOutcome(answer, name) {
|
|
|
154
155
|
return { kind: 'transport-uncertainty' };
|
|
155
156
|
return { kind: 'action', result: answer.body };
|
|
156
157
|
}
|
|
157
|
-
function referredRecord(view, roomRef) {
|
|
158
|
-
const held = record(view);
|
|
159
|
-
if (roomRef === undefined || typeof held.record !== 'string' || !Array.isArray(held.attachments))
|
|
160
|
-
return view;
|
|
161
|
-
const referrer = {
|
|
162
|
-
room_ref: roomRef,
|
|
163
|
-
record: held.record,
|
|
164
|
-
};
|
|
165
|
-
return {
|
|
166
|
-
...held,
|
|
167
|
-
attachments: held.attachments.map((attachment) => ({ ...record(attachment), referrer })),
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
async function recordsAction(transport, route, input, name) {
|
|
171
|
-
const outcome = actionOutcome(await transport.door(route, input), name);
|
|
172
|
-
if (outcome.kind !== 'action')
|
|
173
|
-
return outcome;
|
|
174
|
-
const roomRef = text(input, 'room_ref');
|
|
175
|
-
const read = record(outcome.result);
|
|
176
|
-
return {
|
|
177
|
-
...outcome,
|
|
178
|
-
result: Array.isArray(read.records)
|
|
179
|
-
? { ...read, records: read.records.map((view) => referredRecord(view, roomRef)) }
|
|
180
|
-
: referredRecord(outcome.result, roomRef),
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
158
|
async function carry(transport, route, name, input) {
|
|
184
159
|
return actionOutcome(await transport.door(route, input), name);
|
|
185
160
|
}
|
|
@@ -199,59 +174,6 @@ async function sendAction(transport, route, input, name) {
|
|
|
199
174
|
return outcome;
|
|
200
175
|
return { ...outcome, result: withTurn(outcome.result) };
|
|
201
176
|
}
|
|
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)
|
|
208
|
-
return null;
|
|
209
|
-
if (typeof bytes !== 'number')
|
|
210
|
-
return null;
|
|
211
|
-
const mediaType = text(input, 'mediaType');
|
|
212
|
-
return {
|
|
213
|
-
room_ref: room,
|
|
214
|
-
name,
|
|
215
|
-
bytes,
|
|
216
|
-
sha256,
|
|
217
|
-
media_type: mediaType !== undefined && mediaType.length > 0 ? mediaType : OCTET_STREAM,
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
function uploadGrant(answer) {
|
|
221
|
-
const upload = record(record(answer).upload);
|
|
222
|
-
if (upload.method !== 'POST')
|
|
223
|
-
return null;
|
|
224
|
-
if (typeof upload.operation !== 'string' || typeof upload.url !== 'string')
|
|
225
|
-
return null;
|
|
226
|
-
return { operation: upload.operation, url: upload.url };
|
|
227
|
-
}
|
|
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))
|
|
232
|
-
return malformed();
|
|
233
|
-
const outcome = actionOutcome(await transport.door(route, body), name);
|
|
234
|
-
if (outcome.kind !== 'action')
|
|
235
|
-
return outcome;
|
|
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 };
|
|
254
|
-
}
|
|
255
177
|
function historyCursor(value) {
|
|
256
178
|
const acceptedAt = text(value, 'accepted_at');
|
|
257
179
|
const messageId = text(value, 'message_id');
|
|
@@ -259,7 +181,7 @@ function historyCursor(value) {
|
|
|
259
181
|
return null;
|
|
260
182
|
return { accepted_at: acceptedAt, message_id: messageId };
|
|
261
183
|
}
|
|
262
|
-
function
|
|
184
|
+
export function cursorPosition(cursor) {
|
|
263
185
|
return JSON.stringify({ accepted_at: cursor.accepted_at, message_id: cursor.message_id });
|
|
264
186
|
}
|
|
265
187
|
function positionCursor(value) {
|
|
@@ -277,7 +199,7 @@ export function acceptedMessage(entry) {
|
|
|
277
199
|
return {
|
|
278
200
|
identity: cursor.message_id,
|
|
279
201
|
turn: text(entry, 'turn_id') ?? cursor.message_id,
|
|
280
|
-
position:
|
|
202
|
+
position: cursorPosition(cursor),
|
|
281
203
|
text: text(entry, 'text') ?? '',
|
|
282
204
|
message: structuredClone(record(entry)),
|
|
283
205
|
};
|
|
@@ -297,7 +219,7 @@ function historyPage(entry) {
|
|
|
297
219
|
const next = held.next === null || held.next === undefined ? undefined : historyCursor(held.next);
|
|
298
220
|
if (next === null)
|
|
299
221
|
return null;
|
|
300
|
-
return { conversation, messages, ...(next === undefined ? {} : { next:
|
|
222
|
+
return { conversation, messages, ...(next === undefined ? {} : { next: cursorPosition(next) }) };
|
|
301
223
|
}
|
|
302
224
|
function historyAsks(input) {
|
|
303
225
|
const asked = record(input).conversations;
|
|
@@ -316,22 +238,6 @@ function historyAsks(input) {
|
|
|
316
238
|
}
|
|
317
239
|
return asks;
|
|
318
240
|
}
|
|
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
|
-
}
|
|
335
241
|
async function historyAction(transport, route, input, name) {
|
|
336
242
|
const asks = historyAsks(input);
|
|
337
243
|
if (asks === null)
|
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,EAIV,OAAO,
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,OAAO,EAGP,aAAa,EAkBd,MAAM,wBAAwB,CAAC;AAoChC,OAAO,EAUL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AA0BxB,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;AAqErD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CA+jBpF"}
|