@agentshouse/mdruntime-adapter 0.1.0-ce4626067e686 → 0.1.0-ceda7e87cc6e8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +140 -110
- package/dist/actions.d.ts +41 -1
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +53 -7
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +102 -27
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +5 -2
- package/dist/handed.d.ts +15 -0
- package/dist/handed.d.ts.map +1 -0
- package/dist/handed.js +38 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/read.d.ts +7 -6
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +61 -49
- package/dist/referrer.d.ts +7 -0
- package/dist/referrer.d.ts.map +1 -0
- package/dist/referrer.js +35 -0
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +35 -4
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +13 -6
- package/dist/transport.d.ts +14 -2
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +3 -0
- package/dist/write.d.ts +2 -9
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +54 -5
- package/package.json +3 -3
- package/dist/links.d.ts +0 -20
- package/dist/links.d.ts.map +0 -1
- package/dist/links.js +0 -104
package/AGENTS.md
CHANGED
|
@@ -1,25 +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
|
-
|
|
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,
|
|
11
|
-
the reported persistence answer, reauthorization,
|
|
12
|
-
and Presentation State. Sync Status, the Service
|
|
13
|
-
statement, the deployment facts and the signed-in member
|
|
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
14
|
|
|
15
15
|
The host attaches each port with its reach, and every member and observation
|
|
16
16
|
answers within it: a Room outside it answers as one the replica does not hold,
|
|
17
17
|
Rooms lists only the Rooms reached whole, a Room reached for single Documents
|
|
18
18
|
shows only those Documents and the Types of the models that govern them, and
|
|
19
19
|
without conversations the conversation members, the chat draft and the
|
|
20
|
-
conversation observation hold none.
|
|
21
|
-
|
|
22
|
-
keeping every unchanged Document the same object.
|
|
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.
|
|
23
22
|
|
|
24
23
|
Every `observe` resolves, once its first value has arrived, to a handle:
|
|
25
24
|
`current()` is the latest complete value, `subscribe(listener)` hears each later
|
|
@@ -27,33 +26,45 @@ value whole and returns its unsubscribe, and `close()` ends the observation.
|
|
|
27
26
|
Closing the port ends every handle and rejects every pending call and
|
|
28
27
|
observation; a client that reconnects observes again.
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
`
|
|
34
|
-
and
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
and
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
each with
|
|
49
|
-
`
|
|
50
|
-
|
|
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.
|
|
51
63
|
|
|
52
64
|
Rooms, Query, Search, Observe, Types, Room Draft, Save, and Reached never
|
|
53
|
-
touch the network.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
Provider. 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
|
|
57
68
|
effect the Provider places in a Room carries `at`, that Room and Room Version;
|
|
58
69
|
`reached(room, roomVersion)` answers whether the Room's confirmed state has
|
|
59
70
|
reached it, and the MD Runtime keeps refreshing that Room until it has;
|
|
@@ -62,33 +73,26 @@ that document was written at a later Room Version. Each History revision
|
|
|
62
73
|
names its author, `{ kind: 'user', id }` or `{ kind: 'site', id, name }`.
|
|
63
74
|
History of a Path no current document holds answers the removed document's
|
|
64
75
|
revisions with `deleted: true`, newest first; that revision is what a link to
|
|
65
|
-
the Path opens. Every
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
`
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
MD Runtime keeps it with the Local Replicas, so it answers offline once known,
|
|
86
|
-
and every port hears the next member the Provider names; signing out answers
|
|
87
|
-
`null`, then ends the observation with the authorization. It is the only way App code learns who
|
|
88
|
-
uses it.
|
|
89
|
-
|
|
90
|
-
The in-memory Adapter at `@agentshouse/mdruntime/memory` is for tests and
|
|
91
|
-
ships in no bundle.
|
|
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.
|
|
79
|
+
|
|
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`.
|
|
86
|
+
|
|
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.
|
|
92
96
|
|
|
93
97
|
## Local Query rules
|
|
94
98
|
|
|
@@ -106,13 +110,12 @@ data:
|
|
|
106
110
|
pointers, ANDs them, and nests `$and` and `$or`; a pointer through a list holds
|
|
107
111
|
when any item satisfies it. A bare value is equality; the operators are `$eq`,
|
|
108
112
|
`$ne`, `$in`, `$nin`, `$gt`, `$gte`, `$lt`, `$lte`, `$all`, `$size` and
|
|
109
|
-
`$exists`. Equality on a list asks whether it contains the value. Missing,
|
|
110
|
-
`$exists: false` keeps a missing field, `null` an
|
|
111
|
-
text and `$size: 0` an empty list. A date compares
|
|
112
|
-
with a date-time. A reference compares by the Room
|
|
113
|
-
Untyped frontmatter, and a value under `oneOf` or a
|
|
114
|
-
values. There is no text containment or regular
|
|
115
|
-
expression.
|
|
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.
|
|
116
119
|
- **Relations.** `hop: { field, types, where, pathPrefix }` keeps Documents whose
|
|
117
120
|
reference at pointer `field`, at any depth, points to a matching Document of the
|
|
118
121
|
same Room. `backlinks: { field, types, where, pathPrefix }` keeps Documents that a
|
|
@@ -122,8 +125,9 @@ data:
|
|
|
122
125
|
list of pointers and `sections` `'all'` or a list of names. Selected pointers
|
|
123
126
|
return the frontmatter holding only them, nested as written. A backlink names
|
|
124
127
|
the referring Path, MD Type and the pointer it came from as `field`. Room and Path always return; a Markdown
|
|
125
|
-
Document also returns its MD Type. A non-Markdown Document
|
|
126
|
-
|
|
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
|
|
127
131
|
what a screen shows: a list that selects the Markdown hears every edit of it.
|
|
128
132
|
- **Change.** `change` is `{ author, time }` of the Document's head revision as
|
|
129
133
|
the Provider last delivered it: `author` is `{ kind: 'user' | 'site', id, name }`
|
|
@@ -164,17 +168,16 @@ search.
|
|
|
164
168
|
|
|
165
169
|
## Room Draft, Save, and outcome rules
|
|
166
170
|
|
|
167
|
-
The MD Runtime owns one Room Draft per Room and Path, shared by every App and
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
base. A
|
|
176
|
-
`
|
|
177
|
-
the current Room Draft; read it and write again.
|
|
171
|
+
The MD Runtime owns one Room Draft per Room and Path, shared by every App and tab.
|
|
172
|
+
It is durable: it survives reload and navigation. A Room that Discovery stops
|
|
173
|
+
listing takes its Room Drafts and its queue with it. Write a Room Draft with
|
|
174
|
+
`roomDraft.write(room, path, revision, parts)`, naming the revision you read, or
|
|
175
|
+
`null` when there was none, and every part it should now change: fields, sections
|
|
176
|
+
and the preamble, or the whole Markdown, a creation, a move, or a removal. A part
|
|
177
|
+
new to the Room Draft names its base, the value you showed when it was opened; the
|
|
178
|
+
MD Runtime keeps a part's first base; a binary Path entry's move or removal takes
|
|
179
|
+
`null` as its base. A write or a discard from an older revision is refused as
|
|
180
|
+
`stale` with the current Room Draft; read it and write again.
|
|
178
181
|
|
|
179
182
|
Save takes one Room and the Room Drafts of it to save, each with its revision,
|
|
180
183
|
validates locally, and on success appends one Change Batch to that Room's
|
|
@@ -182,7 +185,7 @@ queue and removes those Room Drafts. It is refused with the `code` `stale`,
|
|
|
182
185
|
`changed-underneath` naming each part whose base no longer matches the visible
|
|
183
186
|
state, or a local validation rule, and then creates nothing and leaves every
|
|
184
187
|
Room Draft in place. A directory move or removal is a move or removal part on
|
|
185
|
-
each Document and binary
|
|
188
|
+
each Document and binary Path entry beneath it, saved together.
|
|
186
189
|
|
|
187
190
|
Outcomes follow the Provider's answer. An Accepted Change Batch stays in the
|
|
188
191
|
queue, drawn over the confirmed layer, until the confirmed layer reaches the
|
|
@@ -200,19 +203,17 @@ it names; the MD Runtime retries the same Change Batch identity and payload and
|
|
|
200
203
|
never infers an outcome from transport uncertainty. The MD Runtime never
|
|
201
204
|
combines, reorders, or rebases.
|
|
202
205
|
|
|
203
|
-
On a Site, every Save stays in the visitor's browser. Write grants and
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
returns no Room Draft.
|
|
206
|
+
On a Site, every Save stays in the visitor's browser. Write grants and revisions
|
|
207
|
+
do not refuse it, and its Pending Change shows in every query and across reloads
|
|
208
|
+
until the browser's storage is cleared. It is never sent: `observe('queue', room)`
|
|
209
|
+
shows it `local`, and Sync Status never waits on it. Once the Room changes so that
|
|
210
|
+
it no longer applies, it leaves the queue and returns no Room Draft.
|
|
209
211
|
|
|
210
|
-
`observe('service-mode')` answers the Provider's Service
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
instead of retrying.
|
|
212
|
+
`observe('service-mode')` answers the Provider's Service Mode, `open` or
|
|
213
|
+
`write-halted`. While writes are halted, Save still succeeds, its Change Batch
|
|
214
|
+
waits unsent, and the queue is submitted in order once the Provider reopens
|
|
215
|
+
writes. An Action is never held: a write the Provider refuses for the halt returns
|
|
216
|
+
that refusal to its caller. Show the Provider as read-only instead of retrying.
|
|
216
217
|
|
|
217
218
|
## The neutrality rule
|
|
218
219
|
|
|
@@ -242,26 +243,55 @@ the network. Data lives only in the App Creator's browser and with the Provider.
|
|
|
242
243
|
|
|
243
244
|
## App code takes the client its host hands it and never constructs a Runtime
|
|
244
245
|
|
|
245
|
-
App code takes the client its host hands it: in House,
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
served App does not.
|
|
246
|
+
App code takes the client its host hands it: in House, `houseBridge().runtime`
|
|
247
|
+
from `@agentshouse/app-bridge` resolves to the client House built into the page.
|
|
248
|
+
It imports only types from `@agentshouse/mdruntime/client`, never calls
|
|
249
|
+
`connectMdRuntime` or `serveMdRuntime`, and never imports the package main, the
|
|
250
|
+
host entry or the Adapter package, which hosts and tests use. The in-memory
|
|
251
|
+
Adapter at `@agentshouse/mdruntime/memory` is for tests and ships in no bundle.
|
|
252
252
|
|
|
253
253
|
A React App may observe and save through `@agentshouse/mdruntime/react`, which
|
|
254
254
|
names React as a peer dependency. `useObserve(client, topic, ...input)` takes
|
|
255
255
|
the arguments of `observe` and returns `{ state: 'loading' }` until the topic's
|
|
256
256
|
first value arrives, then `{ state: 'ready', value }`, re-rendering on each
|
|
257
|
-
change; a `null` client observes nothing and stays loading. `useSave(client)`
|
|
258
|
-
`
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
or discard; a failure is
|
|
262
|
-
roomDrafts)` is that save
|
|
263
|
-
reads and writes its Rooms
|
|
264
|
-
`@agentshouse/mdruntime-families`.
|
|
257
|
+
change; a `null` client observes nothing and stays loading. `useSave(client)`
|
|
258
|
+
returns `busy`, the last `outcome` or `failure`, and `save(room, roomDrafts)`,
|
|
259
|
+
which writes each Path's parts onto the Room Draft already there, keeping the
|
|
260
|
+
bases its parts have, or onto a new one, and saves them together. A refused
|
|
261
|
+
Save leaves the Room Drafts for the App to save again or discard; a failure is
|
|
262
|
+
recorded and rejects. `saveRoomDrafts(client, room, roomDrafts)` is that save
|
|
263
|
+
outside a component. A react-admin or Refine App reads and writes its Rooms
|
|
264
|
+
through the data providers of `@agentshouse/mdruntime-families`.
|
|
265
|
+
|
|
266
|
+
## The Chat
|
|
267
|
+
|
|
268
|
+
`@agentshouse/mdruntime/chat` holds the Chat, one data layer for every App.
|
|
269
|
+
Its required peers are React, React DOM and `@assistant-ui/react`: add React as
|
|
270
|
+
a dependency, also in an App not written in 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()`.
|
|
285
|
+
|
|
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.
|
|
265
295
|
|
|
266
296
|
## What an agent must never do
|
|
267
297
|
|
package/dist/actions.d.ts
CHANGED
|
@@ -1,9 +1,49 @@
|
|
|
1
|
-
import { type AcceptedMessage, type ActionDeclaration, type ActionRequest, type ActionResult, type ConversationAgents } 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
|
+
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.send': {
|
|
36
|
+
readonly turn: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
3
39
|
export declare const HOUSE_APP_ACTS: Readonly<Record<string, string>>;
|
|
40
|
+
export declare const SITE_SUBMIT = "submit";
|
|
41
|
+
export declare const HOUSE_SITE_ACTS: Readonly<Record<string, string>>;
|
|
42
|
+
export declare const HOUSE_APP_BATCHES: Readonly<Partial<Record<string, readonly string[]>>>;
|
|
4
43
|
export declare function houseConversationAgents(locator: string): ConversationAgents;
|
|
5
44
|
export declare function declaredActions(routes: readonly string[]): readonly ActionDeclaration[];
|
|
6
45
|
export declare function houseAction(transport: HouseTransport, request: ActionRequest): Promise<ActionResult>;
|
|
7
46
|
export declare function actionOutcome(answer: HouseDoorAnswer, name: string): ActionResult;
|
|
8
47
|
export declare function acceptedMessage(entry: unknown): AcceptedMessage | null;
|
|
48
|
+
export {};
|
|
9
49
|
//# sourceMappingURL=actions.d.ts.map
|
package/dist/actions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAA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 function mapped(door, input = (given) => given) {
|
|
|
11
11
|
},
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
function carried(door, carry) {
|
|
14
|
+
function carried(door, carry, batched) {
|
|
15
15
|
return {
|
|
16
16
|
door,
|
|
17
|
+
...(batched === undefined ? {} : { batched }),
|
|
17
18
|
carry: (transport, input, name) => carry(transport, `/door/${door}`, input, name),
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
21
|
const APP_ACTS = {
|
|
21
22
|
'access.read': mapped('rooms/access/read'),
|
|
22
23
|
'conversation.answer': mapped('conversations/interaction/answer', answerBody),
|
|
23
|
-
'conversation.create':
|
|
24
|
+
'conversation.create': carried('conversations/create', createAction),
|
|
24
25
|
'conversation.delete': mapped('conversations/delete', controlBody),
|
|
25
|
-
'conversation.history': carried('conversations/history', historyAction),
|
|
26
|
+
'conversation.history': carried('conversations/history', historyAction, ['conversations']),
|
|
26
27
|
'conversation.interrupt': mapped('conversations/interrupt', controlBody),
|
|
27
28
|
'conversation.kill': mapped('conversations/kill', controlBody),
|
|
28
29
|
'conversation.markDone': mapped('conversations/done'),
|
|
@@ -35,7 +36,7 @@ const APP_ACTS = {
|
|
|
35
36
|
'member.list': mapped('rooms/members'),
|
|
36
37
|
'message.send': mapped('apps/messages/send'),
|
|
37
38
|
'processing.read': mapped('rooms/settings/processing/read'),
|
|
38
|
-
'record.list':
|
|
39
|
+
'record.list': carried('records/read', recordsAction),
|
|
39
40
|
'relay.read': mapped('apps/relay'),
|
|
40
41
|
'routine.list': mapped('routines/access'),
|
|
41
42
|
'routineAccess.list': mapped('routines/granted'),
|
|
@@ -46,9 +47,14 @@ const APP_ACTS = {
|
|
|
46
47
|
'triggerOccurrence.list': mapped('triggers/fired'),
|
|
47
48
|
};
|
|
48
49
|
export const HOUSE_APP_ACTS = Object.fromEntries(Object.entries(APP_ACTS).map(([name, act]) => [name, act.door]));
|
|
50
|
+
export const SITE_SUBMIT = 'submit';
|
|
51
|
+
export const HOUSE_SITE_ACTS = {
|
|
52
|
+
[SITE_SUBMIT]: 'site/submission',
|
|
53
|
+
};
|
|
54
|
+
export const HOUSE_APP_BATCHES = Object.fromEntries(Object.entries(APP_ACTS).flatMap(([name, act]) => act.batched === undefined ? [] : [[name, act.batched]]));
|
|
49
55
|
const APP_NAMES = new Map(Object.entries(APP_ACTS).map(([name, act]) => [act.door, name]));
|
|
50
56
|
export function houseConversationAgents(locator) {
|
|
51
|
-
return { locator, type: 'house-agent', identity: 'agent', name: 'name' };
|
|
57
|
+
return { locator, type: 'house-agent', identity: 'agent', name: 'name', retired: 'retired' };
|
|
52
58
|
}
|
|
53
59
|
export function declaredActions(routes) {
|
|
54
60
|
return routes.map((route) => ({
|
|
@@ -110,10 +116,20 @@ function answerBody(input) {
|
|
|
110
116
|
response: nested.response,
|
|
111
117
|
};
|
|
112
118
|
}
|
|
119
|
+
async function createAction(transport, route, input, name) {
|
|
120
|
+
const outcome = actionOutcome(await transport.door(route, createBody(input)), name);
|
|
121
|
+
if (outcome.kind !== 'action')
|
|
122
|
+
return outcome;
|
|
123
|
+
const held = record(outcome.result);
|
|
124
|
+
const conversation = text(held, 'conversation_id');
|
|
125
|
+
return conversation === undefined ? outcome : { ...outcome, result: { ...held, conversation } };
|
|
126
|
+
}
|
|
113
127
|
function withTurn(body) {
|
|
114
128
|
const held = record(body);
|
|
115
129
|
const turn = text(held, 'message_id');
|
|
116
|
-
return turn === undefined
|
|
130
|
+
return turn === undefined
|
|
131
|
+
? body
|
|
132
|
+
: { ...held, turn };
|
|
117
133
|
}
|
|
118
134
|
export function actionOutcome(answer, name) {
|
|
119
135
|
if (answer.status === 401)
|
|
@@ -127,6 +143,29 @@ export function actionOutcome(answer, name) {
|
|
|
127
143
|
return { kind: 'transport-uncertainty' };
|
|
128
144
|
return { kind: 'action', result: answer.body };
|
|
129
145
|
}
|
|
146
|
+
function referredRecord(view, roomRef) {
|
|
147
|
+
const held = record(view);
|
|
148
|
+
if (roomRef === undefined || typeof held.record !== 'string' || !Array.isArray(held.attachments))
|
|
149
|
+
return view;
|
|
150
|
+
const referrer = { room_ref: roomRef, record: held.record };
|
|
151
|
+
return {
|
|
152
|
+
...held,
|
|
153
|
+
attachments: held.attachments.map((attachment) => ({ ...record(attachment), referrer })),
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
async function recordsAction(transport, route, input, name) {
|
|
157
|
+
const outcome = actionOutcome(await transport.door(route, input), name);
|
|
158
|
+
if (outcome.kind !== 'action')
|
|
159
|
+
return outcome;
|
|
160
|
+
const roomRef = text(input, 'room_ref');
|
|
161
|
+
const read = record(outcome.result);
|
|
162
|
+
return {
|
|
163
|
+
...outcome,
|
|
164
|
+
result: Array.isArray(read.records)
|
|
165
|
+
? { ...read, records: read.records.map((view) => referredRecord(view, roomRef)) }
|
|
166
|
+
: referredRecord(outcome.result, roomRef),
|
|
167
|
+
};
|
|
168
|
+
}
|
|
130
169
|
async function carry(transport, route, name, input) {
|
|
131
170
|
return actionOutcome(await transport.door(route, input), name);
|
|
132
171
|
}
|
|
@@ -263,12 +302,19 @@ export function acceptedMessage(entry) {
|
|
|
263
302
|
const cursor = historyCursor(entry);
|
|
264
303
|
if (cursor === null)
|
|
265
304
|
return null;
|
|
305
|
+
const message = structuredClone(record(entry));
|
|
306
|
+
const referrer = { message: cursor.message_id };
|
|
266
307
|
return {
|
|
267
308
|
identity: cursor.message_id,
|
|
268
309
|
turn: text(entry, 'turn_id') ?? cursor.message_id,
|
|
269
310
|
position: position(cursor),
|
|
270
311
|
text: text(entry, 'text') ?? '',
|
|
271
|
-
message:
|
|
312
|
+
message: Array.isArray(message.files)
|
|
313
|
+
? {
|
|
314
|
+
...message,
|
|
315
|
+
files: message.files.map((file) => ({ ...record(file), referrer })),
|
|
316
|
+
}
|
|
317
|
+
: message,
|
|
272
318
|
};
|
|
273
319
|
}
|
|
274
320
|
function historyPage(entry) {
|
package/dist/adapter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,OAAO,EACP,aAAa,
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,OAAO,EACP,aAAa,EAgBd,MAAM,wBAAwB,CAAC;AAuChC,OAAO,EASL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAyBxB,MAAM,MAAM,yBAAyB,GACjC;IACE,SAAS,EAAE,cAAc,CAAC;IAC1B,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;CACrC,GACD;IAAE,IAAI,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAwBjC,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CA8cpF"}
|