@agentshouse/mdruntime-adapter 0.1.0-c2880bd12f733 → 0.1.0-c2989a271775e

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.
Files changed (88) hide show
  1. package/README.md +2 -2
  2. package/dist/actions.d.ts +10 -164
  3. package/dist/actions.d.ts.map +1 -1
  4. package/dist/actions.js +128 -226
  5. package/dist/adapter.d.ts +0 -1
  6. package/dist/adapter.d.ts.map +1 -1
  7. package/dist/adapter.js +215 -214
  8. package/dist/authored-path.d.ts +61 -0
  9. package/dist/authored-path.d.ts.map +1 -0
  10. package/dist/authored-path.js +166 -0
  11. package/dist/chunks.d.ts +36 -0
  12. package/dist/chunks.d.ts.map +1 -0
  13. package/dist/chunks.js +281 -0
  14. package/dist/digest.d.ts +0 -1
  15. package/dist/discovery.d.ts +40 -10
  16. package/dist/discovery.d.ts.map +1 -1
  17. package/dist/discovery.js +226 -45
  18. package/dist/history.d.ts +6 -0
  19. package/dist/history.d.ts.map +1 -0
  20. package/dist/history.js +85 -0
  21. package/dist/index.d.ts +10 -10
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +9 -8
  24. package/dist/map.d.ts +0 -1
  25. package/dist/model.d.ts +6 -9
  26. package/dist/model.d.ts.map +1 -1
  27. package/dist/model.js +28 -26
  28. package/dist/read.d.ts +20 -24
  29. package/dist/read.d.ts.map +1 -1
  30. package/dist/read.js +106 -176
  31. package/dist/refusal.d.ts +6 -2
  32. package/dist/refusal.d.ts.map +1 -1
  33. package/dist/refusal.js +28 -7
  34. package/dist/renamed.d.ts +10 -0
  35. package/dist/renamed.d.ts.map +1 -0
  36. package/dist/renamed.js +20 -0
  37. package/dist/room-query.d.ts +4 -0
  38. package/dist/room-query.d.ts.map +1 -0
  39. package/dist/room-query.js +63 -0
  40. package/dist/search.d.ts +4 -0
  41. package/dist/search.d.ts.map +1 -0
  42. package/dist/search.js +47 -0
  43. package/dist/session-content/check.d.ts +17 -0
  44. package/dist/session-content/index.d.ts +6 -0
  45. package/dist/session-content/parts.d.ts +30 -0
  46. package/dist/session-content/state.d.ts +59 -0
  47. package/dist/session-content/turn.d.ts +137 -0
  48. package/dist/site.d.ts +0 -1
  49. package/dist/site.d.ts.map +1 -1
  50. package/dist/site.js +102 -67
  51. package/dist/space-schema.d.ts +6 -0
  52. package/dist/space-schema.d.ts.map +1 -0
  53. package/dist/space-schema.js +11 -0
  54. package/dist/stream.d.ts +15 -6
  55. package/dist/stream.d.ts.map +1 -1
  56. package/dist/stream.js +195 -52
  57. package/dist/transport.d.ts +80 -25
  58. package/dist/transport.d.ts.map +1 -1
  59. package/dist/transport.js +53 -11
  60. package/dist/uncertain.d.ts +5 -0
  61. package/dist/uncertain.d.ts.map +1 -0
  62. package/dist/uncertain.js +11 -0
  63. package/dist/upload.d.ts +7 -2
  64. package/dist/upload.d.ts.map +1 -1
  65. package/dist/upload.js +49 -6
  66. package/dist/version.d.ts +0 -1
  67. package/dist/write.d.ts +2 -8
  68. package/dist/write.d.ts.map +1 -1
  69. package/dist/write.js +94 -129
  70. package/package.json +4 -3
  71. package/dist/app-reference.d.ts +0 -2
  72. package/dist/app-reference.d.ts.map +0 -1
  73. package/dist/app-reference.js +0 -2
  74. package/dist/crockford.d.ts +0 -4
  75. package/dist/crockford.d.ts.map +0 -1
  76. package/dist/crockford.js +0 -3
  77. package/dist/house-model.d.ts +0 -2951
  78. package/dist/house-model.d.ts.map +0 -1
  79. package/dist/house-model.js +0 -1627
  80. package/dist/part.d.ts +0 -14
  81. package/dist/part.d.ts.map +0 -1
  82. package/dist/part.js +0 -90
  83. package/dist/room-stream.d.ts +0 -19
  84. package/dist/room-stream.d.ts.map +0 -1
  85. package/dist/room-stream.js +0 -57
  86. package/dist/room-types.d.ts +0 -7
  87. package/dist/room-types.d.ts.map +0 -1
  88. package/dist/room-types.js +0 -126
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 `open_guide` opens.
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,169 +1,15 @@
1
- import { type AcceptedMessage, type ActionDeclaration, type ActionRequest, type ActionResult, type ConversationAgents, type ConversationHistories, type ConversationHistoryRequest } from '@agentshouse/mdruntime';
1
+ import type { ActionDeclaration, ActionRequest, ActionResult } from '@agentshouse/mdruntime';
2
2
  import type { HouseDoorAnswer, HouseTransport } from './transport.js';
