@apollo/client-ai-apps 0.5.3 → 0.6.0

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 (71) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/dist/config/defineConfig.d.ts +1 -0
  3. package/dist/config/defineConfig.d.ts.map +1 -1
  4. package/dist/config/schema.d.ts +1 -0
  5. package/dist/config/schema.d.ts.map +1 -1
  6. package/dist/config/schema.js +1 -0
  7. package/dist/config/schema.js.map +1 -1
  8. package/dist/mcp/core/McpAppManager.d.ts +2 -1
  9. package/dist/mcp/core/McpAppManager.d.ts.map +1 -1
  10. package/dist/mcp/core/McpAppManager.js +11 -1
  11. package/dist/mcp/core/McpAppManager.js.map +1 -1
  12. package/dist/mcp/react/hooks/useHostContext.d.ts +2 -0
  13. package/dist/mcp/react/hooks/useHostContext.d.ts.map +1 -0
  14. package/dist/mcp/react/hooks/useHostContext.js +7 -0
  15. package/dist/mcp/react/hooks/useHostContext.js.map +1 -0
  16. package/dist/mcp/react/index.d.ts +1 -0
  17. package/dist/mcp/react/index.d.ts.map +1 -1
  18. package/dist/mcp/react/index.js +1 -0
  19. package/dist/mcp/react/index.js.map +1 -1
  20. package/dist/openai/core/McpAppManager.d.ts +2 -1
  21. package/dist/openai/core/McpAppManager.d.ts.map +1 -1
  22. package/dist/openai/core/McpAppManager.js +11 -1
  23. package/dist/openai/core/McpAppManager.js.map +1 -1
  24. package/dist/openai/react/hooks/useHostContext.d.ts +2 -0
  25. package/dist/openai/react/hooks/useHostContext.d.ts.map +1 -0
  26. package/dist/openai/react/hooks/useHostContext.js +7 -0
  27. package/dist/openai/react/hooks/useHostContext.js.map +1 -0
  28. package/dist/openai/react/index.d.ts +1 -0
  29. package/dist/openai/react/index.d.ts.map +1 -1
  30. package/dist/openai/react/index.js +1 -0
  31. package/dist/openai/react/index.js.map +1 -1
  32. package/dist/react/index.d.ts +1 -0
  33. package/dist/react/index.d.ts.map +1 -1
  34. package/dist/react/index.js +1 -0
  35. package/dist/react/index.js.map +1 -1
  36. package/dist/react/index.mcp.d.ts +1 -1
  37. package/dist/react/index.mcp.d.ts.map +1 -1
  38. package/dist/react/index.mcp.js +1 -1
  39. package/dist/react/index.mcp.js.map +1 -1
  40. package/dist/react/index.openai.d.ts +1 -1
  41. package/dist/react/index.openai.d.ts.map +1 -1
  42. package/dist/react/index.openai.js +1 -1
  43. package/dist/react/index.openai.js.map +1 -1
  44. package/dist/types/application-manifest.d.ts +1 -0
  45. package/dist/types/application-manifest.d.ts.map +1 -1
  46. package/dist/types/application-manifest.js.map +1 -1
  47. package/dist/vite/__tests__/utilities/build.d.ts.map +1 -1
  48. package/dist/vite/__tests__/utilities/build.js +0 -1
  49. package/dist/vite/__tests__/utilities/build.js.map +1 -1
  50. package/dist/vite/apolloClientAiApps.d.ts +1 -0
  51. package/dist/vite/apolloClientAiApps.d.ts.map +1 -1
  52. package/dist/vite/apolloClientAiApps.js +63 -46
  53. package/dist/vite/apolloClientAiApps.js.map +1 -1
  54. package/package.json +1 -4
  55. package/src/config/schema.ts +1 -0
  56. package/src/mcp/core/McpAppManager.ts +23 -1
  57. package/src/mcp/react/hooks/__tests__/useHostContext.test.tsx +95 -0
  58. package/src/mcp/react/hooks/useHostContext.ts +14 -0
  59. package/src/mcp/react/index.ts +1 -0
  60. package/src/openai/core/McpAppManager.ts +22 -1
  61. package/src/openai/react/hooks/useHostContext.ts +14 -0
  62. package/src/openai/react/index.ts +1 -0
  63. package/src/react/index.mcp.ts +1 -0
  64. package/src/react/index.openai.ts +1 -0
  65. package/src/react/index.ts +3 -0
  66. package/src/testing/internal/mcp/mockMcpHost.ts +12 -0
  67. package/src/testing/internal/utilities/mockApplicationManifest.ts +1 -0
  68. package/src/types/application-manifest.ts +1 -0
  69. package/src/vite/__tests__/apolloClientAiApps.test.ts +460 -61
  70. package/src/vite/__tests__/utilities/build.ts +0 -1
  71. package/src/vite/apolloClientAiApps.ts +100 -57
package/CHANGELOG.md CHANGED
@@ -1,3 +1,68 @@
1
+ ## 0.6.0 (2026-03-06)
2
+
3
+ ### Breaking Changes
4
+
5
+ #### Added a new required `appsOutDir` option to the `apolloClientAiApps` Vite plugin
6
+
7
+ The `apolloClientAiApps` Vite plugin now requires an `appsOutDir` option that controls where build output is written. The value must end with `apps` as the final path segment (e.g. `"dist/apps"`).
8
+
9
+ ```ts
10
+ apolloClientAiApps({ targets: ["mcp"], appsOutDir: "dist/apps" });
11
+ ```
12
+
13
+ The plugin will now write the application manifest to `<appsOutDir>/<appName>/.application-manifest.json`, where `appName` is taken from the `name` field in your `apollo-client-ai-apps` config or `package.json`. Previously, the output location was derived from `build.outDir` in your Vite config. Setting `build.outDir` alongside this plugin will now emit a warning that it is ignored.
14
+
15
+ This option replaces `build.outDir`. Setting `build.outDir` now emits a warning and the value is ignored. To migrate, please move the path from `build.outDir` to the `appsOutDir` option in the `apolloClientAiApps` plugin.
16
+
17
+ ```diff
18
+ // vite.config.ts
19
+ export default defineConfig({
20
+ - build: {
21
+ - outDir: "../../apps",
22
+ - },
23
+ plugins: [
24
+ apolloClientAiApps({
25
+ targets: ["mcp"],
26
+ + appsOutDir: "../../apps" ,
27
+ }),
28
+ ],
29
+ });
30
+ ```
31
+
32
+ ### Features
33
+
34
+ #### Add `baseUriDomains` to CSP config
35
+
36
+ Adds support for configuring `baseUriDomains` in CSP settings. Only available for MCP apps.
37
+
38
+ #### Add a `useHostContext` hook
39
+
40
+ Adds a new `useHostContext` hook that returns the current host context from the MCP host.
41
+
42
+ ```typescript
43
+ import { useHostContext } from "@apollo/client-ai-apps/react";
44
+
45
+ function MyComponent() {
46
+ const hostContext = useHostContext();
47
+
48
+ // ...
49
+ }
50
+ ```
51
+
52
+ ### Fixes
53
+
54
+ #### `@modelcontextprotocol/ext-apps` is now a required peer dependency
55
+
56
+ `@modelcontextprotocol/ext-apps` is now a required peer dependency and must be installed along with this library.
57
+
58
+ ## 0.5.4 (2026-02-27)
59
+
60
+ ### Fixes
61
+
62
+ #### Fix build when using fragment definitions
63
+
64
+ Fix an issue where fragment definitions would cause the Vite build to crash.
65
+
1
66
  ## 0.5.3 (2026-02-26)
2
67
 
3
68
  ### Features
@@ -12,6 +12,7 @@ export declare function defineConfig(config: ApolloClientAiAppsConfig.Config): {
12
12
  frameDomains?: string[];
13
13
  redirectDomains?: string[];
14
14
  resourceDomains?: string[];
15
+ baseUriDomains?: string[];
15
16
  };
