@dudko.dev/agent-web 0.0.27 → 0.0.29
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 +39 -1
- package/dist/agent-web.js +111 -98
- package/dist/agent-web.js.map +1 -1
- package/dist/{chunk-V7COB2EA.js → chunk-CPSDKXO6.js} +5 -2
- package/dist/chunk-CPSDKXO6.js.map +1 -0
- package/dist/index.cjs +496 -63
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +349 -24
- package/dist/index.d.ts +349 -24
- package/dist/index.js +490 -63
- package/dist/index.js.map +1 -1
- package/dist/mcp.cjs +3 -1
- package/dist/mcp.cjs.map +1 -1
- package/dist/mcp.js +1 -1
- package/dist/types-DwSMj_Xs.d.cts +21 -0
- package/dist/types-DwSMj_Xs.d.ts +21 -0
- package/dist/webmcp.cjs +208 -0
- package/dist/webmcp.cjs.map +1 -0
- package/dist/webmcp.d.cts +131 -0
- package/dist/webmcp.d.ts +131 -0
- package/dist/webmcp.js +179 -0
- package/dist/webmcp.js.map +1 -0
- package/package.json +19 -9
- package/dist/chunk-V7COB2EA.js.map +0 -1
package/README.md
CHANGED
|
@@ -293,6 +293,37 @@ browser's silence: it re-probes the endpoint with a plain request and, if that
|
|
|
293
293
|
gets through, says which header is being refused. `diagnoseMcpCors(url)` is
|
|
294
294
|
exported so a UI can show the same sentence.
|
|
295
295
|
|
|
296
|
+
## Optional: WebMCP — a page's tools, both ways
|
|
297
|
+
|
|
298
|
+
[WebMCP](https://webmachinelearning.github.io/webmcp/) lets a page register named, typed tools
|
|
299
|
+
(`document.modelContext.registerTool(tool, { signal })`) that a browser's agent — Chrome's origin
|
|
300
|
+
trial, Edge, an extension, an in-page agent — can discover and call. The `./webmcp` subpath bridges it
|
|
301
|
+
and an agent's `ToolSet`, with no extra dependency and as a no-op where the browser has no WebMCP:
|
|
302
|
+
|
|
303
|
+
```ts
|
|
304
|
+
import { connectWebMcp, registerWebMcpTools } from '@dudko.dev/agent-web/webmcp'
|
|
305
|
+
|
|
306
|
+
// 1. Publish the tools your in-page agent uses, so any agent of the browser can drive them too.
|
|
307
|
+
// One definition, two consumers; withdrawn when the signal aborts or unregister() is called.
|
|
308
|
+
const reg = await registerWebMcpTools(tools, {
|
|
309
|
+
prefix: 'myapp_', // WebMCP tool names are shared with everything else on the page
|
|
310
|
+
except: ['debug_dump'],
|
|
311
|
+
consequential: ['clear_page'], // annotated consequentialHint: true
|
|
312
|
+
signal: controller.signal,
|
|
313
|
+
})
|
|
314
|
+
// readOnly: true tools (defineTool) are annotated readOnlyHint: true
|
|
315
|
+
|
|
316
|
+
// 2. Use the tools a page has registered as the agent's own.
|
|
317
|
+
const web = await connectWebMcp({ onToolsChanged: () => rebuildAgent() })
|
|
318
|
+
const agent = await createAgent({ model, tools: { ...tools, ...web?.tools } })
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
Both generations of the browser API are handled: the current one on `document.modelContext` (a
|
|
322
|
+
tool is withdrawn by aborting its signal) and Chrome's early preview on `navigator.modelContext`
|
|
323
|
+
(`unregisterTool(name)`). Results are returned as text content (structured results as JSON), as
|
|
324
|
+
WebMCP clients read them. Validate strictly inside your `execute`, loosely in the schema: a
|
|
325
|
+
rejected call should be a result the calling agent can read, not a stalled tool.
|
|
326
|
+
|
|
296
327
|
## Thinking, limits, consent, skills, subagents
|
|
297
328
|
|
|
298
329
|
```ts
|
|
@@ -319,7 +350,14 @@ With more than 40 tools (several MCP servers) the executor switches to **tool
|
|
|
319
350
|
search**: it starts each step small and calls `find_tools` to activate what it
|
|
320
351
|
needs. Subagents are tools too — `createSubagentTool({ config })` runs a child
|
|
321
352
|
agent in-process, `createSubagentTool({ worker, workerConfig })` isolates it in a
|
|
322
|
-
Web Worker served by `serveSubagentWorker()`.
|
|
353
|
+
Web Worker served by `serveSubagentWorker()`. Add `profiles` and the parent model
|
|
354
|
+
chooses, per call, between named variants of the same subagent — another model,
|
|
355
|
+
thinking level, limits or system prompt. Give `persistence` a store
|
|
356
|
+
(`new IndexedDBRunStore()`) and a run interrupted by a reload or a crash resumes from its
|
|
357
|
+
last checkpoint with `run('', { resumeFromRunId })` — the planner does not run again and
|
|
358
|
+
no finished step is repeated. `createRunControl()` steers a run that is going: `send()`
|
|
359
|
+
puts a message in front of the model at the next boundary (the replanner re-checks the plan
|
|
360
|
+
against it), `stopSubagent(id)` stops one subagent. Details, defaults and events:
|
|
323
361
|
**[docs/capabilities.md](docs/capabilities.md)**.
|
|
324
362
|
|
|
325
363
|
## Configuration (highlights)
|