@agentshouse/mdruntime-adapter 0.1.0-ca764edcceec6 → 0.1.0-ca80960fd750d

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 (48) hide show
  1. package/AGENTS.md +118 -105
  2. package/dist/actions.d.ts +14 -21
  3. package/dist/actions.d.ts.map +1 -1
  4. package/dist/actions.js +84 -133
  5. package/dist/adapter.d.ts.map +1 -1
  6. package/dist/adapter.js +235 -169
  7. package/dist/discovery.d.ts +4 -3
  8. package/dist/discovery.d.ts.map +1 -1
  9. package/dist/discovery.js +28 -10
  10. package/dist/gather.d.ts +1 -1
  11. package/dist/gather.d.ts.map +1 -1
  12. package/dist/gather.js +4 -14
  13. package/dist/index.d.ts +4 -2
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +3 -1
  16. package/dist/model.d.ts +5 -1
  17. package/dist/model.d.ts.map +1 -1
  18. package/dist/model.js +8 -1
  19. package/dist/part.d.ts +15 -0
  20. package/dist/part.d.ts.map +1 -0
  21. package/dist/part.js +82 -0
  22. package/dist/read.d.ts +57 -26
  23. package/dist/read.d.ts.map +1 -1
  24. package/dist/read.js +268 -152
  25. package/dist/room-types.d.ts +6 -0
  26. package/dist/room-types.d.ts.map +1 -0
  27. package/dist/room-types.js +83 -0
  28. package/dist/site.d.ts.map +1 -1
  29. package/dist/site.js +78 -105
  30. package/dist/stream.d.ts +5 -5
  31. package/dist/stream.d.ts.map +1 -1
  32. package/dist/stream.js +60 -38
  33. package/dist/transport.d.ts +25 -15
  34. package/dist/transport.d.ts.map +1 -1
  35. package/dist/transport.js +1 -1
  36. package/dist/upload.d.ts +12 -0
  37. package/dist/upload.d.ts.map +1 -0
  38. package/dist/upload.js +63 -0
  39. package/dist/write.d.ts +12 -1
  40. package/dist/write.d.ts.map +1 -1
  41. package/dist/write.js +92 -55
  42. package/package.json +3 -3
  43. package/dist/handed.d.ts +0 -15
  44. package/dist/handed.d.ts.map +0 -1
  45. package/dist/handed.js +0 -38
  46. package/dist/referrer.d.ts +0 -7
  47. package/dist/referrer.d.ts.map +0 -1
  48. package/dist/referrer.js +0 -35
package/AGENTS.md CHANGED
@@ -5,8 +5,8 @@ change it, build, and push. They are documentation, not enforcement.
5
5
 
6
6
  ## The MD Runtime API
7
7
 
8
- App code reaches the MD Runtime through the remote client. The surfaces are Rooms,
9
- Query, Search, Observe, Types, Room Draft, Save, History, the binary file reads, Call,
8
+ App code reaches the MD Runtime through the remote client. The surfaces are Rooms, Query,
9
+ Search, Observe, Types, Room Draft, Save, History, Resolve, the binary file reads, Call,
10
10
  Reached, Log, the reported persistence answer, reauthorization, conversation, the chat
11
11
  draft, and Presentation State. Sync Status, readiness, the Service Mode, the storage-loss
12
12
  statement, the deployment facts and the signed-in member are observations only.
@@ -35,7 +35,8 @@ only in memory, what the Provider streams whether or not anything views it: the
35
35
  `turn` with its parts and its context in use and window, which the message accepted under
36
36
  the turn's id replaces, the open questions, the process state, and the CLI's commands and
37
37
  options, none stored or searchable. `chatDraft.write` and `chatDraft.discard` keep what
38
- the App Creator composes; sending it is a Provider Action that needs the Provider
38
+ the App Creator composes, and `chatDraft.prepend(conversation, draft)` puts a returned
39
+ message ahead of it as it stands. Sending it is a Provider Action that needs the Provider
39
40
  reachable and is never queued. A new conversation's chat draft is keyed `new:<Agent
