@agentshouse/mdruntime-adapter 0.1.0-cd519a0f878dc → 0.1.0-cd59e72d7f397
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 +14 -59
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +194 -289
- package/dist/adapter.d.ts +0 -1
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +234 -423
- package/dist/authored-path.d.ts +61 -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 +110 -363
- 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 +20 -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 +20 -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 +152 -0
- package/dist/site.d.ts +0 -1
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +120 -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 +16 -16
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +306 -430
- package/dist/transport.d.ts +113 -46
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +92 -11
- 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 +2 -4
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +100 -127
- 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 -441
- 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,62 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { ActionDeclaration, ActionRequest, ActionResult } from '@agentshouse/mdruntime';
|
|
2
2
|
import type { HouseDoorAnswer, HouseTransport } from './transport.js';
|
|
3
|
-
export
|
|
4
|
-
export declare const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
readonly blob: Blob;
|
|
15
|
-
};
|
|
16
|
-
readonly 'conversation.answer': ConversationControl & {
|
|
17
|
-
readonly answer: {
|
|
18
|
-
readonly interaction_id: string;
|
|
19
|
-
readonly response: unknown;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
readonly 'conversation.create': Operated & {
|
|
23
|
-
readonly agent_id: string;
|
|
24
|
-
readonly replaces?: string;
|
|
25
|
-
};
|
|
26
|
-
readonly 'conversation.delete': ConversationControl;
|
|
27
|
-
readonly 'conversation.history': ConversationHistoryRequest;
|
|
28
|
-
readonly 'conversation.interrupt': ConversationControl;
|
|
29
|
-
readonly 'conversation.kill': ConversationControl;
|
|
30
|
-
readonly 'conversation.send': ConversationControl & {
|
|
31
|
-
readonly operation_id: string;
|
|
32
|
-
readonly text: string;
|
|
33
|
-
};
|
|
34
|
-
readonly 'trigger.list': {
|
|
35
|
-
readonly room_refs: readonly string[];
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
export type AppAnswers = {
|
|
39
|
-
readonly 'conversation.attach': {
|
|
40
|
-
readonly path: string;
|
|
41
|
-
};
|
|
42
|
-
readonly 'conversation.history': ConversationHistories;
|
|
43
|
-
};
|
|
44
|
-
export type AppAnswerAdditions = {
|
|
45
|
-
readonly 'conversation.create': {
|
|
46
|
-
readonly conversation: string;
|
|
47
|
-
};
|
|
48
|
-
readonly 'conversation.send': {
|
|
49
|
-
readonly turn: string;
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
export declare const HOUSE_APP_ACTS: Readonly<Record<string, string>>;
|
|
53
|
-
export declare const SITE_SUBMIT = "submit";
|
|
54
|
-
export declare const HOUSE_SITE_ACTS: Readonly<Record<string, string>>;
|
|
55
|
-
export declare const HOUSE_APP_BATCHES: Readonly<Partial<Record<string, readonly string[]>>>;
|
|
56
|
-
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
|
+
type Rewrites = ReadonlyMap<string, (input: unknown) => unknown>;
|
|
8
|
+
export declare const HOUSE_REWRITTEN_UNTIL_2026_12_19: Rewrites;
|
|
9
|
+
export declare const HOUSE_RENAMED_UNTIL_2026_12_21: ReadonlyMap<string, string>;
|
|
10
|
+
export declare const HOUSE_REWRITTEN_UNTIL_2026_12_21: Rewrites;
|
|
11
|
+
export declare const HOUSE_RENAMED_UNTIL_2026_12_22: ReadonlyMap<string, string>;
|
|
12
|
+
export declare const HOUSE_REWRITTEN_UNTIL_2026_12_22: Rewrites;
|
|
13
|
+
export declare function rewrittenInTurn(...rewrites: readonly Rewrites[]): Rewrites;
|
|
57
14
|
export declare function declaredActions(routes: readonly string[]): readonly ActionDeclaration[];
|
|
58
|
-
export declare function houseAction(transport:
|
|
59
|
-
export declare function actionOutcome(answer: HouseDoorAnswer, name: string): ActionResult;
|
|
60
|
-
export declare function acceptedMessage(entry: unknown): AcceptedMessage | null;
|
|
15
|
+
export declare function houseAction(transport: HouseActDoor, request: ActionRequest): Promise<ActionResult>;
|
|
16
|
+
export declare function actionOutcome(answer: HouseDoorAnswer, name: string, input: unknown): ActionResult;
|
|
61
17
|
export {};
|
|
62
|
-
//# 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;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,EAMhD,CAAC;AAEF,eAAO,MAAM,8BAA8B,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAErE,CAAC;AAgCH,KAAK,QAAQ,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,CAAC;AAEjE,eAAO,MAAM,gCAAgC,EAAE,QAAgD,CAAC;AAEhG,eAAO,MAAM,8BAA8B,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAkBrE,CAAC;AAsDH,eAAO,MAAM,gCAAgC,EAAE,QAmB7C,CAAC;AAEH,eAAO,MAAM,8BAA8B,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAYrE,CAAC;AAEH,eAAO,MAAM,gCAAgC,EAAE,QAe7C,CAAC;AAEH,wBAAgB,eAAe,CAAC,GAAG,QAAQ,EAAE,SAAS,QAAQ,EAAE,GAAG,QAAQ,CAQ1E;AAcD,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,81 +1,188 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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.read security',
|
|
6
|
+
'account.billing',
|
|
7
|
+
'account.clients',
|
|
8
|
+
];
|
|
9
|
+
export const HOUSE_LEADING_READS = [
|
|
10
|
+
'app.list',
|
|
11
|
+
'apps/list',
|
|
12
|
+
'sites/list',
|
|
13
|
+
'rooms/members/list',
|
|
14
|
+
'sharing.members',
|
|
15
|
+
];
|
|
16
|
+
export const HOUSE_RENAMED_UNTIL_2026_12_18 = new Map([
|
|
17
|
+
['files/batch', 'update'],
|
|
18
|
+
]);
|
|
19
|
+
function withoutRoomRef(input) {
|
|
20
|
+
if (typeof input !== 'object' || input === null || !('room_ref' in input))
|
|
21
|
+
return input;
|
|
22
|
+
const { room_ref: _room, ...paths } = input;
|
|
23
|
+
return paths;
|
|
24
|
+
}
|
|
25
|
+
const CURRENT_OPS = new Map([
|
|
26
|
+
['create', 'write'],
|
|
27
|
+
['replace', 'write'],
|
|
28
|
+
['patch', 'edit'],
|
|
29
|
+
['rename', 'move'],
|
|
30
|
+
['remove', 'delete'],
|
|
31
|
+
['create_folder', 'mkdir'],
|
|
32
|
+
['remove_folder', 'delete'],
|
|
33
|
+
]);
|
|
34
|
+
function withCurrentOps(input) {
|
|
35
|
+
if (typeof input !== 'object' || input === null || !('changes' in input))
|
|
36
|
+
return input;
|
|
37
|
+
const { changes } = input;
|
|
38
|
+
if (!Array.isArray(changes))
|
|
39
|
+
return input;
|
|
8
40
|
return {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
41
|
+
...input,
|
|
42
|
+
changes: changes.map((change) => {
|
|
43
|
+
if (typeof change !== 'object' || change === null || !('op' in change))
|
|
44
|
+
return change;
|
|
45
|
+
const op = CURRENT_OPS.get(change.op);
|
|
46
|
+
return op === undefined ? change : { ...change, op };
|
|
47
|
+
}),
|
|
13
48
|
};
|
|
14
49
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
50
|
+
export const HOUSE_REWRITTEN_UNTIL_2026_12_19 = new Map([['update', withoutRoomRef]]);
|
|
51
|
+
export const HOUSE_RENAMED_UNTIL_2026_12_21 = new Map([
|
|
52
|
+
['apps/create', 'app_update'],
|
|
53
|
+
['apps/upload', 'app_update'],
|
|
54
|
+
['shares/accept', 'sharing_update'],
|
|
55
|
+
['shares/decline', 'sharing_update'],
|
|
56
|
+
['shares/join-requests/approve', 'sharing_update'],
|
|
57
|
+
['shares/join-requests/decline', 'sharing_update'],
|
|
58
|
+
['rooms/ownership/offer', 'sharing_update'],
|
|
59
|
+
['rooms/ownership/accept', 'sharing_update'],
|
|
60
|
+
['rooms/ownership/decline', 'sharing_update'],
|
|
61
|
+
['rooms/instructions/follow', 'sharing_update'],
|
|
62
|
+
['agents/standing-answer/set', 'agent_update'],
|
|
63
|
+
['agents/ask-afk/set', 'agent_update'],
|
|
64
|
+
['environments/sign-in', 'environment_update'],
|
|
65
|
+
['environments/rooms/set', 'environment_update'],
|
|
66
|
+
['environments/login-code/create', 'environment_update'],
|
|
67
|
+
['environments/login-code/create-reusable', 'environment_update'],
|
|
68
|
+
['environments/login-code/cancel', 'environment_update'],
|
|
69
|
+
]);
|
|
70
|
+
function held(input) {
|
|
71
|
+
return typeof input === 'object' && input !== null
|
|
72
|
+
? { ...input }
|
|
73
|
+
: {};
|
|
74
|
+
}
|
|
75
|
+
function created(input) {
|
|
76
|
+
return { op: 'create', ...held(input) };
|
|
77
|
+
}
|
|
78
|
+
function uploaded(input) {
|
|
79
|
+
const { app_ref: app, ...files } = held(input);
|
|
80
|
+
return { op: 'publish', app, ...files };
|
|
81
|
+
}
|
|
82
|
+
function decided(op) {
|
|
83
|
+
return (input) => ({ op, ...held(input) });
|
|
84
|
+
}
|
|
85
|
+
function reusable(input) {
|
|
86
|
+
return { op: 'login_code_create', reusable: true, ...held(input) };
|
|
87
|
+
}
|
|
88
|
+
function zoned(input) {
|
|
89
|
+
const { browser, ...named } = held(input);
|
|
90
|
+
return { op: 'set', ...named, ...(browser === undefined ? {} : { if_unset: browser }) };
|
|
91
|
+
}
|
|
92
|
+
function exported(input) {
|
|
93
|
+
const { room_refs: rooms, ...named } = held(input);
|
|
94
|
+
return { op: 'export', ...named, ...(rooms === undefined ? {} : { rooms }) };
|
|
95
|
+
}
|
|
96
|
+
function roomNamed(op) {
|
|
97
|
+
return (input) => {
|
|
98
|
+
const { room_ref: room, ...named } = held(input);
|
|
99
|
+
return { op, room, ...named };
|
|
21
100
|
};
|
|
22
101
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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' };
|
|
102
|
+
function appNamed(op) {
|
|
103
|
+
return (input) => {
|
|
104
|
+
const { app_ref: app, ...named } = held(input);
|
|
105
|
+
return { op, app, ...named };
|
|
106
|
+
};
|
|
66
107
|
}
|
|
108
|
+
function askedAway(input) {
|
|
109
|
+
const { room_ref: room, afk, ...named } = held(input);
|
|
110
|
+
return { op: 'set', ...named, room, ask_afk: afk };
|
|
111
|
+
}
|
|
112
|
+
export const HOUSE_REWRITTEN_UNTIL_2026_12_21 = new Map([
|
|
113
|
+
['apps/create', created],
|
|
114
|
+
['apps/upload', uploaded],
|
|
115
|
+
['shares/accept', decided('share_accept')],
|
|
116
|
+
['shares/decline', decided('share_decline')],
|
|
117
|
+
['shares/join-requests/approve', decided('join_request_approve')],
|
|
118
|
+
['shares/join-requests/decline', decided('join_request_decline')],
|
|
119
|
+
['rooms/ownership/offer', roomNamed('ownership_offer')],
|
|
120
|
+
['rooms/ownership/accept', decided('ownership_accept')],
|
|
121
|
+
['rooms/ownership/decline', decided('ownership_decline')],
|
|
122
|
+
['rooms/instructions/follow', roomNamed('instructions_follow')],
|
|
123
|
+
['agents/standing-answer/set', roomNamed('standing_answer_set')],
|
|
124
|
+
['agents/ask-afk/set', askedAway],
|
|
125
|
+
['environments/sign-in', decided('sign_in')],
|
|
126
|
+
['environments/rooms/set', decided('set')],
|
|
127
|
+
['environments/login-code/create', decided('login_code_create')],
|
|
128
|
+
['environments/login-code/create-reusable', reusable],
|
|
129
|
+
['environments/login-code/cancel', decided('login_code_cancel')],
|
|
130
|
+
['update', withCurrentOps],
|
|
131
|
+
]);
|
|
132
|
+
export const HOUSE_RENAMED_UNTIL_2026_12_22 = new Map([
|
|
133
|
+
['account/security/browsers/revoke', 'account_update'],
|
|
134
|
+
['account/security/browsers/revoke-others', 'account_update'],
|
|
135
|
+
['account/time-zone/set', 'account_update'],
|
|
136
|
+
['account/who-can-add-me/set', 'account_update'],
|
|
137
|
+
['clients/revoke', 'account_update'],
|
|
138
|
+
['clients/rooms/set', 'account_update'],
|
|
139
|
+
['storage/archive', 'account_update'],
|
|
140
|
+
['billing/subscribe', 'account_update'],
|
|
141
|
+
['billing/top-up', 'account_update'],
|
|
142
|
+
['billing/manage', 'account_update'],
|
|
143
|
+
['apps/features/set', 'app_update'],
|
|
144
|
+
]);
|
|
145
|
+
export const HOUSE_REWRITTEN_UNTIL_2026_12_22 = new Map([
|
|
146
|
+
['account/security/browsers/revoke', decided('browser_revoke')],
|
|
147
|
+
[
|
|
148
|
+
'account/security/browsers/revoke-others',
|
|
149
|
+
(input) => ({ op: 'browser_revoke', ...held(input), others: true }),
|
|
150
|
+
],
|
|
151
|
+
['account/time-zone/set', zoned],
|
|
152
|
+
['account/who-can-add-me/set', decided('set')],
|
|
153
|
+
['clients/revoke', decided('client_revoke')],
|
|
154
|
+
['clients/rooms/set', decided('client_rooms_set')],
|
|
155
|
+
['storage/archive', exported],
|
|
156
|
+
['billing/subscribe', decided('subscribe')],
|
|
157
|
+
['billing/top-up', decided('top_up')],
|
|
158
|
+
['billing/manage', decided('billing_manage')],
|
|
159
|
+
['apps/features/set', appNamed('feature_set')],
|
|
160
|
+
]);
|
|
161
|
+
export function rewrittenInTurn(...rewrites) {
|
|
162
|
+
const names = new Set(rewrites.flatMap((each) => [...each.keys()]));
|
|
163
|
+
return new Map([...names].map((name) => [
|
|
164
|
+
name,
|
|
165
|
+
(input) => rewrites.reduce((held, each) => each.get(name)?.(held) ?? held, input),
|
|
166
|
+
]));
|
|
167
|
+
}
|
|
168
|
+
const ROOM_SELECTORS = new Map([
|
|
169
|
+
['update', { room: 'changes.room', roomPaths: ['changes.path', 'changes.to', 'paths', 'mount'] }],
|
|
170
|
+
['sharing', { room: 'room' }],
|
|
171
|
+
['sharing_update', { room: 'room' }],
|
|
172
|
+
['inbox_update', { room: 'room', roomPaths: ['path'] }],
|
|
173
|
+
['agent', { room: 'room' }],
|
|
174
|
+
['agent_update', { room: 'room' }],
|
|
175
|
+
['environment', { room: 'room' }],
|
|
176
|
+
]);
|
|
67
177
|
export function declaredActions(routes) {
|
|
68
|
-
return routes.map((
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
178
|
+
return routes.map((name) => ({
|
|
179
|
+
name,
|
|
180
|
+
inputShape: {},
|
|
181
|
+
resultKind: 'house',
|
|
182
|
+
...(ROOM_SELECTORS.get(name) ?? { room: 'room_ref' }),
|
|
183
|
+
}));
|
|
72
184
|
}
|
|
73
185
|
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
186
|
const route = routeOf(request.name);
|
|
80
187
|
if (route === null)
|
|
81
188
|
return Promise.resolve(malformed());
|
|
@@ -92,239 +199,37 @@ function routeOf(name) {
|
|
|
92
199
|
return null;
|
|
93
200
|
}
|
|
94
201
|
}
|
|
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
202
|
function malformed() {
|
|
106
203
|
return { kind: 'rejected', code: 'invalid_request', fields: {}, retryable: false };
|
|
107
204
|
}
|
|
108
205
|
function unimplemented(name) {
|
|
109
206
|
return { kind: 'rejected', code: 'action-unimplemented', fields: { name }, retryable: false };
|
|
110
207
|
}
|
|
111
|
-
function
|
|
112
|
-
|
|
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
|
-
};
|
|
208
|
+
function numbered(input) {
|
|
209
|
+
return typeof input?.operation_id === 'string';
|
|
143
210
|
}
|
|
144
|
-
function
|
|
145
|
-
const held = record(body);
|
|
146
|
-
const turn = text(held, 'message_id');
|
|
147
|
-
return turn === undefined
|
|
148
|
-
? body
|
|
149
|
-
: { ...held, turn };
|
|
150
|
-
}
|
|
151
|
-
export function actionOutcome(answer, name) {
|
|
211
|
+
export function actionOutcome(answer, name, input) {
|
|
152
212
|
if (answer.status === 401)
|
|
153
213
|
return { kind: 'revoked-authorization' };
|
|
154
214
|
const refusal = doorRefusal(answer.body);
|
|
155
|
-
if (refusal?.code === 'operation_contended')
|
|
156
|
-
return
|
|
157
|
-
if (refusal !== null)
|
|
158
|
-
|
|
215
|
+
if (refusal?.code === 'operation_contended' && numbered(input))
|
|
216
|
+
return refusedFor(refusal);
|
|
217
|
+
if (refusal !== null) {
|
|
218
|
+
const reset = resetOf(refusal);
|
|
219
|
+
return { kind: 'rejected', ...refusal, ...(reset === undefined ? {} : { reset }) };
|
|
220
|
+
}
|
|
159
221
|
if (answer.status === 404)
|
|
160
222
|
return unimplemented(name);
|
|
161
|
-
if (answer.status === 0 || answer.status >= 400)
|
|
162
|
-
return
|
|
223
|
+
if (answer.status === 0 || answer.status >= 400) {
|
|
224
|
+
return answeredFailure(answer.status, answer.body);
|
|
225
|
+
}
|
|
163
226
|
return { kind: 'action', result: answer.body };
|
|
164
227
|
}
|
|
165
228
|
async function carry(transport, route, name, input) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
const
|
|
171
|
-
|
|
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 };
|
|
229
|
+
const answered = actionOutcome(await transport.door(route, input), name, input);
|
|
230
|
+
const renamed = renamedHandle(answered);
|
|
231
|
+
if (renamed === null)
|
|
232
|
+
return answered;
|
|
233
|
+
const moved = movedPaths(input, ROOM_SELECTORS.get(name)?.roomPaths ?? [], renamed);
|
|
234
|
+
return actionOutcome(await transport.door(route, moved), name, moved);
|
|
330
235
|
}
|
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;AAqChC,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,CAodpF"}
|