@agentshouse/mdruntime-adapter 0.1.0-c506c7d6e6199 → 0.1.0-c50b979d9313f

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 (49) hide show
  1. package/AGENTS.md +177 -86
  2. package/README.md +3 -3
  3. package/dist/actions.d.ts +62 -2
  4. package/dist/actions.d.ts.map +1 -1
  5. package/dist/actions.js +148 -122
  6. package/dist/adapter.d.ts.map +1 -1
  7. package/dist/adapter.js +220 -154
  8. package/dist/discovery.d.ts +5 -12
  9. package/dist/discovery.d.ts.map +1 -1
  10. package/dist/discovery.js +31 -36
  11. package/dist/gather.d.ts +1 -0
  12. package/dist/gather.d.ts.map +1 -1
  13. package/dist/gather.js +11 -6
  14. package/dist/handed.d.ts +15 -0
  15. package/dist/handed.d.ts.map +1 -0
  16. package/dist/handed.js +38 -0
  17. package/dist/index.d.ts +2 -1
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +1 -0
  20. package/dist/model.d.ts +7 -18
  21. package/dist/model.d.ts.map +1 -1
  22. package/dist/model.js +60 -39
  23. package/dist/read.d.ts +15 -7
  24. package/dist/read.d.ts.map +1 -1
  25. package/dist/read.js +90 -86
  26. package/dist/referrer.d.ts +7 -0
  27. package/dist/referrer.d.ts.map +1 -0
  28. package/dist/referrer.js +35 -0
  29. package/dist/refusal.d.ts +5 -9
  30. package/dist/refusal.d.ts.map +1 -1
  31. package/dist/refusal.js +31 -17
  32. package/dist/site.d.ts.map +1 -1
  33. package/dist/site.js +156 -92
  34. package/dist/stream.d.ts +9 -4
  35. package/dist/stream.d.ts.map +1 -1
  36. package/dist/stream.js +226 -78
  37. package/dist/transport.d.ts +61 -22
  38. package/dist/transport.d.ts.map +1 -1
  39. package/dist/transport.js +3 -1
  40. package/dist/version.d.ts +1 -0
  41. package/dist/version.d.ts.map +1 -1
  42. package/dist/version.js +9 -0
  43. package/dist/write.d.ts +2 -1
  44. package/dist/write.d.ts.map +1 -1
  45. package/dist/write.js +91 -13
  46. package/package.json +3 -4
  47. package/dist/links.d.ts +0 -12
  48. package/dist/links.d.ts.map +0 -1
  49. package/dist/links.js +0 -66
package/AGENTS.md CHANGED
@@ -1,16 +1,24 @@
1
1
  # Instructions for the App Creator's agent
2
2
 
3
- These instructions address an agent in an environment with Git. Obtain the
4
- App Repository, change it, build, and push. They are documentation, not
5
- enforcement.
3
+ These instructions address an agent in an environment with Git. Obtain the App
4
+ Repository, change it, build, and push. They are documentation, not enforcement.
6
5
 
7
6
  ## The MD Runtime API
8
7
 
9
8
  App code reaches the MD Runtime through the remote client. The surfaces are
10
- Rooms, Query, Search, Observe, Types, Room Draft, Save, History, Call, Reached, Log,
11
- the reported persistence answer, reauthorization, conversation, the chat draft,
12
- and Presentation State. Sync Status, the Service Mode, the storage-loss
13
- statement and the deployment facts are observations only.
9
+ Rooms, Query, Search, Observe, Types, Room Draft, Save, History, the binary file
10
+ reads, Call, Reached, Log, the reported persistence answer, reauthorization,
11
+ conversation, the chat draft, and Presentation State. Sync Status, the Service
12
+ Mode, the storage-loss statement, the deployment facts and the signed-in member
13
+ are observations only.
14
+
15
+ The host attaches each port with its reach, and every member and observation
16
+ answers within it: a Room outside it answers as one the replica does not hold,
17
+ Rooms lists only the Rooms reached whole, a Room reached for single Documents
18
+ shows only those Documents and the Types of the models that govern them, and
19
+ without conversations the conversation members, the chat draft and the
20
+ conversation observation hold none. A change of the reach reaches every open
21
+ observation as its new value, a query keeping unchanged Documents the same objects.
14
22
 
