@copilotkit/mcp-apps-renderer 2.0.0-rc.4 → 2.0.0-rc.41
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/dist/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/activity.cjs +6 -0
- package/dist/activity.d.cts +2 -1
- package/dist/activity.d.mts +2 -1
- package/dist/activity.mjs +2 -1
- package/dist/activity.umd.js +369 -35
- package/dist/activity.umd.js.map +1 -1
- package/dist/content-schema.cjs +37 -35
- package/dist/content-schema.cjs.map +1 -1
- package/dist/content-schema.d.cts +40 -3309
- package/dist/content-schema.d.cts.map +1 -1
- package/dist/content-schema.d.mts +40 -3309
- package/dist/content-schema.d.mts.map +1 -1
- package/dist/content-schema.mjs +2 -2
- package/dist/content-schema.mjs.map +1 -1
- package/dist/host.cjs +246 -0
- package/dist/host.cjs.map +1 -0
- package/dist/host.d.cts +99 -0
- package/dist/host.d.cts.map +1 -0
- package/dist/host.d.mts +99 -0
- package/dist/host.d.mts.map +1 -0
- package/dist/host.mjs +241 -0
- package/dist/host.mjs.map +1 -0
- package/dist/request-queue.mjs.map +1 -1
- package/dist/session.d.cts +172 -0
- package/dist/session.d.cts.map +1 -0
- package/dist/session.d.mts +1 -58
- package/dist/session.d.mts.map +1 -1
- package/dist/session.mjs +2 -2
- package/dist/session.mjs.map +1 -1
- package/package.json +17 -8
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
|
|
29
|
+
exports.__toESM = __toESM;
|
package/dist/activity.cjs
CHANGED
|
@@ -2,8 +2,14 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
const require_constants = require('./constants.cjs');
|
|
3
3
|
const require_content_schema = require('./content-schema.cjs');
|
|
4
4
|
const require_follow_up = require('./follow-up.cjs');
|
|
5
|
+
const require_host = require('./host.cjs');
|
|
5
6
|
|
|
6
7
|
exports.MCPAppsActivityContentSchema = require_content_schema.MCPAppsActivityContentSchema;
|
|
7
8
|
exports.MCPAppsActivityType = require_constants.MCPAppsActivityType;
|
|
8
9
|
exports.MCP_OPEN_LINK_BLOCKED_SCHEMES = require_constants.MCP_OPEN_LINK_BLOCKED_SCHEMES;
|
|
10
|
+
exports.ɵMCP_APPS_NO_AGENT_MESSAGE = require_host.MCP_APPS_NO_AGENT_MESSAGE;
|
|
11
|
+
exports.ɵMCP_APPS_RENDERER_MISSING_MESSAGE = require_host.MCP_APPS_RENDERER_MISSING_MESSAGE;
|
|
12
|
+
exports.ɵMCP_APP_MAX_HEIGHT = require_host.MCP_APP_MAX_HEIGHT;
|
|
13
|
+
exports.ɵMcpAppHost = require_host.McpAppHost;
|
|
14
|
+
exports.ɵloadMcpAppsRenderer = require_host.loadMcpAppsRenderer;
|
|
9
15
|
exports.ɵrunMcpFollowUp = require_follow_up.ɵrunMcpFollowUp;
|
package/dist/activity.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MCPAppsActivityType, MCP_OPEN_LINK_BLOCKED_SCHEMES } from "./constants.cjs";
|
|
2
2
|
import { MCPAppsActivityContent, MCPAppsActivityContentSchema } from "./content-schema.cjs";
|
|
3
3
|
import { ɵMcpFollowUpHost, ɵrunMcpFollowUp } from "./follow-up.cjs";
|
|
4
|
-
|
|
4
|
+
import { MCP_APPS_NO_AGENT_MESSAGE, MCP_APPS_RENDERER_MISSING_MESSAGE, MCP_APP_MAX_HEIGHT, McpAppHost, McpAppHostOptions, McpAppHostState, McpAppsRendererImporter, loadMcpAppsRenderer } from "./host.cjs";
|
|
5
|
+
export { MCPAppsActivityContent, MCPAppsActivityContentSchema, MCPAppsActivityType, MCP_OPEN_LINK_BLOCKED_SCHEMES, MCP_APPS_NO_AGENT_MESSAGE as ɵMCP_APPS_NO_AGENT_MESSAGE, MCP_APPS_RENDERER_MISSING_MESSAGE as ɵMCP_APPS_RENDERER_MISSING_MESSAGE, MCP_APP_MAX_HEIGHT as ɵMCP_APP_MAX_HEIGHT, McpAppHost as ɵMcpAppHost, type McpAppHostOptions as ɵMcpAppHostOptions, type McpAppHostState as ɵMcpAppHostState, type McpAppsRendererImporter as ɵMcpAppsRendererImporter, ɵMcpFollowUpHost, loadMcpAppsRenderer as ɵloadMcpAppsRenderer, ɵrunMcpFollowUp };
|
package/dist/activity.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MCPAppsActivityType, MCP_OPEN_LINK_BLOCKED_SCHEMES } from "./constants.mjs";
|
|
2
2
|
import { MCPAppsActivityContent, MCPAppsActivityContentSchema } from "./content-schema.mjs";
|
|
3
3
|
import { ɵMcpFollowUpHost, ɵrunMcpFollowUp } from "./follow-up.mjs";
|
|
4
|
-
|
|
4
|
+
import { MCP_APPS_NO_AGENT_MESSAGE, MCP_APPS_RENDERER_MISSING_MESSAGE, MCP_APP_MAX_HEIGHT, McpAppHost, McpAppHostOptions, McpAppHostState, McpAppsRendererImporter, loadMcpAppsRenderer } from "./host.mjs";
|
|
5
|
+
export { MCPAppsActivityContent, MCPAppsActivityContentSchema, MCPAppsActivityType, MCP_OPEN_LINK_BLOCKED_SCHEMES, MCP_APPS_NO_AGENT_MESSAGE as ɵMCP_APPS_NO_AGENT_MESSAGE, MCP_APPS_RENDERER_MISSING_MESSAGE as ɵMCP_APPS_RENDERER_MISSING_MESSAGE, MCP_APP_MAX_HEIGHT as ɵMCP_APP_MAX_HEIGHT, McpAppHost as ɵMcpAppHost, type McpAppHostOptions as ɵMcpAppHostOptions, type McpAppHostState as ɵMcpAppHostState, type McpAppsRendererImporter as ɵMcpAppsRendererImporter, ɵMcpFollowUpHost, loadMcpAppsRenderer as ɵloadMcpAppsRenderer, ɵrunMcpFollowUp };
|
package/dist/activity.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MCPAppsActivityType, MCP_OPEN_LINK_BLOCKED_SCHEMES } from "./constants.mjs";
|
|
2
2
|
import { MCPAppsActivityContentSchema } from "./content-schema.mjs";
|
|
3
3
|
import { ɵrunMcpFollowUp } from "./follow-up.mjs";
|
|
4
|
+
import { MCP_APPS_NO_AGENT_MESSAGE, MCP_APPS_RENDERER_MISSING_MESSAGE, MCP_APP_MAX_HEIGHT, McpAppHost, loadMcpAppsRenderer } from "./host.mjs";
|
|
4
5
|
|
|
5
|
-
export { MCPAppsActivityContentSchema, MCPAppsActivityType, MCP_OPEN_LINK_BLOCKED_SCHEMES, ɵrunMcpFollowUp };
|
|
6
|
+
export { MCPAppsActivityContentSchema, MCPAppsActivityType, MCP_OPEN_LINK_BLOCKED_SCHEMES, MCP_APPS_NO_AGENT_MESSAGE as ɵMCP_APPS_NO_AGENT_MESSAGE, MCP_APPS_RENDERER_MISSING_MESSAGE as ɵMCP_APPS_RENDERER_MISSING_MESSAGE, MCP_APP_MAX_HEIGHT as ɵMCP_APP_MAX_HEIGHT, McpAppHost as ɵMcpAppHost, loadMcpAppsRenderer as ɵloadMcpAppsRenderer, ɵrunMcpFollowUp };
|
package/dist/activity.umd.js
CHANGED
|
@@ -4,6 +4,34 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.CopilotKitMcpAppsRendererActivity = {}), global.Zod));
|
|
5
5
|
})(this, function(exports, zod) {
|
|
6
6
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
7
|
+
//#region \0rolldown/runtime.js
|
|
8
|
+
var __create = Object.create;
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
11
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
17
|
+
key = keys[i];
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
19
|
+
__defProp(to, key, {
|
|
20
|
+
get: ((k) => from[k]).bind(null, key),
|
|
21
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
29
|
+
value: mod,
|
|
30
|
+
enumerable: true
|
|
31
|
+
}) : target, mod));
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
zod = __toESM(zod);
|
|
7
35
|
|
|
8
36
|
//#region src/constants.ts
|
|
9
37
|
/**
|
|
@@ -34,14 +62,14 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
34
62
|
|
|
35
63
|
//#endregion
|
|
36
64
|
//#region src/content-schema.ts
|
|
37
|
-
const looseObject = (shape) => zod.
|
|
38
|
-
const metaSchema = zod.
|
|
65
|
+
const looseObject = (shape) => zod.object(shape).loose();
|
|
66
|
+
const metaSchema = zod.record(zod.string(), zod.unknown());
|
|
39
67
|
const annotationsSchema = looseObject({
|
|
40
|
-
audience: zod.
|
|
41
|
-
priority: zod.
|
|
42
|
-
lastModified: zod.
|
|
68
|
+
audience: zod.array(zod.enum(["user", "assistant"])).optional(),
|
|
69
|
+
priority: zod.number().min(0).max(1).optional(),
|
|
70
|
+
lastModified: zod.string().optional()
|
|
43
71
|
});
|
|
44
|
-
const base64Schema = zod.
|
|
72
|
+
const base64Schema = zod.string().refine((value) => {
|
|
45
73
|
try {
|
|
46
74
|
atob(value);
|
|
47
75
|
return true;
|
|
@@ -49,69 +77,69 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
49
77
|
return false;
|
|
50
78
|
}
|
|
51
79
|
}, "Expected base64-encoded data");
|
|
52
|
-
const resourceContentsSchema = zod.
|
|
53
|
-
uri: zod.
|
|
54
|
-
mimeType: zod.
|
|
55
|
-
text: zod.
|
|
80
|
+
const resourceContentsSchema = zod.union([looseObject({
|
|
81
|
+
uri: zod.string(),
|
|
82
|
+
mimeType: zod.string().optional(),
|
|
83
|
+
text: zod.string(),
|
|
56
84
|
_meta: metaSchema.optional()
|
|
57
85
|
}), looseObject({
|
|
58
|
-
uri: zod.
|
|
59
|
-
mimeType: zod.
|
|
86
|
+
uri: zod.string(),
|
|
87
|
+
mimeType: zod.string().optional(),
|
|
60
88
|
blob: base64Schema,
|
|
61
89
|
_meta: metaSchema.optional()
|
|
62
90
|
})]);
|
|
63
|
-
const contentItemSchema = zod.
|
|
91
|
+
const contentItemSchema = zod.discriminatedUnion("type", [
|
|
64
92
|
looseObject({
|
|
65
|
-
type: zod.
|
|
66
|
-
text: zod.
|
|
93
|
+
type: zod.literal("text"),
|
|
94
|
+
text: zod.string(),
|
|
67
95
|
annotations: annotationsSchema.optional(),
|
|
68
96
|
_meta: metaSchema.optional()
|
|
69
97
|
}),
|
|
70
98
|
looseObject({
|
|
71
|
-
type: zod.
|
|
99
|
+
type: zod.literal("image"),
|
|
72
100
|
data: base64Schema,
|
|
73
|
-
mimeType: zod.
|
|
101
|
+
mimeType: zod.string(),
|
|
74
102
|
annotations: annotationsSchema.optional(),
|
|
75
103
|
_meta: metaSchema.optional()
|
|
76
104
|
}),
|
|
77
105
|
looseObject({
|
|
78
|
-
type: zod.
|
|
106
|
+
type: zod.literal("audio"),
|
|
79
107
|
data: base64Schema,
|
|
80
|
-
mimeType: zod.
|
|
108
|
+
mimeType: zod.string(),
|
|
81
109
|
annotations: annotationsSchema.optional(),
|
|
82
110
|
_meta: metaSchema.optional()
|
|
83
111
|
}),
|
|
84
112
|
looseObject({
|
|
85
|
-
type: zod.
|
|
113
|
+
type: zod.literal("resource"),
|
|
86
114
|
resource: resourceContentsSchema,
|
|
87
115
|
annotations: annotationsSchema.optional(),
|
|
88
116
|
_meta: metaSchema.optional()
|
|
89
117
|
}),
|
|
90
118
|
looseObject({
|
|
91
|
-
type: zod.
|
|
92
|
-
uri: zod.
|
|
93
|
-
name: zod.
|
|
94
|
-
title: zod.
|
|
95
|
-
description: zod.
|
|
96
|
-
mimeType: zod.
|
|
97
|
-
size: zod.
|
|
119
|
+
type: zod.literal("resource_link"),
|
|
120
|
+
uri: zod.string(),
|
|
121
|
+
name: zod.string(),
|
|
122
|
+
title: zod.string().optional(),
|
|
123
|
+
description: zod.string().optional(),
|
|
124
|
+
mimeType: zod.string().optional(),
|
|
125
|
+
size: zod.number().optional(),
|
|
98
126
|
annotations: annotationsSchema.optional(),
|
|
99
127
|
_meta: metaSchema.optional()
|
|
100
128
|
})
|
|
101
129
|
]);
|
|
102
130
|
const callToolResultSchema = looseObject({
|
|
103
|
-
content: zod.
|
|
104
|
-
structuredContent: zod.
|
|
105
|
-
isError: zod.
|
|
106
|
-
_meta: zod.
|
|
131
|
+
content: zod.array(contentItemSchema).default([]),
|
|
132
|
+
structuredContent: zod.record(zod.string(), zod.unknown()).optional(),
|
|
133
|
+
isError: zod.boolean().optional(),
|
|
134
|
+
_meta: zod.record(zod.string(), zod.unknown()).optional()
|
|
107
135
|
});
|
|
108
136
|
/** Activity input accepts an omitted result.content; validation defaults it to []. */
|
|
109
137
|
const MCPAppsActivityContentSchema = looseObject({
|
|
110
138
|
result: callToolResultSchema,
|
|
111
|
-
resourceUri: zod.
|
|
112
|
-
serverHash: zod.
|
|
113
|
-
serverId: zod.
|
|
114
|
-
toolInput: zod.
|
|
139
|
+
resourceUri: zod.string(),
|
|
140
|
+
serverHash: zod.string(),
|
|
141
|
+
serverId: zod.string().optional(),
|
|
142
|
+
toolInput: zod.record(zod.string(), zod.unknown()).optional()
|
|
115
143
|
});
|
|
116
144
|
|
|
117
145
|
//#endregion
|
|
@@ -145,10 +173,316 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
145
173
|
};
|
|
146
174
|
}
|
|
147
175
|
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region \0@oxc-project+runtime@0.112.0/helpers/checkPrivateRedeclaration.js
|
|
178
|
+
function _checkPrivateRedeclaration(e, t) {
|
|
179
|
+
if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region \0@oxc-project+runtime@0.112.0/helpers/classPrivateMethodInitSpec.js
|
|
184
|
+
function _classPrivateMethodInitSpec(e, a) {
|
|
185
|
+
_checkPrivateRedeclaration(e, a), a.add(e);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
//#endregion
|
|
189
|
+
//#region \0@oxc-project+runtime@0.112.0/helpers/classPrivateFieldInitSpec.js
|
|
190
|
+
function _classPrivateFieldInitSpec(e, t, a) {
|
|
191
|
+
_checkPrivateRedeclaration(e, t), t.set(e, a);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
//#endregion
|
|
195
|
+
//#region \0@oxc-project+runtime@0.112.0/helpers/assertClassBrand.js
|
|
196
|
+
function _assertClassBrand(e, t, n) {
|
|
197
|
+
if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
|
|
198
|
+
throw new TypeError("Private element is not present on this object");
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
//#endregion
|
|
202
|
+
//#region \0@oxc-project+runtime@0.112.0/helpers/classPrivateFieldGet2.js
|
|
203
|
+
function _classPrivateFieldGet2(s, a) {
|
|
204
|
+
return s.get(_assertClassBrand(s, a));
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
//#endregion
|
|
208
|
+
//#region \0@oxc-project+runtime@0.112.0/helpers/classPrivateFieldSet2.js
|
|
209
|
+
function _classPrivateFieldSet2(s, a, r) {
|
|
210
|
+
return s.set(_assertClassBrand(s, a), r), r;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
//#endregion
|
|
214
|
+
//#region src/host.ts
|
|
215
|
+
/** Message shown when the bridge package cannot be loaded. */
|
|
216
|
+
const MCP_APPS_RENDERER_MISSING_MESSAGE = "MCP Apps require '@copilotkit/mcp-apps-renderer' and its '@modelcontextprotocol/ext-apps' dependency. Reinstall your dependencies if this package is missing.";
|
|
217
|
+
/** Error text when an MCP App renders without an agent to fetch it through. */
|
|
218
|
+
const MCP_APPS_NO_AGENT_MESSAGE = "No agent available to fetch resource";
|
|
219
|
+
/** Tallest an MCP App iframe may grow, in pixels. */
|
|
220
|
+
const MCP_APP_MAX_HEIGHT = 5e3;
|
|
221
|
+
/** The height the iframe starts at before the widget reports its size. */
|
|
222
|
+
const INITIAL_HEIGHT_PX = 100;
|
|
223
|
+
/**
|
|
224
|
+
* Loads the bridge (`bindMcpApp`) lazily. The bridge pulls the MCP SDK and
|
|
225
|
+
* its zod schemas (~40-50 kB gzipped), so an app only pays for it when an MCP
|
|
226
|
+
* App renders. The `import()` itself stays in the frontend, where its bundler
|
|
227
|
+
* can split it out. A failed load rethrows with what to install, since a raw
|
|
228
|
+
* module-resolution error does not say.
|
|
229
|
+
*
|
|
230
|
+
* @param importRenderer - `() => import("@copilotkit/mcp-apps-renderer")`.
|
|
231
|
+
*/
|
|
232
|
+
function loadMcpAppsRenderer(importRenderer) {
|
|
233
|
+
return importRenderer().catch((importErr) => {
|
|
234
|
+
throw new Error(MCP_APPS_RENDERER_MISSING_MESSAGE, { cause: importErr });
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
function identityOf(content) {
|
|
238
|
+
if (!content) return "";
|
|
239
|
+
return JSON.stringify([
|
|
240
|
+
content.resourceUri,
|
|
241
|
+
content.serverHash,
|
|
242
|
+
content.serverId
|
|
243
|
+
]);
|
|
244
|
+
}
|
|
245
|
+
const INITIAL_STATE = {
|
|
246
|
+
loading: true,
|
|
247
|
+
error: null,
|
|
248
|
+
contentError: null,
|
|
249
|
+
size: {},
|
|
250
|
+
prefersBorder: false
|
|
251
|
+
};
|
|
252
|
+
var _options = /* @__PURE__ */ new WeakMap();
|
|
253
|
+
var _listeners = /* @__PURE__ */ new WeakMap();
|
|
254
|
+
var _container = /* @__PURE__ */ new WeakMap();
|
|
255
|
+
var _content = /* @__PURE__ */ new WeakMap();
|
|
256
|
+
var _agent = /* @__PURE__ */ new WeakMap();
|
|
257
|
+
var _messageId = /* @__PURE__ */ new WeakMap();
|
|
258
|
+
var _bindKey = /* @__PURE__ */ new WeakMap();
|
|
259
|
+
var _iframe = /* @__PURE__ */ new WeakMap();
|
|
260
|
+
var _session = /* @__PURE__ */ new WeakMap();
|
|
261
|
+
var _generation = /* @__PURE__ */ new WeakMap();
|
|
262
|
+
var _state = /* @__PURE__ */ new WeakMap();
|
|
263
|
+
var _McpAppHost_brand = /* @__PURE__ */ new WeakSet();
|
|
264
|
+
var _boundAgent = /* @__PURE__ */ new WeakMap();
|
|
265
|
+
var _boundContainer = /* @__PURE__ */ new WeakMap();
|
|
266
|
+
/**
|
|
267
|
+
* Hosts one MCP App: creates the sandbox iframe in a container, binds the
|
|
268
|
+
* MCP session to it, sizes it as the widget reports, and keeps the state a
|
|
269
|
+
* frontend renders. It binds again (new iframe, new session) only when the
|
|
270
|
+
* container, agent, message id or widget identity (resource URI, server)
|
|
271
|
+
* changes; new tool input or results feed the existing session.
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* ```ts
|
|
275
|
+
* const app = new ɵMcpAppHost({ host: core });
|
|
276
|
+
* app.subscribe(() => render(app.getState()));
|
|
277
|
+
* app.setContent(content);
|
|
278
|
+
* app.setAgent(agent);
|
|
279
|
+
* app.setMessageId(message.id);
|
|
280
|
+
* app.setContainer(element); // on mount
|
|
281
|
+
* app.destroy(); // on unmount
|
|
282
|
+
* ```
|
|
283
|
+
*/
|
|
284
|
+
var McpAppHost = class {
|
|
285
|
+
constructor(options) {
|
|
286
|
+
_classPrivateMethodInitSpec(this, _McpAppHost_brand);
|
|
287
|
+
_classPrivateFieldInitSpec(this, _options, void 0);
|
|
288
|
+
_classPrivateFieldInitSpec(this, _listeners, /* @__PURE__ */ new Set());
|
|
289
|
+
_classPrivateFieldInitSpec(this, _container, null);
|
|
290
|
+
_classPrivateFieldInitSpec(this, _content, void 0);
|
|
291
|
+
_classPrivateFieldInitSpec(this, _agent, void 0);
|
|
292
|
+
_classPrivateFieldInitSpec(this, _messageId, void 0);
|
|
293
|
+
_classPrivateFieldInitSpec(this, _bindKey, "");
|
|
294
|
+
_classPrivateFieldInitSpec(this, _iframe, null);
|
|
295
|
+
_classPrivateFieldInitSpec(this, _session, null);
|
|
296
|
+
_classPrivateFieldInitSpec(this, _generation, 0);
|
|
297
|
+
_classPrivateFieldInitSpec(this, _state, INITIAL_STATE);
|
|
298
|
+
this.getState = () => _classPrivateFieldGet2(_state, this);
|
|
299
|
+
this.subscribe = (listener) => {
|
|
300
|
+
_classPrivateFieldGet2(_listeners, this).add(listener);
|
|
301
|
+
return () => {
|
|
302
|
+
_classPrivateFieldGet2(_listeners, this).delete(listener);
|
|
303
|
+
};
|
|
304
|
+
};
|
|
305
|
+
_classPrivateFieldInitSpec(this, _boundAgent, void 0);
|
|
306
|
+
_classPrivateFieldInitSpec(this, _boundContainer, null);
|
|
307
|
+
_classPrivateFieldSet2(_options, this, options);
|
|
308
|
+
}
|
|
309
|
+
/** Sets the element the iframe goes into. `null` removes it. */
|
|
310
|
+
setContainer(container) {
|
|
311
|
+
_classPrivateFieldSet2(_container, this, container);
|
|
312
|
+
_assertClassBrand(_McpAppHost_brand, this, _rebindIfNeeded).call(this);
|
|
313
|
+
}
|
|
314
|
+
/** Sets the latest activity content. */
|
|
315
|
+
setContent(content) {
|
|
316
|
+
var _classPrivateFieldGet2$1;
|
|
317
|
+
_classPrivateFieldSet2(_content, this, content);
|
|
318
|
+
if (!_assertClassBrand(_McpAppHost_brand, this, _rebindIfNeeded).call(this)) (_classPrivateFieldGet2$1 = _classPrivateFieldGet2(_session, this)) === null || _classPrivateFieldGet2$1 === void 0 || _classPrivateFieldGet2$1.syncContent(content);
|
|
319
|
+
}
|
|
320
|
+
/** Sets the agent the widget's requests go through. */
|
|
321
|
+
setAgent(agent) {
|
|
322
|
+
_classPrivateFieldSet2(_agent, this, agent);
|
|
323
|
+
_assertClassBrand(_McpAppHost_brand, this, _rebindIfNeeded).call(this);
|
|
324
|
+
}
|
|
325
|
+
/** Sets the id of the activity message, so the session follows the store. */
|
|
326
|
+
setMessageId(messageId) {
|
|
327
|
+
_classPrivateFieldSet2(_messageId, this, messageId);
|
|
328
|
+
_assertClassBrand(_McpAppHost_brand, this, _rebindIfNeeded).call(this);
|
|
329
|
+
}
|
|
330
|
+
/** Tears the session down and removes the iframe. A later setter binds again. */
|
|
331
|
+
destroy() {
|
|
332
|
+
_assertClassBrand(_McpAppHost_brand, this, _unbind).call(this);
|
|
333
|
+
_classPrivateFieldSet2(_bindKey, this, "");
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
function _rebindIfNeeded() {
|
|
337
|
+
var _this$messageId;
|
|
338
|
+
const key = JSON.stringify([
|
|
339
|
+
identityOf(_classPrivateFieldGet2(_content, this)),
|
|
340
|
+
(_this$messageId = _classPrivateFieldGet2(_messageId, this)) !== null && _this$messageId !== void 0 ? _this$messageId : null,
|
|
341
|
+
_classPrivateFieldGet2(_container, this) !== null,
|
|
342
|
+
_classPrivateFieldGet2(_agent, this) !== void 0
|
|
343
|
+
]);
|
|
344
|
+
const agentChanged = _classPrivateFieldGet2(_session, this) !== null && _classPrivateFieldGet2(_boundAgent, this) !== _classPrivateFieldGet2(_agent, this);
|
|
345
|
+
const containerChanged = _classPrivateFieldGet2(_boundContainer, this) !== _classPrivateFieldGet2(_container, this);
|
|
346
|
+
if (key === _classPrivateFieldGet2(_bindKey, this) && !agentChanged && !containerChanged) return false;
|
|
347
|
+
_classPrivateFieldSet2(_bindKey, this, key);
|
|
348
|
+
_assertClassBrand(_McpAppHost_brand, this, _bind).call(this);
|
|
349
|
+
return true;
|
|
350
|
+
}
|
|
351
|
+
function _bind() {
|
|
352
|
+
var _this$options$iframeA;
|
|
353
|
+
_assertClassBrand(_McpAppHost_brand, this, _unbind).call(this);
|
|
354
|
+
const container = _classPrivateFieldGet2(_container, this);
|
|
355
|
+
const content = _classPrivateFieldGet2(_content, this);
|
|
356
|
+
const agent = _classPrivateFieldGet2(_agent, this);
|
|
357
|
+
_classPrivateFieldSet2(_boundAgent, this, agent);
|
|
358
|
+
_classPrivateFieldSet2(_boundContainer, this, container);
|
|
359
|
+
if (!content || !container) return;
|
|
360
|
+
if (!agent) {
|
|
361
|
+
_assertClassBrand(_McpAppHost_brand, this, _setState).call(this, {
|
|
362
|
+
...INITIAL_STATE,
|
|
363
|
+
loading: false,
|
|
364
|
+
error: MCP_APPS_NO_AGENT_MESSAGE
|
|
365
|
+
});
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
const generation = _classPrivateFieldGet2(_generation, this);
|
|
369
|
+
const isCurrent = () => generation === _classPrivateFieldGet2(_generation, this);
|
|
370
|
+
_assertClassBrand(_McpAppHost_brand, this, _setState).call(this, INITIAL_STATE);
|
|
371
|
+
const iframe = document.createElement("iframe");
|
|
372
|
+
for (const [name, value] of Object.entries((_this$options$iframeA = _classPrivateFieldGet2(_options, this).iframeAttributes) !== null && _this$options$iframeA !== void 0 ? _this$options$iframeA : {})) iframe.setAttribute(name, value);
|
|
373
|
+
iframe.style.width = "100%";
|
|
374
|
+
iframe.style.height = `${String(INITIAL_HEIGHT_PX)}px`;
|
|
375
|
+
iframe.style.border = "none";
|
|
376
|
+
iframe.style.backgroundColor = "transparent";
|
|
377
|
+
iframe.style.display = "block";
|
|
378
|
+
container.appendChild(iframe);
|
|
379
|
+
_classPrivateFieldSet2(_iframe, this, iframe);
|
|
380
|
+
const scoped = _classPrivateFieldGet2(_options, this).scopeToWidget === true;
|
|
381
|
+
const fail = (err) => {
|
|
382
|
+
if (!isCurrent()) return;
|
|
383
|
+
_assertClassBrand(_McpAppHost_brand, this, _setState).call(this, {
|
|
384
|
+
..._classPrivateFieldGet2(_state, this),
|
|
385
|
+
loading: false,
|
|
386
|
+
error: err.message
|
|
387
|
+
});
|
|
388
|
+
if (scoped) {
|
|
389
|
+
var _classPrivateFieldGet3;
|
|
390
|
+
(_classPrivateFieldGet3 = _classPrivateFieldGet2(_session, this)) === null || _classPrivateFieldGet3 === void 0 || _classPrivateFieldGet3.teardown();
|
|
391
|
+
_classPrivateFieldSet2(_session, this, null);
|
|
392
|
+
iframe.removeAttribute("srcdoc");
|
|
393
|
+
iframe.removeAttribute("data-mcp-app-initialized");
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
loadMcpAppsRenderer(_classPrivateFieldGet2(_options, this).importRenderer).then((mod) => {
|
|
397
|
+
var _this$content2;
|
|
398
|
+
if (!isCurrent()) return;
|
|
399
|
+
const session = mod.bindMcpApp({
|
|
400
|
+
iframe,
|
|
401
|
+
getContent: () => {
|
|
402
|
+
var _this$content;
|
|
403
|
+
return (_this$content = _classPrivateFieldGet2(_content, this)) !== null && _this$content !== void 0 ? _this$content : content;
|
|
404
|
+
},
|
|
405
|
+
getAgent: () => _classPrivateFieldGet2(_agent, this),
|
|
406
|
+
host: _classPrivateFieldGet2(_options, this).host,
|
|
407
|
+
messageId: _classPrivateFieldGet2(_messageId, this),
|
|
408
|
+
options: _classPrivateFieldGet2(_options, this).sessionOptions,
|
|
409
|
+
cancelFollowUpsOnTeardown: scoped,
|
|
410
|
+
requireExactResourceUri: scoped,
|
|
411
|
+
cancelRunningWaitOnTeardown: scoped,
|
|
412
|
+
hooks: {
|
|
413
|
+
onResource: (resource) => {
|
|
414
|
+
var _resource$_meta;
|
|
415
|
+
if (!isCurrent()) return;
|
|
416
|
+
_assertClassBrand(_McpAppHost_brand, this, _setState).call(this, {
|
|
417
|
+
..._classPrivateFieldGet2(_state, this),
|
|
418
|
+
loading: false,
|
|
419
|
+
prefersBorder: ((_resource$_meta = resource._meta) === null || _resource$_meta === void 0 || (_resource$_meta = _resource$_meta.ui) === null || _resource$_meta === void 0 ? void 0 : _resource$_meta.prefersBorder) === true
|
|
420
|
+
});
|
|
421
|
+
},
|
|
422
|
+
onInitialized: () => {
|
|
423
|
+
if (isCurrent()) iframe.setAttribute("data-mcp-app-initialized", "true");
|
|
424
|
+
},
|
|
425
|
+
onSizeChanged: (size) => {
|
|
426
|
+
if (isCurrent()) _assertClassBrand(_McpAppHost_brand, this, _applySize).call(this, iframe, size);
|
|
427
|
+
},
|
|
428
|
+
onContentError: (err) => {
|
|
429
|
+
var _err$message;
|
|
430
|
+
if (!isCurrent()) return;
|
|
431
|
+
_assertClassBrand(_McpAppHost_brand, this, _setState).call(this, {
|
|
432
|
+
..._classPrivateFieldGet2(_state, this),
|
|
433
|
+
contentError: (_err$message = err === null || err === void 0 ? void 0 : err.message) !== null && _err$message !== void 0 ? _err$message : null
|
|
434
|
+
});
|
|
435
|
+
},
|
|
436
|
+
onError: fail,
|
|
437
|
+
...scoped ? { onFollowUpError: fail } : {}
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
_classPrivateFieldSet2(_session, this, session);
|
|
441
|
+
session.syncContent((_this$content2 = _classPrivateFieldGet2(_content, this)) !== null && _this$content2 !== void 0 ? _this$content2 : content);
|
|
442
|
+
}).catch((err) => {
|
|
443
|
+
console.error("[MCPAppsRenderer] Setup error:", err);
|
|
444
|
+
fail(err instanceof Error ? err : new Error(String(err)));
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
function _applySize(iframe, size) {
|
|
448
|
+
const next = {};
|
|
449
|
+
if (typeof size.width === "number" && Number.isFinite(size.width)) {
|
|
450
|
+
next.width = size.width;
|
|
451
|
+
iframe.style.minWidth = `min(${String(size.width)}px, 100%)`;
|
|
452
|
+
iframe.style.width = "100%";
|
|
453
|
+
}
|
|
454
|
+
const height = size.height;
|
|
455
|
+
if (typeof height === "number" && Number.isFinite(height) && height > 0) {
|
|
456
|
+
next.height = Math.ceil(Math.min(height, MCP_APP_MAX_HEIGHT));
|
|
457
|
+
iframe.style.height = `${String(next.height)}px`;
|
|
458
|
+
}
|
|
459
|
+
_assertClassBrand(_McpAppHost_brand, this, _setState).call(this, {
|
|
460
|
+
..._classPrivateFieldGet2(_state, this),
|
|
461
|
+
size: next
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
function _unbind() {
|
|
465
|
+
var _classPrivateFieldGet4, _classPrivateFieldGet5;
|
|
466
|
+
_classPrivateFieldSet2(_generation, this, _classPrivateFieldGet2(_generation, this) + 1);
|
|
467
|
+
(_classPrivateFieldGet4 = _classPrivateFieldGet2(_session, this)) === null || _classPrivateFieldGet4 === void 0 || _classPrivateFieldGet4.teardown();
|
|
468
|
+
_classPrivateFieldSet2(_session, this, null);
|
|
469
|
+
(_classPrivateFieldGet5 = _classPrivateFieldGet2(_iframe, this)) === null || _classPrivateFieldGet5 === void 0 || _classPrivateFieldGet5.remove();
|
|
470
|
+
_classPrivateFieldSet2(_iframe, this, null);
|
|
471
|
+
}
|
|
472
|
+
function _setState(state) {
|
|
473
|
+
_classPrivateFieldSet2(_state, this, state);
|
|
474
|
+
for (const listener of _classPrivateFieldGet2(_listeners, this)) listener();
|
|
475
|
+
}
|
|
476
|
+
|
|
148
477
|
//#endregion
|
|
149
478
|
exports.MCPAppsActivityContentSchema = MCPAppsActivityContentSchema;
|
|
150
479
|
exports.MCPAppsActivityType = MCPAppsActivityType;
|
|
151
480
|
exports.MCP_OPEN_LINK_BLOCKED_SCHEMES = MCP_OPEN_LINK_BLOCKED_SCHEMES;
|
|
481
|
+
exports.ɵMCP_APPS_NO_AGENT_MESSAGE = MCP_APPS_NO_AGENT_MESSAGE;
|
|
482
|
+
exports.ɵMCP_APPS_RENDERER_MISSING_MESSAGE = MCP_APPS_RENDERER_MISSING_MESSAGE;
|
|
483
|
+
exports.ɵMCP_APP_MAX_HEIGHT = MCP_APP_MAX_HEIGHT;
|
|
484
|
+
exports.ɵMcpAppHost = McpAppHost;
|
|
485
|
+
exports.ɵloadMcpAppsRenderer = loadMcpAppsRenderer;
|
|
152
486
|
exports.ɵrunMcpFollowUp = ɵrunMcpFollowUp;
|
|
153
487
|
});
|
|
154
488
|
//# sourceMappingURL=activity.umd.js.map
|
package/dist/activity.umd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activity.umd.js","names":["z"],"sources":["../src/constants.ts","../src/content-schema.ts","../src/follow-up.ts"],"sourcesContent":["/**\n * Activity type for MCP Apps events - must match the middleware's MCPAppsActivityType.\n */\nexport const MCPAppsActivityType = \"mcp-apps\";\n\n/**\n * URL schemes a widget may NOT open via ui/open-link. The ext-apps schema\n * validates `url` as a plain string only (noopener/noreferrer does not restrict\n * the scheme), so ui/open-link could otherwise become an XSS vector.\n *\n * We use a denylist rather than an allowlist on purpose: deep links use\n * arbitrary, app-defined schemes (`myapp:`, `whatsapp:`, `slack:`, `spotify:`,\n * `sms:`, ...) that an allowlist could never enumerate, and `window.open`ing them\n * just hands off to an OS handler - it does not execute script in the page, so\n * it is not an XSS risk. Universal links / App Links are plain `https:` URLs and\n * pass regardless. What IS dangerous is the small, well-known set of schemes\n * that execute script or render attacker HTML in the page context; block those\n * and allow everything else (including deep links).\n */\nexport const MCP_OPEN_LINK_BLOCKED_SCHEMES = new Set([\n \"javascript:\",\n \"data:\",\n \"vbscript:\",\n \"blob:\",\n \"file:\",\n]);\n","import { z } from \"zod\";\n\n// Keep /activity bridge-free: the MCP SDK is only used as a test oracle.\n// This is the Angular host's content contract, expressed using our zod API.\nconst looseObject = <T extends z.ZodRawShape>(shape: T) =>\n z.object(shape).passthrough();\n\n// `_meta` is an extension channel, so its CONTENTS stay unconstrained - but the\n// SDK still requires it to be an object, and a string or array there is a bug\n// worth catching rather than forwarding.\nconst metaSchema = z.record(z.string(), z.unknown());\n\nconst annotationsSchema = looseObject({\n audience: z.array(z.enum([\"user\", \"assistant\"])).optional(),\n priority: z.number().min(0).max(1).optional(),\n lastModified: z.string().optional(),\n});\n\n// Validated by decoding, mirroring the MCP SDK's own base64 check, rather than\n// by pattern. The pattern this replaces additionally required canonical padding,\n// which the SDK does not: it accepts an unpadded payload that we rejected. Since\n// one bad block fails the whole content array, that cost the entire widget.\nconst base64Schema = z.string().refine((value) => {\n try {\n atob(value);\n return true;\n } catch {\n return false;\n }\n}, \"Expected base64-encoded data\");\n\nconst resourceContentsSchema = z.union([\n looseObject({\n uri: z.string(),\n mimeType: z.string().optional(),\n text: z.string(),\n _meta: metaSchema.optional(),\n }),\n looseObject({\n uri: z.string(),\n mimeType: z.string().optional(),\n blob: base64Schema,\n _meta: metaSchema.optional(),\n }),\n]);\n\nconst contentItemSchema = z.discriminatedUnion(\"type\", [\n looseObject({\n type: z.literal(\"text\"),\n text: z.string(),\n annotations: annotationsSchema.optional(),\n _meta: metaSchema.optional(),\n }),\n looseObject({\n type: z.literal(\"image\"),\n data: base64Schema,\n mimeType: z.string(),\n annotations: annotationsSchema.optional(),\n _meta: metaSchema.optional(),\n }),\n looseObject({\n type: z.literal(\"audio\"),\n data: base64Schema,\n mimeType: z.string(),\n annotations: annotationsSchema.optional(),\n _meta: metaSchema.optional(),\n }),\n looseObject({\n type: z.literal(\"resource\"),\n resource: resourceContentsSchema,\n annotations: annotationsSchema.optional(),\n _meta: metaSchema.optional(),\n }),\n looseObject({\n type: z.literal(\"resource_link\"),\n uri: z.string(),\n name: z.string(),\n title: z.string().optional(),\n description: z.string().optional(),\n mimeType: z.string().optional(),\n size: z.number().optional(),\n annotations: annotationsSchema.optional(),\n _meta: metaSchema.optional(),\n }),\n]);\n\nconst callToolResultSchema = looseObject({\n content: z.array(contentItemSchema).default([]),\n structuredContent: z.record(z.string(), z.unknown()).optional(),\n isError: z.boolean().optional(),\n _meta: z.record(z.string(), z.unknown()).optional(),\n});\n\n/** Activity input accepts an omitted result.content; validation defaults it to []. */\nexport const MCPAppsActivityContentSchema = looseObject({\n result: callToolResultSchema,\n resourceUri: z.string(),\n serverHash: z.string(),\n serverId: z.string().optional(),\n toolInput: z.record(z.string(), z.unknown()).optional(),\n});\n\n// Keep the public input contract compatible with structured-only results.\n// Parsed output is normalized before it crosses the bridge.\nexport type MCPAppsActivityContent = z.input<\n typeof MCPAppsActivityContentSchema\n>;\n","import type { AbstractAgent, RunAgentResult } from \"@ag-ui/client\";\n\n/**\n * The subset of `CopilotKitCore` that {@link ɵrunMcpFollowUp} depends on.\n * Declared structurally so the runner can be unit-tested without a full core.\n */\nexport interface ɵMcpFollowUpHost {\n runAgent(params: { agent: AbstractAgent }): Promise<RunAgentResult>;\n}\n\n/**\n * Run an MCP app `ui/message` follow-up, scoped to the thread it was enqueued\n * for (issue #5819).\n *\n * The MCP request queue delays follow-up work until the agent is idle. There is\n * a single shared registry agent per id, and switching threads overwrites its\n * `threadId`/`messages` in place. So if the host switches threads while a\n * follow-up is queued, running it now would execute against — and stream into —\n * the now-foreground thread.\n *\n * - **Same thread** (the common case): run on the shared agent, unchanged.\n * - **Thread changed**: the shared agent has moved on, so the follow-up can no\n * longer run in its originating thread's context. Drop it rather than leak it\n * into the current thread. (The MCP app already received its `ui/message` ack\n * at enqueue time; only the optional agent turn is skipped.)\n *\n * @internal exported for testing.\n */\nexport async function ɵrunMcpFollowUp({\n host,\n agent,\n capturedThreadId,\n}: {\n host: ɵMcpFollowUpHost;\n agent: AbstractAgent;\n capturedThreadId: string;\n}): Promise<RunAgentResult> {\n const currentThreadId = agent.threadId || \"default\";\n const originThreadId = capturedThreadId || \"default\";\n\n if (currentThreadId === originThreadId) {\n return host.runAgent({ agent });\n }\n\n console.warn(\n \"[MCPAppsRenderer] ui/message follow-up dropped: the thread changed \" +\n `(${originThreadId} → ${currentThreadId}) between enqueue and execution, ` +\n \"so running it would leak into the now-foreground thread.\",\n );\n return { result: undefined, newMessages: [] };\n}\n"],"mappings":";;;;;;;;;;;CAGA,MAAa,sBAAsB;;;;;;;;;;;;;;;CAgBnC,MAAa,gCAAgC,IAAI,IAAI;EACnD;EACA;EACA;EACA;EACA;EACD,CAAC;;;;CCrBF,MAAM,eAAwC,UAC5CA,MAAE,OAAO,MAAM,CAAC,aAAa;CAK/B,MAAM,aAAaA,MAAE,OAAOA,MAAE,QAAQ,EAAEA,MAAE,SAAS,CAAC;CAEpD,MAAM,oBAAoB,YAAY;EACpC,UAAUA,MAAE,MAAMA,MAAE,KAAK,CAAC,QAAQ,YAAY,CAAC,CAAC,CAAC,UAAU;EAC3D,UAAUA,MAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,UAAU;EAC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AU;GAClC,UAAUA,MAAE,QAAQ,CAAC,UAAU;GAC/B,MAAMA,MAAE,QAAQ,CAAC,UAAU;GAC3B,aAAa,kBAAkB,UAAU;GACzC,OAAO,WAAW,UAAU;GAC7B,CAAC;EACH,CAAC;CAEF,MAAM,uBAAuB,YAAY;EACvC,SAASA,MAAE,MAAM,kBAAkB,CAAC,QAAQ,EAAE,CAAC;EAC/C,mBAAmBA,MAAE,OAAOA,MAAE,QAAQ,EAAEA,MAAE,SAAS,CAAC,CAAC,UAAU;EAC/D,SAASA,MAAE,SAAS,CAAC,UAAU;EAC/B,OAAOA,MAAE,OAAOA,MAAE,QAAQ,EAAEA,MAAE,SAAS,CAAC,CAAC,UAAU;EACpD,CAAC;;CAGF,MAAa,+BAA+B,YAAY;EACtD,QAAQ;EACR,aAAaA,MAAE,QAAQ;EACvB,YAAYA,MAAE,QAAQ;EACtB,UAAUA,MAAE,QAAQ,CAAC,UAAU;EAC/B,WAAWA,MAAE,OAAOA,MAAE,QAAQ,EAAEA,MAAE,SAAS,CAAC,CAAC,UAAU;EACxD,CAAC;;;;;;;;;;;;;;;;;;;;;;CCxEF,eAAsB,gBAAgB,EACpC,MACA,OACA,oBAK0B;EAC1B,MAAM,kBAAkB,MAAM,YAAY;EAC1C,MAAM,iBAAiB,oBAAoB;AAE3C,MAAI,oBAAoB,eACtB,QAAO,KAAK,SAAS,EAAE,OAAO,CAAC;AAGjC,UAAQ,KACN,uEACM,eAAe,KAAK,gBAAgB,2FAE3C;AACD,SAAO;GAAE,QAAQ;GAAW,aAAa,EAAE;GAAE"}
|
|
1
|
+
{"version":3,"file":"activity.umd.js","names":["z"],"sources":["../src/constants.ts","../src/content-schema.ts","../src/follow-up.ts","../src/host.ts"],"sourcesContent":["/**\n * Activity type for MCP Apps events - must match the middleware's MCPAppsActivityType.\n */\nexport const MCPAppsActivityType = \"mcp-apps\";\n\n/**\n * URL schemes a widget may NOT open via ui/open-link. The ext-apps schema\n * validates `url` as a plain string only (noopener/noreferrer does not restrict\n * the scheme), so ui/open-link could otherwise become an XSS vector.\n *\n * We use a denylist rather than an allowlist on purpose: deep links use\n * arbitrary, app-defined schemes (`myapp:`, `whatsapp:`, `slack:`, `spotify:`,\n * `sms:`, ...) that an allowlist could never enumerate, and `window.open`ing them\n * just hands off to an OS handler - it does not execute script in the page, so\n * it is not an XSS risk. Universal links / App Links are plain `https:` URLs and\n * pass regardless. What IS dangerous is the small, well-known set of schemes\n * that execute script or render attacker HTML in the page context; block those\n * and allow everything else (including deep links).\n */\nexport const MCP_OPEN_LINK_BLOCKED_SCHEMES = new Set([\n \"javascript:\",\n \"data:\",\n \"vbscript:\",\n \"blob:\",\n \"file:\",\n]);\n","import * as z from \"zod\";\n\n// Keep /activity bridge-free: the MCP SDK is only used as a test oracle.\n// This is the Angular host's content contract, expressed using our zod API.\nconst looseObject = <T extends z.ZodRawShape>(shape: T) =>\n z.object(shape).loose();\n\n// `_meta` is an extension channel, so its CONTENTS stay unconstrained - but the\n// SDK still requires it to be an object, and a string or array there is a bug\n// worth catching rather than forwarding.\nconst metaSchema = z.record(z.string(), z.unknown());\n\nconst annotationsSchema = looseObject({\n audience: z.array(z.enum([\"user\", \"assistant\"])).optional(),\n priority: z.number().min(0).max(1).optional(),\n lastModified: z.string().optional(),\n});\n\n// Validated by decoding, mirroring the MCP SDK's own base64 check, rather than\n// by pattern. The pattern this replaces additionally required canonical padding,\n// which the SDK does not: it accepts an unpadded payload that we rejected. Since\n// one bad block fails the whole content array, that cost the entire widget.\nconst base64Schema = z.string().refine((value) => {\n try {\n atob(value);\n return true;\n } catch {\n return false;\n }\n}, \"Expected base64-encoded data\");\n\nconst resourceContentsSchema = z.union([\n looseObject({\n uri: z.string(),\n mimeType: z.string().optional(),\n text: z.string(),\n _meta: metaSchema.optional(),\n }),\n looseObject({\n uri: z.string(),\n mimeType: z.string().optional(),\n blob: base64Schema,\n _meta: metaSchema.optional(),\n }),\n]);\n\nconst contentItemSchema = z.discriminatedUnion(\"type\", [\n looseObject({\n type: z.literal(\"text\"),\n text: z.string(),\n annotations: annotationsSchema.optional(),\n _meta: metaSchema.optional(),\n }),\n looseObject({\n type: z.literal(\"image\"),\n data: base64Schema,\n mimeType: z.string(),\n annotations: annotationsSchema.optional(),\n _meta: metaSchema.optional(),\n }),\n looseObject({\n type: z.literal(\"audio\"),\n data: base64Schema,\n mimeType: z.string(),\n annotations: annotationsSchema.optional(),\n _meta: metaSchema.optional(),\n }),\n looseObject({\n type: z.literal(\"resource\"),\n resource: resourceContentsSchema,\n annotations: annotationsSchema.optional(),\n _meta: metaSchema.optional(),\n }),\n looseObject({\n type: z.literal(\"resource_link\"),\n uri: z.string(),\n name: z.string(),\n title: z.string().optional(),\n description: z.string().optional(),\n mimeType: z.string().optional(),\n size: z.number().optional(),\n annotations: annotationsSchema.optional(),\n _meta: metaSchema.optional(),\n }),\n]);\n\nconst callToolResultSchema = looseObject({\n content: z.array(contentItemSchema).default([]),\n structuredContent: z.record(z.string(), z.unknown()).optional(),\n isError: z.boolean().optional(),\n _meta: z.record(z.string(), z.unknown()).optional(),\n});\n\n/** Activity input accepts an omitted result.content; validation defaults it to []. */\nexport const MCPAppsActivityContentSchema = looseObject({\n result: callToolResultSchema,\n resourceUri: z.string(),\n serverHash: z.string(),\n serverId: z.string().optional(),\n toolInput: z.record(z.string(), z.unknown()).optional(),\n});\n\n// Keep the public input contract compatible with structured-only results.\n// Parsed output is normalized before it crosses the bridge.\nexport type MCPAppsActivityContent = z.input<\n typeof MCPAppsActivityContentSchema\n>;\n","import type { AbstractAgent, RunAgentResult } from \"@ag-ui/client\";\n\n/**\n * The subset of `CopilotKitCore` that {@link ɵrunMcpFollowUp} depends on.\n * Declared structurally so the runner can be unit-tested without a full core.\n */\nexport interface ɵMcpFollowUpHost {\n runAgent(params: { agent: AbstractAgent }): Promise<RunAgentResult>;\n}\n\n/**\n * Run an MCP app `ui/message` follow-up, scoped to the thread it was enqueued\n * for (issue #5819).\n *\n * The MCP request queue delays follow-up work until the agent is idle. There is\n * a single shared registry agent per id, and switching threads overwrites its\n * `threadId`/`messages` in place. So if the host switches threads while a\n * follow-up is queued, running it now would execute against — and stream into —\n * the now-foreground thread.\n *\n * - **Same thread** (the common case): run on the shared agent, unchanged.\n * - **Thread changed**: the shared agent has moved on, so the follow-up can no\n * longer run in its originating thread's context. Drop it rather than leak it\n * into the current thread. (The MCP app already received its `ui/message` ack\n * at enqueue time; only the optional agent turn is skipped.)\n *\n * @internal exported for testing.\n */\nexport async function ɵrunMcpFollowUp({\n host,\n agent,\n capturedThreadId,\n}: {\n host: ɵMcpFollowUpHost;\n agent: AbstractAgent;\n capturedThreadId: string;\n}): Promise<RunAgentResult> {\n const currentThreadId = agent.threadId || \"default\";\n const originThreadId = capturedThreadId || \"default\";\n\n if (currentThreadId === originThreadId) {\n return host.runAgent({ agent });\n }\n\n console.warn(\n \"[MCPAppsRenderer] ui/message follow-up dropped: the thread changed \" +\n `(${originThreadId} → ${currentThreadId}) between enqueue and execution, ` +\n \"so running it would leak into the now-foreground thread.\",\n );\n return { result: undefined, newMessages: [] };\n}\n","// The framework-neutral host shell around `bindMcpApp`: the iframe, its size,\n// and the loading / error / content-error state every frontend renders. It is\n// bridge-free (the bridge loads lazily through `loadMcpAppsRenderer`), so\n// frontends can import it statically from the `/activity` entry.\nimport type { AbstractAgent } from \"@ag-ui/client\";\nimport type { MCPAppsActivityContent } from \"./content-schema\";\nimport type { ɵMcpFollowUpHost } from \"./follow-up\";\nimport type {\n BindMcpAppOptions,\n FetchedResource,\n McpAppSession,\n McpAppSessionOptions,\n} from \"./session\";\n\n/** The part of the bridge module the host uses, loaded on demand. */\nexport interface McpAppsRendererModule {\n bindMcpApp(options: BindMcpAppOptions): McpAppSession;\n}\n\n/** Message shown when the bridge package cannot be loaded. */\nexport const MCP_APPS_RENDERER_MISSING_MESSAGE =\n \"MCP Apps require '@copilotkit/mcp-apps-renderer' and its \" +\n \"'@modelcontextprotocol/ext-apps' dependency. Reinstall your \" +\n \"dependencies if this package is missing.\";\n\n/** Error text when an MCP App renders without an agent to fetch it through. */\nexport const MCP_APPS_NO_AGENT_MESSAGE = \"No agent available to fetch resource\";\n\n/** Tallest an MCP App iframe may grow, in pixels. */\nexport const MCP_APP_MAX_HEIGHT = 5000;\n\n/** The height the iframe starts at before the widget reports its size. */\nconst INITIAL_HEIGHT_PX = 100;\n\n/** Imports the bridge module; frontends pass `() => import(\"@copilotkit/mcp-apps-renderer\")`. */\nexport type McpAppsRendererImporter = () => Promise<McpAppsRendererModule>;\n\n/**\n * Loads the bridge (`bindMcpApp`) lazily. The bridge pulls the MCP SDK and\n * its zod schemas (~40-50 kB gzipped), so an app only pays for it when an MCP\n * App renders. The `import()` itself stays in the frontend, where its bundler\n * can split it out. A failed load rethrows with what to install, since a raw\n * module-resolution error does not say.\n *\n * @param importRenderer - `() => import(\"@copilotkit/mcp-apps-renderer\")`.\n */\nexport function loadMcpAppsRenderer(importRenderer: McpAppsRendererImporter) {\n return importRenderer().catch((importErr: unknown) => {\n throw new Error(MCP_APPS_RENDERER_MISSING_MESSAGE, { cause: importErr });\n });\n}\n\n/** What a frontend renders around the MCP App iframe. */\nexport interface McpAppHostState {\n loading: boolean;\n /** Fatal setup failure; shown until the host binds again. */\n error: string | null;\n /** Recoverable: the latest content was rejected and not forwarded. */\n contentError: string | null;\n /** The size the widget reported. */\n size: { width?: number; height?: number };\n /** The resource asked the host for a border and background. */\n prefersBorder: boolean;\n}\n\nexport interface McpAppHostOptions {\n /** The CopilotKit core, for `ui/message` follow-up runs. */\n host: ɵMcpFollowUpHost;\n /** Session options (host info, timeouts, `allowSameOriginFallback`). */\n sessionOptions?: McpAppSessionOptions;\n /**\n * Scope the session to the widget (Angular's contract): teardown cancels\n * its queued follow-up and releases running waits, the fetched resource URI\n * must match exactly, and a failed follow-up or setup error tears the\n * session down, blanks the iframe and shows the error.\n */\n scopeToWidget?: boolean;\n /** Attributes set on the iframe, such as a `data-testid` or `title`. */\n iframeAttributes?: Record<string, string>;\n /** `() => import(\"@copilotkit/mcp-apps-renderer\")`; see {@link loadMcpAppsRenderer}. */\n importRenderer: McpAppsRendererImporter;\n}\n\nfunction identityOf(content: MCPAppsActivityContent | undefined) {\n if (!content) return \"\";\n return JSON.stringify([\n content.resourceUri,\n content.serverHash,\n content.serverId,\n ]);\n}\n\nconst INITIAL_STATE: McpAppHostState = {\n loading: true,\n error: null,\n contentError: null,\n size: {},\n prefersBorder: false,\n};\n\n/**\n * Hosts one MCP App: creates the sandbox iframe in a container, binds the\n * MCP session to it, sizes it as the widget reports, and keeps the state a\n * frontend renders. It binds again (new iframe, new session) only when the\n * container, agent, message id or widget identity (resource URI, server)\n * changes; new tool input or results feed the existing session.\n *\n * @example\n * ```ts\n * const app = new ɵMcpAppHost({ host: core });\n * app.subscribe(() => render(app.getState()));\n * app.setContent(content);\n * app.setAgent(agent);\n * app.setMessageId(message.id);\n * app.setContainer(element); // on mount\n * app.destroy(); // on unmount\n * ```\n */\nexport class McpAppHost {\n readonly #options: McpAppHostOptions;\n readonly #listeners = new Set<() => void>();\n #container: HTMLElement | null = null;\n #content: MCPAppsActivityContent | undefined;\n #agent: AbstractAgent | undefined;\n #messageId: string | undefined;\n #bindKey = \"\";\n #iframe: HTMLIFrameElement | null = null;\n #session: McpAppSession | null = null;\n /** Bumped on every bind and on destroy; stale async work checks it. */\n #generation = 0;\n #state: McpAppHostState = INITIAL_STATE;\n\n constructor(options: McpAppHostOptions) {\n this.#options = options;\n }\n\n /** The current state. The same object until something changes. */\n getState = () => this.#state;\n\n /** Calls `listener` when the state changes. Returns the unsubscribe function. */\n subscribe = (listener: () => void) => {\n this.#listeners.add(listener);\n return () => {\n this.#listeners.delete(listener);\n };\n };\n\n /** Sets the element the iframe goes into. `null` removes it. */\n setContainer(container: HTMLElement | null) {\n this.#container = container;\n this.#rebindIfNeeded();\n }\n\n /** Sets the latest activity content. */\n setContent(content: MCPAppsActivityContent) {\n this.#content = content;\n if (!this.#rebindIfNeeded()) this.#session?.syncContent(content);\n }\n\n /** Sets the agent the widget's requests go through. */\n setAgent(agent: AbstractAgent | undefined) {\n this.#agent = agent;\n this.#rebindIfNeeded();\n }\n\n /** Sets the id of the activity message, so the session follows the store. */\n setMessageId(messageId: string | undefined) {\n this.#messageId = messageId;\n this.#rebindIfNeeded();\n }\n\n /** Tears the session down and removes the iframe. A later setter binds again. */\n destroy() {\n this.#unbind();\n this.#bindKey = \"\";\n }\n\n #rebindIfNeeded() {\n const key = JSON.stringify([\n identityOf(this.#content),\n this.#messageId ?? null,\n this.#container !== null,\n this.#agent !== undefined,\n ]);\n const agentChanged =\n this.#session !== null && this.#boundAgent !== this.#agent;\n const containerChanged = this.#boundContainer !== this.#container;\n if (key === this.#bindKey && !agentChanged && !containerChanged) {\n return false;\n }\n this.#bindKey = key;\n this.#bind();\n return true;\n }\n\n #boundAgent: AbstractAgent | undefined;\n #boundContainer: HTMLElement | null = null;\n\n #bind() {\n this.#unbind();\n const container = this.#container;\n const content = this.#content;\n const agent = this.#agent;\n this.#boundAgent = agent;\n this.#boundContainer = container;\n if (!content || !container) return;\n if (!agent) {\n this.#setState({\n ...INITIAL_STATE,\n loading: false,\n error: MCP_APPS_NO_AGENT_MESSAGE,\n });\n return;\n }\n\n const generation = this.#generation;\n const isCurrent = () => generation === this.#generation;\n this.#setState(INITIAL_STATE);\n\n const iframe = document.createElement(\"iframe\");\n for (const [name, value] of Object.entries(\n this.#options.iframeAttributes ?? {},\n )) {\n iframe.setAttribute(name, value);\n }\n iframe.style.width = \"100%\";\n iframe.style.height = `${String(INITIAL_HEIGHT_PX)}px`;\n iframe.style.border = \"none\";\n iframe.style.backgroundColor = \"transparent\";\n iframe.style.display = \"block\";\n container.appendChild(iframe);\n this.#iframe = iframe;\n\n const scoped = this.#options.scopeToWidget === true;\n const fail = (err: Error) => {\n if (!isCurrent()) return;\n this.#setState({ ...this.#state, loading: false, error: err.message });\n if (scoped) {\n // Blank the widget, so a failed app does not stay interactive.\n this.#session?.teardown();\n this.#session = null;\n iframe.removeAttribute(\"srcdoc\");\n iframe.removeAttribute(\"data-mcp-app-initialized\");\n }\n };\n loadMcpAppsRenderer(this.#options.importRenderer)\n .then((mod) => {\n if (!isCurrent()) return;\n const session = mod.bindMcpApp({\n iframe,\n getContent: () => this.#content ?? content,\n getAgent: () => this.#agent,\n host: this.#options.host,\n messageId: this.#messageId,\n options: this.#options.sessionOptions,\n cancelFollowUpsOnTeardown: scoped,\n requireExactResourceUri: scoped,\n cancelRunningWaitOnTeardown: scoped,\n hooks: {\n onResource: (resource: FetchedResource) => {\n if (!isCurrent()) return;\n this.#setState({\n ...this.#state,\n loading: false,\n prefersBorder: resource._meta?.ui?.prefersBorder === true,\n });\n },\n onInitialized: () => {\n if (isCurrent()) {\n iframe.setAttribute(\"data-mcp-app-initialized\", \"true\");\n }\n },\n onSizeChanged: (size) => {\n if (isCurrent()) this.#applySize(iframe, size);\n },\n onContentError: (err) => {\n if (!isCurrent()) return;\n this.#setState({\n ...this.#state,\n contentError: err?.message ?? null,\n });\n },\n onError: fail,\n ...(scoped ? { onFollowUpError: fail } : {}),\n },\n });\n this.#session = session;\n // Seed the content: an activity rendered from an external message\n // list is not in the agent's store, so nothing else would send it.\n session.syncContent(this.#content ?? content);\n })\n .catch((err: unknown) => {\n console.error(\"[MCPAppsRenderer] Setup error:\", err);\n fail(err instanceof Error ? err : new Error(String(err)));\n });\n }\n\n #applySize(\n iframe: HTMLIFrameElement,\n size: { width?: number; height?: number },\n ) {\n const next: McpAppHostState[\"size\"] = {};\n if (typeof size.width === \"number\" && Number.isFinite(size.width)) {\n next.width = size.width;\n // Allow expansion but cap at the container width.\n iframe.style.minWidth = `min(${String(size.width)}px, 100%)`;\n iframe.style.width = \"100%\";\n }\n const height = size.height;\n if (typeof height === \"number\" && Number.isFinite(height) && height > 0) {\n next.height = Math.ceil(Math.min(height, MCP_APP_MAX_HEIGHT));\n iframe.style.height = `${String(next.height)}px`;\n }\n this.#setState({ ...this.#state, size: next });\n }\n\n #unbind() {\n this.#generation += 1;\n this.#session?.teardown();\n this.#session = null;\n this.#iframe?.remove();\n this.#iframe = null;\n }\n\n #setState(state: McpAppHostState) {\n this.#state = state;\n for (const listener of this.#listeners) listener();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGA,MAAa,sBAAsB;;;;;;;;;;;;;;;CAgBnC,MAAa,gCAAgC,IAAI,IAAI;EACnD;EACA;EACA;EACA;EACA;EACD,CAAC;;;;CCrBF,MAAM,eAAwC,UAC5CA,IAAE,OAAO,MAAM,CAAC,OAAO;CAKzB,MAAM,aAAaA,IAAE,OAAOA,IAAE,QAAQ,EAAEA,IAAE,SAAS,CAAC;CAEpD,MAAM,oBAAoB,YAAY;EACpC,UAAUA,IAAE,MAAMA,IAAE,KAAK,CAAC,QAAQ,YAAY,CAAC,CAAC,CAAC,UAAU;EAC3D,UAAUA,IAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,UAAU;EAC7C,cAAcA,IAAE,QAAQ,CAAC,UAAU;EACpC,CAAC;CAMF,MAAM,eAAeA,IAAE,QAAQ,CAAC,QAAQ,UAAU;AAChD,MAAI;AACF,QAAK,MAAM;AACX,UAAO;oBACD;AACN,UAAO;;IAER,+BAA+B;CAElC,MAAM,yBAAyBA,IAAE,MAAM,CACrC,YAAY;EACV,KAAKA,IAAE,QAAQ;EACf,UAAUA,IAAE,QAAQ,CAAC,UAAU;EAC/B,MAAMA,IAAE,QAAQ;EAChB,OAAO,WAAW,UAAU;EAC7B,CAAC,EACF,YAAY;EACV,KAAKA,IAAE,QAAQ;EACf,UAAUA,IAAE,QAAQ,CAAC,UAAU;EAC/B,MAAM;EACN,OAAO,WAAW,UAAU;EAC7B,CAAC,CACH,CAAC;CAEF,MAAM,oBAAoBA,IAAE,mBAAmB,QAAQ;EACrD,YAAY;GACV,MAAMA,IAAE,QAAQ,OAAO;GACvB,MAAMA,IAAE,QAAQ;GAChB,aAAa,kBAA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