@copilotkit/angular 0.5.3 → 2.0.0-rc.52

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.
Files changed (37) hide show
  1. package/.attw.json +1 -2
  2. package/README.md +31 -133
  3. package/dist/README.md +31 -133
  4. package/dist/fesm2022/copilotkit-angular-generative-ui-chart.mjs +28 -0
  5. package/dist/fesm2022/copilotkit-angular-generative-ui-chart.mjs.map +1 -0
  6. package/dist/fesm2022/copilotkit-angular-generative-ui-icons.mjs +30 -0
  7. package/dist/fesm2022/copilotkit-angular-generative-ui-icons.mjs.map +1 -0
  8. package/dist/fesm2022/copilotkit-angular-generative-ui-map.mjs +28 -0
  9. package/dist/fesm2022/copilotkit-angular-generative-ui-map.mjs.map +1 -0
  10. package/dist/fesm2022/copilotkit-angular-generative-ui.mjs +11975 -0
  11. package/dist/fesm2022/copilotkit-angular-generative-ui.mjs.map +1 -0
  12. package/dist/fesm2022/copilotkit-angular-mcp-apps.mjs +43 -142
  13. package/dist/fesm2022/copilotkit-angular-mcp-apps.mjs.map +1 -1
  14. package/dist/fesm2022/copilotkit-angular.mjs +7436 -7448
  15. package/dist/fesm2022/copilotkit-angular.mjs.map +1 -1
  16. package/dist/types/copilotkit-angular-generative-ui-chart.d.ts +16 -0
  17. package/dist/types/copilotkit-angular-generative-ui-chart.d.ts.map +1 -0
  18. package/dist/types/copilotkit-angular-generative-ui-icons.d.ts +18 -0
  19. package/dist/types/copilotkit-angular-generative-ui-icons.d.ts.map +1 -0
  20. package/dist/types/copilotkit-angular-generative-ui-map.d.ts +16 -0
  21. package/dist/types/copilotkit-angular-generative-ui-map.d.ts.map +1 -0
  22. package/dist/types/copilotkit-angular-generative-ui.d.ts +8011 -0
  23. package/dist/types/copilotkit-angular-generative-ui.d.ts.map +1 -0
  24. package/dist/types/copilotkit-angular-mcp-apps.d.ts +234 -5560
  25. package/dist/types/copilotkit-angular-mcp-apps.d.ts.map +1 -1
  26. package/dist/types/copilotkit-angular.d.ts +1217 -812
  27. package/dist/types/copilotkit-angular.d.ts.map +1 -1
  28. package/package.json +54 -39
  29. package/scripts/generate-stylesheet.mjs +63 -0
  30. package/tsconfig.json +11 -1
  31. package/vitest.config.mts +6 -0
  32. package/dist/fesm2022/copilotkit-angular-a2ui.mjs +0 -1492
  33. package/dist/fesm2022/copilotkit-angular-a2ui.mjs.map +0 -1
  34. package/dist/styles.css +0 -2679
  35. package/dist/types/copilotkit-angular-a2ui.d.ts +0 -178
  36. package/dist/types/copilotkit-angular-a2ui.d.ts.map +0 -1
  37. package/scripts/scope-preflight.mjs +0 -100
@@ -1,7 +1,7 @@
1
- import { MCPAppsActivityContentSchema } from '@copilotkit/mcp-apps-renderer/activity';
1
+ import { MCPAppsActivityContentSchema, ɵMcpAppHost as _McpAppHost } from '@copilotkit/mcp-apps-renderer/activity';
2
2
  import { isPlatformBrowser } from '@angular/common';
3
3
  import * as i0 from '@angular/core';
4
- import { InjectionToken, inject, PLATFORM_ID, input, computed, viewChild, signal, afterRenderEffect, untracked, ChangeDetectionStrategy, Component, makeEnvironmentProviders } from '@angular/core';
4
+ import { InjectionToken, input, inject, PLATFORM_ID, signal, viewChild, DestroyRef, afterRenderEffect, ChangeDetectionStrategy, Component, makeEnvironmentProviders } from '@angular/core';
5
5
  import { CopilotKit, ɵCOPILOTKIT_BUILT_IN_ACTIVITY_RENDERERS as _COPILOTKIT_BUILT_IN_ACTIVITY_RENDERERS } from '@copilotkit/angular';
6
6
 
7
7
  /** Preserve the Angular export while sharing the runtime content contract. */
@@ -22,16 +22,16 @@ const DEFAULT_MCP_APPS_CONFIG = {
22
22
  hostContext: {
23
23
  platform: "web",
24
24
  },
25
+ allowSameOriginFallback: false,
25
26
  };
26
27
  /** Holds renderer behavior configuration registered via `provideMCPApps`. */
27
28
  const MCP_APPS_CONFIG = new InjectionToken("MCP_APPS_CONFIG", { factory: () => ({ ...DEFAULT_MCP_APPS_CONFIG }) });
28
29
 