15
23
  Every `observe` resolves, once its first value has arrived, to a handle:
16
24
  `current()` is the latest complete value, `subscribe(listener)` hears each later
@@ -18,44 +26,73 @@ value whole and returns its unsubscribe, and `close()` ends the observation.
18
26
  Closing the port ends every handle and rejects every pending call and
19
27
  observation; a client that reconnects observes again.
20
28
 
21
- Each conversation a Provider card names is held complete in the browser.
22
- Observe one with `observe('conversation', id, { limit })`: the view
23
- holds its latest `limit` messages, or all of them, oldest first, its chat
24
- draft, and what the Provider streams for it whether or not anything views it:
25
- the growing text and plan of the running turn, the open questions, the process
26
- state, the CLI's commands and options, and the latest `workingNote`. These live
27
- only in memory: the turn's accepted message replaces its growing text and plan,
28
- a working note is never part of a message, and none of them is stored or
29
- searchable.
30
- `chatDraft.write` and `chatDraft.discard` keep what the App Creator composes;
31
- sending it is a Provider Action that needs the Provider reachable and is never
32
- queued.
33
-
34
- Each Room in Rooms lists its `attachments`, the files the Provider holds for it
35
- that its Documents link by the Provider's reference, ordered by `reference`,
36
- each with `name`, `byteLength`, `mediaType` and the Provider's own entry as
37
- `entry`. They are as the Provider last declared them and hold no bytes;
38
- open one through the Provider Action that serves it.
29
+ `observe('agents')` answers every Agent a new conversation can go to, each
30
+ `{ identity, name }`, whether or not it has a conversation yet. Each conversation
31
+ the Provider's conversation list names is held complete in the browser.
32
+ `conversation.list()` and `observe('conversations')` answer each with its Agent's
33
+ identity and name, its name, created and finished times, last outcome and live
34
+ `state`: `asking` while a question waits, `working` while a turn runs, else
35
+ `idle`, and `started`, when the running turn began, or `null`. Observe one with
36
+ `observe('conversation', id, { limit })`: the view holds its latest `limit`
37
+ messages, or all of them, oldest first, its chat draft, and what the Provider
38
+ streams for it whether or not anything views it: the running `turn` with its
39
+ message parts and its context in use and window, the open questions, the process
40
+ state, and the CLI's commands and options. These live only in memory: the
41
+ message accepted under the turn's id replaces the running turn, and none of them
42
+ is stored or searchable. `chatDraft.write` and `chatDraft.discard` keep what the
43
+ App Creator composes; sending it is a Provider Action that needs the Provider
44
+ reachable and is never queued.
45
+
46
+ A binary file at a Path is a binary Path entry. Query lists it by `path`, and
47
+ History each of its revisions, with its `binaryFile` record and never its bytes:
48
+ `{ state: 'accepted', revision, path, fileRef, byteLength, mediaType, sha256 }`,
49
+ or, from a Save until the Provider accepts it, `{ state: 'pending', localId,
50
+ path, byteLength, mediaType, sha256 }`. Write one with a Room Draft whose only
51
+ part is `file: { blob }`, the `Blob`'s `type` its media type: Save keeps the
52
+ bytes in its Pending Change, offline too, and acceptance gives the record the
53
+ Provider's revision. Move or remove one as a Document, a pending one before or
54
+ after Save too, its bytes following; once its Pending Change has gone to the
55
+ Provider, Save refuses that as `unknown-revision` until it is accepted.
56
+ `binaryFile.read(room, path, revision?)` answers a pending record's saved bytes,
57
+ or asks the Provider again on every read of an accepted one or of a History
58
+ revision, a removed file's last included, keeping nothing. Text, a Record
59
+ attachment or a conversation message may name a file by its `fileRef`; read it
60
+ with `binaryFile.readReference({ fileRef, referrer })`, the referrer being the
61
+ `referrer` the Provider gave beside it, or `{ room, path }` of the document whose
62
+ text names it. Both answer `{ kind: 'binary', blob }` or a refusal or failure.
39
63
 
40
64
  Rooms, Query, Search, Observe, Types, Room Draft, Save, and Reached never