3
3
  export type HouseActDoor = Pick<HouseTransport, 'door'>;
4
- export declare const HISTORY_PAGE = 100;
5
- type Operated = {
6
- readonly operation_id?: string;
7
- };
8
- type ConversationControl = Operated & {
9
- readonly conversation: string;
10
- };
11
- export type AppInputs = {
12
- readonly 'conversation.answer': ConversationControl & {
13
- readonly answer: {
14
- readonly interaction_id: string;
15
- readonly response: unknown;
16
- };
17
- };
18
- readonly 'conversation.create': Operated & {
19
- readonly agent_id: string;
20
- readonly replaces?: string;
21
- };
22
- readonly 'conversation.delete': ConversationControl;
23
- readonly 'conversation.history': ConversationHistoryRequest;
24
- readonly 'conversation.interrupt': ConversationControl;
25
- readonly 'conversation.kill': ConversationControl;
26
- readonly 'conversation.send': ConversationControl & {
27
- readonly operation_id: string;
28
- readonly text: string;
29
- };
30
- };
31
- export type AppAnswers = {
32
- readonly 'conversation.history': ConversationHistories;
33
- };
34
- export type AppAnswerAdditions = {
35
- readonly 'conversation.create': {
36
- readonly conversation: string;
37
- };
38
- readonly 'conversation.send': {
39
- readonly turn: string;
40
- };
41
- };
42
- type AppAct<Input = unknown> = {
43
- readonly door: string;
44
- readonly batched?: readonly string[];
45
- carry(transport: HouseActDoor, input: Input, name: string): Promise<ActionResult>;
46
- };
47
- declare const APP_ACTS: {
48
- 'access.read': AppAct<unknown> & {
49
- readonly door: "rooms/access/read";
50
- };
51
- 'conversation.answer': AppAct<Operated & {
52
- readonly conversation: string;
53
- } & {
54
- readonly answer: {
55
- readonly interaction_id: string;
56
- readonly response: unknown;
57
- };
58
- }> & {
59
- readonly door: "conversations/interaction/answer";
60
- };
61
- 'conversation.create': AppAct<Operated & {
62
- readonly agent_id: string;
63
- readonly replaces?: string;
64
- }> & {
65
- readonly door: "conversations/create";
66
- };
67
- 'conversation.delete': AppAct<ConversationControl> & {
68
- readonly door: "conversations/delete";
69
- };
70
- 'conversation.history': AppAct<ConversationHistoryRequest> & {
71
- readonly door: "conversations/history";
72
- };
73
- 'conversation.interrupt': AppAct<ConversationControl> & {
74
- readonly door: "conversations/interrupt";
75
- };
76
- 'conversation.kill': AppAct<ConversationControl> & {
77
- readonly door: "conversations/kill";
78
- };
79
- 'conversation.markDone': AppAct<unknown> & {
80
- readonly door: "conversations/done";
81
- };
82
- 'conversation.rename': AppAct<unknown> & {
83
- readonly door: "conversations/rename";
84
- };
85
- 'conversation.retry': AppAct<unknown> & {
86
- readonly door: "conversations/retry";
87
- };
88
- 'conversation.send': AppAct<Operated & {
89
- readonly conversation: string;
90
- } & {
91
- readonly operation_id: string;
92
- readonly text: string;
93
- }> & {
94
- readonly door: "conversations/send";
95
- };
96
- 'conversation.setOption': AppAct<unknown> & {
97
- readonly door: "conversations/option";
98
- };
99
- 'feature.list': AppAct<unknown> & {
100
- readonly door: "apps/features/read";
101
- };
102
- 'holder.list': AppAct<unknown> & {
103
- readonly door: "apps/holders";
104
- };
105
- 'holder.ring': AppAct<unknown> & {
106
- readonly door: "apps/ring";
107
- };
108
- 'inboxChat.assign': AppAct<unknown> & {
109
- readonly door: "chats/assign";
110
- };
111
- 'inboxChat.return': AppAct<unknown> & {
112
- readonly door: "chats/return";
113
- };
114
- 'inboxChat.takeControl': AppAct<unknown> & {
115
- readonly door: "chats/take-control";
116
- };
117
- 'member.list': AppAct<unknown> & {
118
- readonly door: "rooms/members";
119
- };
120
- 'message.send': AppAct<unknown> & {
121
- readonly door: "apps/messages/send";
122
- };
123
- 'processing.read': AppAct<unknown> & {
124
- readonly door: "rooms/settings/processing/read";
125
- };
126
- 'record.list': AppAct<unknown> & {
127
- readonly door: "records/read";
128
- };
129
- 'relay.read': AppAct<unknown> & {
130
- readonly door: "apps/relay";
131
- };
132
- 'routine.list': AppAct<unknown> & {
133
- readonly door: "routines/access";
134
- };
135
- 'routineAccess.list': AppAct<unknown> & {
136
- readonly door: "routines/granted";
137
- };
138
- 'routineAllowance.list': AppAct<unknown> & {
139
- readonly door: "routines/allowance";
140
- };
141
- 'routineRequest.list': AppAct<unknown> & {
142
- readonly door: "routines/requests";
143
- };
144
- 'storage.read': AppAct<unknown> & {
145
- readonly door: "storage/inventory";
146
- };
147
- 'triggerEvent.list': AppAct<unknown> & {
148
- readonly door: "triggers/fired";
149
- };
150
- };
151
- export type HouseAppActs = {
152
- readonly [Name in keyof typeof APP_ACTS]: (typeof APP_ACTS)[Name]['door'];
153
- };
154
- export declare const HOUSE_APP_ACTS: Readonly<Record<string, string>>;
155
- export declare const SITE_SUBMIT = "submit";
156
- export declare const HOUSE_SITE_ACTS: Readonly<Record<string, string>>;
157
- export declare const HOUSE_APP_BATCHES: Readonly<Partial<Record<string, readonly string[]>>>;
158
- export declare function houseConversationAgents(locator: string): ConversationAgents;
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 function rewrittenInTurn(...rewrites: readonly Rewrites[]): Rewrites;
159
12
  export declare function declaredActions(routes: readonly string[]): readonly ActionDeclaration[];
