foldkit-agent-webmcp 0.9.0 → 0.11.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 +46 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -55,6 +55,33 @@ not an arbitrary Foldkit runtime handle.
|
|
|
55
55
|
Bind that contract to the running application, then register its currently
|
|
56
56
|
available capabilities with WebMCP:
|
|
57
57
|
|
|
58
|
+
<!-- docs-check standalone
|
|
59
|
+
import { Agent } from 'foldkit-agent'
|
|
60
|
+
import { Option, Schema } from 'effect'
|
|
61
|
+
import { defineMessageUnion } from 'foldkit/message'
|
|
62
|
+
const Message = defineMessageUnion({
|
|
63
|
+
RequestedCreateTodo: { title: Schema.String },
|
|
64
|
+
DraftSubmitted: {},
|
|
65
|
+
})
|
|
66
|
+
type Message = typeof Message.Type
|
|
67
|
+
interface Model {
|
|
68
|
+
readonly selectedTodoId: Option.Option<string>
|
|
69
|
+
}
|
|
70
|
+
interface Principal {
|
|
71
|
+
readonly user: string
|
|
72
|
+
}
|
|
73
|
+
const AgentBuilder = Agent.forModel<Model, Principal>()
|
|
74
|
+
const AssistantAgent = AgentBuilder.make({
|
|
75
|
+
messages: AgentBuilder.expose(Message, { RequestedCreateTodo: 'Create a todo' }),
|
|
76
|
+
})
|
|
77
|
+
declare const mounted: {
|
|
78
|
+
readonly model: () => Model
|
|
79
|
+
readonly dispatch: (message: Message) => void
|
|
80
|
+
readonly subscribe: (listener: () => void) => () => void
|
|
81
|
+
readonly observe: (listener: (message: Message) => void) => () => void
|
|
82
|
+
}
|
|
83
|
+
declare const currentPrincipal: Principal
|
|
84
|
+
-->
|
|
58
85
|
```ts
|
|
59
86
|
import { AgentWebMcp } from 'foldkit-agent-webmcp'
|
|
60
87
|
|
|
@@ -62,7 +89,9 @@ const agentRuntime = AgentBuilder.bind({
|
|
|
62
89
|
definition: AssistantAgent,
|
|
63
90
|
host: {
|
|
64
91
|
model: mounted.model,
|
|
65
|
-
dispatch: message =>
|
|
92
|
+
dispatch: (message: Message) => {
|
|
93
|
+
mounted.dispatch(message)
|
|
94
|
+
},
|
|
66
95
|
subscribe: mounted.subscribe,
|
|
67
96
|
observe: mounted.observe, // Message-based completion
|
|
68
97
|
principal: () => currentPrincipal, // your authenticated application principal
|
|
@@ -165,6 +194,13 @@ browser fills the fields and submits; the person can see the form as it is
|
|
|
165
194
|
filled. `formTool` draws a capability that way, from the same contract, so the
|
|
166
195
|
form and the registered tool cannot name or describe it differently:
|
|
167
196
|
|
|
197
|
+
<!-- docs-check
|
|
198
|
+
import type { HtmlBuilder } from 'foldkit/html'
|
|
199
|
+
declare const AppAgent: typeof AssistantAgent
|
|
200
|
+
declare const h: HtmlBuilder<Message>
|
|
201
|
+
declare const model: { readonly draft: string }
|
|
202
|
+
declare const agent: typeof agentRuntime
|
|
203
|
+
-->
|
|
168
204
|
```ts
|
|
169
205
|
const CreateTodoForm = AgentWebMcp.formTool(AppAgent, 'requested_create_todo')
|
|
170
206
|
|
|
@@ -206,6 +242,9 @@ keys.
|
|
|
206
242
|
|
|
207
243
|
`AgentWebMcp.register` returns:
|
|
208
244
|
|
|
245
|
+
<!-- docs-check
|
|
246
|
+
declare const registration: ReturnType<typeof AgentWebMcp.register>
|
|
247
|
+
-->
|
|
209
248
|
```ts
|
|
210
249
|
registration.registered() // capability names currently registered
|
|
211
250
|
await registration.refresh() // reconcile against the current Model
|
|
@@ -250,13 +289,17 @@ the application.
|
|
|
250
289
|
object with `registerTool` to capture descriptors and invoke their `execute`
|
|
251
290
|
functions directly:
|
|
252
291
|
|
|
292
|
+
<!-- docs-check
|
|
293
|
+
import type { ModelContext } from 'foldkit-agent-webmcp'
|
|
294
|
+
declare const fakeModelContext: ModelContext
|
|
295
|
+
-->
|
|
253
296
|
```ts
|
|
254
|
-
const
|
|
297
|
+
const tested = AgentWebMcp.register({
|
|
255
298
|
agent: agentRuntime,
|
|
256
299
|
modelContext: fakeModelContext,
|
|
257
300
|
})
|
|
258
301
|
|
|
259
|
-
await
|
|
302
|
+
await tested.refresh()
|
|
260
303
|
```
|
|
261
304
|
|
|
262
305
|
That is how the package test suite and [`examples/todo`](../../examples/todo)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foldkit-agent-webmcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "WebMCP adapter for foldkit-agent. Projects exposed Foldkit Messages into document.modelContext tools.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"foldkit",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"effect": "^4.1.0",
|
|
42
42
|
"foldkit": "^0.170.0",
|
|
43
|
-
"foldkit-agent": "^0.
|
|
43
|
+
"foldkit-agent": "^0.12.0"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {},
|
|
46
46
|
"devDependencies": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"foldkit": "0.170.0",
|
|
50
50
|
"tsdown": "^0.23.1",
|
|
51
51
|
"typescript": "7.0.2",
|
|
52
|
-
"foldkit-agent": "0.
|
|
52
|
+
"foldkit-agent": "0.12.0"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"build": "node ../../scripts/declarations.mjs . && tsdown && node ../../scripts/declared-any.mjs .",
|