41
- touch the network.
42
- History and Call go to the Provider through the Adapter. A Call result whose
65
+ touch the network. History, the binary file reads and Call go to the Provider
66
+ through the Adapter. Call takes the Action names the Adapter declares; any other
67
+ name answers `undeclared` without reaching the Provider. A Call result whose
43
68
  effect the Provider places in a Room carries `at`, that Room and Room Version;
44
69
  `reached(room, roomVersion)` answers whether the Room's confirmed state has
45
70
  reached it, and the MD Runtime keeps refreshing that Room until it has;
46
71
  `reached(room, roomVersion, path)` answers whether the held confirmed copy of
47
72
  that document was written at a later Room Version. Each History revision
48
- names its author, `{ kind: 'user', id }` or `{ kind: 'site', id, name }`. Every
49
- member of the
50
- client is asynchronous. Results are detached snapshots. Nothing in this
51
- surface returns the authorization, performs a request the App's code
52
- composes, or exposes the browser store.
73
+ names its author, `{ kind: 'user', id }` or `{ kind: 'site', id, name }`.
74
+ History of a Path no current document holds answers the removed document's
75
+ revisions with `deleted: true`, newest first; that revision is what a link to
76
+ the Path opens. Every member of the client is asynchronous. Results are
77
+ detached snapshots. Nothing in this surface returns the authorization, performs
78
+ a request the App's code composes, or exposes the browser store.
53
79
 
54
- Read the deployment facts with `observe('deployment-facts')`. Interpret the
55
- opaque value using the host's contract.
80
+ Every refusal and failure carries `code` and `retryable`: each Call and History
81
+ answer other than its result, a refused Save or Room Draft write, a returned Room
82
+ Draft's reason, a Room's refusal and the Connection Refusal, and every error a
83
+ member rejects with, beside its message. A Provider refusal carries the
84
+ Provider's own `retryable`. Every code and every value the API answers is open:
85
+ handle one you do not know by its `code` and `retryable`.
56
86
 
57
- The in-memory Adapter at `@agentshouse/mdruntime/memory` is for tests and
58
- ships in no bundle.
87
+ Read the deployment facts with `observe('deployment-facts')`, an opaque value
88
+ the host's contract interprets. `observe('member')` answers who uses the App:
89
+ the User the Provider signed in, `{ kind: 'user', id, name }` in the shape of a
90
+ change's `author`, so a Document whose `change.author.id` equals its `id` is that
91
+ User's own. It is `null` until the Provider first names one, and where it names
92
+ none, such as a Site. The MD Runtime keeps it with the Local Replicas, so it
93
+ answers offline once known, and every port hears the next member the Provider
94
+ names; signing out answers `null`, then ends the observation with the
95
+ authorization. It is the only way App code learns who uses it.
59
96
 
60
97
  ## Local Query rules
61
98
 
@@ -67,51 +104,56 @@ data:
67
104
  - **Filter.** `rooms` names Room locators and defaults to every Room. `types`
68
105
  names MD Types, and `any` names untyped Markdown Documents. `pathPrefix` is a
69
106
  directory: `notes` keeps `notes/a.md` and not `notes2/a.md`.
70
- - **Fields.** `where` names frontmatter fields, ANDs them, and nests `$and` and
71
- `$or`. A bare value is equality; the operators are `$eq`, `$ne`, `$in`, `$nin`,
72
- `$gt`, `$gte`, `$lt`, `$lte`, `$all`, `$size` and `$exists`. Equality on a list
73
- asks whether it contains the value. Missing, null and empty differ:
74
- `$exists: false` keeps a missing field, `null` an explicit null, `''` empty
75
- text and `$size: 0` an empty list. A date compares in calendar order and never
76
- with a date-time. A reference compares by the Room Path it resolves to.
77
- Untyped frontmatter is plain values. There is no text containment or regular
78
- expression.
107
+ - **Fields.** Every frontmatter value is named by JSON Pointer: `/status`,
108
+ `/shipping/city`, `~1` for a `/` and `~0` for a `~` in a key. A segment that
109
+ meets a list applies to every item and a number names one item. `where` names
110
+ pointers, ANDs them, and nests `$and` and `$or`; a pointer through a list holds
111
+ when any item satisfies it. A bare value is equality; the operators are `$eq`,
112
+ `$ne`, `$in`, `$nin`, `$gt`, `$gte`, `$lt`, `$lte`, `$all`, `$size` and
113
+ `$exists`. Equality on a list asks whether it contains the value. Missing,
114
+ null and empty differ: `$exists: false` keeps a missing field, `null` an
115
+ explicit null, `''` empty text and `$size: 0` an empty list. A date compares
116
+ in calendar order and never with a date-time. A reference compares by the Room
117
+ Path it resolves to. Untyped frontmatter, and a value under `oneOf` or a
118
+ conditional, is plain values. There is no text containment or regular expression.
79
119
  - **Relations.** `hop: { field, types, where, pathPrefix }` keeps Documents whose