160
13
  export declare function houseAction(transport: HouseActDoor, request: ActionRequest): Promise<ActionResult>;
161
- export declare function actionOutcome(answer: HouseDoorAnswer, name: string): ActionResult;
162
- type HistoryCursor = {
163
- accepted_at: string;
164
- message_id: string;
165
- };
166
- export declare function cursorPosition(cursor: HistoryCursor): string;
167
- export declare function acceptedMessage(entry: unknown): AcceptedMessage | null;
14
+ export declare function actionOutcome(answer: HouseDoorAnswer, name: string, input: unknown): ActionResult;
168
15
  export {};
169
- //# sourceMappingURL=actions.d.ts.map
@@ -1 +1 @@
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,CA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AAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,YAAY,CAajG"}
package/dist/actions.js CHANGED
@@ -1,74 +1,121 @@
1
- import { changeBatchIdentity, HISTORY_CONVERSATIONS, } from '@agentshouse/mdruntime';
2
- import { doorRefusal } from './refusal.js';
3
- export const HISTORY_PAGE = 100;
4
- function mapped(door, input = (given) => given) {
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
+ '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;
5
40
  return {
6
- door,
7
- async carry(transport, given, name) {
8
- return actionOutcome(await transport.door(`/door/${door}`, input(given)), name);
9
- },
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
+ }),
10
48
  };