16
17
  widgetSettings?: {
17
18
  prefersBorder?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"defineConfig.d.ts","sourceRoot":"","sources":["../../src/config/defineConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAE3D;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,wBAAwB,CAAC,MAAM;;;;;;;;;;;;;;;;;;;;;;EAEnE"}
1
+ {"version":3,"file":"defineConfig.d.ts","sourceRoot":"","sources":["../../src/config/defineConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAE3D;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,wBAAwB,CAAC,MAAM;;;;;;;;;;;;;;;;;;;;;;;EAEnE"}
@@ -10,6 +10,7 @@ export declare const ApolloClientAiAppsConfigSchema: z.ZodObject<{
10
10
  frameDomains: z.ZodExactOptional<z.ZodArray<z.ZodString>>;
11
11
  redirectDomains: z.ZodExactOptional<z.ZodArray<z.ZodString>>;
12
12
  resourceDomains: z.ZodExactOptional<z.ZodArray<z.ZodString>>;
13
+ baseUriDomains: z.ZodExactOptional<z.ZodArray<z.ZodString>>;
13
14
  }, z.core.$strict>>;
14
15
  widgetSettings: z.ZodExactOptional<z.ZodObject<{
15
16
  prefersBorder: z.ZodExactOptional<z.ZodBoolean>;
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/config/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,SAAS,gCAA+B,CAAC;AAwBtD,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;kBA8CzC,CAAC"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/config/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,SAAS,gCAA+B,CAAC;AAwBtD,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;kBA+CzC,CAAC"}
@@ -23,6 +23,7 @@ export const ApolloClientAiAppsConfigSchema = z.strictObject({
23
23
  frameDomains: z.array(z.string()).exactOptional(),
24
24
  redirectDomains: z.array(z.string()).exactOptional(),
25
25
  resourceDomains: z.array(z.string()).exactOptional(),
26
+ baseUriDomains: z.array(z.string()).exactOptional(),
26
27
  })),
27
28
  widgetSettings: z.exactOptional(z.strictObject({
28
29
  prefersBorder: z.boolean().exactOptional(),
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/config/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;AAEtD,MAAM,IAAI,GAAG,CAAC;KACX,OAAO,CAAC,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;KACtC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAc,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC;AAEnE,MAAM,WAAW,GAAG,CAAC,CAAC,aAAa,CACjC,CAAC,CAAC,YAAY,CAAC;IACb,cAAc,EAAE,CAAC,CAAC,aAAa,CAC7B,CAAC,CAA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K,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,aAAa,EAAE;KACrD,CAAC,CACH;IACD,cAAc,EAAE,CAAC,CAAC,aAAa,CAC7B,CAAC,CAAC,YAAY,CAAC;QACb,aAAa,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,aAAa,EAAE;QAC1C,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,aAAa,EAAE;QACvC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,aAAa,EAAE;KACnC,CAAC,CACH;IACD,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,YAAY,EAAE;QACzC,MAAM,EAAE,GAAG,EAAE;YACX,qEAAqE;YACrE,wEAAwE;YACxE,qEAAqE;YACrE,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,MAAM,EAAE,CAAC,EAAE,cAAc,EAAE,EAAE,EAAE;YAC7B,MAAM,MAAM,GAAiC,EAAE,CAAC;YAEhD,IAAI,cAAc,EAAE,QAAQ,EAAE,CAAC;gBAC7B,MAAM,CAAC,yBAAyB,CAAC,GAAG,cAAc,CAAC,QAAQ,CAAC;YAC9D,CAAC;YAED,IAAI,cAAc,EAAE,OAAO,EAAE,CAAC;gBAC5B,MAAM,CAAC,wBAAwB,CAAC,GAAG,cAAc,CAAC,OAAO,CAAC;YAC5D,CAAC;YAED,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;CACH,CAAC,CAAC","sourcesContent":["import { z } from \"zod\";\n\nexport const AppTarget = z.literal([\"mcp\", \"openai\"]);\n\nconst Mode = z\n .literal([\"development\", \"production\"])\n .or(z.custom<string & {}>((value) => typeof value === \"string\"));\n\nconst labelsInput = z.exactOptional(\n z.strictObject({\n toolInvocation: z.exactOptional(\n z.strictObject({\n invoking: z.string().exactOptional(),\n invoked: z.string().exactOptional(),\n })\n ),\n })\n);\n\nconst labelsOutput = z.exactOptional(\n z.strictObject({\n \"toolInvocation/invoking\": z.string().exactOptional(),\n \"toolInvocation/invoked\": z.string().exactOptional(),\n })\n);\n\nexport const ApolloClientAiAppsConfigSchema = z.strictObject({\n name: z.string().exactOptional(),\n description: z.string().exactOptional(),\n version: z.string().exactOptional(),\n entry: z.exactOptional(\n z.partialRecord(\n Mode,\n z.union([z.string(), z.partialRecord(AppTarget, z.string())])\n )\n ),\n csp: z.exactOptional(\n z.strictObject({\n connectDomains: z.array(z.string()).exactOptional(),\n frameDomains: z.array(z.string()).exactOptional(),\n redirectDomains: z.array(z.string()).exactOptional(),\n resourceDomains: z.array(z.string()).exactOptional(),\n })\n ),\n widgetSettings: z.exactOptional(\n z.strictObject({\n prefersBorder: z.boolean().exactOptional(),\n description: z.string().exactOptional(),\n domain: z.string().exactOptional(),\n })\n ),\n labels: z.codec(labelsInput, labelsOutput, {\n encode: () => {\n // encode is currently not used so we can skip the business logic and\n // return an empty object which satisfies the type. If we need to encode\n // labels back to the original form, this will need to be implemented\n return {};\n },\n decode: ({ toolInvocation }) => {\n const config: z.infer<typeof labelsOutput> = {};\n\n if (toolInvocation?.invoking) {\n config[\"toolInvocation/invoking\"] = toolInvocation.invoking;\n }\n\n if (toolInvocation?.invoked) {\n config[\"toolInvocation/invoked\"] = toolInvocation.invoked;\n }\n\n return config;\n },\n }),\n});\n"]}
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/config/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;AAEtD,MAAM,IAAI,GAAG,CAAC;KACX,OAAO,CAAC,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;KACtC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAc,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC;AAEnE,MAAM,WAAW,G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AAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,aAAa,EAAE;QACpD,eAAe,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,aAAa,EAAE;QACpD,cAAc,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,aAAa,EAAE;KACpD,CAAC,CACH;IACD,cAAc,EAAE,CAAC,CAAC,aAAa,CAC7B,CAAC,CAAC,YAAY,CAAC;QACb,aAAa,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,aAAa,EAAE;QAC1C,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,aAAa,EAAE;QACvC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,aAAa,EAAE;KACnC,CAAC,CACH;IACD,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,YAAY,EAAE;QACzC,MAAM,EAAE,GAAG,EAAE;YACX,qEAAqE;YACrE,wEAAwE;YACxE,qEAAqE;YACrE,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,MAAM,EAAE,CAAC,EAAE,cAAc,EAAE,EAAE,EAAE;YAC7B,MAAM,MAAM,GAAiC,EAAE,CAAC;YAEhD,IAAI,cAAc,EAAE,QAAQ,EAAE,CAAC;gBAC7B,MAAM,CAAC,yBAAyB,CAAC,GAAG,cAAc,CAAC,QAAQ,CAAC;YAC9D,CAAC;YAED,IAAI,cAAc,EAAE,OAAO,EAAE,CAAC;gBAC5B,MAAM,CAAC,wBAAwB,CAAC,GAAG,cAAc,CAAC,OAAO,CAAC;YAC5D,CAAC;YAED,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;CACH,CAAC,CAAC","sourcesContent":["import { z } from \"zod\";\n\nexport const AppTarget = z.literal([\"mcp\", \"openai\"]);\n\nconst Mode = z\n .literal([\"development\", \"production\"])\n .or(z.custom<string & {}>((value) => typeof value === \"string\"));\n\nconst labelsInput = z.exactOptional(\n z.strictObject({\n toolInvocation: z.exactOptional(\n z.strictObject({\n invoking: z.string().exactOptional(),\n invoked: z.string().exactOptional(),\n })\n ),\n })\n);\n\nconst labelsOutput = z.exactOptional(\n z.strictObject({\n \"toolInvocation/invoking\": z.string().exactOptional(),\n \"toolInvocation/invoked\": z.string().exactOptional(),\n })\n);\n\nexport const ApolloClientAiAppsConfigSchema = z.strictObject({\n name: z.string().exactOptional(),\n description: z.string().exactOptional(),\n version: z.string().exactOptional(),\n entry: z.exactOptional(\n z.partialRecord(\n Mode,\n z.union([z.string(), z.partialRecord(AppTarget, z.string())])\n )\n ),\n csp: z.exactOptional(\n z.strictObject({\n connectDomains: z.array(z.string()).exactOptional(),\n frameDomains: z.array(z.string()).exactOptional(),\n redirectDomains: z.array(z.string()).exactOptional(),\n resourceDomains: z.array(z.string()).exactOptional(),\n baseUriDomains: z.array(z.string()).exactOptional(),\n })\n ),\n widgetSettings: z.exactOptional(\n z.strictObject({\n prefersBorder: z.boolean().exactOptional(),\n description: z.string().exactOptional(),\n domain: z.string().exactOptional(),\n })\n ),\n labels: z.codec(labelsInput, labelsOutput, {\n encode: () => {\n // encode is currently not used so we can skip the business logic and\n // return an empty object which satisfies the type. If we need to encode\n // labels back to the original form, this will need to be implemented\n return {};\n },\n decode: ({ toolInvocation }) => {\n const config: z.infer<typeof labelsOutput> = {};\n\n if (toolInvocation?.invoking) {\n config[\"toolInvocation/invoking\"] = toolInvocation.invoking;\n }\n\n if (toolInvocation?.invoked) {\n config[\"toolInvocation/invoked\"] = toolInvocation.invoked;\n }\n\n return config;\n },\n }),\n});\n"]}
@@ -1,4 +1,4 @@
1
- import { App } from "@modelcontextprotocol/ext-apps";
1
+ import { App, type McpUiHostContextChangedNotification } from "@modelcontextprotocol/ext-apps";
2
2
  import type { ApplicationManifest } from "../../types/application-manifest";
3
3
  import type { FormattedExecutionResult } from "graphql";