80
- reference `field` points to a matching Document of the same Room.
81
- `backlinks: { field, types, where, pathPrefix }` keeps Documents that a
120
+ reference at pointer `field`, at any depth, points to a matching Document of the
121
+ same Room. `backlinks: { field, types, where, pathPrefix }` keeps Documents that a
82
122
  matching Document of the same Room references. Each keeps a Document once.
83
123
  - **Parts.** A Document query must `select`: `'all'`, or `fields`, `sections`,
84
- `preamble`, `markdown`, `backlinks` and `change`, where `fields` and `sections`
85
- are `'all'` or a list of names. Room and Path always return; a Markdown
86
- Document also returns its MD Type. A non-Markdown Document or binary link
87
- target returns only Room and Path. An unselected part is absent. Select only
124
+ `preamble`, `markdown`, `backlinks` and `change`, where `fields` is `'all'` or a
125
+ list of pointers and `sections` `'all'` or a list of names. Selected pointers
126
+ return the frontmatter holding only them, nested as written. A backlink names
127
+ the referring Path, MD Type and the pointer it came from as `field`. Room and Path always return; a Markdown
128
+ Document also returns its MD Type. A non-Markdown Document returns only Room
129
+ and Path, and a binary Path entry Room, Path and its `binaryFile` record,
130
+ whatever is selected. An unselected part is absent. Select only
88
131
  what a screen shows: a list that selects the Markdown hears every edit of it.
89
132
  - **Change.** `change` is `{ author, time }` of the Document's head revision as
90
133
  the Provider last delivered it: `author` is `{ kind: 'user' | 'site', id, name }`
91
134
  or `null` for a write the Provider made itself, and `time` is the Provider's
92
135
  ISO 8601 change time. It is `null` where the Provider delivered no time, as at
93
136
  a Site. An unsent edit or move keeps it, an unsent creation has none, and a
94
- saved write takes the Provider's own once it is Accepted and refreshed. A
137
+ saved write takes the Provider's own once it is Accepted. A
95
138
  Room's last change is its Document with the latest `time`.
96
139
  - **Order and groups.** `orderBy` sorts by `room`, `path`, `type` or `{ field }`
97
140
  with TanStack DB's own options, and ties end with Room, then Path. `groupBy` by
98
141
  `room`, `type` or `{ field }` answers `{ groups: [{ key, count }] }`, counted
99
- over every match and ordered by `count` or a key. `limit` bounds the Documents
100
- or the groups.
142
+ over every match and ordered by `count` or a key. A sort or group takes only a
143
+ pointer that holds one value. `limit` bounds the Documents or the groups.
101
144
  - **Results and errors.** A result carries no Room Version: read freshness from
102
- Rooms and Sync Status. An invalid query fails with `invalid-query`,
103
- `unknown-type`, `unknown-field` or `wrong-kind`, naming where, and never
104
- answers an empty result in its place.
145
+ Rooms and Sync Status. An invalid query fails with the `code`
146
+ `invalid-query`, `unknown-type`, `unknown-field` or `wrong-kind`, naming where,
147
+ and never answers an empty result in its place.
105
148
 
106
149
  ## Local Search rules
107
150
 
108
151
  `search({ text, documents, conversations, limit })` answers once, by words, from
109
- local state, with MiniSearch at its default configuration. There is no observed
110
- search.
152
+ local state, with MiniSearch's defaults. There is no observed search.
111
153
 
112
154
  - **What is found.** A Document by its field values, its sections' headings and
113
155
  text, its preamble and its Path; a message by its text. Frontmatter keys, Room
