@multiplayer-app/ai-agent-react 0.1.0-beta.83 → 0.1.0-beta.85
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 +60 -1
- package/dist/ai-agent-react.cjs.js +22 -22
- package/dist/ai-agent-react.cjs.js.map +1 -1
- package/dist/ai-agent-react.es.js +1907 -1894
- package/dist/ai-agent-react.es.js.map +1 -1
- package/dist/components/ChatWindow/Composer/ComposerInputRow/ComposerInputRow.d.ts.map +1 -1
- package/dist/config/types.d.ts +30 -2
- package/dist/config/types.d.ts.map +1 -1
- package/dist/runtime/AgentRuntime.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -83,7 +83,8 @@ If you set `containsPII: true` with `redactionsApplied: []`, you are explicitly
|
|
|
83
83
|
### What the React library does
|
|
84
84
|
|
|
85
85
|
- **UI**: renders attachment chips under messages.
|
|
86
|
-
- **Composer**: includes
|
|
86
|
+
- **Composer**: includes built-in attach controls (files, selection, page context) behind `config.features` toggles.
|
|
87
|
+
- **Composer (custom actions)**: optional `config.composerAttachmentActions` slot for host-defined toolbar buttons that add custom attachments.
|
|
87
88
|
- **Composer (page context)**: auto-attaches a `pageContext` chip (URL + metadata) by default. Users can remove it; if removed, the composer shows an “Attach page context” button.
|
|
88
89
|
- **Runtime**: forwards `attachments` in `SendMessagePayload` to your transport (proxy or direct).
|
|
89
90
|
|
|
@@ -262,6 +263,62 @@ const att = createContextAttachment({
|
|
|
262
263
|
|
|
263
264
|
This produces a valid `AgentAttachment` with defaults filled in.
|
|
264
265
|
|
|
266
|
+
#### Custom composer attachment actions (`config.composerAttachmentActions`)
|
|
267
|
+
|
|
268
|
+
To add toolbar buttons in the composer (next to file/selection attach), pass a React component. It receives the current draft attachments and helpers to add or remove attachments:
|
|
269
|
+
|
|
270
|
+
```tsx
|
|
271
|
+
import {
|
|
272
|
+
AgentProvider,
|
|
273
|
+
AgentChatWindow,
|
|
274
|
+
createContextAttachment,
|
|
275
|
+
type ComposerAttachmentActionsProps,
|
|
276
|
+
type AgentFrontendConfig
|
|
277
|
+
} from '@multiplayer-app/ai-agent-react'
|
|
278
|
+
import { Bookmark } from 'lucide-react'
|
|
279
|
+
|
|
280
|
+
function RecordAttachmentActions({ addAttachments }: ComposerAttachmentActionsProps) {
|
|
281
|
+
return (
|
|
282
|
+
<button
|
|
283
|
+
type="button"
|
|
284
|
+
className="mp-agent-composer-button mp-agent-composer-tool-button"
|
|
285
|
+
aria-label="Attach current record"
|
|
286
|
+
onClick={() => {
|
|
287
|
+
addAttachments([
|
|
288
|
+
createContextAttachment({
|
|
289
|
+
kind: 'record',
|
|
290
|
+
title: 'Current record',
|
|
291
|
+
selectedText: JSON.stringify({ id: 'rec_123' })
|
|
292
|
+
})
|
|
293
|
+
])
|
|
294
|
+
}}
|
|
295
|
+
>
|
|
296
|
+
<Bookmark size={16} />
|
|
297
|
+
</button>
|
|
298
|
+
)
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
const config: AgentFrontendConfig = {
|
|
302
|
+
appId: 'your-app',
|
|
303
|
+
contextKeys: [{ key: 'default', label: 'Default', tools: [] }],
|
|
304
|
+
transport: { mode: 'proxy', baseUrl: '/api' },
|
|
305
|
+
features: {
|
|
306
|
+
fileAttachments: true,
|
|
307
|
+
selectionAttachments: true,
|
|
308
|
+
pageContextAttachments: true
|
|
309
|
+
},
|
|
310
|
+
composerAttachmentActions: RecordAttachmentActions
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export const YourAppAgent = () => (
|
|
314
|
+
<AgentProvider config={config}>
|
|
315
|
+
<AgentChatWindow />
|
|
316
|
+
</AgentProvider>
|
|
317
|
+
)
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
Use `mp-agent-composer-button` and `mp-agent-composer-tool-button` on buttons so they match the built-in composer controls. For attach UI outside the composer toolbar, use `useComposerDraft()` or `AttachContextButton` instead.
|
|
321
|
+
|
|
265
322
|
#### Example: create a custom context attachment
|
|
266
323
|
|
|
267
324
|
```ts
|
|
@@ -426,6 +483,8 @@ User selects tool chip / runtime.tools.invoke(...)
|
|
|
426
483
|
| `features` | Fine-grained toggles: reasoning panel location, artifact visibility, multi-agent controls, sandbox switches, etc. |
|
|
427
484
|
| `theme` | Partial overrides for the default theme tokens (background, accent, font, radius, etc.). |
|
|
428
485
|
| `toolRenderers` | Map tool names to React components when tool output needs rich visuals (tables, charts, custom viewers). |
|
|
486
|
+
| `composerAttachmentActions` | React component in the composer toolbar for host-defined attachment buttons (`addAttachments`, `removeAttachment`, current `attachments`). |
|
|
487
|
+
| `pageContext` | Options and `getData` hook for the built-in page-context attachment chip. |
|
|
429
488
|
| `user` | Optional `{ id, displayName, email, avatarUrl }` shape. If provided, user metadata is attached to tool calls/history. |
|
|
430
489
|
|
|
431
490
|
All configs are validated through `zod` at runtime, so invalid configurations fail fast.
|