@thegreataxios/webmcp-vue 0.0.0-stage → 0.2.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.
- package/LICENSE +21 -0
- package/README.md +53 -2
- package/dist/index.cjs +233 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +109 -0
- package/dist/index.d.ts +109 -0
- package/dist/index.js +215 -0
- package/dist/index.js.map +1 -0
- package/package.json +49 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sawyer Cutler
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,54 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @thegreataxios/webmcp-vue
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Vue 3 Composition API bindings and plugin for the [W3C WebMCP](https://github.com/webmachinelearning/webmcp) API.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @thegreataxios/webmcp-vue @thegreataxios/webmcp-core
|
|
9
|
+
# or
|
|
10
|
+
bun add @thegreataxios/webmcp-vue @thegreataxios/webmcp-core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```vue
|
|
16
|
+
<script setup lang="ts">
|
|
17
|
+
import { provideWebMCP, useWebMCPTool } from "@thegreataxios/webmcp-vue";
|
|
18
|
+
|
|
19
|
+
provideWebMCP({ name: "shop", version: "1.0.0" });
|
|
20
|
+
|
|
21
|
+
useWebMCPTool({
|
|
22
|
+
name: "search_catalog",
|
|
23
|
+
title: "Search Catalog",
|
|
24
|
+
description: "Search products by keyword",
|
|
25
|
+
inputSchema: {
|
|
26
|
+
type: "object",
|
|
27
|
+
properties: { q: { type: "string" } },
|
|
28
|
+
required: ["q"],
|
|
29
|
+
},
|
|
30
|
+
annotations: { readOnlyHint: true },
|
|
31
|
+
handler: async ({ q }, options) => {
|
|
32
|
+
const res = await fetch(`/api/search?q=${encodeURIComponent(String(q))}`, {
|
|
33
|
+
signal: options?.signal,
|
|
34
|
+
});
|
|
35
|
+
return res.json();
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
</script>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Exports
|
|
42
|
+
|
|
43
|
+
- `createWebMCPPlugin({ name, version })` (`app.use(...)`)
|
|
44
|
+
- `provideWebMCP({ name, version })` / `useWebMCP()`
|
|
45
|
+
- `useWebMCPTool(options)` — auto-aborts on `onScopeDispose`
|
|
46
|
+
- `useWaitForToolsUntil(promise)`
|
|
47
|
+
- `experimental_useWebMCPSync({ initial, tools })` — returns a readonly Vue `Ref<T>`
|
|
48
|
+
- `experimental_useWebMCPJourney({ name, tools, active })`
|
|
49
|
+
- `experimental_provideWebMCPConfirm()` / `experimental_useWebMCPConfirm()` / `experimental_useWebMCPGuardedTool(options)` — HITL confirmation queue & guarded tool registration
|
|
50
|
+
- `experimental_useWebMCPBridge({ url, token })`
|
|
51
|
+
|
|
52
|
+
## License
|
|
53
|
+
|
|
54
|
+
MIT
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
WEBMCP_CONFIRM_INJECTION_KEY: () => WEBMCP_CONFIRM_INJECTION_KEY,
|
|
24
|
+
WEBMCP_INJECTION_KEY: () => WEBMCP_INJECTION_KEY,
|
|
25
|
+
createWebMCPPlugin: () => createWebMCPPlugin,
|
|
26
|
+
experimental_provideWebMCPConfirm: () => experimental_provideWebMCPConfirm,
|
|
27
|
+
experimental_useWebMCPBridge: () => experimental_useWebMCPBridge,
|
|
28
|
+
experimental_useWebMCPGuardedTool: () => experimental_useWebMCPGuardedTool,
|
|
29
|
+
experimental_useWebMCPJourney: () => experimental_useWebMCPJourney,
|
|
30
|
+
experimental_useWebMCPSync: () => experimental_useWebMCPSync,
|
|
31
|
+
provideWebMCP: () => provideWebMCP,
|
|
32
|
+
useWaitForToolsUntil: () => useWaitForToolsUntil,
|
|
33
|
+
useWebMCP: () => useWebMCP,
|
|
34
|
+
useWebMCPTool: () => useWebMCPTool
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(index_exports);
|
|
37
|
+
var import_vue = require("vue");
|
|
38
|
+
var import_webmcp_core = require("@thegreataxios/webmcp-core");
|
|
39
|
+
var WEBMCP_INJECTION_KEY = /* @__PURE__ */ Symbol("webmcp-vue-context");
|
|
40
|
+
var WEBMCP_CONFIRM_INJECTION_KEY = /* @__PURE__ */ Symbol(
|
|
41
|
+
"webmcp-vue-confirm"
|
|
42
|
+
);
|
|
43
|
+
function registerScopeCleanup(fn) {
|
|
44
|
+
if ((0, import_vue.getCurrentScope)()) {
|
|
45
|
+
(0, import_vue.onScopeDispose)(fn);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function provideWebMCP(options) {
|
|
49
|
+
const journeyRegistry = (0, import_webmcp_core.experimental_createJourneyRegistry)();
|
|
50
|
+
(0, import_webmcp_core.setJourneyRegistry)(journeyRegistry);
|
|
51
|
+
(0, import_webmcp_core.installPolyfill)();
|
|
52
|
+
let destroyed = false;
|
|
53
|
+
const destroy = () => {
|
|
54
|
+
if (destroyed) return;
|
|
55
|
+
destroyed = true;
|
|
56
|
+
(0, import_webmcp_core.setJourneyRegistry)(null);
|
|
57
|
+
(0, import_webmcp_core.cleanupPolyfill)();
|
|
58
|
+
};
|
|
59
|
+
const ctx = {
|
|
60
|
+
available: typeof document !== "undefined" && document.modelContext != null,
|
|
61
|
+
native: (0, import_webmcp_core.isNativeModelContext)(),
|
|
62
|
+
appName: options.name,
|
|
63
|
+
appVersion: options.version,
|
|
64
|
+
journeyRegistry,
|
|
65
|
+
destroy
|
|
66
|
+
};
|
|
67
|
+
if ((0, import_vue.getCurrentInstance)()) {
|
|
68
|
+
(0, import_vue.provide)(WEBMCP_INJECTION_KEY, ctx);
|
|
69
|
+
}
|
|
70
|
+
registerScopeCleanup(destroy);
|
|
71
|
+
return ctx;
|
|
72
|
+
}
|
|
73
|
+
function createWebMCPPlugin(options) {
|
|
74
|
+
return {
|
|
75
|
+
install(app) {
|
|
76
|
+
const ctx = provideWebMCP(options);
|
|
77
|
+
app.provide(WEBMCP_INJECTION_KEY, ctx);
|
|
78
|
+
const origUnmount = app.unmount.bind(app);
|
|
79
|
+
app.unmount = () => {
|
|
80
|
+
ctx.destroy();
|
|
81
|
+
return origUnmount();
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function useWebMCP() {
|
|
87
|
+
return (0, import_vue.getCurrentInstance)() ? (0, import_vue.inject)(WEBMCP_INJECTION_KEY, void 0) : void 0;
|
|
88
|
+
}
|
|
89
|
+
function useWebMCPTool(options) {
|
|
90
|
+
const controller = new AbortController();
|
|
91
|
+
let disposed = false;
|
|
92
|
+
const dispose = () => {
|
|
93
|
+
if (disposed) return;
|
|
94
|
+
disposed = true;
|
|
95
|
+
controller.abort();
|
|
96
|
+
};
|
|
97
|
+
if (typeof document !== "undefined" && document.modelContext) {
|
|
98
|
+
document.modelContext.registerTool(
|
|
99
|
+
{
|
|
100
|
+
name: options.name,
|
|
101
|
+
title: options.title,
|
|
102
|
+
description: options.description,
|
|
103
|
+
inputSchema: options.inputSchema,
|
|
104
|
+
outputSchema: options.outputSchema,
|
|
105
|
+
annotations: options.annotations,
|
|
106
|
+
execute: options.handler
|
|
107
|
+
},
|
|
108
|
+
{ signal: controller.signal, exposedTo: options.exposedTo }
|
|
109
|
+
).catch(() => {
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
registerScopeCleanup(dispose);
|
|
113
|
+
return { dispose };
|
|
114
|
+
}
|
|
115
|
+
function useWaitForToolsUntil(promise) {
|
|
116
|
+
if (typeof document !== "undefined") {
|
|
117
|
+
document.modelContext?.waitForToolsUntil?.(promise);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function experimental_useWebMCPSync(options) {
|
|
121
|
+
const controller = (0, import_webmcp_core.experimental_createSyncStateController)(options.initial);
|
|
122
|
+
const stateRef = (0, import_vue.ref)(controller.getState());
|
|
123
|
+
const unsub = controller.subscribe((next) => {
|
|
124
|
+
stateRef.value = next;
|
|
125
|
+
});
|
|
126
|
+
const handles = Object.entries(options.tools).map(
|
|
127
|
+
([name, def]) => useWebMCPTool({
|
|
128
|
+
name,
|
|
129
|
+
title: def.title,
|
|
130
|
+
description: def.description,
|
|
131
|
+
inputSchema: def.inputSchema,
|
|
132
|
+
outputSchema: def.outputSchema,
|
|
133
|
+
annotations: def.annotations,
|
|
134
|
+
handler: (args, cbOptions) => controller.enqueueMutation(def.reducer, args, cbOptions)
|
|
135
|
+
})
|
|
136
|
+
);
|
|
137
|
+
const dispose = () => {
|
|
138
|
+
unsub();
|
|
139
|
+
for (const h of handles) h.dispose();
|
|
140
|
+
};
|
|
141
|
+
registerScopeCleanup(dispose);
|
|
142
|
+
return {
|
|
143
|
+
state: (0, import_vue.readonly)(stateRef),
|
|
144
|
+
set: controller.setState,
|
|
145
|
+
update: controller.updateState,
|
|
146
|
+
dispose
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
function experimental_useWebMCPJourney(options) {
|
|
150
|
+
const registry = options.registry ?? useWebMCP()?.journeyRegistry;
|
|
151
|
+
registry?.register({
|
|
152
|
+
name: options.name,
|
|
153
|
+
description: options.description,
|
|
154
|
+
tools: options.tools
|
|
155
|
+
});
|
|
156
|
+
if (options.active) {
|
|
157
|
+
registry?.setJourneyActive(options.name, true);
|
|
158
|
+
}
|
|
159
|
+
const dispose = () => {
|
|
160
|
+
registry?.unregister(options.name);
|
|
161
|
+
};
|
|
162
|
+
registerScopeCleanup(dispose);
|
|
163
|
+
return {
|
|
164
|
+
setActive: (active) => registry?.setJourneyActive(options.name, active),
|
|
165
|
+
dispose
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
function experimental_useWebMCPBridge(options) {
|
|
169
|
+
const statusRef = (0, import_vue.ref)("disconnected");
|
|
170
|
+
const client = (0, import_webmcp_core.createPageBridgeClient)({
|
|
171
|
+
url: options.url ?? "ws://127.0.0.1:17321/ws",
|
|
172
|
+
token: options.token,
|
|
173
|
+
onStatusChange: (next) => {
|
|
174
|
+
statusRef.value = next;
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
client.connect();
|
|
178
|
+
const disconnect = () => client.disconnect();
|
|
179
|
+
registerScopeCleanup(disconnect);
|
|
180
|
+
return {
|
|
181
|
+
status: (0, import_vue.readonly)(statusRef),
|
|
182
|
+
disconnect
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function experimental_provideWebMCPConfirm() {
|
|
186
|
+
const queue = (0, import_webmcp_core.experimental_createConfirmQueue)();
|
|
187
|
+
const pendingRef = (0, import_vue.ref)(queue.getPending());
|
|
188
|
+
const unsub = queue.subscribe((next) => {
|
|
189
|
+
pendingRef.value = next;
|
|
190
|
+
});
|
|
191
|
+
const dispose = () => {
|
|
192
|
+
unsub();
|
|
193
|
+
queue.dispose();
|
|
194
|
+
};
|
|
195
|
+
if ((0, import_vue.getCurrentInstance)()) {
|
|
196
|
+
(0, import_vue.provide)(WEBMCP_CONFIRM_INJECTION_KEY, queue);
|
|
197
|
+
}
|
|
198
|
+
registerScopeCleanup(dispose);
|
|
199
|
+
return {
|
|
200
|
+
pending: (0, import_vue.readonly)(pendingRef),
|
|
201
|
+
queue,
|
|
202
|
+
dispose
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
function experimental_useWebMCPGuardedTool(options) {
|
|
206
|
+
const injected = (0, import_vue.getCurrentInstance)() ? (0, import_vue.inject)(WEBMCP_CONFIRM_INJECTION_KEY, void 0) : void 0;
|
|
207
|
+
const queue = options.confirmQueue ?? injected;
|
|
208
|
+
return useWebMCPTool({
|
|
209
|
+
...options,
|
|
210
|
+
handler: (0, import_webmcp_core.experimental_wrapGuardedHandler)({
|
|
211
|
+
name: options.name,
|
|
212
|
+
requiresConfirm: options.requiresConfirm,
|
|
213
|
+
queue,
|
|
214
|
+
handler: options.handler
|
|
215
|
+
})
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
219
|
+
0 && (module.exports = {
|
|
220
|
+
WEBMCP_CONFIRM_INJECTION_KEY,
|
|
221
|
+
WEBMCP_INJECTION_KEY,
|
|
222
|
+
createWebMCPPlugin,
|
|
223
|
+
experimental_provideWebMCPConfirm,
|
|
224
|
+
experimental_useWebMCPBridge,
|
|
225
|
+
experimental_useWebMCPGuardedTool,
|
|
226
|
+
experimental_useWebMCPJourney,
|
|
227
|
+
experimental_useWebMCPSync,
|
|
228
|
+
provideWebMCP,
|
|
229
|
+
useWaitForToolsUntil,
|
|
230
|
+
useWebMCP,
|
|
231
|
+
useWebMCPTool
|
|
232
|
+
});
|
|
233
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {\n getCurrentInstance,\n getCurrentScope,\n inject,\n onScopeDispose,\n provide,\n readonly,\n ref,\n type App,\n type InjectionKey,\n type Plugin,\n type Ref,\n} from \"vue\";\nimport {\n cleanupPolyfill,\n createPageBridgeClient,\n experimental_createConfirmQueue,\n experimental_createJourneyRegistry,\n experimental_createSyncStateController,\n experimental_wrapGuardedHandler,\n installPolyfill,\n isNativeModelContext,\n setJourneyRegistry,\n type ConfirmPrompt,\n type ConfirmQueue,\n type JourneyRegistry,\n type JsonSchema,\n type PageBridgeStatus,\n type ToolAnnotations,\n type ToolExecuteCallback,\n type ToolExecuteCallbackOptions,\n} from \"@thegreataxios/webmcp-core\";\n\nexport interface WebMCPVueContext {\n readonly available: boolean;\n readonly native: boolean;\n readonly appName: string;\n readonly appVersion?: string;\n readonly journeyRegistry: JourneyRegistry;\n destroy(): void;\n}\n\nexport const WEBMCP_INJECTION_KEY: InjectionKey<WebMCPVueContext> = Symbol(\"webmcp-vue-context\");\nexport const WEBMCP_CONFIRM_INJECTION_KEY: InjectionKey<ConfirmQueue> = Symbol(\n \"webmcp-vue-confirm\",\n);\n\nexport interface ProvideWebMCPOptions {\n name: string;\n version?: string;\n}\n\nfunction registerScopeCleanup(fn: () => void): void {\n if (getCurrentScope()) {\n onScopeDispose(fn);\n }\n}\n\n/**\n * Initialize WebMCP inside a Vue component `setup()` or `effectScope()`.\n */\nexport function provideWebMCP(options: ProvideWebMCPOptions): WebMCPVueContext {\n const journeyRegistry = experimental_createJourneyRegistry();\n setJourneyRegistry(journeyRegistry);\n installPolyfill();\n\n let destroyed = false;\n const destroy = () => {\n if (destroyed) return;\n destroyed = true;\n setJourneyRegistry(null);\n cleanupPolyfill();\n };\n\n const ctx: WebMCPVueContext = {\n available: typeof document !== \"undefined\" && document.modelContext != null,\n native: isNativeModelContext(),\n appName: options.name,\n appVersion: options.version,\n journeyRegistry,\n destroy,\n };\n\n if (getCurrentInstance()) {\n provide(WEBMCP_INJECTION_KEY, ctx);\n }\n registerScopeCleanup(destroy);\n return ctx;\n}\n\n/**\n * Vue 3 plugin (`app.use(createWebMCPPlugin({ name: \"my-app\" }))`).\n */\nexport function createWebMCPPlugin(options: ProvideWebMCPOptions): Plugin {\n return {\n install(app: App) {\n const ctx = provideWebMCP(options);\n app.provide(WEBMCP_INJECTION_KEY, ctx);\n const origUnmount = app.unmount.bind(app);\n app.unmount = () => {\n ctx.destroy();\n return origUnmount();\n };\n },\n };\n}\n\nexport function useWebMCP(): WebMCPVueContext | undefined {\n return getCurrentInstance() ? inject(WEBMCP_INJECTION_KEY, undefined) : undefined;\n}\n\nexport interface VueToolOptions {\n name: string;\n description: string;\n title?: string;\n inputSchema?: JsonSchema;\n outputSchema?: JsonSchema;\n annotations?: ToolAnnotations;\n exposedTo?: string[];\n handler: ToolExecuteCallback;\n}\n\n/**\n * Register a WebMCP tool for the lifetime of the current Vue component or `effectScope()`.\n */\nexport function useWebMCPTool(options: VueToolOptions): { dispose: () => void } {\n const controller = new AbortController();\n let disposed = false;\n\n const dispose = () => {\n if (disposed) return;\n disposed = true;\n controller.abort();\n };\n\n if (typeof document !== \"undefined\" && document.modelContext) {\n document.modelContext\n .registerTool(\n {\n name: options.name,\n title: options.title,\n description: options.description,\n inputSchema: options.inputSchema,\n outputSchema: options.outputSchema,\n annotations: options.annotations,\n execute: options.handler,\n },\n { signal: controller.signal, exposedTo: options.exposedTo },\n )\n .catch(() => {});\n }\n\n registerScopeCleanup(dispose);\n return { dispose };\n}\n\n/**\n * Signal async tool registration stability to `document.modelContext.waitForToolsUntil`.\n */\nexport function useWaitForToolsUntil(promise: Promise<unknown>): void {\n if (typeof document !== \"undefined\") {\n document.modelContext?.waitForToolsUntil?.(promise);\n }\n}\n\nexport interface VueSyncTool<TState> {\n description: string;\n title?: string;\n inputSchema?: JsonSchema;\n outputSchema?: JsonSchema;\n annotations?: ToolAnnotations;\n reducer: (\n state: TState,\n args: Record<string, unknown>,\n options?: ToolExecuteCallbackOptions,\n ) => TState | Promise<TState>;\n}\n\n/**\n * Bind a Vue reactive `ref` to one or more WebMCP tools whose reducers update state.\n */\nexport function experimental_useWebMCPSync<TState>(options: {\n initial: TState;\n tools: Record<string, VueSyncTool<TState>>;\n}): {\n state: Readonly<Ref<TState>>;\n set: (next: TState) => void;\n update: (fn: (prev: TState) => TState) => void;\n dispose: () => void;\n} {\n const controller = experimental_createSyncStateController(options.initial);\n const stateRef = ref(controller.getState()) as Ref<TState>;\n const unsub = controller.subscribe((next) => {\n stateRef.value = next;\n });\n\n const handles = Object.entries(options.tools).map(([name, def]) =>\n useWebMCPTool({\n name,\n title: def.title,\n description: def.description,\n inputSchema: def.inputSchema,\n outputSchema: def.outputSchema,\n annotations: def.annotations,\n handler: (args, cbOptions) => controller.enqueueMutation(def.reducer, args, cbOptions),\n }),\n );\n\n const dispose = () => {\n unsub();\n for (const h of handles) h.dispose();\n };\n registerScopeCleanup(dispose);\n\n return {\n state: readonly(stateRef) as Readonly<Ref<TState>>,\n set: controller.setState,\n update: controller.updateState,\n dispose,\n };\n}\n\n/**\n * Register and control a journey from Vue, auto-cleaning up on scope dispose.\n */\nexport function experimental_useWebMCPJourney(options: {\n name: string;\n tools: string[];\n description?: string;\n active?: boolean;\n registry?: JourneyRegistry;\n}): {\n setActive: (active: boolean) => void;\n dispose: () => void;\n} {\n const registry = options.registry ?? useWebMCP()?.journeyRegistry;\n registry?.register({\n name: options.name,\n description: options.description,\n tools: options.tools,\n });\n if (options.active) {\n registry?.setJourneyActive(options.name, true);\n }\n\n const dispose = () => {\n registry?.unregister(options.name);\n };\n registerScopeCleanup(dispose);\n\n return {\n setActive: (active: boolean) => registry?.setJourneyActive(options.name, active),\n dispose,\n };\n}\n\n/**\n * Connect a Vue app to `webmcp-bridge` and expose reactive connection status.\n */\nexport function experimental_useWebMCPBridge(options: {\n url?: string;\n token: string;\n}): {\n status: Readonly<Ref<PageBridgeStatus>>;\n disconnect: () => void;\n} {\n const statusRef = ref<PageBridgeStatus>(\"disconnected\");\n const client = createPageBridgeClient({\n url: options.url ?? \"ws://127.0.0.1:17321/ws\",\n token: options.token,\n onStatusChange: (next) => {\n statusRef.value = next;\n },\n });\n client.connect();\n\n const disconnect = () => client.disconnect();\n registerScopeCleanup(disconnect);\n\n return {\n status: readonly(statusRef),\n disconnect,\n };\n}\n\n/**\n * Create a HITL confirmation queue for Vue components and expose the active prompt as a readonly Ref.\n */\nexport function experimental_provideWebMCPConfirm(): {\n pending: Readonly<Ref<ConfirmPrompt | null>>;\n queue: ConfirmQueue;\n dispose: () => void;\n} {\n const queue = experimental_createConfirmQueue();\n const pendingRef = ref<ConfirmPrompt | null>(queue.getPending());\n const unsub = queue.subscribe((next) => {\n pendingRef.value = next;\n });\n\n const dispose = () => {\n unsub();\n queue.dispose();\n };\n\n if (getCurrentInstance()) {\n provide(WEBMCP_CONFIRM_INJECTION_KEY, queue);\n }\n registerScopeCleanup(dispose);\n\n return {\n pending: readonly(pendingRef) as Readonly<Ref<ConfirmPrompt | null>>,\n queue,\n dispose,\n };\n}\n\nexport interface VueGuardedToolOptions extends VueToolOptions {\n requiresConfirm?: boolean;\n confirmQueue?: ConfirmQueue;\n}\n\n/**\n * Register a WebMCP tool guarded by a HITL confirmation queue (fails closed if none is provided).\n */\nexport function experimental_useWebMCPGuardedTool(\n options: VueGuardedToolOptions,\n): { dispose: () => void } {\n const injected = getCurrentInstance() ? inject(WEBMCP_CONFIRM_INJECTION_KEY, undefined) : undefined;\n const queue = options.confirmQueue ?? injected;\n return useWebMCPTool({\n ...options,\n handler: experimental_wrapGuardedHandler({\n name: options.name,\n requiresConfirm: options.requiresConfirm,\n queue,\n handler: options.handler,\n }),\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAYO;AACP,yBAkBO;AAWA,IAAM,uBAAuD,uBAAO,oBAAoB;AACxF,IAAM,+BAA2D;AAAA,EACtE;AACF;AAOA,SAAS,qBAAqB,IAAsB;AAClD,UAAI,4BAAgB,GAAG;AACrB,mCAAe,EAAE;AAAA,EACnB;AACF;AAKO,SAAS,cAAc,SAAiD;AAC7E,QAAM,sBAAkB,uDAAmC;AAC3D,6CAAmB,eAAe;AAClC,0CAAgB;AAEhB,MAAI,YAAY;AAChB,QAAM,UAAU,MAAM;AACpB,QAAI,UAAW;AACf,gBAAY;AACZ,+CAAmB,IAAI;AACvB,4CAAgB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|
|
1
|
+
import { InjectionKey, Plugin, Ref } from 'vue';
|
|
2
|
+
import { JsonSchema, ToolAnnotations, ToolExecuteCallback, ConfirmQueue, ToolExecuteCallbackOptions, JourneyRegistry, ConfirmPrompt, PageBridgeStatus } from '@thegreataxios/webmcp-core';
|
|
3
|
+
|
|
4
|
+
interface WebMCPVueContext {
|
|
5
|
+
readonly available: boolean;
|
|
6
|
+
readonly native: boolean;
|
|
7
|
+
readonly appName: string;
|
|
8
|
+
readonly appVersion?: string;
|
|
9
|
+
readonly journeyRegistry: JourneyRegistry;
|
|
10
|
+
destroy(): void;
|
|
11
|
+
}
|
|
12
|
+
declare const WEBMCP_INJECTION_KEY: InjectionKey<WebMCPVueContext>;
|
|
13
|
+
declare const WEBMCP_CONFIRM_INJECTION_KEY: InjectionKey<ConfirmQueue>;
|
|
14
|
+
interface ProvideWebMCPOptions {
|
|
15
|
+
name: string;
|
|
16
|
+
version?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Initialize WebMCP inside a Vue component `setup()` or `effectScope()`.
|
|
20
|
+
*/
|
|
21
|
+
declare function provideWebMCP(options: ProvideWebMCPOptions): WebMCPVueContext;
|
|
22
|
+
/**
|
|
23
|
+
* Vue 3 plugin (`app.use(createWebMCPPlugin({ name: "my-app" }))`).
|
|
24
|
+
*/
|
|
25
|
+
declare function createWebMCPPlugin(options: ProvideWebMCPOptions): Plugin;
|
|
26
|
+
declare function useWebMCP(): WebMCPVueContext | undefined;
|
|
27
|
+
interface VueToolOptions {
|
|
28
|
+
name: string;
|
|
29
|
+
description: string;
|
|
30
|
+
title?: string;
|
|
31
|
+
inputSchema?: JsonSchema;
|
|
32
|
+
outputSchema?: JsonSchema;
|
|
33
|
+
annotations?: ToolAnnotations;
|
|
34
|
+
exposedTo?: string[];
|
|
35
|
+
handler: ToolExecuteCallback;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Register a WebMCP tool for the lifetime of the current Vue component or `effectScope()`.
|
|
39
|
+
*/
|
|
40
|
+
declare function useWebMCPTool(options: VueToolOptions): {
|
|
41
|
+
dispose: () => void;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Signal async tool registration stability to `document.modelContext.waitForToolsUntil`.
|
|
45
|
+
*/
|
|
46
|
+
declare function useWaitForToolsUntil(promise: Promise<unknown>): void;
|
|
47
|
+
interface VueSyncTool<TState> {
|
|
48
|
+
description: string;
|
|
49
|
+
title?: string;
|
|
50
|
+
inputSchema?: JsonSchema;
|
|
51
|
+
outputSchema?: JsonSchema;
|
|
52
|
+
annotations?: ToolAnnotations;
|
|
53
|
+
reducer: (state: TState, args: Record<string, unknown>, options?: ToolExecuteCallbackOptions) => TState | Promise<TState>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Bind a Vue reactive `ref` to one or more WebMCP tools whose reducers update state.
|
|
57
|
+
*/
|
|
58
|
+
declare function experimental_useWebMCPSync<TState>(options: {
|
|
59
|
+
initial: TState;
|
|
60
|
+
tools: Record<string, VueSyncTool<TState>>;
|
|
61
|
+
}): {
|
|
62
|
+
state: Readonly<Ref<TState>>;
|
|
63
|
+
set: (next: TState) => void;
|
|
64
|
+
update: (fn: (prev: TState) => TState) => void;
|
|
65
|
+
dispose: () => void;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Register and control a journey from Vue, auto-cleaning up on scope dispose.
|
|
69
|
+
*/
|
|
70
|
+
declare function experimental_useWebMCPJourney(options: {
|
|
71
|
+
name: string;
|
|
72
|
+
tools: string[];
|
|
73
|
+
description?: string;
|
|
74
|
+
active?: boolean;
|
|
75
|
+
registry?: JourneyRegistry;
|
|
76
|
+
}): {
|
|
77
|
+
setActive: (active: boolean) => void;
|
|
78
|
+
dispose: () => void;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Connect a Vue app to `webmcp-bridge` and expose reactive connection status.
|
|
82
|
+
*/
|
|
83
|
+
declare function experimental_useWebMCPBridge(options: {
|
|
84
|
+
url?: string;
|
|
85
|
+
token: string;
|
|
86
|
+
}): {
|
|
87
|
+
status: Readonly<Ref<PageBridgeStatus>>;
|
|
88
|
+
disconnect: () => void;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Create a HITL confirmation queue for Vue components and expose the active prompt as a readonly Ref.
|
|
92
|
+
*/
|
|
93
|
+
declare function experimental_provideWebMCPConfirm(): {
|
|
94
|
+
pending: Readonly<Ref<ConfirmPrompt | null>>;
|
|
95
|
+
queue: ConfirmQueue;
|
|
96
|
+
dispose: () => void;
|
|
97
|
+
};
|
|
98
|
+
interface VueGuardedToolOptions extends VueToolOptions {
|
|
99
|
+
requiresConfirm?: boolean;
|
|
100
|
+
confirmQueue?: ConfirmQueue;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Register a WebMCP tool guarded by a HITL confirmation queue (fails closed if none is provided).
|
|
104
|
+
*/
|
|
105
|
+
declare function experimental_useWebMCPGuardedTool(options: VueGuardedToolOptions): {
|
|
106
|
+
dispose: () => void;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export { type ProvideWebMCPOptions, type VueGuardedToolOptions, type VueSyncTool, type VueToolOptions, WEBMCP_CONFIRM_INJECTION_KEY, WEBMCP_INJECTION_KEY, type WebMCPVueContext, createWebMCPPlugin, experimental_provideWebMCPConfirm, experimental_useWebMCPBridge, experimental_useWebMCPGuardedTool, experimental_useWebMCPJourney, experimental_useWebMCPSync, provideWebMCP, useWaitForToolsUntil, useWebMCP, useWebMCPTool };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { InjectionKey, Plugin, Ref } from 'vue';
|
|
2
|
+
import { JsonSchema, ToolAnnotations, ToolExecuteCallback, ConfirmQueue, ToolExecuteCallbackOptions, JourneyRegistry, ConfirmPrompt, PageBridgeStatus } from '@thegreataxios/webmcp-core';
|
|
3
|
+
|
|
4
|
+
interface WebMCPVueContext {
|
|
5
|
+
readonly available: boolean;
|
|
6
|
+
readonly native: boolean;
|
|
7
|
+
readonly appName: string;
|
|
8
|
+
readonly appVersion?: string;
|
|
9
|
+
readonly journeyRegistry: JourneyRegistry;
|
|
10
|
+
destroy(): void;
|
|
11
|
+
}
|
|
12
|
+
declare const WEBMCP_INJECTION_KEY: InjectionKey<WebMCPVueContext>;
|
|
13
|
+
declare const WEBMCP_CONFIRM_INJECTION_KEY: InjectionKey<ConfirmQueue>;
|
|
14
|
+
interface ProvideWebMCPOptions {
|
|
15
|
+
name: string;
|
|
16
|
+
version?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Initialize WebMCP inside a Vue component `setup()` or `effectScope()`.
|
|
20
|
+
*/
|
|
21
|
+
declare function provideWebMCP(options: ProvideWebMCPOptions): WebMCPVueContext;
|
|
22
|
+
/**
|
|
23
|
+
* Vue 3 plugin (`app.use(createWebMCPPlugin({ name: "my-app" }))`).
|
|
24
|
+
*/
|
|
25
|
+
declare function createWebMCPPlugin(options: ProvideWebMCPOptions): Plugin;
|
|
26
|
+
declare function useWebMCP(): WebMCPVueContext | undefined;
|
|
27
|
+
interface VueToolOptions {
|
|
28
|
+
name: string;
|
|
29
|
+
description: string;
|
|
30
|
+
title?: string;
|
|
31
|
+
inputSchema?: JsonSchema;
|
|
32
|
+
outputSchema?: JsonSchema;
|
|
33
|
+
annotations?: ToolAnnotations;
|
|
34
|
+
exposedTo?: string[];
|
|
35
|
+
handler: ToolExecuteCallback;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Register a WebMCP tool for the lifetime of the current Vue component or `effectScope()`.
|
|
39
|
+
*/
|
|
40
|
+
declare function useWebMCPTool(options: VueToolOptions): {
|
|
41
|
+
dispose: () => void;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Signal async tool registration stability to `document.modelContext.waitForToolsUntil`.
|
|
45
|
+
*/
|
|
46
|
+
declare function useWaitForToolsUntil(promise: Promise<unknown>): void;
|
|
47
|
+
interface VueSyncTool<TState> {
|
|
48
|
+
description: string;
|
|
49
|
+
title?: string;
|
|
50
|
+
inputSchema?: JsonSchema;
|
|
51
|
+
outputSchema?: JsonSchema;
|
|
52
|
+
annotations?: ToolAnnotations;
|
|
53
|
+
reducer: (state: TState, args: Record<string, unknown>, options?: ToolExecuteCallbackOptions) => TState | Promise<TState>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Bind a Vue reactive `ref` to one or more WebMCP tools whose reducers update state.
|
|
57
|
+
*/
|
|
58
|
+
declare function experimental_useWebMCPSync<TState>(options: {
|
|
59
|
+
initial: TState;
|
|
60
|
+
tools: Record<string, VueSyncTool<TState>>;
|
|
61
|
+
}): {
|
|
62
|
+
state: Readonly<Ref<TState>>;
|
|
63
|
+
set: (next: TState) => void;
|
|
64
|
+
update: (fn: (prev: TState) => TState) => void;
|
|
65
|
+
dispose: () => void;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Register and control a journey from Vue, auto-cleaning up on scope dispose.
|
|
69
|
+
*/
|
|
70
|
+
declare function experimental_useWebMCPJourney(options: {
|
|
71
|
+
name: string;
|
|
72
|
+
tools: string[];
|
|
73
|
+
description?: string;
|
|
74
|
+
active?: boolean;
|
|
75
|
+
registry?: JourneyRegistry;
|
|
76
|
+
}): {
|
|
77
|
+
setActive: (active: boolean) => void;
|
|
78
|
+
dispose: () => void;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Connect a Vue app to `webmcp-bridge` and expose reactive connection status.
|
|
82
|
+
*/
|
|
83
|
+
declare function experimental_useWebMCPBridge(options: {
|
|
84
|
+
url?: string;
|
|
85
|
+
token: string;
|
|
86
|
+
}): {
|
|
87
|
+
status: Readonly<Ref<PageBridgeStatus>>;
|
|
88
|
+
disconnect: () => void;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Create a HITL confirmation queue for Vue components and expose the active prompt as a readonly Ref.
|
|
92
|
+
*/
|
|
93
|
+
declare function experimental_provideWebMCPConfirm(): {
|
|
94
|
+
pending: Readonly<Ref<ConfirmPrompt | null>>;
|
|
95
|
+
queue: ConfirmQueue;
|
|
96
|
+
dispose: () => void;
|
|
97
|
+
};
|
|
98
|
+
interface VueGuardedToolOptions extends VueToolOptions {
|
|
99
|
+
requiresConfirm?: boolean;
|
|
100
|
+
confirmQueue?: ConfirmQueue;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Register a WebMCP tool guarded by a HITL confirmation queue (fails closed if none is provided).
|
|
104
|
+
*/
|
|
105
|
+
declare function experimental_useWebMCPGuardedTool(options: VueGuardedToolOptions): {
|
|
106
|
+
dispose: () => void;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export { type ProvideWebMCPOptions, type VueGuardedToolOptions, type VueSyncTool, type VueToolOptions, WEBMCP_CONFIRM_INJECTION_KEY, WEBMCP_INJECTION_KEY, type WebMCPVueContext, createWebMCPPlugin, experimental_provideWebMCPConfirm, experimental_useWebMCPBridge, experimental_useWebMCPGuardedTool, experimental_useWebMCPJourney, experimental_useWebMCPSync, provideWebMCP, useWaitForToolsUntil, useWebMCP, useWebMCPTool };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import {
|
|
3
|
+
getCurrentInstance,
|
|
4
|
+
getCurrentScope,
|
|
5
|
+
inject,
|
|
6
|
+
onScopeDispose,
|
|
7
|
+
provide,
|
|
8
|
+
readonly,
|
|
9
|
+
ref
|
|
10
|
+
} from "vue";
|
|
11
|
+
import {
|
|
12
|
+
cleanupPolyfill,
|
|
13
|
+
createPageBridgeClient,
|
|
14
|
+
experimental_createConfirmQueue,
|
|
15
|
+
experimental_createJourneyRegistry,
|
|
16
|
+
experimental_createSyncStateController,
|
|
17
|
+
experimental_wrapGuardedHandler,
|
|
18
|
+
installPolyfill,
|
|
19
|
+
isNativeModelContext,
|
|
20
|
+
setJourneyRegistry
|
|
21
|
+
} from "@thegreataxios/webmcp-core";
|
|
22
|
+
var WEBMCP_INJECTION_KEY = /* @__PURE__ */ Symbol("webmcp-vue-context");
|
|
23
|
+
var WEBMCP_CONFIRM_INJECTION_KEY = /* @__PURE__ */ Symbol(
|
|
24
|
+
"webmcp-vue-confirm"
|
|
25
|
+
);
|
|
26
|
+
function registerScopeCleanup(fn) {
|
|
27
|
+
if (getCurrentScope()) {
|
|
28
|
+
onScopeDispose(fn);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function provideWebMCP(options) {
|
|
32
|
+
const journeyRegistry = experimental_createJourneyRegistry();
|
|
33
|
+
setJourneyRegistry(journeyRegistry);
|
|
34
|
+
installPolyfill();
|
|
35
|
+
let destroyed = false;
|
|
36
|
+
const destroy = () => {
|
|
37
|
+
if (destroyed) return;
|
|
38
|
+
destroyed = true;
|
|
39
|
+
setJourneyRegistry(null);
|
|
40
|
+
cleanupPolyfill();
|
|
41
|
+
};
|
|
42
|
+
const ctx = {
|
|
43
|
+
available: typeof document !== "undefined" && document.modelContext != null,
|
|
44
|
+
native: isNativeModelContext(),
|
|
45
|
+
appName: options.name,
|
|
46
|
+
appVersion: options.version,
|
|
47
|
+
journeyRegistry,
|
|
48
|
+
destroy
|
|
49
|
+
};
|
|
50
|
+
if (getCurrentInstance()) {
|
|
51
|
+
provide(WEBMCP_INJECTION_KEY, ctx);
|
|
52
|
+
}
|
|
53
|
+
registerScopeCleanup(destroy);
|
|
54
|
+
return ctx;
|
|
55
|
+
}
|
|
56
|
+
function createWebMCPPlugin(options) {
|
|
57
|
+
return {
|
|
58
|
+
install(app) {
|
|
59
|
+
const ctx = provideWebMCP(options);
|
|
60
|
+
app.provide(WEBMCP_INJECTION_KEY, ctx);
|
|
61
|
+
const origUnmount = app.unmount.bind(app);
|
|
62
|
+
app.unmount = () => {
|
|
63
|
+
ctx.destroy();
|
|
64
|
+
return origUnmount();
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function useWebMCP() {
|
|
70
|
+
return getCurrentInstance() ? inject(WEBMCP_INJECTION_KEY, void 0) : void 0;
|
|
71
|
+
}
|
|
72
|
+
function useWebMCPTool(options) {
|
|
73
|
+
const controller = new AbortController();
|
|
74
|
+
let disposed = false;
|
|
75
|
+
const dispose = () => {
|
|
76
|
+
if (disposed) return;
|
|
77
|
+
disposed = true;
|
|
78
|
+
controller.abort();
|
|
79
|
+
};
|
|
80
|
+
if (typeof document !== "undefined" && document.modelContext) {
|
|
81
|
+
document.modelContext.registerTool(
|
|
82
|
+
{
|
|
83
|
+
name: options.name,
|
|
84
|
+
title: options.title,
|
|
85
|
+
description: options.description,
|
|
86
|
+
inputSchema: options.inputSchema,
|
|
87
|
+
outputSchema: options.outputSchema,
|
|
88
|
+
annotations: options.annotations,
|
|
89
|
+
execute: options.handler
|
|
90
|
+
},
|
|
91
|
+
{ signal: controller.signal, exposedTo: options.exposedTo }
|
|
92
|
+
).catch(() => {
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
registerScopeCleanup(dispose);
|
|
96
|
+
return { dispose };
|
|
97
|
+
}
|
|
98
|
+
function useWaitForToolsUntil(promise) {
|
|
99
|
+
if (typeof document !== "undefined") {
|
|
100
|
+
document.modelContext?.waitForToolsUntil?.(promise);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function experimental_useWebMCPSync(options) {
|
|
104
|
+
const controller = experimental_createSyncStateController(options.initial);
|
|
105
|
+
const stateRef = ref(controller.getState());
|
|
106
|
+
const unsub = controller.subscribe((next) => {
|
|
107
|
+
stateRef.value = next;
|
|
108
|
+
});
|
|
109
|
+
const handles = Object.entries(options.tools).map(
|
|
110
|
+
([name, def]) => useWebMCPTool({
|
|
111
|
+
name,
|
|
112
|
+
title: def.title,
|
|
113
|
+
description: def.description,
|
|
114
|
+
inputSchema: def.inputSchema,
|
|
115
|
+
outputSchema: def.outputSchema,
|
|
116
|
+
annotations: def.annotations,
|
|
117
|
+
handler: (args, cbOptions) => controller.enqueueMutation(def.reducer, args, cbOptions)
|
|
118
|
+
})
|
|
119
|
+
);
|
|
120
|
+
const dispose = () => {
|
|
121
|
+
unsub();
|
|
122
|
+
for (const h of handles) h.dispose();
|
|
123
|
+
};
|
|
124
|
+
registerScopeCleanup(dispose);
|
|
125
|
+
return {
|
|
126
|
+
state: readonly(stateRef),
|
|
127
|
+
set: controller.setState,
|
|
128
|
+
update: controller.updateState,
|
|
129
|
+
dispose
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function experimental_useWebMCPJourney(options) {
|
|
133
|
+
const registry = options.registry ?? useWebMCP()?.journeyRegistry;
|
|
134
|
+
registry?.register({
|
|
135
|
+
name: options.name,
|
|
136
|
+
description: options.description,
|
|
137
|
+
tools: options.tools
|
|
138
|
+
});
|
|
139
|
+
if (options.active) {
|
|
140
|
+
registry?.setJourneyActive(options.name, true);
|
|
141
|
+
}
|
|
142
|
+
const dispose = () => {
|
|
143
|
+
registry?.unregister(options.name);
|
|
144
|
+
};
|
|
145
|
+
registerScopeCleanup(dispose);
|
|
146
|
+
return {
|
|
147
|
+
setActive: (active) => registry?.setJourneyActive(options.name, active),
|
|
148
|
+
dispose
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function experimental_useWebMCPBridge(options) {
|
|
152
|
+
const statusRef = ref("disconnected");
|
|
153
|
+
const client = createPageBridgeClient({
|
|
154
|
+
url: options.url ?? "ws://127.0.0.1:17321/ws",
|
|
155
|
+
token: options.token,
|
|
156
|
+
onStatusChange: (next) => {
|
|
157
|
+
statusRef.value = next;
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
client.connect();
|
|
161
|
+
const disconnect = () => client.disconnect();
|
|
162
|
+
registerScopeCleanup(disconnect);
|
|
163
|
+
return {
|
|
164
|
+
status: readonly(statusRef),
|
|
165
|
+
disconnect
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
function experimental_provideWebMCPConfirm() {
|
|
169
|
+
const queue = experimental_createConfirmQueue();
|
|
170
|
+
const pendingRef = ref(queue.getPending());
|
|
171
|
+
const unsub = queue.subscribe((next) => {
|
|
172
|
+
pendingRef.value = next;
|
|
173
|
+
});
|
|
174
|
+
const dispose = () => {
|
|
175
|
+
unsub();
|
|
176
|
+
queue.dispose();
|
|
177
|
+
};
|
|
178
|
+
if (getCurrentInstance()) {
|
|
179
|
+
provide(WEBMCP_CONFIRM_INJECTION_KEY, queue);
|
|
180
|
+
}
|
|
181
|
+
registerScopeCleanup(dispose);
|
|
182
|
+
return {
|
|
183
|
+
pending: readonly(pendingRef),
|
|
184
|
+
queue,
|
|
185
|
+
dispose
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
function experimental_useWebMCPGuardedTool(options) {
|
|
189
|
+
const injected = getCurrentInstance() ? inject(WEBMCP_CONFIRM_INJECTION_KEY, void 0) : void 0;
|
|
190
|
+
const queue = options.confirmQueue ?? injected;
|
|
191
|
+
return useWebMCPTool({
|
|
192
|
+
...options,
|
|
193
|
+
handler: experimental_wrapGuardedHandler({
|
|
194
|
+
name: options.name,
|
|
195
|
+
requiresConfirm: options.requiresConfirm,
|
|
196
|
+
queue,
|
|
197
|
+
handler: options.handler
|
|
198
|
+
})
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
export {
|
|
202
|
+
WEBMCP_CONFIRM_INJECTION_KEY,
|
|
203
|
+
WEBMCP_INJECTION_KEY,
|
|
204
|
+
createWebMCPPlugin,
|
|
205
|
+
experimental_provideWebMCPConfirm,
|
|
206
|
+
experimental_useWebMCPBridge,
|
|
207
|
+
experimental_useWebMCPGuardedTool,
|
|
208
|
+
experimental_useWebMCPJourney,
|
|
209
|
+
experimental_useWebMCPSync,
|
|
210
|
+
provideWebMCP,
|
|
211
|
+
useWaitForToolsUntil,
|
|
212
|
+
useWebMCP,
|
|
213
|
+
useWebMCPTool
|
|
214
|
+
};
|
|
215
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {\n getCurrentInstance,\n getCurrentScope,\n inject,\n onScopeDispose,\n provide,\n readonly,\n ref,\n type App,\n type InjectionKey,\n type Plugin,\n type Ref,\n} from \"vue\";\nimport {\n cleanupPolyfill,\n createPageBridgeClient,\n experimental_createConfirmQueue,\n experimental_createJourneyRegistry,\n experimental_createSyncStateController,\n experimental_wrapGuardedHandler,\n installPolyfill,\n isNativeModelContext,\n setJourneyRegistry,\n type ConfirmPrompt,\n type ConfirmQueue,\n type JourneyRegistry,\n type JsonSchema,\n type PageBridgeStatus,\n type ToolAnnotations,\n type ToolExecuteCallback,\n type ToolExecuteCallbackOptions,\n} from \"@thegreataxios/webmcp-core\";\n\nexport interface WebMCPVueContext {\n readonly available: boolean;\n readonly native: boolean;\n readonly appName: string;\n readonly appVersion?: string;\n readonly journeyRegistry: JourneyRegistry;\n destroy(): void;\n}\n\nexport const WEBMCP_INJECTION_KEY: InjectionKey<WebMCPVueContext> = Symbol(\"webmcp-vue-context\");\nexport const WEBMCP_CONFIRM_INJECTION_KEY: InjectionKey<ConfirmQueue> = Symbol(\n \"webmcp-vue-confirm\",\n);\n\nexport interface ProvideWebMCPOptions {\n name: string;\n version?: string;\n}\n\nfunction registerScopeCleanup(fn: () => void): void {\n if (getCurrentScope()) {\n onScopeDispose(fn);\n }\n}\n\n/**\n * Initialize WebMCP inside a Vue component `setup()` or `effectScope()`.\n */\nexport function provideWebMCP(options: ProvideWebMCPOptions): WebMCPVueContext {\n const journeyRegistry = experimental_createJourneyRegistry();\n setJourneyRegistry(journeyRegistry);\n installPolyfill();\n\n let destroyed = false;\n const destroy = () => {\n if (destroyed) return;\n destroyed = true;\n setJourneyRegistry(null);\n cleanupPolyfill();\n };\n\n const ctx: WebMCPVueContext = {\n available: typeof document !== \"undefined\" && document.modelContext != null,\n native: isNativeModelContext(),\n appName: options.name,\n appVersion: options.version,\n journeyRegistry,\n destroy,\n };\n\n if (getCurrentInstance()) {\n provide(WEBMCP_INJECTION_KEY, ctx);\n }\n registerScopeCleanup(destroy);\n return ctx;\n}\n\n/**\n * Vue 3 plugin (`app.use(createWebMCPPlugin({ name: \"my-app\" }))`).\n */\nexport function createWebMCPPlugin(options: ProvideWebMCPOptions): Plugin {\n return {\n install(app: App) {\n const ctx = provideWebMCP(options);\n app.provide(WEBMCP_INJECTION_KEY, ctx);\n const origUnmount = app.unmount.bind(app);\n app.unmount = () => {\n ctx.destroy();\n return origUnmount();\n };\n },\n };\n}\n\nexport function useWebMCP(): WebMCPVueContext | undefined {\n return getCurrentInstance() ? inject(WEBMCP_INJECTION_KEY, undefined) : undefined;\n}\n\nexport interface VueToolOptions {\n name: string;\n description: string;\n title?: string;\n inputSchema?: JsonSchema;\n outputSchema?: JsonSchema;\n annotations?: ToolAnnotations;\n exposedTo?: string[];\n handler: ToolExecuteCallback;\n}\n\n/**\n * Register a WebMCP tool for the lifetime of the current Vue component or `effectScope()`.\n */\nexport function useWebMCPTool(options: VueToolOptions): { dispose: () => void } {\n const controller = new AbortController();\n let disposed = false;\n\n const dispose = () => {\n if (disposed) return;\n disposed = true;\n controller.abort();\n };\n\n if (typeof document !== \"undefined\" && document.modelContext) {\n document.modelContext\n .registerTool(\n {\n name: options.name,\n title: options.title,\n description: options.description,\n inputSchema: options.inputSchema,\n outputSchema: options.outputSchema,\n annotations: options.annotations,\n execute: options.handler,\n },\n { signal: controller.signal, exposedTo: options.exposedTo },\n )\n .catch(() => {});\n }\n\n registerScopeCleanup(dispose);\n return { dispose };\n}\n\n/**\n * Signal async tool registration stability to `document.modelContext.waitForToolsUntil`.\n */\nexport function useWaitForToolsUntil(promise: Promise<unknown>): void {\n if (typeof document !== \"undefined\") {\n document.modelContext?.waitForToolsUntil?.(promise);\n }\n}\n\nexport interface VueSyncTool<TState> {\n description: string;\n title?: string;\n inputSchema?: JsonSchema;\n outputSchema?: JsonSchema;\n annotations?: ToolAnnotations;\n reducer: (\n state: TState,\n args: Record<string, unknown>,\n options?: ToolExecuteCallbackOptions,\n ) => TState | Promise<TState>;\n}\n\n/**\n * Bind a Vue reactive `ref` to one or more WebMCP tools whose reducers update state.\n */\nexport function experimental_useWebMCPSync<TState>(options: {\n initial: TState;\n tools: Record<string, VueSyncTool<TState>>;\n}): {\n state: Readonly<Ref<TState>>;\n set: (next: TState) => void;\n update: (fn: (prev: TState) => TState) => void;\n dispose: () => void;\n} {\n const controller = experimental_createSyncStateController(options.initial);\n const stateRef = ref(controller.getState()) as Ref<TState>;\n const unsub = controller.subscribe((next) => {\n stateRef.value = next;\n });\n\n const handles = Object.entries(options.tools).map(([name, def]) =>\n useWebMCPTool({\n name,\n title: def.title,\n description: def.description,\n inputSchema: def.inputSchema,\n outputSchema: def.outputSchema,\n annotations: def.annotations,\n handler: (args, cbOptions) => controller.enqueueMutation(def.reducer, args, cbOptions),\n }),\n );\n\n const dispose = () => {\n unsub();\n for (const h of handles) h.dispose();\n };\n registerScopeCleanup(dispose);\n\n return {\n state: readonly(stateRef) as Readonly<Ref<TState>>,\n set: controller.setState,\n update: controller.updateState,\n dispose,\n };\n}\n\n/**\n * Register and control a journey from Vue, auto-cleaning up on scope dispose.\n */\nexport function experimental_useWebMCPJourney(options: {\n name: string;\n tools: string[];\n description?: string;\n active?: boolean;\n registry?: JourneyRegistry;\n}): {\n setActive: (active: boolean) => void;\n dispose: () => void;\n} {\n const registry = options.registry ?? useWebMCP()?.journeyRegistry;\n registry?.register({\n name: options.name,\n description: options.description,\n tools: options.tools,\n });\n if (options.active) {\n registry?.setJourneyActive(options.name, true);\n }\n\n const dispose = () => {\n registry?.unregister(options.name);\n };\n registerScopeCleanup(dispose);\n\n return {\n setActive: (active: boolean) => registry?.setJourneyActive(options.name, active),\n dispose,\n };\n}\n\n/**\n * Connect a Vue app to `webmcp-bridge` and expose reactive connection status.\n */\nexport function experimental_useWebMCPBridge(options: {\n url?: string;\n token: string;\n}): {\n status: Readonly<Ref<PageBridgeStatus>>;\n disconnect: () => void;\n} {\n const statusRef = ref<PageBridgeStatus>(\"disconnected\");\n const client = createPageBridgeClient({\n url: options.url ?? \"ws://127.0.0.1:17321/ws\",\n token: options.token,\n onStatusChange: (next) => {\n statusRef.value = next;\n },\n });\n client.connect();\n\n const disconnect = () => client.disconnect();\n registerScopeCleanup(disconnect);\n\n return {\n status: readonly(statusRef),\n disconnect,\n };\n}\n\n/**\n * Create a HITL confirmation queue for Vue components and expose the active prompt as a readonly Ref.\n */\nexport function experimental_provideWebMCPConfirm(): {\n pending: Readonly<Ref<ConfirmPrompt | null>>;\n queue: ConfirmQueue;\n dispose: () => void;\n} {\n const queue = experimental_createConfirmQueue();\n const pendingRef = ref<ConfirmPrompt | null>(queue.getPending());\n const unsub = queue.subscribe((next) => {\n pendingRef.value = next;\n });\n\n const dispose = () => {\n unsub();\n queue.dispose();\n };\n\n if (getCurrentInstance()) {\n provide(WEBMCP_CONFIRM_INJECTION_KEY, queue);\n }\n registerScopeCleanup(dispose);\n\n return {\n pending: readonly(pendingRef) as Readonly<Ref<ConfirmPrompt | null>>,\n queue,\n dispose,\n };\n}\n\nexport interface VueGuardedToolOptions extends VueToolOptions {\n requiresConfirm?: boolean;\n confirmQueue?: ConfirmQueue;\n}\n\n/**\n * Register a WebMCP tool guarded by a HITL confirmation queue (fails closed if none is provided).\n */\nexport function experimental_useWebMCPGuardedTool(\n options: VueGuardedToolOptions,\n): { dispose: () => void } {\n const injected = getCurrentInstance() ? inject(WEBMCP_CONFIRM_INJECTION_KEY, undefined) : undefined;\n const queue = options.confirmQueue ?? injected;\n return useWebMCPTool({\n ...options,\n handler: experimental_wrapGuardedHandler({\n name: options.name,\n requiresConfirm: options.requiresConfirm,\n queue,\n handler: options.handler,\n }),\n });\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAKK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA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AU;AAAA,IAC5B;AAAA,IACA;AAAA,EACF;AACF;AAUO,SAAS,kCACd,SACyB;AACzB,QAAM,WAAW,mBAAmB,IAAI,OAAO,8BAA8B,MAAS,IAAI;AAC1F,QAAM,QAAQ,QAAQ,gBAAgB;AACtC,SAAO,cAAc;AAAA,IACnB,GAAG;AAAA,IACH,SAAS,gCAAgC;AAAA,MACvC,MAAM,QAAQ;AAAA,MACd,iBAAiB,QAAQ;AAAA,MACzB;AAAA,MACA,SAAS,QAAQ;AAAA,IACnB,CAAC;AAAA,EACH,CAAC;AACH;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thegreataxios/webmcp-vue",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "Vue 3 Composition API bindings and plugin for W3C WebMCP",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"LICENSE"
|
|
19
|
+
],
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsup",
|
|
23
|
+
"typecheck": "tsc --noEmit",
|
|
24
|
+
"test": "bun test"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"webmcp",
|
|
28
|
+
"vue",
|
|
29
|
+
"vue3",
|
|
30
|
+
"document.modelContext"
|
|
31
|
+
],
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "https://github.com/TheGreatAxios/webmcp"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"vue": ">=3.3.0"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@thegreataxios/webmcp-core": "0.2.1"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@happy-dom/global-registrator": "^20.0.0",
|
|
48
|
+
"typescript": "^5.9.3",
|
|
49
|
+
"vue": "^3.5.0"
|
|
50
|
+
}
|
|
51
|
+
}
|