40
41
  identity>`: no conversation list removes it, a retired Agent's goes, and the first answer
41
42
  to `conversation.create({ agent_id, operation_id })` moves it to the created conversation,
@@ -51,32 +52,34 @@ change, and no tab sees it then.
51
52
 
52
53
  A binary file at a Path is a binary Path entry. Query lists it by `path`, and History each
53
54
  of its revisions, with its `binaryFile` record and never its bytes: `{ state: 'accepted',
54
- revision, path, fileRef, byteLength, mediaType, sha256 }`, or, from a Save until the
55
+ revision, path, byteLength, mediaType, sha256 }`, or, from a Save until the
55
56
  Provider accepts it, `{ state: 'pending', localId, path, byteLength, mediaType, sha256 }`.
56
57
  Write one with a Room Draft whose only part is `file: { blob }`, the `Blob`'s `type` its
57
58
  media type: Save keeps the bytes in its Pending Change, offline too, and acceptance gives
58
59
  the record the Provider's revision. Move or remove one as a Document, a pending one too,
59
60
  its bytes following; once its Pending Change has gone to the Provider, Save refuses that
60
61
  as `unknown-revision` until it is accepted. `binaryFile.read(room, path, revision?)`
61
- answers a pending record's saved bytes, or asks the Provider on every read of an accepted
62
- one or a History revision, a removed file's last included, keeping nothing. Text, a Record
63
- attachment or a conversation message may name a file by its `fileRef`; read it with
64
- `binaryFile.readReference({ fileRef, referrer })`, the `referrer` the Provider gave beside
65
- it, or `{ room, path }` of the document whose text names it. Both answer
66
- `{ kind: 'binary', blob }` or a refusal or failure.
62
+ answers a pending record's saved bytes, or an accepted one's or a History revision's, a
63
+ removed file's last included: the first read asks the Provider and the browser keeps the
64
+ bytes, and every later read of that revision, offline too, answers them from the browser.
65
+ Text names a file only by a link to its Path. A read answers
66
+ `{ kind: 'binary', stream, byteLength, mediaType }`, the bytes a `ReadableStream`
67
+ of parts of at most a mebibyte, or a refusal or failure; read the stream to its end, or
68
+ take it whole with `new Response(stream).blob()` where a screen needs one `Blob`.
67
69
 
68
70
  Rooms, Query, Search, Observe, Types, Room Draft, Save, and Reached never touch the
69
- network; History, the binary file reads and Call go to the Provider through the Adapter.
71
+ network; History, a binary file read the browser does not keep yet and Call go to the
72
+ Provider through the Adapter.
70
73
  Call takes the Action names the Adapter declares, any other answering `undeclared`. A Call
71
74
  result whose effect the Provider places in a Room carries `at`, that Room and Room
72
75
  Version: `reached(room, roomVersion)` answers whether the Room's confirmed state has
73
76
  reached it, refreshing the Room until it has, and `reached(room, roomVersion, path)`
74
77
  whether the held copy of that document was written later. A History revision names its
75
- author, `{ kind: 'user', id }` or `{ kind: 'site', id, name }`; History of a Path no
78
+ author, `{ kind: 'user', id }` or `{ kind: 'site' | 'inbox', id, name }`; History of a Path no
76
79
  document holds answers the removed document's revisions, newest first, with `deleted:
77
80
  true`, which a link to the Path opens. Every member is asynchronous and every result a
78
81
  detached snapshot; nothing returns the authorization, performs a request the App's code
79
- composes, or exposes the browser store.
82
+ composes, or exposes the browser store. A Room `rooms` names `locked` shows only online.
80
83
 
81
84
  Every refusal and failure carries `code` and `retryable`: each Call and History answer
82
85
  other than its result, a refused Save or Room Draft write, a returned Room Draft's reason,
@@ -100,8 +103,8 @@ named; signing out answers `null`, then ends the observation with the authorizat
100
103
  hears it again only when it changes, keeping every unchanged Document the same object, so
101
104
  a component can tell what changed by identity. `{ documents, coverage }` or `{ groups,
102
105
  coverage }` is complete for the Rooms its `coverage` names, and `{ pending }` names each
103
- Room not yet acquired or prepared, `[{ room, awaits }]`: never read it as empty, draw it
104
- as loading and observe the query to hear the complete answer. A query is data:
106
+ Room not yet acquired, prepared or unlocked, `[{ room, awaits }]`: never read it as empty,
107
+ draw it as loading and observe the query to hear the complete answer. A query is data:
105
108
 
106
109
  - **Filter.** `rooms` names Room locators and defaults to every Room. `types` names MD
107
110
  Types, and `any` names untyped Markdown Documents. `pathPrefix` is a directory: `notes`
@@ -118,36 +121,41 @@ as loading and observe the query to hear the complete answer. A query is data:
118
121
  compares in calendar order and never with a date-time. A reference compares by the
119
122
  Room Path it resolves to. Untyped frontmatter, and a value under `oneOf` or a
120
123
  conditional, is plain values. There is no text containment or regular expression.
121
- - **Relations.** `hop: { field, types, where, pathPrefix }` keeps Documents whose
122
- reference at pointer `field`, at any depth, points to a matching Document of the same
123
- Room. `backlinks: { field, types, where, pathPrefix }` keeps Documents that a matching
124
- Document of the same Room references. Each keeps a Document once.
124
+ - **Relations.** Within one Room, `hop: { field, types, where, pathPrefix }` keeps Documents
125
+ whose reference at pointer `field`, at any depth, points to a matching Document, and
126
+ `backlinks` with the same keys those a matching Document references, each once. A body
127
+ link or a `cross_room` reference may name another Room's `/rooms/<handle>/<path>`:
128
+ `resolve(room, path, destination)` answers its `document`, the `deleted` one's last
129
+ `revision`, or `unreadable` where the App does not bind it or it is locked.
125
130
  - **Parts.** A Document query must `select`: `'all'`, or `fields`, `sections`,
126
- `preamble`, `markdown`, `backlinks`, `change` and `fileId`, where `fields` is `'all'`
131
+ `preamble`, `markdown`, `backlinks`, `change`, `fileId` and `revision`, where `fields` is `'all'`
127
132
  or a list of pointers and `sections` `'all'` or a list of names. Selected pointers
128
133
  return the frontmatter holding only them, nested as written. A backlink names the
129
134
  referring Path, MD Type and the pointer it came from as `field`. Room and Path always
130
135
  return; a Markdown Document also returns its MD Type, and at most its first 1,000
131
136
  backlinks: a query on the referring field reads the rest. A non-Markdown Document
132
- returns only Room, Path and a selected `fileId`, and a binary Path entry its
133
- `binaryFile` record too. An unselected part is absent. Select only what a screen shows:
134
- a list that selects the Markdown hears every edit of it.
135
- - **Change and file ID.** `change` is `{ author, time }` of the Document's head revision
136
- as the Provider last delivered it: `author` is `{ kind: 'user' | 'site', id, name }`, or
137
+ returns only Room, Path and a selected `fileId` and `revision`, a binary Path entry its `binaryFile`
138
+ record too, and a YAML file under `settings/` its text as a selected `markdown`, kept
139
+ out of Search. An unselected part is absent. Select only what a screen shows: a list
140
+ that selects the Markdown hears every edit of it.
141
+ - **Change, file ID and revision.** `change` is `{ author, time }` of the Document's head revision
142
+ as the Provider last delivered it: `author` is `{ kind: 'user' | 'site' | 'inbox', id, name }`, or
137
143
  `null` for a write the Provider made itself, and `time` its ISO 8601 change time, or the
138
144
  whole change `null` where it delivered no time, as at a Site. `fileId` is the Provider's
139
145
  Stable File ID of the file at the Path, or `null`. An unsent edit keeps both, an unsent
140
146
  move keeps the change and carries the file ID to the new Path, so a file ID that leaves
141
147
  one Path for another is the same file moved, and an unsent creation has neither until it
142
- is Accepted. A Room's last change is its Document with the latest `time`.
143
- - **Order and groups.** `orderBy` sorts by `room`, `path`, `type`, `folder` or `{ field }`
144
- with TanStack DB's own options; ties end with Room, then Path. `groupBy` by `room`,
145
- `type`, `folder` or `{ field }` answers `{ groups: [{ key, count }] }`, counted over every
146
- match and ordered by `count` or a key. A sort or group takes only a single-value pointer.
147
- `limit`, at most 1,000 whatever a query names, bounds the Documents or the groups, and a
148
- result it cuts short names `next`: the same query with it as `after` reads the next
149
- window, in the same order, ties included. `total: true` adds `total`, every match's
150
- count. An observed window hears rows entering, leaving or changing, and `next`, `total`.
148
+ is Accepted. `revision` is the Provider's head revision, `null` for an unsent creation or edit,
149
+ and moves with an unsent move. A Room's last change is its Document with the latest `time`.
150
+ - **Order and groups.** `orderBy` sorts by `room`, `path`, `type`, `folder` or `{ field }`: missing
151
+ and null first, last with `nulls: 'last'`, then numbers and booleans, then text by `locale` or
152
+ code point with `stringSort: 'lexical'`, then lists item by item; ties end with Room, then Path.
153
+ `groupBy` by `room`, `type`, `folder` or `{ field }` answers `{ groups: [{ key, count }] }`,
154
+ counted over every match and ordered by `count` or a key. A sort or group takes only a
155
+ single-value pointer. `limit`, at most 1,000 whatever a query names, bounds the Documents or the
156
+ groups, and a result it cuts short names `next`: the same query with it as `after` reads the next
157
+ window, in the same order, ties included. `total: true` adds `total`, every match's count. An
158
+ observed window hears rows entering, leaving or changing, and `next`, `total`.
151
159
  - **Results and errors.** A result carries no Room Version: read freshness from Rooms and
152
160
  Sync Status. `coverage` names each Room read as `{ room, generation, current }`,
153
161
  `current` false while a newer copy of that Room is being fetched, and the queued changes
@@ -157,46 +165,59 @@ as loading and observe the query to hear the complete answer. A query is data:
157
165
  ## Local Search rules
158
166
 
159
167
  `search({ text, documents, collection, conversations, limit, after, total })` answers
160
- once, by words, from local state, with MiniSearch's defaults. There is no observed search.
168
+ once, by words, from the full-text index the browser keeps with its local state, so it
169
+ answers at once after a reload. There is no observed search.
161
170
 
162
- - **Declaration.** Only an App whose release declares Local Search searches, its first
163
- readiness waiting for its index; any other App's `search` answers the never retryable
164
- `undeclared` refusal `search-undeclared`, its `fields` naming `local_search`.
171
+ - **Declaration.** Only an App whose release declares Local Search searches; any other
172
+ App's `search` answers the never retryable `undeclared` refusal `search-undeclared`, its
173
+ `fields` naming `local_search`.
165
174
  - **What is found.** A Document by its field values, its sections' headings and text, its
166
175
  preamble and its Path, and a message by its text, never a frontmatter key, a Room Draft,
167
- a chat draft or a running turn's parts, with no phrases, word forms, typo tolerance or
168
- prefix matching.
176
+ a chat draft or a running turn's parts. Any word found ranks a hit, more found rank it
177
+ higher, and adjacent words higher still; case and the marks of Latin, Greek and
178
+ Cyrillic letters fold, English word forms stem, the last word also matches as the start
179
+ of a word unless the text ends with a space, and Chinese, Japanese, Korean and Thai text
180
+ matches by character pairs. There is no typo tolerance and no operator syntax.
169
181
  - **Narrowing.** `documents` is a Local Query filter, and `collection: true` leaves out
170
182
  what each Room's `typedSelection` roots hold; `conversations` names conversations. All
171
183
  apply before `limit`, which bounds each list, at most 1,000 whatever a search names. A
172
184
  complete answer it cuts short names `next`, which `after` takes for the next window of
173
- both lists. `total: true` adds `total`, each list's count.
185
+ both lists. `total: true` adds `total`, each list's count. A word in very many Documents
186
+ ranks among a bounded set of them, the Documents of a rarer word of the search always
187
+ among them.
174
188
  - **Results.** `{ documents, messages, coverage }`, or the same with `pending` naming each
175
- Room or conversation the search still waits for: show its hits, ask again, and never
176
- read pending as no hits. `coverage` names the Rooms and conversations searched. Each
177
- list is ranked by `score`, comparable only within it; ties come by `room`, then `path`,
178
- or by `conversation`, then `identity`. A Document hit names its `room`, `path` and
179
- `type`, a message hit its `conversation` and `identity`; `matches` maps each matched
180
- word to the parts it matched in: `fields`, `sections`, `preamble`, `path` or `text`. A
181
- hit carries no position: mark the words you show. A bad filter fails as a query does.
189
+ Room the search still waits for: show its hits, ask again, and never read pending as no
190
+ hits. `coverage` names the Rooms and conversations searched. Each list is ranked by
191
+ `score`, comparable only within it; ties come by `room`, then `path`, or by
192
+ `conversation`, then `identity`. A Document hit names its `room`, `path` and `type`, a
193
+ message hit its `conversation` and `identity`; `matches` maps each word of the search
194
+ to the parts it was found in: `fields`, `sections`, `preamble`, `path` or `text`. A hit
195
+ whose words were found carries `snippet: { part, text, at }`: the part's text around
196
+ the first word found, at most 80 characters on either side, and `at` that word's start
197
+ and end in `text`. Mark the words you show. A bad filter fails as a query does.
182
198
 
183
199
  ## Room Draft, Save, and outcome rules
184
200
 
185
201
  The MD Runtime owns one durable Room Draft per Room and Path, shared by every App and tab
186
202
  across reloads; a Room the Provider reports lost takes its Room Drafts and queue with it.
187
- Write one with `roomDraft.write(room, path, revision, parts)`, naming the revision you
188
- read or `null`, and every part it now changes: fields, sections and the preamble, or the
189
- whole Markdown, a creation, a move or a removal. A new part names its base, the value you
190
- showed when it was opened, a field's as `{ value }` or `null` for no such field, and keeps
191
- its first base; a binary Path entry's move or removal takes `null`. A write or discard
192
- from an older revision is refused as `stale` with the current Room Draft.
203
+ Write one with `roomDraft.write(room, path, revision, parts)`, naming the revision you read
204
+ or `null`, and every part it now changes: fields, sections and the preamble, or the whole
205
+ Markdown, a creation, a move, into another Room when it names `room`, or a removal. A new
206
+ part names its base, the value you showed when it was opened, a field's as `{ value }` or
207
+ `null` for no such field, and keeps its first base; a binary Path entry's move or removal
208
+ takes `null`. A write or discard from an older revision is refused as `stale` with the
209
+ current Room Draft.
193
210
 
194
211
  Save takes one Room and the Room Drafts of it to save, each with its revision, validates
195
- locally, and on success appends one Change Batch to that Room's queue and removes those
196
- Room Drafts. Refused as `stale`, `changed-underneath` naming each part whose base no
197
- longer matches the visible state, or a local validation rule, it creates nothing and
198
- leaves every Room Draft. A directory move or removal is that part on each Document and
199
- binary Path entry beneath it, saved together.
212
+ locally, and on success appends one Change Batch to that Room's queue and removes those Room
213
+ Drafts. Refused as `stale`, `changed-underneath` naming each part whose base no longer
214
+ matches the visible state, or a local validation rule, it creates nothing and leaves every
215
+ Room Draft. A directory move or removal is that part on each Document and binary Path entry
216
+ beneath it, saved together; moves into another Room, saved alone, are one Change Batch in
217
+ both Rooms' queues. `saveParts(room, [{ path, parts }])` saves parts, each Path once and
218
+ each new part with its base, the same way but writes no Room Draft: one held at a saved Path
219
+ stays, one at a moved Path moves with it to a destination that holds none. Never save by
220
+ writing back a Room Draft read before.
200
221
 
201
222
  Outcomes follow the Provider's answer. An Accepted Change Batch stays in the queue, drawn
202
223
  over the confirmed layer, until that layer reaches the Room Version it was accepted at.
@@ -206,24 +227,23 @@ Provider's structured refusal code and fields as returned, not known to have app
206
227
  withdrawn locally. The rest of the queue keeps synchronizing, and Sync Status requires
207
228
  attention until each returned Room Draft is saved or discarded. `observe('queue', room)`
208
229
  shows each Pending Change Batch, which keeps no outcome once it leaves. Transport failure,
209
- Provider unavailability and a refusal the Provider marks retryable, until the reset it
210
- names, keep work Pending; the MD Runtime retries the same Change Batch identity and
211
- payload, never infers an outcome from transport uncertainty, and never combines,
212
- reorders, or rebases.
213
-
214
- On a Site, every Save stays in the visitor's browser: write grants and revisions do not
215
- refuse it, and its Pending Change shows in every query and across reloads until the
216
- browser's storage is cleared. It is never sent: `observe('queue', room)` shows it `local`,
217
- Sync Status never waits on it, and once the Room no longer lets it apply it leaves the
218
- queue and returns no Room Draft.
219
-
220
- `observe('service-mode')` answers the Provider's Service Mode, `open` or `write-halted`.
221
- While writes are halted, Save succeeds, its Change Batch waits unsent and the queue is
222
- submitted in order once writes reopen; an Action is never held, and one the halt refuses
223
- returns that refusal: show the Provider as read-only instead of retrying.
224
- `observe('readiness')` tells whether the App's code and bound Rooms are held locally
225
- (`ready`), each Room's state, each refused Room's file and rule, the persistence answer
226
- and a paused preparation's `capacity` cause; `retry()` resumes a paused preparation.
230
+ Provider unavailability and a refusal marked retryable, until the reset it names, keep
231
+ work Pending; the MD Runtime retries the same Change Batch identity and payload, never
232
+ infers an outcome from transport uncertainty, and never combines, reorders, or rebases.
233
+
234
+ On a Site, every Save stays in the visitor's browser: write grants and revisions do not refuse it,
235
+ and its Pending Change shows in every query and across reloads until the browser's storage is
236
+ cleared. It is never sent: `observe('queue', room)` shows it `local`, Sync Status never waits on
237
+ it, and once the Room no longer lets it apply it leaves the queue and returns no Room Draft.
238
+
239
+ `observe('service-mode')` answers the Provider's Service Mode, `open` or `write-halted`. While writes
240
+ are halted, Save succeeds, its Change Batch waits unsent and the queue is submitted in order once writes
241
+ reopen; an Action is never held, and one the halt refuses returns that refusal: show the Provider as
242
+ read-only instead of retrying. `observe('readiness')` tells whether code and bound Rooms are held
243
+ locally (`ready`), each Room's state, each refused Room's file and rule, the persistence answer, `space`
244
+ (`full` once the device's storage refused a write, Save and messages refusing as `durable-write` until
245
+ `retry()` or a later test write finds space, or once the origin refused a newer release), and the
246
+ `installation`'s Rooms, parts, bytes, `received`, `step` and `paused`.
227
247
 
228
248
  ## Content safety and launch promises
229
249
 
@@ -264,36 +284,29 @@ peer dependency. `useObserve(client, topic, ...input)` takes the arguments of `o
264
284
  and returns `{ state: 'loading' }` until the topic's first value arrives, then `{ state:
265
285
  'ready', value }`, re-rendering on each change; a `null` client stays loading.
266
286
  `useSave(client)` returns `busy`, the last `outcome` or `failure`, and `save(room,
267
- roomDrafts)`, which writes each Path's parts onto its Room Draft, keeping their bases, and
268
- saves them together: a refused Save leaves the Room Drafts to save again or discard, and a
269
- failure is recorded and rejects; `saveRoomDrafts(client, room, roomDrafts)` is that save
270
- outside a component. `saveWritten(room, roomDrafts)` saves Room Drafts the App wrote
271
- itself, each named with the revision its last write returned: one another tab wrote since
272
- is refused as `stale`, and nothing is saved. A react-admin or Refine App uses the data
273
- providers of `@agentshouse/mdruntime-families`.
287
+ parts)`, which saves through `saveParts` and rejects with a recorded failure.
288
+ `saveWritten(room, roomDrafts)` saves Room Drafts the App wrote, each named with the
289
+ revision its last write returned: one another tab wrote since is refused as `stale`, and
290
+ nothing is saved. React-admin and Refine Apps use `@agentshouse/mdruntime-families`.
274
291
 
275
292
  ## The Chat
276
293
 
277
- `@agentshouse/mdruntime/chat` holds the Chat, one data layer for every App; add React as a
278
- dependency in any App, with React DOM and `@assistant-ui/react`. Place the ready chat with
279
- `<Chat client={runtime} conversation={id} agent={agent} width="1/3" showChats />`:
280
- `conversation` opens one, `null` for a new chat, `agent` is the Agent a new chat goes to,
281
- `onOpen` hears each one it opens, and `width` is `full` (the place you give it), or `3/4`,
282
- `1/2` or `1/3` of the window docked at its right edge, whole on a narrow window.
283
- `showChats` adds its conversation list; or draw your own inside a `ChatProvider` around a
284
- `<Chat />` with no `client`. Theme its own styles with CSS custom properties on it or an
285
- ancestor: `--chat-background`, `--chat-surface`, `--chat-text`, `--chat-text-muted`,
294
+ In House the page's bridge places the Chat, one data layer for every App, which House
295
+ serves with the page and keeps current: install, import and bundle nothing for it, and add
296
+ no dependency. `const chat = await houseBridge.chat.mount(element, options)`, on the bridge
297
+ object House hands the page as `window.houseBridge`, which `houseBridge()` of
298
+ `@agentshouse/app-bridge` returns, draws it in `element` over the App's own client and
299
+ resolves to a handle: `chat.update(options)` replaces its options and `chat.unmount()`
300
+ removes it. `conversation` opens one, `null` for a
301
+ new chat, `agent` is the Agent a new chat goes to, `showChats` adds its conversation list,
302
+ `width` is `full` (the element), or `3/4`, `1/2` or `1/3` of the window docked at its right
303
+ edge, whole on a narrow window, `onOpen` hears each conversation it opens as `{
304
+ conversation, agent }`, and `onLink` takes a link without a scheme in place of the browser.
305
+ Theme its own styles with CSS custom properties on the element or an ancestor:
306
+ `--chat-background`, `--chat-surface`, `--chat-text`, `--chat-text-muted`,
286
307
  `--chat-accent`, `--chat-line`, `--chat-attention`, `--chat-danger`, `--chat-font`,
