foldkit-agent-webmcp 0.3.0 → 0.4.1

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.
Files changed (2) hide show
  1. package/README.md +16 -10
  2. package/package.json +10 -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
- [WebMCP](https://github.com/webmachinelearning/webmcp) is an experimental web
35
- platform proposal. No stable browser ships it today, so feature detection is
36
- part of the normal integration path.
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
- Assume the application already declared a protocol-neutral contract:
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, // required only by capabilities with completion contracts
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
- window.addEventListener('beforeunload', () => registration.unregister())
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.0",
3
+ "version": "0.4.1",
4
4
  "description": "WebMCP adapter for foldkit-agent. Projects exposed Foldkit Messages into document.modelContext tools.",
5
5
  "keywords": [
6
6
  "foldkit",
@@ -27,6 +27,7 @@
27
27
  },
28
28
  "exports": {
29
29
  ".": {
30
+ "foldkit-plus:source": "./src/index.ts",
30
31
  "types": "./dist/index.d.mts",
31
32
  "import": "./dist/index.mjs"
32
33
  }
@@ -37,17 +38,18 @@
37
38
  "LICENSE"
38
39
  ],
39
40
  "peerDependencies": {
40
- "effect": "^4.0.0-rc.112",
41
- "foldkit": "^0.158.2",
42
- "foldkit-agent": "^0.3.0"
41
+ "effect": ">=4.0.0-rc.116 <4.0.0-rc.118",
42
+ "foldkit": "^0.163.0",
43
+ "foldkit-agent": "^0.5.0"
43
44
  },
44
45
  "dependencies": {},
45
46
  "devDependencies": {
46
- "effect": "4.0.0-rc.112",
47
- "foldkit": "0.158.2",
47
+ "@effect/platform-browser": "4.0.0-rc.116",
48
+ "effect": "4.0.0-rc.116",
49
+ "foldkit": "0.163.0",
48
50
  "tsdown": "^0.23.0",
49
- "typescript": "^5.7.2",
50
- "foldkit-agent": "0.3.0"
51
+ "typescript": "5.9.3",
52
+ "foldkit-agent": "0.5.0"
51
53
  },
52
54
  "scripts": {
53
55
  "build": "tsdown",