@agentshouse/mdruntime-adapter 0.1.0-ce1149641691d → 0.1.0-ce3ced044cab5
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 +6 -26
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +18 -150
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +167 -223
- 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 +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 +486 -0
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- 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 +33 -17
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +187 -122
- 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 +7 -0
- package/dist/room-types.d.ts.map +1 -0
- package/dist/room-types.js +125 -0
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +43 -92
- package/dist/stream.d.ts +1 -0
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +17 -2
- package/dist/transport.d.ts +14 -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 +22 -18
- 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 -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,14 +1,13 @@
|
|
|
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
|
};
|
|
6
8
|
type ConversationControl = Operated & {
|
|
7
9
|
readonly conversation: string;
|
|
8
10
|
};
|
|
9
|
-
type SentFile = FileDeclaration & {
|
|
10
|
-
readonly blob: Blob;
|
|
11
|
-
};
|
|
12
11
|
export type AppInputs = {
|
|
13
12
|
readonly 'conversation.answer': ConversationControl & {
|
|
14
13
|
readonly answer: {
|
|
@@ -18,6 +17,7 @@ export type AppInputs = {
|
|
|
18
17
|
};
|
|
19
18
|
readonly 'conversation.create': Operated & {
|
|
20
19
|
readonly agent_id: string;
|
|
20
|
+
readonly replaces?: string;
|
|
21
21
|
};
|
|
22
22
|
readonly 'conversation.delete': ConversationControl;
|
|
23
23
|
readonly 'conversation.history': ConversationHistoryRequest;
|
|
@@ -25,11 +25,7 @@ export type AppInputs = {
|
|
|
25
25
|
readonly 'conversation.kill': ConversationControl;
|
|
26
26
|
readonly 'conversation.send': ConversationControl & {
|
|
27
27
|
readonly operation_id: string;
|
|
28
|
-
readonly text
|
|
29
|
-
readonly files?: readonly SentFile[];
|
|
30
|
-
};
|
|
31
|
-
readonly 'trigger.list': {
|
|
32
|
-
readonly room_refs: readonly string[];
|
|
28
|
+
readonly text: string;
|
|
33
29
|
};
|
|
34
30
|
};
|
|
35
31
|
export type AppAnswers = {
|
|
@@ -42,22 +38,6 @@ export type AppAnswerAdditions = {
|
|
|
42
38
|
readonly 'conversation.send': {
|
|
43
39
|
readonly turn: string;
|
|
44
40
|
};
|
|
45
|
-
readonly 'record.list': {
|
|
46
|
-
readonly attachments: readonly {
|
|
47
|
-
readonly referrer: {
|
|
48
|
-
readonly room_ref: string;
|
|
49
|
-
readonly record: string;
|
|
50
|
-
};
|
|
51
|
-
}[];
|
|
52
|
-
readonly records: readonly {
|
|
53
|
-
readonly attachments: readonly {
|
|
54
|
-
readonly referrer: {
|
|
55
|
-
readonly room_ref: string;
|
|
56
|
-
readonly record: string;
|
|
57
|
-
};
|
|
58
|
-
}[];
|
|
59
|
-
}[];
|
|
60
|
-
};
|
|
61
41
|
};
|
|
62
42
|
export declare const HOUSE_APP_ACTS: Readonly<Record<string, string>>;
|
|
63
43
|
export declare const SITE_SUBMIT = "submit";
|
|
@@ -65,7 +45,7 @@ export declare const HOUSE_SITE_ACTS: Readonly<Record<string, string>>;
|
|
|
65
45
|
export declare const HOUSE_APP_BATCHES: Readonly<Partial<Record<string, readonly string[]>>>;
|
|
66
46
|
export declare function houseConversationAgents(locator: string): ConversationAgents;
|
|
67
47
|
export declare function declaredActions(routes: readonly string[]): readonly ActionDeclaration[];
|
|
68
|
-
export declare function houseAction(transport:
|
|
48
|
+
export declare function houseAction(transport: HouseActDoor, request: ActionRequest): Promise<ActionResult>;
|
|
69
49
|
export declare function actionOutcome(answer: HouseDoorAnswer, name: string): ActionResult;
|
|
70
50
|
export declare function acceptedMessage(entry: unknown): AcceptedMessage | null;
|
|
71
51
|
export {};
|
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,EAGL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAE1B,KAAK,0BAA0B,EAChC,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEtE,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AAExD,eAAO,MAAM,YAAY,MAAM,CAAC;AAEhC,KAAK,QAAQ,GAAG;IAAE,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnD,KAAK,mBAAmB,GAAG,QAAQ,GAAG;IAAE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC;AAExE,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,qBAAqB,EAAE,mBAAmB,GAAG;QACpD,QAAQ,CAAC,MAAM,EAAE;YAAE,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;SAAE,CAAC;KAClF,CAAC;IACF,QAAQ,CAAC,qBAAqB,EAAE,QAAQ,GAAG;QACzC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;KAC5B,CAAC;IACF,QAAQ,CAAC,qBAAqB,EAAE,mBAAmB,CAAC;IACpD,QAAQ,CAAC,sBAAsB,EAAE,0BAA0B,CAAC;IAC5D,QAAQ,CAAC,wBAAwB,EAAE,mBAAmB,CAAC;IACvD,QAAQ,CAAC,mBAAmB,EAAE,mBAAmB,CAAC;IAClD,QAAQ,CAAC,mBAAmB,EAAE,mBAAmB,GAAG;QAClD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;QAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;KACvB,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,sBAAsB,EAAE,qBAAqB,CAAC;CACxD,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,qBAAqB,EAAE;QAAE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC;IAClE,QAAQ,CAAC,mBAAmB,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CACzD,CAAC;AA2EF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAE3D,CAAC;AAEF,eAAO,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;AAMJ,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,YAAY,EACvB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,YAAY,CAAC,CAQvB;AAkFD,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,CAQjF;AAoDD,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAUtE"}
|
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,11 +9,10 @@ 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
|
}
|
|
@@ -36,17 +32,19 @@ const APP_ACTS = {
|
|
|
36
32
|
'feature.list': mapped('apps/features/read'),
|
|
37
33
|
'holder.list': mapped('apps/holders'),
|
|
38
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'),
|
|
39
38
|
'member.list': mapped('rooms/members'),
|
|
40
39
|
'message.send': mapped('apps/messages/send'),
|
|
41
40
|
'processing.read': mapped('rooms/settings/processing/read'),
|
|
42
|
-
'record.list':
|
|
41
|
+
'record.list': mapped('records/read'),
|
|
43
42
|
'relay.read': mapped('apps/relay'),
|
|
44
43
|
'routine.list': mapped('routines/access'),
|
|
45
44
|
'routineAccess.list': mapped('routines/granted'),
|
|
46
45
|
'routineAllowance.list': mapped('routines/allowance'),
|
|
47
46
|
'routineRequest.list': mapped('routines/requests'),
|
|
48
47
|
'storage.read': mapped('storage/inventory'),
|
|
49
|
-
'trigger.list': carried('triggers/read', triggersAction, ['room_refs'], 'room_refs'),
|
|
50
48
|
'triggerOccurrence.list': mapped('triggers/fired'),
|
|
51
49
|
};
|
|
52
50
|
export const HOUSE_APP_ACTS = Object.fromEntries(Object.entries(APP_ACTS).map(([name, act]) => [name, act.door]));
|
|
@@ -56,14 +54,13 @@ export const HOUSE_SITE_ACTS = {
|
|
|
56
54
|
};
|
|
57
55
|
export const HOUSE_APP_BATCHES = Object.fromEntries(Object.entries(APP_ACTS).flatMap(([name, act]) => act.batched === undefined ? [] : [[name, act.batched]]));
|
|
58
56
|
const APP_NAMES = new Map(Object.entries(APP_ACTS).map(([name, act]) => [act.door, name]));
|
|
59
|
-
const APP_ROOMS = new Map(Object.entries(APP_ACTS).flatMap(([name, act]) => act.room === undefined ? [] : [[name, act.room]]));
|
|
60
57
|
export function houseConversationAgents(locator) {
|
|
61
58
|
return { locator, type: 'house-agent', identity: 'agent', name: 'name', retired: 'retired' };
|
|
62
59
|
}
|
|
63
60
|
export function declaredActions(routes) {
|
|
64
61
|
return routes.map((route) => {
|
|
65
62
|
const name = APP_NAMES.get(route) ?? route;
|
|
66
|
-
return { name, inputShape: {}, resultKind: 'house', room:
|
|
63
|
+
return { name, inputShape: {}, resultKind: 'house', room: 'room_ref' };
|
|
67
64
|
});
|
|
68
65
|
}
|
|
69
66
|
export function houseAction(transport, request) {
|
|
@@ -105,7 +102,12 @@ function unimplemented(name) {
|
|
|
105
102
|
return { kind: 'rejected', code: 'action-unimplemented', fields: { name }, retryable: false };
|
|
106
103
|
}
|
|
107
104
|
function createBody(input) {
|
|
108
|
-
|
|
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
|
+
};
|
|
109
111
|
}
|
|
110
112
|
function controlBody(input) {
|
|
111
113
|
return { conversation_id: text(input, 'conversation'), operation_id: operationId(input) };
|
|
@@ -153,123 +155,15 @@ export function actionOutcome(answer, name) {
|
|
|
153
155
|
return { kind: 'transport-uncertainty' };
|
|
154
156
|
return { kind: 'action', result: answer.body };
|
|
155
157
|
}
|
|
156
|
-
function referredRecord(view, roomRef) {
|
|
157
|
-
const held = record(view);
|
|
158
|
-
if (roomRef === undefined || typeof held.record !== 'string' || !Array.isArray(held.attachments))
|
|
159
|
-
return view;
|
|
160
|
-
const referrer = {
|
|
161
|
-
room_ref: roomRef,
|
|
162
|
-
record: held.record,
|
|
163
|
-
};
|
|
164
|
-
return {
|
|
165
|
-
...held,
|
|
166
|
-
attachments: held.attachments.map((attachment) => ({ ...record(attachment), referrer })),
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
async function recordsAction(transport, route, input, name) {
|
|
170
|
-
const outcome = actionOutcome(await transport.door(route, input), name);
|
|
171
|
-
if (outcome.kind !== 'action')
|
|
172
|
-
return outcome;
|
|
173
|
-
const roomRef = text(input, 'room_ref');
|
|
174
|
-
const read = record(outcome.result);
|
|
175
|
-
return {
|
|
176
|
-
...outcome,
|
|
177
|
-
result: Array.isArray(read.records)
|
|
178
|
-
? { ...read, records: read.records.map((view) => referredRecord(view, roomRef)) }
|
|
179
|
-
: referredRecord(outcome.result, roomRef),
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
158
|
async function carry(transport, route, name, input) {
|
|
183
159
|
return actionOutcome(await transport.door(route, input), name);
|
|
184
160
|
}
|
|
185
|
-
function sendFile(entry) {
|
|
186
|
-
const file = record(entry);
|
|
187
|
-
const name = text(file, 'name');
|
|
188
|
-
const bytes = file.byteLength;
|
|
189
|
-
const sha256 = text(file, 'contentHash');
|
|
190
|
-
if (name === undefined || typeof bytes !== 'number' || sha256 === undefined)
|
|
191
|
-
return null;
|
|
192
|
-
const mediaType = text(file, 'mediaType');
|
|
193
|
-
const width = file.width;
|
|
194
|
-
const height = file.height;
|
|
195
|
-
return {
|
|
196
|
-
name,
|
|
197
|
-
media_type: mediaType !== undefined && mediaType.length > 0 ? mediaType : OCTET_STREAM,
|
|
198
|
-
bytes,
|
|
199
|
-
sha256,
|
|
200
|
-
...(typeof width === 'number' && typeof height === 'number'
|
|
201
|
-
? { dimensions: { width, height } }
|
|
202
|
-
: {}),
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
function sendFiles(input) {
|
|
206
|
-
const files = record(input).files;
|
|
207
|
-
if (files === undefined)
|
|
208
|
-
return [];
|
|
209
|
-
if (!Array.isArray(files))
|
|
210
|
-
return null;
|
|
211
|
-
const declared = [];
|
|
212
|
-
for (const entry of files) {
|
|
213
|
-
const file = sendFile(entry);
|
|
214
|
-
if (file === null)
|
|
215
|
-
return null;
|
|
216
|
-
declared.push(file);
|
|
217
|
-
}
|
|
218
|
-
return declared;
|
|
219
|
-
}
|
|
220
161
|
function sendBody(input) {
|
|
221
|
-
const files = sendFiles(input);
|
|
222
162
|
const operation = text(input, 'operation_id');
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
const textValue = text(input, 'text');
|
|
226
|
-
return {
|
|
227
|
-
conversation_id: text(input, 'conversation'),
|
|
228
|
-
operation_id: operation,
|
|
229
|
-
...(textValue !== undefined && textValue.length > 0 ? { text: textValue } : {}),
|
|
230
|
-
...(files.length === 0 ? {} : { files }),
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
async function fileBytes(file) {
|
|
234
|
-
const blob = record(file).blob;
|
|
235
|
-
if (blob === undefined || typeof blob !== 'object' || blob === null)
|
|
236
|
-
return null;
|
|
237
|
-
if (!('arrayBuffer' in blob) || typeof blob.arrayBuffer !== 'function')
|
|
163
|
+
const said = text(input, 'text');
|
|
164
|
+
if (operation === undefined || said === undefined)
|
|
238
165
|
return null;
|
|
239
|
-
return
|
|
240
|
-
}
|
|
241
|
-
function uploadGrant(entry) {
|
|
242
|
-
if (!('upload' in record(entry)))
|
|
243
|
-
return 'absent';
|
|
244
|
-
const upload = record(record(entry).upload);
|
|
245
|
-
if (upload.method !== 'POST')
|
|
246
|
-
return null;
|
|
247
|
-
if (typeof upload.operation !== 'string' || typeof upload.url !== 'string')
|
|
248
|
-
return null;
|
|
249
|
-
return { method: 'POST', operation: upload.operation, url: upload.url };
|
|
250
|
-
}
|
|
251
|
-
async function uploadFiles(transport, input, result) {
|
|
252
|
-
const sent = record(result).files;
|
|
253
|
-
if (!Array.isArray(sent))
|
|
254
|
-
return true;
|
|
255
|
-
const files = Array.isArray(record(input).files) ? record(input).files : [];
|
|
256
|
-
for (const [index, entry] of sent.entries()) {
|
|
257
|
-
const grant = uploadGrant(entry);
|
|
258
|
-
if (grant === 'absent')
|
|
259
|
-
continue;
|
|
260
|
-
const bytes = index < files.length ? await fileBytes(files[index]) : null;
|
|
261
|
-
if (grant === null || bytes === null)
|
|
262
|
-
return false;
|
|
263
|
-
const answer = await transport.transfer({
|
|
264
|
-
act: 'conversation_file_upload',
|
|
265
|
-
url: grant.url,
|
|
266
|
-
body: bytes,
|
|
267
|
-
operation: grant.operation,
|
|
268
|
-
});
|
|
269
|
-
if (answer.status !== 200)
|
|
270
|
-
return false;
|
|
271
|
-
}
|
|
272
|
-
return true;
|
|
166
|
+
return { conversation_id: text(input, 'conversation'), operation_id: operation, text: said };
|
|
273
167
|
}
|
|
274
168
|
async function sendAction(transport, route, input, name) {
|
|
275
169
|
const body = sendBody(input);
|
|
@@ -278,9 +172,6 @@ async function sendAction(transport, route, input, name) {
|
|
|
278
172
|
const outcome = actionOutcome(await transport.door(route, body), name);
|
|
279
173
|
if (outcome.kind !== 'action')
|
|
280
174
|
return outcome;
|
|
281
|
-
if (!(await uploadFiles(transport, input, outcome.result))) {
|
|
282
|
-
return { kind: 'transport-uncertainty' };
|
|
283
|
-
}
|
|
284
175
|
return { ...outcome, result: withTurn(outcome.result) };
|
|
285
176
|
}
|
|
286
177
|
function historyCursor(value) {
|
|
@@ -305,19 +196,12 @@ export function acceptedMessage(entry) {
|
|
|
305
196
|
const cursor = historyCursor(entry);
|
|
306
197
|
if (cursor === null)
|
|
307
198
|
return null;
|
|
308
|
-
const message = structuredClone(record(entry));
|
|
309
|
-
const referrer = { message: cursor.message_id };
|
|
310
199
|
return {
|
|
311
200
|
identity: cursor.message_id,
|
|
312
201
|
turn: text(entry, 'turn_id') ?? cursor.message_id,
|
|
313
202
|
position: position(cursor),
|
|
314
203
|
text: text(entry, 'text') ?? '',
|
|
315
|
-
message:
|
|
316
|
-
? {
|
|
317
|
-
...message,
|
|
318
|
-
files: message.files.map((file) => ({ ...record(file), referrer })),
|
|
319
|
-
}
|
|
320
|
-
: message,
|
|
204
|
+
message: structuredClone(record(entry)),
|
|
321
205
|
};
|
|
322
206
|
}
|
|
323
207
|
function historyPage(entry) {
|
|
@@ -354,22 +238,6 @@ function historyAsks(input) {
|
|
|
354
238
|
}
|
|
355
239
|
return asks;
|
|
356
240
|
}
|
|
357
|
-
async function triggersAction(transport, route, input, name) {
|
|
358
|
-
const asked = record(input).room_refs;
|
|
359
|
-
if (!Array.isArray(asked) || asked.length === 0)
|
|
360
|
-
return malformed();
|
|
361
|
-
const rooms = [];
|
|
362
|
-
for (let at = 0; at < asked.length; at += TRIGGER_ROOMS) {
|
|
363
|
-
const outcome = actionOutcome(await transport.door(route, { room_refs: asked.slice(at, at + TRIGGER_ROOMS) }), name);
|
|
364
|
-
if (outcome.kind !== 'action')
|
|
365
|
-
return outcome;
|
|
366
|
-
const answered = record(outcome.result).rooms;
|
|
367
|
-
if (!Array.isArray(answered))
|
|
368
|
-
return { kind: 'transport-uncertainty' };
|
|
369
|
-
rooms.push(...answered);
|
|
370
|
-
}
|
|
371
|
-
return { kind: 'action', result: { rooms } };
|
|
372
|
-
}
|
|
373
241
|
async function historyAction(transport, route, input, name) {
|
|
374
242
|
const asks = historyAsks(input);
|
|
375
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"}
|