114
- Drafts, chat drafts and growing text are never found. There are no phrases,
156
+ Drafts, chat drafts and a running turn's parts are never found. There are no phrases,
115
157
  word forms, typo tolerance or prefix matching.
116
158
  - **Narrowing.** `documents` is a Local Query filter: `rooms`, `types`, `where`,
117
159
  `pathPrefix`, `hop` and `backlinks`. `conversations` names conversations. Both
@@ -125,25 +167,24 @@ search.
125
167
 
126
168
  ## Room Draft, Save, and outcome rules
127
169
 
128
- The MD Runtime owns one Room Draft per Room and Path, shared by every App and
129
- tab. It is durable: it survives reload and navigation. A Room that Discovery
130
- stops listing takes its Room Drafts and its queue with it.
131
- Write a Room Draft with `roomDraft.write(room, path, revision, parts)`, naming
132
- the revision you read, or `null` when there was none, and every part it should
133
- now change: fields, sections and the preamble, or the whole Markdown, a
134
- creation, a move, or a removal. A part new to the Room Draft names its base,
135
- the value you showed when it was opened; the MD Runtime keeps a part's first
136
- base. A binary link target has a Room Draft too, for a move or a removal, with
137
- `null` as its base. A write or a discard from an older revision is refused as `stale` with
138
- the current Room Draft; read it and write again.
170
+ The MD Runtime owns one Room Draft per Room and Path, shared by every App and tab.
171
+ It is durable: it survives reload and navigation. A Room that Discovery stops
172
+ listing takes its Room Drafts and its queue with it. Write a Room Draft with
173
+ `roomDraft.write(room, path, revision, parts)`, naming the revision you read, or
174
+ `null` when there was none, and every part it should now change: fields, sections
175
+ and the preamble, or the whole Markdown, a creation, a move, or a removal. A part
176
+ new to the Room Draft names its base, the value you showed when it was opened; the
177
+ MD Runtime keeps a part's first base; a binary Path entry's move or removal takes
178
+ `null` as its base. A write or a discard from an older revision is refused as
179
+ `stale` with the current Room Draft; read it and write again.
139
180
 
140
181
  Save takes one Room and the Room Drafts of it to save, each with its revision,
141
182
  validates locally, and on success appends one Change Batch to that Room's
142
- queue and removes those Room Drafts. It is refused as `stale`, as
183
+ queue and removes those Room Drafts. It is refused with the `code` `stale`,
143
184
  `changed-underneath` naming each part whose base no longer matches the visible
144
- state, or by a local validation rule, and then creates nothing and leaves every
185
+ state, or a local validation rule, and then creates nothing and leaves every
145
186
  Room Draft in place. A directory move or removal is a move or removal part on
146
- each Document and binary link target beneath it, saved together.
187
+ each Document and binary Path entry beneath it, saved together.
147
188
 
148
189
  Outcomes follow the Provider's answer. An Accepted Change Batch stays in the
149
190
  queue, drawn over the confirmed layer, until the confirmed layer reaches the
@@ -161,12 +202,17 @@ it names; the MD Runtime retries the same Change Batch identity and payload and
161
202
  never infers an outcome from transport uncertainty. The MD Runtime never
162
203
  combines, reorders, or rebases.
163
204
 
164
- `observe('service-mode')` answers the Provider's Service
165
- Mode, `open` or `write-halted`. While writes are halted, Save still succeeds,
166
- its Change Batch waits unsent, and the queue is submitted in order once the
167
- Provider reopens writes. An Action is never held: a write the Provider refuses
168
- for the halt returns that refusal to its caller. Show the Provider as read-only
169
- instead of retrying.
205
+ On a Site, every Save stays in the visitor's browser. Write grants and revisions
206
+ do not refuse it, and its Pending Change shows in every query and across reloads
207
+ until the browser's storage is cleared. It is never sent: `observe('queue', room)`
208
+ shows it `local`, and Sync Status never waits on it. Once the Room changes so that
209
+ it no longer applies, it leaves the queue and returns no Room Draft.
210
+
211
+ `observe('service-mode')` answers the Provider's Service Mode, `open` or
212
+ `write-halted`. While writes are halted, Save still succeeds, its Change Batch
213
+ waits unsent, and the queue is submitted in order once the Provider reopens
214
+ writes. An Action is never held: a write the Provider refuses for the halt returns
215
+ that refusal to its caller. Show the Provider as read-only instead of retrying.
170
216
 
