@copilotkit/mcp-apps-renderer 2.0.0-rc.2 → 2.0.0-rc.20
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.umd.js +63 -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/request-queue.mjs.map +1 -1
- package/dist/session.mjs +2 -2
- package/dist/session.mjs.map +1 -1
- package/package.json +9 -7
|
@@ -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.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
|
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
|
|
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 * 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"],"mapp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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"}
|
package/dist/content-schema.cjs
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
1
2
|
let zod = require("zod");
|
|
3
|
+
zod = require_runtime.__toESM(zod);
|
|
2
4
|
|
|
3
5
|
//#region src/content-schema.ts
|
|
4
|
-
const looseObject = (shape) => zod.
|
|
5
|
-
const metaSchema = zod.
|
|
6
|
+
const looseObject = (shape) => zod.object(shape).loose();
|
|
7
|
+
const metaSchema = zod.record(zod.string(), zod.unknown());
|
|
6
8
|
const annotationsSchema = looseObject({
|
|
7
|
-
audience: zod.
|
|
8
|
-
priority: zod.
|
|
9
|
-
lastModified: zod.
|
|
9
|
+
audience: zod.array(zod.enum(["user", "assistant"])).optional(),
|
|
10
|
+
priority: zod.number().min(0).max(1).optional(),
|
|
11
|
+
lastModified: zod.string().optional()
|
|
10
12
|
});
|
|
11
|
-
const base64Schema = zod.
|
|
13
|
+
const base64Schema = zod.string().refine((value) => {
|
|
12
14
|
try {
|
|
13
15
|
atob(value);
|
|
14
16
|
return true;
|
|
@@ -16,69 +18,69 @@ const base64Schema = zod.z.string().refine((value) => {
|
|
|
16
18
|
return false;
|
|
17
19
|
}
|
|
18
20
|
}, "Expected base64-encoded data");
|
|
19
|
-
const resourceContentsSchema = zod.
|
|
20
|
-
uri: zod.
|
|
21
|
-
mimeType: zod.
|
|
22
|
-
text: zod.
|
|
21
|
+
const resourceContentsSchema = zod.union([looseObject({
|
|
22
|
+
uri: zod.string(),
|
|
23
|
+
mimeType: zod.string().optional(),
|
|
24
|
+
text: zod.string(),
|
|
23
25
|
_meta: metaSchema.optional()
|
|
24
26
|
}), looseObject({
|
|
25
|
-
uri: zod.
|
|
26
|
-
mimeType: zod.
|
|
27
|
+
uri: zod.string(),
|
|
28
|
+
mimeType: zod.string().optional(),
|
|
27
29
|
blob: base64Schema,
|
|
28
30
|
_meta: metaSchema.optional()
|
|
29
31
|
})]);
|
|
30
|
-
const contentItemSchema = zod.
|
|
32
|
+
const contentItemSchema = zod.discriminatedUnion("type", [
|
|
31
33
|
looseObject({
|
|
32
|
-
type: zod.
|
|
33
|
-
text: zod.
|
|
34
|
+
type: zod.literal("text"),
|
|
35
|
+
text: zod.string(),
|
|
34
36
|
annotations: annotationsSchema.optional(),
|
|
35
37
|
_meta: metaSchema.optional()
|
|
36
38
|
}),
|
|
37
39
|
looseObject({
|
|
38
|
-
type: zod.
|
|
40
|
+
type: zod.literal("image"),
|
|
39
41
|
data: base64Schema,
|
|
40
|
-
mimeType: zod.
|
|
42
|
+
mimeType: zod.string(),
|
|
41
43
|
annotations: annotationsSchema.optional(),
|
|
42
44
|
_meta: metaSchema.optional()
|
|
43
45
|
}),
|
|
44
46
|
looseObject({
|
|
45
|
-
type: zod.
|
|
47
|
+
type: zod.literal("audio"),
|
|
46
48
|
data: base64Schema,
|
|
47
|
-
mimeType: zod.
|
|
49
|
+
mimeType: zod.string(),
|
|
48
50
|
annotations: annotationsSchema.optional(),
|
|
49
51
|
_meta: metaSchema.optional()
|
|
50
52
|
}),
|
|
51
53
|
looseObject({
|
|
52
|
-
type: zod.
|
|
54
|
+
type: zod.literal("resource"),
|
|
53
55
|
resource: resourceContentsSchema,
|
|
54
56
|
annotations: annotationsSchema.optional(),
|
|
55
57
|
_meta: metaSchema.optional()
|
|
56
58
|
}),
|
|
57
59
|
looseObject({
|
|
58
|
-
type: zod.
|
|
59
|
-
uri: zod.
|
|
60
|
-
name: zod.
|
|
61
|
-
title: zod.
|
|
62
|
-
description: zod.
|
|
63
|
-
mimeType: zod.
|
|
64
|
-
size: zod.
|
|
60
|
+
type: zod.literal("resource_link"),
|
|
61
|
+
uri: zod.string(),
|
|
62
|
+
name: zod.string(),
|
|
63
|
+
title: zod.string().optional(),
|
|
64
|
+
description: zod.string().optional(),
|
|
65
|
+
mimeType: zod.string().optional(),
|
|
66
|
+
size: zod.number().optional(),
|
|
65
67
|
annotations: annotationsSchema.optional(),
|
|
66
68
|
_meta: metaSchema.optional()
|
|
67
69
|
})
|
|
68
70
|
]);
|
|
69
71
|
const callToolResultSchema = looseObject({
|
|
70
|
-
content: zod.
|
|
71
|
-
structuredContent: zod.
|
|
72
|
-
isError: zod.
|
|
73
|
-
_meta: zod.
|
|
72
|
+
content: zod.array(contentItemSchema).default([]),
|
|
73
|
+
structuredContent: zod.record(zod.string(), zod.unknown()).optional(),
|
|
74
|
+
isError: zod.boolean().optional(),
|
|
75
|
+
_meta: zod.record(zod.string(), zod.unknown()).optional()
|
|
74
76
|
});
|
|
75
77
|
/** Activity input accepts an omitted result.content; validation defaults it to []. */
|
|
76
78
|
const MCPAppsActivityContentSchema = looseObject({
|
|
77
79
|
result: callToolResultSchema,
|
|
78
|
-
resourceUri: zod.
|
|
79
|
-
serverHash: zod.
|
|
80
|
-
serverId: zod.
|
|
81
|
-
toolInput: zod.
|
|
80
|
+
resourceUri: zod.string(),
|
|
81
|
+
serverHash: zod.string(),
|
|
82
|
+
serverId: zod.string().optional(),
|
|
83
|
+
toolInput: zod.record(zod.string(), zod.unknown()).optional()
|
|
82
84
|
});
|
|
83
85
|
|
|
84
86
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-schema.cjs","names":["z"],"sources":["../src/content-schema.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"content-schema.cjs","names":["z"],"sources":["../src/content-schema.ts"],"sourcesContent":["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"],"mappings":";;;;;AAIA,MAAM,eAAwC,UAC5CA,IAAE,OAAO,MAAM,CAAC,OAAO;AAKzB,MAAM,aAAaA,IAAE,OAAOA,IAAE,QAAQ,EAAEA,IAAE,SAAS,CAAC;AAEpD,MAAM,oBAAoB,YAAY;CACpC,UAAUA,IAAE,MAAMA,IAAE,KAAK,CAAC,QAAQ,YAAY,CAAC,CAAC,CAAC,UAAU;CAC3D,UAAUA,IAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,UAAU;CAC7C,cAAcA,IAAE,QAAQ,CAAC,UAAU;CACpC,CAAC;AAMF,MAAM,eAAeA,IAAE,QAAQ,CAAC,QAAQ,UAAU;AAChD,KAAI;AACF,OAAK,MAAM;AACX,SAAO;SACD;AACN,SAAO;;GAER,+BAA+B;AAElC,MAAM,yBAAyBA,IAAE,MAAM,CACrC,YAAY;CACV,KAAKA,IAAE,QAAQ;CACf,UAAUA,IAAE,QAAQ,CAAC,UAAU;CAC/B,MAAMA,IAAE,QAAQ;CAChB,OAAO,WAAW,UAAU;CAC7B,CAAC,EACF,YAAY;CACV,KAAKA,IAAE,QAAQ;CACf,UAAUA,IAAE,QAAQ,CAAC,UAAU;CAC/B,MAAM;CACN,OAAO,WAAW,UAAU;CAC7B,CAAC,CACH,CAAC;AAEF,MAAM,oBAAoBA,IAAE,mBAAmB,QAA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