4
4
  import type { DocumentNode, OperationVariables } from "@apollo/client";
@@ -11,6 +11,7 @@ export declare class McpAppManager {
11
11
  get toolName(): string | undefined;
12
12
  get toolMetadata(): ApolloMcpServerApps.Meta | undefined;
13
13
  get toolInput(): Record<string, unknown> | undefined;
14
+ onHostContextChanged(cb: (params: McpUiHostContextChangedNotification["params"]) => void): () => void;
14
15
  connect: (() => Promise<{
15
16
  toolName: string | undefined;
16
17
  args: Record<string, unknown> | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"McpAppManager.d.ts","sourceRoot":"","sources":["../../../src/mcp/core/McpAppManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAwB,MAAM,gCAAgC,CAAC;AAE3E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAM5D,gBAAgB;AAChB,qBAAa,aAAa;;IACxB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;gBAMN,QAAQ,EAAE,mBAAmB;IAIzC,IAAI,QAAQ,uBAEX;IAED,IAAI,YAAY,yCAEf;IAED,IAAI,SAAS,wCAEZ;IAED,OAAO;;;;;;;MAqCJ;IAEH,KAAK;IAIC,YAAY,CAAC,EACjB,KAAK,EACL,SAAS,GACV,EAAE;QACD,KAAK,EAAE,YAAY,CAAC;QACpB,SAAS,EAAE,kBAAkB,GAAG,SAAS,CAAC;KAC3C;YASa,aAAa;CAW5B"}
1
+ {"version":3,"file":"McpAppManager.d.ts","sourceRoot":"","sources":["../../../src/mcp/core/McpAppManager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EAEH,KAAK,mCAAmC,EACzC,MAAM,gCAAgC,CAAC;AAExC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAM5D,gBAAgB;AAChB,qBAAa,aAAa;;IACxB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;gBAUN,QAAQ,EAAE,mBAAmB;IAIzC,IAAI,QAAQ,uBAEX;IAED,IAAI,YAAY,yCAEf;IAED,IAAI,SAAS,wCAEZ;IAED,oBAAoB,CAClB,EAAE,EAAE,CAAC,MAAM,EAAE,mCAAmC,CAAC,QAAQ,CAAC,KAAK,IAAI;IASrE,OAAO;;;;;;;MAyCJ;IAEH,KAAK;IAIC,YAAY,CAAC,EACjB,KAAK,EACL,SAAS,GACV,EAAE;QACD,KAAK,EAAE,YAAY,CAAC;QACpB,SAAS,EAAE,kBAAkB,GAAG,SAAS,CAAC;KAC3C;YASa,aAAa;CAW5B"}
@@ -1,4 +1,4 @@
1
- import { App, PostMessageTransport } from "@modelcontextprotocol/ext-apps";
1
+ import { App, PostMessageTransport, } from "@modelcontextprotocol/ext-apps";
2
2
  import { print } from "@apollo/client/utilities";
3
3
  import { cacheAsync, promiseWithResolvers } from "../../utilities";
4
4
  /** @internal */
@@ -7,6 +7,7 @@ export class McpAppManager {
7
7
  #toolName;
8
8
  #toolMetadata;
9
9
  #toolInput;
10
+ #hostContextCallbacks = new Set();
10
11
  constructor(manifest) {
11
12
  this.app = new App({ name: manifest.name, version: manifest.appVersion });
12
13
  }
@@ -19,6 +20,12 @@ export class McpAppManager {
19
20
  get toolInput() {
20
21
  return this.#toolInput;
21
22
  }
23
+ onHostContextChanged(cb) {
24
+ this.#hostContextCallbacks.add(cb);
25
+ return () => {
26
+ this.#hostContextCallbacks.delete(cb);
27
+ };
28
+ }
22
29
  connect = cacheAsync(async () => {
23
30
  let toolResult = promiseWithResolvers();
24
31
  let toolInput = promiseWithResolvers();
@@ -28,6 +35,9 @@ export class McpAppManager {
28
35
  this.app.ontoolinput = (params) => {
29
36
  toolInput.resolve(params);
30
37
  };
38
+ this.app.onhostcontextchanged = (params) => {
39
+ this.#hostContextCallbacks.forEach((cb) => cb(params));
40
+ };
31
41
  await this.connectToHost();
32
42
  const { structuredContent, _meta } = await toolResult.promise;
33
43
  const { arguments: args } = await toolInput.promise;
@@ -1 +1 @@
1
- {"version":3,"file":"McpAppManager.js","sourceRoot":"","sources":["../../../src/mcp/core/McpAppManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAK3E,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAOnE,gBAAgB;AAChB,MAAM,OAAO,aAAa;IACf,GAAG,CAAM;IAElB,SAAS,CAAqB;IAC9B,aAAa,CAA0D;IACvE,UAAU,CAAsC;IAEhD,YAAY,QAA6B;QACvC,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,OAAO,GAAG,UAAU,CAAC,KAAK,IAAI,EAAE;QAC9B,IAAI,UAAU,GAAG,oBAAoB,EAAsC,CAAC;QAC5E,IAAI,SAAS,GAAG,oBAAoB,EAAqC,CAAC;QAE1E,IAAI,CAAC,GAAG,CAAC,YAAY,GAAG,CA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AAO,MAAM,CAAC,iBAAiB,CAAC;IAClC,CAAC;IAEO,KAAK,CAAC,aAAa;QACzB,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAC3B,IAAI,oBAAoB,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CACvD,CAAC;QACJ,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,KAAK,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;YAEtE,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF","sourcesContent":["import { App, PostMessageTransport } from \"@modelcontextprotocol/ext-apps\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport type { ApplicationManifest } from \"../../types/application-manifest\";\nimport type { FormattedExecutionResult } from \"graphql\";\nimport type { DocumentNode, OperationVariables } from \"@apollo/client\";\nimport { print } from \"@apollo/client/utilities\";\nimport { cacheAsync, promiseWithResolvers } from \"../../utilities\";\nimport type { ApolloMcpServerApps } from \"../../core/types\";\n\ntype ExecuteQueryCallToolResult = Omit<CallToolResult, \"structuredContent\"> & {\n structuredContent: FormattedExecutionResult;\n};\n\n/** @internal */\nexport class McpAppManager {\n readonly app: App;\n\n #toolName: string | undefined;\n #toolMetadata: ApolloMcpServerApps.CallToolResult[\"_meta\"] | undefined;\n #toolInput: Record<string, unknown> | undefined;\n\n constructor(manifest: ApplicationManifest) {\n this.app = new App({ name: manifest.name, version: manifest.appVersion });\n }\n\n get toolName() {\n return this.#toolName;\n }\n\n get toolMetadata() {\n return this.#toolMetadata;\n }\n\n get toolInput() {\n return this.#toolInput;\n }\n\n connect = cacheAsync(async () => {\n let toolResult = promiseWithResolvers<ApolloMcpServerApps.CallToolResult>();\n let toolInput = promiseWithResolvers<Parameters<App[\"ontoolinput\"]>[0]>();\n\n this.app.ontoolresult = (params) => {\n toolResult.resolve(\n params as unknown as ApolloMcpServerApps.CallToolResult\n );\n };\n\n this.app.ontoolinput = (params) => {\n toolInput.resolve(params);\n };\n\n await this.connectToHost();\n\n const { structuredContent, _meta } = await toolResult.promise;\n const { arguments: args } = await toolInput.promise;\n\n // Some hosts do not provide toolInfo in the ui/initialize response, so we\n // fallback to `_meta.toolName` provided by Apollo MCP server if the value\n // is not available.\n this.#toolName =\n this.app.getHostContext()?.toolInfo?.tool.name ??\n _meta?.toolName ??\n // Some hosts do not forward `_meta` nor do they provide `toolInfo`. Our\n // MCP server provides `toolName` in `structuredContent` as a workaround\n // that we can use if all else fails\n structuredContent.toolName;\n this.#toolMetadata = _meta;\n this.#toolInput = args;\n\n return {\n ...structuredContent,\n toolName: this.toolName,\n args,\n };\n });\n\n close() {\n return this.app.close();\n }\n\n async executeQuery({\n query,\n variables,\n }: {\n query: DocumentNode;\n variables: OperationVariables | undefined;\n }) {\n const result = (await this.app.callServerTool({\n name: \"execute\",\n arguments: { query: print(query), variables },\n })) as ExecuteQueryCallToolResult;\n\n return result.structuredContent;\n }\n\n private async connectToHost() {\n try {\n return await this.app.connect(\n new PostMessageTransport(window.parent, window.parent)\n );\n } catch (e) {\n const error = e instanceof Error ? e : new Error(\"Failed to connect\");\n\n throw error;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"McpAppManager.js","sourceRoot":"","sources":["../../../src/mcp/core/McpAppManager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,oBAAoB,GAErB,MAAM,gCAAgC,CAAC;AAKxC,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAOnE,gBAAgB;AAChB,MAAM,OAAO,aAAa;IACf,GAAG,CAAM;IAElB,SAAS,CAAqB;IAC9B,aAAa,CAA0D;IACvE,UAAU,CAAsC;IAEhD,qBAAqB,GAAG,IAAI,GAAG,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C;YACX,MAAM,KAAK,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;YAEtE,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF","sourcesContent":["import {\n App,\n PostMessageTransport,\n type McpUiHostContextChangedNotification,\n} from \"@modelcontextprotocol/ext-apps\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport type { ApplicationManifest } from \"../../types/application-manifest\";\nimport type { FormattedExecutionResult } from \"graphql\";\nimport type { DocumentNode, OperationVariables } from \"@apollo/client\";\nimport { print } from \"@apollo/client/utilities\";\nimport { cacheAsync, promiseWithResolvers } from \"../../utilities\";\nimport type { ApolloMcpServerApps } from \"../../core/types\";\n\ntype ExecuteQueryCallToolResult = Omit<CallToolResult, \"structuredContent\"> & {\n structuredContent: FormattedExecutionResult;\n};\n\n/** @internal */\nexport class McpAppManager {\n readonly app: App;\n\n #toolName: string | undefined;\n #toolMetadata: ApolloMcpServerApps.CallToolResult[\"_meta\"] | undefined;\n #toolInput: Record<string, unknown> | undefined;\n\n #hostContextCallbacks = new Set<\n (params: McpUiHostContextChangedNotification[\"params\"]) => void\n >();\n\n constructor(manifest: ApplicationManifest) {\n this.app = new App({ name: manifest.name, version: manifest.appVersion });\n }\n\n get toolName() {\n return this.#toolName;\n }\n\n get toolMetadata() {\n return this.#toolMetadata;\n }\n\n get toolInput() {\n return this.#toolInput;\n }\n\n onHostContextChanged(\n cb: (params: McpUiHostContextChangedNotification[\"params\"]) => void\n ) {\n this.#hostContextCallbacks.add(cb);\n\n return () => {\n this.#hostContextCallbacks.delete(cb);\n };\n }\n\n connect = cacheAsync(async () => {\n let toolResult = promiseWithResolvers<ApolloMcpServerApps.CallToolResult>();\n let toolInput = promiseWithResolvers<Parameters<App[\"ontoolinput\"]>[0]>();\n\n this.app.ontoolresult = (params) => {\n toolResult.resolve(\n params as unknown as ApolloMcpServerApps.CallToolResult\n );\n };\n\n this.app.ontoolinput = (params) => {\n toolInput.resolve(params);\n };\n\n this.app.onhostcontextchanged = (params) => {\n this.#hostContextCallbacks.forEach((cb) => cb(params));\n };\n\n await this.connectToHost();\n\n const { structuredContent, _meta } = await toolResult.promise;\n const { arguments: args } = await toolInput.promise;\n\n // Some hosts do not provide toolInfo in the ui/initialize response, so we\n // fallback to `_meta.toolName` provided by Apollo MCP server if the value\n // is not available.\n this.#toolName =\n this.app.getHostContext()?.toolInfo?.tool.name ??\n _meta?.toolName ??\n // Some hosts do not forward `_meta` nor do they provide `toolInfo`. Our\n // MCP server provides `toolName` in `structuredContent` as a workaround\n // that we can use if all else fails\n structuredContent.toolName;\n this.#toolMetadata = _meta;\n this.#toolInput = args;\n\n return {\n ...structuredContent,\n toolName: this.toolName,\n args,\n };\n });\n\n close() {\n return this.app.close();\n }\n\n async executeQuery({\n query,\n variables,\n }: {\n query: DocumentNode;\n variables: OperationVariables | undefined;\n }) {\n const result = (await this.app.callServerTool({\n name: \"execute\",\n arguments: { query: print(query), variables },\n })) as ExecuteQueryCallToolResult;\n\n return result.structuredContent;\n }\n\n private async connectToHost() {\n try {\n return await this.app.connect(\n new PostMessageTransport(window.parent, window.parent)\n );\n } catch (e) {\n const error = e instanceof Error ? e : new Error(\"Failed to connect\");\n\n throw error;\n }\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare function useHostContext(): import("@modelcontextprotocol/ext-apps").McpUiHostContext | undefined;
2
+ //# sourceMappingURL=useHostContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHostContext.d.ts","sourceRoot":"","sources":["../../../../src/mcp/react/hooks/useHostContext.ts"],"names":[],"mappings":"AAGA,wBAAgB,cAAc,0EAU7B"}
@@ -0,0 +1,7 @@
1
+ import { useCallback, useSyncExternalStore } from "react";
2
+ import { useApolloClient } from "./useApolloClient";
3
+ export function useHostContext() {
4
+ const appManager = useApolloClient()["appManager"];
5
+ return useSyncExternalStore(useCallback((update) => appManager.onHostContextChanged(update), [appManager]), () => appManager.app.getHostContext());
6
+ }
7
+ //# sourceMappingURL=useHostContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHostContext.js","sourceRoot":"","sources":["../../../../src/mcp/react/hooks/useHostContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,UAAU,cAAc;IAC5B,MAAM,UAAU,GAAG,eAAe,EAAE,CAAC,YAAY,CAAC,CAAC;IAEnD,OAAO,oBAAoB,CACzB,WAAW,CACT,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,oBAAoB,CAAC,MAAM,CAAC,EACnD,CAAC,UAAU,CAAC,CACb,EACD,GAAG,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,cAAc,EAAE,CACtC,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useSyncExternalStore } from \"react\";\nimport { useApolloClient } from \"./useApolloClient\";\n\nexport function useHostContext() {\n const appManager = useApolloClient()[\"appManager\"];\n\n return useSyncExternalStore(\n useCallback(\n (update) => appManager.onHostContextChanged(update),\n [appManager]\n ),\n () => appManager.app.getHostContext()\n );\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  export { useApp } from "./hooks/useApp.js";
2
+ export { useHostContext } from "./hooks/useHostContext.js";
2
3
  export { useToolName } from "./hooks/useToolName.js";
3
4
  export { useToolMetadata } from "./hooks/useToolMetadata.js";
4
5
  export { useToolInput } from "./hooks/useToolInput.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mcp/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mcp/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export { useApp } from "./hooks/useApp.js";
2
+ export { useHostContext } from "./hooks/useHostContext.js";
2
3
  export { useToolName } from "./hooks/useToolName.js";
3
4
  export { useToolMetadata } from "./hooks/useToolMetadata.js";
4
5
  export { useToolInput } from "./hooks/useToolInput.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/mcp/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC","sourcesContent":["export { useApp } from \"./hooks/useApp.js\";\nexport { useToolName } from \"./hooks/useToolName.js\";\nexport { useToolMetadata } from \"./hooks/useToolMetadata.js\";\nexport { useToolInput } from \"./hooks/useToolInput.js\";\nexport { createHydrationUtils } from \"./hooks/createHydrationUtils.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/mcp/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC","sourcesContent":["export { useApp } from \"./hooks/useApp.js\";\nexport { useHostContext } from \"./hooks/useHostContext.js\";\nexport { useToolName } from \"./hooks/useToolName.js\";\nexport { useToolMetadata } from \"./hooks/useToolMetadata.js\";\nexport { useToolInput } from \"./hooks/useToolInput.js\";\nexport { createHydrationUtils } from \"./hooks/createHydrationUtils.js\";\n"]}
@@ -1,4 +1,4 @@
1
- import { App } from "@modelcontextprotocol/ext-apps";
1
+ import { App, type McpUiHostContextChangedNotification } from "@modelcontextprotocol/ext-apps";
2
2
  import type { ApplicationManifest } from "../../types/application-manifest";
3
3
  import type { FormattedExecutionResult } from "graphql";
4
4
  import type { DocumentNode, OperationVariables } from "@apollo/client";
@@ -10,6 +10,7 @@ export declare class McpAppManager {
10
10
  get toolName(): string | undefined;
11
11
  get toolMetadata(): Record<string, unknown> | null;
12
12
  get toolInput(): Record<string, unknown> | undefined;
13
+ onHostContextChanged(cb: (params: McpUiHostContextChangedNotification["params"]) => void): () => void;
13
14
  connect: (() => Promise<{
14
15
  toolName: string | undefined;
15
16
  args: Record<string, unknown> | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"McpAppManager.d.ts","sourceRoot":"","sources":["../../../src/openai/core/McpAppManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAwB,MAAM,gCAAgC,CAAC;AAE3E,OAAO,KAAK,EAAE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SAAS,GACV,EAAE;QACD,KAAK,EAAE,YAAY,CAAC;QACpB,SAAS,EAAE,kBAAkB,GAAG,SAAS,CAAC;KAC3C;YASa,aAAa;CAW5B"}
@@ -1,4 +1,4 @@
1
- import { App, PostMessageTransport } from "@modelcontextprotocol/ext-apps";
1
+ import { App, PostMessageTransport, } from "@modelcontextprotocol/ext-apps";
2
2
  import { print } from "@apollo/client/utilities";
3
3
  import { cacheAsync, promiseWithResolvers } from "../../utilities";
4
4
  /** @internal */
@@ -7,6 +7,7 @@ export class McpAppManager {
7
7
  #toolName;
8
8
  #toolMetadata = null;
9
9
  #toolInput;
10
+ #hostContextCallbacks = new Set();
10
11
  constructor(manifest) {
11
12
  this.app = new App({ name: manifest.name, version: manifest.appVersion });
12
13
  }
@@ -19,11 +20,20 @@ export class McpAppManager {
19
20
  get toolInput() {
20
21
  return this.#toolInput;
21
22
  }
23
+ onHostContextChanged(cb) {
24
+ this.#hostContextCallbacks.add(cb);
25
+ return () => {
26
+ this.#hostContextCallbacks.delete(cb);
27
+ };
28
+ }
22
29
  connect = cacheAsync(async () => {
23
30
  let toolResult = promiseWithResolvers();
24
31
  this.app.ontoolresult = (params) => {
25
32
  toolResult.resolve(params);
26
33
  };
34
+ this.app.onhostcontextchanged = (params) => {
35
+ this.#hostContextCallbacks.forEach((cb) => cb(params));
36
+ };
27
37
  await this.connectToHost();
28
38
  const { structuredContent } = await toolResult.promise;
29
39
  this.#toolName = this.app.getHostContext()?.toolInfo?.tool.name;
@@ -1 +1 @@
1
- {"version":3,"file":"McpAppManager.js","sourceRoot":"","sources":["../../../src/openai/core/McpAppManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAK3E,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAOnE,gBAAgB;AAChB,MAAM,OAA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CAAC;QAExD,OAAO;YACL,GAAG,iBAAiB;YACpB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,IAAI,EAAE,IAAI,CAAC,SAAS;SACrB,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,KAAK;QACH,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,EACjB,KAAK,EACL,SAAS,GAIV;QACC,MAAM,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC;YAC5C,IAAI,EAAE,SAAS;YACf,SAAS,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE;SAC9C,CAAC,CAA+B,CAAC;QAElC,OAAO,MAAM,CAAC,iBAAiB,CAAC;IAClC,CAAC;IAEO,KAAK,CAAC,aAAa;QACzB,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAC3B,IAAI,oBAAoB,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CACvD,CAAC;QACJ,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,KAAK,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;YAEtE,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF","sourcesContent":["import { App, PostMessageTransport } from \"@modelcontextprotocol/ext-apps\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport type { ApplicationManifest } from \"../../types/application-manifest\";\nimport type { FormattedExecutionResult } from \"graphql\";\nimport type { DocumentNode, OperationVariables } from \"@apollo/client\";\nimport { print } from \"@apollo/client/utilities\";\nimport { cacheAsync, promiseWithResolvers } from \"../../utilities\";\nimport type { ApolloMcpServerApps } from \"../../core/types\";\n\ntype ExecuteQueryCallToolResult = Omit<CallToolResult, \"structuredContent\"> & {\n structuredContent: FormattedExecutionResult;\n};\n\n/** @internal */\nexport class McpAppManager {\n readonly app: App;\n\n #toolName: string | undefined;\n #toolMetadata: Record<string, unknown> | null = null;\n #toolInput: Record<string, unknown> | undefined;\n\n constructor(manifest: ApplicationManifest) {\n this.app = new App({ name: manifest.name, version: manifest.appVersion });\n }\n\n get toolName() {\n return this.#toolName;\n }\n\n get toolMetadata() {\n return this.#toolMetadata;\n }\n\n get toolInput() {\n return this.#toolInput;\n }\n\n connect = cacheAsync(async () => {\n let toolResult = promiseWithResolvers<ApolloMcpServerApps.CallToolResult>();\n\n this.app.ontoolresult = (params) => {\n toolResult.resolve(\n params as unknown as ApolloMcpServerApps.CallToolResult\n );\n };\n\n await this.connectToHost();\n\n const { structuredContent } = await toolResult.promise;\n\n this.#toolName = this.app.getHostContext()?.toolInfo?.tool.name;\n\n // OpenAI is not consistent about sending `ui/notifications/tool-input`.\n // Sometimes it doesn't send at all, other times it sends more than once\n // before we get the tool result (which should always happen and at most\n // once according to the spec). Rather than relying on the\n // `ui/notifications/tool-input` notification to set the tool input value,\n // we read from `window.openai.toolInput so that we have the most recent\n // set value.\n //\n // When OpenAI fixes this issue and sends `ui/notifications/tool-input`\n // consistently according to the MCP Apps specification, this can be\n // reverted to use the `app.ontoolinput` callback.\n this.#toolInput = window.openai.toolInput;\n\n // OpenAI doesn't provide access to `_meta`, so we need to use\n // window.openai.toolResponseMetadata directly\n this.#toolMetadata = window.openai.toolResponseMetadata;\n\n return {\n ...structuredContent,\n toolName: this.toolName,\n args: this.toolInput,\n };\n });\n\n close() {\n return this.app.close();\n }\n\n async executeQuery({\n query,\n variables,\n }: {\n query: DocumentNode;\n variables: OperationVariables | undefined;\n }) {\n const result = (await this.app.callServerTool({\n name: \"execute\",\n arguments: { query: print(query), variables },\n })) as ExecuteQueryCallToolResult;\n\n return result.structuredContent;\n }\n\n private async connectToHost() {\n try {\n return await this.app.connect(\n new PostMessageTransport(window.parent, window.parent)\n );\n } catch (e) {\n const error = e instanceof Error ? e : new Error(\"Failed to connect\");\n\n throw error;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"McpAppManager.js","sourceRoot":"","sources":["../../../src/openai/core/McpAppManager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,oBAAoB,GAErB,MAAM,gCAAgC,CAAC;AAKxC,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAOnE,gBAAgB;AAChB,MAAM,OAAO,aAAa;IACf,GAAG,CAAM;IAElB,SAAS,CAAqB;IAC9B,aAAa,GAAmC,IAAI,CAAC;IACrD,UAAU,CAAsC;IAEhD,qBAAqB,GAAG,IAAI,GAAG,EAE5B,CAAC;IAEJ,YAAY,QAA6B;QACvC,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,oBAAoB,CAClB,EAAmE;QAEnE,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACnC,OAAO,GAAG,EAAE;YACV,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACxC,CAAC,CAAC;IACJ,CAAC;IAED,OAAO,GAAG,UAAU,CAAC,KAAK,IAAI,EAAE;QAC9B,IAAI,UAAU,GAAG,oBAAoB,EAAsC,CAAC;QAE5E,IAAI,CAAC,GAAG,CAAC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EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE;SAC9C,CAAC,CAA+B,CAAC;QAElC,OAAO,MAAM,CAAC,iBAAiB,CAAC;IAClC,CAAC;IAEO,KAAK,CAAC,aAAa;QACzB,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAC3B,IAAI,oBAAoB,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CACvD,CAAC;QACJ,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,KAAK,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;YAEtE,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF","sourcesContent":["import {\n App,\n PostMessageTransport,\n type McpUiHostContextChangedNotification,\n} from \"@modelcontextprotocol/ext-apps\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport type { ApplicationManifest } from \"../../types/application-manifest\";\nimport type { FormattedExecutionResult } from \"graphql\";\nimport type { DocumentNode, OperationVariables } from \"@apollo/client\";\nimport { print } from \"@apollo/client/utilities\";\nimport { cacheAsync, promiseWithResolvers } from \"../../utilities\";\nimport type { ApolloMcpServerApps } from \"../../core/types\";\n\ntype ExecuteQueryCallToolResult = Omit<CallToolResult, \"structuredContent\"> & {\n structuredContent: FormattedExecutionResult;\n};\n\n/** @internal */\nexport class McpAppManager {\n readonly app: App;\n\n #toolName: string | undefined;\n #toolMetadata: Record<string, unknown> | null = null;\n #toolInput: Record<string, unknown> | undefined;\n\n #hostContextCallbacks = new Set<\n (params: McpUiHostContextChangedNotification[\"params\"]) => void\n >();\n\n constructor(manifest: ApplicationManifest) {\n this.app = new App({ name: manifest.name, version: manifest.appVersion });\n }\n\n get toolName() {\n return this.#toolName;\n }\n\n get toolMetadata() {\n return this.#toolMetadata;\n }\n\n get toolInput() {\n return this.#toolInput;\n }\n\n onHostContextChanged(\n cb: (params: McpUiHostContextChangedNotification[\"params\"]) => void\n ) {\n this.#hostContextCallbacks.add(cb);\n return () => {\n this.#hostContextCallbacks.delete(cb);\n };\n }\n\n connect = cacheAsync(async () => {\n let toolResult = promiseWithResolvers<ApolloMcpServerApps.CallToolResult>();\n\n this.app.ontoolresult = (params) => {\n toolResult.resolve(\n params as unknown as ApolloMcpServerApps.CallToolResult\n );\n };\n\n this.app.onhostcontextchanged = (params) => {\n this.#hostContextCallbacks.forEach((cb) => cb(params));\n };\n\n await this.connectToHost();\n\n const { structuredContent } = await toolResult.promise;\n\n this.#toolName = this.app.getHostContext()?.toolInfo?.tool.name;\n\n // OpenAI is not consistent about sending `ui/notifications/tool-input`.\n // Sometimes it doesn't send at all, other times it sends more than once\n // before we get the tool result (which should always happen and at most\n // once according to the spec). Rather than relying on the\n // `ui/notifications/tool-input` notification to set the tool input value,\n // we read from `window.openai.toolInput so that we have the most recent\n // set value.\n //\n // When OpenAI fixes this issue and sends `ui/notifications/tool-input`\n // consistently according to the MCP Apps specification, this can be\n // reverted to use the `app.ontoolinput` callback.\n this.#toolInput = window.openai.toolInput;\n\n // OpenAI doesn't provide access to `_meta`, so we need to use\n // window.openai.toolResponseMetadata directly\n this.#toolMetadata = window.openai.toolResponseMetadata;\n\n return {\n ...structuredContent,\n toolName: this.toolName,\n args: this.toolInput,\n };\n });\n\n close() {\n return this.app.close();\n }\n\n async executeQuery({\n query,\n variables,\n }: {\n query: DocumentNode;\n variables: OperationVariables | undefined;\n }) {\n const result = (await this.app.callServerTool({\n name: \"execute\",\n arguments: { query: print(query), variables },\n })) as ExecuteQueryCallToolResult;\n\n return result.structuredContent;\n }\n\n private async connectToHost() {\n try {\n return await this.app.connect(\n new PostMessageTransport(window.parent, window.parent)\n );\n } catch (e) {\n const error = e instanceof Error ? e : new Error(\"Failed to connect\");\n\n throw error;\n }\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare function useHostContext(): import("@modelcontextprotocol/ext-apps").McpUiHostContext | undefined;
2
+ //# sourceMappingURL=useHostContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHostContext.d.ts","sourceRoot":"","sources":["../../../../src/openai/react/hooks/useHostContext.ts"],"names":[],"mappings":"AAGA,wBAAgB,cAAc,0EAU7B"}
@@ -0,0 +1,7 @@
1
+ import { useCallback, useSyncExternalStore } from "react";
2
+ import { useApolloClient } from "./useApolloClient";
3
+ export function useHostContext() {
4
+ const appManager = useApolloClient()["appManager"];
5
+ return useSyncExternalStore(useCallback((update) => appManager.onHostContextChanged(update), [appManager]), () => appManager.app.getHostContext());
6
+ }
7
+ //# sourceMappingURL=useHostContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHostContext.js","sourceRoot":"","sources":["../../../../src/openai/react/hooks/useHostContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,UAAU,cAAc;IAC5B,MAAM,UAAU,GAAG,eAAe,EAAE,CAAC,YAAY,CAAC,CAAC;IAEnD,OAAO,oBAAoB,CACzB,WAAW,CACT,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,oBAAoB,CAAC,MAAM,CAAC,EACnD,CAAC,UAAU,CAAC,CACb,EACD,GAAG,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,cAAc,EAAE,CACtC,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useSyncExternalStore } from \"react\";\nimport { useApolloClient } from \"./useApolloClient\";\n\nexport function useHostContext() {\n const appManager = useApolloClient()[\"appManager\"];\n\n return useSyncExternalStore(\n useCallback(\n (update) => appManager.onHostContextChanged(update),\n [appManager]\n ),\n () => appManager.app.getHostContext()\n );\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  export { useApp } from "./hooks/useApp.js";
2
+ export { useHostContext } from "./hooks/useHostContext.js";
2
3
  export { useToolName } from "./hooks/useToolName.js";
3
4
  export { useToolMetadata } from "./hooks/useToolMetadata.js";
4
5
  export { useToolInput } from "./hooks/useToolInput.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/openai/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/openai/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export { useApp } from "./hooks/useApp.js";
2
+ export { useHostContext } from "./hooks/useHostContext.js";
2
3
  export { useToolName } from "./hooks/useToolName.js";
3
4
  export { useToolMetadata } from "./hooks/useToolMetadata.js";
4
5
  export { useToolInput } from "./hooks/useToolInput.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/openai/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC","sourcesContent":["export { useApp } from \"./hooks/useApp.js\";\nexport { useToolName } from \"./hooks/useToolName.js\";\nexport { useToolMetadata } from \"./hooks/useToolMetadata.js\";\nexport { useToolInput } from \"./hooks/useToolInput.js\";\nexport { createHydrationUtils } from \"./hooks/createHydrationUtils.js\";\nexport { useWidgetState } from \"./hooks/useWidgetState.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/openai/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC","sourcesContent":["export { useApp } from \"./hooks/useApp.js\";\nexport { useHostContext } from \"./hooks/useHostContext.js\";\nexport { useToolName } from \"./hooks/useToolName.js\";\nexport { useToolMetadata } from \"./hooks/useToolMetadata.js\";\nexport { useToolInput } from \"./hooks/useToolInput.js\";\nexport { createHydrationUtils } from \"./hooks/createHydrationUtils.js\";\nexport { useWidgetState } from \"./hooks/useWidgetState.js\";\n"]}
@@ -2,6 +2,7 @@ export { ApolloProvider } from "./ApolloProvider.js";
2
2
  export { reactive } from "./reactive.js";
3
3
  export type { Reactive } from "./reactive.js";
4
4
  export declare const useApp: typeof import("./index.mcp.js").useApp;
5
+ export declare const useHostContext: typeof import("./index.mcp.js").useHostContext;
5
6
  export declare const useToolInput: typeof import("./index.mcp.js").useToolInput;
6
7
  export declare const useToolMetadata: typeof import("./index.mcp.js").useToolMetadata;
7
8
  export declare const useToolName: typeof import("./index.mcp.js").useToolName;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAI9C,eAAO,MAAM,MAAM,wCAC4C,CAAC;AAEhE,eAAO,MAAM,YAAY,8CACkD,CAAC;AAE5E,eAAO,MAAM,eAAe,iDAGzB,CAAC;AAEJ,eAAO,MAAM,WAAW,6CACiD,CAAC;AAE1E,oBAAoB;AACpB,eAAO,MAAM,oBAAoB,sDAER,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAI9C,eAAO,MAAM,MAAM,wCAC4C,CAAC;AAEhE,eAAO,MAAM,cAAc,gDACoD,CAAC;AAEhF,eAAO,MAAM,YAAY,8CACkD,CAAC;AAE5E,eAAO,MAAM,eAAe,iDAGzB,CAAC;AAEJ,eAAO,MAAM,WAAW,6CACiD,CAAC;AAE1E,oBAAoB;AACpB,eAAO,MAAM,oBAAoB,sDAER,CAAC"}
@@ -4,6 +4,7 @@ export { reactive } from "./reactive.js";
4
4
  // Use `mcp` related types since these are the most common between the two
5
5
  // targets
6
6
  export const useApp = missingHook("useApp");
7
+ export const useHostContext = missingHook("useHostContext");
7
8
  export const useToolInput = missingHook("useToolInput");
8
9
  export const useToolMetadata = missingHook("useToolMetadata");
9
10
  export const useToolName = missingHook("useToolName");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,0EAA0E;AAC1E,UAAU;AACV,MAAM,CAAC,MAAM,MAAM,GACjB,WAAW,CAAyC,QAAQ,CAAC,CAAC;AAEhE,MAAM,CAAC,MAAM,YAAY,GACvB,WAAW,CAA+C,cAAc,CAAC,CAAC;AAE5E,MAAM,CAAC,MAAM,eAAe,GAC1B,WAAW,CACT,iBAAiB,CAClB,CAAC;AAEJ,MAAM,CAAC,MAAM,WAAW,GACtB,WAAW,CAA8C,aAAa,CAAC,CAAC;AAE1E,oBAAoB;AACpB,MAAM,CAAC,MAAM,oBAAoB,GAAG,WAAW,CAE7C,sBAAsB,CAAC,CAAC","sourcesContent":["import { missingHook } from \"./missingHook.js\";\n\nexport { ApolloProvider } from \"./ApolloProvider.js\";\nexport { reactive } from \"./reactive.js\";\nexport type { Reactive } from \"./reactive.js\";\n\n// Use `mcp` related types since these are the most common between the two\n// targets\nexport const useApp =\n missingHook<typeof import(\"./index.mcp.js\").useApp>(\"useApp\");\n\nexport const useToolInput =\n missingHook<typeof import(\"./index.mcp.js\").useToolInput>(\"useToolInput\");\n\nexport const useToolMetadata =\n missingHook<typeof import(\"./index.mcp.js\").useToolMetadata>(\n \"useToolMetadata\"\n );\n\nexport const useToolName =\n missingHook<typeof import(\"./index.mcp.js\").useToolName>(\"useToolName\");\n\n/** @experimental */\nexport const createHydrationUtils = missingHook<\n typeof import(\"./index.mcp.js\").createHydrationUtils\n>(\"createHydrationUtils\");\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,0EAA0E;AAC1E,UAAU;AACV,MAAM,CAAC,MAAM,MAAM,GACjB,WAAW,CAAyC,QAAQ,CAAC,CAAC;AAEhE,MAAM,CAAC,MAAM,cAAc,GACzB,WAAW,CAAiD,gBAAgB,CAAC,CAAC;AAEhF,MAAM,CAAC,MAAM,YAAY,GACvB,WAAW,CAA+C,cAAc,CAAC,CAAC;AAE5E,MAAM,CAAC,MAAM,eAAe,GAC1B,WAAW,CACT,iBAAiB,CAClB,CAAC;AAEJ,MAAM,CAAC,MAAM,WAAW,GACtB,WAAW,CAA8C,aAAa,CAAC,CAAC;AAE1E,oBAAoB;AACpB,MAAM,CAAC,MAAM,oBAAoB,GAAG,WAAW,CAE7C,sBAAsB,CAAC,CAAC","sourcesContent":["import { missingHook } from \"./missingHook.js\";\n\nexport { ApolloProvider } from \"./ApolloProvider.js\";\nexport { reactive } from \"./reactive.js\";\nexport type { Reactive } from \"./reactive.js\";\n\n// Use `mcp` related types since these are the most common between the two\n// targets\nexport const useApp =\n missingHook<typeof import(\"./index.mcp.js\").useApp>(\"useApp\");\n\nexport const useHostContext =\n missingHook<typeof import(\"./index.mcp.js\").useHostContext>(\"useHostContext\");\n\nexport const useToolInput =\n missingHook<typeof import(\"./index.mcp.js\").useToolInput>(\"useToolInput\");\n\nexport const useToolMetadata =\n missingHook<typeof import(\"./index.mcp.js\").useToolMetadata>(\n \"useToolMetadata\"\n );\n\nexport const useToolName =\n missingHook<typeof import(\"./index.mcp.js\").useToolName>(\"useToolName\");\n\n/** @experimental */\nexport const createHydrationUtils = missingHook<\n typeof import(\"./index.mcp.js\").createHydrationUtils\n>(\"createHydrationUtils\");\n"]}
@@ -1,3 +1,3 @@
1
1
  export * from "./index.js";
2
- export { useApp, useToolInput, createHydrationUtils, useToolMetadata, useToolName, } from "../mcp/react/index.js";
2
+ export { useApp, useHostContext, useToolInput, createHydrationUtils, useToolMetadata, useToolName, } from "../mcp/react/index.js";
3
3
  //# sourceMappingURL=index.mcp.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mcp.d.ts","sourceRoot":"","sources":["../../src/react/index.mcp.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EACL,MAAM,EACN,YAAY,EACZ,oBAAoB,EACpB,eAAe,EACf,WAAW,GACZ,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.mcp.d.ts","sourceRoot":"","sources":["../../src/react/index.mcp.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EACL,MAAM,EACN,cAAc,EACd,YAAY,EACZ,oBAAoB,EACpB,eAAe,EACf,WAAW,GACZ,MAAM,uBAAuB,CAAC"}
@@ -1,3 +1,3 @@
1
1
  export * from "./index.js";
2
- export { useApp, useToolInput, createHydrationUtils, useToolMetadata, useToolName, } from "../mcp/react/index.js";
2
+ export { useApp, useHostContext, useToolInput, createHydrationUtils, useToolMetadata, useToolName, } from "../mcp/react/index.js";
3
3
  //# sourceMappingURL=index.mcp.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mcp.js","sourceRoot":"","sources":["../../src/react/index.mcp.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EACL,MAAM,EACN,YAAY,EACZ,oBAAoB,EACpB,eAAe,EACf,WAAW,GACZ,MAAM,uBAAuB,CAAC","sourcesContent":["export * from \"./index.js\";\nexport {\n useApp,\n useToolInput,\n createHydrationUtils,\n useToolMetadata,\n useToolName,\n} from \"../mcp/react/index.js\";\n"]}
1
+ {"version":3,"file":"index.mcp.js","sourceRoot":"","sources":["../../src/react/index.mcp.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EACL,MAAM,EACN,cAAc,EACd,YAAY,EACZ,oBAAoB,EACpB,eAAe,EACf,WAAW,GACZ,MAAM,uBAAuB,CAAC","sourcesContent":["export * from \"./index.js\";\nexport {\n useApp,\n useHostContext,\n useToolInput,\n createHydrationUtils,\n useToolMetadata,\n useToolName,\n} from \"../mcp/react/index.js\";\n"]}
@@ -1,3 +1,3 @@
1
1
  export * from "./index.js";
2
- export { useApp, useToolInput, createHydrationUtils, useToolMetadata, useToolName, } from "../openai/react/index.js";
2
+ export { useApp, useHostContext, useToolInput, createHydrationUtils, useToolMetadata, useToolName, } from "../openai/react/index.js";
3
3
  //# sourceMappingURL=index.openai.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.openai.d.ts","sourceRoot":"","sources":["../../src/react/index.openai.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EACL,MAAM,EACN,YAAY,EACZ,oBAAoB,EACpB,eAAe,EACf,WAAW,GACZ,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.openai.d.ts","sourceRoot":"","sources":["../../src/react/index.openai.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EACL,MAAM,EACN,cAAc,EACd,YAAY,EACZ,oBAAoB,EACpB,eAAe,EACf,WAAW,GACZ,MAAM,0BAA0B,CAAC"}
@@ -1,3 +1,3 @@
1
1
  export * from "./index.js";
2
- export { useApp, useToolInput, createHydrationUtils, useToolMetadata, useToolName, } from "../openai/react/index.js";
2
+ export { useApp, useHostContext, useToolInput, createHydrationUtils, useToolMetadata, useToolName, } from "../openai/react/index.js";
3
3
  //# sourceMappingURL=index.openai.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.openai.js","sourceRoot":"","sources":["../../src/react/index.openai.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EACL,MAAM,EACN,YAAY,EACZ,oBAAoB,EACpB,eAAe,EACf,WAAW,GACZ,MAAM,0BAA0B,CAAC","sourcesContent":["export * from \"./index.js\";\nexport {\n useApp,\n useToolInput,\n createHydrationUtils,\n useToolMetadata,\n useToolName,\n} from \"../openai/react/index.js\";\n"]}
1
+ {"version":3,"file":"index.openai.js","sourceRoot":"","sources":["../../src/react/index.openai.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EACL,MAAM,EACN,cAAc,EACd,YAAY,EACZ,oBAAoB,EACpB,eAAe,EACf,WAAW,GACZ,MAAM,0BAA0B,CAAC","sourcesContent":["export * from \"./index.js\";\nexport {\n useApp,\n useHostContext,\n useToolInput,\n createHydrationUtils,\n useToolMetadata,\n useToolName,\n} from \"../openai/react/index.js\";\n"]}
@@ -41,6 +41,7 @@ export type ManifestExtraInput = {
41
41
  type: "string" | "boolean" | "number";
42
42
  };
43
43
  export type ManifestCsp = {
44
+ baseUriDomains: string[];
44
45
  connectDomains: string[];
45
46
  frameDomains: string[];
46
47
  redirectDomains: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"application-manifest.d.ts","sourceRoot":"","sources":["../../src/types/application-manifest.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,wBAAwB,CAAC;IACjC,OAAO,EAAE,GAAG,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EACJ,MAAM,GACN;QACE,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;IACN,UAAU,EAAE,iBAAiB,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AM,CAAC;IACnC,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC,CAAC"}
1
+ {"version":3,"file":"application-manifest.d.ts","sourceRoot":"","sources":["../../src/types/application-manifest.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,wBAAwB,CAAC;IACjC,OAAO,EAAE,GAAG,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EACJ,MAAM,GACN;QACE,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;IACN,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAChC,GAAG,EAAE,WAAW,CAAC;IACjB,cAAc,CAAC,EAAE,sBAAsB,CAAC;IACxC,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,GAAG,UAAU,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IAC/C,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,YAAY,EAAE,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,kBAAkB,EAAE,CAAC;IACnC,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"application-manifest.js","sourceRoot":"","sources":["../../src/types/application-manifest.ts"],"names":[],"mappings":"","sourcesContent":["export type ApplicationManifest = {\n format: \"apollo-ai-app-manifest\";\n version: \"1\";\n appVersion: string;\n name: string;\n description: string;\n hash: string;\n resource:\n | string\n | {\n mcp?: string;\n openai?: string;\n };\n operations: ManifestOperation[];\n csp: ManifestCsp;\n widgetSettings?: ManifestWidgetSettings;\n labels?: ManifestLabels;\n};\n\nexport type ManifestOperation = {\n id: string;\n name: string;\n type: \"query\" | \"mutation\";\n body: string;\n variables?: Record<string, string | undefined>;\n prefetch: boolean;\n prefetchID?: string;\n tools: ManifestTool[];\n};\n\nexport type ManifestTool = {\n name: string;\n description: string;\n extraInputs?: ManifestExtraInput[];\n labels?: ManifestLabels;\n};\n\nexport type ManifestWidgetSettings = {\n description?: string;\n domain?: string;\n prefersBorder?: boolean;\n};\n\nexport type ManifestExtraInput = {\n name: string;\n description: string;\n type: \"string\" | \"boolean\" | \"number\";\n};\n\nexport type ManifestCsp = {\n connectDomains: string[];\n frameDomains: string[];\n redirectDomains: string[];\n resourceDomains: string[];\n};\n\nexport type ManifestLabels = {\n \"toolInvocation/invoking\"?: string;\n \"toolInvocation/invoked\"?: string;\n};\n"]}
1
+ {"version":3,"file":"application-manifest.js","sourceRoot":"","sources":["../../src/types/application-manifest.ts"],"names":[],"mappings":"","sourcesContent":["export type ApplicationManifest = {\n format: \"apollo-ai-app-manifest\";\n version: \"1\";\n appVersion: string;\n name: string;\n description: string;\n hash: string;\n resource:\n | string\n | {\n mcp?: string;\n openai?: string;\n };\n operations: ManifestOperation[];\n csp: ManifestCsp;\n widgetSettings?: ManifestWidgetSettings;\n labels?: ManifestLabels;\n};\n\nexport type ManifestOperation = {\n id: string;\n name: string;\n type: \"query\" | \"mutation\";\n body: string;\n variables?: Record<string, string | undefined>;\n prefetch: boolean;\n prefetchID?: string;\n tools: ManifestTool[];\n};\n\nexport type ManifestTool = {\n name: string;\n description: string;\n extraInputs?: ManifestExtraInput[];\n labels?: ManifestLabels;\n};\n\nexport type ManifestWidgetSettings = {\n description?: string;\n domain?: string;\n prefersBorder?: boolean;\n};\n\nexport type ManifestExtraInput = {\n name: string;\n description: string;\n type: \"string\" | \"boolean\" | \"number\";\n};\n\nexport type ManifestCsp = {\n baseUriDomains: string[];\n connectDomains: string[];\n frameDomains: string[];\n redirectDomains: string[];\n resourceDomains: string[];\n};\n\nexport type ManifestLabels = {\n \"toolInvocation/invoking\"?: string;\n \"toolInvocation/invoked\"?: string;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../../src/vite/__tests__/utilities/build.ts"],"names":[],"mappings":"AAEA,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,MAAM,CAAC;AAE9D,KAAK,OAAO,GAAG,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC;AAEpD,wBAAsB,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE;;;;;;;;;;;;;;;;;;;qBAkEmmkG,CAAC;;;;;;;;;;;mCAA45C,CAAC;GAlD7knG;AAED,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE,YAAY,GAAG,SAAS,CAAC,GAAG;IACrD,OAAO,EAAE,OAAO,CAAC;CAClB,iBA4CF"}
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../../src/vite/__tests__/utilities/build.ts"],"names":[],"mappings":"AAEA,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,MAAM,CAAC;AAE9D,KAAK,OAAO,GAAG,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC;AAEpD,wBAAsB,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE;;;;;;;;;;;;;;;;;;;qBAiEynkG,CAAC;;;;;;;;;;;mCAA45C,CAAC;GAjDnmnG;AAED,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE,YAAY,GAAG,SAAS,CAAC,GAAG;IACrD,OAAO,EAAE,OAAO,CAAC;CAClB,iBA2CF"}
@@ -24,7 +24,6 @@ export async function buildApp(config) {
24
24
  ...config,
25
25
  build: {
26
26
  emptyOutDir: false,
27
- outDir: "dist",
28
27
  ...config.build,
29
28
  rollupOptions: {
30
29
  input: config.build?.rollupOptions?.input ?? "virtual:entry",
@@ -1 +1 @@
1
- {"version":3,"file":"build.js","sourceRoot":"","sources":["../../../../src/vite/__tests__/utilities/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,YAAY,EAAqB,MAAM,MAAM,CAAC;AAI9D,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,MAA2C;IAC3E,MAAM,MAAM,GAAG,MAAM,YAA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C,EAAE;oBACL,IAAI,EAAE,KAAK,eAAe;wBAAE,OAAO,oBAAoB,CAAC;oBAExD,IAAI,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC;wBACtB,OAAO,EAAE,CAAC,YAAY,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;oBACrC,CAAC;gBACH,CAAC;aACF;SACF;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { build, createServer, type InlineConfig } from \"vite\";\n\ntype Plugins = NonNullable<InlineConfig[\"plugins\"]>;\n\nexport async function setupServer(config: InlineConfig & { plugins: Plugins }) {\n const server = await createServer({\n configFile: false,\n server: {\n port: 3333,\n ...config.server,\n },\n ...config,\n });\n\n return {\n ...server,\n [Symbol.asyncDispose]() {\n return server.close();\n },\n };\n}\n\nexport async function buildApp(\n config: Omit<InlineConfig, \"configFile\" | \"plugins\"> & {\n plugins: Plugins;\n }\n) {\n await build({\n configFile: false,\n logLevel: \"silent\",\n ...config,\n build: {\n emptyOutDir: false,\n outDir: \"dist\",\n ...config.build,\n rollupOptions: {\n input: config.build?.rollupOptions?.input ?? \"virtual:entry\",\n },\n },\n plugins: [\n ...config.plugins,\n\n // We need to use `fs` to resolve modules to ensure vite uses memfs when\n // building, otherwise we get an ENOENT error for any files written to the\n // virtual filesystem.\n {\n name: \"test:virtual-entry\",\n resolveId(id) {\n if (id === \"virtual:entry\") return id;\n if (id.endsWith(\".html\")) return path.resolve(id);\n\n if (id.startsWith(\"/\")) {\n const resolved = path.resolve(id.slice(1));\n\n if (fs.existsSync(resolved)) {\n return resolved;\n }\n }\n },\n load(id) {\n if (id === \"virtual:entry\") return \"export default {};\";\n\n if (fs.existsSync(id)) {\n return fs.readFileSync(id, \"utf8\");\n }\n },\n },\n ],\n });\n}\n"]}
1
+ {"version":3,"file":"build.js","sourceRoot":"","sources":["../../../../src/vite/__tests__/utilities/build.ts"],"names":[],"mappings":"AAAA,OAAO,EA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C,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;wBAE3C,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;4BAC5B,OAAO,QAAQ,CAAC;wBAClB,CAAC;oBACH,CAAC;gBACH,CAAC;gBACD,IAAI,CAAC,EAAE;oBACL,IAAI,EAAE,KAAK,eAAe;wBAAE,OAAO,oBAAoB,CAAC;oBAExD,IAAI,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC;wBACtB,OAAO,EAAE,CAAC,YAAY,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;oBACrC,CAAC;gBACH,CAAC;aACF;SACF;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { build, createServer, type InlineConfig } from \"vite\";\n\ntype Plugins = NonNullable<InlineConfig[\"plugins\"]>;\n\nexport async function setupServer(config: InlineConfig & { plugins: Plugins }) {\n const server = await createServer({\n configFile: false,\n server: {\n port: 3333,\n ...config.server,\n },\n ...config,\n });\n\n return {\n ...server,\n [Symbol.asyncDispose]() {\n return server.close();\n },\n };\n}\n\nexport async function buildApp(\n config: Omit<InlineConfig, \"configFile\" | \"plugins\"> & {\n plugins: Plugins;\n }\n) {\n await build({\n configFile: false,\n logLevel: \"silent\",\n ...config,\n build: {\n emptyOutDir: false,\n ...config.build,\n rollupOptions: {\n input: config.build?.rollupOptions?.input ?? \"virtual:entry\",\n },\n },\n plugins: [\n ...config.plugins,\n\n // We need to use `fs` to resolve modules to ensure vite uses memfs when\n // building, otherwise we get an ENOENT error for any files written to the\n // virtual filesystem.\n {\n name: \"test:virtual-entry\",\n resolveId(id) {\n if (id === \"virtual:entry\") return id;\n if (id.endsWith(\".html\")) return path.resolve(id);\n\n if (id.startsWith(\"/\")) {\n const resolved = path.resolve(id.slice(1));\n\n if (fs.existsSync(resolved)) {\n return resolved;\n }\n }\n },\n load(id) {\n if (id === \"virtual:entry\") return \"export default {};\";\n\n if (fs.existsSync(id)) {\n return fs.readFileSync(id, \"utf8\");\n }\n },\n },\n ],\n });\n}\n"]}
@@ -6,6 +6,7 @@ export declare namespace apolloClientAiApps {
6
6
  interface Options {
7
7
  targets: Target[];
8
8
  devTarget?: Target | undefined;
9
+ appsOutDir: string;
9
10
  }
10
11
  }
11
12
  export declare function devTarget(target: string | undefined): "mcp" | "openai" | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"apolloClientAiApps.d.ts","sourceRoot":"","sources":["../../src/vite/apolloClientAiApps.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,MAAM,EAEZ,MAAM,MAAM,CAAC;AAId,OAAO,EAA4B,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAoB7E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAInE,MAAM,CAAC,OAAO,WAAW,kBAAkB,CAAC;IAC1C,KAAY,MAAM,GAAG,wBAAwB,CAAC,SAAS,CAAC;IAExD,UAAiB,OAAO;QACtB,OAAO,EAAE,MAAM,EAAE,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KAChC;CACF;AAgBD,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,gCAOnD;AAQD,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,kBAAkB,CAAC,OAAO,GAClC,MAAM,CA6QR;AA8ED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,YAAY,GAAG,YAAY,CA2CzE"}
1
+ {"version":3,"file":"apolloClientAiApps.d.ts","sourceRoot":"","sources":["../../src/vite/apolloClientAiApps.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,MAAM,EAEZ,MAAM,MAAM,CAAC;AAId,OAAO,EAA4B,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAoB7E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAKnE,MAAM,CAAC,O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