@botdojo/chat-sdk 0.0.28 → 0.0.29
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/lib/index.d.ts +898 -44
- package/lib/index.js +480 -851
- package/lib/index.js.map +1 -1
- package/lib/mcp-app-view/host.js.map +1 -1
- package/lib/mcp-app-view/index.js +1 -1
- package/lib/mcp-app-view/index.js.map +1 -1
- package/lib/mcp-app-view/react.js +52 -25
- package/lib/mcp-app-view/react.js.map +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -8,12 +8,6 @@ var require = (id) => {
|
|
|
8
8
|
if (id === 'react-dom') return __ReactDOM;
|
|
9
9
|
throw new Error('Dynamic require not supported: ' + id);
|
|
10
10
|
};
|
|
11
|
-
var __create = Object.create;
|
|
12
|
-
var __defProp = Object.defineProperty;
|
|
13
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
14
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
15
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
16
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
17
11
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
18
12
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
19
13
|
}) : x)(function(x) {
|
|
@@ -21,748 +15,344 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
21
15
|
return require.apply(this, arguments);
|
|
22
16
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
23
17
|
});
|
|
24
|
-
var __commonJS = (cb, mod) => function __require3() {
|
|
25
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
26
|
-
};
|
|
27
|
-
var __copyProps = (to, from, except, desc) => {
|
|
28
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
29
|
-
for (let key of __getOwnPropNames(from))
|
|
30
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
31
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
32
|
-
}
|
|
33
|
-
return to;
|
|
34
|
-
};
|
|
35
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
36
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
37
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
38
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
39
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
40
|
-
__defProp(target, "default", { value: mod, enumerable: true }) ,
|
|
41
|
-
mod
|
|
42
|
-
));
|
|
43
18
|
|
|
44
|
-
//
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
resource.allowExternal = options.allowExternal;
|
|
81
|
-
}
|
|
82
|
-
if ((options == null ? void 0 : options.initialData) || (options == null ? void 0 : options.frameSize) || (options == null ? void 0 : options.uiMeta)) {
|
|
83
|
-
resource.meta = {
|
|
84
|
-
ui: {
|
|
85
|
-
...options.uiMeta || {},
|
|
86
|
-
...options.frameSize ? { preferredFrameSize: options.frameSize } : {},
|
|
87
|
-
...options.initialData ? { initialRenderData: options.initialData } : {}
|
|
88
|
-
}
|
|
89
|
-
};
|
|
19
|
+
// src/generated/sdk-types-snapshot.ts
|
|
20
|
+
function tool(definition) {
|
|
21
|
+
return definition;
|
|
22
|
+
}
|
|
23
|
+
function textResult(text) {
|
|
24
|
+
return { type: "text", text };
|
|
25
|
+
}
|
|
26
|
+
function imageResult(data, mimeType = "image/png") {
|
|
27
|
+
return { type: "image", data, mimeType };
|
|
28
|
+
}
|
|
29
|
+
function uiResource(uri, options) {
|
|
30
|
+
const resource = {
|
|
31
|
+
uri,
|
|
32
|
+
mimeType: (options == null ? void 0 : options.mimeType) || (uri.startsWith("ui://") ? MIME_TYPES.HTML_MCP_PROFILE : MIME_TYPES.URI_LIST)
|
|
33
|
+
};
|
|
34
|
+
if (options == null ? void 0 : options.html) {
|
|
35
|
+
resource.html = options.html;
|
|
36
|
+
}
|
|
37
|
+
if (options == null ? void 0 : options.urlList) {
|
|
38
|
+
resource.urlList = options.urlList;
|
|
39
|
+
}
|
|
40
|
+
if (options == null ? void 0 : options.baseUrl) {
|
|
41
|
+
resource.baseUrl = options.baseUrl;
|
|
42
|
+
}
|
|
43
|
+
if ((options == null ? void 0 : options.prefersProxy) !== void 0) {
|
|
44
|
+
resource.prefersProxy = options.prefersProxy;
|
|
45
|
+
}
|
|
46
|
+
if ((options == null ? void 0 : options.allowExternal) !== void 0) {
|
|
47
|
+
resource.allowExternal = options.allowExternal;
|
|
48
|
+
}
|
|
49
|
+
if ((options == null ? void 0 : options.initialData) || (options == null ? void 0 : options.frameSize) || (options == null ? void 0 : options.uiMeta)) {
|
|
50
|
+
resource.meta = {
|
|
51
|
+
ui: {
|
|
52
|
+
...options.uiMeta || {},
|
|
53
|
+
...options.frameSize ? { preferredFrameSize: options.frameSize } : {},
|
|
54
|
+
...options.initialData ? { initialRenderData: options.initialData } : {}
|
|
90
55
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
exports.mcpResource = mcpResource2;
|
|
106
|
-
function citation2(data) {
|
|
107
|
-
return {
|
|
108
|
-
type: "resource",
|
|
109
|
-
resource: {
|
|
110
|
-
uri: `citation://${data.id}`,
|
|
111
|
-
mimeType: index_1.MIME_TYPES.CITATION,
|
|
112
|
-
text: JSON.stringify(data)
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
exports.citation = citation2;
|
|
117
|
-
function citations2(data) {
|
|
118
|
-
return {
|
|
119
|
-
type: "resource",
|
|
120
|
-
resource: {
|
|
121
|
-
uri: "citations://batch",
|
|
122
|
-
mimeType: index_1.MIME_TYPES.CITATIONS,
|
|
123
|
-
text: JSON.stringify(data)
|
|
124
|
-
}
|
|
125
|
-
};
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return { type: "resource", resource };
|
|
59
|
+
}
|
|
60
|
+
function mcpResource(uri) {
|
|
61
|
+
return {
|
|
62
|
+
type: "resource",
|
|
63
|
+
resource: {
|
|
64
|
+
uri,
|
|
65
|
+
mimeType: MIME_TYPES.MODEL_CONTEXT,
|
|
66
|
+
text: uri
|
|
67
|
+
// URI points to resource handler
|
|
126
68
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function citation(data) {
|
|
72
|
+
return {
|
|
73
|
+
type: "resource",
|
|
74
|
+
resource: {
|
|
75
|
+
uri: `citation://${data.id}`,
|
|
76
|
+
mimeType: MIME_TYPES.CITATION,
|
|
77
|
+
text: JSON.stringify(data)
|
|
130
78
|
}
|
|
131
|
-
|
|
132
|
-
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function citations(data) {
|
|
82
|
+
return {
|
|
83
|
+
type: "resource",
|
|
84
|
+
resource: {
|
|
85
|
+
uri: "citations://batch",
|
|
86
|
+
mimeType: MIME_TYPES.CITATIONS,
|
|
87
|
+
text: JSON.stringify(data)
|
|
133
88
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const baseTool = {
|
|
152
|
-
name: toolName,
|
|
153
|
-
description: toolDef.description,
|
|
154
|
-
inputSchema: jsonSchema,
|
|
155
|
-
execute: toolDef.execute
|
|
156
|
-
};
|
|
157
|
-
if (toolDef._meta) {
|
|
158
|
-
baseTool._meta = toolDef._meta;
|
|
159
|
-
}
|
|
160
|
-
modelTools.push(baseTool);
|
|
161
|
-
}
|
|
162
|
-
const context = {
|
|
163
|
-
name: contextName,
|
|
164
|
-
description: (options == null ? void 0 : options.description) || `Tools for ${contextName}`,
|
|
165
|
-
toolPrefix: options == null ? void 0 : options.toolPrefix,
|
|
166
|
-
uri: (options == null ? void 0 : options.uri) || `app://${contextName}`,
|
|
167
|
-
tools: modelTools,
|
|
168
|
-
prompts: []
|
|
169
|
-
};
|
|
170
|
-
return context;
|
|
171
|
-
}
|
|
172
|
-
exports.toolsToModelContext = toolsToModelContext;
|
|
173
|
-
function extractToolHandlers(tools) {
|
|
174
|
-
const handlers = {};
|
|
175
|
-
if (Array.isArray(tools)) {
|
|
176
|
-
for (const tool3 of tools) {
|
|
177
|
-
if (tool3.execute && tool3.name) {
|
|
178
|
-
handlers[tool3.name] = tool3.execute;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
} else {
|
|
182
|
-
for (const [toolName, toolDef] of Object.entries(tools)) {
|
|
183
|
-
if (toolDef.execute) {
|
|
184
|
-
handlers[toolName] = toolDef.execute;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
return handlers;
|
|
189
|
-
}
|
|
190
|
-
exports.extractToolHandlers = extractToolHandlers;
|
|
191
|
-
function modelContext2(definition) {
|
|
192
|
-
const { name, uri, description, toolPrefix, tools, resources } = definition;
|
|
193
|
-
let context;
|
|
194
|
-
if (tools && Object.keys(tools).length > 0) {
|
|
195
|
-
context = toolsToModelContext(name, tools, {
|
|
196
|
-
description,
|
|
197
|
-
toolPrefix,
|
|
198
|
-
uri
|
|
199
|
-
});
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function isZodSchema(schema) {
|
|
92
|
+
return schema && typeof schema.parse === "function";
|
|
93
|
+
}
|
|
94
|
+
function zodToJsonSchema(zodSchema) {
|
|
95
|
+
throw new Error(
|
|
96
|
+
"Zod schemas are not supported in botdojo-sdk-types to keep it dependency-free. Please use JSON Schema directly, or convert your Zod schema using zod-to-json-schema in your own code."
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
function toolsToModelContext(contextName, tools, options) {
|
|
100
|
+
const modelTools = [];
|
|
101
|
+
for (const [toolName, toolDef] of Object.entries(tools)) {
|
|
102
|
+
let jsonSchema;
|
|
103
|
+
if (toolDef.parameters) {
|
|
104
|
+
if (isZodSchema(toolDef.parameters)) {
|
|
105
|
+
jsonSchema = zodToJsonSchema(toolDef.parameters);
|
|
200
106
|
} else {
|
|
201
|
-
|
|
202
|
-
name,
|
|
203
|
-
description: description || `Model context for ${name}`,
|
|
204
|
-
toolPrefix,
|
|
205
|
-
uri,
|
|
206
|
-
tools: [],
|
|
207
|
-
prompts: []
|
|
208
|
-
};
|
|
107
|
+
jsonSchema = toolDef.parameters;
|
|
209
108
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
// ../../packages/sdk-types/lib/toolResponseMapper.js
|
|
217
|
-
var require_toolResponseMapper = __commonJS({
|
|
218
|
-
"../../packages/sdk-types/lib/toolResponseMapper.js"(exports) {
|
|
219
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
220
|
-
exports.mapToolResponseToBackend = void 0;
|
|
221
|
-
function isResourceContent(item) {
|
|
222
|
-
return item.type === "resource" && !!item.resource;
|
|
223
|
-
}
|
|
224
|
-
function toCanvasFromResource(resource) {
|
|
225
|
-
var _a;
|
|
226
|
-
const mime = resource.mimeType || "text/uri-list";
|
|
227
|
-
const isMcp = mime === "text/uri-list" || mime === "text/html" || mime === "text/html+mcp" || mime === "text/html;profile=mcp-app";
|
|
228
|
-
if (!isMcp)
|
|
229
|
-
return void 0;
|
|
230
|
-
const meta = resource.meta || {};
|
|
231
|
-
const uiMeta = meta.ui || {};
|
|
232
|
-
const frame = uiMeta.preferredFrameSize || {};
|
|
233
|
-
const initialRenderData = uiMeta.initialRenderData;
|
|
234
|
-
const stateless = uiMeta.stateless;
|
|
235
|
-
const canvasData = {
|
|
236
|
-
url: resource.text || resource.uri,
|
|
237
|
-
mimeType: mime,
|
|
238
|
-
show_inline: (_a = uiMeta.showInline) != null ? _a : true,
|
|
239
|
-
agent_enabled: true,
|
|
240
|
-
width: (frame == null ? void 0 : frame[0]) || (frame == null ? void 0 : frame.width),
|
|
241
|
-
height: (frame == null ? void 0 : frame[1]) || (frame == null ? void 0 : frame.height),
|
|
242
|
-
...initialRenderData && { initialData: initialRenderData },
|
|
243
|
-
...uiMeta.displayName && { displayName: uiMeta.displayName },
|
|
244
|
-
...stateless !== void 0 && { stateless },
|
|
245
|
-
metadata: resource.meta
|
|
246
|
-
};
|
|
247
|
-
return {
|
|
248
|
-
canvasType: "mcp-app",
|
|
249
|
-
canvasData
|
|
250
|
-
};
|
|
251
|
-
}
|
|
252
|
-
function processContentItems(items) {
|
|
253
|
-
const outputFromToolObject = items;
|
|
254
|
-
const outputFromTool = JSON.stringify(items, null, 2);
|
|
255
|
-
let canvas;
|
|
256
|
-
for (const item of items) {
|
|
257
|
-
if (isResourceContent(item)) {
|
|
258
|
-
const maybe = toCanvasFromResource(item.resource);
|
|
259
|
-
if (maybe) {
|
|
260
|
-
canvas = maybe;
|
|
261
|
-
break;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
return {
|
|
266
|
-
outputFromTool,
|
|
267
|
-
outputFromToolObject,
|
|
268
|
-
canvas
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
async function mapToolResponseToBackend2(response) {
|
|
272
|
-
if (Array.isArray(response)) {
|
|
273
|
-
return processContentItems(response);
|
|
274
|
-
}
|
|
275
|
-
return {
|
|
276
|
-
outputFromTool: response === void 0 ? "" : JSON.stringify(response, null, 2),
|
|
277
|
-
outputFromToolObject: response
|
|
109
|
+
} else {
|
|
110
|
+
jsonSchema = {
|
|
111
|
+
type: "object",
|
|
112
|
+
properties: {},
|
|
113
|
+
required: []
|
|
278
114
|
};
|
|
279
115
|
}
|
|
280
|
-
|
|
116
|
+
const baseTool = {
|
|
117
|
+
name: toolName,
|
|
118
|
+
description: toolDef.description,
|
|
119
|
+
inputSchema: jsonSchema,
|
|
120
|
+
execute: toolDef.execute
|
|
121
|
+
};
|
|
122
|
+
if (toolDef._meta) {
|
|
123
|
+
baseTool._meta = toolDef._meta;
|
|
124
|
+
}
|
|
125
|
+
modelTools.push(baseTool);
|
|
126
|
+
}
|
|
127
|
+
const context = {
|
|
128
|
+
name: contextName,
|
|
129
|
+
description: (options == null ? void 0 : options.description) || `Tools for ${contextName}`,
|
|
130
|
+
toolPrefix: options == null ? void 0 : options.toolPrefix,
|
|
131
|
+
uri: (options == null ? void 0 : options.uri) || `app://${contextName}`,
|
|
132
|
+
tools: modelTools,
|
|
133
|
+
prompts: []
|
|
134
|
+
};
|
|
135
|
+
return context;
|
|
136
|
+
}
|
|
137
|
+
function modelContext(definition) {
|
|
138
|
+
const { name, uri, description, toolPrefix, tools, resources } = definition;
|
|
139
|
+
let context;
|
|
140
|
+
if (tools && Object.keys(tools).length > 0) {
|
|
141
|
+
context = toolsToModelContext(name, tools, {
|
|
142
|
+
description,
|
|
143
|
+
toolPrefix,
|
|
144
|
+
uri
|
|
145
|
+
});
|
|
146
|
+
} else {
|
|
147
|
+
context = {
|
|
148
|
+
name,
|
|
149
|
+
description: description || `Model context for ${name}`,
|
|
150
|
+
toolPrefix,
|
|
151
|
+
uri,
|
|
152
|
+
tools: [],
|
|
153
|
+
prompts: []
|
|
154
|
+
};
|
|
281
155
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
const templatePart = templateParts[i];
|
|
305
|
-
if (templatePart.startsWith("{") && templatePart.endsWith("}")) {
|
|
306
|
-
const paramName = templatePart.slice(1, -1);
|
|
307
|
-
params[paramName] = uriParts[i];
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
return params;
|
|
311
|
-
}
|
|
312
|
-
exports.extractUriParams = extractUriParams;
|
|
313
|
-
function normalizeResourceContent(uri, mimeType, result) {
|
|
314
|
-
if (typeof result === "string") {
|
|
315
|
-
return {
|
|
316
|
-
uri,
|
|
317
|
-
mimeType,
|
|
318
|
-
text: result
|
|
319
|
-
};
|
|
320
|
-
}
|
|
321
|
-
if ("url" in result && !("text" in result) && !("mcp" in result)) {
|
|
322
|
-
return {
|
|
323
|
-
uri,
|
|
324
|
-
mimeType,
|
|
325
|
-
text: JSON.stringify({ url: result.url })
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
|
-
return {
|
|
329
|
-
uri,
|
|
330
|
-
mimeType,
|
|
331
|
-
...result
|
|
332
|
-
};
|
|
333
|
-
}
|
|
334
|
-
function buildResourceProvider(providerId, resources) {
|
|
335
|
-
const templates = resources.map((resource) => {
|
|
336
|
-
if (isDynamicResource2(resource)) {
|
|
337
|
-
return {
|
|
338
|
-
uriTemplate: resource.uriTemplate,
|
|
339
|
-
name: resource.label || resource.uriTemplate,
|
|
340
|
-
label: resource.label || resource.uriTemplate,
|
|
341
|
-
description: resource.description,
|
|
342
|
-
mimeType: resource.mimeType
|
|
343
|
-
};
|
|
344
|
-
} else {
|
|
345
|
-
return {
|
|
346
|
-
uriTemplate: resource.uri,
|
|
347
|
-
name: resource.label || resource.uri,
|
|
348
|
-
label: resource.label || resource.uri,
|
|
349
|
-
description: resource.description,
|
|
350
|
-
mimeType: resource.mimeType
|
|
351
|
-
};
|
|
352
|
-
}
|
|
353
|
-
});
|
|
354
|
-
const getResource = async (templateName, uri, params, onlyMetadata) => {
|
|
355
|
-
for (const resource of resources) {
|
|
356
|
-
const template = isDynamicResource2(resource) ? resource.uriTemplate : resource.uri;
|
|
357
|
-
if (matchesUriTemplate(uri, template)) {
|
|
358
|
-
if (onlyMetadata) {
|
|
359
|
-
return {
|
|
360
|
-
uri,
|
|
361
|
-
mimeType: resource.mimeType,
|
|
362
|
-
meta: {
|
|
363
|
-
description: resource.description,
|
|
364
|
-
label: resource.label
|
|
365
|
-
}
|
|
366
|
-
};
|
|
367
|
-
}
|
|
368
|
-
let result;
|
|
369
|
-
if (isDynamicResource2(resource)) {
|
|
370
|
-
const extractedParams = params || extractUriParams(uri, resource.uriTemplate);
|
|
371
|
-
result = await resource.getContent(extractedParams);
|
|
372
|
-
} else {
|
|
373
|
-
result = await resource.getContent();
|
|
374
|
-
}
|
|
375
|
-
return normalizeResourceContent(uri, resource.mimeType, result);
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
throw new Error(`No resource definition found for URI: ${uri}`);
|
|
379
|
-
};
|
|
380
|
-
return {
|
|
381
|
-
id: providerId,
|
|
382
|
-
templates,
|
|
383
|
-
getResource
|
|
384
|
-
};
|
|
385
|
-
}
|
|
386
|
-
exports.buildResourceProvider = buildResourceProvider;
|
|
156
|
+
return context;
|
|
157
|
+
}
|
|
158
|
+
function isDynamicResource(resource) {
|
|
159
|
+
return "uriTemplate" in resource;
|
|
160
|
+
}
|
|
161
|
+
function translateModelContextToBackend(context) {
|
|
162
|
+
const tools = translateToolsToBackend(context.tools || []);
|
|
163
|
+
const prompts = translatePromptsToBackend(context.prompts || []);
|
|
164
|
+
const resources = translateResourcesToBackend(context);
|
|
165
|
+
return {
|
|
166
|
+
name: context.name,
|
|
167
|
+
description: context.description,
|
|
168
|
+
toolPrefix: context.toolPrefix,
|
|
169
|
+
resourceUri: context.uri,
|
|
170
|
+
tools,
|
|
171
|
+
prompts,
|
|
172
|
+
resources
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function convertUiResourceTemplateToCanvasTemplate(resourceTemplate) {
|
|
176
|
+
if (!resourceTemplate || !resourceTemplate.uri) {
|
|
177
|
+
return void 0;
|
|
387
178
|
}
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
179
|
+
const metadata = resourceTemplate.metadata || {};
|
|
180
|
+
const uiMeta = metadata.ui || {};
|
|
181
|
+
const frameSize = uiMeta.preferredFrameSize || {};
|
|
182
|
+
const width = Array.isArray(frameSize) ? frameSize[0] : frameSize.width || "100%";
|
|
183
|
+
const height = Array.isArray(frameSize) ? frameSize[1] : frameSize.height || "520px";
|
|
184
|
+
const initialRenderData = uiMeta.initialRenderData || {};
|
|
185
|
+
const displayName = uiMeta.displayName;
|
|
186
|
+
const stateless = uiMeta.stateless === true;
|
|
187
|
+
const mimeType = resourceTemplate.mimeType;
|
|
188
|
+
const html = uiMeta.html;
|
|
189
|
+
const prefersProxy = uiMeta.prefersProxy;
|
|
190
|
+
const allowExternal = uiMeta.allowExternal;
|
|
191
|
+
const baseUrl = uiMeta.baseUrl;
|
|
192
|
+
const urlList = uiMeta.urlList;
|
|
193
|
+
return {
|
|
194
|
+
type: "mcp-app",
|
|
195
|
+
width,
|
|
196
|
+
height,
|
|
197
|
+
stateless,
|
|
198
|
+
initialData: {
|
|
199
|
+
url: resourceTemplate.uri,
|
|
200
|
+
show_inline: true,
|
|
201
|
+
agent_enabled: true,
|
|
202
|
+
...mimeType && { mimeType },
|
|
203
|
+
...html && { html, inlineHtml: true },
|
|
204
|
+
...prefersProxy !== void 0 && { prefersProxy },
|
|
205
|
+
...allowExternal !== void 0 && { allowExternal },
|
|
206
|
+
...baseUrl && { baseUrl },
|
|
207
|
+
...urlList && { urlList },
|
|
208
|
+
...initialRenderData,
|
|
209
|
+
...displayName && { displayName },
|
|
210
|
+
metadata
|
|
408
211
|
}
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
const displayName = uiMeta.displayName;
|
|
421
|
-
const stateless = uiMeta.stateless === true;
|
|
422
|
-
const mimeType = resourceTemplate.mimeType;
|
|
423
|
-
const html = uiMeta.html;
|
|
424
|
-
const prefersProxy = uiMeta.prefersProxy;
|
|
425
|
-
const allowExternal = uiMeta.allowExternal;
|
|
426
|
-
const baseUrl = uiMeta.baseUrl;
|
|
427
|
-
const urlList = uiMeta.urlList;
|
|
428
|
-
return {
|
|
429
|
-
type: "mcp-app",
|
|
430
|
-
width,
|
|
431
|
-
height,
|
|
432
|
-
stateless,
|
|
433
|
-
initialData: {
|
|
434
|
-
url: resourceTemplate.uri,
|
|
435
|
-
show_inline: true,
|
|
436
|
-
agent_enabled: true,
|
|
437
|
-
...mimeType && { mimeType },
|
|
438
|
-
...html && { html, inlineHtml: true },
|
|
439
|
-
...prefersProxy !== void 0 && { prefersProxy },
|
|
440
|
-
...allowExternal !== void 0 && { allowExternal },
|
|
441
|
-
...baseUrl && { baseUrl },
|
|
442
|
-
...urlList && { urlList },
|
|
443
|
-
...initialRenderData,
|
|
444
|
-
...displayName && { displayName },
|
|
445
|
-
metadata
|
|
446
|
-
}
|
|
447
|
-
};
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
function translateToolsToBackend(tools) {
|
|
215
|
+
const toolsArray = Array.isArray(tools) ? tools : Object.entries(tools || {}).map(([name, tool2]) => ({ ...tool2, name }));
|
|
216
|
+
return toolsArray.map((tool2) => {
|
|
217
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
218
|
+
let canvasTemplate = tool2.canvasTemplate || ((_a = tool2._meta) == null ? void 0 : _a["botdojo/canvas"]);
|
|
219
|
+
if (!canvasTemplate && ((_b = tool2._meta) == null ? void 0 : _b["botdojo/resource-template"])) {
|
|
220
|
+
canvasTemplate = convertUiResourceTemplateToCanvasTemplate(
|
|
221
|
+
tool2._meta["botdojo/resource-template"]
|
|
222
|
+
);
|
|
448
223
|
}
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
}
|
|
457
|
-
if (!canvasTemplate && ((_d = (_c = tool2._meta) == null ? void 0 : _c.ui) == null ? void 0 : _d.resourceUri)) {
|
|
458
|
-
canvasTemplate = convertUiResourceTemplateToCanvasTemplate({
|
|
459
|
-
uri: tool2._meta.ui.resourceUri,
|
|
460
|
-
mimeType: tool2._meta.ui.mimeType || "text/html;profile=mcp-app",
|
|
461
|
-
metadata: { ui: tool2._meta.ui }
|
|
462
|
-
});
|
|
224
|
+
if (!canvasTemplate && ((_d = (_c = tool2._meta) == null ? void 0 : _c.ui) == null ? void 0 : _d.resourceUri)) {
|
|
225
|
+
canvasTemplate = convertUiResourceTemplateToCanvasTemplate({
|
|
226
|
+
uri: tool2._meta.ui.resourceUri,
|
|
227
|
+
mimeType: tool2._meta.ui.mimeType || "text/html;profile=mcp-app",
|
|
228
|
+
metadata: {
|
|
229
|
+
ui: tool2._meta.ui,
|
|
230
|
+
...((_e = tool2._meta) == null ? void 0 : _e["botdojo/no-cache"]) === true ? { "botdojo/no-cache": true } : {}
|
|
463
231
|
}
|
|
464
|
-
return {
|
|
465
|
-
name: tool2.name,
|
|
466
|
-
description: tool2.description,
|
|
467
|
-
displayName: tool2.displayName || ((_e = tool2._meta) == null ? void 0 : _e["botdojo/display-name"]) || ((_g = (_f = tool2._meta) == null ? void 0 : _f.ui) == null ? void 0 : _g.displayName) || tool2.name,
|
|
468
|
-
// Convert SDK's inputSchema (MCP standard) to backend's arguments field
|
|
469
|
-
// Keep fallback for legacy: arguments > parameters > inputSchema
|
|
470
|
-
arguments: tool2.arguments || tool2.parameters || tool2.inputSchema,
|
|
471
|
-
canvasTemplate,
|
|
472
|
-
hideStep: (_i = (_h = tool2._meta) == null ? void 0 : _h["botdojo/hide-step"]) != null ? _i : false,
|
|
473
|
-
hideStepDetails: (_k = (_j = tool2._meta) == null ? void 0 : _j["botdojo/hide-step-details"]) != null ? _k : false,
|
|
474
|
-
// Preserve _meta for additional metadata (e.g., streaming-preview, execute function)
|
|
475
|
-
_meta: tool2._meta
|
|
476
|
-
};
|
|
477
232
|
});
|
|
478
233
|
}
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
return (prompts || []).map((p) => ({
|
|
482
|
-
name: p.name,
|
|
483
|
-
description: p.description,
|
|
484
|
-
messages: (p.messages || []).map((m) => ({
|
|
485
|
-
role: m.role,
|
|
486
|
-
content: m.content
|
|
487
|
-
}))
|
|
488
|
-
}));
|
|
489
|
-
}
|
|
490
|
-
exports.translatePromptsToBackend = translatePromptsToBackend;
|
|
491
|
-
function translateResourcesToBackend(context) {
|
|
492
|
-
const resources = [];
|
|
493
|
-
if (context.resources) {
|
|
494
|
-
resources.push(...(context.resources || []).map((r) => {
|
|
495
|
-
const uri = "uriTemplate" in r ? r.uriTemplate : r.uri;
|
|
496
|
-
return {
|
|
497
|
-
uri,
|
|
498
|
-
name: r.name,
|
|
499
|
-
description: r.description,
|
|
500
|
-
mimeType: r.mimeType
|
|
501
|
-
};
|
|
502
|
-
}));
|
|
503
|
-
}
|
|
504
|
-
return resources;
|
|
505
|
-
}
|
|
506
|
-
exports.translateResourcesToBackend = translateResourcesToBackend;
|
|
507
|
-
}
|
|
508
|
-
});
|
|
509
|
-
|
|
510
|
-
// ../../packages/sdk-types/lib/type-translation.js
|
|
511
|
-
var require_type_translation = __commonJS({
|
|
512
|
-
"../../packages/sdk-types/lib/type-translation.js"(exports) {
|
|
513
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
514
|
-
exports.translateResourcesToBackend = exports.translatePromptsToBackend = exports.translateToolsToBackend = exports.translateModelContextToBackend = void 0;
|
|
515
|
-
var modelContextTranslation_snapshot_1 = require_modelContextTranslation_snapshot();
|
|
516
|
-
function translateModelContextToBackend3(context) {
|
|
517
|
-
return (0, modelContextTranslation_snapshot_1.translateModelContextToBackend)(context);
|
|
518
|
-
}
|
|
519
|
-
exports.translateModelContextToBackend = translateModelContextToBackend3;
|
|
520
|
-
function translateToolsToBackend(tools) {
|
|
521
|
-
return (0, modelContextTranslation_snapshot_1.translateToolsToBackend)(tools);
|
|
522
|
-
}
|
|
523
|
-
exports.translateToolsToBackend = translateToolsToBackend;
|
|
524
|
-
function translatePromptsToBackend(prompts) {
|
|
525
|
-
return (0, modelContextTranslation_snapshot_1.translatePromptsToBackend)(prompts);
|
|
234
|
+
if (((_f = canvasTemplate == null ? void 0 : canvasTemplate.initialData) == null ? void 0 : _f.metadata) && ((_g = tool2._meta) == null ? void 0 : _g["botdojo/no-cache"]) === true) {
|
|
235
|
+
canvasTemplate.initialData.metadata["botdojo/no-cache"] = true;
|
|
526
236
|
}
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
const content = internalStep.content;
|
|
558
|
-
if (content.trim().startsWith("{") || content.trim().startsWith("[")) {
|
|
559
|
-
try {
|
|
560
|
-
sdkStep.stepToolResult = JSON.parse(content);
|
|
561
|
-
} catch {
|
|
562
|
-
sdkStep.stepToolResult = content;
|
|
563
|
-
}
|
|
564
|
-
} else {
|
|
565
|
-
sdkStep.stepToolResult = content;
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
if (internalStep.toolPhase) {
|
|
569
|
-
sdkStep.stepToolPhase = internalStep.toolPhase;
|
|
570
|
-
}
|
|
571
|
-
return sdkStep;
|
|
572
|
-
}
|
|
573
|
-
exports.toSDKStep = toSDKStep;
|
|
574
|
-
function toInternalStep(sdkStep) {
|
|
575
|
-
var _a;
|
|
576
|
-
const internalStep = {
|
|
577
|
-
...sdkStep,
|
|
578
|
-
subIntermediateSteps: (_a = sdkStep.subSteps) == null ? void 0 : _a.map(toInternalStep)
|
|
579
|
-
};
|
|
580
|
-
delete internalStep.subSteps;
|
|
581
|
-
return internalStep;
|
|
582
|
-
}
|
|
583
|
-
exports.toInternalStep = toInternalStep;
|
|
584
|
-
function toInternalCallbacks(sdkCallbacks) {
|
|
585
|
-
if (!sdkCallbacks)
|
|
586
|
-
return void 0;
|
|
237
|
+
return {
|
|
238
|
+
name: tool2.name,
|
|
239
|
+
description: tool2.description,
|
|
240
|
+
displayName: tool2.displayName || ((_h = tool2._meta) == null ? void 0 : _h["botdojo/display-name"]) || ((_j = (_i = tool2._meta) == null ? void 0 : _i.ui) == null ? void 0 : _j.displayName) || tool2.name,
|
|
241
|
+
// Convert SDK's inputSchema (MCP standard) to backend's arguments field
|
|
242
|
+
// Keep fallback for legacy: arguments > parameters > inputSchema
|
|
243
|
+
arguments: tool2.arguments || tool2.parameters || tool2.inputSchema,
|
|
244
|
+
canvasTemplate,
|
|
245
|
+
hideStep: (_l = (_k = tool2._meta) == null ? void 0 : _k["botdojo/hide-step"]) != null ? _l : false,
|
|
246
|
+
hideStepDetails: (_n = (_m = tool2._meta) == null ? void 0 : _m["botdojo/hide-step-details"]) != null ? _n : false,
|
|
247
|
+
// Preserve _meta for additional metadata (e.g., streaming-preview, execute function)
|
|
248
|
+
_meta: tool2._meta
|
|
249
|
+
};
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
function translatePromptsToBackend(prompts) {
|
|
253
|
+
return (prompts || []).map((p) => ({
|
|
254
|
+
name: p.name,
|
|
255
|
+
description: p.description,
|
|
256
|
+
messages: (p.messages || []).map((m) => ({
|
|
257
|
+
role: m.role,
|
|
258
|
+
content: m.content
|
|
259
|
+
}))
|
|
260
|
+
}));
|
|
261
|
+
}
|
|
262
|
+
function translateResourcesToBackend(context) {
|
|
263
|
+
const resources = [];
|
|
264
|
+
if (context.resources) {
|
|
265
|
+
resources.push(...(context.resources || []).map((r) => {
|
|
266
|
+
const uri = "uriTemplate" in r ? r.uriTemplate : r.uri;
|
|
587
267
|
return {
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
} : void 0
|
|
593
|
-
// Note: Other SDK callbacks (onFlowRequestStart, onNewToken, etc.) are not currently mapped
|
|
594
|
-
// as they have incompatible signatures with internal callbacks
|
|
268
|
+
uri,
|
|
269
|
+
name: r.name,
|
|
270
|
+
description: r.description,
|
|
271
|
+
mimeType: r.mimeType
|
|
595
272
|
};
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
273
|
+
}));
|
|
274
|
+
}
|
|
275
|
+
return resources;
|
|
276
|
+
}
|
|
277
|
+
function isResourceContent(item) {
|
|
278
|
+
return item.type === "resource" && !!item.resource;
|
|
279
|
+
}
|
|
280
|
+
function toCanvasFromResource(resource) {
|
|
281
|
+
var _a;
|
|
282
|
+
const mime = resource.mimeType || "text/uri-list";
|
|
283
|
+
const isMcp = mime === "text/uri-list" || mime === "text/html" || mime === "text/html+mcp" || mime === "text/html;profile=mcp-app";
|
|
284
|
+
if (!isMcp)
|
|
285
|
+
return void 0;
|
|
286
|
+
const meta = resource.meta || {};
|
|
287
|
+
const uiMeta = meta.ui || {};
|
|
288
|
+
const frame = uiMeta.preferredFrameSize || {};
|
|
289
|
+
const initialRenderData = uiMeta.initialRenderData;
|
|
290
|
+
const stateless = uiMeta.stateless;
|
|
291
|
+
const canvasData = {
|
|
292
|
+
url: resource.text || resource.uri,
|
|
293
|
+
mimeType: mime,
|
|
294
|
+
show_inline: (_a = uiMeta.showInline) != null ? _a : true,
|
|
295
|
+
agent_enabled: true,
|
|
296
|
+
width: (frame == null ? void 0 : frame[0]) || (frame == null ? void 0 : frame.width),
|
|
297
|
+
height: (frame == null ? void 0 : frame[1]) || (frame == null ? void 0 : frame.height),
|
|
298
|
+
...initialRenderData && { initialData: initialRenderData },
|
|
299
|
+
...uiMeta.displayName && { displayName: uiMeta.displayName },
|
|
300
|
+
...stateless !== void 0 && { stateless },
|
|
301
|
+
metadata: resource.meta
|
|
302
|
+
};
|
|
303
|
+
return {
|
|
304
|
+
canvasType: "mcp-app",
|
|
305
|
+
canvasData
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
function processContentItems(items) {
|
|
309
|
+
const outputFromToolObject = items;
|
|
310
|
+
const outputFromTool = JSON.stringify(items, null, 2);
|
|
311
|
+
let canvas;
|
|
312
|
+
for (const item of items) {
|
|
313
|
+
if (isResourceContent(item)) {
|
|
314
|
+
const maybe = toCanvasFromResource(item.resource);
|
|
315
|
+
if (maybe) {
|
|
316
|
+
canvas = maybe;
|
|
317
|
+
break;
|
|
612
318
|
}
|
|
613
|
-
return apiConfig;
|
|
614
|
-
}
|
|
615
|
-
function toInternalRunOptions(sdkOptions) {
|
|
616
|
-
if (!sdkOptions)
|
|
617
|
-
return {};
|
|
618
|
-
return {
|
|
619
|
-
flow_id: sdkOptions.flowId,
|
|
620
|
-
flow_session_id: sdkOptions.sessionId,
|
|
621
|
-
// Map sessionId to flow_session_id for server
|
|
622
|
-
stream_events: sdkOptions.streamEvents,
|
|
623
|
-
stream: sdkOptions.stream,
|
|
624
|
-
model_context: sdkOptions.modelContext,
|
|
625
|
-
callbacks: toInternalCallbacks(sdkOptions.callbacks),
|
|
626
|
-
debug: sdkOptions.debug,
|
|
627
|
-
circuitBreaker: convertCircuitBreakerToAPI(sdkOptions.circuitBreaker)
|
|
628
|
-
};
|
|
629
319
|
}
|
|
630
|
-
exports.toInternalRunOptions = toInternalRunOptions;
|
|
631
320
|
}
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
// ../../packages/sdk-types/lib/index.js
|
|
642
|
-
var require_lib = __commonJS({
|
|
643
|
-
"../../packages/sdk-types/lib/index.js"(exports) {
|
|
644
|
-
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
645
|
-
if (k2 === void 0)
|
|
646
|
-
k2 = k;
|
|
647
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
648
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
649
|
-
desc = { enumerable: true, get: function() {
|
|
650
|
-
return m[k];
|
|
651
|
-
} };
|
|
652
|
-
}
|
|
653
|
-
Object.defineProperty(o, k2, desc);
|
|
654
|
-
} : function(o, m, k, k2) {
|
|
655
|
-
if (k2 === void 0)
|
|
656
|
-
k2 = k;
|
|
657
|
-
o[k2] = m[k];
|
|
658
|
-
});
|
|
659
|
-
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|
660
|
-
for (var p in m)
|
|
661
|
-
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
|
|
662
|
-
__createBinding(exports2, m, p);
|
|
663
|
-
};
|
|
664
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
665
|
-
exports.toInternalRunOptions = exports.toInternalCallbacks = exports.toInternalStep = exports.toSDKStep = exports.translateResourcesToBackend = exports.translatePromptsToBackend = exports.translateToolsToBackend = exports.translateModelContextToBackend = exports.extractUriParams = exports.matchesUriTemplate = exports.isDynamicResource = exports.buildResourceProvider = exports.mapToolResponseToBackend = exports.citations = exports.citation = exports.mcpResource = exports.uiResource = exports.imageResult = exports.textResult = exports.extractToolHandlers = exports.toolsToModelContext = exports.modelContext = exports.tool = exports.MCP_HTML_MIME_TYPES = exports.MIME_TYPES = void 0;
|
|
666
|
-
exports.MIME_TYPES = {
|
|
667
|
-
// UI Canvas types (MCP Apps standard)
|
|
668
|
-
URI_LIST: "text/uri-list",
|
|
669
|
-
HTML: "text/html",
|
|
670
|
-
HTML_MCP: "text/html+mcp",
|
|
671
|
-
HTML_MCP_PROFILE: "text/html;profile=mcp-app",
|
|
672
|
-
// Remote DOM (both MCP Apps standard and BotDojo alias)
|
|
673
|
-
REMOTE_DOM: "application/vnd.mcp-ui.remote-dom",
|
|
674
|
-
REMOTE_DOM_BOTDOJO: "application/vnd.botdojo.ui-remote-dom",
|
|
675
|
-
// BotDojo extensions
|
|
676
|
-
MODEL_CONTEXT: "application/vnd.botdojo.modelcontext",
|
|
677
|
-
CITATION: "application/vnd.botdojo.citation",
|
|
678
|
-
CITATIONS: "application/vnd.botdojo.citations"
|
|
679
|
-
};
|
|
680
|
-
exports.MCP_HTML_MIME_TYPES = [
|
|
681
|
-
exports.MIME_TYPES.HTML_MCP,
|
|
682
|
-
exports.MIME_TYPES.HTML_MCP_PROFILE
|
|
683
|
-
];
|
|
684
|
-
var tool_utils_1 = require_tool_utils();
|
|
685
|
-
Object.defineProperty(exports, "tool", { enumerable: true, get: function() {
|
|
686
|
-
return tool_utils_1.tool;
|
|
687
|
-
} });
|
|
688
|
-
Object.defineProperty(exports, "modelContext", { enumerable: true, get: function() {
|
|
689
|
-
return tool_utils_1.modelContext;
|
|
690
|
-
} });
|
|
691
|
-
Object.defineProperty(exports, "toolsToModelContext", { enumerable: true, get: function() {
|
|
692
|
-
return tool_utils_1.toolsToModelContext;
|
|
693
|
-
} });
|
|
694
|
-
Object.defineProperty(exports, "extractToolHandlers", { enumerable: true, get: function() {
|
|
695
|
-
return tool_utils_1.extractToolHandlers;
|
|
696
|
-
} });
|
|
697
|
-
Object.defineProperty(exports, "textResult", { enumerable: true, get: function() {
|
|
698
|
-
return tool_utils_1.textResult;
|
|
699
|
-
} });
|
|
700
|
-
Object.defineProperty(exports, "imageResult", { enumerable: true, get: function() {
|
|
701
|
-
return tool_utils_1.imageResult;
|
|
702
|
-
} });
|
|
703
|
-
Object.defineProperty(exports, "uiResource", { enumerable: true, get: function() {
|
|
704
|
-
return tool_utils_1.uiResource;
|
|
705
|
-
} });
|
|
706
|
-
Object.defineProperty(exports, "mcpResource", { enumerable: true, get: function() {
|
|
707
|
-
return tool_utils_1.mcpResource;
|
|
708
|
-
} });
|
|
709
|
-
Object.defineProperty(exports, "citation", { enumerable: true, get: function() {
|
|
710
|
-
return tool_utils_1.citation;
|
|
711
|
-
} });
|
|
712
|
-
Object.defineProperty(exports, "citations", { enumerable: true, get: function() {
|
|
713
|
-
return tool_utils_1.citations;
|
|
714
|
-
} });
|
|
715
|
-
var toolResponseMapper_1 = require_toolResponseMapper();
|
|
716
|
-
Object.defineProperty(exports, "mapToolResponseToBackend", { enumerable: true, get: function() {
|
|
717
|
-
return toolResponseMapper_1.mapToolResponseToBackend;
|
|
718
|
-
} });
|
|
719
|
-
var resource_utils_1 = require_resource_utils();
|
|
720
|
-
Object.defineProperty(exports, "buildResourceProvider", { enumerable: true, get: function() {
|
|
721
|
-
return resource_utils_1.buildResourceProvider;
|
|
722
|
-
} });
|
|
723
|
-
Object.defineProperty(exports, "isDynamicResource", { enumerable: true, get: function() {
|
|
724
|
-
return resource_utils_1.isDynamicResource;
|
|
725
|
-
} });
|
|
726
|
-
Object.defineProperty(exports, "matchesUriTemplate", { enumerable: true, get: function() {
|
|
727
|
-
return resource_utils_1.matchesUriTemplate;
|
|
728
|
-
} });
|
|
729
|
-
Object.defineProperty(exports, "extractUriParams", { enumerable: true, get: function() {
|
|
730
|
-
return resource_utils_1.extractUriParams;
|
|
731
|
-
} });
|
|
732
|
-
var type_translation_1 = require_type_translation();
|
|
733
|
-
Object.defineProperty(exports, "translateModelContextToBackend", { enumerable: true, get: function() {
|
|
734
|
-
return type_translation_1.translateModelContextToBackend;
|
|
735
|
-
} });
|
|
736
|
-
Object.defineProperty(exports, "translateToolsToBackend", { enumerable: true, get: function() {
|
|
737
|
-
return type_translation_1.translateToolsToBackend;
|
|
738
|
-
} });
|
|
739
|
-
Object.defineProperty(exports, "translatePromptsToBackend", { enumerable: true, get: function() {
|
|
740
|
-
return type_translation_1.translatePromptsToBackend;
|
|
741
|
-
} });
|
|
742
|
-
Object.defineProperty(exports, "translateResourcesToBackend", { enumerable: true, get: function() {
|
|
743
|
-
return type_translation_1.translateResourcesToBackend;
|
|
744
|
-
} });
|
|
745
|
-
var converters_1 = require_converters();
|
|
746
|
-
Object.defineProperty(exports, "toSDKStep", { enumerable: true, get: function() {
|
|
747
|
-
return converters_1.toSDKStep;
|
|
748
|
-
} });
|
|
749
|
-
Object.defineProperty(exports, "toInternalStep", { enumerable: true, get: function() {
|
|
750
|
-
return converters_1.toInternalStep;
|
|
751
|
-
} });
|
|
752
|
-
Object.defineProperty(exports, "toInternalCallbacks", { enumerable: true, get: function() {
|
|
753
|
-
return converters_1.toInternalCallbacks;
|
|
754
|
-
} });
|
|
755
|
-
Object.defineProperty(exports, "toInternalRunOptions", { enumerable: true, get: function() {
|
|
756
|
-
return converters_1.toInternalRunOptions;
|
|
757
|
-
} });
|
|
758
|
-
__exportStar(require_mcp_apps(), exports);
|
|
321
|
+
return {
|
|
322
|
+
outputFromTool,
|
|
323
|
+
outputFromToolObject,
|
|
324
|
+
canvas
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
async function mapToolResponseToBackend(response) {
|
|
328
|
+
if (Array.isArray(response)) {
|
|
329
|
+
return processContentItems(response);
|
|
759
330
|
}
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
331
|
+
return {
|
|
332
|
+
outputFromTool: response === void 0 ? "" : JSON.stringify(response, null, 2),
|
|
333
|
+
outputFromToolObject: response
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
var MIME_TYPES = {
|
|
337
|
+
// UI Canvas types (MCP Apps standard)
|
|
338
|
+
URI_LIST: "text/uri-list",
|
|
339
|
+
HTML: "text/html",
|
|
340
|
+
HTML_MCP: "text/html+mcp",
|
|
341
|
+
HTML_MCP_PROFILE: "text/html;profile=mcp-app",
|
|
342
|
+
// Remote DOM (both MCP Apps standard and BotDojo alias)
|
|
343
|
+
REMOTE_DOM: "application/vnd.mcp-ui.remote-dom",
|
|
344
|
+
REMOTE_DOM_BOTDOJO: "application/vnd.botdojo.ui-remote-dom",
|
|
345
|
+
// BotDojo extensions
|
|
346
|
+
MODEL_CONTEXT: "application/vnd.botdojo.modelcontext",
|
|
347
|
+
CITATION: "application/vnd.botdojo.citation",
|
|
348
|
+
CITATIONS: "application/vnd.botdojo.citations"
|
|
349
|
+
};
|
|
350
|
+
[
|
|
351
|
+
MIME_TYPES.HTML_MCP,
|
|
352
|
+
MIME_TYPES.HTML_MCP_PROFILE
|
|
353
|
+
];
|
|
764
354
|
|
|
765
|
-
//
|
|
355
|
+
// ../../node_modules/.pnpm/botdojo-rpc@0.1.1/node_modules/botdojo-rpc/dist/index.mjs
|
|
766
356
|
var __require2 = /* @__PURE__ */ ((x) => typeof __require !== "undefined" ? __require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
767
357
|
get: (a, b) => (typeof __require !== "undefined" ? __require : a)[b]
|
|
768
358
|
}) : x)(function(x) {
|
|
@@ -1959,7 +1549,7 @@ var BotDojoConnector = class {
|
|
|
1959
1549
|
source: this.connection.sender,
|
|
1960
1550
|
func: async () => {
|
|
1961
1551
|
return Array.from(this.registeredModelContexts.values()).map((ctx) => {
|
|
1962
|
-
const backendFormat =
|
|
1552
|
+
const backendFormat = translateModelContextToBackend(ctx);
|
|
1963
1553
|
const tools = (backendFormat.tools || []).map((tool2) => {
|
|
1964
1554
|
const { execute, ...toolWithoutExecute } = tool2;
|
|
1965
1555
|
return toolWithoutExecute;
|
|
@@ -2092,7 +1682,7 @@ var BotDojoConnector = class {
|
|
|
2092
1682
|
};
|
|
2093
1683
|
const rawresult = await tool2.execute(toolArgs, toolExecContext2);
|
|
2094
1684
|
await toolExecContext2.notifyToolResult(rawresult);
|
|
2095
|
-
return await
|
|
1685
|
+
return await mapToolResponseToBackend(rawresult);
|
|
2096
1686
|
}
|
|
2097
1687
|
const baseToolInfo = {
|
|
2098
1688
|
toolName,
|
|
@@ -2127,7 +1717,7 @@ var BotDojoConnector = class {
|
|
|
2127
1717
|
};
|
|
2128
1718
|
const rawResult = await tool2.execute(toolArgs, toolExecContext);
|
|
2129
1719
|
await toolExecContext.notifyToolResult(rawResult);
|
|
2130
|
-
return await
|
|
1720
|
+
return await mapToolResponseToBackend(rawResult);
|
|
2131
1721
|
}
|
|
2132
1722
|
});
|
|
2133
1723
|
}
|
|
@@ -2172,7 +1762,7 @@ var BotDojoConnector = class {
|
|
|
2172
1762
|
if (msg.functionName === "broadcastAgentHostConnected") {
|
|
2173
1763
|
for (const [contextName, ctx] of this.registeredModelContexts.entries()) {
|
|
2174
1764
|
try {
|
|
2175
|
-
const backendFormat =
|
|
1765
|
+
const backendFormat = translateModelContextToBackend(ctx);
|
|
2176
1766
|
const tools = (backendFormat.tools || []).map((tool2) => {
|
|
2177
1767
|
const { execute, ...toolWithoutExecute } = tool2;
|
|
2178
1768
|
return toolWithoutExecute;
|
|
@@ -2251,7 +1841,7 @@ var BotDojoConnector = class {
|
|
|
2251
1841
|
for (const resource of ctx.resources) {
|
|
2252
1842
|
let matches = false;
|
|
2253
1843
|
let extractedParams = params || {};
|
|
2254
|
-
if (
|
|
1844
|
+
if (isDynamicResource(resource)) {
|
|
2255
1845
|
const template = resource.uriTemplate;
|
|
2256
1846
|
if (this.matchesUriTemplate(resourceUri, template)) {
|
|
2257
1847
|
matches = true;
|
|
@@ -2277,7 +1867,7 @@ var BotDojoConnector = class {
|
|
|
2277
1867
|
}
|
|
2278
1868
|
};
|
|
2279
1869
|
}
|
|
2280
|
-
const content =
|
|
1870
|
+
const content = isDynamicResource(resource) ? await resource.getContent(extractedParams) : await resource.getContent();
|
|
2281
1871
|
let result;
|
|
2282
1872
|
if (typeof content === "string") {
|
|
2283
1873
|
result = {
|
|
@@ -2400,7 +1990,7 @@ var BotDojoConnector = class {
|
|
|
2400
1990
|
console.log("\u{1F3AF} HOST: getModelContexts called");
|
|
2401
1991
|
console.log(`\u{1F3AF} HOST: Current registered contexts: ${this.registeredModelContexts.size}`);
|
|
2402
1992
|
const contexts = Array.from(this.registeredModelContexts.values()).map((ctx) => {
|
|
2403
|
-
const backendFormat =
|
|
1993
|
+
const backendFormat = translateModelContextToBackend(ctx);
|
|
2404
1994
|
const tools = (backendFormat.tools || []).map((tool2) => {
|
|
2405
1995
|
const { execute, ...toolWithoutExecute } = tool2;
|
|
2406
1996
|
return toolWithoutExecute;
|
|
@@ -2528,7 +2118,7 @@ var BotDojoConnector = class {
|
|
|
2528
2118
|
};
|
|
2529
2119
|
const rawresult2 = await tool2.execute(toolArgs, toolExecContext2);
|
|
2530
2120
|
await toolExecContext2.notifyToolResult(rawresult2);
|
|
2531
|
-
const result2 = await
|
|
2121
|
+
const result2 = await mapToolResponseToBackend(rawresult2);
|
|
2532
2122
|
console.log(`\u2705 Tool executed successfully: ${toolName}`);
|
|
2533
2123
|
return result2;
|
|
2534
2124
|
}
|
|
@@ -2565,7 +2155,7 @@ var BotDojoConnector = class {
|
|
|
2565
2155
|
};
|
|
2566
2156
|
const rawresult = await tool2.execute(toolArgs, toolExecContext);
|
|
2567
2157
|
await toolExecContext.notifyToolResult(rawresult);
|
|
2568
|
-
const result = await
|
|
2158
|
+
const result = await mapToolResponseToBackend(rawresult);
|
|
2569
2159
|
console.log(`\u2705 Tool executed successfully: ${toolName}`);
|
|
2570
2160
|
return result;
|
|
2571
2161
|
} catch (error) {
|
|
@@ -3089,7 +2679,11 @@ function buildMcpProxyUrl(options) {
|
|
|
3089
2679
|
const origin = options.origin || "https://mcp-app-proxy.botdojo.com";
|
|
3090
2680
|
const flowId = encodeURIComponent(options.flowId || "unknown");
|
|
3091
2681
|
const encodedResource = encodeURIComponent(options.resource || "");
|
|
3092
|
-
|
|
2682
|
+
let url = `${origin}/${flowId}/?url=${encodedResource}`;
|
|
2683
|
+
if (options.noCache) {
|
|
2684
|
+
url += "&noCache=true";
|
|
2685
|
+
}
|
|
2686
|
+
return url;
|
|
3093
2687
|
}
|
|
3094
2688
|
function buildMcpCacheKey(opts) {
|
|
3095
2689
|
const raw = `${opts.flowId || "unknown"}|${opts.contextResourceUri || ""}|${opts.resourceUri || ""}`;
|
|
@@ -5186,58 +4780,6 @@ function chatReducer(state, action) {
|
|
|
5186
4780
|
return state;
|
|
5187
4781
|
}
|
|
5188
4782
|
}
|
|
5189
|
-
|
|
5190
|
-
// src/headless/context/BotDojoChatProvider.tsx
|
|
5191
|
-
var import_sdk_types2 = __toESM(require_lib());
|
|
5192
|
-
|
|
5193
|
-
// ../../node_modules/.pnpm/uuid@10.0.0/node_modules/uuid/dist/esm-browser/stringify.js
|
|
5194
|
-
var byteToHex = [];
|
|
5195
|
-
for (i = 0; i < 256; ++i) {
|
|
5196
|
-
byteToHex.push((i + 256).toString(16).slice(1));
|
|
5197
|
-
}
|
|
5198
|
-
var i;
|
|
5199
|
-
function unsafeStringify(arr, offset = 0) {
|
|
5200
|
-
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|
5201
|
-
}
|
|
5202
|
-
|
|
5203
|
-
// ../../node_modules/.pnpm/uuid@10.0.0/node_modules/uuid/dist/esm-browser/rng.js
|
|
5204
|
-
var getRandomValues;
|
|
5205
|
-
var rnds8 = new Uint8Array(16);
|
|
5206
|
-
function rng() {
|
|
5207
|
-
if (!getRandomValues) {
|
|
5208
|
-
getRandomValues = typeof crypto !== "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
5209
|
-
if (!getRandomValues) {
|
|
5210
|
-
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
5211
|
-
}
|
|
5212
|
-
}
|
|
5213
|
-
return getRandomValues(rnds8);
|
|
5214
|
-
}
|
|
5215
|
-
|
|
5216
|
-
// ../../node_modules/.pnpm/uuid@10.0.0/node_modules/uuid/dist/esm-browser/native.js
|
|
5217
|
-
var randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
5218
|
-
var native_default = {
|
|
5219
|
-
randomUUID
|
|
5220
|
-
};
|
|
5221
|
-
|
|
5222
|
-
// ../../node_modules/.pnpm/uuid@10.0.0/node_modules/uuid/dist/esm-browser/v4.js
|
|
5223
|
-
function v4(options, buf, offset) {
|
|
5224
|
-
if (native_default.randomUUID && !buf && !options) {
|
|
5225
|
-
return native_default.randomUUID();
|
|
5226
|
-
}
|
|
5227
|
-
options = options || {};
|
|
5228
|
-
var rnds = options.random || (options.rng || rng)();
|
|
5229
|
-
rnds[6] = rnds[6] & 15 | 64;
|
|
5230
|
-
rnds[8] = rnds[8] & 63 | 128;
|
|
5231
|
-
if (buf) {
|
|
5232
|
-
offset = offset || 0;
|
|
5233
|
-
for (var i = 0; i < 16; ++i) {
|
|
5234
|
-
buf[offset + i] = rnds[i];
|
|
5235
|
-
}
|
|
5236
|
-
return buf;
|
|
5237
|
-
}
|
|
5238
|
-
return unsafeStringify(rnds);
|
|
5239
|
-
}
|
|
5240
|
-
var v4_default = v4;
|
|
5241
4783
|
var BotDojoChatContext = createContext(null);
|
|
5242
4784
|
function BotDojoChatProvider(props) {
|
|
5243
4785
|
const {
|
|
@@ -5255,6 +4797,8 @@ function BotDojoChatProvider(props) {
|
|
|
5255
4797
|
onConnectorError,
|
|
5256
4798
|
// Debug mode for MCP App rendering
|
|
5257
4799
|
debug = false,
|
|
4800
|
+
// Cache key for MCP proxy URLs
|
|
4801
|
+
cacheKey,
|
|
5258
4802
|
// MCP App handlers (SEP-1865)
|
|
5259
4803
|
onOpenLink,
|
|
5260
4804
|
onToolCall,
|
|
@@ -5264,7 +4808,7 @@ function BotDojoChatProvider(props) {
|
|
|
5264
4808
|
const iframeRef = useRef(null);
|
|
5265
4809
|
const [isIframeReady, setIsIframeReady] = useState(false);
|
|
5266
4810
|
const [isSocketConnected, setIsSocketConnected] = useState(false);
|
|
5267
|
-
const externalUIChannelIdRef = useRef(
|
|
4811
|
+
const externalUIChannelIdRef = useRef(generateUUID2());
|
|
5268
4812
|
const connectorRef = useRef(null);
|
|
5269
4813
|
const connectionRef = useRef(null);
|
|
5270
4814
|
const [connector, setConnector] = useState(null);
|
|
@@ -5293,6 +4837,10 @@ function BotDojoChatProvider(props) {
|
|
|
5293
4837
|
useEffect(() => {
|
|
5294
4838
|
modelContextRef.current = modelContext2;
|
|
5295
4839
|
}, [modelContext2]);
|
|
4840
|
+
const debugLog = useCallback((...args) => {
|
|
4841
|
+
if (debug)
|
|
4842
|
+
console.log("[BotDojoChatProvider]", ...args);
|
|
4843
|
+
}, [debug]);
|
|
5296
4844
|
const iframeUrl = useMemo(() => {
|
|
5297
4845
|
const url = new URL("/embed/headless", baseUrl);
|
|
5298
4846
|
url.searchParams.set("apiKey", apiKey);
|
|
@@ -5316,11 +4864,11 @@ function BotDojoChatProvider(props) {
|
|
|
5316
4864
|
}
|
|
5317
4865
|
}, [isSocketConnected, modelContext2]);
|
|
5318
4866
|
const handleIframeLoad = useCallback(() => {
|
|
5319
|
-
|
|
4867
|
+
debugLog(" Headless iframe loaded");
|
|
5320
4868
|
setIsIframeReady(true);
|
|
5321
4869
|
}, []);
|
|
5322
4870
|
const serializeModelContext = useCallback((ctx) => {
|
|
5323
|
-
const backendFormat =
|
|
4871
|
+
const backendFormat = translateModelContextToBackend(ctx);
|
|
5324
4872
|
const tools = (backendFormat.tools || []).map((tool2) => {
|
|
5325
4873
|
const { execute, ...toolWithoutExecute } = tool2;
|
|
5326
4874
|
return toolWithoutExecute;
|
|
@@ -5339,7 +4887,7 @@ function BotDojoChatProvider(props) {
|
|
|
5339
4887
|
const contexts = Array.isArray(modelContextRef.current) ? modelContextRef.current : [modelContextRef.current];
|
|
5340
4888
|
const ctx = contexts[0];
|
|
5341
4889
|
if (ctx) {
|
|
5342
|
-
|
|
4890
|
+
debugLog(" Sending model context to HeadlessEmbed:", ctx.name);
|
|
5343
4891
|
iframeRef.current.contentWindow.postMessage({
|
|
5344
4892
|
type: "set_model_context",
|
|
5345
4893
|
modelContext: serializeModelContext(ctx)
|
|
@@ -5544,7 +5092,7 @@ function BotDojoChatProvider(props) {
|
|
|
5544
5092
|
throw new Error(`Tool not found: ${toolName}`);
|
|
5545
5093
|
}, []);
|
|
5546
5094
|
const getMcpAppData = useCallback((appId) => {
|
|
5547
|
-
var _a, _b, _c, _d;
|
|
5095
|
+
var _a, _b, _c, _d, _e;
|
|
5548
5096
|
const cached = mcpAppDataCacheRef.current.get(appId);
|
|
5549
5097
|
if (cached == null ? void 0 : cached.url) {
|
|
5550
5098
|
return { mcpAppId: appId, mcpAppType: "mcp-app", ...cached };
|
|
@@ -5555,9 +5103,28 @@ function BotDojoChatProvider(props) {
|
|
|
5555
5103
|
const canvasUrl = (_b = step.canvas.canvasData) == null ? void 0 : _b.url;
|
|
5556
5104
|
let proxyUrl;
|
|
5557
5105
|
if (canvasUrl == null ? void 0 : canvasUrl.startsWith("ui://")) {
|
|
5558
|
-
const flowId =
|
|
5106
|
+
const flowId = cacheKey || appId;
|
|
5107
|
+
let noCache = false;
|
|
5108
|
+
const toolName = step.stepToolName;
|
|
5109
|
+
debugLog(" Checking no-cache for tool:", toolName, "modelContextRef:", !!modelContextRef.current);
|
|
5110
|
+
if (toolName && modelContextRef.current) {
|
|
5111
|
+
const contexts = Array.isArray(modelContextRef.current) ? modelContextRef.current : [modelContextRef.current];
|
|
5112
|
+
for (const ctx of contexts) {
|
|
5113
|
+
const tools = ctx.tools;
|
|
5114
|
+
debugLog(" Context tools:", Array.isArray(tools) ? tools.length : "not array");
|
|
5115
|
+
if (Array.isArray(tools)) {
|
|
5116
|
+
const tool2 = tools.find((t) => t.name === toolName);
|
|
5117
|
+
debugLog(" Found tool:", tool2 == null ? void 0 : tool2.name, "_meta:", tool2 == null ? void 0 : tool2._meta);
|
|
5118
|
+
if ((_c = tool2 == null ? void 0 : tool2._meta) == null ? void 0 : _c["botdojo/no-cache"]) {
|
|
5119
|
+
noCache = true;
|
|
5120
|
+
break;
|
|
5121
|
+
}
|
|
5122
|
+
}
|
|
5123
|
+
}
|
|
5124
|
+
}
|
|
5125
|
+
debugLog(" noCache result:", noCache);
|
|
5559
5126
|
try {
|
|
5560
|
-
proxyUrl = buildMcpProxyUrl({ flowId: String(flowId), resource: canvasUrl });
|
|
5127
|
+
proxyUrl = buildMcpProxyUrl({ flowId: String(flowId), resource: canvasUrl, noCache });
|
|
5561
5128
|
} catch (err) {
|
|
5562
5129
|
console.warn("[BotDojoChatProvider] Failed to build proxy URL for hydration:", err);
|
|
5563
5130
|
}
|
|
@@ -5570,8 +5137,8 @@ function BotDojoChatProvider(props) {
|
|
|
5570
5137
|
toolInfo: step.stepToolName ? { tool: { name: step.stepToolName } } : void 0,
|
|
5571
5138
|
arguments: step.stepToolArguments,
|
|
5572
5139
|
result: step.stepToolResult,
|
|
5573
|
-
height: (
|
|
5574
|
-
width: (
|
|
5140
|
+
height: (_d = step.canvas.canvasData) == null ? void 0 : _d.height,
|
|
5141
|
+
width: (_e = step.canvas.canvasData) == null ? void 0 : _e.width,
|
|
5575
5142
|
...cached
|
|
5576
5143
|
// Merge any partial cached data
|
|
5577
5144
|
};
|
|
@@ -5586,24 +5153,24 @@ function BotDojoChatProvider(props) {
|
|
|
5586
5153
|
setMcpAppDataVersion((v) => v + 1);
|
|
5587
5154
|
}, []);
|
|
5588
5155
|
const getResource = useCallback(async (uri, params, onlyMetadata) => {
|
|
5589
|
-
|
|
5156
|
+
debugLog(" getResource called for URI:", uri);
|
|
5590
5157
|
const ctx = modelContextRef.current;
|
|
5591
5158
|
if (!ctx) {
|
|
5592
5159
|
console.error("[BotDojoChatProvider] getResource: No model context available");
|
|
5593
5160
|
throw new Error("No model context available");
|
|
5594
5161
|
}
|
|
5595
5162
|
const contexts = Array.isArray(ctx) ? ctx : [ctx];
|
|
5596
|
-
|
|
5163
|
+
debugLog(" getResource: Searching", contexts.length, "context(s)");
|
|
5597
5164
|
for (const context of contexts) {
|
|
5598
5165
|
if (context.resources) {
|
|
5599
|
-
|
|
5166
|
+
debugLog(" getResource: Context has", context.resources.length, "resources");
|
|
5600
5167
|
for (const resource of context.resources) {
|
|
5601
5168
|
const resourceUri = "uri" in resource ? resource.uri : "no-uri";
|
|
5602
|
-
|
|
5169
|
+
debugLog(" getResource: Checking resource URI:", resourceUri, "=== requested URI:", uri, "?", resourceUri === uri);
|
|
5603
5170
|
if ("uri" in resource && resource.uri === uri && resource.getContent) {
|
|
5604
|
-
|
|
5171
|
+
debugLog(" getResource: MATCH FOUND! Calling getContent()");
|
|
5605
5172
|
const content = await resource.getContent();
|
|
5606
|
-
|
|
5173
|
+
debugLog(" getResource: getContent returned:", typeof content, typeof content === "object" && content && "uri" in content ? content.uri : "(no uri)");
|
|
5607
5174
|
return {
|
|
5608
5175
|
uri,
|
|
5609
5176
|
mimeType: resource.mimeType,
|
|
@@ -5617,9 +5184,9 @@ function BotDojoChatProvider(props) {
|
|
|
5617
5184
|
throw new Error(`Resource not found: ${uri}`);
|
|
5618
5185
|
}, []);
|
|
5619
5186
|
const registerMcpApp = useCallback((appId, iframeWindow) => {
|
|
5620
|
-
|
|
5187
|
+
debugLog(" Registering MCP App iframe:", appId);
|
|
5621
5188
|
if (appBridgesRef.current.has(appId)) {
|
|
5622
|
-
|
|
5189
|
+
debugLog(" MCP App already registered, refreshing bridge:", appId);
|
|
5623
5190
|
const existingBridge = appBridgesRef.current.get(appId);
|
|
5624
5191
|
existingBridge == null ? void 0 : existingBridge.stop();
|
|
5625
5192
|
appBridgesRef.current.delete(appId);
|
|
@@ -5633,13 +5200,13 @@ function BotDojoChatProvider(props) {
|
|
|
5633
5200
|
role: "parent",
|
|
5634
5201
|
onMessage: async (msg) => {
|
|
5635
5202
|
var _a;
|
|
5636
|
-
|
|
5203
|
+
debugLog(" Message from MCP App:", appId, msg.functionName);
|
|
5637
5204
|
if (msg.functionName.startsWith("tool_")) {
|
|
5638
5205
|
const toolName = msg.functionName.substring(5);
|
|
5639
5206
|
if (connectorRef.current) {
|
|
5640
|
-
|
|
5207
|
+
debugLog(" Tool call from app:", toolName, msg.data);
|
|
5641
5208
|
} else {
|
|
5642
|
-
|
|
5209
|
+
debugLog(" Forwarding tool call to server:", toolName);
|
|
5643
5210
|
if ((_a = iframeRef.current) == null ? void 0 : _a.contentWindow) {
|
|
5644
5211
|
iframeRef.current.contentWindow.postMessage(
|
|
5645
5212
|
{
|
|
@@ -5663,7 +5230,7 @@ function BotDojoChatProvider(props) {
|
|
|
5663
5230
|
setRegisteredMcpApps((prev) => new Set(prev).add(appId));
|
|
5664
5231
|
const pending = pendingAppEventsRef.current.get(appId);
|
|
5665
5232
|
if (pending && pending.length > 0) {
|
|
5666
|
-
|
|
5233
|
+
debugLog(" Sending pending events to app:", appId, pending.length);
|
|
5667
5234
|
pending.forEach((event) => {
|
|
5668
5235
|
bridge.sendMessage(RPCMessage.request(
|
|
5669
5236
|
`parent-to-app-${appId}`,
|
|
@@ -5674,10 +5241,10 @@ function BotDojoChatProvider(props) {
|
|
|
5674
5241
|
});
|
|
5675
5242
|
pendingAppEventsRef.current.delete(appId);
|
|
5676
5243
|
}
|
|
5677
|
-
|
|
5244
|
+
debugLog(" MCP App registered successfully:", appId);
|
|
5678
5245
|
}, [baseUrl]);
|
|
5679
5246
|
const unregisterMcpApp = useCallback((appId) => {
|
|
5680
|
-
|
|
5247
|
+
debugLog(" Unregistering MCP App iframe:", appId);
|
|
5681
5248
|
const bridge = appBridgesRef.current.get(appId);
|
|
5682
5249
|
if (bridge) {
|
|
5683
5250
|
bridge.stop();
|
|
@@ -5694,7 +5261,7 @@ function BotDojoChatProvider(props) {
|
|
|
5694
5261
|
const forwardEventToApp = useCallback((appId, eventName, data) => {
|
|
5695
5262
|
const bridge = appBridgesRef.current.get(appId);
|
|
5696
5263
|
if (bridge) {
|
|
5697
|
-
|
|
5264
|
+
debugLog(" Forwarding event to app:", appId, eventName);
|
|
5698
5265
|
bridge.sendMessage(RPCMessage.request(
|
|
5699
5266
|
`parent-to-app-${appId}`,
|
|
5700
5267
|
"app",
|
|
@@ -5702,7 +5269,7 @@ function BotDojoChatProvider(props) {
|
|
|
5702
5269
|
data
|
|
5703
5270
|
));
|
|
5704
5271
|
} else {
|
|
5705
|
-
|
|
5272
|
+
debugLog(" Queueing event for app (not ready):", appId, eventName);
|
|
5706
5273
|
if (!pendingAppEventsRef.current.has(appId)) {
|
|
5707
5274
|
pendingAppEventsRef.current.set(appId, []);
|
|
5708
5275
|
}
|
|
@@ -5727,23 +5294,23 @@ function BotDojoChatProvider(props) {
|
|
|
5727
5294
|
if ((_a = data.type) == null ? void 0 : _a.startsWith("botdojo-")) {
|
|
5728
5295
|
return;
|
|
5729
5296
|
}
|
|
5730
|
-
|
|
5297
|
+
debugLog(" Received event:", data.type, data);
|
|
5731
5298
|
switch (data.type) {
|
|
5732
5299
|
case "socket_connected":
|
|
5733
|
-
|
|
5300
|
+
debugLog(" HeadlessEmbed Socket.IO connected");
|
|
5734
5301
|
setIsSocketConnected(true);
|
|
5735
5302
|
sendModelContextToHeadless();
|
|
5736
5303
|
break;
|
|
5737
5304
|
case "request_model_context":
|
|
5738
|
-
|
|
5305
|
+
debugLog(" HeadlessEmbed requesting model context");
|
|
5739
5306
|
sendModelContextToHeadless();
|
|
5740
5307
|
break;
|
|
5741
5308
|
case "get_model_contexts":
|
|
5742
|
-
|
|
5309
|
+
debugLog(" HeadlessEmbed requesting all model contexts");
|
|
5743
5310
|
sendModelContextToHeadless();
|
|
5744
5311
|
break;
|
|
5745
5312
|
case "tool_call":
|
|
5746
|
-
|
|
5313
|
+
debugLog(" Tool call from HeadlessEmbed:", data.toolName, "appId:", data.appId || data.canvasId || "none");
|
|
5747
5314
|
(async () => {
|
|
5748
5315
|
var _a2, _b, _c, _d;
|
|
5749
5316
|
try {
|
|
@@ -5765,7 +5332,7 @@ function BotDojoChatProvider(props) {
|
|
|
5765
5332
|
})();
|
|
5766
5333
|
break;
|
|
5767
5334
|
case "get_resource":
|
|
5768
|
-
|
|
5335
|
+
debugLog(" Resource request from HeadlessEmbed:", data.uri);
|
|
5769
5336
|
(async () => {
|
|
5770
5337
|
var _a2, _b, _c, _d;
|
|
5771
5338
|
try {
|
|
@@ -5786,7 +5353,7 @@ function BotDojoChatProvider(props) {
|
|
|
5786
5353
|
})();
|
|
5787
5354
|
break;
|
|
5788
5355
|
case "model_context_registered":
|
|
5789
|
-
|
|
5356
|
+
debugLog(" \u2705 Model context registered:", data.name);
|
|
5790
5357
|
setIsModelContextRegistered(true);
|
|
5791
5358
|
onConnectorInit == null ? void 0 : onConnectorInit(null);
|
|
5792
5359
|
break;
|
|
@@ -5835,7 +5402,7 @@ function BotDojoChatProvider(props) {
|
|
|
5835
5402
|
case "step_update":
|
|
5836
5403
|
const rawStep = data.step;
|
|
5837
5404
|
if (rawStep == null ? void 0 : rawStep.canvas) {
|
|
5838
|
-
|
|
5405
|
+
debugLog(" Step has MCP App:", rawStep.canvas.canvasId, rawStep.canvas.canvasType, JSON.stringify(rawStep.canvas.canvasData, null, 2));
|
|
5839
5406
|
const toolName = rawStep.stepToolName || rawStep.stepLabel;
|
|
5840
5407
|
const appId = rawStep.canvas.canvasId;
|
|
5841
5408
|
if (toolName && appId) {
|
|
@@ -5847,20 +5414,20 @@ function BotDojoChatProvider(props) {
|
|
|
5847
5414
|
}
|
|
5848
5415
|
}
|
|
5849
5416
|
(async () => {
|
|
5850
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
5417
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
5851
5418
|
let stepToDispatch = rawStep;
|
|
5852
5419
|
const canvasUrl = (_b = (_a2 = rawStep == null ? void 0 : rawStep.canvas) == null ? void 0 : _a2.canvasData) == null ? void 0 : _b.url;
|
|
5853
5420
|
if (canvasUrl && canvasUrl.startsWith("ui://") && !((_d = (_c = rawStep == null ? void 0 : rawStep.canvas) == null ? void 0 : _c.canvasData) == null ? void 0 : _d.html)) {
|
|
5854
|
-
|
|
5421
|
+
debugLog(" Resolving ui:// resource:", canvasUrl);
|
|
5855
5422
|
try {
|
|
5856
5423
|
const resource = await getResource(canvasUrl);
|
|
5857
|
-
|
|
5424
|
+
debugLog(" Resource result:", resource ? "got content" : "no content");
|
|
5858
5425
|
let htmlContent = (resource == null ? void 0 : resource.text) || (resource == null ? void 0 : resource.content);
|
|
5859
5426
|
if (htmlContent) {
|
|
5860
5427
|
const cspMeta = extractUiCspFromResource(resource);
|
|
5861
5428
|
if (cspMeta) {
|
|
5862
5429
|
const resolvedCsp = resolveUiCsp(cspMeta);
|
|
5863
|
-
|
|
5430
|
+
debugLog(" Injecting CSP into HTML:", resolvedCsp.csp.substring(0, 100) + "...");
|
|
5864
5431
|
const cspMetaTag = `<meta http-equiv="Content-Security-Policy" content="${resolvedCsp.csp.replace(/"/g, """)}">`;
|
|
5865
5432
|
if (/<head[^>]*>/i.test(htmlContent)) {
|
|
5866
5433
|
htmlContent = htmlContent.replace(/<head([^>]*)>/i, `<head$1>
|
|
@@ -5888,17 +5455,38 @@ ${htmlContent}`;
|
|
|
5888
5455
|
}
|
|
5889
5456
|
}
|
|
5890
5457
|
};
|
|
5891
|
-
|
|
5458
|
+
debugLog(" \u2705 Resolved ui:// resource to HTML (" + htmlContent.length + " chars)");
|
|
5892
5459
|
let proxyUrl;
|
|
5893
5460
|
const proxyOrigin = process.env.NEXT_PUBLIC_MCP_HTML_PROXY_ORIGIN || void 0;
|
|
5894
|
-
const
|
|
5461
|
+
const canvasId = (_e = rawStep.canvas) == null ? void 0 : _e.canvasId;
|
|
5462
|
+
const flowIdForProxy = cacheKey || canvasId || `unknown-${generateUUID2()}`;
|
|
5463
|
+
let noCache = false;
|
|
5464
|
+
const toolNameForMeta = rawStep.stepToolName || rawStep.stepLabel;
|
|
5465
|
+
debugLog(" handleStepUpdate - Checking no-cache for tool:", toolNameForMeta, "modelContextRef:", !!modelContextRef.current);
|
|
5466
|
+
if (toolNameForMeta && modelContextRef.current) {
|
|
5467
|
+
const contexts = Array.isArray(modelContextRef.current) ? modelContextRef.current : [modelContextRef.current];
|
|
5468
|
+
for (const ctx of contexts) {
|
|
5469
|
+
const tools = ctx.tools;
|
|
5470
|
+
debugLog(" handleStepUpdate - Context tools:", Array.isArray(tools) ? tools.length : "not array");
|
|
5471
|
+
if (Array.isArray(tools)) {
|
|
5472
|
+
const tool2 = tools.find((t) => t.name === toolNameForMeta);
|
|
5473
|
+
debugLog(" handleStepUpdate - Found tool:", tool2 == null ? void 0 : tool2.name, "_meta:", JSON.stringify(tool2 == null ? void 0 : tool2._meta));
|
|
5474
|
+
if ((_f = tool2 == null ? void 0 : tool2._meta) == null ? void 0 : _f["botdojo/no-cache"]) {
|
|
5475
|
+
noCache = true;
|
|
5476
|
+
break;
|
|
5477
|
+
}
|
|
5478
|
+
}
|
|
5479
|
+
}
|
|
5480
|
+
}
|
|
5481
|
+
debugLog(" handleStepUpdate - noCache result:", noCache);
|
|
5895
5482
|
try {
|
|
5896
5483
|
proxyUrl = buildMcpProxyUrl({
|
|
5897
5484
|
flowId: String(flowIdForProxy),
|
|
5898
5485
|
resource: canvasUrl,
|
|
5899
|
-
...proxyOrigin ? { origin: proxyOrigin } : {}
|
|
5486
|
+
...proxyOrigin ? { origin: proxyOrigin } : {},
|
|
5487
|
+
noCache
|
|
5900
5488
|
});
|
|
5901
|
-
|
|
5489
|
+
debugLog(" Using MCP proxy URL:", proxyUrl, noCache ? "(no-cache)" : "");
|
|
5902
5490
|
} catch (err) {
|
|
5903
5491
|
console.warn("[BotDojoChatProvider] Failed to build MCP proxy URL", err);
|
|
5904
5492
|
}
|
|
@@ -5909,8 +5497,8 @@ ${htmlContent}`;
|
|
|
5909
5497
|
html: htmlContent,
|
|
5910
5498
|
url: proxyUrl || canvasUrl,
|
|
5911
5499
|
toolInfo: toolNameForCache ? { tool: { name: toolNameForCache } } : void 0,
|
|
5912
|
-
height: (
|
|
5913
|
-
width: (
|
|
5500
|
+
height: (_g = rawStep.canvas.canvasData) == null ? void 0 : _g.height,
|
|
5501
|
+
width: (_h = rawStep.canvas.canvasData) == null ? void 0 : _h.width
|
|
5914
5502
|
});
|
|
5915
5503
|
}
|
|
5916
5504
|
} else {
|
|
@@ -5926,7 +5514,7 @@ ${htmlContent}`;
|
|
|
5926
5514
|
messageId: data.messageId,
|
|
5927
5515
|
step: stepToDispatch
|
|
5928
5516
|
});
|
|
5929
|
-
const appIdFromCanvas = (
|
|
5517
|
+
const appIdFromCanvas = (_i = stepToDispatch == null ? void 0 : stepToDispatch.canvas) == null ? void 0 : _i.canvasId;
|
|
5930
5518
|
const appIdFromStepId = (stepToDispatch == null ? void 0 : stepToDispatch.stepId) ? stepIdToAppIdRef.current.get(stepToDispatch.stepId) : void 0;
|
|
5931
5519
|
const toolNameForLookup = (stepToDispatch == null ? void 0 : stepToDispatch.stepToolName) || (stepToDispatch == null ? void 0 : stepToDispatch.stepLabel);
|
|
5932
5520
|
const appIdFromToolName = toolNameForLookup ? activeAppByToolRef.current.get(toolNameForLookup) : void 0;
|
|
@@ -5947,12 +5535,12 @@ ${htmlContent}`;
|
|
|
5947
5535
|
}
|
|
5948
5536
|
return value;
|
|
5949
5537
|
};
|
|
5950
|
-
const canvasResult = parseIfJson((
|
|
5538
|
+
const canvasResult = parseIfJson((_k = (_j = stepToDispatch == null ? void 0 : stepToDispatch.canvas) == null ? void 0 : _j.canvasData) == null ? void 0 : _k.result);
|
|
5951
5539
|
const rawStepResult = stepToDispatch.stepToolResult;
|
|
5952
5540
|
const stepResult = rawStepResult !== void 0 && rawStepResult !== "" ? parseIfJson(rawStepResult) : canvasResult !== void 0 ? canvasResult : parseIfJson(stepToDispatch.content);
|
|
5953
5541
|
const rawStepArgs = stepToDispatch.stepToolArguments;
|
|
5954
5542
|
const rawArgsString = stepToDispatch.arguments;
|
|
5955
|
-
const canvasArgs = (
|
|
5543
|
+
const canvasArgs = (_m = (_l = stepToDispatch == null ? void 0 : stepToDispatch.canvas) == null ? void 0 : _l.canvasData) == null ? void 0 : _m.arguments;
|
|
5956
5544
|
let stepArguments = rawStepArgs && typeof rawStepArgs === "object" ? rawStepArgs : null;
|
|
5957
5545
|
if (!stepArguments && rawArgsString && rawArgsString.trim()) {
|
|
5958
5546
|
try {
|
|
@@ -6395,9 +5983,6 @@ function useMcpHostBridge(options) {
|
|
|
6395
5983
|
}, [toolInfo, toolArguments, toolResult, isComplete, log]);
|
|
6396
5984
|
const handleMessage = useCallback((event) => {
|
|
6397
5985
|
var _a;
|
|
6398
|
-
if (debug) {
|
|
6399
|
-
console.log(`[useMcpHostBridge:${appId}] raw message`, { origin: event.origin, data: event.data });
|
|
6400
|
-
}
|
|
6401
5986
|
if (!event.data || event.data.jsonrpc !== "2.0")
|
|
6402
5987
|
return;
|
|
6403
5988
|
const data = event.data;
|
|
@@ -6425,15 +6010,71 @@ function useMcpHostBridge(options) {
|
|
|
6425
6010
|
}
|
|
6426
6011
|
case "ui/notifications/sandbox-ready":
|
|
6427
6012
|
case "ui/notifications/sandbox-proxy-ready": {
|
|
6428
|
-
|
|
6013
|
+
const loadedFromCache = params == null ? void 0 : params.loadedFromCache;
|
|
6429
6014
|
const resource = params == null ? void 0 : params.resource;
|
|
6430
|
-
|
|
6431
|
-
|
|
6015
|
+
const flowId = params == null ? void 0 : params.flowId;
|
|
6016
|
+
log("Proxy reported sandbox-ready, loadedFromCache:", loadedFromCache, "resource:", resource);
|
|
6017
|
+
if (loadedFromCache) {
|
|
6018
|
+
log("Proxy loaded from cache, skipping sandbox-resource-ready");
|
|
6019
|
+
break;
|
|
6020
|
+
}
|
|
6021
|
+
if (!resource) {
|
|
6022
|
+
log("No resource in sandbox-ready, cannot send HTML");
|
|
6023
|
+
break;
|
|
6024
|
+
}
|
|
6025
|
+
const cacheKey = `${flowId || "unknown"}|${resource}`;
|
|
6026
|
+
if (sandboxResourceCacheRef.current.has(cacheKey)) {
|
|
6027
|
+
const cached = sandboxResourceCacheRef.current.get(cacheKey);
|
|
6028
|
+
log("Using cached sandbox resource for:", resource);
|
|
6432
6029
|
sendNotification("ui/notifications/sandbox-resource-ready", {
|
|
6433
6030
|
resource,
|
|
6031
|
+
flowId,
|
|
6032
|
+
...cached
|
|
6033
|
+
});
|
|
6034
|
+
break;
|
|
6035
|
+
}
|
|
6036
|
+
if (html) {
|
|
6037
|
+
log("Using inline HTML for sandbox-ready:", resource);
|
|
6038
|
+
const entry = {
|
|
6434
6039
|
html,
|
|
6435
6040
|
sandbox: "allow-scripts allow-same-origin"
|
|
6041
|
+
};
|
|
6042
|
+
sandboxResourceCacheRef.current.set(cacheKey, entry);
|
|
6043
|
+
sendNotification("ui/notifications/sandbox-resource-ready", {
|
|
6044
|
+
resource,
|
|
6045
|
+
flowId,
|
|
6046
|
+
...entry
|
|
6436
6047
|
});
|
|
6048
|
+
break;
|
|
6049
|
+
}
|
|
6050
|
+
if (onSandboxResourceRequest) {
|
|
6051
|
+
(async () => {
|
|
6052
|
+
try {
|
|
6053
|
+
log("Calling onSandboxResourceRequest for sandbox-ready:", resource);
|
|
6054
|
+
const resolved = await onSandboxResourceRequest({ resource, flowId });
|
|
6055
|
+
const payload = typeof resolved === "string" ? { html: resolved } : resolved;
|
|
6056
|
+
if (payload == null ? void 0 : payload.html) {
|
|
6057
|
+
log("Got HTML from onSandboxResourceRequest for:", resource, "length:", payload.html.length);
|
|
6058
|
+
const entry = {
|
|
6059
|
+
html: payload.html,
|
|
6060
|
+
sandbox: payload.sandbox || "allow-scripts allow-same-origin",
|
|
6061
|
+
csp: payload.csp
|
|
6062
|
+
};
|
|
6063
|
+
sandboxResourceCacheRef.current.set(cacheKey, entry);
|
|
6064
|
+
sendNotification("ui/notifications/sandbox-resource-ready", {
|
|
6065
|
+
resource,
|
|
6066
|
+
flowId,
|
|
6067
|
+
...entry
|
|
6068
|
+
});
|
|
6069
|
+
} else {
|
|
6070
|
+
log("onSandboxResourceRequest returned no HTML for:", resource);
|
|
6071
|
+
}
|
|
6072
|
+
} catch (err) {
|
|
6073
|
+
console.warn("[useMcpHostBridge] Failed to resolve sandbox resource on sandbox-ready:", err);
|
|
6074
|
+
}
|
|
6075
|
+
})();
|
|
6076
|
+
} else {
|
|
6077
|
+
log("No onSandboxResourceRequest handler and no inline HTML for:", resource);
|
|
6437
6078
|
}
|
|
6438
6079
|
break;
|
|
6439
6080
|
}
|
|
@@ -7127,9 +6768,6 @@ function extractMcpAppData(step, options) {
|
|
|
7127
6768
|
toolInfo: toolName ? { tool: { name: toolName } } : void 0
|
|
7128
6769
|
};
|
|
7129
6770
|
}
|
|
7130
|
-
|
|
7131
|
-
// src/index.tsx
|
|
7132
|
-
var import_sdk_types3 = __toESM(require_lib());
|
|
7133
6771
|
var CanvasContext = createContext(null);
|
|
7134
6772
|
var DEFAULT_ACK_TTL_MS = 3 * 60 * 1e3;
|
|
7135
6773
|
var DEFAULT_RESPONSE_TIMEOUT_MS = 2e4;
|
|
@@ -8017,16 +7655,7 @@ function useBotDojoCanvas() {
|
|
|
8017
7655
|
}
|
|
8018
7656
|
return context;
|
|
8019
7657
|
}
|
|
8020
|
-
var export_MIME_TYPES = import_sdk_types3.MIME_TYPES;
|
|
8021
|
-
var export_citation = import_sdk_types3.citation;
|
|
8022
|
-
var export_citations = import_sdk_types3.citations;
|
|
8023
|
-
var export_imageResult = import_sdk_types3.imageResult;
|
|
8024
|
-
var export_mcpResource = import_sdk_types3.mcpResource;
|
|
8025
|
-
var export_modelContext = import_sdk_types3.modelContext;
|
|
8026
|
-
var export_textResult = import_sdk_types3.textResult;
|
|
8027
|
-
var export_tool = import_sdk_types3.tool;
|
|
8028
|
-
var export_uiResource = import_sdk_types3.uiResource;
|
|
8029
7658
|
|
|
8030
|
-
export { BotDojoCanvasFrame, BotDojoCanvasProvider, BotDojoChat, BotDojoChatProvider, BotDojoConnector, DEFAULT_MCP_HOST_CAPABILITIES, HeadlessChat,
|
|
7659
|
+
export { BotDojoCanvasFrame, BotDojoCanvasProvider, BotDojoChat, BotDojoChatProvider, BotDojoConnector, DEFAULT_MCP_HOST_CAPABILITIES, HeadlessChat, MIME_TYPES, McpAppHost, McpAppHostContext, McpAppHostProvider, MockCanvasProvider, RequestEvents, buildMcpCacheKey, buildMcpProxyUrl, citation, citations, createMcpHtmlProxy, extractMcpAppData, extractUiCspFromResource, getContentKey, imageResult, mcpResource, modelContext, parseMaybeJson2 as parseMaybeJson, processStepUpdate, resolveUiCsp, textResult, tool, uiResource, useBotDojoCanvas, useBotDojoChat, useChatActions, useChatMessages, useChatStatus, useMcpAppHost, useMcpAppHostRequired, useMcpHostBridge, validateToolParams };
|
|
8031
7660
|
//# sourceMappingURL=out.js.map
|
|
8032
7661
|
//# sourceMappingURL=index.js.map
|