11
49
  }
12
- function carried(door, carry, batched) {
13
- return {
14
- door,
15
- ...(batched === undefined ? {} : { batched }),
16
- carry: (transport, input, name) => carry(transport, `/door/${door}`, input, name),
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
+ ]);
63
+ function held(input) {
64
+ return typeof input === 'object' && input !== null
65
+ ? { ...input }
66
+ : {};
67
+ }
68
+ function created(input) {
69
+ return { op: 'create', ...held(input) };
70
+ }
71
+ function uploaded(input) {
72
+ const { app_ref: app, ...files } = held(input);
73
+ return { op: 'publish', app, ...files };
74
+ }
75
+ function decided(op) {
76
+ return (input) => ({ op, ...held(input) });
77
+ }
78
+ function roomNamed(op) {
79
+ return (input) => {
80
+ const { room_ref: room, ...named } = held(input);
81
+ return { op, room, ...named };
17
82
  };
18
83
  }
19
- const APP_ACTS = {
20
- 'access.read': mapped('rooms/access/read'),
21
- 'conversation.answer': mapped('conversations/interaction/answer', answerBody),
22
- 'conversation.create': carried('conversations/create', createAction),
23
- 'conversation.delete': mapped('conversations/delete', controlBody),
24
- 'conversation.history': carried('conversations/history', historyAction, ['conversations']),
25
- 'conversation.interrupt': mapped('conversations/interrupt', controlBody),
26
- 'conversation.kill': mapped('conversations/kill', controlBody),
27
- 'conversation.markDone': mapped('conversations/done'),
28
- 'conversation.rename': mapped('conversations/rename'),
29
- 'conversation.retry': mapped('conversations/retry'),
30
- 'conversation.send': carried('conversations/send', sendAction),
31
- 'conversation.setOption': mapped('conversations/option'),
32
- 'feature.list': mapped('apps/features/read'),
33
- 'holder.list': mapped('apps/holders'),
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'),
38
- 'member.list': mapped('rooms/members'),
39
- 'message.send': mapped('apps/messages/send'),
40
- 'processing.read': mapped('rooms/settings/processing/read'),
41
- 'record.list': mapped('records/read'),
42
- 'relay.read': mapped('apps/relay'),
43
- 'routine.list': mapped('routines/access'),
44
- 'routineAccess.list': mapped('routines/granted'),
45
- 'routineAllowance.list': mapped('routines/allowance'),
46
- 'routineRequest.list': mapped('routines/requests'),
47
- 'storage.read': mapped('storage/inventory'),
48
- 'triggerEvent.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
- }
84
+ export const HOUSE_REWRITTEN_UNTIL_2026_12_21 = new Map([
85
+ ['apps/create', created],
86
+ ['apps/upload', uploaded],
87
+ ['shares/accept', decided('share_accept')],
88
+ ['shares/decline', decided('share_decline')],
89
+ ['shares/join-requests/approve', decided('join_request_approve')],
90
+ ['shares/join-requests/decline', decided('join_request_decline')],
91
+ ['rooms/ownership/offer', roomNamed('ownership_offer')],
92
+ ['rooms/ownership/accept', decided('ownership_accept')],
93
+ ['rooms/ownership/decline', decided('ownership_decline')],
94
+ ['rooms/instructions/follow', roomNamed('instructions_follow')],
95
+ ['update', withCurrentOps],
96
+ ]);
97
+ export function rewrittenInTurn(...rewrites) {
98
+ const names = new Set(rewrites.flatMap((each) => [...each.keys()]));
99
+ return new Map([...names].map((name) => [
100
+ name,
101
+ (input) => rewrites.reduce((held, each) => each.get(name)?.(held) ?? held, input),
102
+ ]));
103
+ }
104
+ const ROOM_SELECTORS = new Map([
105
+ ['update', { room: 'changes.room', roomPaths: ['changes.path', 'changes.to', 'paths', 'mount'] }],
106
+ ['sharing', { room: 'room' }],
107
+ ['sharing_update', { room: 'room' }],
108
+ ['inbox_update', { room: 'room', roomPaths: ['path'] }],
109
+ ]);
60
110
  export function declaredActions(routes) {
61
- return routes.map((route) => {
62
- const name = APP_NAMES.get(route) ?? route;
63
- return { name, inputShape: {}, resultKind: 'house', room: 'room_ref' };
64
- });
111
+ return routes.map((name) => ({
112
+ name,
113
+ inputShape: {},
114
+ resultKind: 'house',
115
+ ...(ROOM_SELECTORS.get(name) ?? { room: 'room_ref' }),
116
+ }));
65
117
  }
