@frontmcp/react 0.0.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 +201 -0
- package/README.md +263 -0
- package/ai/createToolHandler.d.ts +10 -0
- package/ai/createToolHandler.d.ts.map +1 -0
- package/ai/index.d.ts +7 -0
- package/ai/index.d.ts.map +1 -0
- package/ai/index.js +416 -0
- package/ai/types.d.ts +52 -0
- package/ai/types.d.ts.map +1 -0
- package/ai/useAITools.d.ts +17 -0
- package/ai/useAITools.d.ts.map +1 -0
- package/ai/useTools.d.ts +19 -0
- package/ai/useTools.d.ts.map +1 -0
- package/api/api.types.d.ts +61 -0
- package/api/api.types.d.ts.map +1 -0
- package/api/createFetchClient.d.ts +9 -0
- package/api/createFetchClient.d.ts.map +1 -0
- package/api/index.d.ts +12 -0
- package/api/index.d.ts.map +1 -0
- package/api/index.js +402 -0
- package/api/parseOpenApiSpec.d.ts +9 -0
- package/api/parseOpenApiSpec.d.ts.map +1 -0
- package/api/useApiClient.d.ts +9 -0
- package/api/useApiClient.d.ts.map +1 -0
- package/components/AgentContent.d.ts +30 -0
- package/components/AgentContent.d.ts.map +1 -0
- package/components/AgentSearch.d.ts +35 -0
- package/components/AgentSearch.d.ts.map +1 -0
- package/components/ComponentRegistry.d.ts +36 -0
- package/components/ComponentRegistry.d.ts.map +1 -0
- package/components/DomResources.d.ts +16 -0
- package/components/DomResources.d.ts.map +1 -0
- package/components/DynamicRenderer.d.ts +19 -0
- package/components/DynamicRenderer.d.ts.map +1 -0
- package/components/OutputDisplay.d.ts +11 -0
- package/components/OutputDisplay.d.ts.map +1 -0
- package/components/PromptForm.d.ts +13 -0
- package/components/PromptForm.d.ts.map +1 -0
- package/components/ResourceViewer.d.ts +18 -0
- package/components/ResourceViewer.d.ts.map +1 -0
- package/components/ToolForm.d.ts +16 -0
- package/components/ToolForm.d.ts.map +1 -0
- package/components/index.d.ts +21 -0
- package/components/index.d.ts.map +1 -0
- package/components/mcpComponent.d.ts +48 -0
- package/components/mcpComponent.d.ts.map +1 -0
- package/esm/ai/index.mjs +393 -0
- package/esm/api/index.mjs +379 -0
- package/esm/index.mjs +1814 -0
- package/esm/package.json +111 -0
- package/esm/router/index.mjs +157 -0
- package/esm/state/index.mjs +450 -0
- package/hooks/index.d.ts +21 -0
- package/hooks/index.d.ts.map +1 -0
- package/hooks/useCallTool.d.ts +9 -0
- package/hooks/useCallTool.d.ts.map +1 -0
- package/hooks/useComponentTree.d.ts +21 -0
- package/hooks/useComponentTree.d.ts.map +1 -0
- package/hooks/useDynamicResource.d.ts +20 -0
- package/hooks/useDynamicResource.d.ts.map +1 -0
- package/hooks/useDynamicTool.d.ts +39 -0
- package/hooks/useDynamicTool.d.ts.map +1 -0
- package/hooks/useFrontMcp.d.ts +8 -0
- package/hooks/useFrontMcp.d.ts.map +1 -0
- package/hooks/useGetPrompt.d.ts +13 -0
- package/hooks/useGetPrompt.d.ts.map +1 -0
- package/hooks/useListPrompts.d.ts +10 -0
- package/hooks/useListPrompts.d.ts.map +1 -0
- package/hooks/useListResources.d.ts +14 -0
- package/hooks/useListResources.d.ts.map +1 -0
- package/hooks/useListTools.d.ts +10 -0
- package/hooks/useListTools.d.ts.map +1 -0
- package/hooks/useReadResource.d.ts +23 -0
- package/hooks/useReadResource.d.ts.map +1 -0
- package/hooks/useResolvedServer.d.ts +16 -0
- package/hooks/useResolvedServer.d.ts.map +1 -0
- package/hooks/useServer.d.ts +17 -0
- package/hooks/useServer.d.ts.map +1 -0
- package/hooks/useStoreResource.d.ts +22 -0
- package/hooks/useStoreResource.d.ts.map +1 -0
- package/index.d.ts +33 -0
- package/index.d.ts.map +1 -0
- package/index.js +1821 -0
- package/package.json +111 -0
- package/provider/FrontMcpContext.d.ts +6 -0
- package/provider/FrontMcpContext.d.ts.map +1 -0
- package/provider/FrontMcpProvider.d.ts +34 -0
- package/provider/FrontMcpProvider.d.ts.map +1 -0
- package/provider/index.d.ts +4 -0
- package/provider/index.d.ts.map +1 -0
- package/registry/DynamicRegistry.d.ts +55 -0
- package/registry/DynamicRegistry.d.ts.map +1 -0
- package/registry/ServerRegistry.d.ts +43 -0
- package/registry/ServerRegistry.d.ts.map +1 -0
- package/registry/createWrappedServer.d.ts +14 -0
- package/registry/createWrappedServer.d.ts.map +1 -0
- package/registry/index.d.ts +5 -0
- package/registry/index.d.ts.map +1 -0
- package/router/current-route.resource.d.ts +11 -0
- package/router/current-route.resource.d.ts.map +1 -0
- package/router/go-back.tool.d.ts +18 -0
- package/router/go-back.tool.d.ts.map +1 -0
- package/router/index.d.ts +9 -0
- package/router/index.d.ts.map +1 -0
- package/router/index.js +180 -0
- package/router/navigate.tool.d.ts +35 -0
- package/router/navigate.tool.d.ts.map +1 -0
- package/router/router-bridge.d.ts +20 -0
- package/router/router-bridge.d.ts.map +1 -0
- package/router/router.entries.d.ts +23 -0
- package/router/router.entries.d.ts.map +1 -0
- package/router/useRouterBridge.d.ts +7 -0
- package/router/useRouterBridge.d.ts.map +1 -0
- package/state/adapters/createStore.d.ts +15 -0
- package/state/adapters/createStore.d.ts.map +1 -0
- package/state/adapters/index.d.ts +7 -0
- package/state/adapters/index.d.ts.map +1 -0
- package/state/adapters/reduxAdapter.d.ts +21 -0
- package/state/adapters/reduxAdapter.d.ts.map +1 -0
- package/state/adapters/valtioAdapter.d.ts +19 -0
- package/state/adapters/valtioAdapter.d.ts.map +1 -0
- package/state/index.d.ts +15 -0
- package/state/index.d.ts.map +1 -0
- package/state/index.js +473 -0
- package/state/state.types.d.ts +48 -0
- package/state/state.types.d.ts.map +1 -0
- package/state/useReduxResource.d.ts +8 -0
- package/state/useReduxResource.d.ts.map +1 -0
- package/state/useStoreRegistration.d.ts +14 -0
- package/state/useStoreRegistration.d.ts.map +1 -0
- package/state/useStoreResource.d.ts +10 -0
- package/state/useStoreResource.d.ts.map +1 -0
- package/state/useValtioResource.d.ts +9 -0
- package/state/useValtioResource.d.ts.map +1 -0
- package/types.d.ts +127 -0
- package/types.d.ts.map +1 -0
- package/utils/index.d.ts +2 -0
- package/utils/index.d.ts.map +1 -0
- package/utils/zodToJsonSchema.d.ts +9 -0
- package/utils/zodToJsonSchema.d.ts.map +1 -0
package/api/index.js
ADDED
|
@@ -0,0 +1,402 @@
|
|
|
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
|
+
// libs/react/src/api/index.ts
|
|
21
|
+
var api_exports = {};
|
|
22
|
+
__export(api_exports, {
|
|
23
|
+
createFetchClient: () => createFetchClient,
|
|
24
|
+
parseOpenApiSpec: () => parseOpenApiSpec,
|
|
25
|
+
useApiClient: () => useApiClient
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(api_exports);
|
|
28
|
+
|
|
29
|
+
// libs/react/src/api/useApiClient.ts
|
|
30
|
+
var import_react2 = require("react");
|
|
31
|
+
|
|
32
|
+
// libs/react/src/provider/FrontMcpContext.ts
|
|
33
|
+
var import_react = require("react");
|
|
34
|
+
|
|
35
|
+
// libs/react/src/components/ComponentRegistry.ts
|
|
36
|
+
var ComponentRegistry = class {
|
|
37
|
+
entries = /* @__PURE__ */ new Map();
|
|
38
|
+
register(uri, component, meta) {
|
|
39
|
+
const name = extractName(uri);
|
|
40
|
+
this.entries.set(uri, { uri, name, component, description: meta?.description });
|
|
41
|
+
}
|
|
42
|
+
registerAll(map) {
|
|
43
|
+
for (const [uri, component] of Object.entries(map)) {
|
|
44
|
+
this.register(uri, component);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
get(uri) {
|
|
48
|
+
return this.entries.get(uri)?.component;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Resolve a shorthand name like `'UserCard'` by trying
|
|
52
|
+
* `component://UserCard`, `element://UserCard`, `page://UserCard`.
|
|
53
|
+
*/
|
|
54
|
+
resolve(type) {
|
|
55
|
+
const exact = this.entries.get(type);
|
|
56
|
+
if (exact) return exact.component;
|
|
57
|
+
for (const protocol of ["component://", "element://", "page://"]) {
|
|
58
|
+
const entry = this.entries.get(`${protocol}${type}`);
|
|
59
|
+
if (entry) return entry.component;
|
|
60
|
+
}
|
|
61
|
+
return void 0;
|
|
62
|
+
}
|
|
63
|
+
has(uri) {
|
|
64
|
+
return this.entries.has(uri);
|
|
65
|
+
}
|
|
66
|
+
list() {
|
|
67
|
+
return Array.from(this.entries.values()).map(({ uri, name, description }) => ({
|
|
68
|
+
uri,
|
|
69
|
+
name,
|
|
70
|
+
description
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
clear() {
|
|
74
|
+
this.entries.clear();
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
function extractName(uri) {
|
|
78
|
+
const idx = uri.indexOf("://");
|
|
79
|
+
return idx >= 0 ? uri.slice(idx + 3) : uri;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// libs/react/src/registry/DynamicRegistry.ts
|
|
83
|
+
var DynamicRegistry = class {
|
|
84
|
+
tools = /* @__PURE__ */ new Map();
|
|
85
|
+
resources = /* @__PURE__ */ new Map();
|
|
86
|
+
toolRefCounts = /* @__PURE__ */ new Map();
|
|
87
|
+
resourceRefCounts = /* @__PURE__ */ new Map();
|
|
88
|
+
listeners = /* @__PURE__ */ new Set();
|
|
89
|
+
version = 0;
|
|
90
|
+
/**
|
|
91
|
+
* Register a dynamic tool. Returns an unregister function
|
|
92
|
+
* suitable for useEffect cleanup.
|
|
93
|
+
*
|
|
94
|
+
* Multiple registrations of the same name are ref-counted:
|
|
95
|
+
* subsequent registrations update the definition but the tool
|
|
96
|
+
* is only removed when every registrant has unregistered.
|
|
97
|
+
*/
|
|
98
|
+
registerTool(def) {
|
|
99
|
+
const existing = this.toolRefCounts.get(def.name) ?? 0;
|
|
100
|
+
this.toolRefCounts.set(def.name, existing + 1);
|
|
101
|
+
this.tools.set(def.name, def);
|
|
102
|
+
if (existing === 0) {
|
|
103
|
+
this.notify();
|
|
104
|
+
}
|
|
105
|
+
let called = false;
|
|
106
|
+
return () => {
|
|
107
|
+
if (called) return;
|
|
108
|
+
called = true;
|
|
109
|
+
this.unregisterTool(def.name);
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
unregisterTool(name) {
|
|
113
|
+
const count = this.toolRefCounts.get(name);
|
|
114
|
+
if (count == null) return;
|
|
115
|
+
if (count <= 1) {
|
|
116
|
+
this.toolRefCounts.delete(name);
|
|
117
|
+
this.tools.delete(name);
|
|
118
|
+
this.notify();
|
|
119
|
+
} else {
|
|
120
|
+
this.toolRefCounts.set(name, count - 1);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Register a dynamic resource. Returns an unregister function
|
|
125
|
+
* suitable for useEffect cleanup.
|
|
126
|
+
*
|
|
127
|
+
* Multiple registrations of the same URI are ref-counted.
|
|
128
|
+
*/
|
|
129
|
+
registerResource(def) {
|
|
130
|
+
const existing = this.resourceRefCounts.get(def.uri) ?? 0;
|
|
131
|
+
this.resourceRefCounts.set(def.uri, existing + 1);
|
|
132
|
+
this.resources.set(def.uri, def);
|
|
133
|
+
if (existing === 0) {
|
|
134
|
+
this.notify();
|
|
135
|
+
}
|
|
136
|
+
let called = false;
|
|
137
|
+
return () => {
|
|
138
|
+
if (called) return;
|
|
139
|
+
called = true;
|
|
140
|
+
this.unregisterResource(def.uri);
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
unregisterResource(uri) {
|
|
144
|
+
const count = this.resourceRefCounts.get(uri);
|
|
145
|
+
if (count == null) return;
|
|
146
|
+
if (count <= 1) {
|
|
147
|
+
this.resourceRefCounts.delete(uri);
|
|
148
|
+
this.resources.delete(uri);
|
|
149
|
+
this.notify();
|
|
150
|
+
} else {
|
|
151
|
+
this.resourceRefCounts.set(uri, count - 1);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/** Update the execute function for an existing tool (for stale closure prevention). */
|
|
155
|
+
updateToolExecute(name, execute) {
|
|
156
|
+
const existing = this.tools.get(name);
|
|
157
|
+
if (existing) {
|
|
158
|
+
existing.execute = execute;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/** Update the read function for an existing resource and notify subscribers. */
|
|
162
|
+
updateResourceRead(uri, read) {
|
|
163
|
+
const existing = this.resources.get(uri);
|
|
164
|
+
if (existing) {
|
|
165
|
+
existing.read = read;
|
|
166
|
+
this.notify();
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
getTools() {
|
|
170
|
+
return [...this.tools.values()];
|
|
171
|
+
}
|
|
172
|
+
getResources() {
|
|
173
|
+
return [...this.resources.values()];
|
|
174
|
+
}
|
|
175
|
+
findTool(name) {
|
|
176
|
+
return this.tools.get(name);
|
|
177
|
+
}
|
|
178
|
+
findResource(uri) {
|
|
179
|
+
return this.resources.get(uri);
|
|
180
|
+
}
|
|
181
|
+
hasTool(name) {
|
|
182
|
+
return this.tools.has(name);
|
|
183
|
+
}
|
|
184
|
+
hasResource(uri) {
|
|
185
|
+
return this.resources.has(uri);
|
|
186
|
+
}
|
|
187
|
+
subscribe(listener) {
|
|
188
|
+
this.listeners.add(listener);
|
|
189
|
+
return () => {
|
|
190
|
+
this.listeners.delete(listener);
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
getVersion() {
|
|
194
|
+
return this.version;
|
|
195
|
+
}
|
|
196
|
+
clear() {
|
|
197
|
+
if (this.tools.size === 0 && this.resources.size === 0) return;
|
|
198
|
+
this.tools.clear();
|
|
199
|
+
this.resources.clear();
|
|
200
|
+
this.toolRefCounts.clear();
|
|
201
|
+
this.resourceRefCounts.clear();
|
|
202
|
+
this.notify();
|
|
203
|
+
}
|
|
204
|
+
notify() {
|
|
205
|
+
this.version++;
|
|
206
|
+
this.listeners.forEach((l) => {
|
|
207
|
+
l();
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
// libs/react/src/provider/FrontMcpContext.ts
|
|
213
|
+
var defaultDynamicRegistry = new DynamicRegistry();
|
|
214
|
+
var FrontMcpContext = (0, import_react.createContext)({
|
|
215
|
+
name: "default",
|
|
216
|
+
registry: new ComponentRegistry(),
|
|
217
|
+
dynamicRegistry: defaultDynamicRegistry,
|
|
218
|
+
getDynamicRegistry: () => defaultDynamicRegistry,
|
|
219
|
+
connect: async () => {
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
// libs/react/src/api/createFetchClient.ts
|
|
224
|
+
function createFetchClient(fetchFn) {
|
|
225
|
+
const fn = fetchFn ?? globalThis.fetch.bind(globalThis);
|
|
226
|
+
return {
|
|
227
|
+
async request(config) {
|
|
228
|
+
const fetchOptions = {
|
|
229
|
+
method: config.method,
|
|
230
|
+
headers: config.headers
|
|
231
|
+
};
|
|
232
|
+
if (config.body !== void 0) {
|
|
233
|
+
fetchOptions.body = JSON.stringify(config.body);
|
|
234
|
+
const headers = fetchOptions.headers;
|
|
235
|
+
if (headers && !headers["Content-Type"] && !headers["content-type"]) {
|
|
236
|
+
headers["Content-Type"] = "application/json";
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
const response = await fn(config.url, fetchOptions);
|
|
240
|
+
const responseText = await response.text();
|
|
241
|
+
let data;
|
|
242
|
+
try {
|
|
243
|
+
data = JSON.parse(responseText);
|
|
244
|
+
} catch {
|
|
245
|
+
data = responseText;
|
|
246
|
+
}
|
|
247
|
+
return {
|
|
248
|
+
status: response.status,
|
|
249
|
+
statusText: response.statusText,
|
|
250
|
+
data
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// libs/react/src/api/useApiClient.ts
|
|
257
|
+
function interpolatePath(path, params) {
|
|
258
|
+
return path.replace(/\{(\w+)\}/g, (_, key) => {
|
|
259
|
+
const value = params[key];
|
|
260
|
+
return value != null ? encodeURIComponent(String(value)) : `{${key}}`;
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
function useApiClient(options) {
|
|
264
|
+
const { baseUrl, operations, headers, prefix = "api", client, fetch: customFetch } = options;
|
|
265
|
+
const { getDynamicRegistry } = (0, import_react2.useContext)(FrontMcpContext);
|
|
266
|
+
const dynamicRegistry = getDynamicRegistry(options.server);
|
|
267
|
+
const headersRef = (0, import_react2.useRef)(headers);
|
|
268
|
+
headersRef.current = headers;
|
|
269
|
+
const clientRef = (0, import_react2.useRef)(client ?? createFetchClient(customFetch));
|
|
270
|
+
clientRef.current = client ?? createFetchClient(customFetch);
|
|
271
|
+
(0, import_react2.useEffect)(() => {
|
|
272
|
+
const cleanups = [];
|
|
273
|
+
for (const op of operations) {
|
|
274
|
+
const toolName = `${prefix}_${op.operationId}`;
|
|
275
|
+
const execute = async (args) => {
|
|
276
|
+
const resolvedHeaders = {
|
|
277
|
+
"Content-Type": "application/json",
|
|
278
|
+
...typeof headersRef.current === "function" ? headersRef.current() : headersRef.current ?? {}
|
|
279
|
+
};
|
|
280
|
+
const url = baseUrl + interpolatePath(op.path, args);
|
|
281
|
+
const body = args["body"];
|
|
282
|
+
const method = op.method;
|
|
283
|
+
const requestConfig = {
|
|
284
|
+
method,
|
|
285
|
+
url,
|
|
286
|
+
headers: resolvedHeaders
|
|
287
|
+
};
|
|
288
|
+
if (body !== void 0 && method !== "GET" && method !== "HEAD") {
|
|
289
|
+
requestConfig.body = body;
|
|
290
|
+
}
|
|
291
|
+
const response = await clientRef.current.request(requestConfig);
|
|
292
|
+
return {
|
|
293
|
+
content: [
|
|
294
|
+
{
|
|
295
|
+
type: "text",
|
|
296
|
+
text: JSON.stringify({
|
|
297
|
+
status: response.status,
|
|
298
|
+
statusText: response.statusText,
|
|
299
|
+
data: response.data
|
|
300
|
+
})
|
|
301
|
+
}
|
|
302
|
+
],
|
|
303
|
+
isError: response.status >= 400
|
|
304
|
+
};
|
|
305
|
+
};
|
|
306
|
+
cleanups.push(
|
|
307
|
+
dynamicRegistry.registerTool({
|
|
308
|
+
name: toolName,
|
|
309
|
+
description: op.description,
|
|
310
|
+
inputSchema: op.inputSchema,
|
|
311
|
+
execute
|
|
312
|
+
})
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
return () => {
|
|
316
|
+
cleanups.forEach((fn) => {
|
|
317
|
+
fn();
|
|
318
|
+
});
|
|
319
|
+
};
|
|
320
|
+
}, [dynamicRegistry, baseUrl, operations, prefix, client, customFetch]);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// libs/react/src/api/parseOpenApiSpec.ts
|
|
324
|
+
var HTTP_METHODS = ["get", "post", "put", "delete", "patch", "options", "head"];
|
|
325
|
+
function parseOpenApiSpec(spec) {
|
|
326
|
+
const paths = spec["paths"];
|
|
327
|
+
if (!paths) return [];
|
|
328
|
+
const operations = [];
|
|
329
|
+
const usedIds = /* @__PURE__ */ new Set();
|
|
330
|
+
for (const [path, pathItem] of Object.entries(paths)) {
|
|
331
|
+
if (!pathItem || typeof pathItem !== "object") continue;
|
|
332
|
+
for (const method of HTTP_METHODS) {
|
|
333
|
+
const operation = pathItem[method];
|
|
334
|
+
if (!operation || typeof operation !== "object") continue;
|
|
335
|
+
const rawOperationId = operation["operationId"];
|
|
336
|
+
let operationId = typeof rawOperationId === "string" ? rawOperationId : `${method}_${path.replace(/[^a-zA-Z0-9]/g, "_")}`;
|
|
337
|
+
if (usedIds.has(operationId)) {
|
|
338
|
+
let suffix = 1;
|
|
339
|
+
while (usedIds.has(`${operationId}_${suffix}`)) suffix++;
|
|
340
|
+
operationId = `${operationId}_${suffix}`;
|
|
341
|
+
}
|
|
342
|
+
usedIds.add(operationId);
|
|
343
|
+
const rawSummary = operation["summary"];
|
|
344
|
+
const rawDescription = operation["description"];
|
|
345
|
+
const description = (typeof rawSummary === "string" ? rawSummary : void 0) ?? (typeof rawDescription === "string" ? rawDescription : void 0) ?? `${method.toUpperCase()} ${path}`;
|
|
346
|
+
const properties = /* @__PURE__ */ Object.create(null);
|
|
347
|
+
const required = [];
|
|
348
|
+
const rawPathParams = pathItem["parameters"];
|
|
349
|
+
const rawOpParams = operation["parameters"];
|
|
350
|
+
const pathParams = Array.isArray(rawPathParams) ? rawPathParams.filter(Boolean) : [];
|
|
351
|
+
const opParams = Array.isArray(rawOpParams) ? rawOpParams.filter(Boolean) : [];
|
|
352
|
+
const paramMap = /* @__PURE__ */ new Map();
|
|
353
|
+
for (const param of pathParams) {
|
|
354
|
+
if (typeof param === "object" && param !== null && param.name) {
|
|
355
|
+
paramMap.set(`${param.in}:${param.name}`, param);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
for (const param of opParams) {
|
|
359
|
+
if (typeof param === "object" && param !== null && param.name) {
|
|
360
|
+
paramMap.set(`${param.in}:${param.name}`, param);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
const propertyLocations = /* @__PURE__ */ new Map();
|
|
364
|
+
for (const param of paramMap.values()) {
|
|
365
|
+
if (param.name === "__proto__" || param.name === "constructor" || param.name === "prototype") continue;
|
|
366
|
+
const existingIn = propertyLocations.get(param.name);
|
|
367
|
+
if (existingIn && existingIn !== param.in) {
|
|
368
|
+
throw new Error(
|
|
369
|
+
`Parameter "${param.name}" appears in both "${existingIn}" and "${param.in}" \u2014 ambiguous mapping`
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
propertyLocations.set(param.name, param.in);
|
|
373
|
+
properties[param.name] = {
|
|
374
|
+
...param.schema ?? { type: "string" },
|
|
375
|
+
description: param.description
|
|
376
|
+
};
|
|
377
|
+
if (param.required) required.push(param.name);
|
|
378
|
+
}
|
|
379
|
+
const requestBody = operation["requestBody"];
|
|
380
|
+
if (requestBody) {
|
|
381
|
+
const content = requestBody["content"];
|
|
382
|
+
const jsonContent = content?.["application/json"];
|
|
383
|
+
if (jsonContent?.["schema"]) {
|
|
384
|
+
properties["body"] = {
|
|
385
|
+
...jsonContent["schema"],
|
|
386
|
+
description: "Request body"
|
|
387
|
+
};
|
|
388
|
+
if (requestBody["required"]) required.push("body");
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
const inputSchema = {
|
|
392
|
+
type: "object",
|
|
393
|
+
properties
|
|
394
|
+
};
|
|
395
|
+
if (required.length > 0) {
|
|
396
|
+
inputSchema["required"] = required;
|
|
397
|
+
}
|
|
398
|
+
operations.push({ operationId, description, method: method.toUpperCase(), path, inputSchema });
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
return operations;
|
|
402
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* parseOpenApiSpec — extracts ApiOperation[] from an OpenAPI 3.x JSON spec.
|
|
3
|
+
*
|
|
4
|
+
* Lightweight parser that pulls operationId, method, path, description,
|
|
5
|
+
* and builds a JSON Schema for the input from parameters and requestBody.
|
|
6
|
+
*/
|
|
7
|
+
import type { ApiOperation } from './api.types';
|
|
8
|
+
export declare function parseOpenApiSpec(spec: Record<string, unknown>): ApiOperation[];
|
|
9
|
+
//# sourceMappingURL=parseOpenApiSpec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseOpenApiSpec.d.ts","sourceRoot":"","sources":["../../src/api/parseOpenApiSpec.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAYhD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,YAAY,EAAE,CAmG9E"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useApiClient — registers OpenAPI operations as MCP tools.
|
|
3
|
+
*
|
|
4
|
+
* Each operation becomes a dynamic tool that makes an HTTP request
|
|
5
|
+
* using an injected HttpClient, a custom fetch, or globalThis.fetch.
|
|
6
|
+
*/
|
|
7
|
+
import type { ApiClientOptions } from './api.types';
|
|
8
|
+
export declare function useApiClient(options: ApiClientOptions): void;
|
|
9
|
+
//# sourceMappingURL=useApiClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useApiClient.d.ts","sourceRoot":"","sources":["../../src/api/useApiClient.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,gBAAgB,EAAiC,MAAM,aAAa,CAAC;AAUnF,wBAAgB,YAAY,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAuE5D"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentContent — a component that registers itself as an MCP tool.
|
|
3
|
+
*
|
|
4
|
+
* When an agent calls the tool, the component stores the args and
|
|
5
|
+
* renders them via the `render` prop. Before the first invocation
|
|
6
|
+
* it shows the `fallback`.
|
|
7
|
+
*
|
|
8
|
+
* @deprecated Use `mcpComponent()` instead for type-safe schemas and
|
|
9
|
+
* a cleaner component-wrapping API.
|
|
10
|
+
*/
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import type { ReactNode } from 'react';
|
|
13
|
+
/** @deprecated Use `mcpComponent()` instead. */
|
|
14
|
+
export interface AgentContentProps {
|
|
15
|
+
/** MCP tool name that agents will call to push data. */
|
|
16
|
+
name: string;
|
|
17
|
+
/** Tool description for agents. */
|
|
18
|
+
description: string;
|
|
19
|
+
/** JSON Schema for the tool's input. */
|
|
20
|
+
inputSchema?: Record<string, unknown>;
|
|
21
|
+
/** Render function — receives the args the agent sent. */
|
|
22
|
+
render: (data: Record<string, unknown>) => ReactNode;
|
|
23
|
+
/** Shown before the agent's first invocation. */
|
|
24
|
+
fallback?: ReactNode;
|
|
25
|
+
/** Target a specific named server. */
|
|
26
|
+
server?: string;
|
|
27
|
+
}
|
|
28
|
+
/** @deprecated Use `mcpComponent()` instead. */
|
|
29
|
+
export declare function AgentContent({ name, description, inputSchema, render, fallback, server, }: AgentContentProps): React.ReactElement;
|
|
30
|
+
//# sourceMappingURL=AgentContent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentContent.d.ts","sourceRoot":"","sources":["../../src/components/AgentContent.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAgC,MAAM,OAAO,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC,gDAAgD;AAChD,MAAM,WAAW,iBAAiB;IAChC,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,mCAAmC;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,wCAAwC;IACxC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,0DAA0D;IAC1D,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,SAAS,CAAC;IACrD,iDAAiD;IACjD,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,gDAAgD;AAChD,wBAAgB,YAAY,CAAC,EAC3B,IAAI,EACJ,WAAW,EACX,WAAgC,EAChC,MAAM,EACN,QAAe,EACf,MAAM,GACP,EAAE,iBAAiB,GAAG,KAAK,CAAC,YAAY,CAgBxC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentSearch — a headless search component powered by an MCP tool.
|
|
3
|
+
*
|
|
4
|
+
* Registers a tool that agents call to execute search queries.
|
|
5
|
+
* Also exposes the current search input value as a dynamic resource
|
|
6
|
+
* so agents can see what the user typed.
|
|
7
|
+
*
|
|
8
|
+
* @deprecated Use `mcpComponent()` with `columns` option for table-based
|
|
9
|
+
* search result rendering.
|
|
10
|
+
*/
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import type { ReactNode } from 'react';
|
|
13
|
+
export interface SearchInputRenderProps {
|
|
14
|
+
value: string;
|
|
15
|
+
onChange: (value: string) => void;
|
|
16
|
+
placeholder?: string;
|
|
17
|
+
}
|
|
18
|
+
/** @deprecated Use `mcpComponent()` with `columns` option instead. */
|
|
19
|
+
export interface AgentSearchProps {
|
|
20
|
+
/** MCP tool name agents call to execute searches. */
|
|
21
|
+
toolName: string;
|
|
22
|
+
/** Tool description for agents. */
|
|
23
|
+
description: string;
|
|
24
|
+
/** Input placeholder text. */
|
|
25
|
+
placeholder?: string;
|
|
26
|
+
/** Called with search results when the agent responds. */
|
|
27
|
+
onResults: (results: unknown) => void;
|
|
28
|
+
/** Custom input renderer (headless pattern). Falls back to a plain <input>. */
|
|
29
|
+
renderInput?: (props: SearchInputRenderProps) => ReactNode;
|
|
30
|
+
/** Target a specific named server. */
|
|
31
|
+
server?: string;
|
|
32
|
+
}
|
|
33
|
+
/** @deprecated Use `mcpComponent()` with `columns` option instead. */
|
|
34
|
+
export declare function AgentSearch({ toolName, description, placeholder, onResults, renderInput, server, }: AgentSearchProps): React.ReactElement;
|
|
35
|
+
//# sourceMappingURL=AgentSearch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentSearch.d.ts","sourceRoot":"","sources":["../../src/components/AgentSearch.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAgC,MAAM,OAAO,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKvC,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,sEAAsE;AACtE,MAAM,WAAW,gBAAgB;IAC/B,qDAAqD;IACrD,QAAQ,EAAE,MAAM,CAAC;IACjB,mCAAmC;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,8BAA8B;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0DAA0D;IAC1D,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,+EAA+E;IAC/E,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,SAAS,CAAC;IAC3D,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,sEAAsE;AACtE,wBAAgB,WAAW,CAAC,EAC1B,QAAQ,EACR,WAAW,EACX,WAAW,EACX,SAAS,EACT,WAAW,EACX,MAAM,GACP,EAAE,gBAAgB,GAAG,KAAK,CAAC,YAAY,CA4DvC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ComponentRegistry — maps URI protocols to React components.
|
|
3
|
+
*
|
|
4
|
+
* Supported URI protocols:
|
|
5
|
+
* - `component://` — custom React components
|
|
6
|
+
* - `element://` — reusable UI elements
|
|
7
|
+
* - `page://` — full page components
|
|
8
|
+
*/
|
|
9
|
+
import type { ComponentType } from 'react';
|
|
10
|
+
export interface ComponentRegistryEntry {
|
|
11
|
+
uri: string;
|
|
12
|
+
name: string;
|
|
13
|
+
component: ComponentType<Record<string, unknown>>;
|
|
14
|
+
description?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare class ComponentRegistry {
|
|
17
|
+
private readonly entries;
|
|
18
|
+
register(uri: string, component: ComponentType<Record<string, unknown>>, meta?: {
|
|
19
|
+
description?: string;
|
|
20
|
+
}): void;
|
|
21
|
+
registerAll(map: Record<string, ComponentType<Record<string, unknown>>>): void;
|
|
22
|
+
get(uri: string): ComponentType<Record<string, unknown>> | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Resolve a shorthand name like `'UserCard'` by trying
|
|
25
|
+
* `component://UserCard`, `element://UserCard`, `page://UserCard`.
|
|
26
|
+
*/
|
|
27
|
+
resolve(type: string): ComponentType<Record<string, unknown>> | undefined;
|
|
28
|
+
has(uri: string): boolean;
|
|
29
|
+
list(): Array<{
|
|
30
|
+
uri: string;
|
|
31
|
+
name: string;
|
|
32
|
+
description?: string;
|
|
33
|
+
}>;
|
|
34
|
+
clear(): void;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=ComponentRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComponentRegistry.d.ts","sourceRoot":"","sources":["../../src/components/ComponentRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,MAAM,WAAW,sBAAsB;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAClD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6C;IAErE,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAK/G,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI;IAM9E,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS;IAIpE;;;OAGG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS;IAczE,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIzB,IAAI,IAAI,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAQlE,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in DOM resource templates.
|
|
3
|
+
*
|
|
4
|
+
* Provides `dom://byId/{id}` and `dom://selector/{selector}` that read
|
|
5
|
+
* DOM elements and return their outerHTML + text content.
|
|
6
|
+
*/
|
|
7
|
+
export interface DomResourceResult {
|
|
8
|
+
contents: Array<{
|
|
9
|
+
uri: string;
|
|
10
|
+
mimeType: string;
|
|
11
|
+
text: string;
|
|
12
|
+
}>;
|
|
13
|
+
}
|
|
14
|
+
export declare function readDomById(id: string): DomResourceResult;
|
|
15
|
+
export declare function readDomBySelector(selector: string): DomResourceResult;
|
|
16
|
+
//# sourceMappingURL=DomResources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DomResources.d.ts","sourceRoot":"","sources":["../../src/components/DomResources.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,KAAK,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;QACZ,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC,CAAC;CACJ;AAED,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,iBAAiB,CAuCzD;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB,CAuDrE"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DynamicRenderer — recursively renders a ComponentNode tree into React elements.
|
|
3
|
+
*
|
|
4
|
+
* Resolution order for `type`:
|
|
5
|
+
* 1. Exact URI match in registry
|
|
6
|
+
* 2. `component://{type}` in registry
|
|
7
|
+
* 3. `element://{type}` in registry
|
|
8
|
+
* 4. Fallback `<div>`
|
|
9
|
+
*/
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import type { ComponentNode } from '../types';
|
|
12
|
+
import type { ComponentRegistry } from './ComponentRegistry';
|
|
13
|
+
export interface DynamicRendererProps {
|
|
14
|
+
tree: ComponentNode;
|
|
15
|
+
registry: ComponentRegistry;
|
|
16
|
+
fallback?: React.ComponentType<Record<string, unknown>>;
|
|
17
|
+
}
|
|
18
|
+
export declare function DynamicRenderer({ tree, registry, fallback }: DynamicRendererProps): React.ReactElement;
|
|
19
|
+
//# sourceMappingURL=DynamicRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DynamicRenderer.d.ts","sourceRoot":"","sources":["../../src/components/DynamicRenderer.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,aAAa,CAAC;IACpB,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,QAAQ,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACzD;AAED,wBAAgB,eAAe,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,oBAAoB,GAAG,KAAK,CAAC,YAAY,CAEtG"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OutputDisplay — renders JSON or text output from tool/prompt calls.
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react';
|
|
5
|
+
export interface OutputDisplayProps {
|
|
6
|
+
data: unknown;
|
|
7
|
+
loading?: boolean;
|
|
8
|
+
error?: Error | null;
|
|
9
|
+
}
|
|
10
|
+
export declare function OutputDisplay({ data, loading, error }: OutputDisplayProps): React.ReactElement;
|
|
11
|
+
//# sourceMappingURL=OutputDisplay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OutputDisplay.d.ts","sourceRoot":"","sources":["../../src/components/OutputDisplay.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;CACtB;AAED,wBAAgB,aAAa,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,kBAAkB,GAAG,KAAK,CAAC,YAAY,CAiC9F"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PromptForm — headless form generator from prompt.arguments.
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import type { PromptInfo, FieldRenderProps } from '../types';
|
|
6
|
+
export interface PromptFormProps {
|
|
7
|
+
prompt: PromptInfo;
|
|
8
|
+
onSubmit: (args: Record<string, string>) => void;
|
|
9
|
+
renderField?: (props: FieldRenderProps) => React.ReactNode;
|
|
10
|
+
submitLabel?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function PromptForm({ prompt, onSubmit, renderField, submitLabel, }: PromptFormProps): React.ReactElement;
|
|
13
|
+
//# sourceMappingURL=PromptForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PromptForm.d.ts","sourceRoot":"","sources":["../../src/components/PromptForm.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAgC,MAAM,OAAO,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE7D,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;IACjD,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,KAAK,CAAC,SAAS,CAAC;IAC3D,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,UAAU,CAAC,EACzB,MAAM,EACN,QAAQ,EACR,WAAW,EACX,WAA0B,GAC3B,EAAE,eAAe,GAAG,KAAK,CAAC,YAAY,CA+DtC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ResourceViewer — displays a ReadResourceResult.
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react';
|
|
5
|
+
export interface ResourceContent {
|
|
6
|
+
uri: string;
|
|
7
|
+
mimeType?: string;
|
|
8
|
+
text?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ResourceViewerProps {
|
|
11
|
+
data: {
|
|
12
|
+
contents?: ResourceContent[];
|
|
13
|
+
} | null;
|
|
14
|
+
loading?: boolean;
|
|
15
|
+
error?: Error | null;
|
|
16
|
+
}
|
|
17
|
+
export declare function ResourceViewer({ data, loading, error }: ResourceViewerProps): React.ReactElement;
|
|
18
|
+
//# sourceMappingURL=ResourceViewer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResourceViewer.d.ts","sourceRoot":"","sources":["../../src/components/ResourceViewer.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE;QAAE,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAA;KAAE,GAAG,IAAI,CAAC;IAC9C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;CACtB;AAED,wBAAgB,cAAc,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,mBAAmB,GAAG,KAAK,CAAC,YAAY,CA+BhG"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ToolForm — headless form generator from tool.inputSchema.
|
|
3
|
+
*
|
|
4
|
+
* If `renderField` is provided, delegates rendering to the consumer.
|
|
5
|
+
* Otherwise uses basic unstyled `<input>` / `<select>` / `<textarea>`.
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import type { ToolInfo, FieldRenderProps } from '../types';
|
|
9
|
+
export interface ToolFormProps {
|
|
10
|
+
tool: ToolInfo;
|
|
11
|
+
onSubmit: (args: Record<string, unknown>) => void;
|
|
12
|
+
renderField?: (props: FieldRenderProps) => React.ReactNode;
|
|
13
|
+
submitLabel?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function ToolForm({ tool, onSubmit, renderField, submitLabel, }: ToolFormProps): React.ReactElement;
|
|
16
|
+
//# sourceMappingURL=ToolForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolForm.d.ts","sourceRoot":"","sources":["../../src/components/ToolForm.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAgC,MAAM,OAAO,CAAC;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE3D,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IAClD,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,KAAK,CAAC,SAAS,CAAC;IAC3D,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,QAAQ,CAAC,EACvB,IAAI,EACJ,QAAQ,EACR,WAAW,EACX,WAAyB,GAC1B,EAAE,aAAa,GAAG,KAAK,CAAC,YAAY,CAsFpC"}
|