@daex-dev/chat-ui 0.0.0-stage → 0.8.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Arul Sharma
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,438 @@
1
- # Temporary Holding Version
1
+ # @daex-dev/chat-ui
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Embeddable React chat components over `@daex-dev/sdk`.
4
+
5
+ Formerly `@ade-dev/chat-ui`. To move, change your imports to `@daex-dev/chat-ui`;
6
+ the `Ade*` names (`AdeChat`, `useAdeThread`, ...) still work as deprecated
7
+ aliases of the `DAEX*` names.
8
+
9
+ **Docs:** [Chat UI](https://ade-app.dev/docs/sdk/chat-ui) · [DAEX SDK](https://ade-app.dev/docs/sdk/overview)
10
+
11
+ This package renders an agent conversation for **your** users, not for DAEX
12
+ developers. There are no lanes, projects, repos, or worktrees in any prop or
13
+ any string it can display. Tool activity is renamed through a label map, so a
14
+ customer sees "Searching your invoices…" where the agent ran `server.tool`.
15
+
16
+ - Zero runtime dependencies. React and React DOM are peers; `@daex-dev/sdk` is an
17
+ optional peer used for types only.
18
+ - Theming is CSS custom properties only — no Tailwind, no class overrides.
19
+ - Every component is importable standalone; `<DaexChat>` is one assembly of them.
20
+
21
+ ```bash
22
+ npm install @daex-dev/chat-ui
23
+ ```
24
+
25
+ ```tsx
26
+ import { DaexChat, createTheme } from "@daex-dev/chat-ui";
27
+
28
+ <DaexChat
29
+ client={client}
30
+ threadKey="support-42"
31
+ labels={{ map: { "server.*": "Looking that up…" } }}
32
+ theme={createTheme({ accent: "#7c5cff", background: "#0e0f13" })}
33
+ />;
34
+ ```
35
+
36
+ ## Layout
37
+
38
+ ```
39
+ packages/chat-ui/
40
+ src/
41
+ index.ts public surface
42
+ sdkTypes.ts copied SDK contract (see below)
43
+ DaexChat.tsx composed default
44
+ composer/
45
+ Composer.tsx
46
+ composerState.ts pure send/steer/key decisions
47
+ transcript/
48
+ Transcript.tsx scroll container + row views + ActivityIndicator
49
+ ToolChip.tsx
50
+ ApprovalCard.tsx inline approval card
51
+ transcriptRows.ts ported row collapsing/grouping
52
+ markdown.tsx dependency-free markdown renderer
53
+ links.tsx DaexLink + onLinkClick context (every link chat-ui draws)
54
+ models/
55
+ ModelPicker.tsx rail + search + grouped list
56
+ ProviderCard.tsx ProviderCard, ProviderCards
57
+ modelSearch.ts ported scoring + provider grouping
58
+ activity/labels.ts label map, wildcards, phases, elapsed
59
+ theme/
60
+ createTheme.ts token generator
61
+ styles.ts the stylesheet
62
+ DaexChatStyles.tsx
63
+ context/AdeChatContext.tsx provider + useDaexProviders + useDaexThread
64
+ examples/
65
+ fakeClient.ts typed in-memory client
66
+ basic.tsx full assembly, both shapes
67
+ test/ 225 tests
68
+ ```
69
+
70
+ Ported files carry a provenance header naming their DAEX desktop source and what
71
+ was trimmed. `transcriptRows.ts` and `modelSearch.ts` are ports;
72
+ `Composer.tsx` and the model picker components are fresh implementations that
73
+ follow the desktop interaction/visual structure without inheriting its props.
74
+
75
+ ## Components
76
+
77
+ ### `<DaexChat>`
78
+
79
+ Transcript above, composer with the model rail below. No header bar.
80
+
81
+ | Prop | Type | Default | |
82
+ |---|---|---|---|
83
+ | `client` | `DaexChatClient` | — | required |
84
+ | `threadKey` | `string` | — | changing it opens a different conversation |
85
+ | `defaultModelId` / `modelId` | `string` | — | uncontrolled / controlled selection |
86
+ | `onModelChange` | `(model: ModelDescriptor) => void` | — | |
87
+ | `labels` | `ActivityLabelConfig` | — | |
88
+ | `theme` | `Partial<DaexChatTheme>` | — | usually `createTheme(...)` |
89
+ | `disableStyles` | `boolean` | `false` | skip the injected stylesheet |
90
+ | `placeholder`, `sendOnEnter`, `onRequestAttachment` | | | forwarded to `<Composer>` |
91
+ | `value` / `onValueChange` | | — | controlled draft, forwarded to `<Composer>` (0.4) |
92
+ | `onSend` | `(input, thread) => DaexChatSendResult \| Promise<…>` | — | runs before a new message is sent; `false` cancels and keeps the draft, `"handled"` means you sent it yourself (0.4) |
93
+ | `children` | `(thread: ThreadState) => ReactNode` | — | drawn between transcript and composer (0.4) |
94
+ | `threadRef` | `{ current: ThreadState \| null }` | — | the live thread state for code outside the tree (0.4) |
95
+ | `onLinkClick` | `(href, { source, text }) => void` | — | handle links yourself; pass it in Electron (0.4) |
96
+ | `modelRail` | `ReactNode` | built-in picker | replaces the default picker; `null` = empty rail |
97
+ | `actions` | `ReactNode` | — | extra composer controls (right rail) |
98
+ | `attachments` / `onAttachmentsChange` | | — | controlled staging; see the merge rule under `<Composer>` |
99
+ | `reasoningEffort` / `onReasoningEffortChange` | | — | the picker's effort control; the host applies it |
100
+ | `renderToolResult`, `toolChipActions` | | | forwarded to `<Transcript>` |
101
+ | `historyPageSize` | `number` | `200` | events per history page, when the thread has `historyPage` |
102
+ | `styleNonce` | `string` | — | CSP nonce for the injected `<style>` |
103
+ | `hideToolCalls`, `hideReasoning`, `renderMarkdown`, `emptyState` | | | forwarded to `<Transcript>` |
104
+ | `approvals` | `{ render?, labels? }` | — | approval card wording, or a replacement card |
105
+ | `hideModelPicker` | `boolean` | `false` | when the host pins a model |
106
+ | `className` | `string` | — | |
107
+
108
+ The approval card itself is not opt-in. A provider that asks for permission
109
+ parks its turn until someone answers, so a host that drew nothing would show a
110
+ conversation that had silently stopped. `approvals` changes only how it looks.
111
+
112
+ ### `<Composer>`
113
+
114
+ | Prop | Type | Default | |
115
+ |---|---|---|---|
116
+ | `onSend` | `(input: SendInput) => void \| Promise<void>` | — | required |
117
+ | `onSteer` | same | — | omit to disable steering entirely |
118
+ | `onInterrupt` | `() => void \| Promise<void>` | — | omit to hide Stop |
119
+ | `status` | `"idle" \| "running" \| "error"` | `"idle"` | |
120
+ | `ready` | `boolean` | `true` | false while the thread resolves |
121
+ | `disabled` | `boolean` | `false` | |
122
+ | `value` / `onValueChange` | `string` / `(v) => void` | — | controlled draft |
123
+ | `placeholder` | `string` | `"Send a message…"` | |
124
+ | `sendOnEnter` | `boolean` | `true` | false swaps to Cmd/Ctrl+Enter |
125
+ | `autoFocus` | `boolean` | `false` | |
126
+ | `maxRows` | `number` | `12` | autosize ceiling |
127
+ | `onRequestAttachment` | `() => Promise<ChatAttachment[] \| null> \| …` | — | omit to hide the button |
128
+ | `attachments` / `onAttachmentsChange` | | — | controlled staging |
129
+ | `modelRail` | `ReactNode` | — | slot for the model rail |
130
+ | `actions` | `ReactNode` | — | extra controls |
131
+ | `error` | `string \| null` | — | |
132
+ | `className` | `string` | — | |
133
+
134
+ Controlled attachments: `onAttachmentsChange` always receives the FULL new
135
+ list, so replace your state with it and never append. A picker result is merged
136
+ into the latest list (not the list from when the picker opened), duplicates are
137
+ removed by `id`, and a remove click removes one `id`. Every attachment is sent
138
+ with `type`: `"image"` for an `image/*` MIME type or an image extension (bmp,
139
+ gif, heic, heif, ico, jpeg, jpg, png, svg, tif, tiff, webp), else `"file"`. This
140
+ is the runtime's own rule.
141
+
142
+ Submitting during a running turn dispatches `onSteer`, never a second `onSend`,
143
+ and staged attachments go with the steer. Enter sends, Shift+Enter is a newline, IME composition never submits, Escape
144
+ interrupts a running turn. A failed send restores the draft rather than losing
145
+ it.
146
+
147
+ ### `<Transcript>`
148
+
149
+ | Prop | Type | Default | |
150
+ |---|---|---|---|
151
+ | `rows` | `readonly TranscriptRow[]` | — | from `buildTranscriptRows()` or `useDaexThread()` |
152
+ | `status` | `"idle" \| "running" \| "error"` | `"idle"` | drives the live indicator |
153
+ | `labels` | `ActivityLabelConfig` | — | |
154
+ | `hideToolCalls` | `boolean` | `false` | hides chips entirely |
155
+ | `hideReasoning` | `boolean` | `false` | |
156
+ | `expandReasoning` | `boolean` | `false` | reasoning starts collapsed |
157
+ | `renderMarkdown` | `(text: string) => ReactNode` | built-in | |
158
+ | `onLinkClick` | `(href, { source, text }) => void` | — | chat-ui calls `preventDefault()` and hands you the link. Without it, links open with `target="_blank"` — in Electron, a chrome-less app window (0.4) |
159
+ | `onApprove` | `(itemId, decision) => void \| Promise<void>` | — | omit to render approval cards read-only |
160
+ | `approvals` | `{ render?, labels? }` | — | custom approval card and button wording |
161
+ | `emptyState` | `ReactNode` | `"No messages yet."` | |
162
+ | `renderToolResult` | `(row: ToolChipRow) => ReactNode` | — | custom result view under a chip |
163
+ | `toolChipActions` | `(row: ToolChipRow) => { label, onSelect }[]` | — | buttons on a chip. Prefer `row.resourceLinks`; when a tool returns only ids, parse `row.result` yourself |
164
+ | `hasOlder` / `loadingOlder` / `onLoadOlder` | | — | "Load older messages" paging |
165
+ | `windowThreshold` | `number` | `150` | row count above which rows are windowed |
166
+ | `overscan` | `number` | `8` | rows mounted on each side of the view |
167
+ | `className` | `string` | — | |
168
+
169
+ Card set: user text, assistant markdown, collapsed reasoning, tool chips,
170
+ approvals, error. Pinned to the bottom and released as soon as the reader
171
+ scrolls up. Above `windowThreshold` rows only the rows in view plus `overscan`
172
+ are mounted (no dependency; every row renders where `ResizeObserver` is
173
+ missing). Tool chip rows carry `identity: { server, tool }` and, when the
174
+ provider passes them, `resourceLinks`.
175
+
176
+ ### Approval cards
177
+
178
+ An `approval_request` becomes an `approval` row and renders inline where the
179
+ request happened, not as a modal — the reader needs to see what the agent was
180
+ doing when it asked. `pending_input_resolved` settles the same card in place,
181
+ and a turn that ends unanswered marks it expired. The card never disappears and
182
+ never takes focus from the composer.
183
+
184
+ Two rules keep a live card from being drawn dead, which is a hang rather than a
185
+ cosmetic bug — the buttons go read-only while the runtime still waits:
186
+
187
+ - **A turn ending is `done`, or a `status` of `completed` / `failed` /
188
+ `interrupted`. Never `error`.** An `error` ends no turn on either layer: an
189
+ OpenCode per-tool failure emits one and keeps streaming, and the Codex
190
+ planning-approval guard emits one to decline a single request.
191
+ - **A restored row is live by construction.** `pendingApprovals()` is the
192
+ engine's authoritative "still blocked right now" list, read after the history
193
+ window, so no ending in that history expires it. Only an explicit resolution
194
+ settles it. Restored rows sort in at the instant they were read rather than
195
+ being appended.
196
+
197
+ | Decision | Button | Meaning |
198
+ |---|---|---|
199
+ | `accept` | Allow once | this call only |
200
+ | `accept_always` | Always allow | stop asking for this in this session |
201
+ | `reject` | Reject | refuse, and let the model hear why |
202
+
203
+ Questions, structured questions and plan approvals use an input card backed by
204
+ the optional `thread.respond(requestId, response)` method. `response` can carry
205
+ question `answers`, a `decision`, or `responseText`. Plan buttons send
206
+ `decision: "accept"` or `decision: "decline"`; question answers are keyed by
207
+ question id. Without `respond`, those
208
+ cards stay read-only with a reason. Model-selection requests stay read-only.
209
+ Approval cards without `thread.approve` are also read-only; neither card type
210
+ offers an action the client cannot perform.
211
+
212
+ ## Questions, queue and account surfaces
213
+
214
+ `<DaexChat>` renders question and plan cards in the transcript, a queue strip
215
+ when `thread.queue.list()` exists, and a usage-limit notice when the thread
216
+ reports resume controls. A client may omit any of these optional methods; the
217
+ corresponding controls are hidden or read-only. Failed queue and account reads
218
+ show an error and retry rather than presenting a false empty list.
219
+
220
+ Structured answers are keyed by question id. Single choices and freeform input
221
+ use a string; multi-select uses a string array. Secret questions use a password
222
+ field. Unstructured freeform responses use `responseText`.
223
+
224
+ The standalone `<AccountList>`, `<SignInCard>`, `<ApiKeyForm>`,
225
+ `<UsageMeter>` and `<AccountSwitcher>` components are also available. Account
226
+ rows contain no stored API keys. `<ApiKeyForm>` clears the entered key after a
227
+ successful save and does not include service error details that might echo it.
228
+
229
+ ### `<ModelPicker>`
230
+
231
+ | Prop | Type | Default | |
232
+ |---|---|---|---|
233
+ | `value` | `string \| null` | — | selected model id |
234
+ | `onChange` | `(model: ModelDescriptor) => void` | — | required |
235
+ | `models` / `providers` | arrays | — | supply data directly; omit to read from the client |
236
+ | `client` | `DaexChatClient` | context | used only when data is not supplied |
237
+ | `searchable` | `boolean` | `true` | |
238
+ | `renderProviderNotice` | `(status, providerId) => ReactNode` | — | drawn under an unusable provider group |
239
+ | `className` | `string` | — | |
240
+
241
+ Models group under their provider; rows are disabled when the provider is not
242
+ installed/authenticated or the model reports `available: false`.
243
+
244
+ ### `<ProviderCard>` / `<ProviderCards>`
245
+
246
+ Free-floating — the host decides placement.
247
+
248
+ | Prop | Type | |
249
+ |---|---|---|
250
+ | `status` | `ProviderStatus` | required on `ProviderCard` |
251
+ | `renderAction` | `(command, kind: "install" \| "login") => ReactNode` | replace the copy button |
252
+ | `onCopy` | `(command: string) => void \| Promise<void>` | override the clipboard write |
253
+ | `showDetail` | `boolean` (default `false`) | add a line with the version and a truncated binary path |
254
+ | `className` | `string` | |
255
+
256
+ `<ProviderCards>` adds `statuses`, `client`, and `onlyNeedsAttention` (default
257
+ `true`) and renders one card per provider needing action. `showDetail` is
258
+ forwarded to every card.
259
+
260
+ A missing provider reads "Not installed" only when `source` is `"probed"` —
261
+ a runtime looked and found nothing. When the status was derived from the model
262
+ catalog nobody looked, so the card says "Not detected" instead. Telling someone
263
+ to install a CLI they already have is the failure that distinction removes.
264
+
265
+ ## Activity labels
266
+
267
+ ```ts
268
+ labels={{
269
+ map: {
270
+ "server.tool": { running: "Searching…", done: "Searched", error: "Search failed" },
271
+ "server.*": "Talking to your account…", // string = running phase only
272
+ "*": "Working…",
273
+ },
274
+ resolve: (source) => source.tool === "x" ? "Custom" : null, // wins over map
275
+ icons: { "server.*": <ServerIcon /> },
276
+ thinkingLabel: "Thinking…",
277
+ elapsedAfterMs: 3000,
278
+ }}
279
+ ```
280
+
281
+ Resolution order: `resolve()` → exact key → longest wildcard prefix → `*` →
282
+ the raw tool name. A bare string labels the running phase only, so a finished
283
+ chip never keeps saying "Searching…". Labels apply to the live thinking
284
+ indicator, tool chips, and error text. An elapsed suffix appears after 3s of
285
+ running and is formatted `45s` / `1m 35s` / `1h 5m`. `prefers-reduced-motion`
286
+ is respected in both CSS and the indicator's animated ellipsis.
287
+
288
+ An MCP tool may be keyed in any spelling — `mcp:versic:search`,
289
+ `mcp__versic__search`, `versic:search`, or the bare `search` — and one key
290
+ matches the tool under every provider. A **server-qualified** key matches a
291
+ tool the provider reported by its bare name only when the event names that
292
+ server (`ToolChipRow.identity`). A bare name with no server on the event
293
+ matches only a bare key, and the matcher never guesses a server from the name.
294
+
295
+ A bare key is compared with the tool's **own name**, so the bare key to write is
296
+ the name your providers report. One wildcard covers a whole family when your
297
+ injected tools carry a prefix:
298
+
299
+ ```ts
300
+ labels={{
301
+ map: {
302
+ "mcp:versic:*": "Checking your projects…", // wins when the event names the server
303
+ "versic_*": "Checking your projects…", // the tool's own name, e.g. versic_projects
304
+ "*": "Working…",
305
+ },
306
+ }}
307
+ ```
308
+
309
+ `versic_*` matches `versic_projects`, whether it arrives bare or as
310
+ `mcp__versic__versic_projects`. It does **not** match a bare `search` that
311
+ belongs to the `versic` server — that name starts with `search` — so only `*` or
312
+ an exact `search` key reaches that one.
313
+
314
+ ## Theming
315
+
316
+ `createTheme({ accent, background, foreground, muted, danger, success, radius, fontFamily, monoFontFamily, fontSize, space, scheme })`
317
+ returns the full token set; hovers, borders and subtle tints are derived. Pass
318
+ it to `theme`, or set the tokens yourself on any ancestor.
319
+
320
+ ```
321
+ --adechat-bg --adechat-accent --adechat-radius
322
+ --adechat-bg-subtle --adechat-accent-fg --adechat-radius-sm
323
+ --adechat-bg-raised --adechat-accent-subtle --adechat-font
324
+ --adechat-fg --adechat-border --adechat-font-mono
325
+ --adechat-muted --adechat-border-strong --adechat-font-size
326
+ --adechat-danger --adechat-hover --adechat-space
327
+ --adechat-danger-subtle --adechat-success
328
+ ```
329
+
330
+ `--adechat-root-bg` is the chat root's background: `transparent` for
331
+ `createTheme({ background: "transparent" })`, else `var(--adechat-bg)`. Pass
332
+ `scheme` with a transparent background. `injectDaexChatStyles(target?, { nonce })`
333
+ and `<DaexChatStyles nonce>` set a CSP nonce on the injected `<style>`.
334
+
335
+ Light/dark is inferred from the background's luminance (override with
336
+ `scheme`). Non-hex colors (`var(--brand)`, `color-mix(...)`) pass straight
337
+ through; derived tints are only computed for hex inputs.
338
+
339
+ ## What `adaptSdkClient` produces
340
+
341
+ `src/sdkTypes.ts` is the *view* contract this package renders against — a copy,
342
+ not an import, so the package is standalone and any client shape can satisfy it.
343
+ `src/adapters/sdkClient.ts` bridges a real `@daex-dev/sdk` client onto it and does
344
+ import that package's types (type-only, and `@daex-dev/sdk` is an optional peer, so
345
+ nothing reaches the bundle).
346
+
347
+ The list below is the adapter's **output** contract: what every component here
348
+ may assume about the client it is handed. Write your own client — a WebSocket
349
+ proxy, an Electron IPC bridge, a fake — and these are the rules to meet.
350
+
351
+ One such client is checked here rather than described: `test/electronBridge.test.tsx`
352
+ assigns `createDaexIpcClient()` from `@daex-dev/sdk/electron/renderer` to
353
+ `SdkLikeChatClient` with no cast, then drives a full turn through
354
+ `registerDaexIpc` and `<DaexChat>`. A drift between that bridge and this contract
355
+ is a typecheck failure, not a runtime surprise.
356
+
357
+ 1. **`client.providers.status()`** resolves `ProviderStatus[]` with `installed`
358
+ and `authenticated` as separate booleans. Both true means selectable.
359
+ `loginCommand` / `installCommand` are copy-pasteable shell strings.
360
+ `source` says whether `installed` was probed or derived, and the card's
361
+ wording depends on it.
362
+ 2. **`client.providers.onChange(cb)`** fires with the *full* status list (not a
363
+ delta) and returns an unsubscribe function. A status change may also change
364
+ the model catalog, so the hook re-reads `models.list()` after each one.
365
+ `refresh()` is optional and is never called by a poll.
366
+ 3. **`client.models.list()`** resolves the full catalog. `providerId` must match
367
+ a `ProviderStatus.id`; models whose provider has no status entry still render
368
+ (grouped under the raw id) but are never selectable.
369
+ 4. **`client.threads.open(key, opts)`** is idempotent per key within a session —
370
+ re-opening the same key returns a handle onto the same conversation.
371
+ 5. **`thread.history()`** returns envelopes in transcript order. Ordering is
372
+ envelope-based (`sequence`, then `timestamp`); provider clocks are not
373
+ trusted. Events emitted while `history()` is in flight must also reach the
374
+ `"event"` subscriber — the hook de-duplicates the overlap on
375
+ `sessionId:sequence:timestamp:type` and then re-sorts, so a live envelope
376
+ that beat the page still renders in its own place. The canonical definition
377
+ of that key is `envelopeDedupeKey` in `@daex-dev/sdk`
378
+ (`src/electron/protocol.ts`); this package mirrors it because the SDK is an
379
+ optional peer.
380
+ 6. **Streaming text** may be sent either as growing snapshots or as deltas; both
381
+ collapse correctly. Chunks of one message must share a `messageId`, or
382
+ failing that a `turnId` + `itemId`.
383
+ 7. **`tool_result` must reuse its `tool_call`'s `itemId`**, or carry a matching
384
+ `logicalItemId` when the provider renumbers items. Otherwise the result
385
+ renders as a second, orphaned chip.
386
+ 8. **`thread.on("status")`** reports `running` for the whole duration of a turn
387
+ and returns to `idle` when it ends. The composer's send-vs-steer decision is
388
+ driven entirely by this.
389
+ 9. **`steer()` does not start a turn.** It delivers into the running one and
390
+ must be safe to call while `status.state === "running"`.
391
+ 10. **Unknown event types are ignored, not rendered.** The SDK may add event
392
+ kinds without breaking this package, but anything it wants drawn here needs
393
+ a matching row kind.
394
+ 11. **`approval_request` blocks the turn until it is answered.** An
395
+ `approval_request` and its `pending_input_resolved` must share an `itemId`
396
+ (or a matching `logicalItemId`), and a turn that ends without an answer
397
+ must emit `done`, `error`, or a terminal `status` so the card can settle.
398
+ 12. **`thread.approve` and `thread.pendingApprovals` are optional.** A client
399
+ that omits `approve` gets a read-only card with a line saying why, never a
400
+ throw. `pendingApprovals()` is read once on open, so a reload restores the
401
+ cards a lost live stream would otherwise have taken with it.
402
+
403
+ ## What `@daex-dev/sdk` actually returns
404
+
405
+ The adapter exists because the two shapes do not meet. The differences that
406
+ catch people writing their own proxy:
407
+
408
+ - `providers.status()` returns a **`Record<string, ProviderStatus>` keyed by
409
+ provider id**, not an array.
410
+ - A status record calls the id `provider`, not `id`, and carries
411
+ `available` / `requiresConfiguration` / `modelCount` / `stale` — fields this
412
+ package folds into `installed` and a `detail` sentence.
413
+ - A catalog entry calls its provider `provider` and its usability
414
+ `isAvailable`, where the view contract uses `providerId` and `available`.
415
+ - `threads.open(key, opts)` takes the SDK's own option names (`provider`,
416
+ `model`), which `adaptSdkClient` maps from `providerId` / `modelId`.
417
+ - `send(text, { attachments })` is positional, and an attachment is a
418
+ `{ path }` file ref rather than the view's `ChatAttachment`.
419
+ - `on("status")` and `on("usage")` deliver raw envelopes; the adapter maps them
420
+ to `{ state, turnId }` and `{ inputTokens, … }` and drops anything that maps
421
+ to nothing.
422
+
423
+ ## Development
424
+
425
+ Requires Node 24, the version in the repository's `.nvmrc` (`/opt/homebrew/opt/node@24/bin` on macOS).
426
+
427
+ ```bash
428
+ npm install # in packages/chat-ui
429
+ npm test # vitest, 225 tests
430
+ npm run typecheck # tsc --noEmit
431
+ npm run build # tsup → dist/ (ESM + CJS + d.ts)
432
+ ```
433
+
434
+ From the repo root: `npm run test:chat-ui`, `npm run build:chat-ui`.
435
+
436
+ ## License
437
+
438
+ MIT. See [LICENSE](./LICENSE). DAEX (formerly ADE) itself remains AGPL-3.0-only; see the [DAEX Runtime Embedding Exception](https://github.com/arul28/DAEX/blob/main/RUNTIME-EMBEDDING-EXCEPTION.md) for shipping the runtime binary in your app.