@agentshouse/mdruntime 0.1.0-cede5a74284be → 0.1.0-cef5833f6c689
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -16
- package/dist/adapter.d.ts +153 -56
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +5 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +38 -4
- package/dist/attempt.d.ts.map +1 -1
- package/dist/attempt.js +14 -1
- package/dist/binary.d.ts +0 -5
- package/dist/binary.d.ts.map +1 -1
- package/dist/binary.js +1 -1
- package/dist/bootstrap.d.ts +27 -11
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +185 -81
- package/dist/chain.d.ts +12 -0
- package/dist/chain.d.ts.map +1 -0
- package/dist/chain.js +64 -0
- package/dist/change-set.d.ts +9 -14
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +11 -63
- package/dist/change.d.ts +31 -1
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +10 -1
- package/dist/client.d.ts +29 -16
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +98 -12
- package/dist/collection.d.ts +11 -7
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +38 -79
- package/dist/compile.d.ts +11 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +589 -0
- package/dist/connection.d.ts +44 -16
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +3759 -991
- package/dist/context.d.ts +2 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/{chat/context.js → context.js} +1 -4
- package/dist/conversation.d.ts +39 -17
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +691 -259
- package/dist/digest.d.ts +7 -0
- package/dist/digest.d.ts.map +1 -0
- package/dist/digest.js +113 -0
- package/dist/durability.d.ts +4 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +5 -0
- package/dist/entry.d.ts +20 -0
- package/dist/entry.d.ts.map +1 -0
- package/dist/entry.js +160 -0
- package/dist/fence.d.ts +6 -0
- package/dist/fence.d.ts.map +1 -0
- package/dist/fence.js +10 -0
- package/dist/file.d.ts +2 -19
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +7 -122
- package/dist/host.d.ts +11 -3
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +122 -19
- package/dist/index.d.ts +19 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/job.d.ts +14 -0
- package/dist/job.d.ts.map +1 -0
- package/dist/job.js +28 -0
- package/dist/live.d.ts +23 -0
- package/dist/live.d.ts.map +1 -0
- package/dist/live.js +127 -0
- package/dist/media.d.ts +8 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +218 -0
- package/dist/memory.d.ts +17 -5
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +214 -94
- package/dist/messages.d.ts +28 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +89 -0
- package/dist/model.d.ts +10 -4
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +8 -5
- package/dist/name.d.ts +4 -0
- package/dist/name.d.ts.map +1 -0
- package/dist/name.js +122 -0
- package/dist/observation.d.ts +22 -4
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +120 -14
- package/dist/opened.d.ts +22 -0
- package/dist/opened.d.ts.map +1 -0
- package/dist/opened.js +107 -0
- package/dist/outcome.d.ts +49 -7
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +40 -0
- package/dist/overlay.d.ts +3 -4
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +100 -182
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +4 -0
- package/dist/query.d.ts +41 -183
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +3 -464
- package/dist/reach.d.ts +18 -6
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +221 -80
- package/dist/react.d.ts +10 -6
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +7 -17
- package/dist/readiness.d.ts +50 -0
- package/dist/readiness.d.ts.map +1 -0
- package/dist/readiness.js +27 -0
- package/dist/recovery.d.ts +26 -0
- package/dist/recovery.d.ts.map +1 -0
- package/dist/recovery.js +224 -0
- package/dist/refresh.d.ts +17 -14
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +155 -51
- package/dist/replica.d.ts +56 -33
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +301 -154
- package/dist/room-draft.d.ts +37 -6
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +161 -74
- package/dist/rows.d.ts +21 -37
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +63 -122
- package/dist/save.d.ts +52 -9
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +539 -171
- package/dist/search.d.ts +15 -55
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +10 -121
- package/dist/seed.d.ts +16 -0
- package/dist/seed.d.ts.map +1 -0
- package/dist/seed.js +75 -0
- package/dist/shared.d.ts +15 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +421 -0
- package/dist/status.d.ts +5 -0
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +3 -1
- package/dist/store.d.ts +110 -76
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +341 -442
- package/dist/stored.d.ts +162 -0
- package/dist/stored.d.ts.map +1 -0
- package/dist/stored.js +543 -0
- package/dist/tables.d.ts +352 -0
- package/dist/tables.d.ts.map +1 -0
- package/dist/tables.js +586 -0
- package/dist/transfer.d.ts +0 -5
- package/dist/transfer.d.ts.map +1 -1
- package/dist/turn.d.ts +9 -0
- package/dist/turn.d.ts.map +1 -0
- package/dist/turn.js +75 -0
- package/dist/validation.d.ts +29 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +104 -0
- package/dist/windows.d.ts +11 -0
- package/dist/windows.d.ts.map +1 -0
- package/dist/windows.js +16 -0
- package/dist/wire.d.ts +165 -32
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +56 -31
- package/package.json +22 -19
- package/AGENTS.md +0 -318
- package/dist/chat/acts.d.ts +0 -34
- package/dist/chat/acts.d.ts.map +0 -1
- package/dist/chat/acts.js +0 -36
- package/dist/chat/context.d.ts +0 -3
- package/dist/chat/context.d.ts.map +0 -1
- package/dist/chat/input.d.ts +0 -9
- package/dist/chat/input.d.ts.map +0 -1
- package/dist/chat/input.js +0 -99
- package/dist/chat/kit.d.ts +0 -60
- package/dist/chat/kit.d.ts.map +0 -1
- package/dist/chat/kit.js +0 -123
- package/dist/chat/lasting.d.ts +0 -6
- package/dist/chat/lasting.d.ts.map +0 -1
- package/dist/chat/lasting.js +0 -19
- package/dist/chat/list.d.ts +0 -20
- package/dist/chat/list.d.ts.map +0 -1
- package/dist/chat/list.js +0 -59
- package/dist/chat/markdown.d.ts +0 -19
- package/dist/chat/markdown.d.ts.map +0 -1
- package/dist/chat/markdown.js +0 -187
- package/dist/chat/message.d.ts +0 -6
- package/dist/chat/message.d.ts.map +0 -1
- package/dist/chat/message.js +0 -192
- package/dist/chat/messages.d.ts +0 -21
- package/dist/chat/messages.d.ts.map +0 -1
- package/dist/chat/messages.js +0 -151
- package/dist/chat/name.d.ts +0 -6
- package/dist/chat/name.d.ts.map +0 -1
- package/dist/chat/name.js +0 -37
- package/dist/chat/opened.d.ts +0 -11
- package/dist/chat/opened.d.ts.map +0 -1
- package/dist/chat/opened.js +0 -17
- package/dist/chat/overlay.d.ts +0 -31
- package/dist/chat/overlay.d.ts.map +0 -1
- package/dist/chat/overlay.js +0 -97
- package/dist/chat/parts.d.ts +0 -57
- package/dist/chat/parts.d.ts.map +0 -1
- package/dist/chat/parts.js +0 -119
- package/dist/chat/process.d.ts +0 -20
- package/dist/chat/process.d.ts.map +0 -1
- package/dist/chat/process.js +0 -32
- package/dist/chat/provider.d.ts +0 -63
- package/dist/chat/provider.d.ts.map +0 -1
- package/dist/chat/provider.js +0 -645
- package/dist/chat/question.d.ts +0 -9
- package/dist/chat/question.d.ts.map +0 -1
- package/dist/chat/question.js +0 -80
- package/dist/chat/questions.d.ts +0 -31
- package/dist/chat/questions.d.ts.map +0 -1
- package/dist/chat/questions.js +0 -111
- package/dist/chat/read.d.ts +0 -5
- package/dist/chat/read.d.ts.map +0 -1
- package/dist/chat/read.js +0 -13
- package/dist/chat/ready.d.ts +0 -33
- package/dist/chat/ready.d.ts.map +0 -1
- package/dist/chat/ready.js +0 -91
- package/dist/chat/style.d.ts +0 -4
- package/dist/chat/style.d.ts.map +0 -1
- package/dist/chat/style.js +0 -302
- package/dist/chat.d.ts +0 -14
- package/dist/chat.d.ts.map +0 -1
- package/dist/chat.js +0 -8
- package/dist/read-side.d.ts +0 -18
- package/dist/read-side.d.ts.map +0 -1
- package/dist/read-side.js +0 -440
package/AGENTS.md
DELETED
|
@@ -1,318 +0,0 @@
|
|
|
1
|
-
# Instructions for the App Creator's agent
|
|
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 enforcement.
|
|
5
|
-
|
|
6
|
-
## The MD Runtime API
|
|
7
|
-
|
|
8
|
-
App code reaches the MD Runtime through the remote client. The surfaces are
|
|
9
|
-
Rooms, Query, Search, Observe, Types, Room Draft, Save, History, the binary file
|
|
10
|
-
reads, 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, the deployment facts and the signed-in member 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.
|
|
21
|
-
A change of the reach reaches every open observation as its new value, a query
|
|
22
|
-
keeping every unchanged Document the same object.
|
|
23
|
-
|
|
24
|
-
Every `observe` resolves, once its first value has arrived, to a handle:
|
|
25
|
-
`current()` is the latest complete value, `subscribe(listener)` hears each later
|
|
26
|
-
value whole and returns its unsubscribe, and `close()` ends the observation.
|
|
27
|
-
Closing the port ends every handle and rejects every pending call and
|
|
28
|
-
observation; a client that reconnects observes again.
|
|
29
|
-
|
|
30
|
-
`observe('agents')` answers every Agent a new conversation can go to, each
|
|
31
|
-
`{ identity, name }`, whether or not it has a conversation yet.
|
|
32
|
-
Each conversation the Provider's conversation list names is held complete in the
|
|
33
|
-
browser. `conversation.list()` and `observe('conversations')` answer each with its
|
|
34
|
-
Agent's identity and name, its name, created and finished times, last outcome and live
|
|
35
|
-
`state`: `asking` while a question waits, `working` while a turn runs, else `idle`,
|
|
36
|
-
and `started`, when the running turn began, or `null`.
|
|
37
|
-
Observe one with `observe('conversation', id, { limit })`: the view
|
|
38
|
-
holds its latest `limit` messages, or all of them, oldest first, its chat
|
|
39
|
-
draft, and what the Provider streams for it whether or not anything views it:
|
|
40
|
-
the running `turn` with its message parts and its context in use and window, the
|
|
41
|
-
open questions, the process state, and the CLI's commands and options. These live
|
|
42
|
-
only in memory: the message accepted under the turn's id replaces the running turn,
|
|
43
|
-
and none of them is stored or searchable.
|
|
44
|
-
`chatDraft.write` and `chatDraft.discard` keep what the App Creator composes;
|
|
45
|
-
sending it is a Provider Action that needs the Provider reachable and is never
|
|
46
|
-
queued.
|
|
47
|
-
|
|
48
|
-
A binary file at a Path of a Room is a binary Path entry. Query lists it by
|
|
49
|
-
`path` with its `binaryFile` record and never its bytes: `{ state: 'accepted',
|
|
50
|
-
revision, path, fileRef, byteLength, mediaType, sha256 }`, or, from a Save until
|
|
51
|
-
the Provider accepts it, `{ state: 'pending', localId, path, byteLength,
|
|
52
|
-
mediaType, sha256 }` with no revision. Write one with a Room Draft whose only part
|
|
53
|
-
is `file: { blob }`, a `Blob` whose `type` is its media type; Save keeps the bytes
|
|
54
|
-
in its Pending Change, works offline, and the record turns accepted with the
|
|
55
|
-
Provider's revision once the Pending Change is accepted. Move or remove an
|
|
56
|
-
accepted one as a Document. Move or remove a pending one the same way, before or
|
|
57
|
-
after Save: the Room Draft or its queued Pending Change carries the bytes to the
|
|
58
|
-
new Path or drops them, and once that Pending Change has gone to the Provider
|
|
59
|
-
Save refuses it as `unknown-revision` until it is accepted. Read the bytes with
|
|
60
|
-
`binaryFile.read(room, path)`: a pending record answers its saved bytes, and
|
|
61
|
-
every read of an accepted one asks the Provider again and keeps nothing. Pass a
|
|
62
|
-
History revision as `binaryFile.read(room, path, revision)` to open that
|
|
63
|
-
revision, a removed file's last one included. Text, a Record attachment or a conversation
|
|
64
|
-
message may name a file directly by its `fileRef`; read that file with
|
|
65
|
-
`binaryFile.readReference({ fileRef, referrer })`, where the referrer is the
|
|
66
|
-
`referrer` the Provider gave beside the reference, or `{ room, path }` of the
|
|
67
|
-
document whose text names it. Both answer `{ kind: 'binary', blob }` or a
|
|
68
|
-
refusal or failure. History of a binary Path lists each revision's
|
|
69
|
-
`binaryFile` metadata without bytes.
|
|
70
|
-
|
|
71
|
-
Rooms, Query, Search, Observe, Types, Room Draft, Save, and Reached never
|
|
72
|
-
touch the network.
|
|
73
|
-
History, the binary file reads and Call go to the Provider through the Adapter. Call takes the Action names
|
|
74
|
-
the Adapter declares; any other name answers `undeclared` without reaching the
|
|
75
|
-
Provider. A Call result whose
|
|
76
|
-
effect the Provider places in a Room carries `at`, that Room and Room Version;
|
|
77
|
-
`reached(room, roomVersion)` answers whether the Room's confirmed state has
|
|
78
|
-
reached it, and the MD Runtime keeps refreshing that Room until it has;
|
|
79
|
-
`reached(room, roomVersion, path)` answers whether the held confirmed copy of
|
|
80
|
-
that document was written at a later Room Version. Each History revision
|
|
81
|
-
names its author, `{ kind: 'user', id }` or `{ kind: 'site', id, name }`.
|
|
82
|
-
History of a Path no current document holds answers the removed document's
|
|
83
|
-
revisions with `deleted: true`, newest first; that revision is what a link to
|
|
84
|
-
the Path opens. Every
|
|
85
|
-
member of the
|
|
86
|
-
client is asynchronous. Results are detached snapshots. Nothing in this
|
|
87
|
-
surface returns the authorization, performs a request the App's code
|
|
88
|
-
composes, or exposes the browser store.
|
|
89
|
-
|
|
90
|
-
Every refusal and failure carries `code` and `retryable`: each Call and History answer
|
|
91
|
-
other than its result, a refused Save or Room Draft write, a returned Room Draft's
|
|
92
|
-
reason, a Room's refusal and the Connection Refusal, and every error a member rejects
|
|
93
|
-
with, beside its message. A Provider refusal carries the Provider's own `retryable`.
|
|
94
|
-
Every code and every value the API answers is open: handle one you do not know by its
|
|
95
|
-
`code` and `retryable`.
|
|
96
|
-
|
|
97
|
-
Read the deployment facts with `observe('deployment-facts')`. Interpret the
|
|
98
|
-
opaque value using the host's contract.
|
|
99
|
-
|
|
100
|
-
`observe('member')` answers who uses the App: the User the Provider signed in,
|
|
101
|
-
`{ kind: 'user', id, name }` in the shape of a change's `author`, so a Document
|
|
102
|
-
whose `change.author.id` equals its `id` is that User's own. It is `null` until
|
|
103
|
-
the Provider first names one, and where it names none, such as a Site. The
|
|
104
|
-
MD Runtime keeps it with the Local Replicas, so it answers offline once known,
|
|
105
|
-
and every port hears the next member the Provider names; signing out answers
|
|
106
|
-
`null`, then ends the observation with the authorization. It is the only way App code learns who
|
|
107
|
-
uses it.
|
|
108
|
-
|
|
109
|
-
The in-memory Adapter at `@agentshouse/mdruntime/memory` is for tests and
|
|
110
|
-
ships in no bundle.
|
|
111
|
-
|
|
112
|
-
## Local Query rules
|
|
113
|
-
|
|
114
|
-
`query(q)` answers once from local state; `observe('query', q)` holds the whole
|
|
115
|
-
result and hears it again only when it changes, keeping every unchanged Document
|
|
116
|
-
the same object, so a component can tell what changed by identity. A query is
|
|
117
|
-
data:
|
|
118
|
-
|
|
119
|
-
- **Filter.** `rooms` names Room locators and defaults to every Room. `types`
|
|
120
|
-
names MD Types, and `any` names untyped Markdown Documents. `pathPrefix` is a
|
|
121
|
-
directory: `notes` keeps `notes/a.md` and not `notes2/a.md`.
|
|
122
|
-
- **Fields.** Every frontmatter value is named by JSON Pointer: `/status`,
|
|
123
|
-
`/shipping/city`, `~1` for a `/` and `~0` for a `~` in a key. A segment that
|
|
124
|
-
meets a list applies to every item and a number names one item. `where` names
|
|
125
|
-
pointers, ANDs them, and nests `$and` and `$or`; a pointer through a list holds
|
|
126
|
-
when any item satisfies it. A bare value is equality; the operators are `$eq`,
|
|
127
|
-
`$ne`, `$in`, `$nin`, `$gt`, `$gte`, `$lt`, `$lte`, `$all`, `$size` and
|
|
128
|
-
`$exists`. Equality on a list asks whether it contains the value. Missing, null and empty differ:
|
|
129
|
-
`$exists: false` keeps a missing field, `null` an explicit null, `''` empty
|
|
130
|
-
text and `$size: 0` an empty list. A date compares in calendar order and never
|
|
131
|
-
with a date-time. A reference compares by the Room Path it resolves to.
|
|
132
|
-
Untyped frontmatter, and a value under `oneOf` or a conditional, is plain
|
|
133
|
-
values. There is no text containment or regular
|
|
134
|
-
expression.
|
|
135
|
-
- **Relations.** `hop: { field, types, where, pathPrefix }` keeps Documents whose
|
|
136
|
-
reference at pointer `field`, at any depth, points to a matching Document of the
|
|
137
|
-
same Room. `backlinks: { field, types, where, pathPrefix }` keeps Documents that a
|
|
138
|
-
matching Document of the same Room references. Each keeps a Document once.
|
|
139
|
-
- **Parts.** A Document query must `select`: `'all'`, or `fields`, `sections`,
|
|
140
|
-
`preamble`, `markdown`, `backlinks` and `change`, where `fields` is `'all'` or a
|
|
141
|
-
list of pointers and `sections` `'all'` or a list of names. Selected pointers
|
|
142
|
-
return the frontmatter holding only them, nested as written. A backlink names
|
|
143
|
-
the referring Path, MD Type and the pointer it came from as `field`. Room and Path always return; a Markdown
|
|
144
|
-
Document also returns its MD Type. A non-Markdown Document returns only Room
|
|
145
|
-
and Path, and a binary Path entry Room, Path and its `binaryFile` record,
|
|
146
|
-
whatever is selected. An unselected part is absent. Select only
|
|
147
|
-
what a screen shows: a list that selects the Markdown hears every edit of it.
|
|
148
|
-
- **Change.** `change` is `{ author, time }` of the Document's head revision as
|
|
149
|
-
the Provider last delivered it: `author` is `{ kind: 'user' | 'site', id, name }`
|
|
150
|
-
or `null` for a write the Provider made itself, and `time` is the Provider's
|
|
151
|
-
ISO 8601 change time. It is `null` where the Provider delivered no time, as at
|
|
152
|
-
a Site. An unsent edit or move keeps it, an unsent creation has none, and a
|
|
153
|
-
saved write takes the Provider's own once it is Accepted. A
|
|
154
|
-
Room's last change is its Document with the latest `time`.
|
|
155
|
-
- **Order and groups.** `orderBy` sorts by `room`, `path`, `type` or `{ field }`
|
|
156
|
-
with TanStack DB's own options, and ties end with Room, then Path. `groupBy` by
|
|
157
|
-
`room`, `type` or `{ field }` answers `{ groups: [{ key, count }] }`, counted
|
|
158
|
-
over every match and ordered by `count` or a key. A sort or group takes only a
|
|
159
|
-
pointer that holds one value. `limit` bounds the Documents or the groups.
|
|
160
|
-
- **Results and errors.** A result carries no Room Version: read freshness from
|
|
161
|
-
Rooms and Sync Status. An invalid query fails with the `code`
|
|
162
|
-
`invalid-query`, `unknown-type`, `unknown-field` or `wrong-kind`, naming where,
|
|
163
|
-
and never answers an empty result in its place.
|
|
164
|
-
|
|
165
|
-
## Local Search rules
|
|
166
|
-
|
|
167
|
-
`search({ text, documents, conversations, limit })` answers once, by words, from
|
|
168
|
-
local state, with MiniSearch at its default configuration. There is no observed
|
|
169
|
-
search.
|
|
170
|
-
|
|
171
|
-
- **What is found.** A Document by its field values, its sections' headings and
|
|
172
|
-
text, its preamble and its Path; a message by its text. Frontmatter keys, Room
|
|
173
|
-
Drafts, chat drafts and a running turn's parts are never found. There are no phrases,
|
|
174
|
-
word forms, typo tolerance or prefix matching.
|
|
175
|
-
- **Narrowing.** `documents` is a Local Query filter: `rooms`, `types`, `where`,
|
|
176
|
-
`pathPrefix`, `hop` and `backlinks`. `conversations` names conversations. Both
|
|
177
|
-
apply before `limit`, which bounds each list; without it every hit returns.
|
|
178
|
-
- **Results.** `{ documents, messages }`, each ranked by `score`, which compares
|
|
179
|
-
hits of one list of one search. A Document hit names its `room`, `path` and
|
|
180
|
-
`type`, a message hit its `conversation` and `identity`, and `matches` maps each
|
|
181
|
-
matched word to the parts it matched in: `fields`, `sections`, `preamble` or
|
|
182
|
-
`path`, or `text`. A hit carries no position; mark the words in the text you
|
|
183
|
-
show. An invalid filter fails with its Local Query error.
|
|
184
|
-
|
|
185
|
-
## Room Draft, Save, and outcome rules
|
|
186
|
-
|
|
187
|
-
The MD Runtime owns one Room Draft per Room and Path, shared by every App and
|
|
188
|
-
tab. It is durable: it survives reload and navigation. A Room that Discovery
|
|
189
|
-
stops listing takes its Room Drafts and its queue with it.
|
|
190
|
-
Write a Room Draft with `roomDraft.write(room, path, revision, parts)`, naming
|
|
191
|
-
the revision you read, or `null` when there was none, and every part it should
|
|
192
|
-
now change: fields, sections and the preamble, or the whole Markdown, a
|
|
193
|
-
creation, a move, or a removal. A part new to the Room Draft names its base,
|
|
194
|
-
the value you showed when it was opened; the MD Runtime keeps a part's first
|
|
195
|
-
base. A binary link target has a Room Draft too, for a move or a removal, with
|
|
196
|
-
`null` as its base. A write or a discard from an older revision is refused as `stale` with
|
|
197
|
-
the current Room Draft; read it and write again.
|
|
198
|
-
|
|
199
|
-
Save takes one Room and the Room Drafts of it to save, each with its revision,
|
|
200
|
-
validates locally, and on success appends one Change Batch to that Room's
|
|
201
|
-
queue and removes those Room Drafts. It is refused with the `code` `stale`,
|
|
202
|
-
`changed-underneath` naming each part whose base no longer matches the visible
|
|
203
|
-
state, or a local validation rule, and then creates nothing and leaves every
|
|
204
|
-
Room Draft in place. A directory move or removal is a move or removal part on
|
|
205
|
-
each Document and binary link target beneath it, saved together.
|
|
206
|
-
|
|
207
|
-
Outcomes follow the Provider's answer. An Accepted Change Batch stays in the
|
|
208
|
-
queue, drawn over the confirmed layer, until the confirmed layer reaches the
|
|
209
|
-
Room Version it was accepted at, and then leaves it. Conflicted and Rejected, an expired operation, and a change that no
|
|
210
|
-
longer applies over the Room each leave the queue and return as Room Drafts on
|
|
211
|
-
the Documents they changed, marked with why: the Provider's structured refusal
|
|
212
|
-
code and fields as returned, not known to have applied, or withdrawn locally.
|
|
213
|
-
The rest of the queue keeps synchronizing, and Sync Status requires attention
|
|
214
|
-
until each returned Room Draft is saved again or discarded. A Change Batch
|
|
215
|
-
keeps no outcome once it leaves the queue; `observe('queue', room)` shows each
|
|
216
|
-
Pending one, and a returned Room Draft says why it returned. Transport
|
|
217
|
-
failure and Provider unavailability keep work Pending and do not infer a
|
|
218
|
-
rejection. A refusal the Provider marks retryable stays Pending until the reset
|
|
219
|
-
it names; the MD Runtime retries the same Change Batch identity and payload and
|
|
220
|
-
never infers an outcome from transport uncertainty. The MD Runtime never
|
|
221
|
-
combines, reorders, or rebases.
|
|
222
|
-
|
|
223
|
-
On a Site, every Save stays in the visitor's browser. Write grants and
|
|
224
|
-
revisions do not refuse it, and its Pending Change shows in every query and
|
|
225
|
-
across reloads until the browser's storage is cleared. It is never sent:
|
|
226
|
-
`observe('queue', room)` shows it `local`, and Sync Status never waits on it.
|
|
227
|
-
Once the Room changes so that it no longer applies, it leaves the queue and
|
|
228
|
-
returns no Room Draft.
|
|
229
|
-
|
|
230
|
-
`observe('service-mode')` answers the Provider's Service
|
|
231
|
-
Mode, `open` or `write-halted`. While writes are halted, Save still succeeds,
|
|
232
|
-
its Change Batch waits unsent, and the queue is submitted in order once the
|
|
233
|
-
Provider reopens writes. An Action is never held: a write the Provider refuses
|
|
234
|
-
for the halt returns that refusal to its caller. Show the Provider as read-only
|
|
235
|
-
instead of retrying.
|
|
236
|
-
|
|
237
|
-
## The neutrality rule
|
|
238
|
-
|
|
239
|
-
No module outside an Adapter package imports, names, or special-cases a
|
|
240
|
-
Provider. MD UI and every App reach data only through the client entry.
|
|
241
|
-
|
|
242
|
-
## Content-safety rules
|
|
243
|
-
|
|
244
|
-
The Provider authorization belongs to the Runtime host and is never readable
|
|
245
|
-
by the App's code. The App's code reaches the network only at the external
|
|
246
|
-
origins its manifest declares, empty by default, and the Provider enforces
|
|
247
|
-
that set. Every request to the Provider itself goes through the MD Runtime.
|
|
248
|
-
Rendered Markdown never executes scripts, renders raw HTML only for the
|
|
249
|
-
details and summary elements, and loads images and other resources only from
|
|
250
|
-
origins the Provider's policy allows.
|
|
251
|
-
|
|
252
|
-
## Launch promises MD UI keeps
|
|
253
|
-
|
|
254
|
-
MD UI uses semantic HTML, is fully operable from a keyboard with visible
|
|
255
|
-
focus and labelled controls, and lays out from a 360 pixel wide viewport to
|
|
256
|
-
a desktop. Its strings are English only, dates and numbers follow the
|
|
257
|
-
browser locale, and content is never translated. Light and dark themes come
|
|
258
|
-
from CSS custom properties with the browser's preference as the default and
|
|
259
|
-
an App's override respected. What an App Creator's agent adds carries none
|
|
260
|
-
of these promises by itself. Reading, querying and searching never wait for
|
|
261
|
-
the network. Data lives only in the App Creator's browser and with the Provider.
|
|
262
|
-
|
|
263
|
-
## App code takes the client its host hands it and never constructs a Runtime
|
|
264
|
-
|
|
265
|
-
App code takes the client its host hands it: in House, `houseBridge().runtime`
|
|
266
|
-
from `@agentshouse/app-bridge` resolves to the client House built into the page.
|
|
267
|
-
It never constructs a Runtime or a client. It imports only types from
|
|
268
|
-
`@agentshouse/mdruntime/client`, does not call `connectMdRuntime` or
|
|
269
|
-
`serveMdRuntime`, and does not import the package main, the host entry, or the
|
|
270
|
-
Adapter package. Hosts and tests use those entries; the served App does not.
|
|
271
|
-
|
|
272
|
-
A React App may observe and save through `@agentshouse/mdruntime/react`, which
|
|
273
|
-
names React as a peer dependency. `useObserve(client, topic, ...input)` takes
|
|
274
|
-
the arguments of `observe` and returns `{ state: 'loading' }` until the topic's
|
|
275
|
-
first value arrives, then `{ state: 'ready', value }`, re-rendering on each
|
|
276
|
-
change; a `null` client observes nothing and stays loading. `useSave(client)`
|
|
277
|
-
returns `busy`, the last `outcome` or `failure`, and `save(room, roomDrafts)`,
|
|
278
|
-
which writes each Path's parts onto the Room Draft already there, keeping the
|
|
279
|
-
bases its parts have, or onto a new one, and saves them together. A refused
|
|
280
|
-
Save leaves the Room Drafts for the App to save again or discard; a failure is
|
|
281
|
-
recorded and rejects. `saveRoomDrafts(client, room, roomDrafts)` is that save
|
|
282
|
-
outside a component. A react-admin or Refine App reads and writes its Rooms
|
|
283
|
-
through the data providers of `@agentshouse/mdruntime-families`.
|
|
284
|
-
|
|
285
|
-
## The Chat
|
|
286
|
-
|
|
287
|
-
`@agentshouse/mdruntime/chat` holds the Chat, one data layer for every App.
|
|
288
|
-
Its required peers are React, React DOM and `@assistant-ui/react`: add React as
|
|
289
|
-
a dependency, also in an App not written in React.
|
|
290
|
-
|
|
291
|
-
Place the ready chat with `<Chat client={runtime} conversation={id}
|
|
292
|
-
agent={agent} width="1/3" showChats />`: `conversation` opens one, `null` for a
|
|
293
|
-
new chat, `agent` is the Agent a new chat goes to, `onOpen` hears each one it
|
|
294
|
-
opens, and `width` is `full` (the place you give it), or `3/4`, `1/2` or `1/3`
|
|
295
|
-
of the window docked at its right edge, whole on a narrow window. `showChats`
|
|
296
|
-
adds its conversation list; or draw your own inside a `ChatProvider` around a
|
|
297
|
-
`<Chat />` with no `client`. It carries its own styles; theme it with CSS custom
|
|
298
|
-
properties on it or an ancestor: `--chat-background`, `--chat-surface`,
|
|
299
|
-
`--chat-text`, `--chat-text-muted`, `--chat-accent`, `--chat-line`,
|
|
300
|
-
`--chat-attention`, `--chat-danger`, `--chat-font`, `--chat-font-mono`,
|
|
301
|
-
`--chat-font-size`, `--chat-radius` and `--chat-density` (a factor for spacing);
|
|
302
|
-
an unset one keeps House's light or dark look. `mountChat(element, { client })`
|
|
303
|
-
places it outside React and returns `update(props)` and `unmount()`.
|
|
304
|
-
|
|
305
|
-
Mix `ChatMessageList` (`components` takes your `UserMessage` and
|
|
306
|
-
`AssistantMessage`), `ChatInput` and `ChatQuestionCard` with your own design
|
|
307
|
-
inside a `ChatProvider`, or compose assistant-ui's primitives there; `useChat()`
|
|
308
|
-
gives `send`, the conversations, the Agents, questions to `answer`, `options`
|
|
309
|
-
to `choose`, `commands`, the queue to `edit` or `unqueue`, `stop`, `kill` and
|
|
310
|
-
outcomes; never replace its messages, sending or store. A secret question is
|
|
311
|
-
never answered here; typed answers live in Presentation State's `typed` key:
|
|
312
|
-
keep it, and change Presentation State only inside `inTurn(client, work)` from
|
|
313
|
-
`@agentshouse/mdruntime/client`. `Markdown` draws Markdown safely.
|
|
314
|
-
|
|
315
|
-
## What an agent must never do
|
|
316
|
-
|
|
317
|
-
An agent must never read the authorization, load code from a Room, call the
|
|
318
|
-
Provider directly, or rebase a refused Change Batch.
|
package/dist/chat/acts.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { type Answered } from '../attempt.js';
|
|
2
|
-
import { type CallResult } from '../outcome.js';
|
|
3
|
-
import type { Expected } from './overlay.js';
|
|
4
|
-
export type ChatResult = CallResult | {
|
|
5
|
-
readonly kind: 'offline';
|
|
6
|
-
};
|
|
7
|
-
export type ChatOutcome = {
|
|
8
|
-
readonly state: 'sending';
|
|
9
|
-
} | {
|
|
10
|
-
readonly state: 'offline';
|
|
11
|
-
} | {
|
|
12
|
-
readonly state: 'failed';
|
|
13
|
-
readonly result: CallResult;
|
|
14
|
-
};
|
|
15
|
-
export declare function accepted(result: ChatResult): result is Extract<CallResult, {
|
|
16
|
-
readonly kind: 'action';
|
|
17
|
-
}>;
|
|
18
|
-
export declare function unanswered(result: ChatResult): boolean;
|
|
19
|
-
export declare function outcomeOf(result: ChatResult): ChatOutcome | null;
|
|
20
|
-
export declare function answeredOf(result: ChatResult): Answered;
|
|
21
|
-
export type Sender = {
|
|
22
|
-
carried(name: string, about: unknown, sending: (operation: string) => Promise<CallResult>): Promise<ChatResult>;
|
|
23
|
-
expect(expected: Expected): void;
|
|
24
|
-
draw(expected: Expected): void;
|
|
25
|
-
};
|
|
26
|
-
type Senders = {
|
|
27
|
-
readonly online: boolean;
|
|
28
|
-
identity(intent: string): string;
|
|
29
|
-
expect(expected: Expected): void;
|
|
30
|
-
draw(expected: Expected): void;
|
|
31
|
-
};
|
|
32
|
-
export declare function sender({ online, identity, expect, draw }: Senders): Sender;
|
|
33
|
-
export {};
|
|
34
|
-
//# sourceMappingURL=acts.d.ts.map
|
package/dist/chat/acts.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"acts.d.ts","sourceRoot":"","sources":["../../src/chat/acts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAa,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7C,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC;AAEnE,MAAM,MAAM,WAAW,GACnB;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GAC7B;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GAC7B;IAAE,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAA;CAAE,CAAC;AAE9D,wBAAgB,QAAQ,CACtB,MAAM,EAAE,UAAU,GACjB,MAAM,IAAI,OAAO,CAAC,UAAU,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,CAE5D;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAEtD;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,WAAW,GAAG,IAAI,CAGhE;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,UAAU,GAAG,QAAQ,CAIvD;AAED,MAAM,MAAM,MAAM,GAAG;IACnB,OAAO,CACL,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,CAAC,GAClD,OAAO,CAAC,UAAU,CAAC,CAAC;IACvB,MAAM,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IACjC,IAAI,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;CAChC,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,MAAM,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IACjC,IAAI,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;CAChC,CAAC;AAEF,wBAAgB,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,OAAO,GAAG,MAAM,CAa1E"}
|
package/dist/chat/acts.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { intentOf } from '../attempt.js';
|
|
2
|
-
import { UNCERTAIN } from '../outcome.js';
|
|
3
|
-
export function accepted(result) {
|
|
4
|
-
return result.kind === 'action';
|
|
5
|
-
}
|
|
6
|
-
export function unanswered(result) {
|
|
7
|
-
return result.kind === 'transport-uncertainty';
|
|
8
|
-
}
|
|
9
|
-
export function outcomeOf(result) {
|
|
10
|
-
if (accepted(result))
|
|
11
|
-
return null;
|
|
12
|
-
return result.kind === 'offline' ? { state: 'offline' } : { state: 'failed', result };
|
|
13
|
-
}
|
|
14
|
-
export function answeredOf(result) {
|
|
15
|
-
if (accepted(result))
|
|
16
|
-
return 'accepted';
|
|
17
|
-
if (result.kind === 'offline')
|
|
18
|
-
return 'offline';
|
|
19
|
-
return unanswered(result) ? 'unanswered' : 'refused';
|
|
20
|
-
}
|
|
21
|
-
export function sender({ online, identity, expect, draw }) {
|
|
22
|
-
return {
|
|
23
|
-
async carried(name, about, sending) {
|
|
24
|
-
if (!online)
|
|
25
|
-
return { kind: 'offline' };
|
|
26
|
-
try {
|
|
27
|
-
return await sending(identity(intentOf(name, about)));
|
|
28
|
-
}
|
|
29
|
-
catch {
|
|
30
|
-
return UNCERTAIN;
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
expect,
|
|
34
|
-
draw,
|
|
35
|
-
};
|
|
36
|
-
}
|
package/dist/chat/context.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/chat/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAQjD,wBAAgB,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAExD"}
|
package/dist/chat/input.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type ReactElement, type ReactNode } from 'react';
|
|
2
|
-
import { type ChatNoteProps } from './kit.js';
|
|
3
|
-
export type ChatInputProps = {
|
|
4
|
-
readonly messageLength?: number;
|
|
5
|
-
readonly note?: (note: ChatNoteProps) => ReactNode;
|
|
6
|
-
readonly autoFocus?: boolean;
|
|
7
|
-
};
|
|
8
|
-
export declare function ChatInput({ messageLength, note, autoFocus, }: ChatInputProps): ReactElement;
|
|
9
|
-
//# sourceMappingURL=input.d.ts.map
|
package/dist/chat/input.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/chat/input.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA0C,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAqBlG,OAAO,EAAsD,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAMlG,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,SAAS,CAAC;IACnD,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAiGF,wBAAgB,SAAS,CAAC,EACxB,aAAa,EACb,IAAY,EACZ,SAAiB,GAClB,EAAE,cAAc,GAAG,YAAY,CA+K/B"}
|
package/dist/chat/input.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useContext, useEffect, useMemo, useRef } from 'react';
|
|
3
|
-
import { ComposerPrimitive, useAui, useAuiState, } from '@assistant-ui/react';
|
|
4
|
-
import { DropdownMenu } from 'radix-ui';
|
|
5
|
-
import ArrowUp from 'lucide-react/dist/esm/icons/arrow-up.mjs';
|
|
6
|
-
import Check from 'lucide-react/dist/esm/icons/check.mjs';
|
|
7
|
-
import ChevronDown from 'lucide-react/dist/esm/icons/chevron-down.mjs';
|
|
8
|
-
import CornerDownRight from 'lucide-react/dist/esm/icons/corner-down-right.mjs';
|
|
9
|
-
import ListEnd from 'lucide-react/dist/esm/icons/list-end.mjs';
|
|
10
|
-
import Paperclip from 'lucide-react/dist/esm/icons/paperclip.mjs';
|
|
11
|
-
import Pencil from 'lucide-react/dist/esm/icons/pencil.mjs';
|
|
12
|
-
import Plus from 'lucide-react/dist/esm/icons/plus.mjs';
|
|
13
|
-
import Square from 'lucide-react/dist/esm/icons/square.mjs';
|
|
14
|
-
import X from 'lucide-react/dist/esm/icons/x.mjs';
|
|
15
|
-
import { contextText } from './context.js';
|
|
16
|
-
import { Button, ChatNote, IconButton, Name, Portal, Scoped } from './kit.js';
|
|
17
|
-
import { COMMAND } from './process.js';
|
|
18
|
-
import { useChat, useChatScope } from './provider.js';
|
|
19
|
-
import { forgetAnswers } from './question.js';
|
|
20
|
-
import { useOpened } from './opened.js';
|
|
21
|
-
const commanded = {
|
|
22
|
-
serialize: (item) => `${COMMAND}${item.id}`,
|
|
23
|
-
parse: (said) => [{ kind: 'text', text: said }],
|
|
24
|
-
};
|
|
25
|
-
const atStart = (said, char, cursor) => {
|
|
26
|
-
const typed = said.slice(0, cursor);
|
|
27
|
-
return typed.startsWith(char) && !/\s/.test(typed)
|
|
28
|
-
? { query: typed.slice(char.length), offset: 0, endOffset: cursor }
|
|
29
|
-
: null;
|
|
30
|
-
};
|
|
31
|
-
function commandItem(command) {
|
|
32
|
-
return {
|
|
33
|
-
id: command.name,
|
|
34
|
-
type: 'command',
|
|
35
|
-
label: `${COMMAND}${command.name}`,
|
|
36
|
-
description: command.description,
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function commandsFound(commands, query) {
|
|
40
|
-
const asked = query.toLowerCase();
|
|
41
|
-
const named = commands.filter((one) => one.name.toLowerCase().startsWith(asked));
|
|
42
|
-
const within = commands.filter((one) => !named.includes(one) && one.name.toLowerCase().includes(asked));
|
|
43
|
-
return [...named, ...within].map(commandItem);
|
|
44
|
-
}
|
|
45
|
-
function Attached({ id, name }) {
|
|
46
|
-
const aui = useAui();
|
|
47
|
-
return (_jsxs("span", { className: "ahc-chip ahc-chip--removable", children: [_jsx(Paperclip, { "aria-hidden": "true" }), _jsx(Name, { text: name }), _jsx(IconButton, { label: `Remove ${name}`, compact: true, onClick: () => void aui.composer().attachment({ id }).remove(), children: _jsx(X, { "aria-hidden": "true" }) })] }));
|
|
48
|
-
}
|
|
49
|
-
function Picker({ option, choose, }) {
|
|
50
|
-
const container = useContext(Portal);
|
|
51
|
-
return (_jsxs(DropdownMenu.Root, { modal: false, children: [_jsxs(DropdownMenu.Trigger, { className: "ahc-btn ahc-picker", "aria-label": option.name, title: option.name, children: [_jsx(Name, { text: option.values.find((one) => one.value === option.value)?.name ?? option.value }), _jsx(ChevronDown, { "aria-hidden": "true" })] }), _jsx(DropdownMenu.Portal, { container: container, children: _jsxs(DropdownMenu.Content, { className: "ahc-menu", side: "top", align: "start", children: [_jsx(DropdownMenu.Label, { className: "ahc-menu__heading", children: option.name }), _jsx(DropdownMenu.RadioGroup, { value: option.value, onValueChange: (value) => {
|
|
52
|
-
if (value !== option.value)
|
|
53
|
-
void choose(option.id, value);
|
|
54
|
-
}, children: option.values.map((one) => (_jsxs(DropdownMenu.RadioItem, { value: one.value, className: "ahc-row", children: [_jsx("span", { className: "ahc-row__label", children: one.name }), _jsx(DropdownMenu.ItemIndicator, { asChild: true, children: _jsx(Check, { "aria-hidden": "true" }) })] }, one.value))) })] }) })] }));
|
|
55
|
-
}
|
|
56
|
-
function noted(note) {
|
|
57
|
-
return _jsx(ChatNote, { ...note });
|
|
58
|
-
}
|
|
59
|
-
export function ChatInput({ messageLength, note = noted, autoFocus = false, }) {
|
|
60
|
-
const chat = useChat();
|
|
61
|
-
const { client } = useChatScope();
|
|
62
|
-
const aui = useAui();
|
|
63
|
-
const opened = useOpened();
|
|
64
|
-
const { lone, commands, context, queued, running } = opened;
|
|
65
|
-
const conversation = chat.conversation ?? '';
|
|
66
|
-
const input = useRef(null);
|
|
67
|
-
const picker = useRef(null);
|
|
68
|
-
const thread = chat.conversation ?? `new:${chat.agent ?? ''}`;
|
|
69
|
-
useEffect(() => {
|
|
70
|
-
if (autoFocus)
|
|
71
|
-
input.current?.focus();
|
|
72
|
-
}, [autoFocus, thread]);
|
|
73
|
-
const typed = useAuiState((s) => s.composer.text);
|
|
74
|
-
const attached = useAuiState((s) => s.composer.attachments.length > 0);
|
|
75
|
-
const fault = messageLength !== undefined && typed.length > messageLength
|
|
76
|
-
? `Keep it to ${messageLength} characters.`
|
|
77
|
-
: null;
|
|
78
|
-
const listed = useMemo(() => ({
|
|
79
|
-
categories: () => [],
|
|
80
|
-
categoryItems: () => [],
|
|
81
|
-
search: (query) => commandsFound(commands, query),
|
|
82
|
-
}), [commands]);
|
|
83
|
-
const interrupt = () => void chat.stop().then((stopped) => {
|
|
84
|
-
if (stopped)
|
|
85
|
-
void forgetAnswers(client, conversation);
|
|
86
|
-
});
|
|
87
|
-
const edit = (id) => {
|
|
88
|
-
chat.edit(id);
|
|
89
|
-
input.current?.focus();
|
|
90
|
-
};
|
|
91
|
-
const drafted = typed.trim() !== '' || attached;
|
|
92
|
-
const readOnly = opened.deleted;
|
|
93
|
-
return (_jsx(Scoped, { children: _jsxs("div", { className: "ahc-input-area", children: [readOnly || queued.length === 0 ? null : (_jsxs("div", { role: "group", "aria-label": "Queued messages", className: "ahc-queue", children: [_jsxs("div", { className: "ahc-queue__head", children: [_jsx(ListEnd, { "aria-hidden": "true" }), _jsx("span", { className: "ahc-queue__said", children: `${queued.length} ${queued.length === 1 ? 'message waits' : 'messages wait'} for ${opened.name} to finish` }), running ? (_jsx(Button, { variant: "outline", compact: true, onClick: interrupt, children: "Send now" })) : null] }), queued.map((item) => (_jsxs("div", { className: "ahc-queue-row", children: [_jsx(CornerDownRight, { "aria-hidden": "true", className: "ahc-muted" }), _jsx("span", { className: "ahc-queue-row__text", children: item.text }), _jsx(IconButton, { label: "Edit queued message", compact: true, onClick: () => edit(item.id), children: _jsx(Pencil, { "aria-hidden": "true" }) }), _jsx(IconButton, { label: "Remove queued message", compact: true, onClick: () => chat.unqueue(item.id), children: _jsx(X, { "aria-hidden": "true" }) })] }, item.id)))] })), readOnly ? null : (_jsx(ComposerPrimitive.Root, { className: "ahc-composer", children: _jsxs(ComposerPrimitive.Unstable_TriggerPopoverRoot, { children: [commands.length === 0 ? null : (_jsxs(ComposerPrimitive.Unstable_TriggerPopover, { char: COMMAND, matcher: atStart, adapter: listed, "aria-label": "Commands", className: "ahc-menu ahc-commands", children: [_jsx(ComposerPrimitive.Unstable_TriggerPopover.Directive, { formatter: commanded }), _jsx(ComposerPrimitive.Unstable_TriggerPopoverItems, { children: (items) => items.map((item, index) => (_jsx(ComposerPrimitive.Unstable_TriggerPopoverItem, { item: item, index: index, className: "ahc-row ahc-row--two", children: _jsxs("span", { className: "ahc-row__label", children: [_jsx("span", { className: "ahc-row__title ahc-mono", children: item.label }), _jsx("span", { className: "ahc-row__sub", children: item.description })] }) }, item.id))) })] })), attached ? (_jsx("div", { className: "ahc-chips", children: _jsx(ComposerPrimitive.Attachments, { children: ({ attachment }) => _jsx(Attached, { id: attachment.id, name: attachment.name }) }) })) : null, _jsx(ComposerPrimitive.Input, { asChild: true, "aria-label": "Message", placeholder: lone === null ? `Message ${opened.name}` : lone.field.prompt, submitMode: fault === null ? 'enter' : 'none', children: _jsx("textarea", { ref: input, className: "ahc-composer__input", rows: 1 }) }), _jsxs("div", { className: "ahc-composer__bar", children: [_jsx(IconButton, { label: "Add files", onClick: () => picker.current?.click(), children: _jsx(Plus, { size: 20, "aria-hidden": "true" }) }), _jsx("input", { ref: picker, type: "file", multiple: true, hidden: true, onChange: (event) => {
|
|
94
|
-
const chosen = [...(event.target.files ?? [])];
|
|
95
|
-
event.target.value = '';
|
|
96
|
-
for (const file of chosen)
|
|
97
|
-
void aui.composer().addAttachment(file);
|
|
98
|
-
} }), opened.options.map((option) => (_jsx(Picker, { option: option, choose: chat.choose }, option.id))), _jsx("span", { className: "ahc-spacer" }), context === null ? null : (_jsx("span", { title: "Context in use", className: "ahc-meta", children: contextText(context) })), running ? (_jsx("button", { type: "button", className: `ahc-btn ahc-btn--icon ${drafted ? 'ahc-btn--outline' : 'ahc-btn--ink'}`, "aria-label": "Stop", title: "Stop", onClick: interrupt, children: _jsx(Square, { "aria-hidden": "true" }) })) : null, running && !drafted ? null : (_jsx(ComposerPrimitive.Send, { className: "ahc-btn ahc-btn--icon ahc-btn--ink", "aria-label": running ? 'Queue message' : 'Send', disabled: fault !== null, children: _jsx(ArrowUp, { size: 20, "aria-hidden": "true" }) }))] })] }) })), fault === null ? null : (_jsx("p", { className: "ahc-note", role: "status", "data-state": "refused", children: fault })), note({ outcome: chat.acting.outcome }), note({ outcome: chat.sending.outcome, again: chat.sending.again ?? undefined })] }) }));
|
|
99
|
-
}
|
package/dist/chat/kit.d.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { type ComponentPropsWithRef, type ReactElement, type ReactNode } from 'react';
|
|
2
|
-
import type { ChatOutcome } from './acts.js';
|
|
3
|
-
export type Variant = 'quiet' | 'ink' | 'outline' | 'danger' | 'danger-outline';
|
|
4
|
-
export declare const Portal: import("react").Context<HTMLElement | null>;
|
|
5
|
-
export declare function Within({ root, children, }: {
|
|
6
|
-
root: HTMLElement;
|
|
7
|
-
children: ReactNode;
|
|
8
|
-
}): ReactElement;
|
|
9
|
-
export declare function Scoped({ children }: {
|
|
10
|
-
children: ReactNode;
|
|
11
|
-
}): ReactElement;
|
|
12
|
-
export declare function buttonClass(variant: Variant, compact: boolean, icon: boolean): string;
|
|
13
|
-
type Native = Omit<ComponentPropsWithRef<'button'>, 'className'>;
|
|
14
|
-
export declare function Button({ variant, compact, type, children, ...rest }: Native & {
|
|
15
|
-
variant?: Variant;
|
|
16
|
-
compact?: boolean;
|
|
17
|
-
}): ReactElement;
|
|
18
|
-
export declare function IconButton({ label, variant, compact, type, ...rest }: Native & {
|
|
19
|
-
label: string;
|
|
20
|
-
variant?: Variant;
|
|
21
|
-
compact?: boolean;
|
|
22
|
-
}): ReactElement;
|
|
23
|
-
export declare function Name({ text, className }: {
|
|
24
|
-
text: string;
|
|
25
|
-
className?: string;
|
|
26
|
-
}): ReactElement;
|
|
27
|
-
export declare function Menu({ trigger, children, }: {
|
|
28
|
-
trigger: ReactElement;
|
|
29
|
-
children: ReactNode;
|
|
30
|
-
}): ReactElement;
|
|
31
|
-
export declare function MenuGap(): ReactElement;
|
|
32
|
-
export declare function MenuItem({ icon, danger, onSelect, children, }: {
|
|
33
|
-
icon: ReactNode;
|
|
34
|
-
danger?: boolean;
|
|
35
|
-
onSelect: () => void;
|
|
36
|
-
children: ReactNode;
|
|
37
|
-
}): ReactElement;
|
|
38
|
-
export declare function Confirm({ title, text, action, onConfirm, onClose, }: {
|
|
39
|
-
title: string;
|
|
40
|
-
text: string;
|
|
41
|
-
action: string;
|
|
42
|
-
onConfirm: () => void;
|
|
43
|
-
onClose: () => void;
|
|
44
|
-
}): ReactElement;
|
|
45
|
-
export declare function ItemRow({ lead, title, sub, trailing, }: {
|
|
46
|
-
lead: ReactNode;
|
|
47
|
-
title: ReactNode;
|
|
48
|
-
sub: ReactNode;
|
|
49
|
-
trailing: ReactNode;
|
|
50
|
-
}): ReactElement;
|
|
51
|
-
export declare function Working({ step }: {
|
|
52
|
-
step?: string | undefined;
|
|
53
|
-
}): ReactElement;
|
|
54
|
-
export type ChatNoteProps = {
|
|
55
|
-
readonly outcome: ChatOutcome | null;
|
|
56
|
-
readonly again?: (() => void) | undefined;
|
|
57
|
-
};
|
|
58
|
-
export declare function ChatNote({ outcome, again }: ChatNoteProps): ReactElement | null;
|
|
59
|
-
export {};
|
|
60
|
-
//# sourceMappingURL=kit.d.ts.map
|
package/dist/chat/kit.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"kit.d.ts","sourceRoot":"","sources":["../../src/chat/kit.tsx"],"names":[],"mappings":"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"}
|