171
217
  ## The neutrality rule
172
218
 
@@ -194,13 +240,58 @@ an App's override respected. What an App Creator's agent adds carries none
194
240
  of these promises by itself. Reading, querying and searching never wait for
195
241
  the network. Data lives only in the App Creator's browser and with the Provider.
196
242
 
197
- ## App code imports only the client entry and never constructs a Runtime
243
+ ## App code takes the client its host hands it and never constructs a Runtime
244
+
245
+ App code takes the client its host hands it: in House, `houseBridge().runtime`
246
+ from `@agentshouse/app-bridge` resolves to the client House built into the page.
247
+ It imports only types from `@agentshouse/mdruntime/client`, never calls
248
+ `connectMdRuntime` or `serveMdRuntime`, and never imports the package main, the
249
+ host entry or the Adapter package, which hosts and tests use. The in-memory
250
+ Adapter at `@agentshouse/mdruntime/memory` is for tests and ships in no bundle.
251
+ A Site's page fills its Entry Data Contract's `{"$param": name}` arguments with
252
+ `boundQuery` from `@agentshouse/mdruntime/entry`, as House did for its HTML.
253
+
254
+ A React App may observe and save through `@agentshouse/mdruntime/react`, which
255
+ names React as a peer dependency. `useObserve(client, topic, ...input)` takes
256
+ the arguments of `observe` and returns `{ state: 'loading' }` until the topic's
257
+ first value arrives, then `{ state: 'ready', value }`, re-rendering on each
258
+ change; a `null` client observes nothing and stays loading. `useSave(client)`
259
+ returns `busy`, the last `outcome` or `failure`, and `save(room, roomDrafts)`,
260
+ which writes each Path's parts onto the Room Draft already there, keeping the
261
+ bases its parts have, or onto a new one, and saves them together. A refused
262
+ Save leaves the Room Drafts for the App to save again or discard; a failure is
263
+ recorded and rejects. `saveRoomDrafts(client, room, roomDrafts)` is that save
264
+ outside a component. A react-admin or Refine App reads and writes its Rooms
265
+ through the data providers of `@agentshouse/mdruntime-families`.
266
+
267
+ ## The Chat
268
+
269
+ `@agentshouse/mdruntime/chat` holds the Chat, one data layer for every App; add
270
+ React as a dependency in any App, with React DOM and `@assistant-ui/react`.
271
+
272
+ Place the ready chat with `<Chat client={runtime} conversation={id}
273
+ agent={agent} width="1/3" showChats />`: `conversation` opens one, `null` for a
274
+ new chat, `agent` is the Agent a new chat goes to, `onOpen` hears each one it
275
+ opens, and `width` is `full` (the place you give it), or `3/4`, `1/2` or `1/3`
276
+ of the window docked at its right edge, whole on a narrow window. `showChats`
277
+ adds its conversation list; or draw your own inside a `ChatProvider` around a
278
+ `<Chat />` with no `client`. It carries its own styles; theme it with CSS custom
279
+ properties on it or an ancestor: `--chat-background`, `--chat-surface`,
280
+ `--chat-text`, `--chat-text-muted`, `--chat-accent`, `--chat-line`,
281
+ `--chat-attention`, `--chat-danger`, `--chat-font`, `--chat-font-mono`,
282
+ `--chat-font-size`, `--chat-radius` and `--chat-density` (a factor for spacing);
283
+ an unset one keeps House's light or dark look. `mountChat(element, { client })`
284
+ places it outside React and returns `update(props)` and `unmount()`.
198
285
 
199
- App code imports only `@agentshouse/mdruntime/client` and calls
200
- `connectMdRuntime` on the port the host hands it. It never constructs a
201
- Runtime. It does not import the package main, the host entry, or the Adapter
202
- package, and it does not call `serveMdRuntime`. Hosts
203
- and tests use those entries; the served App does not.
286
+ Mix `ChatMessageList` (`components` takes your `UserMessage` and
287
+ `AssistantMessage`), `ChatInput` and `ChatQuestionCard` with your own design
288
+ inside a `ChatProvider`, or compose assistant-ui's primitives there; `useChat()`
289
+ gives `send`, the conversations, the Agents, questions to `answer`, `options`
290
+ to `choose`, `commands`, the queue to `edit` or `unqueue`, `stop`, `kill` and
291
+ outcomes; never replace its messages, sending or store. A secret question is
292
+ never answered here; typed answers live in Presentation State's `typed` key:
293
+ keep it, and change Presentation State only inside `inTurn(client, work)` from
294
+ `@agentshouse/mdruntime/client`. `Markdown` draws Markdown safely.
204
295
 