66
118
  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
119
  const route = routeOf(request.name);
73
120
  if (route === null)
74
121
  return Promise.resolve(malformed());
@@ -85,182 +132,37 @@ function routeOf(name) {
85
132
  return null;
86
133
  }
87
134
  }
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
135
  function malformed() {
99
136
  return { kind: 'rejected', code: 'invalid_request', fields: {}, retryable: false };
100
137
  }
101
138
  function unimplemented(name) {
102
139
  return { kind: 'rejected', code: 'action-unimplemented', fields: { name }, retryable: false };
103
140
  }
104
- function createBody(input) {
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
- };
111
- }
112
- function controlBody(input) {
113
- return { conversation_id: text(input, 'conversation'), operation_id: operationId(input) };
141
+ function numbered(input) {
142
+ return typeof input?.operation_id === 'string';
114
143
  }
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
- };
123
- }
124
- async function createAction(transport, route, input, name) {
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) {
144
+ export function actionOutcome(answer, name, input) {
145
145
  if (answer.status === 401)
146
146
  return { kind: 'revoked-authorization' };
147
147
  const refusal = doorRefusal(answer.body);
148
- if (refusal?.code === 'operation_contended')
149
- return { kind: 'transport-uncertainty' };
150
- if (refusal !== null)
151
- return { kind: 'rejected', ...refusal };
148
+ if (refusal?.code === 'operation_contended' && numbered(input))
149
+ return refusedFor(refusal);
150
+ if (refusal !== null) {
151
+ const reset = resetOf(refusal);
152
+ return { kind: 'rejected', ...refusal, ...(reset === undefined ? {} : { reset }) };
153
+ }
152
154
  if (answer.status === 404)
153
155
  return unimplemented(name);
154
- if (answer.status === 0 || answer.status >= 400)
155
- return { kind: 'transport-uncertainty' };
156
+ if (answer.status === 0 || answer.status >= 400) {
157
+ return answeredFailure(answer.status, answer.body);
158
+ }
156
159
  return { kind: 'action', result: answer.body };
157
160
  }
158
161
  async function carry(transport, route, name, input) {
159
- return actionOutcome(await transport.door(route, input), name);
160
- }
161
- function sendBody(input) {
162
- const operation = text(input, 'operation_id');
163
- const said = text(input, 'text');
164
- if (operation === undefined || said === undefined)
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
- export function cursorPosition(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: cursorPosition(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: cursorPosition(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 };
162
+ const answered = actionOutcome(await transport.door(route, input), name, input);
163
+ const renamed = renamedHandle(answered);
164
+ if (renamed === null)
165
+ return answered;
166
+ const moved = movedPaths(input, ROOM_SELECTORS.get(name)?.roomPaths ?? [], renamed);
167
+ return actionOutcome(await transport.door(route, moved), name, moved);
266
168
  }
package/dist/adapter.d.ts CHANGED
@@ -8,4 +8,3 @@ export type AgentsHouseAdapterOptions = {
8
8
  snapshot?: boolean;
9
9
  };
10
10
  export declare function createAgentsHouseAdapter(options: AgentsHouseAdapterOptions): Adapter;
11
- //# sourceMappingURL=adapter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,OAAO,EAGP,aAAa,EAed,MAAM,wBAAwB,CAAC;AA2BhC,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAmBxB,MAAM,MAAM,yBAAyB,GACjC;IACE,SAAS,EAAE,cAAc,CAAC;IAC1B,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;CACrC,GACD;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AA6DrD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CA6ZpF"}
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;AAmChC,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,CA8cpF"}