287
308
  `--chat-font-mono`, `--chat-font-size`, `--chat-radius` and `--chat-density` (a factor for
288
- spacing); an unset one keeps House's light or dark look. `mountChat(element, { client })`
289
- places it outside React, with `update(props)` and `unmount()`.
290
-
291
- Mix `ChatMessageList` (`components` takes your `UserMessage` and `AssistantMessage`),
292
- `ChatInput` and `ChatQuestionCard` with your own design inside a `ChatProvider`, or
293
- compose assistant-ui's primitives there; `useChat()` gives `send`, the conversations, the
294
- Agents, questions to `answer`, `options` to `choose`, `commands`, the queue to `edit` or
295
- `unqueue`, `stop`, `kill` and outcomes; never replace its messages, sending or store. It
296
- shows a conversation's latest 50 messages, and assistant-ui's `loadEarlier()` the 50
297
- before, which `ChatMessageList` calls as the reader scrolls back. A secret question is
298
- never answered here; typed answers live in the Presentation State members named `typed:…`:
299
- leave them. `Markdown` draws Markdown safely.
309
+ spacing); an unset one keeps House's light or dark look. It shows conversations only where
310
+ the release declares them; otherwise it lists no conversation and no Agent. A secret
311
+ question is never answered here; typed answers live in the Presentation State members named
312
+ `typed:…`: leave them.
package/dist/actions.d.ts CHANGED
@@ -1,15 +1,18 @@
1
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 HISTORY_PAGE = 100;
4
+ export declare const TRIGGER_ROOMS = 100;
3
5
  type Operated = {
4
6
  readonly operation_id?: string;
5
7
  };
