@agentshouse/mdruntime-adapter 0.1.0-cfded86738bb2 → 0.1.0-cfe552b74bdf7
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 +3 -56
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +1 -287
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +158 -326
- 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/discovery.d.ts +12 -12
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +44 -51
- package/dist/history.d.ts +12 -0
- package/dist/history.d.ts.map +1 -0
- package/dist/history.js +91 -0
- package/dist/house-model.d.ts +892 -0
- package/dist/house-model.d.ts.map +1 -0
- package/dist/house-model.js +482 -0
- package/dist/index.d.ts +9 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -2
- package/dist/model.d.ts +5 -2
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +10 -29
- package/dist/part.d.ts +11 -12
- package/dist/part.d.ts.map +1 -1
- package/dist/part.js +63 -55
- package/dist/read.d.ts +19 -57
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +84 -220
- package/dist/refusal.d.ts +0 -3
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +0 -5
- 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 +62 -3
- package/dist/search.d.ts +5 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +47 -0
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +75 -157
- package/dist/stream.d.ts +13 -14
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +168 -426
- package/dist/transport.d.ts +48 -36
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +55 -11
- package/dist/upload.d.ts.map +1 -1
- package/dist/upload.js +26 -15
- package/dist/write.d.ts +6 -1
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +17 -19
- package/package.json +8 -4
- package/AGENTS.md +0 -317
- package/dist/gather.d.ts +0 -4
- package/dist/gather.d.ts.map +0 -1
- package/dist/gather.js +0 -35
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,60 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { ActionDeclaration, ActionRequest, ActionResult } from '@agentshouse/mdruntime';
|
|
2
2
|
import type { HouseDoorAnswer, HouseTransport } from './transport.js';
|
|
3
|
-
type
|
|
4
|
-
readonly operation_id?: string;
|
|
5
|
-
};
|
|
6
|
-
type ConversationControl = Operated & {
|
|
7
|
-
readonly conversation: string;
|
|
8
|
-
};
|
|
9
|
-
export type AppInputs = {
|
|
10
|
-
readonly 'conversation.attach': FileDeclaration & {
|
|
11
|
-
readonly room: string;
|
|
12
|
-
readonly blob: Blob;
|
|
13
|
-
};
|
|
14
|
-
readonly 'conversation.answer': ConversationControl & {
|
|
15
|
-
readonly answer: {
|
|
16
|
-
readonly interaction_id: string;
|
|
17
|
-
readonly response: unknown;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
readonly 'conversation.create': Operated & {
|
|
21
|
-
readonly agent_id: string;
|
|
22
|
-
readonly replaces?: string;
|
|
23
|
-
};
|
|
24
|
-
readonly 'conversation.delete': ConversationControl;
|
|
25
|
-
readonly 'conversation.history': ConversationHistoryRequest;
|
|
26
|
-
readonly 'conversation.interrupt': ConversationControl;
|
|
27
|
-
readonly 'conversation.kill': ConversationControl;
|
|
28
|
-
readonly 'conversation.send': ConversationControl & {
|
|
29
|
-
readonly operation_id: string;
|
|
30
|
-
readonly text: string;
|
|
31
|
-
};
|
|
32
|
-
readonly 'trigger.list': {
|
|
33
|
-
readonly room_refs: readonly string[];
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
export type AppAnswers = {
|
|
37
|
-
readonly 'conversation.attach': {
|
|
38
|
-
readonly path: string;
|
|
39
|
-
};
|
|
40
|
-
readonly 'conversation.history': ConversationHistories;
|
|
41
|
-
};
|
|
42
|
-
export type AppAnswerAdditions = {
|
|
43
|
-
readonly 'conversation.create': {
|
|
44
|
-
readonly conversation: string;
|
|
45
|
-
};
|
|
46
|
-
readonly 'conversation.send': {
|
|
47
|
-
readonly turn: string;
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
export declare const HOUSE_APP_ACTS: Readonly<Record<string, string>>;
|
|
51
|
-
export declare const SITE_SUBMIT = "submit";
|
|
52
|
-
export declare const HOUSE_SITE_ACTS: Readonly<Record<string, string>>;
|
|
53
|
-
export declare const HOUSE_APP_BATCHES: Readonly<Partial<Record<string, readonly string[]>>>;
|
|
54
|
-
export declare function houseConversationAgents(locator: string): ConversationAgents;
|
|
3
|
+
export type HouseActDoor = Pick<HouseTransport, 'door'>;
|
|
55
4
|
export declare function declaredActions(routes: readonly string[]): readonly ActionDeclaration[];
|
|
56
|
-
export declare function houseAction(transport:
|
|
5
|
+
export declare function houseAction(transport: HouseActDoor, request: ActionRequest): Promise<ActionResult>;
|
|
57
6
|
export declare function actionOutcome(answer: HouseDoorAnswer, name: string): ActionResult;
|
|
58
|
-
export declare function acceptedMessage(entry: unknown): AcceptedMessage | null;
|
|
59
|
-
export {};
|
|
60
7
|
//# 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":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE7F,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEtE,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AAExD,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,iBAAiB,EAAE,CAEvF;AAED,wBAAgB,WAAW,CACzB,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,YAAY,CAAC,CAIvB;AAoBD,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,CAQjF"}
|
package/dist/actions.js
CHANGED
|
@@ -1,81 +1,8 @@
|
|
|
1
|
-
import { changeBatchIdentity, HISTORY_CONVERSATIONS, } from '@agentshouse/mdruntime';
|
|
2
1
|
import { doorRefusal } from './refusal.js';
|
|
3
|
-
import { finishedUpload, houseUpload } from './upload.js';
|
|
4
|
-
const HISTORY_PAGE = 100;
|
|
5
|
-
const TRIGGER_ROOMS = 100;
|
|
6
|
-
const OCTET_STREAM = 'application/octet-stream';
|
|
7
|
-
function mapped(door, input = (given) => given) {
|
|
8
|
-
return {
|
|
9
|
-
door,
|
|
10
|
-
async carry(transport, given, name) {
|
|
11
|
-
return actionOutcome(await transport.door(`/door/${door}`, input(given)), name);
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
function carried(door, carry, batched, room) {
|
|
16
|
-
return {
|
|
17
|
-
door,
|
|
18
|
-
...(batched === undefined ? {} : { batched }),
|
|
19
|
-
...(room === undefined ? {} : { room }),
|
|
20
|
-
carry: (transport, input, name) => carry(transport, `/door/${door}`, input, name),
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
const APP_ACTS = {
|
|
24
|
-
'access.read': mapped('rooms/access/read'),
|
|
25
|
-
'conversation.answer': mapped('conversations/interaction/answer', answerBody),
|
|
26
|
-
'conversation.attach': carried('conversations/attach', attachAction, undefined, 'room'),
|
|
27
|
-
'conversation.create': carried('conversations/create', createAction),
|
|
28
|
-
'conversation.delete': mapped('conversations/delete', controlBody),
|
|
29
|
-
'conversation.history': carried('conversations/history', historyAction, ['conversations']),
|
|
30
|
-
'conversation.interrupt': mapped('conversations/interrupt', controlBody),
|
|
31
|
-
'conversation.kill': mapped('conversations/kill', controlBody),
|
|
32
|
-
'conversation.markDone': mapped('conversations/done'),
|
|
33
|
-
'conversation.rename': mapped('conversations/rename'),
|
|
34
|
-
'conversation.retry': mapped('conversations/retry'),
|
|
35
|
-
'conversation.send': carried('conversations/send', sendAction),
|
|
36
|
-
'conversation.setOption': mapped('conversations/option'),
|
|
37
|
-
'feature.list': mapped('apps/features/read'),
|
|
38
|
-
'holder.list': mapped('apps/holders'),
|
|
39
|
-
'holder.ring': mapped('apps/ring'),
|
|
40
|
-
'inboxChat.assign': mapped('chats/assign'),
|
|
41
|
-
'inboxChat.return': mapped('chats/return'),
|
|
42
|
-
'inboxChat.takeControl': mapped('chats/take-control'),
|
|
43
|
-
'member.list': mapped('rooms/members'),
|
|
44
|
-
'message.send': mapped('apps/messages/send'),
|
|
45
|
-
'processing.read': mapped('rooms/settings/processing/read'),
|
|
46
|
-
'record.list': mapped('records/read'),
|
|
47
|
-
'relay.read': mapped('apps/relay'),
|
|
48
|
-
'routine.list': mapped('routines/access'),
|
|
49
|
-
'routineAccess.list': mapped('routines/granted'),
|
|
50
|
-
'routineAllowance.list': mapped('routines/allowance'),
|
|
51
|
-
'routineRequest.list': mapped('routines/requests'),
|
|
52
|
-
'storage.read': mapped('storage/inventory'),
|
|
53
|
-
'trigger.list': carried('triggers/read', triggersAction, ['room_refs'], 'room_refs'),
|
|
54
|
-
'triggerOccurrence.list': mapped('triggers/fired'),
|
|
55
|
-
};
|
|
56
|
-
export const HOUSE_APP_ACTS = Object.fromEntries(Object.entries(APP_ACTS).map(([name, act]) => [name, act.door]));
|
|
57
|
-
export const SITE_SUBMIT = 'submit';
|
|
58
|
-
export const HOUSE_SITE_ACTS = {
|
|
59
|
-
[SITE_SUBMIT]: 'site/submission',
|
|
60
|
-
};
|
|
61
|
-
export const HOUSE_APP_BATCHES = Object.fromEntries(Object.entries(APP_ACTS).flatMap(([name, act]) => act.batched === undefined ? [] : [[name, act.batched]]));
|
|
62
|
-
const APP_NAMES = new Map(Object.entries(APP_ACTS).map(([name, act]) => [act.door, name]));
|
|
63
|
-
const APP_ROOMS = new Map(Object.entries(APP_ACTS).flatMap(([name, act]) => act.room === undefined ? [] : [[name, act.room]]));
|
|
64
|
-
export function houseConversationAgents(locator) {
|
|
65
|
-
return { locator, type: 'house-agent', identity: 'agent', name: 'name', retired: 'retired' };
|
|
66
|
-
}
|
|
67
2
|
export function declaredActions(routes) {
|
|
68
|
-
return routes.map((
|
|
69
|
-
const name = APP_NAMES.get(route) ?? route;
|
|
70
|
-
return { name, inputShape: {}, resultKind: 'house', room: APP_ROOMS.get(name) ?? 'room_ref' };
|
|
71
|
-
});
|
|
3
|
+
return routes.map((name) => ({ name, inputShape: {}, resultKind: 'house', room: 'room_ref' }));
|
|
72
4
|
}
|
|
73
5
|
export function houseAction(transport, request) {
|
|
74
|
-
if (Object.hasOwn(APP_ACTS, request.name)) {
|
|
75
|
-
return APP_ACTS[request.name].carry(transport, request.input, request.name);
|
|
76
|
-
}
|
|
77
|
-
if (APP_NAMES.has(request.name))
|
|
78
|
-
return Promise.resolve(unimplemented(request.name));
|
|
79
6
|
const route = routeOf(request.name);
|
|
80
7
|
if (route === null)
|
|
81
8
|
return Promise.resolve(malformed());
|
|
@@ -92,62 +19,12 @@ function routeOf(name) {
|
|
|
92
19
|
return null;
|
|
93
20
|
}
|
|
94
21
|
}
|
|
95
|
-
function record(value) {
|
|
96
|
-
return typeof value === 'object' && value !== null ? value : {};
|
|
97
|
-
}
|
|
98
|
-
function text(value, name) {
|
|
99
|
-
const held = record(value)[name];
|
|
100
|
-
return typeof held === 'string' ? held : undefined;
|
|
101
|
-
}
|
|
102
|
-
function operationId(input) {
|
|
103
|
-
return text(input, 'operation_id') ?? changeBatchIdentity();
|
|
104
|
-
}
|
|
105
22
|
function malformed() {
|
|
106
23
|
return { kind: 'rejected', code: 'invalid_request', fields: {}, retryable: false };
|
|
107
24
|
}
|
|
108
25
|
function unimplemented(name) {
|
|
109
26
|
return { kind: 'rejected', code: 'action-unimplemented', fields: { name }, retryable: false };
|
|
110
27
|
}
|
|
111
|
-
function createBody(input) {
|
|
112
|
-
const replaces = text(input, 'replaces');
|
|
113
|
-
return {
|
|
114
|
-
agent_id: text(input, 'agent_id'),
|
|
115
|
-
operation_id: operationId(input),
|
|
116
|
-
...(replaces === undefined ? {} : { replaces }),
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
function controlBody(input) {
|
|
120
|
-
return { conversation_id: text(input, 'conversation'), operation_id: operationId(input) };
|
|
121
|
-
}
|
|
122
|
-
function answerBody(input) {
|
|
123
|
-
const nested = record(record(input).answer);
|
|
124
|
-
return {
|
|
125
|
-
conversation_id: text(input, 'conversation'),
|
|
126
|
-
operation_id: operationId(input),
|
|
127
|
-
interaction_id: text(nested, 'interaction_id'),
|
|
128
|
-
response: nested.response,
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
async function createAction(transport, route, input, name) {
|
|
132
|
-
const outcome = actionOutcome(await transport.door(route, createBody(input)), name);
|
|
133
|
-
if (outcome.kind !== 'action')
|
|
134
|
-
return outcome;
|
|
135
|
-
const held = record(outcome.result);
|
|
136
|
-
const conversation = text(held, 'conversation_id');
|
|
137
|
-
return conversation === undefined
|
|
138
|
-
? outcome
|
|
139
|
-
: {
|
|
140
|
-
...outcome,
|
|
141
|
-
result: { ...held, conversation },
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
function withTurn(body) {
|
|
145
|
-
const held = record(body);
|
|
146
|
-
const turn = text(held, 'message_id');
|
|
147
|
-
return turn === undefined
|
|
148
|
-
? body
|
|
149
|
-
: { ...held, turn };
|
|
150
|
-
}
|
|
151
28
|
export function actionOutcome(answer, name) {
|
|
152
29
|
if (answer.status === 401)
|
|
153
30
|
return { kind: 'revoked-authorization' };
|
|
@@ -165,166 +42,3 @@ export function actionOutcome(answer, name) {
|
|
|
165
42
|
async function carry(transport, route, name, input) {
|
|
166
43
|
return actionOutcome(await transport.door(route, input), name);
|
|
167
44
|
}
|
|
168
|
-
function sendBody(input) {
|
|
169
|
-
const operation = text(input, 'operation_id');
|
|
170
|
-
const said = text(input, 'text');
|
|
171
|
-
if (operation === undefined || said === undefined)
|
|
172
|
-
return null;
|
|
173
|
-
return { conversation_id: text(input, 'conversation'), operation_id: operation, text: said };
|
|
174
|
-
}
|
|
175
|
-
async function sendAction(transport, route, input, name) {
|
|
176
|
-
const body = sendBody(input);
|
|
177
|
-
if (body === null)
|
|
178
|
-
return malformed();
|
|
179
|
-
const outcome = actionOutcome(await transport.door(route, body), name);
|
|
180
|
-
if (outcome.kind !== 'action')
|
|
181
|
-
return outcome;
|
|
182
|
-
return { ...outcome, result: withTurn(outcome.result) };
|
|
183
|
-
}
|
|
184
|
-
function attachBody(input) {
|
|
185
|
-
const room = text(input, 'room');
|
|
186
|
-
const name = text(input, 'name');
|
|
187
|
-
const sha256 = text(input, 'contentHash');
|
|
188
|
-
const bytes = record(input).byteLength;
|
|
189
|
-
if (room === undefined || name === undefined || sha256 === undefined)
|
|
190
|
-
return null;
|
|
191
|
-
if (typeof bytes !== 'number')
|
|
192
|
-
return null;
|
|
193
|
-
const mediaType = text(input, 'mediaType');
|
|
194
|
-
return {
|
|
195
|
-
room_ref: room,
|
|
196
|
-
name,
|
|
197
|
-
bytes,
|
|
198
|
-
sha256,
|
|
199
|
-
media_type: mediaType !== undefined && mediaType.length > 0 ? mediaType : OCTET_STREAM,
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
async function attachAction(transport, route, input, name) {
|
|
203
|
-
const body = attachBody(input);
|
|
204
|
-
const blob = record(input).blob;
|
|
205
|
-
if (body === null || !(blob instanceof Blob))
|
|
206
|
-
return malformed();
|
|
207
|
-
const outcome = actionOutcome(await transport.door(route, body), name);
|
|
208
|
-
if (outcome.kind !== 'action')
|
|
209
|
-
return outcome;
|
|
210
|
-
const upload = houseUpload(record(outcome.result).upload);
|
|
211
|
-
if (upload === null)
|
|
212
|
-
return { kind: 'transport-uncertainty' };
|
|
213
|
-
const finished = await finishedUpload(transport, upload, blob);
|
|
214
|
-
if (finished === null)
|
|
215
|
-
return { kind: 'transport-uncertainty' };
|
|
216
|
-
const settled = actionOutcome(finished, name);
|
|
217
|
-
if (settled.kind !== 'action')
|
|
218
|
-
return settled;
|
|
219
|
-
const path = text(settled.result, 'path');
|
|
220
|
-
if (path === undefined)
|
|
221
|
-
return { kind: 'transport-uncertainty' };
|
|
222
|
-
const result = { path };
|
|
223
|
-
return { kind: 'action', result };
|
|
224
|
-
}
|
|
225
|
-
function historyCursor(value) {
|
|
226
|
-
const acceptedAt = text(value, 'accepted_at');
|
|
227
|
-
const messageId = text(value, 'message_id');
|
|
228
|
-
if (acceptedAt === undefined || messageId === undefined)
|
|
229
|
-
return null;
|
|
230
|
-
return { accepted_at: acceptedAt, message_id: messageId };
|
|
231
|
-
}
|
|
232
|
-
function position(cursor) {
|
|
233
|
-
return JSON.stringify({ accepted_at: cursor.accepted_at, message_id: cursor.message_id });
|
|
234
|
-
}
|
|
235
|
-
function positionCursor(value) {
|
|
236
|
-
try {
|
|
237
|
-
return historyCursor(JSON.parse(value));
|
|
238
|
-
}
|
|
239
|
-
catch {
|
|
240
|
-
return null;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
export function acceptedMessage(entry) {
|
|
244
|
-
const cursor = historyCursor(entry);
|
|
245
|
-
if (cursor === null)
|
|
246
|
-
return null;
|
|
247
|
-
return {
|
|
248
|
-
identity: cursor.message_id,
|
|
249
|
-
turn: text(entry, 'turn_id') ?? cursor.message_id,
|
|
250
|
-
position: position(cursor),
|
|
251
|
-
text: text(entry, 'text') ?? '',
|
|
252
|
-
message: structuredClone(record(entry)),
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
function historyPage(entry) {
|
|
256
|
-
const held = record(entry);
|
|
257
|
-
const conversation = text(held, 'conversation_id');
|
|
258
|
-
if (conversation === undefined || !Array.isArray(held.messages))
|
|
259
|
-
return null;
|
|
260
|
-
const messages = [];
|
|
261
|
-
for (const one of held.messages) {
|
|
262
|
-
const message = acceptedMessage(one);
|
|
263
|
-
if (message === null)
|
|
264
|
-
return null;
|
|
265
|
-
messages.push(message);
|
|
266
|
-
}
|
|
267
|
-
const next = held.next === null || held.next === undefined ? undefined : historyCursor(held.next);
|
|
268
|
-
if (next === null)
|
|
269
|
-
return null;
|
|
270
|
-
return { conversation, messages, ...(next === undefined ? {} : { next: position(next) }) };
|
|
271
|
-
}
|
|
272
|
-
function historyAsks(input) {
|
|
273
|
-
const asked = record(input).conversations;
|
|
274
|
-
if (!Array.isArray(asked) || asked.length === 0)
|
|
275
|
-
return null;
|
|
276
|
-
const asks = [];
|
|
277
|
-
for (const entry of asked) {
|
|
278
|
-
const conversationId = text(entry, 'conversation');
|
|
279
|
-
if (conversationId === undefined)
|
|
280
|
-
return null;
|
|
281
|
-
const afterValue = text(entry, 'after');
|
|
282
|
-
const after = afterValue === undefined ? undefined : positionCursor(afterValue);
|
|
283
|
-
if (after === null)
|
|
284
|
-
return null;
|
|
285
|
-
asks.push({ conversation_id: conversationId, ...(after === undefined ? {} : { after }) });
|
|
286
|
-
}
|
|
287
|
-
return asks;
|
|
288
|
-
}
|
|
289
|
-
async function triggersAction(transport, route, input, name) {
|
|
290
|
-
const asked = record(input).room_refs;
|
|
291
|
-
if (!Array.isArray(asked) || asked.length === 0)
|
|
292
|
-
return malformed();
|
|
293
|
-
const rooms = [];
|
|
294
|
-
for (let at = 0; at < asked.length; at += TRIGGER_ROOMS) {
|
|
295
|
-
const outcome = actionOutcome(await transport.door(route, { room_refs: asked.slice(at, at + TRIGGER_ROOMS) }), name);
|
|
296
|
-
if (outcome.kind !== 'action')
|
|
297
|
-
return outcome;
|
|
298
|
-
const answered = record(outcome.result).rooms;
|
|
299
|
-
if (!Array.isArray(answered))
|
|
300
|
-
return { kind: 'transport-uncertainty' };
|
|
301
|
-
rooms.push(...answered);
|
|
302
|
-
}
|
|
303
|
-
return { kind: 'action', result: { rooms } };
|
|
304
|
-
}
|
|
305
|
-
async function historyAction(transport, route, input, name) {
|
|
306
|
-
const asks = historyAsks(input);
|
|
307
|
-
if (asks === null)
|
|
308
|
-
return malformed();
|
|
309
|
-
const histories = [];
|
|
310
|
-
for (let at = 0; at < asks.length; at += HISTORY_CONVERSATIONS) {
|
|
311
|
-
const answer = await transport.door(route, {
|
|
312
|
-
conversations: asks.slice(at, at + HISTORY_CONVERSATIONS),
|
|
313
|
-
limit: HISTORY_PAGE,
|
|
314
|
-
});
|
|
315
|
-
const outcome = actionOutcome(answer, name);
|
|
316
|
-
if (outcome.kind !== 'action')
|
|
317
|
-
return outcome;
|
|
318
|
-
const answered = record(outcome.result).histories;
|
|
319
|
-
if (!Array.isArray(answered))
|
|
320
|
-
return { kind: 'transport-uncertainty' };
|
|
321
|
-
for (const entry of answered) {
|
|
322
|
-
const page = historyPage(entry);
|
|
323
|
-
if (page === null)
|
|
324
|
-
return { kind: 'transport-uncertainty' };
|
|
325
|
-
histories.push(page);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
const result = { histories };
|
|
329
|
-
return { kind: 'action', result };
|
|
330
|
-
}
|
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,EAIP,aAAa,EAgBd,MAAM,wBAAwB,CAAC;AAgChC,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAmBxB,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;AA+DrD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CA4bpF"}
|