@agentshouse/mdruntime-adapter 0.1.0-c574f13baffd6 → 0.1.0-c57c76f615a7b
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 -49
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +71 -231
- package/dist/adapter.d.ts +0 -1
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +222 -456
- package/dist/authored-path.d.ts +66 -0
- package/dist/authored-path.d.ts.map +1 -0
- package/dist/authored-path.js +166 -0
- package/dist/chunks.d.ts +36 -0
- package/dist/chunks.d.ts.map +1 -0
- package/dist/chunks.js +281 -0
- package/dist/digest.d.ts +0 -1
- package/dist/discovery.d.ts +42 -12
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +231 -51
- package/dist/history.d.ts +6 -0
- package/dist/history.d.ts.map +1 -0
- package/dist/history.js +85 -0
- package/dist/index.d.ts +10 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -6
- package/dist/map.d.ts +0 -1
- package/dist/model.d.ts +6 -10
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +27 -42
- package/dist/read.d.ts +22 -74
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +107 -360
- package/dist/refusal.d.ts +6 -5
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +27 -11
- package/dist/renamed.d.ts +10 -0
- package/dist/renamed.d.ts.map +1 -0
- package/dist/renamed.js +29 -0
- package/dist/room-query.d.ts +4 -0
- package/dist/room-query.d.ts.map +1 -0
- package/dist/room-query.js +63 -0
- package/dist/search.d.ts +4 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +47 -0
- package/dist/session-content/check.d.ts +17 -0
- package/dist/session-content/index.d.ts +6 -0
- package/dist/session-content/parts.d.ts +30 -0
- package/dist/session-content/state.d.ts +59 -0
- package/dist/session-content/turn.d.ts +137 -0
- package/dist/site.d.ts +0 -1
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +117 -175
- package/dist/space-schema.d.ts +6 -0
- package/dist/space-schema.d.ts.map +1 -0
- package/dist/space-schema.js +11 -0
- package/dist/stream.d.ts +15 -16
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +243 -431
- package/dist/transport.d.ts +90 -47
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +94 -12
- package/dist/uncertain.d.ts +5 -0
- package/dist/uncertain.d.ts.map +1 -0
- package/dist/uncertain.js +11 -0
- package/dist/upload.d.ts +7 -2
- package/dist/upload.d.ts.map +1 -1
- package/dist/upload.js +51 -8
- package/dist/version.d.ts +0 -1
- package/dist/write.d.ts +4 -2
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +46 -55
- package/package.json +4 -3
- package/dist/app-reference.d.ts +0 -2
- package/dist/app-reference.d.ts.map +0 -1
- package/dist/app-reference.js +0 -2
- package/dist/crockford.d.ts +0 -4
- package/dist/crockford.d.ts.map +0 -1
- package/dist/crockford.js +0 -3
- package/dist/gather.d.ts +0 -4
- package/dist/gather.d.ts.map +0 -1
- package/dist/gather.js +0 -35
- package/dist/house-model.d.ts +0 -2
- package/dist/house-model.d.ts.map +0 -1
- package/dist/house-model.js +0 -484
- package/dist/part.d.ts +0 -15
- package/dist/part.d.ts.map +0 -1
- package/dist/part.js +0 -82
- package/dist/room-types.d.ts +0 -7
- package/dist/room-types.d.ts.map +0 -1
- package/dist/room-types.js +0 -124
package/README.md
CHANGED
|
@@ -20,12 +20,12 @@ import { createAgentsHouseAdapter } from '@agentshouse/mdruntime-adapter';
|
|
|
20
20
|
|
|
21
21
|
const adapter = createAgentsHouseAdapter({ transport, authorize });
|
|
22
22
|
const host = serveMdRuntime({ adapter, shell });
|
|
23
|
-
host.attach(port, 'my-app');
|
|
23
|
+
host.attach(port, { app: 'my-app' });
|
|
24
24
|
```
|
|
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` tool opens.
|
|
29
29
|
|
|
30
30
|
## License
|
|
31
31
|
|
package/dist/actions.d.ts
CHANGED
|
@@ -1,51 +1,12 @@
|
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export type AppInputs = {
|
|
11
|
-
readonly 'conversation.answer': ConversationControl & {
|
|
12
|
-
readonly answer: {
|
|
13
|
-
readonly interaction_id: string;
|
|
14
|
-
readonly response: unknown;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
readonly 'conversation.create': Operated & {
|
|
18
|
-
readonly agent_id: string;
|
|
19
|
-
readonly replaces?: string;
|
|
20
|
-
};
|
|
21
|
-
readonly 'conversation.delete': ConversationControl;
|
|
22
|
-
readonly 'conversation.history': ConversationHistoryRequest;
|
|
23
|
-
readonly 'conversation.interrupt': ConversationControl;
|
|
24
|
-
readonly 'conversation.kill': ConversationControl;
|
|
25
|
-
readonly 'conversation.send': ConversationControl & {
|
|
26
|
-
readonly operation_id: string;
|
|
27
|
-
readonly text: string;
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
export type AppAnswers = {
|
|
31
|
-
readonly 'conversation.history': ConversationHistories;
|
|
32
|
-
};
|
|
33
|
-
export type AppAnswerAdditions = {
|
|
34
|
-
readonly 'conversation.create': {
|
|
35
|
-
readonly conversation: string;
|
|
36
|
-
};
|
|
37
|
-
readonly 'conversation.send': {
|
|
38
|
-
readonly turn: string;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
export declare const HOUSE_APP_ACTS: Readonly<Record<string, string>>;
|
|
42
|
-
export declare const SITE_SUBMIT = "submit";
|
|
43
|
-
export declare const HOUSE_SITE_ACTS: Readonly<Record<string, string>>;
|
|
44
|
-
export declare const HOUSE_APP_BATCHES: Readonly<Partial<Record<string, readonly string[]>>>;
|
|
45
|
-
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[];
|
|
6
|
+
export declare const HOUSE_RENAMED_UNTIL_2026_12_18: ReadonlyMap<string, string>;
|
|
7
|
+
export declare const HOUSE_REWRITTEN_UNTIL_2026_12_19: ReadonlyMap<string, (input: unknown) => unknown>;
|
|
8
|
+
export declare const HOUSE_RENAMED_UNTIL_2026_12_21: ReadonlyMap<string, string>;
|
|
9
|
+
export declare const HOUSE_REWRITTEN_UNTIL_2026_12_21: ReadonlyMap<string, (input: unknown) => unknown>;
|
|
46
10
|
export declare function declaredActions(routes: readonly string[]): readonly ActionDeclaration[];
|
|
47
|
-
export declare function houseAction(transport:
|
|
48
|
-
export declare function actionOutcome(answer: HouseDoorAnswer, name: string): ActionResult;
|
|
49
|
-
export declare function acceptedMessage(entry: unknown): AcceptedMessage | null;
|
|
50
|
-
export {};
|
|
51
|
-
//# sourceMappingURL=actions.d.ts.map
|
|
11
|
+
export declare function houseAction(transport: HouseActDoor, request: ActionRequest): Promise<ActionResult>;
|
|
12
|
+
export declare function actionOutcome(answer: HouseDoorAnswer, name: string, input: unknown): ActionResult;
|
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;AAI7F,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,EAI/C,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAKhD,CAAC;AAEF,eAAO,MAAM,8BAA8B,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAErE,CAAC;AAQH,eAAO,MAAM,gCAAgC,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CACvD,CAAC;AAExC,eAAO,MAAM,8BAA8B,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAGrE,CAAC;AAiBH,eAAO,MAAM,gCAAgC,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAI1F,CAAC;AAQL,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,iBAAiB,EAAE,CAOvF;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,74 +1,59 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
'
|
|
27
|
-
'
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
'
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
'
|
|
43
|
-
'
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
'
|
|
47
|
-
|
|
48
|
-
'triggerOccurrence.list': mapped('triggers/fired'),
|
|
49
|
-
};
|
|
50
|
-
export const HOUSE_APP_ACTS = Object.fromEntries(Object.entries(APP_ACTS).map(([name, act]) => [name, act.door]));
|
|
51
|
-
export const SITE_SUBMIT = 'submit';
|
|
52
|
-
export const HOUSE_SITE_ACTS = {
|
|
53
|
-
[SITE_SUBMIT]: 'site/submission',
|
|
54
|
-
};
|
|
55
|
-
export const HOUSE_APP_BATCHES = Object.fromEntries(Object.entries(APP_ACTS).flatMap(([name, act]) => act.batched === undefined ? [] : [[name, act.batched]]));
|
|
56
|
-
const APP_NAMES = new Map(Object.entries(APP_ACTS).map(([name, act]) => [act.door, name]));
|
|
57
|
-
export function houseConversationAgents(locator) {
|
|
58
|
-
return { locator, type: 'house-agent', identity: 'agent', name: 'name', retired: 'retired' };
|
|
59
|
-
}
|
|
1
|
+
import { answeredFailure, doorRefusal, resetOf } from './refusal.js';
|
|
2
|
+
import { movedPaths, renamedHandle } from './renamed.js';
|
|
3
|
+
import { refusedFor } from './uncertain.js';
|
|
4
|
+
export const HOUSE_UNKEPT_READS = [
|
|
5
|
+
'account/security/read',
|
|
6
|
+
'billing/read',
|
|
7
|
+
'clients/last-use/list',
|
|
8
|
+
];
|
|
9
|
+
export const HOUSE_LEADING_READS = [
|
|
10
|
+
'app.list',
|
|
11
|
+
'apps/list',
|
|
12
|
+
'sites/list',
|
|
13
|
+
'rooms/members/list',
|
|
14
|
+
];
|
|
15
|
+
export const HOUSE_RENAMED_UNTIL_2026_12_18 = new Map([
|
|
16
|
+
['files/batch', 'update'],
|
|
17
|
+
]);
|
|
18
|
+
function withoutRoomRef(input) {
|
|
19
|
+
if (typeof input !== 'object' || input === null || !('room_ref' in input))
|
|
20
|
+
return input;
|
|
21
|
+
const { room_ref: _room, ...paths } = input;
|
|
22
|
+
return paths;
|
|
23
|
+
}
|
|
24
|
+
export const HOUSE_REWRITTEN_UNTIL_2026_12_19 = new Map([['update', withoutRoomRef]]);
|
|
25
|
+
export const HOUSE_RENAMED_UNTIL_2026_12_21 = new Map([
|
|
26
|
+
['apps/create', 'app_update'],
|
|
27
|
+
['apps/upload', 'app_update'],
|
|
28
|
+
]);
|
|
29
|
+
function held(input) {
|
|
30
|
+
return typeof input === 'object' && input !== null
|
|
31
|
+
? { ...input }
|
|
32
|
+
: {};
|
|
33
|
+
}
|
|
34
|
+
function created(input) {
|
|
35
|
+
return { op: 'create', ...held(input) };
|
|
36
|
+
}
|
|
37
|
+
function uploaded(input) {
|
|
38
|
+
const { app_ref: app, ...files } = held(input);
|
|
39
|
+
return { op: 'publish', app, ...files };
|
|
40
|
+
}
|
|
41
|
+
export const HOUSE_REWRITTEN_UNTIL_2026_12_21 = new Map([
|
|
42
|
+
['apps/create', created],
|
|
43
|
+
['apps/upload', uploaded],
|
|
44
|
+
]);
|
|
45
|
+
const ROOM_SELECTORS = new Map([
|
|
46
|
+
['update', { room: 'changes.room', roomPaths: ['changes.path', 'changes.to', 'paths', 'mount'] }],
|
|
47
|
+
]);
|
|
60
48
|
export function declaredActions(routes) {
|
|
61
|
-
return routes.map((
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
49
|
+
return routes.map((name) => ({
|
|
50
|
+
name,
|
|
51
|
+
inputShape: {},
|
|
52
|
+
resultKind: 'house',
|
|
53
|
+
...(ROOM_SELECTORS.get(name) ?? { room: 'room_ref' }),
|
|
54
|
+
}));
|
|
65
55
|
}
|
|
66
56
|
export function houseAction(transport, request) {
|
|
67
|
-
if (Object.hasOwn(APP_ACTS, request.name)) {
|
|
68
|
-
return APP_ACTS[request.name].carry(transport, request.input, request.name);
|
|
69
|
-
}
|
|
70
|
-
if (APP_NAMES.has(request.name))
|
|
71
|
-
return Promise.resolve(unimplemented(request.name));
|
|
72
57
|
const route = routeOf(request.name);
|
|
73
58
|
if (route === null)
|
|
74
59
|
return Promise.resolve(malformed());
|
|
@@ -85,182 +70,37 @@ function routeOf(name) {
|
|
|
85
70
|
return null;
|
|
86
71
|
}
|
|
87
72
|
}
|
|
88
|
-
function record(value) {
|
|
89
|
-
return typeof value === 'object' && value !== null ? value : {};
|
|
90
|
-
}
|
|
91
|
-
function text(value, name) {
|
|
92
|
-
const held = record(value)[name];
|
|
93
|
-
return typeof held === 'string' ? held : undefined;
|
|
94
|
-
}
|
|
95
|
-
function operationId(input) {
|
|
96
|
-
return text(input, 'operation_id') ?? changeBatchIdentity();
|
|
97
|
-
}
|
|
98
73
|
function malformed() {
|
|
99
74
|
return { kind: 'rejected', code: 'invalid_request', fields: {}, retryable: false };
|
|
100
75
|
}
|
|
101
76
|
function unimplemented(name) {
|
|
102
77
|
return { kind: 'rejected', code: 'action-unimplemented', fields: { name }, retryable: false };
|
|
103
78
|
}
|
|
104
|
-
function
|
|
105
|
-
|
|
106
|
-
return {
|
|
107
|
-
agent_id: text(input, 'agent_id'),
|
|
108
|
-
operation_id: operationId(input),
|
|
109
|
-
...(replaces === undefined ? {} : { replaces }),
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
function controlBody(input) {
|
|
113
|
-
return { conversation_id: text(input, 'conversation'), operation_id: operationId(input) };
|
|
114
|
-
}
|
|
115
|
-
function answerBody(input) {
|
|
116
|
-
const nested = record(record(input).answer);
|
|
117
|
-
return {
|
|
118
|
-
conversation_id: text(input, 'conversation'),
|
|
119
|
-
operation_id: operationId(input),
|
|
120
|
-
interaction_id: text(nested, 'interaction_id'),
|
|
121
|
-
response: nested.response,
|
|
122
|
-
};
|
|
79
|
+
function numbered(input) {
|
|
80
|
+
return typeof input?.operation_id === 'string';
|
|
123
81
|
}
|
|
124
|
-
|
|
125
|
-
const outcome = actionOutcome(await transport.door(route, createBody(input)), name);
|
|
126
|
-
if (outcome.kind !== 'action')
|
|
127
|
-
return outcome;
|
|
128
|
-
const held = record(outcome.result);
|
|
129
|
-
const conversation = text(held, 'conversation_id');
|
|
130
|
-
return conversation === undefined
|
|
131
|
-
? outcome
|
|
132
|
-
: {
|
|
133
|
-
...outcome,
|
|
134
|
-
result: { ...held, conversation },
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
function withTurn(body) {
|
|
138
|
-
const held = record(body);
|
|
139
|
-
const turn = text(held, 'message_id');
|
|
140
|
-
return turn === undefined
|
|
141
|
-
? body
|
|
142
|
-
: { ...held, turn };
|
|
143
|
-
}
|
|
144
|
-
export function actionOutcome(answer, name) {
|
|
82
|
+
export function actionOutcome(answer, name, input) {
|
|
145
83
|
if (answer.status === 401)
|
|
146
84
|
return { kind: 'revoked-authorization' };
|
|
147
85
|
const refusal = doorRefusal(answer.body);
|
|
148
|
-
if (refusal?.code === 'operation_contended')
|
|
149
|
-
return
|
|
150
|
-
if (refusal !== null)
|
|
151
|
-
|
|
86
|
+
if (refusal?.code === 'operation_contended' && numbered(input))
|
|
87
|
+
return refusedFor(refusal);
|
|
88
|
+
if (refusal !== null) {
|
|
89
|
+
const reset = resetOf(refusal);
|
|
90
|
+
return { kind: 'rejected', ...refusal, ...(reset === undefined ? {} : { reset }) };
|
|
91
|
+
}
|
|
152
92
|
if (answer.status === 404)
|
|
153
93
|
return unimplemented(name);
|
|
154
|
-
if (answer.status === 0 || answer.status >= 400)
|
|
155
|
-
return
|
|
94
|
+
if (answer.status === 0 || answer.status >= 400) {
|
|
95
|
+
return answeredFailure(answer.status, answer.body);
|
|
96
|
+
}
|
|
156
97
|
return { kind: 'action', result: answer.body };
|
|
157
98
|
}
|
|
158
99
|
async function carry(transport, route, name, input) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
return null;
|
|
166
|
-
return { conversation_id: text(input, 'conversation'), operation_id: operation, text: said };
|
|
167
|
-
}
|
|
168
|
-
async function sendAction(transport, route, input, name) {
|
|
169
|
-
const body = sendBody(input);
|
|
170
|
-
if (body === null)
|
|
171
|
-
return malformed();
|
|
172
|
-
const outcome = actionOutcome(await transport.door(route, body), name);
|
|
173
|
-
if (outcome.kind !== 'action')
|
|
174
|
-
return outcome;
|
|
175
|
-
return { ...outcome, result: withTurn(outcome.result) };
|
|
176
|
-
}
|
|
177
|
-
function historyCursor(value) {
|
|
178
|
-
const acceptedAt = text(value, 'accepted_at');
|
|
179
|
-
const messageId = text(value, 'message_id');
|
|
180
|
-
if (acceptedAt === undefined || messageId === undefined)
|
|
181
|
-
return null;
|
|
182
|
-
return { accepted_at: acceptedAt, message_id: messageId };
|
|
183
|
-
}
|
|
184
|
-
function position(cursor) {
|
|
185
|
-
return JSON.stringify({ accepted_at: cursor.accepted_at, message_id: cursor.message_id });
|
|
186
|
-
}
|
|
187
|
-
function positionCursor(value) {
|
|
188
|
-
try {
|
|
189
|
-
return historyCursor(JSON.parse(value));
|
|
190
|
-
}
|
|
191
|
-
catch {
|
|
192
|
-
return null;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
export function acceptedMessage(entry) {
|
|
196
|
-
const cursor = historyCursor(entry);
|
|
197
|
-
if (cursor === null)
|
|
198
|
-
return null;
|
|
199
|
-
return {
|
|
200
|
-
identity: cursor.message_id,
|
|
201
|
-
turn: text(entry, 'turn_id') ?? cursor.message_id,
|
|
202
|
-
position: position(cursor),
|
|
203
|
-
text: text(entry, 'text') ?? '',
|
|
204
|
-
message: structuredClone(record(entry)),
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
function historyPage(entry) {
|
|
208
|
-
const held = record(entry);
|
|
209
|
-
const conversation = text(held, 'conversation_id');
|
|
210
|
-
if (conversation === undefined || !Array.isArray(held.messages))
|
|
211
|
-
return null;
|
|
212
|
-
const messages = [];
|
|
213
|
-
for (const one of held.messages) {
|
|
214
|
-
const message = acceptedMessage(one);
|
|
215
|
-
if (message === null)
|
|
216
|
-
return null;
|
|
217
|
-
messages.push(message);
|
|
218
|
-
}
|
|
219
|
-
const next = held.next === null || held.next === undefined ? undefined : historyCursor(held.next);
|
|
220
|
-
if (next === null)
|
|
221
|
-
return null;
|
|
222
|
-
return { conversation, messages, ...(next === undefined ? {} : { next: position(next) }) };
|
|
223
|
-
}
|
|
224
|
-
function historyAsks(input) {
|
|
225
|
-
const asked = record(input).conversations;
|
|
226
|
-
if (!Array.isArray(asked) || asked.length === 0)
|
|
227
|
-
return null;
|
|
228
|
-
const asks = [];
|
|
229
|
-
for (const entry of asked) {
|
|
230
|
-
const conversationId = text(entry, 'conversation');
|
|
231
|
-
if (conversationId === undefined)
|
|
232
|
-
return null;
|
|
233
|
-
const afterValue = text(entry, 'after');
|
|
234
|
-
const after = afterValue === undefined ? undefined : positionCursor(afterValue);
|
|
235
|
-
if (after === null)
|
|
236
|
-
return null;
|
|
237
|
-
asks.push({ conversation_id: conversationId, ...(after === undefined ? {} : { after }) });
|
|
238
|
-
}
|
|
239
|
-
return asks;
|
|
240
|
-
}
|
|
241
|
-
async function historyAction(transport, route, input, name) {
|
|
242
|
-
const asks = historyAsks(input);
|
|
243
|
-
if (asks === null)
|
|
244
|
-
return malformed();
|
|
245
|
-
const histories = [];
|
|
246
|
-
for (let at = 0; at < asks.length; at += HISTORY_CONVERSATIONS) {
|
|
247
|
-
const answer = await transport.door(route, {
|
|
248
|
-
conversations: asks.slice(at, at + HISTORY_CONVERSATIONS),
|
|
249
|
-
limit: HISTORY_PAGE,
|
|
250
|
-
});
|
|
251
|
-
const outcome = actionOutcome(answer, name);
|
|
252
|
-
if (outcome.kind !== 'action')
|
|
253
|
-
return outcome;
|
|
254
|
-
const answered = record(outcome.result).histories;
|
|
255
|
-
if (!Array.isArray(answered))
|
|
256
|
-
return { kind: 'transport-uncertainty' };
|
|
257
|
-
for (const entry of answered) {
|
|
258
|
-
const page = historyPage(entry);
|
|
259
|
-
if (page === null)
|
|
260
|
-
return { kind: 'transport-uncertainty' };
|
|
261
|
-
histories.push(page);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
const result = { histories };
|
|
265
|
-
return { kind: 'action', result };
|
|
100
|
+
const answered = actionOutcome(await transport.door(route, input), name, input);
|
|
101
|
+
const renamed = renamedHandle(answered);
|
|
102
|
+
if (renamed === null)
|
|
103
|
+
return answered;
|
|
104
|
+
const moved = movedPaths(input, renamed);
|
|
105
|
+
return actionOutcome(await transport.door(route, moved), name, moved);
|
|
266
106
|
}
|
package/dist/adapter.d.ts
CHANGED
package/dist/adapter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAIV,OAAO,EAIP,aAAa,EAkBd,MAAM,wBAAwB,CAAC;AAkChC,OAAO,EAIL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAoBxB,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;AAcrD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CA2cpF"}
|