foldkit-agent-webmcp 0.3.0 → 0.4.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/README.md +16 -10
- package/package.json +9 -8
package/README.md
CHANGED
|
@@ -31,9 +31,9 @@ The authority boundary stays in `foldkit-agent`: the contract decides what the
|
|
|
31
31
|
agent may observe and which Messages it may cause. WebMCP only makes those
|
|
32
32
|
capabilities available to a browser-resident agent.
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
The adapter uses the WebMCP producer API when the host exposes it. Feature
|
|
35
|
+
detect `document.modelContext` at runtime; tool registration is optional
|
|
36
|
+
for browsers that do not provide it.
|
|
37
37
|
|
|
38
38
|
## Install
|
|
39
39
|
|
|
@@ -45,12 +45,12 @@ pnpm add foldkit-agent foldkit-agent-webmcp
|
|
|
45
45
|
|
|
46
46
|
## Sixty seconds: publish a bound runtime
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
Start with the [Agent contract and host guide](../agent/README.md#usage).
|
|
49
|
+
The integration below assumes `AssistantAgent` is your declared contract and
|
|
50
|
+
`AgentBuilder` is its application-specialized builder. `mounted` below
|
|
51
|
+
is an application host (for example, the value returned by `Sync.mount`),
|
|
52
|
+
not an arbitrary Foldkit runtime handle.
|
|
49
53
|
|
|
50
|
-
```ts
|
|
51
|
-
const AgentBuilder = Agent.forApplication(App).withPrincipal<Principal>()
|
|
52
|
-
const AssistantAgent = AgentBuilder.make({ ... })
|
|
53
|
-
```
|
|
54
54
|
|
|
55
55
|
Bind that contract to the running application, then register its currently
|
|
56
56
|
available capabilities with WebMCP:
|
|
@@ -64,7 +64,8 @@ const agentRuntime = AgentBuilder.bind({
|
|
|
64
64
|
model: mounted.model,
|
|
65
65
|
dispatch: message => mounted.dispatch(message),
|
|
66
66
|
subscribe: mounted.subscribe,
|
|
67
|
-
observe: mounted.observe, //
|
|
67
|
+
observe: mounted.observe, // Message-based completion
|
|
68
|
+
principal: () => currentPrincipal, // your authenticated application principal
|
|
68
69
|
},
|
|
69
70
|
})
|
|
70
71
|
|
|
@@ -76,10 +77,15 @@ if (modelContext !== undefined) {
|
|
|
76
77
|
modelContext,
|
|
77
78
|
})
|
|
78
79
|
|
|
79
|
-
|
|
80
|
+
await registration.refresh()
|
|
81
|
+
window.addEventListener('pagehide', () => registration.unregister())
|
|
80
82
|
}
|
|
81
83
|
```
|
|
82
84
|
|
|
85
|
+
Also call `registration.unregister()` when the owning component or runtime
|
|
86
|
+
is disposed; a page unload listener alone does not handle in-page teardown.
|
|
87
|
+
`currentPrincipal` above comes from your application, not tool arguments.
|
|
88
|
+
|
|
83
89
|
That is the whole architecture: the contract remains protocol-neutral, the
|
|
84
90
|
runtime remains the one authority for availability/authorization/dispatch, and
|
|
85
91
|
this package translates it to the browser API.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foldkit-agent-webmcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "WebMCP adapter for foldkit-agent. Projects exposed Foldkit Messages into document.modelContext tools.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"foldkit",
|
|
@@ -37,17 +37,18 @@
|
|
|
37
37
|
"LICENSE"
|
|
38
38
|
],
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"effect": "^4.0.0-rc.
|
|
41
|
-
"foldkit": "^0.
|
|
42
|
-
"foldkit-agent": "^0.
|
|
40
|
+
"effect": "^4.0.0-rc.116",
|
|
41
|
+
"foldkit": "^0.163.0",
|
|
42
|
+
"foldkit-agent": "^0.4.0"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"effect": "4.0.0-rc.
|
|
47
|
-
"
|
|
46
|
+
"@effect/platform-browser": "4.0.0-rc.116",
|
|
47
|
+
"effect": "4.0.0-rc.116",
|
|
48
|
+
"foldkit": "0.163.0",
|
|
48
49
|
"tsdown": "^0.23.0",
|
|
49
|
-
"typescript": "
|
|
50
|
-
"foldkit-agent": "0.
|
|
50
|
+
"typescript": "5.9.3",
|
|
51
|
+
"foldkit-agent": "0.4.0"
|
|
51
52
|
},
|
|
52
53
|
"scripts": {
|
|
53
54
|
"build": "tsdown",
|