@dudko.dev/agent-web-react 0.0.17 → 0.0.19
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 +33 -4
- package/dist/index.cjs +84 -767
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -264
- package/dist/index.d.ts +3 -264
- package/dist/index.js +72 -738
- 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/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,
|
|
@@ -318,6 +319,30 @@ function CloudAgent() {
|
|
|
318
319
|
The [`demo/`](demo/) app does exactly this — see
|
|
319
320
|
[`demo/src/providers.ts`](demo/src/providers.ts).
|
|
320
321
|
|
|
322
|
+
## MCP hooks live in their own subpath
|
|
323
|
+
|
|
324
|
+
```tsx
|
|
325
|
+
import { useMcp, useMcpServers } from '@dudko.dev/agent-web-react/mcp'
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
The MCP hooks are **not** exported from `@dudko.dev/agent-web-react`. They load the
|
|
329
|
+
core's `@dudko.dev/agent-web/mcp`, which imports `@modelcontextprotocol/sdk` — an
|
|
330
|
+
*optional* peer, so npm does not install it for you. A bundler cannot honour
|
|
331
|
+
"optional": it resolves even a dynamic `import()` at build time, so a host that
|
|
332
|
+
merely imported `useAgent` from the main entry used to fail webpack/CRA with
|
|
333
|
+
`Module not found: @modelcontextprotocol/sdk/…` while never touching MCP. Behind a
|
|
334
|
+
subpath the decision is yours:
|
|
335
|
+
|
|
336
|
+
- **Don't use MCP** → import only from the main entry. Nothing in your build
|
|
337
|
+
mentions the SDK; install nothing extra.
|
|
338
|
+
- **Use MCP** → import from `…/mcp` and `npm install @modelcontextprotocol/sdk`
|
|
339
|
+
next to the core (it is bundled into an async chunk, loaded when you connect).
|
|
340
|
+
|
|
341
|
+
> **Migrating from ≤ 0.0.18.** `useMcp`, `useMcpServers` and their helpers
|
|
342
|
+
> (`readCallbackParams`, `claimOAuthCallback`, `stripOAuthParams`,
|
|
343
|
+
> `describeMcpResult`, `isUnauthorizedError`) and types (`McpStatus`,
|
|
344
|
+
> `McpAuthMode`, `McpServerView`, …) moved: change the import path, nothing else.
|
|
345
|
+
|
|
321
346
|
## The `useMcp` hook — connect a remote MCP server
|
|
322
347
|
|
|
323
348
|
Let the user name their own MCP server at runtime and hand its tools to the
|
|
@@ -326,6 +351,8 @@ client registration** — no client ID to configure, and the access token is
|
|
|
326
351
|
refreshed for you when it expires mid-run.
|
|
327
352
|
|
|
328
353
|
```tsx
|
|
354
|
+
import { useMcp } from '@dudko.dev/agent-web-react/mcp'
|
|
355
|
+
|
|
329
356
|
const mcp = useMcp({ clientName: 'my-app' })
|
|
330
357
|
|
|
331
358
|
await mcp.connect({ url, oauth: true }) // or { url, headers: { Authorization } }
|
|
@@ -350,9 +377,9 @@ covers that window.
|
|
|
350
377
|
Two notes:
|
|
351
378
|
|
|
352
379
|
- 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
|
-
|
|
380
|
+
and is loaded with a **dynamic import**, so the SDK stays out of your initial
|
|
381
|
+
bundle until `connect` runs. Install `@modelcontextprotocol/sdk` alongside the
|
|
382
|
+
core — importing these hooks is what puts it in your build.
|
|
356
383
|
- `oauthSupported` is `false` on cores older than `@dudko.dev/agent-web@0.0.9`,
|
|
357
384
|
which introduced `BrowserOAuthProvider`; header auth still works there. The
|
|
358
385
|
peer floor is `>=0.0.20` — the first core with the virtual file system,
|
|
@@ -362,6 +389,8 @@ Two notes:
|
|
|
362
389
|
## Several MCP servers — `useMcpServers`
|
|
363
390
|
|
|
364
391
|
```tsx
|
|
392
|
+
import { useMcpServers } from '@dudko.dev/agent-web-react/mcp'
|
|
393
|
+
|
|
365
394
|
const mcp = useMcpServers({ clientName: 'my-app' }) // the list persists; reconnects on load
|
|
366
395
|
await mcp.add({ name: 'docs', url, auth: 'oauth' }) // 'none' | 'bearer' (+ token) | 'oauth'
|
|
367
396
|
mcp.servers // [{ name, url, status, catalog, error, … }]
|