29
- /** Angular owns the DOM and reactive state; the shared session owns MCP. */
30
+ /**
31
+ * Angular draws the state; the shared `ɵMcpAppHost` owns the iframe, its size
32
+ * and the MCP session (scoped to the widget, Angular's contract).
33
+ */
30
34
  class CopilotMCPAppsWidget {
31
- config = inject(MCP_APPS_CONFIG);
32
- copilotKit = inject(CopilotKit);
33
- platformId = inject(PLATFORM_ID);
34
- session;
35
35
  data = input.required(/* @ts-ignore */
36
36
  ...(ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []));
37
37
  agent = input(/* @ts-ignore */
@@ -39,167 +39,68 @@ class CopilotMCPAppsWidget {
39
39
  /** Omitted for direct widget use with external, prop-driven content. */
40
40
  messageId = input(/* @ts-ignore */
41
41
  ...(ngDevMode ? [undefined, { debugName: "messageId" }] : /* istanbul ignore next */ []));
42
- identity = computed(() => {
43
- const { resourceUri, serverHash, serverId } = this.data();
44
- return { resourceUri, serverHash, serverId };
45
- }, { ...(ngDevMode ? { debugName: "identity" } : /* istanbul ignore next */ {}), equal: (a, b) => a.resourceUri === b.resourceUri &&
46
- a.serverHash === b.serverHash &&
47
- a.serverId === b.serverId });
48
- appFrame = viewChild.required("appFrame");
49
- loading = signal(true, /* @ts-ignore */
50
- ...(ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []));
51
- error = signal("", /* @ts-ignore */
52
- ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
53
- contentError = signal("", /* @ts-ignore */
54
- ...(ngDevMode ? [{ debugName: "contentError" }] : /* istanbul ignore next */ []));
42
+ isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
43
+ app = new _McpAppHost({
44
+ host: inject(CopilotKit).core,
45
+ sessionOptions: inject(MCP_APPS_CONFIG),
46
+ scopeToWidget: true,
47
+ iframeAttributes: {
48
+ "data-testid": "mcp-app-iframe",
49
+ title: "Interactive MCP application",
50
+ },
51
+ importRenderer: () => import('@copilotkit/mcp-apps-renderer'),
52
+ });
53
+ state = signal(this.app.getState(), /* @ts-ignore */
54
+ ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
55
+ appContainer = viewChild.required("appContainer");
55
56
  constructor() {
56
- afterRenderEffect((onCleanup) => {
57
- this.identity();
58
- const agent = this.agent();
59
- const messageId = this.messageId();
60
- const frame = this.appFrame().nativeElement;
61
- let active = true;
62
- let session;
63
- this.loading.set(true);
64
- this.error.set("");
65
- this.contentError.set("");
66
- frame.style.removeProperty("height");
67
- frame.removeAttribute("src");
68
- frame.removeAttribute("srcdoc");
69
- frame.removeAttribute("data-mcp-app-initialized");
70
- onCleanup(() => {
71
- active = false;
72
- session?.teardown();
73
- if (this.session === session)
74
- this.session = undefined;
75
- frame.removeAttribute("srcdoc");
76
- frame.removeAttribute("src");
77
- frame.removeAttribute("data-mcp-app-initialized");
78
- });
79
- if (!isPlatformBrowser(this.platformId)) {
80
- this.loading.set(false);
81
- return;
82
- }
83
- if (!agent) {
84
- this.loading.set(false);
85
- this.error.set("No agent is available to load this MCP App.");
86
- return;
87
- }
88
- const fail = (error) => {
89
- if (!active)
90
- return;
91
- this.loading.set(false);
92
- this.error.set(error.message);
93
- session?.teardown();
94
- frame.removeAttribute("srcdoc");
95
- frame.removeAttribute("data-mcp-app-initialized");
96
- };
97
- // Cleanup is registered before importing, so an obsolete bind never starts.
98
- void import('@copilotkit/mcp-apps-renderer')
99
- .catch((importErr) => {
100
- // Name the packages and the fix: the raw module-resolution error
101
- // ("Failed to fetch dynamically imported module...") tells a user
102
- // nothing about what to install. Same message as React and Vue.
103
- throw new Error("MCP Apps require '@copilotkit/mcp-apps-renderer' and its " +
104
- "'@modelcontextprotocol/ext-apps' dependency. Reinstall your " +
105
- "dependencies if this package is missing.", { cause: importErr });
106
- })
107
- .then((mcp) => {
108
- if (!active)
109
- return;
110
- session = mcp.bindMcpApp({
111
- iframe: frame,
112
- getContent: () => untracked(this.data),
113
- getAgent: () => agent,
114
- messageId,
115
- host: this.copilotKit.core,
116
- options: this.config,
117
- cancelFollowUpsOnTeardown: true,
118
- requireExactResourceUri: true,
119
- cancelRunningWaitOnTeardown: true,
120
- hooks: {
121
- onSandboxReady: () => {
122
- if (active)
123
- this.loading.set(false);
124
- },
125
- onInitialized: () => {
126
- if (!active)
127
- return;
128
- this.loading.set(false);
129
- frame.setAttribute("data-mcp-app-initialized", "true");
130
- },
131
- onSizeChanged: ({ height }) => {
132
- if (active &&
133
- typeof height === "number" &&
134
- Number.isFinite(height) &&
135
- height > 0) {
136
- frame.style.height = `${Math.ceil(Math.min(height, 5000))}px`;
137
- }
138
- },
139
- onError: fail,
140
- onContentError: (err) => {
141
- if (active)
142
- this.contentError.set(err?.message ?? "");
143
- },
144
- onFollowUpError: fail,
145
- },
146
- });
147
- this.session = session;
148
- session.syncContent(untracked(this.data));
149
- })
150
- .catch(fail);
57
+ const unsubscribe = this.app.subscribe(() => this.state.set(this.app.getState()));
58
+ inject(DestroyRef).onDestroy(() => {
59
+ unsubscribe();
60
+ this.app.destroy();
151
61
  });
152
- // Content updates feed the existing session and never reload its iframe.
62
+ // Runs in the browser only, so nothing is created during SSR. Content
63
+ // updates feed the existing session and never reload its iframe.
153
64
  afterRenderEffect(() => {
154
- const data = this.data();
155
- untracked(() => this.session?.syncContent(data));
65
+ this.app.setAgent(this.agent());
66
+ this.app.setMessageId(this.messageId());
67
+ this.app.setContent(this.data());
68
+ this.app.setContainer(this.appContainer().nativeElement);
156
69
  });
157
70
  }
158
71
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotMCPAppsWidget, deps: [], target: i0.ɵɵFactoryTarget.Component });
159
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.0", type: CopilotMCPAppsWidget, isStandalone: true, selector: "copilot-mcp-apps-widget", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: true, transformFunction: null }, agent: { classPropertyName: "agent", publicName: "agent", isSignal: true, isRequired: false, transformFunction: null }, messageId: { classPropertyName: "messageId", publicName: "messageId", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "appFrame", first: true, predicate: ["appFrame"], descendants: true, isSignal: true }], ngImport: i0, template: `
160
- <div class="copilot-mcp-apps-container">
161
- @if (loading()) {
72
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.0", type: CopilotMCPAppsWidget, isStandalone: true, selector: "copilot-mcp-apps-widget", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: true, transformFunction: null }, agent: { classPropertyName: "agent", publicName: "agent", isSignal: true, isRequired: false, transformFunction: null }, messageId: { classPropertyName: "messageId", publicName: "messageId", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "appContainer", first: true, predicate: ["appContainer"], descendants: true, isSignal: true }], ngImport: i0, template: `
73
+ <div #appContainer class="copilot-mcp-apps-container">
74
+ @if (isBrowser && state().loading) {
162
75
  <p class="copilot-mcp-apps-status" role="status" aria-live="polite">
163
76
  Loading MCP App…
164
77
  </p>
165
78
  }
166
- @if (error() || contentError()) {
79
+ @if (state().error || state().contentError) {
167
80
  <p class="copilot-mcp-apps-error" role="alert">
168
- {{ error() || contentError() }}
81
+ {{ state().error || state().contentError }}
169
82
  </p>
170
83
  }
171
- <iframe
172
- #appFrame
173
- class="copilot-mcp-apps-frame"
174
- data-testid="mcp-app-iframe"
175
- title="Interactive MCP application"
176
- ></iframe>
177
84
  </div>
178
- `, isInline: true, styles: [".copilot-mcp-apps-container{position:relative;width:100%;min-height:100px;overflow:hidden}.copilot-mcp-apps-frame{display:block;width:100%;min-height:100px;border:0;background:transparent}.copilot-mcp-apps-status,.copilot-mcp-apps-error{margin:0;padding:16px}.copilot-mcp-apps-status{color:#525252}.copilot-mcp-apps-error{color:#991b1b}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
85
+ `, isInline: true, styles: [".copilot-mcp-apps-container{position:relative;width:100%;min-height:100px;overflow:hidden}.copilot-mcp-apps-status,.copilot-mcp-apps-error{margin:0;padding:16px}.copilot-mcp-apps-status{color:#525252}.copilot-mcp-apps-error{color:#991b1b}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
179
86
  }
180
87
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotMCPAppsWidget, decorators: [{
181
88
  type: Component,
182
89
  args: [{ selector: "copilot-mcp-apps-widget", changeDetection: ChangeDetectionStrategy.OnPush, template: `
183
- <div class="copilot-mcp-apps-container">
184
- @if (loading()) {
90
+ <div #appContainer class="copilot-mcp-apps-container">
91
+ @if (isBrowser && state().loading) {
185
92
  <p class="copilot-mcp-apps-status" role="status" aria-live="polite">
186
93
  Loading MCP App…
187
94
  </p>
188
95
  }
189
- @if (error() || contentError()) {
96
+ @if (state().error || state().contentError) {
190
97
  <p class="copilot-mcp-apps-error" role="alert">
191
- {{ error() || contentError() }}
98
+ {{ state().error || state().contentError }}
192
99
  </p>
193
100
  }
194
- <iframe
195
- #appFrame
196
- class="copilot-mcp-apps-frame"
197
- data-testid="mcp-app-iframe"
198
- title="Interactive MCP application"
199
- ></iframe>
200
101
  </div>
201
- `, styles: [".copilot-mcp-apps-container{position:relative;width:100%;min-height:100px;overflow:hidden}.copilot-mcp-apps-frame{display:block;width:100%;min-height:100px;border:0;background:transparent}.copilot-mcp-apps-status,.copilot-mcp-apps-error{margin:0;padding:16px}.copilot-mcp-apps-status{color:#525252}.copilot-mcp-apps-error{color:#991b1b}\n"] }]
202
- }], ctorParameters: () => [], propDecorators: { data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: true }] }], agent: [{ type: i0.Input, args: [{ isSignal: true, alias: "agent", required: false }] }], messageId: [{ type: i0.Input, args: [{ isSignal: true, alias: "messageId", required: false }] }], appFrame: [{ type: i0.ViewChild, args: ["appFrame", { isSignal: true }] }] } });
102
+ `, styles: [".copilot-mcp-apps-container{position:relative;width:100%;min-height:100px;overflow:hidden}.copilot-mcp-apps-status,.copilot-mcp-apps-error{margin:0;padding:16px}.copilot-mcp-apps-status{color:#525252}.copilot-mcp-apps-error{color:#991b1b}\n"] }]
103
+ }], ctorParameters: () => [], propDecorators: { data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: true }] }], agent: [{ type: i0.Input, args: [{ isSignal: true, alias: "agent", required: false }] }], messageId: [{ type: i0.Input, args: [{ isSignal: true, alias: "messageId", required: false }] }], appContainer: [{ type: i0.ViewChild, args: ["appContainer", { isSignal: true }] }] } });
203
104
 
204
105
  /**
205
106
  * Activity renderer for `mcp-apps` snapshots. Renders the referenced MCP App
@@ -1 +1 @@
1
- {"version":3,"file":"copilotkit-angular-mcp-apps.mjs","sources":["../../src/mcp-apps/lib/mcp-apps-content.ts","../../src/mcp-apps/lib/mcp-apps-config.ts","../../src/mcp-apps/lib/mcp-apps-widget.ts","../../src/mcp-apps/lib/mcp-apps-activity-renderer.ts","../../src/mcp-apps/lib/provide-mcp-apps.ts","../../src/mcp-apps/copilotkit-angular-mcp-apps.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { MCPAppsActivityContentSchema } from \"@copilotkit/mcp-apps-renderer/activity\";\n\n/** Preserve the Angular export while sharing the runtime content contract. */\nexport const mcpAppsSnapshotContentSchema = MCPAppsActivityContentSchema;\nexport type MCPAppsSnapshotContent = z.output<\n typeof mcpAppsSnapshotContentSchema\n>;\n","import { InjectionToken } from \"@angular/core\";\n\nexport interface MCPAppsHostInfo {\n name: string;\n version: string;\n}\n\nexport interface MCPAppsConfig {\n /** Maximum time to wait for a busy agent before a queued request fails. */\n idleTimeoutMs?: number;\n /** Maximum time to wait for the sandbox proxy initialization handshake. */\n initializationTimeoutMs?: number;\n /** Host identity announced during the MCP Apps initialization handshake. */\n hostInfo?: MCPAppsHostInfo;\n /** Additional protocol capabilities announced to embedded MCP Apps. */\n hostCapabilities?: Record<string, unknown>;\n /** Additional non-secret UI context announced to embedded MCP Apps. */\n hostContext?: Record<string, unknown>;\n}\n\nexport const DEFAULT_MCP_APPS_CONFIG: Readonly<Required<MCPAppsConfig>> = {\n idleTimeoutMs: 30_000,\n initializationTimeoutMs: 30_000,\n hostInfo: {\n name: \"CopilotKit MCP Apps Host\",\n version: \"1.0.0\",\n },\n hostCapabilities: {\n openLinks: {},\n serverTools: {},\n logging: {},\n },\n hostContext: {\n platform: \"web\",\n },\n};\n\n/** Holds renderer behavior configuration registered via `provideMCPApps`. */\nexport const MCP_APPS_CONFIG = new InjectionToken<Required<MCPAppsConfig>>(\n \"MCP_APPS_CONFIG\",\n { factory: () => ({ ...DEFAULT_MCP_APPS_CONFIG }) },\n);\n","import { isPlatformBrowser } from \"@angular/common\";\nimport type { AbstractAgent } from \"@ag-ui/client\";\nimport {\n ChangeDetectionStrategy,\n Component,\n ElementRef,\n PLATFORM_ID,\n afterRenderEffect,\n computed,\n inject,\n input,\n signal,\n untracked,\n viewChild,\n} from \"@angular/core\";\nimport { CopilotKit } from \"@copilotkit/angular\";\nimport type { McpAppSession } from \"@copilotkit/mcp-apps-renderer\";\nimport { type MCPAppsSnapshotContent } from \"./mcp-apps-content\";\nimport { MCP_APPS_CONFIG } from \"./mcp-apps-config\";\n\n/** Angular owns the DOM and reactive state; the shared session owns MCP. */\n@Component({\n selector: \"copilot-mcp-apps-widget\",\n changeDetection: ChangeDetectionStrategy.OnPush,\n template: `\n <div class=\"copilot-mcp-apps-container\">\n @if (loading()) {\n <p class=\"copilot-mcp-apps-status\" role=\"status\" aria-live=\"polite\">\n Loading MCP App…\n </p>\n }\n @if (error() || contentError()) {\n <p class=\"copilot-mcp-apps-error\" role=\"alert\">\n {{ error() || contentError() }}\n </p>\n }\n <iframe\n #appFrame\n class=\"copilot-mcp-apps-frame\"\n data-testid=\"mcp-app-iframe\"\n title=\"Interactive MCP application\"\n ></iframe>\n </div>\n `,\n styles: `\n .copilot-mcp-apps-container {\n position: relative;\n width: 100%;\n min-height: 100px;\n overflow: hidden;\n }\n\n .copilot-mcp-apps-frame {\n display: block;\n width: 100%;\n min-height: 100px;\n border: 0;\n background: transparent;\n }\n\n .copilot-mcp-apps-status,\n .copilot-mcp-apps-error {\n margin: 0;\n padding: 16px;\n }\n\n .copilot-mcp-apps-status {\n color: #525252;\n }\n\n .copilot-mcp-apps-error {\n color: #991b1b;\n }\n `,\n})\nexport class CopilotMCPAppsWidget {\n private readonly config = inject(MCP_APPS_CONFIG);\n private readonly copilotKit = inject(CopilotKit);\n private readonly platformId = inject(PLATFORM_ID);\n private session: McpAppSession | undefined;\n\n readonly data = input.required<MCPAppsSnapshotContent>();\n readonly agent = input<AbstractAgent | undefined>();\n /** Omitted for direct widget use with external, prop-driven content. */\n readonly messageId = input<string>();\n\n private readonly identity = computed(\n () => {\n const { resourceUri, serverHash, serverId } = this.data();\n return { resourceUri, serverHash, serverId };\n },\n {\n equal: (a, b) =>\n a.resourceUri === b.resourceUri &&\n a.serverHash === b.serverHash &&\n a.serverId === b.serverId,\n },\n );\n\n private readonly appFrame =\n viewChild.required<ElementRef<HTMLIFrameElement>>(\"appFrame\");\n protected readonly loading = signal(true);\n protected readonly error = signal(\"\");\n protected readonly contentError = signal(\"\");\n\n constructor() {\n afterRenderEffect((onCleanup) => {\n this.identity();\n const agent = this.agent();\n const messageId = this.messageId();\n const frame = this.appFrame().nativeElement;\n let active = true;\n let session: McpAppSession | undefined;\n this.loading.set(true);\n this.error.set(\"\");\n this.contentError.set(\"\");\n frame.style.removeProperty(\"height\");\n frame.removeAttribute(\"src\");\n frame.removeAttribute(\"srcdoc\");\n frame.removeAttribute(\"data-mcp-app-initialized\");\n onCleanup(() => {\n active = false;\n session?.teardown();\n if (this.session === session) this.session = undefined;\n frame.removeAttribute(\"srcdoc\");\n frame.removeAttribute(\"src\");\n frame.removeAttribute(\"data-mcp-app-initialized\");\n });\n if (!isPlatformBrowser(this.platformId)) {\n this.loading.set(false);\n return;\n }\n if (!agent) {\n this.loading.set(false);\n this.error.set(\"No agent is available to load this MCP App.\");\n return;\n }\n const fail = (error: Error) => {\n if (!active) return;\n this.loading.set(false);\n this.error.set(error.message);\n session?.teardown();\n frame.removeAttribute(\"srcdoc\");\n frame.removeAttribute(\"data-mcp-app-initialized\");\n };\n // Cleanup is registered before importing, so an obsolete bind never starts.\n void import(\"@copilotkit/mcp-apps-renderer\")\n .catch((importErr: unknown) => {\n // Name the packages and the fix: the raw module-resolution error\n // (\"Failed to fetch dynamically imported module...\") tells a user\n // nothing about what to install. Same message as React and Vue.\n throw new Error(\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 { cause: importErr },\n );\n })\n .then((mcp) => {\n if (!active) return;\n session = mcp.bindMcpApp({\n iframe: frame,\n getContent: () => untracked(this.data),\n getAgent: () => agent,\n messageId,\n host: this.copilotKit.core,\n options: this.config,\n cancelFollowUpsOnTeardown: true,\n requireExactResourceUri: true,\n cancelRunningWaitOnTeardown: true,\n hooks: {\n onSandboxReady: () => {\n if (active) this.loading.set(false);\n },\n onInitialized: () => {\n if (!active) return;\n this.loading.set(false);\n frame.setAttribute(\"data-mcp-app-initialized\", \"true\");\n },\n onSizeChanged: ({ height }) => {\n if (\n active &&\n typeof height === \"number\" &&\n Number.isFinite(height) &&\n height > 0\n ) {\n frame.style.height = `${Math.ceil(Math.min(height, 5000))}px`;\n }\n },\n onError: fail,\n onContentError: (err) => {\n if (active) this.contentError.set(err?.message ?? \"\");\n },\n onFollowUpError: fail,\n },\n });\n this.session = session;\n session.syncContent(untracked(this.data));\n })\n .catch(fail);\n });\n // Content updates feed the existing session and never reload its iframe.\n afterRenderEffect(() => {\n const data = this.data();\n untracked(() => this.session?.syncContent(data));\n });\n }\n}\n","import type { AbstractAgent, ActivityMessage } from \"@ag-ui/client\";\nimport { ChangeDetectionStrategy, Component, input } from \"@angular/core\";\nimport type {\n ActivityRenderer,\n RenderActivityMessageConfig,\n} from \"@copilotkit/angular\";\nimport {\n mcpAppsSnapshotContentSchema,\n type MCPAppsSnapshotContent,\n} from \"./mcp-apps-content\";\nimport { CopilotMCPAppsWidget } from \"./mcp-apps-widget\";\n\n/**\n * Activity renderer for `mcp-apps` snapshots. Renders the referenced MCP App\n * inline via {@link CopilotMCPAppsWidget}. Resource and tool requests are\n * proxied through the activity's selected AG-UI agent.\n */\n@Component({\n selector: \"copilot-mcp-apps-activity-renderer\",\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [CopilotMCPAppsWidget],\n template: `\n <copilot-mcp-apps-widget\n [data]=\"content()\"\n [agent]=\"agent()\"\n [messageId]=\"message().id\"\n />\n `,\n})\nexport class CopilotMCPAppsActivityRenderer implements ActivityRenderer<MCPAppsSnapshotContent> {\n readonly activityType = input.required<string>();\n readonly content = input.required<MCPAppsSnapshotContent>();\n readonly message = input.required<ActivityMessage>();\n readonly agent = input<AbstractAgent | undefined>();\n}\n\n/**\n * Ready-to-register render config for `mcp-apps` activity messages. Pass it\n * to `provideCopilotKit({ renderActivityMessages: [...] })`.\n */\nexport const mcpAppsActivityRendererConfig: RenderActivityMessageConfig<MCPAppsSnapshotContent> =\n {\n activityType: \"mcp-apps\",\n content: mcpAppsSnapshotContentSchema,\n component: CopilotMCPAppsActivityRenderer,\n };\n","import {\n makeEnvironmentProviders,\n type EnvironmentProviders,\n} from \"@angular/core\";\nimport { ɵCOPILOTKIT_BUILT_IN_ACTIVITY_RENDERERS } from \"@copilotkit/angular\";\nimport { mcpAppsActivityRendererConfig } from \"./mcp-apps-activity-renderer\";\nimport {\n DEFAULT_MCP_APPS_CONFIG,\n MCP_APPS_CONFIG,\n type MCPAppsConfig,\n type MCPAppsHostInfo,\n} from \"./mcp-apps-config\";\n\nexport type { MCPAppsConfig, MCPAppsHostInfo } from \"./mcp-apps-config\";\nexport { DEFAULT_MCP_APPS_CONFIG, MCP_APPS_CONFIG } from \"./mcp-apps-config\";\n\n/**\n * Configures and registers the built-in MCP Apps renderer.\n *\n * MCP resource and tool requests always travel through the selected AG-UI\n * agent. Server URLs deliberately are not accepted by this browser provider.\n * Application renderers retain precedence over this built-in registration.\n */\nexport function provideMCPApps(\n config: MCPAppsConfig = {},\n): EnvironmentProviders {\n const idleTimeoutMs =\n config.idleTimeoutMs ?? DEFAULT_MCP_APPS_CONFIG.idleTimeoutMs;\n if (!Number.isFinite(idleTimeoutMs) || idleTimeoutMs <= 0) {\n throw new RangeError(\"idleTimeoutMs must be a positive finite number.\");\n }\n return makeEnvironmentProviders([\n {\n provide: MCP_APPS_CONFIG,\n useValue: {\n ...DEFAULT_MCP_APPS_CONFIG,\n ...config,\n hostInfo: {\n ...DEFAULT_MCP_APPS_CONFIG.hostInfo,\n ...config.hostInfo,\n },\n hostCapabilities: {\n ...DEFAULT_MCP_APPS_CONFIG.hostCapabilities,\n ...config.hostCapabilities,\n },\n hostContext: {\n ...DEFAULT_MCP_APPS_CONFIG.hostContext,\n ...config.hostContext,\n },\n } satisfies Required<MCPAppsConfig>,\n },\n {\n provide: ɵCOPILOTKIT_BUILT_IN_ACTIVITY_RENDERERS,\n multi: true,\n useValue: mcpAppsActivityRendererConfig,\n },\n ]);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["ɵCOPILOTKIT_BUILT_IN_ACTIVITY_RENDERERS"],"mappings":";;;;;;AAGA;AACO,MAAM,4BAA4B,GAAG;;ACgBrC,MAAM,uBAAuB,GAAsC;AACxE,IAAA,aAAa,EAAE,MAAM;AACrB,IAAA,uBAAuB,EAAE,MAAM;AAC/B,IAAA,QAAQ,EAAE;AACR,QAAA,IAAI,EAAE,0BAA0B;AAChC,QAAA,OAAO,EAAE,OAAO;AACjB,KAAA;AACD,IAAA,gBAAgB,EAAE;AAChB,QAAA,SAAS,EAAE,EAAE;AACb,QAAA,WAAW,EAAE,EAAE;AACf,QAAA,OAAO,EAAE,EAAE;AACZ,KAAA;AACD,IAAA,WAAW,EAAE;AACX,QAAA,QAAQ,EAAE,KAAK;AAChB,KAAA;;AAGH;MACa,eA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AAC,QAAQ;AACnB,iBAAA;AACD,gBAAA,gBAAgB,EAAE;oBAChB,GAAG,uBAAuB,CAAC,gBAAgB;oBAC3C,GAAG,MAAM,CAAC,gBAAgB;AAC3B,iBAAA;AACD,gBAAA,WAAW,EAAE;oBACX,GAAG,uBAAuB,CAAC,WAAW;oBACtC,GAAG,MAAM,CAAC,WAAW;AACtB,iBAAA;AACgC,aAAA;AACpC,SAAA;AACD,QAAA;AACE,YAAA,OAAO,EAAEA,uCAAuC;AAChD,YAAA,KAAK,EAAE,IAAI;AACX,YAAA,QAAQ,EAAE,6BAA6B;AACxC,SAAA;AACF,KAAA,CAAC;AACJ;;ACzDA;;AAEG;;;;"}
1
+ {"version":3,"file":"copilotkit-angular-mcp-apps.mjs","sources":["../../src/mcp-apps/lib/mcp-apps-content.ts","../../src/mcp-apps/lib/mcp-apps-config.ts","../../src/mcp-apps/lib/mcp-apps-widget.ts","../../src/mcp-apps/lib/mcp-apps-activity-renderer.ts","../../src/mcp-apps/lib/provide-mcp-apps.ts","../../src/mcp-apps/copilotkit-angular-mcp-apps.ts"],"sourcesContent":["import * as z from \"zod\";\nimport { MCPAppsActivityContentSchema } from \"@copilotkit/mcp-apps-renderer/activity\";\n\n/** Preserve the Angular export while sharing the runtime content contract. */\nexport const mcpAppsSnapshotContentSchema = MCPAppsActivityContentSchema;\nexport type MCPAppsSnapshotContent = z.output<\n typeof mcpAppsSnapshotContentSchema\n>;\n","import { InjectionToken } from \"@angular/core\";\n\nexport interface MCPAppsHostInfo {\n name: string;\n version: string;\n}\n\nexport interface MCPAppsConfig {\n /** Maximum time to wait for a busy agent before a queued request fails. */\n idleTimeoutMs?: number;\n /** Maximum time to wait for the sandbox proxy initialization handshake. */\n initializationTimeoutMs?: number;\n /** Host identity announced during the MCP Apps initialization handshake. */\n hostInfo?: MCPAppsHostInfo;\n /** Additional protocol capabilities announced to embedded MCP Apps. */\n hostCapabilities?: Record<string, unknown>;\n /** Additional non-secret UI context announced to embedded MCP Apps. */\n hostContext?: Record<string, unknown>;\n /**\n * Restore `allow-same-origin` on the MCP App sandbox. Default `false`.\n *\n * **Unsafe.** The widget then runs with your page's origin: it can read\n * your cookies, storage and DOM, and call your APIs as the signed-in user.\n * Only set it for widgets you wrote and trust that need `localStorage`,\n * `IndexedDB` or cookies. By default widgets get an opaque origin.\n */\n allowSameOriginFallback?: boolean;\n}\n\nexport const DEFAULT_MCP_APPS_CONFIG: Readonly<Required<MCPAppsConfig>> = {\n idleTimeoutMs: 30_000,\n initializationTimeoutMs: 30_000,\n hostInfo: {\n name: \"CopilotKit MCP Apps Host\",\n version: \"1.0.0\",\n },\n hostCapabilities: {\n openLinks: {},\n serverTools: {},\n logging: {},\n },\n hostContext: {\n platform: \"web\",\n },\n allowSameOriginFallback: false,\n};\n\n/** Holds renderer behavior configuration registered via `provideMCPApps`. */\nexport const MCP_APPS_CONFIG = new InjectionToken<Required<MCPAppsConfig>>(\n \"MCP_APPS_CONFIG\",\n { factory: () => ({ ...DEFAULT_MCP_APPS_CONFIG }) },\n);\n","import { isPlatformBrowser } from \"@angular/common\";\nimport type { AbstractAgent } from \"@ag-ui/client\";\nimport {\n ChangeDetectionStrategy,\n Component,\n DestroyRef,\n ElementRef,\n PLATFORM_ID,\n afterRenderEffect,\n inject,\n input,\n signal,\n viewChild,\n} from \"@angular/core\";\nimport { CopilotKit } from \"@copilotkit/angular\";\nimport { ɵMcpAppHost } from \"@copilotkit/mcp-apps-renderer/activity\";\nimport { type MCPAppsSnapshotContent } from \"./mcp-apps-content\";\nimport { MCP_APPS_CONFIG } from \"./mcp-apps-config\";\n\n/**\n * Angular draws the state; the shared `ɵMcpAppHost` owns the iframe, its size\n * and the MCP session (scoped to the widget, Angular's contract).\n */\n@Component({\n selector: \"copilot-mcp-apps-widget\",\n changeDetection: ChangeDetectionStrategy.OnPush,\n template: `\n <div #appContainer class=\"copilot-mcp-apps-container\">\n @if (isBrowser && state().loading) {\n <p class=\"copilot-mcp-apps-status\" role=\"status\" aria-live=\"polite\">\n Loading MCP App…\n </p>\n }\n @if (state().error || state().contentError) {\n <p class=\"copilot-mcp-apps-error\" role=\"alert\">\n {{ state().error || state().contentError }}\n </p>\n }\n </div>\n `,\n styles: `\n .copilot-mcp-apps-container {\n position: relative;\n width: 100%;\n min-height: 100px;\n overflow: hidden;\n }\n\n .copilot-mcp-apps-status,\n .copilot-mcp-apps-error {\n margin: 0;\n padding: 16px;\n }\n\n .copilot-mcp-apps-status {\n color: #525252;\n }\n\n .copilot-mcp-apps-error {\n color: #991b1b;\n }\n `,\n})\nexport class CopilotMCPAppsWidget {\n readonly data = input.required<MCPAppsSnapshotContent>();\n readonly agent = input<AbstractAgent | undefined>();\n /** Omitted for direct widget use with external, prop-driven content. */\n readonly messageId = input<string>();\n\n protected readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n private readonly app = new ɵMcpAppHost({\n host: inject(CopilotKit).core,\n sessionOptions: inject(MCP_APPS_CONFIG),\n scopeToWidget: true,\n iframeAttributes: {\n \"data-testid\": \"mcp-app-iframe\",\n title: \"Interactive MCP application\",\n },\n importRenderer: () => import(\"@copilotkit/mcp-apps-renderer\"),\n });\n protected readonly state = signal(this.app.getState());\n private readonly appContainer =\n viewChild.required<ElementRef<HTMLDivElement>>(\"appContainer\");\n\n constructor() {\n const unsubscribe = this.app.subscribe(() =>\n this.state.set(this.app.getState()),\n );\n inject(DestroyRef).onDestroy(() => {\n unsubscribe();\n this.app.destroy();\n });\n // Runs in the browser only, so nothing is created during SSR. Content\n // updates feed the existing session and never reload its iframe.\n afterRenderEffect(() => {\n this.app.setAgent(this.agent());\n this.app.setMessageId(this.messageId());\n this.app.setContent(this.data());\n this.app.setContainer(this.appContainer().nativeElement);\n });\n }\n}\n","import type { AbstractAgent, ActivityMessage } from \"@ag-ui/client\";\nimport { ChangeDetectionStrategy, Component, input } from \"@angular/core\";\nimport type {\n ActivityRenderer,\n RenderActivityMessageConfig,\n} from \"@copilotkit/angular\";\nimport {\n mcpAppsSnapshotContentSchema,\n type MCPAppsSnapshotContent,\n} from \"./mcp-apps-content\";\nimport { CopilotMCPAppsWidget } from \"./mcp-apps-widget\";\n\n/**\n * Activity renderer for `mcp-apps` snapshots. Renders the referenced MCP App\n * inline via {@link CopilotMCPAppsWidget}. Resource and tool requests are\n * proxied through the activity's selected AG-UI agent.\n */\n@Component({\n selector: \"copilot-mcp-apps-activity-renderer\",\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [CopilotMCPAppsWidget],\n template: `\n <copilot-mcp-apps-widget\n [data]=\"content()\"\n [agent]=\"agent()\"\n [messageId]=\"message().id\"\n />\n `,\n})\nexport class CopilotMCPAppsActivityRenderer implements ActivityRenderer<MCPAppsSnapshotContent> {\n readonly activityType = input.required<string>();\n readonly content = input.required<MCPAppsSnapshotContent>();\n readonly message = input.required<ActivityMessage>();\n readonly agent = input<AbstractAgent | undefined>();\n}\n\n/**\n * Ready-to-register render config for `mcp-apps` activity messages. Pass it\n * to `provideCopilotKit({ renderActivityMessages: [...] })`.\n */\nexport const mcpAppsActivityRendererConfig: RenderActivityMessageConfig<MCPAppsSnapshotContent> =\n {\n activityType: \"mcp-apps\",\n content: mcpAppsSnapshotContentSchema,\n component: CopilotMCPAppsActivityRenderer,\n };\n","import {\n makeEnvironmentProviders,\n type EnvironmentProviders,\n} from \"@angular/core\";\nimport { ɵCOPILOTKIT_BUILT_IN_ACTIVITY_RENDERERS } from \"@copilotkit/angular\";\nimport { mcpAppsActivityRendererConfig } from \"./mcp-apps-activity-renderer\";\nimport {\n DEFAULT_MCP_APPS_CONFIG,\n MCP_APPS_CONFIG,\n type MCPAppsConfig,\n type MCPAppsHostInfo,\n} from \"./mcp-apps-config\";\n\nexport type { MCPAppsConfig, MCPAppsHostInfo } from \"./mcp-apps-config\";\nexport { DEFAULT_MCP_APPS_CONFIG, MCP_APPS_CONFIG } from \"./mcp-apps-config\";\n\n/**\n * Configures and registers the built-in MCP Apps renderer.\n *\n * MCP resource and tool requests always travel through the selected AG-UI\n * agent. Server URLs deliberately are not accepted by this browser provider.\n * Application renderers retain precedence over this built-in registration.\n */\nexport function provideMCPApps(\n config: MCPAppsConfig = {},\n): EnvironmentProviders {\n const idleTimeoutMs =\n config.idleTimeoutMs ?? DEFAULT_MCP_APPS_CONFIG.idleTimeoutMs;\n if (!Number.isFinite(idleTimeoutMs) || idleTimeoutMs <= 0) {\n throw new RangeError(\"idleTimeoutMs must be a positive finite number.\");\n }\n return makeEnvironmentProviders([\n {\n provide: MCP_APPS_CONFIG,\n useValue: {\n ...DEFAULT_MCP_APPS_CONFIG,\n ...config,\n hostInfo: {\n ...DEFAULT_MCP_APPS_CONFIG.hostInfo,\n ...config.hostInfo,\n },\n hostCapabilities: {\n ...DEFAULT_MCP_APPS_CONFIG.hostCapabilities,\n ...config.hostCapabilities,\n },\n hostContext: {\n ...DEFAULT_MCP_APPS_CONFIG.hostContext,\n ...config.hostContext,\n },\n } satisfies Required<MCPAppsConfig>,\n },\n {\n provide: ɵCOPILOTKIT_BUILT_IN_ACTIVITY_RENDERERS,\n multi: true,\n useValue: mcpAppsActivityRendererConfig,\n },\n ]);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["ɵMcpAppHost","ɵCOPILOTKIT_BUILT_IN_ACTIVITY_RENDERERS"],"mappings":";;;;;;AAGA;AACO,MAAM,4BAA4B,GAAG;;ACyBrC,MAAM,uBAAuB,GAAsC;AACxE,IAAA,aAAa,EAAE,MAAM;AACrB,IAAA,uBAAuB,EAAE,MAAM;AAC/B,IAAA,QAAQ,EAAE;AACR,QAAA,IAAI,EAAE,0BAA0B;AAChC,QAAA,OAAO,EAAE,OAAO;AACjB,KAAA;AACD,IAAA,gBAAgB,EAAE;AAChB,QAAA,SAAS,EAAE,EAAE;AACb,QAAA,WAAW,EAAE,EAAE;AACf,QAAA,OAAO,EAAE,EAAE;AACZ,KAAA;AACD,IAAA,WAAW,EAAE;AACX,QAAA,QAAQ,EAAE,KAAK;AAChB,K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