6
8
  type ConversationControl = Operated & {
7
9
  readonly conversation: string;
8
10
  };
9
- type SentFile = FileDeclaration & {
10
- readonly blob: Blob;
11
- };
12
11
  export type AppInputs = {
12
+ readonly 'conversation.attach': FileDeclaration & {
13
+ readonly room: string;
14
+ readonly blob: Blob;
15
+ };
13
16
  readonly 'conversation.answer': ConversationControl & {
14
17
  readonly answer: {
15
18
  readonly interaction_id: string;
@@ -18,6 +21,7 @@ export type AppInputs = {
18
21
  };
19
22
  readonly 'conversation.create': Operated & {
20
23
  readonly agent_id: string;
24
+ readonly replaces?: string;
21
25
  };
22
26
  readonly 'conversation.delete': ConversationControl;
23
27
  readonly 'conversation.history': ConversationHistoryRequest;
@@ -25,11 +29,16 @@ export type AppInputs = {
25
29
  readonly 'conversation.kill': ConversationControl;
26
30
  readonly 'conversation.send': ConversationControl & {
27
31
  readonly operation_id: string;
28
- readonly text?: string;
29
- readonly files?: readonly SentFile[];
32
+ readonly text: string;
33
+ };
34
+ readonly 'trigger.list': {
35
+ readonly room_refs: readonly string[];
30
36
  };
31
37
  };
32
38
  export type AppAnswers = {
39
+ readonly 'conversation.attach': {
40
+ readonly path: string;
41
+ };
33
42
  readonly 'conversation.history': ConversationHistories;
34
43
  };
35
44
  export type AppAnswerAdditions = {
@@ -39,22 +48,6 @@ export type AppAnswerAdditions = {
39
48
  readonly 'conversation.send': {
40
49
  readonly turn: string;
41
50
  };
42
- readonly 'record.list': {
43
- readonly attachments: readonly {
44
- readonly referrer: {
45
- readonly room_ref: string;
46
- readonly record: string;
47
- };
48
- }[];
49
- readonly records: readonly {
50
- readonly attachments: readonly {
51
- readonly referrer: {
52
- readonly room_ref: string;
53
- readonly record: string;
54
- };
55
- }[];
56
- }[];
57
- };
58
51
  };
59
52
  export declare const HOUSE_APP_ACTS: Readonly<Record<string, string>>;
60
53
  export declare const SITE_SUBMIT = "submit";
@@ -1 +1 @@
1
- {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAE1B,KAAK,0BAA0B,EAC/B,KAAK,eAAe,EACrB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAQtE,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,KAAK,QAAQ,GAAG,eAAe,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC;AAE1D,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,qBAAqB,EAAE,mBAAmB,GAAG;QACpD,QAAQ,CAAC,MAAM,EAAE;YAAE,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;SAAE,CAAC;KAClF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