205
296
  ## What an agent must never do
206
297
 
package/README.md CHANGED
@@ -19,12 +19,12 @@ import { serveMdRuntime } from '@agentshouse/mdruntime/host';
19
19
  import { createAgentsHouseAdapter } from '@agentshouse/mdruntime-adapter';
20
20
 
21
21
  const adapter = createAgentsHouseAdapter({ transport, authorize });
22
- const host = serveMdRuntime({ adapter, shell, requiredGuarantees: [] });
22
+ const host = serveMdRuntime({ adapter, shell });
23
23
  host.attach(port, 'my-app');
24
24
  ```
25
25
 
26
- App code never imports this package; it reaches the Runtime only through
27
- `@agentshouse/mdruntime/client`. The rules an App's agent follows are in the
26
+ App code never imports this package; it reaches the Runtime only through the
27
+ client its host hands it. The rules an App's agent follows are in the
28
28
  package's `AGENTS.md`.
29
29
 
30
30
  ## License
package/dist/actions.d.ts CHANGED
@@ -1,8 +1,68 @@
1
- import { type AcceptedMessage, type ActionDeclaration, type ActionRequest, type ActionResult, type ConversationCards } from '@agentshouse/mdruntime';
1
+ import { type AcceptedMessage, type ActionDeclaration, type ActionRequest, type ActionResult, type ConversationAgents, type ConversationHistories, type ConversationHistoryRequest, type FileDeclaration } from '@agentshouse/mdruntime';
2
2
  import type { HouseDoorAnswer, HouseTransport } from './transport.js';
3
- export declare const HOUSE_CONVERSATION_CARDS: ConversationCards;
3
+ type Operated = {
4
+ readonly operation_id?: string;
5
+ };
6
+ type ConversationControl = Operated & {
7
+ readonly conversation: string;
8
+ };
9
+ type SentFile = FileDeclaration & {
10
+ readonly blob: Blob;
11
+ };
12
+ export type AppInputs = {
13
+ readonly 'conversation.answer': ConversationControl & {
14
+ readonly answer: {
15
+ readonly interaction_id: string;
16
+ readonly response: unknown;
17
+ };
18
+ };
19
+ readonly 'conversation.create': Operated & {
20
+ readonly agent_id: 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 text?: string;
28
+ readonly files?: readonly SentFile[];
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
+ readonly 'record.list': {
42
+ readonly attachments: readonly {
43
+ readonly referrer: {
44
+ readonly room_ref: string;
45
+ readonly record: string;
46
+ };
47
+ }[];
48
+ readonly records: readonly {
49
+ readonly attachments: readonly {
50
+ readonly referrer: {
51
+ readonly room_ref: string;
52
+ readonly record: string;
53
+ };
54
+ }[];
55
+ }[];
56
+ };
57
+ };
58
+ export declare const HOUSE_APP_ACTS: Readonly<Record<string, string>>;
59
+ export declare const SITE_SUBMIT = "submit";
60
+ export declare const HOUSE_SITE_ACTS: Readonly<Record<string, string>>;
61
+ export declare const HOUSE_APP_BATCHES: Readonly<Partial<Record<string, readonly string[]>>>;
62
+ export declare function houseConversationAgents(locator: string): ConversationAgents;
4
63
  export declare function declaredActions(routes: readonly string[]): readonly ActionDeclaration[];
5
64
  export declare function houseAction(transport: HouseTransport, request: ActionRequest): Promise<ActionResult>;
6
65
  export declare function actionOutcome(answer: HouseDoorAnswer, name: string): ActionResult;
7
66
  export declare function acceptedMessage(entry: unknown): AcceptedMessage | null;
67
+ export {};
8
68
  //# sourceMappingURL=actions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAA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