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