@dudko.dev/agent-web-react 0.0.18 → 0.0.20
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 +34 -4
- package/dist/index.cjs +290 -792
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +144 -271
- package/dist/index.d.ts +144 -271
- package/dist/index.js +278 -764
- package/dist/index.js.map +1 -1
- package/dist/mcp.cjs +711 -0
- package/dist/mcp.cjs.map +1 -0
- package/dist/mcp.d.cts +265 -0
- package/dist/mcp.d.ts +265 -0
- package/dist/mcp.js +668 -0
- package/dist/mcp.js.map +1 -0
- package/dist/styles.css +99 -0
- package/package.json +13 -3
package/README.md
CHANGED
|
@@ -18,7 +18,8 @@ app with a single hook and (optionally) a set of pre-styled components:
|
|
|
18
18
|
- 🧩 **Building blocks** — `<AgentComposer>`, `<MessageList>`, `<StepList>`,
|
|
19
19
|
`<ToolApprovalPrompt>`, `<ChatHistoryList>`, `<FilesPanel>`, `<ContextMeter>`,
|
|
20
20
|
`<ModelLoadBar>`, `<UsageBadge>`, `<ApiKeyForm>`; hooks `useChatHistory`,
|
|
21
|
-
`useVirtualFiles`, `useSpeechToText
|
|
21
|
+
`useVirtualFiles`, `useSpeechToText`; MCP hooks `useMcp` / `useMcpServers` live in
|
|
22
|
+
[`@dudko.dev/agent-web-react/mcp`](#mcp-hooks-live-in-their-own-subpath).
|
|
22
23
|
- 🔑 **`useCredentials`** — store BYOK API keys **encrypted at rest**
|
|
23
24
|
(WebCrypto + IndexedDB).
|
|
24
25
|
- 🖥️ **`useWebLLMModel`** / **`useLocalModel`** — load an on-device model (WebLLM,
|
|
@@ -169,6 +170,7 @@ function Custom() {
|
|
|
169
170
|
| --- | --- |
|
|
170
171
|
| `run(goal, { images, files, attachments, label })` | Start a run (with attachments); resolves with the `RunResult` |
|
|
171
172
|
| `stop()` | Abort the in-flight run |
|
|
173
|
+
| `send(text)`, `stopSubagent(id)` | Say something to the running agent (shown to the model at its next boundary; the replanner re-checks the plan) / stop one subagent. `queued`, `notes` and `undelivered` show where a message is — see [docs/chat.md](docs/chat.md#talking-to-the-agent-while-it-works) |
|
|
172
174
|
| `reset()` | Clear the whole conversation (and the agent's memory of it) |
|
|
173
175
|
| `reload()` | Rebuild the agent (e.g. after storing a new key) |
|
|
174
176
|
| `status` | `idle` \| `initializing` \| `ready` \| `running` \| `error` |
|
|
@@ -318,6 +320,30 @@ function CloudAgent() {
|
|
|
318
320
|
The [`demo/`](demo/) app does exactly this — see
|
|
319
321
|
[`demo/src/providers.ts`](demo/src/providers.ts).
|
|
320
322
|
|
|
323
|
+
## MCP hooks live in their own subpath
|
|
324
|
+
|
|
325
|
+
```tsx
|
|
326
|
+
import { useMcp, useMcpServers } from '@dudko.dev/agent-web-react/mcp'
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
The MCP hooks are **not** exported from `@dudko.dev/agent-web-react`. They load the
|
|
330
|
+
core's `@dudko.dev/agent-web/mcp`, which imports `@modelcontextprotocol/sdk` — an
|
|
331
|
+
*optional* peer, so npm does not install it for you. A bundler cannot honour
|
|
332
|
+
"optional": it resolves even a dynamic `import()` at build time, so a host that
|
|
333
|
+
merely imported `useAgent` from the main entry used to fail webpack/CRA with
|
|
334
|
+
`Module not found: @modelcontextprotocol/sdk/…` while never touching MCP. Behind a
|
|
335
|
+
subpath the decision is yours:
|
|
336
|
+
|
|
337
|
+
- **Don't use MCP** → import only from the main entry. Nothing in your build
|
|
338
|
+
mentions the SDK; install nothing extra.
|
|
339
|
+
- **Use MCP** → import from `…/mcp` and `npm install @modelcontextprotocol/sdk`
|
|
340
|
+
next to the core (it is bundled into an async chunk, loaded when you connect).
|
|
341
|
+
|
|
342
|
+
> **Migrating from ≤ 0.0.18.** `useMcp`, `useMcpServers` and their helpers
|
|
343
|
+
> (`readCallbackParams`, `claimOAuthCallback`, `stripOAuthParams`,
|
|
344
|
+
> `describeMcpResult`, `isUnauthorizedError`) and types (`McpStatus`,
|
|
345
|
+
> `McpAuthMode`, `McpServerView`, …) moved: change the import path, nothing else.
|
|
346
|
+
|
|
321
347
|
## The `useMcp` hook — connect a remote MCP server
|
|
322
348
|
|
|
323
349
|
Let the user name their own MCP server at runtime and hand its tools to the
|
|
@@ -326,6 +352,8 @@ client registration** — no client ID to configure, and the access token is
|
|
|
326
352
|
refreshed for you when it expires mid-run.
|
|
327
353
|
|
|
328
354
|
```tsx
|
|
355
|
+
import { useMcp } from '@dudko.dev/agent-web-react/mcp'
|
|
356
|
+
|
|
329
357
|
const mcp = useMcp({ clientName: 'my-app' })
|
|
330
358
|
|
|
331
359
|
await mcp.connect({ url, oauth: true }) // or { url, headers: { Authorization } }
|
|
@@ -350,9 +378,9 @@ covers that window.
|
|
|
350
378
|
Two notes:
|
|
351
379
|
|
|
352
380
|
- The connector lives in the core's optional `@dudko.dev/agent-web/mcp` subpath
|
|
353
|
-
and is loaded with a **dynamic import**, so
|
|
354
|
-
|
|
355
|
-
|
|
381
|
+
and is loaded with a **dynamic import**, so the SDK stays out of your initial
|
|
382
|
+
bundle until `connect` runs. Install `@modelcontextprotocol/sdk` alongside the
|
|
383
|
+
core — importing these hooks is what puts it in your build.
|
|
356
384
|
- `oauthSupported` is `false` on cores older than `@dudko.dev/agent-web@0.0.9`,
|
|
357
385
|
which introduced `BrowserOAuthProvider`; header auth still works there. The
|
|
358
386
|
peer floor is `>=0.0.20` — the first core with the virtual file system,
|
|
@@ -362,6 +390,8 @@ Two notes:
|
|
|
362
390
|
## Several MCP servers — `useMcpServers`
|
|
363
391
|
|
|
364
392
|
```tsx
|
|
393
|
+
import { useMcpServers } from '@dudko.dev/agent-web-react/mcp'
|
|
394
|
+
|
|
365
395
|
const mcp = useMcpServers({ clientName: 'my-app' }) // the list persists; reconnects on load
|
|
366
396
|
await mcp.add({ name: 'docs', url, auth: 'oauth' }) // 'none' | 'bearer' (+ token) | 'oauth'
|
|
367
397
|
mcp.servers // [{ name, url, status, catalog, error, … }]
|